• API
• FAQ
• Tools
• Trends
• Archive
daily pastebin goal
13%
SHARE
TWEET

# Untitled

a guest Aug 12th, 2017 51 Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
1. %%
2.
3. top: supergoal { rootnode=\$1; \$\$=\$1; }
4.     ;
5.
6. supergoal: goal  {}
7.     | supergoal goal {}
8.     ;
9.
10. goal : VAR '=' expression';' { \$\$ = make_node('=', \$1, \$3); }
11.     | VAR PLUSEQUALS expression';' {\$\$ = make_node(PLUSEQUALS, \$1, \$3); }
12.     | VAR MINUSEQUALS expression';' { \$\$ = make_node(MINUSEQUALS, \$1, \$3); }
13.     | ifstatement';' {}
14.     | whilestatement';' {}
15.     | INT_DECLARE variable_list';' {}
16.     | DOUBLE_DECLARE variable_list';' {}
17.     ;
18.
19. expression : term '+' term { \$\$ = make_node('+', \$1, \$3); }
20.     | term '-' term { \$\$ = make_node('-', \$1, \$3); }
21.     | term {}
22.     ;
23.
24. term : factor '*' factor { \$\$ = make_node('*', \$1, \$3); }
25.     | factor '%' factor {\$\$ = make_node('%', \$1, \$3); }
26.     | factor {}
27.     ;
28.
29. factor : VAR {}
30.     | INT {}
31.     | FLOAT {}
32.     | STRING {}
33.     | '(' expression ')' { \$\$ = \$2; }
34.     ;
35.
36. ifstatement : IF '(' expression ')' goal ELSE goal {}
37.     | IF '(' expression ')' goal {}
38.     ;
39.
40. whilestatement : WHILE '(' expression ')' goal {}
41.     ;
42.
43. variable_list : VAR {}
44.     | variable_list ',' VAR {}
45.     ;
46.
47. %%
RAW Paste Data
Top