| Refresh | Home EGTry.com

imaginary nodes


antlr gammar to add imaginary node

grammar Rewrite;
options 
{
  output=AST;
}

tokens {
FOR;
END;
}

@lexer::header {
  package tree.rewrite;
}

@parser::header {
  package tree.rewrite;
}


prog: 'for' '(' 'init'? ';' 'predicate'? ';' 'update'? ')'  -> ^(FOR 'init'? END 'predicate'? END 'update'? END) 

;


WS: (' '|'\r'|'\n') {$channel=HIDDEN;};


input

for (  ; predicate; update)



output tree