3.1 asttransform.pl -- Properties of abstract syntax trees

author
Adrian Prantl <adrian@complang.tuwien.ac.at>
version
0.8.6-rc4
copyright
Copyright (C) 2007-2010 Adrian Prantl
license
See COPYING in the root folder of the SATIrE project

This module defines commonly-used transformation utilities for C/C++/Objective C ASTs given in the TERMITE term representation as exported by SATIrE.

simple_form_of(?Term, ?SimpleTerm)
This function is obsoleted, since SATIrE>0.7 defaults to the compact representation.

simple_form_of/2 is used to convert the verbose *nary_node() terms to a more compact representation

Example:

 unary_node(int_val, foo ...) <-> int_val(foo, ...)
[nondet]ast_node(?Node, ?Type, ?Children, ?Annot, ?Ai, ?Fi)
ast_node/6 (de)construct an AST node

Since all AST nodes follow the same structure, this predicate can be used to quickly compose or decompse a node.

[det]is_ast_node(+Node, -Type, -Children, -Annot, -Ai, -Fi)
Faster, uni-directional version of ast_node/6.
transformed_with(+Node, +Transformation, +Info, -Info1, -NodeT)
Backwards compatibile version of transformed_with/5:

collate_ast(Map, Reduce, A0, Node, A)
Perform a postorder traversal on the AST Node. For every Node visited call Map = f(Node, A_Children, A). For child nodes in the same hierarchy call foldl1(As, Reduce, A).
[det]unparse(+Term)
This predicate prints the original textual (source code) representation of the program encoded in Term. Output is written on stdout.

This predicate is especially useful for debugging purposes.

[det]needs_semicolon(+Node)
Succeeds if Node needs a semicolon ';' after itself during unparsing.
[det]needs_comma(+Node)
Succeeds if Node needs a comma ',' after itself during unparsing.
[det]replace_types(+InitializedNames, +FuncDecl, -InitializedNames1)
Replace the instantiated types with the original types from the function declaration.

Needed during unparsing.

[det]indent(+FileInfo)
Output the indentation that is encoded in FileInfo.
[det]unparse_ppi(+Location, +PPIs)
Print all preprocessing information(s) PPIs at Location.

Location must be one of [before, after, inside].