|Language Meta-Model Specification|
ast_relation(?Language, ?AstRelLabel : atom, ?AstNodeArguments : list) is nondet
- The nodes in the Abstract Syntax Tree (AST) for the language arg1 are linked by relations with type (label / functor) arg2 and arguments conforming to the Argument Descriptors in arg3. Relations do not have own identities. This is what distinguishes them from AST nodes. All identities occuring as arguments in a relation fact are references to other facts, which represent AST nodes. Example (excerpt from Java AST definition):
ast_relation('Java',extendsT,[ ast_arg(sub, mult(1,1,no ), id, [classT]), ast_arg(super, mult(1,1,no ), id, [classT]) ]).
- Relations can degenerate to simple attributes. Then they take the form of binary predicates with one argument being the id of some AST node and the other argument being the attribute value attached to that node. This makes sense if such arguments can be optional or multi-valued but unordered (Ordered multi-valued arguments are represented as lists). For instance, in the Java AST definition
modifierTadds various modifiers to elements such as classes, methods and fields:
ast_relation('Java',modifierT,[ ast_arg(id, mult(1,1,no ), id, [classT, fieldT, methodT, constructorT, classInitializerT]), ast_arg(modifier, mult(1,1,no ), attr, [atom]) ]).
- Relations can further degenerate to flags. Then they take the form of unary predicate with one single argument being the id of some AST node. For instance, in the Java AST definition
externTmarks classes available only as byte-code:
ast_relation('Java',externT,[ ast_arg(id, mult(1,1,no ), id, [classT]) ]).