fixed last bugs
This commit is contained in:
parent
6bbc6c2d30
commit
9439274586
2 changed files with 7 additions and 4 deletions
2
testFile
2
testFile
|
@ -9,7 +9,7 @@ int compute(int a, int d) {
|
|||
}
|
||||
|
||||
|
||||
void main(void) {
|
||||
void main(int a) {
|
||||
int a;
|
||||
if (a == 3) {
|
||||
print(a);
|
||||
|
|
9
yacc.y
9
yacc.y
|
@ -1,3 +1,5 @@
|
|||
%define parse.error detailed
|
||||
|
||||
%{
|
||||
#include <stdio.h>
|
||||
#include <stdlib.h>
|
||||
|
@ -108,7 +110,8 @@ Expressions : Expression
|
|||
|
||||
FunctionCall : tID tLPAR Expressions tRPAR;
|
||||
|
||||
FunctionDef : Type tID FunctionParams InnerBlock;
|
||||
FunctionDef : Type tID FunctionParams InnerBlock
|
||||
| tVOID tID FunctionParams InnerBlock;
|
||||
|
||||
/*FunctionParams = the parameters of a function*/
|
||||
FunctionParams : tLPAR tRPAR
|
||||
|
@ -122,8 +125,8 @@ VarsWithType : VarWithType
|
|||
VarWithType : Type tID;
|
||||
|
||||
/*the return type or argument type*/
|
||||
Type : tINT {$$ = /*INT*/ 0;}
|
||||
| tFLOAT {$$ = /*FLOAT*/ 1;};
|
||||
Type : tINT {$$ = INT;}
|
||||
| tFLOAT {$$ = FLOAT;};
|
||||
|
||||
Declaration : Type tID tSEMI {addElement($2, (enumVarType) $1);}
|
||||
| Type tID tASSIGN Expression tSEMI {addElement($2, $1);setInit($2);}
|
||||
|
|
Loading…
Reference in a new issue