Merge branch 'main' of gitlab.cs.wallawalla.edu:lustje/language-interpreter-lab into josh3
This commit is contained in:
commit
92aa812da7
|
|
@ -44,7 +44,7 @@ UTEST(scanner, hello) {
|
|||
int index = 0;
|
||||
token_t t;
|
||||
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_STREQ(tokens[index].p, yytext);
|
||||
++index;
|
||||
|
|
|
|||
|
|
@ -60,22 +60,9 @@ int yylex();
|
|||
%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) {
|
||||
fprintf(stderr, "Error | Line: %d\n%s\n",yylineno,msg);
|
||||
|
|
|
|||
Loading…
Reference in New Issue