Advertisement
Guest User

Untitled

a guest
Apr 25th, 2018
64
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.68 KB | None | 0 0
  1. function_declare returns [ASTNode node]:
  2. FUNCTION name=ID {
  3. List<String> paramIds = new ArrayList<>();
  4. List<ASTNode> body = new ArrayList<>();
  5. } PAR_OPEN ( id0=ID {
  6. paramIds.add($id0.text);
  7. } (COMMA id1=ID {
  8. paramIds.add($id1.text);
  9. } )* )? PAR_CLOSE BRACKET_OPEN ( sentence {
  10. body.add($sentence.node);
  11. } )*
  12. BRACKET_CLOSE{
  13. $node = new FunctionDeclare( $name.text , paramIds , body );
  14. };
  15.  
  16. function_ref returns [ASTNode node]:
  17. ID {
  18. List<ASTNode> params = new ArrayList<>();
  19. }
  20. PAR_OPEN ( e0=expression {
  21. params.add($e0.node);
  22. }(COMMA e1=expression {
  23. params.add($e1.node);
  24. })* )? PAR_CLOSE{
  25. $node = new FunctionRef( $ID.text , params );
  26. };
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement