summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorQuentin Carbonneaux <quentin.carbonneaux@yale.edu>2015-07-03 15:32:12 -0400
committerQuentin Carbonneaux <quentin.carbonneaux@yale.edu>2015-09-15 23:01:27 -0400
commit15be4030aca3dac7edffb75c55088c8b97a89435 (patch)
tree42efe31be8f80a58611b753c5c1f0edbea4def4d
parenta7f459b291b5cf7bc4f62061cadb14a93b0c29c1 (diff)
downloadroux-15be4030aca3dac7edffb75c55088c8b97a89435.tar.gz
factoring? in the lexer
-rw-r--r--lisc/parse.c18
1 files changed, 10 insertions, 8 deletions
diff --git a/lisc/parse.c b/lisc/parse.c
index dd8f67f..a1b27d3 100644
--- a/lisc/parse.c
+++ b/lisc/parse.c
@@ -119,6 +119,14 @@ lex()
return TRParen;
case '=':
return TEq;
+ case '%':
+ t = TVar;
+ c = fgetc(inf);
+ goto Alpha;
+ case '@':
+ t = TLbl;
+ c = fgetc(inf);
+ goto Alpha;
case '#':
while (fgetc(inf) != '\n')
;
@@ -145,14 +153,8 @@ lex()
tokval.num *= sgn;
return TNum;
}
- if (c == '%') {
- t = TVar;
- c = fgetc(inf);
- } else if (c == '@') {
- t = TLbl;
- c = fgetc(inf);
- } else
- t = TXXX;
+ t = TXXX;
+Alpha:
if (!isalpha(c))
err("lexing failure");
i = 0;