Cart prefix instead of postfix in antlr

I know what postfix postter means in antlr (i.e. make root), but what about when the carriage is a prefix, like in the next grammar I read (this grammar is brand new and executed by a new command learning antlr) ....

selectClause
    : SELECT resultList -> ^(SELECT_CLAUSE resultList) 
    ;


fromClause
    : FROM tableList -> ^(FROM_CLAUSE tableList) 
    ;

Also, I know what => means, but what about →? What does → mean?

thanks dean

+5
source share
1 answer

^ used as an operator of the embedded tree, indicating that a specific token should become the root of the tree.

For example, the rule:

p : A B^ C;

creates the following AST:

  B
 / \
A   C

AST, . ( ) . "", ->, /, AST.

:

p : A B C;

, ASST "" ( node). , :

p : A B C -> C B A;

AST, p : A B^ C;, ^( ... ), / node. , :

p : A B C -> ^(B A C);

, p : A B^ C;.


:

+6

All Articles