Merge branch 'main' of gitlab.cs.wallawalla.edu:lustje/language-interpreter-lab

This commit is contained in:
Jenessy Lustre 2024-10-24 22:52:46 -07:00
commit 67c7707d8e
2 changed files with 1 additions and 14 deletions

View File

@ -43,7 +43,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;

View File

@ -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);