Advertisement
Guest User

Untitled

a guest
Mar 26th, 2019
89
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 2.16 KB | None | 0 0
  1. VarsAndStatements: %empty {$$=insereNo(NULL,"NULL");}
  2. | VarsAndStatements SEMICOLON {$$=$1;}
  3. | VarsAndStatements VarDeclaration SEMICOLON {$$=$1;insereNoIrmao($1,$2);}
  4. | VarsAndStatements Statement SEMICOLON {$$=$1; insereNoIrmao($1,$2);}
  5. ;
  6.  
  7.  
  8. Statement: ID ASSIGN Expr {$$=insereNo(NULL, "Assign"); $$->filho = insereNo($1, "Id"); insereNoIrmao($$->filho, $3); }
  9. | LBRACE StatementAux RBRACE {$$=$2;}
  10. | IF Expr LBRACE StatementAux RBRACE {$$=insereNo(NULL, "If"); $$->filho=$3;}
  11. | IF Expr LBRACE StatementAux RBRACE ELSE LBRACE StatementAux RBRACE {$$=insereNo(NULL, "If"); $$->filho=$3;}
  12. | FOR LBRACE StatementAux RBRACE {$$=insereNo(NULL, "For"); $$->filho=$3;} /*cock block*/
  13. | FOR Expr LBRACE StatementAux RBRACE {$$=insereNo(NULL, "For"); $$->filho = $2;}
  14. | RETURN {$$=insereNo(NULL, "Return");}
  15. | RETURN Expr {$$=insereNo(NULL, "Return"); $$->filho = $2;}
  16. | FuncInvocation {$$=insereNo(NULL, "Call"); $$->filho=$1;}
  17. | ParseArgs {$$=insereNo(NULL, "ParseArgs"); $$->filho = $1;}
  18. | PRINT LPAR Expr RPAR {$$=insereNo(NULL, "Print"); $$->filho = $3;}
  19. | PRINT LPAR STRLIT RPAR {$$=insereNo(NULL, "Print"); $$->filho=insereNo($3, "StrLit");}
  20. | error {$$=insereNo(NULL, "NULL");}
  21. ;
  22.  
  23. StatementAux: %empty {$$=insereNo(NULL, "NULL");}
  24. | Statement SEMICOLON StatementAux {$$=$1; /*insereNoIrmao($$, $3);*/}
  25. ;
  26.  
  27. ParseArgs: ID COMMA BLANKID ASSIGN PARSEINT LPAR CMDARGS LSQ Expr RSQ RPAR {$$=insereNo($1, "Id"); insereNoIrmao($$, $9);}
  28. | ID COMMA BLANKID ASSIGN PARSEINT LPAR error RPAR {$$=insereNo(NULL, "NULL");}
  29. ;
  30.  
  31. FuncInvocation:
  32. ID LPAR RPAR {$$=insereNo(NULL, "Id");}
  33. | ID LPAR Expr FuncInvocationAux RPAR {$$=insereNo(NULL, "Id"); insereNoIrmao($$,$3); insereNoIrmao($3, $4);}
  34. | ID LPAR error RPAR {$$=insereNo(NULL, "NULL");}
  35. ;
  36.  
  37. FuncInvocationAux: %empty {$$=insereNo(NULL, "NULL");}
  38. | COMMA Expr FuncInvocationAux {$$=$2; insereNoIrmao($$, $3);}
  39. ;
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement