aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorRoberto Ierusalimschy <roberto@inf.puc-rio.br>2001-06-20 18:07:57 -0300
committerRoberto Ierusalimschy <roberto@inf.puc-rio.br>2001-06-20 18:07:57 -0300
commitfccadba4b54f8e13c8b9cfc97307f53931496936 (patch)
tree12c65eb6653b386358b932794fa7afb9c48ae6bb
parentb940f09984b47979caf8142046e1fe813e531e3d (diff)
downloadlua-fccadba4b54f8e13c8b9cfc97307f53931496936.tar.gz
lua-fccadba4b54f8e13c8b9cfc97307f53931496936.tar.bz2
lua-fccadba4b54f8e13c8b9cfc97307f53931496936.zip
new reserved words `in' and `global'
-rw-r--r--llex.c11
-rw-r--r--llex.h7
-rw-r--r--lparser.c9
3 files changed, 12 insertions, 15 deletions
diff --git a/llex.c b/llex.c
index c921b1b4..6ca4ef75 100644
--- a/llex.c
+++ b/llex.c
@@ -1,5 +1,5 @@
1/* 1/*
2** $Id: llex.c,v 1.86 2001/06/13 14:25:49 roberto Exp roberto $ 2** $Id: llex.c,v 1.87 2001/06/15 20:36:57 roberto Exp roberto $
3** Lexical Analyzer 3** Lexical Analyzer
4** See Copyright Notice in lua.h 4** See Copyright Notice in lua.h
5*/ 5*/
@@ -28,10 +28,11 @@
28/* ORDER RESERVED */ 28/* ORDER RESERVED */
29static const l_char *const token2string [] = { 29static const l_char *const token2string [] = {
30 l_s("and"), l_s("break"), l_s("do"), l_s("else"), l_s("elseif"), 30 l_s("and"), l_s("break"), l_s("do"), l_s("else"), l_s("elseif"),
31 l_s("end"), l_s("for"), l_s("function"), l_s("if"), l_s("local"), 31 l_s("end"), l_s("for"), l_s("function"), l_s("global"), l_s("if"),
32 l_s("nil"), l_s("not"), l_s("or"), l_s("repeat"), l_s("return"), 32 l_s("in"), l_s("local"), l_s("nil"), l_s("not"), l_s("or"), l_s("repeat"),
33 l_s("then"), l_s("until"), l_s("while"), l_s(""), l_s(".."), l_s("..."), 33 l_s("return"), l_s("then"), l_s("until"), l_s("while"), l_s(""),
34 l_s("=="), l_s(">="), l_s("<="), l_s("~="), l_s(""), l_s(""), l_s("<eof>") 34 l_s(".."), l_s("..."), l_s("=="), l_s(">="), l_s("<="), l_s("~="),
35 l_s(""), l_s(""), l_s("<eof>")
35}; 36};
36 37
37 38
diff --git a/llex.h b/llex.h
index 4a4370f7..6d0cba47 100644
--- a/llex.h
+++ b/llex.h
@@ -1,5 +1,5 @@
1/* 1/*
2** $Id: llex.h,v 1.34 2001/02/23 17:17:25 roberto Exp roberto $ 2** $Id: llex.h,v 1.35 2001/03/06 14:46:54 roberto Exp roberto $
3** Lexical Analyzer 3** Lexical Analyzer
4** See Copyright Notice in lua.h 4** See Copyright Notice in lua.h
5*/ 5*/
@@ -24,8 +24,9 @@
24enum RESERVED { 24enum RESERVED {
25 /* terminal symbols denoted by reserved words */ 25 /* terminal symbols denoted by reserved words */
26 TK_AND = FIRST_RESERVED, TK_BREAK, 26 TK_AND = FIRST_RESERVED, TK_BREAK,
27 TK_DO, TK_ELSE, TK_ELSEIF, TK_END, TK_FOR, TK_FUNCTION, TK_IF, TK_LOCAL, 27 TK_DO, TK_ELSE, TK_ELSEIF, TK_END, TK_FOR, TK_FUNCTION, TK_GLOBAL, TK_IF,
28 TK_NIL, TK_NOT, TK_OR, TK_REPEAT, TK_RETURN, TK_THEN, TK_UNTIL, TK_WHILE, 28 TK_IN, TK_LOCAL, TK_NIL, TK_NOT, TK_OR, TK_REPEAT, TK_RETURN, TK_THEN,
29 TK_UNTIL, TK_WHILE,
29 /* other terminal symbols */ 30 /* other terminal symbols */
30 TK_NAME, TK_CONCAT, TK_DOTS, TK_EQ, TK_GE, TK_LE, TK_NE, TK_NUMBER, 31 TK_NAME, TK_CONCAT, TK_DOTS, TK_EQ, TK_GE, TK_LE, TK_NE, TK_NUMBER,
31 TK_STRING, TK_EOS 32 TK_STRING, TK_EOS
diff --git a/lparser.c b/lparser.c
index fa6ada93..28f0c4b8 100644
--- a/lparser.c
+++ b/lparser.c
@@ -1,5 +1,5 @@
1/* 1/*
2** $Id: lparser.c,v 1.148 2001/06/11 14:56:42 roberto Exp roberto $ 2** $Id: lparser.c,v 1.149 2001/06/12 14:36:48 roberto Exp roberto $
3** LL(1) Parser and code generator for Lua 3** LL(1) Parser and code generator for Lua
4** See Copyright Notice in lua.h 4** See Copyright Notice in lua.h
5*/ 5*/
@@ -960,12 +960,7 @@ static void forlist (LexState *ls, TString *indexname) {
960 TString *valname; 960 TString *valname;
961 check(ls, l_c(',')); 961 check(ls, l_c(','));
962 valname = str_checkname(ls); 962 valname = str_checkname(ls);
963 /* next test is dirty, but avoids `in' being a reserved word */ 963 check(ls, TK_IN);
964 check_condition(ls,
965 (ls->t.token == TK_NAME &&
966 ls->t.seminfo.ts == luaS_newliteral(ls->L, l_s("in"))),
967 l_s("`in' expected"));
968 next(ls); /* skip `in' */
969 exp1(ls); /* table */ 964 exp1(ls); /* table */
970 new_localvarstr(ls, l_s("(table)"), 0); 965 new_localvarstr(ls, l_s("(table)"), 0);
971 new_localvarstr(ls, l_s("(index)"), 1); 966 new_localvarstr(ls, l_s("(index)"), 1);