For a programming project, I am tasked with taking a set of ANTLR grammar rules for Java and extending them such that they also contain AST rules for the Eclipse JDT API DOM.
For example:
param
: type ID
;
Would become:
param returns [SingleVariableDeclaration result = ast.newSingleVariableDeclaration()]
: paramType=type { result.setType($paramType.result); }
ID { result.setName(ast.newSimpleName($ID.text)); }
;
The first part of the project was creating the grammer rules themselves, and that wasn't too bad, but this part is really throwing me for a loop. Are there any useful resources, examples, or pointers someone could give me as far as adding the AST rules are concerned?
One of the tips I was given was to use the AST viewer in Eclipse to help pinpoint which parts of the API to look at in the Eclipse documentation, but I'm not sure how this helps.
Some of the rules I need to implement yet are array access, for loops, and so on.
Thanks!