diff --git a/testFile b/testFile index 3dad2fd..6f11653 100644 --- a/testFile +++ b/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); diff --git a/yacc.y b/yacc.y index 4a07cc7..f4013ba 100644 --- a/yacc.y +++ b/yacc.y @@ -1,3 +1,5 @@ +%define parse.error detailed + %{ #include #include @@ -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);}