浏览代码

small changes in 'ugly' part.

Roberto Ierusalimschy 31 年之前
父节点
当前提交
e4645c835d
共有 2 个文件被更改,包括 26 次插入19 次删除
  1. 12 17
      lex.c
  2. 14 2
      ugly.h

+ 12 - 17
lex.c

@@ -1,4 +1,4 @@
-char *rcs_lex = "$Id: lex.c,v 2.8 1994/10/18 17:34:34 celes Exp roberto $";
+char *rcs_lex = "$Id: lex.c,v 2.9 1994/11/03 17:09:20 roberto Exp roberto $";
  
 
 #include <ctype.h>
@@ -246,22 +246,17 @@ fraction:
           yylval.vFloat = a;
           return NUMBER;
         }
-      case U_and:	next(); return AND;
-      case U_do:	next(); return DO;
-      case U_else:	next(); return ELSE;
-      case U_elseif:	next(); return ELSEIF;
-      case U_end:	next(); return END;
-      case U_function:	next(); return FUNCTION;
-      case U_if:	next(); return IF;
-      case U_local:	next(); return LOCAL;
-      case U_nil:	next(); return NIL;
-      case U_not:	next(); return NOT;
-      case U_or:	next(); return OR;
-      case U_repeat:	next(); return REPEAT;
-      case U_return:	next(); return RETURN;
-      case U_then:	next(); return THEN;
-      case U_until:	next(); return UNTIL;
-      case U_while:	next(); return WHILE;
+
+      case U_and: case U_do: case U_else: case U_elseif: case U_end:
+      case U_function: case U_if: case U_local: case U_nil: case U_not:
+      case U_or: case U_repeat: case U_return: case U_then:
+      case U_until: case U_while:
+      {
+        int old = current;
+        next();
+        return reserved[old-U_and].token;
+      }
+
       case U_eq:	next(); return EQ;
       case U_le:	next(); return LE;
       case U_ge:	next(); return GE;

+ 14 - 2
ugly.h

@@ -1,5 +1,15 @@
-enum
-{
+/*
+** ugly.h
+** TecCGraf - PUC-Rio
+** $Id: $
+*/
+
+#ifndef ugly_h
+#define ugly_h
+
+/* This enum must have the same order of the array 'reserved' in lex.c */
+
+enum {
  U_and=128,
  U_do,
  U_else,
@@ -22,3 +32,5 @@ enum
  U_ne = '~'+128,
  U_sc = '.'+128
 };
+
+#endif