summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorQuentin Carbonneaux2015-03-02 19:07:22 -0500
committerQuentin Carbonneaux2015-03-02 19:07:22 -0500
commite04b84c61b262d55ea28bed6837f12e514e81e70 (patch)
tree1f9aa69128d5bd84f2dc0cf1f5d1dbd96069f563
parent77e6f3a27f34b8196e6b90409f036714a62f58dd (diff)
use the nice tokens in the test
-rw-r--r--t.y21
1 files changed, 14 insertions, 7 deletions
diff --git a/t.y b/t.y
index 7dbb785..b8a184e 100644
--- a/t.y
+++ b/t.y
@@ -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;