File tree Expand file tree Collapse file tree 1 file changed +14
-9
lines changed Expand file tree Collapse file tree 1 file changed +14
-9
lines changed Original file line number Diff line number Diff line change @@ -79,6 +79,7 @@ local NLMap = {
7979local LineMulti = 10000
8080
8181-- goto 单独处理
82+ -- global 单独处理
8283local KeyWord = {
8384 [' and' ] = true ,
8485 [' break' ] = true ,
@@ -89,7 +90,6 @@ local KeyWord = {
8990 [' false' ] = true ,
9091 [' for' ] = true ,
9192 [' function' ] = true ,
92- [' global' ] = true ,
9393 [' if' ] = true ,
9494 [' in' ] = true ,
9595 [' local' ] = true ,
@@ -209,7 +209,6 @@ local ChunkStartMap = {
209209 [' elseif' ] = true ,
210210 [' for' ] = true ,
211211 [' function' ] = true ,
212- [' global' ] = true ,
213212 [' if' ] = true ,
214213 [' local' ] = true ,
215214 [' repeat' ] = true ,
@@ -1425,6 +1424,18 @@ local function isKeyWord(word, nextToken)
14251424 end
14261425 return true
14271426 end
1427+ if word == ' global' then
1428+ if State .version ~= ' Lua 5.5' then
1429+ return false
1430+ end
1431+ if not nextToken then
1432+ return false
1433+ end
1434+ if CharMapWord [ssub (nextToken , 1 , 1 )] then
1435+ return true
1436+ end
1437+ return false
1438+ end
14281439 return false
14291440end
14301441
@@ -3139,12 +3150,6 @@ end
31393150local function parseGlobal ()
31403151 local globalPos = getPosition (Tokens [Index ], ' left' )
31413152
3142- -- Global declarations are only supported in Lua 5.5
3143- if State .version ~= ' Lua 5.5' then
3144- -- Return nil, true to indicate failed parse so it falls back to treating 'global' as identifier
3145- return nil , true
3146- end
3147-
31483153 Index = Index + 2
31493154 skipSpace ()
31503155
@@ -3946,7 +3951,7 @@ function parseAction()
39463951 return parseLocal ()
39473952 end
39483953
3949- if token == ' global' then
3954+ if token == ' global' and isKeyWord ( ' global ' , Tokens [ Index + 3 ]) then
39503955 return parseGlobal ()
39513956 end
39523957
You can’t perform that action at this time.
0 commit comments