diff options
| author | Quentin Carbonneaux | 2015-03-02 19:07:22 -0500 |
|---|---|---|
| committer | Quentin Carbonneaux | 2015-03-02 19:07:22 -0500 |
| commit | e04b84c61b262d55ea28bed6837f12e514e81e70 (patch) | |
| tree | 1f9aa69128d5bd84f2dc0cf1f5d1dbd96069f563 | |
| parent | 77e6f3a27f34b8196e6b90409f036714a62f58dd (diff) | |
use the nice tokens in the test
| -rw-r--r-- | t.y | 21 |
1 files changed, 14 insertions, 7 deletions
@@ -43,17 +43,24 @@ enum { char line[MaxLine], *p; int -lex() +yyerror() +{ + puts("oops"); +} + +int +yylex() { char c; p += strspn(p, "\t "); switch ((c=*p++)) { - case '+': return 2; - case '-': return 3; - case '*': return 4; - case '(': return 5; - case ')': return 6; + case '+': + case '-': + case '*': + case '(': + case ')': + return c; case 0: case '\n': p--; @@ -61,7 +68,7 @@ lex() } if (isdigit(c)) { yylval.num = strtol(p-1, &p, 0); - return 1; + return NUM; } puts("lex error!"); return 0; |
