Browse Source

Remove compat code in parser when not needed

Roberto Ierusalimschy 2 tháng trước cách đây
mục cha
commit
fded0b4a84
2 tập tin đã thay đổi với 5 bổ sung2 xóa
  1. 1 1
      llex.c
  2. 4 1
      lparser.c

+ 1 - 1
llex.c

@@ -41,7 +41,7 @@
 #define currIsNewline(ls)	(ls->current == '\n' || ls->current == '\r')
 
 #if defined(LUA_COMPAT_GLOBAL)
-#define GLOBALLEX	".g"	/* not recognizable by the scanner */
+#define GLOBALLEX	".g"	/* anything not recognizable as a name */
 #else
 #define GLOBALLEX	"global"
 #endif

+ 4 - 1
lparser.c

@@ -1997,6 +1997,7 @@ static void statement (LexState *ls) {
       gotostat(ls, line);
       break;
     }
+#if defined(LUA_COMPAT_GLOBAL)
     case TK_NAME: {
       /* compatibility code to parse global keyword when "global"
          is not reserved */
@@ -2008,7 +2009,9 @@ static void statement (LexState *ls) {
           break;
         }
       }  /* else... */
-    }  /* FALLTHROUGH */
+    }
+#endif
+    /* FALLTHROUGH */
     default: {  /* stat -> func | assignment */
       exprstat(ls);
       break;