clean up bison file
This commit is contained in:
parent
f01cb2ce5b
commit
454a56fc8f
|
|
@ -43,7 +43,7 @@ UTEST(scanner, hello) {
|
||||||
int index = 0;
|
int index = 0;
|
||||||
token_t t;
|
token_t t;
|
||||||
do {
|
do {
|
||||||
printf("index: %d token: %d text: %s\n", index, t, yytext);
|
// printf("index: %d token: %d text: %s\n", index, t, yytext);
|
||||||
ASSERT_EQ(tokens[index].t, (t = yylex()));
|
ASSERT_EQ(tokens[index].t, (t = yylex()));
|
||||||
ASSERT_STREQ(tokens[index].p, yytext);
|
ASSERT_STREQ(tokens[index].p, yytext);
|
||||||
++index;
|
++index;
|
||||||
|
|
|
||||||
|
|
@ -60,22 +60,9 @@ int yylex();
|
||||||
%token TOKEN_EXPONENTIAL
|
%token TOKEN_EXPONENTIAL
|
||||||
|
|
||||||
%%
|
%%
|
||||||
program : expr TOKEN_SEMI;
|
|
||||||
|
|
||||||
expr : expr TOKEN_PLUS term
|
|
||||||
| expr TOKEN_MINUS term
|
|
||||||
| term
|
|
||||||
;
|
|
||||||
|
|
||||||
term : term TOKEN_MUL factor
|
|
||||||
| term TOKEN_DIV factor
|
|
||||||
| factor
|
|
||||||
;
|
|
||||||
|
|
||||||
factor: TOKEN_MINUS factor
|
|
||||||
| TOKEN_LPAREN expr TOKEN_RPAREN
|
|
||||||
| TOKEN_INT
|
|
||||||
;
|
|
||||||
%%
|
%%
|
||||||
void yyerror(const char* msg) {
|
void yyerror(const char* msg) {
|
||||||
fprintf(stderr, "Error | Line: %d\n%s\n",yylineno,msg);
|
fprintf(stderr, "Error | Line: %d\n%s\n",yylineno,msg);
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue