diff --git a/Makefile b/Makefile index 6fefed1..6a8e88d 100644 --- a/Makefile +++ b/Makefile @@ -4,7 +4,7 @@ FLEX := flex BISON = bison CFLAGS := -ggdb -BISONFLAGS := -d +BISONFLAGS := -d -Wcounterexamples LEX := src/lexicalStructure.lex YACC := src/grammar.y diff --git a/src/grammar.y b/src/grammar.y index 1bad825..36741e3 100644 --- a/src/grammar.y +++ b/src/grammar.y @@ -106,7 +106,6 @@ program: prototype_or_definition_list - | error { yyerrok; } ; @@ -116,15 +115,14 @@ prototype_or_definition_list: | definition prototype_or_definition_list | prototype | definition - | error { yyerrok; } + | prototype error { yyerrok; } + | definition error { yyerrok; } ; prototype: L_PAREN EXTERNAL R_PAREN FUNCTION ID COLON ID - - | error { yyerrok; } ; @@ -355,8 +353,6 @@ idlist: printdebug("Type of entry is %s", getType(entry)); printdebug("tag is %d", getAdInfoType(entry)); } - - | error { yyerrok; } ; @@ -405,8 +401,6 @@ sblock: } R_BRACE {$$ = $5;} - - | error { yyerrok; } ; @@ -427,7 +421,6 @@ dblock: } declaration_list R_BRACKET - | error { yyerrok; } ; @@ -436,8 +429,7 @@ dblock: declaration_list: declaration SEMI_COLON declaration_list | declaration - - | error { yyerrok; } + | error SEMI_COLON { yyerrok; } declaration_list //only perform error recovery once we see semi-colon ; @@ -477,8 +469,6 @@ declaration: CreateEntry(cur,d,(TableNode*)$1,$3,getAdInfo((TableNode*)$1)); } } - - | error { yyerrok; } ; @@ -496,8 +486,6 @@ id_or_types: printdebug("string of type is %s in types pattern of id_or_type rule.",getName((TableNode*)$1)); $$ = (TableNode*)$1; } - - | error { yyerrok; } ; @@ -550,6 +538,7 @@ compound_statement statement_list { | simple_statement SEMI_COLON { $$ = $1; } + | error SEMI_COLON { yyerrok; } statement_list { $$ = $4; } ; @@ -631,8 +620,8 @@ simple_statement: | RETURN expression {$$ = getTypeEntry((TableNode*)$2);} + |simple_statement error {yyerrok; printdebug("error in simple statement");} - | error { yyerrok; } ; @@ -641,7 +630,6 @@ simple_statement: rec_op: DOT - | error { yyerrok; } ; @@ -653,7 +641,6 @@ ablock: printdebug("ablock is %d", $$); } - | error { yyerrok; } ; @@ -674,7 +661,6 @@ argument_list: $$ = 1; printdebug("[ARGUMENT_LIST] argument list is %d", $$); } - | error { yyerrok; } ; @@ -872,8 +858,6 @@ expression: $$=undefined; } } - - | error { yyerrok; } ; @@ -1058,7 +1042,6 @@ assignable: printdebug("[ASSIGNABLE - RULE 3] record = name: %s | field = %s", getName((TableNode*)($1)), getName((TableNode*)$3)); } - | error { yyerrok; } ; @@ -1075,7 +1058,6 @@ memOp: printdebug("release expression"); } - | error { yyerrok; } ; @@ -1260,3 +1242,4 @@ void yyerror(const char *err) { } } } +