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 = {
79
79
local LineMulti = 10000
80
80
81
81
-- goto 单独处理
82
+ -- global 单独处理
82
83
local KeyWord = {
83
84
[' and' ] = true ,
84
85
[' break' ] = true ,
@@ -89,7 +90,6 @@ local KeyWord = {
89
90
[' false' ] = true ,
90
91
[' for' ] = true ,
91
92
[' function' ] = true ,
92
- [' global' ] = true ,
93
93
[' if' ] = true ,
94
94
[' in' ] = true ,
95
95
[' local' ] = true ,
@@ -209,7 +209,6 @@ local ChunkStartMap = {
209
209
[' elseif' ] = true ,
210
210
[' for' ] = true ,
211
211
[' function' ] = true ,
212
- [' global' ] = true ,
213
212
[' if' ] = true ,
214
213
[' local' ] = true ,
215
214
[' repeat' ] = true ,
@@ -1425,6 +1424,18 @@ local function isKeyWord(word, nextToken)
1425
1424
end
1426
1425
return true
1427
1426
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
1428
1439
return false
1429
1440
end
1430
1441
@@ -3139,12 +3150,6 @@ end
3139
3150
local function parseGlobal ()
3140
3151
local globalPos = getPosition (Tokens [Index ], ' left' )
3141
3152
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
-
3148
3153
Index = Index + 2
3149
3154
skipSpace ()
3150
3155
@@ -3946,7 +3951,7 @@ function parseAction()
3946
3951
return parseLocal ()
3947
3952
end
3948
3953
3949
- if token == ' global' then
3954
+ if token == ' global' and isKeyWord ( ' global ' , Tokens [ Index + 3 ]) then
3950
3955
return parseGlobal ()
3951
3956
end
3952
3957
You can’t perform that action at this time.
0 commit comments