Skip to content

Commit 254aa69

Browse files
authored
Add reserved words (#3201)
1 parent 6a9bc3c commit 254aa69

File tree

2 files changed

+55
-0
lines changed

2 files changed

+55
-0
lines changed

lua/entities/gmod_wire_expression2/base/tokenizer.lua

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,7 @@
1515
AddCSLuaFile()
1616

1717
local Trace, Warning, Error = E2Lib.Debug.Trace, E2Lib.Debug.Warning, E2Lib.Debug.Error
18+
local ReservedWord = E2Lib.ReservedWord
1819

1920
local tonumber = tonumber
2021
local string_find, string_gsub, string_sub = string.find, string.gsub, string.sub
@@ -269,6 +270,7 @@ function Tokenizer:Next()
269270
elseif match == "false" then
270271
return Token.new(TokenVariant.Boolean, false)
271272
elseif string_sub(match, 1, 1) ~= "#" then
273+
if ReservedWord[match] then self:Warning("'".. match .. "' is a reserved identifier and may break your code in the future") end
272274
return Token.new(TokenVariant.LowerIdent, match)
273275
end
274276
end

lua/entities/gmod_wire_expression2/core/e2lib.lua

Lines changed: 53 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -653,6 +653,59 @@ local Keyword = {
653653

654654
E2Lib.Keyword = Keyword
655655

656+
--- A list of every word that we might use in the future
657+
E2Lib.ReservedWord = {
658+
abstract = true,
659+
as = true,
660+
await = true,
661+
async = true,
662+
class = true,
663+
constructor = true,
664+
debugger = true,
665+
declare = true,
666+
default = true,
667+
delete = true,
668+
enum = true,
669+
export = true,
670+
extends = true,
671+
["false"] = true,
672+
finally = true,
673+
from = true,
674+
implements = true,
675+
import = true,
676+
["in"] = true,
677+
instanceof = true,
678+
interface = true,
679+
match = true,
680+
macro = true,
681+
mod = true,
682+
module = true,
683+
mut = true,
684+
namespace = true,
685+
new = true,
686+
null = true,
687+
of = true,
688+
package = true,
689+
private = true,
690+
protected =true,
691+
public = true,
692+
require = true,
693+
static = true,
694+
struct = true,
695+
super = true,
696+
this = true,
697+
throw = true,
698+
throws = true,
699+
["true"] = true,
700+
type = true,
701+
typeof = true,
702+
undefined = true,
703+
union = true,
704+
use = true,
705+
yield = true,
706+
var = true,
707+
}
708+
656709
---@type table<string, Keyword>
657710
E2Lib.KeywordLookup = {}
658711

0 commit comments

Comments
 (0)