aboutsummaryrefslogtreecommitdiff
path: root/src/tpc.y
diff options
context:
space:
mode:
authorpacien2018-06-05 13:41:13 +0200
committerpacien2018-06-05 13:41:13 +0200
commit8f6dd273479bdc7789d40a235b0afb6598fd0435 (patch)
tree3f30d4b2869e3460a587ab9e7708afe4a8cacca7 /src/tpc.y
parent7a966d25b34f4bd37f32a18f7e8a62b6f97186e6 (diff)
downloadtpc-compiler-8f6dd273479bdc7789d40a235b0afb6598fd0435.tar.gz
Handle func return
Diffstat (limited to 'src/tpc.y')
-rw-r--r--src/tpc.y11
1 files changed, 6 insertions, 5 deletions
diff --git a/src/tpc.y b/src/tpc.y
index e8f2e41..3bd3df4 100644
--- a/src/tpc.y
+++ b/src/tpc.y
@@ -20,6 +20,7 @@ extern int lineno;
20int yylex(); 20int yylex();
21void yyerror(char *); 21void yyerror(char *);
22static Scope scope = GLOBAL; 22static Scope scope = GLOBAL;
23static Type return_type = VOID;
23static int bss_done = 0; 24static int bss_done = 0;
24static int num_label = 0; 25static int num_label = 0;
25static int num_if = 0; 26static int num_if = 0;
@@ -88,11 +89,11 @@ DeclFoncts:
88; 89;
89DeclFonct: 90DeclFonct:
90 EnTeteFonct { scope = LOCAL; } 91 EnTeteFonct { scope = LOCAL; }
91 Corps { gen_function_end_declaration(); scope = GLOBAL; } 92 Corps { gen_function_end_declaration(); scope = GLOBAL; return_type = VOID; }
92; 93;
93EnTeteFonct: 94EnTeteFonct:
94 TYPE IDENT PrologueCont '(' Parametres ')' {gen_function_declaration($<ident>2, $<type>1, $5);} 95 TYPE IDENT PrologueCont '(' Parametres ')' { return_type = gen_function_declaration($<ident>2, $<type>1, $5); }
95| VOID IDENT PrologueCont '(' Parametres ')' {gen_function_declaration($<ident>2, 2, $5);} 96| VOID IDENT PrologueCont '(' Parametres ')' { return_type = gen_function_declaration($<ident>2, VOID, $5); }
96; 97;
97 98
98PrologueCont: {gen_prologue_continue(&bss_done);}; 99PrologueCont: {gen_prologue_continue(&bss_done);};
@@ -115,8 +116,8 @@ SuiteInstr:
115Instr: 116Instr:
116 Exp ';' 117 Exp ';'
117| ';' 118| ';'
118| RETURN Exp ';' 119| RETURN Exp ';' { gen_function_return(return_type, $<type>2); scope = GLOBAL; return_type = VOID; }
119| RETURN ';' 120| RETURN ';' { gen_function_return(return_type, VOID); scope = GLOBAL; return_type = VOID; }
120| READE '(' IDENT ')' ';' { gen_reade($<ident>3); } 121| READE '(' IDENT ')' ';' { gen_reade($<ident>3); }
121| READC '(' IDENT ')' ';' { gen_readc($<ident>3); } 122| READC '(' IDENT ')' ';' { gen_readc($<ident>3); }
122| PRINT '(' Exp ')' ';' { gen_print($<type>3);} 123| PRINT '(' Exp ')' ';' { gen_print($<type>3);}