aboutsummaryrefslogtreecommitdiff
path: root/src/tpc.y
diff options
context:
space:
mode:
Diffstat (limited to 'src/tpc.y')
-rw-r--r--src/tpc.y23
1 files changed, 17 insertions, 6 deletions
diff --git a/src/tpc.y b/src/tpc.y
index 7321780..ff95f64 100644
--- a/src/tpc.y
+++ b/src/tpc.y
@@ -79,12 +79,12 @@ DeclVars:
79| 79|
80; 80;
81Declarateurs: 81Declarateurs:
82 Declarateurs ',' Declarateur { gen_declaration($<ident>3, $<type>0, scope); } 82 Declarateurs ',' Declarateur
83| Declarateur { gen_declaration($<ident>1, $<type>0, scope); } 83| Declarateur
84; 84;
85Declarateur: 85Declarateur:
86 IDENT 86 IDENT { gen_declaration($<ident>1, $<type>0, scope);}
87| IDENT '[' NUM ']' 87| IDENT '[' NUM ']' { gen_tab_declaration($<ident>1, scope, $<num>3);}
88; 88;
89DeclFoncts: 89DeclFoncts:
90 DeclFoncts DeclFonct 90 DeclFoncts DeclFonct
@@ -133,7 +133,13 @@ IfHandling: { gen_if_start($<num>$ = num_if++); };
133IfEndHandling: { gen_if_end($<num>-3); }; 133IfEndHandling: { gen_if_end($<num>-3); };
134IfElseEndHandling: { gen_ifelse_end($<num>-5); }; 134IfElseEndHandling: { gen_ifelse_end($<num>-5); };
135Exp: 135Exp:
136 LValue '=' Exp { $$ = gen_assign($<ident>1, scope); } 136 LValue '=' Exp {
137 if(loc_lookup($<ident>1) != TAB){
138 $$ = gen_assign($<ident>1, scope);
139 }else{
140 $$ = gen_assign_tab($<ident>1,scope);
141 }
142 }
137| EB 143| EB
138; 144;
139EB: 145EB:
@@ -164,7 +170,12 @@ F:
164 ADDSUB F { $$ = gen_signed_expr($1, $2); } 170 ADDSUB F { $$ = gen_signed_expr($1, $2); }
165| '!' F { $$ = gen_negate_expr($2); } 171| '!' F { $$ = gen_negate_expr($2); }
166| '(' Exp ')' { $$ = $2; } 172| '(' Exp ')' { $$ = $2; }
167| LValue { $$ = gen_value($<ident>1, scope); } 173| LValue { if(loc_lookup($<ident>1) != TAB){
174 $$ = gen_value($<ident>1, scope);
175 }else{
176 $$ = gen_value_tab($<ident>1,scope);
177 }
178 }
168| NUM { $$ = gen_num($1, scope); } 179| NUM { $$ = gen_num($1, scope); }
169| CARACTERE { $$ = gen_char($1, scope); } 180| CARACTERE { $$ = gen_char($1, scope); }
170| IDENT '(' Arguments ')' { $$ = gen_function_call($<ident>1,$<num>3); } 181| IDENT '(' Arguments ')' { $$ = gen_function_call($<ident>1,$<num>3); }