Skip to content

Commit

Permalink
Add let keyword as an alternative to local
Browse files Browse the repository at this point in the history
  • Loading branch information
Vurv78 committed Nov 9, 2023
1 parent 6a983ab commit 287f001
Show file tree
Hide file tree
Showing 3 changed files with 20 additions and 17 deletions.
2 changes: 1 addition & 1 deletion lua/entities/gmod_wire_expression2/base/parser.lua
Original file line number Diff line number Diff line change
Expand Up @@ -359,7 +359,7 @@ function Parser:Stmt()
return Node.new(NodeVariant.Const, { name, value }, trace:stitch(self:Prev().trace))
end

local is_local, var = self:Consume(TokenVariant.Keyword, Keyword.Local), self:Consume(TokenVariant.Ident)
local is_local, var = self:Consume(TokenVariant.Keyword, Keyword.Local) or self:Consume(TokenVariant.Keyword, Keyword.Let), self:Consume(TokenVariant.Ident)
if not var then
self:Assert(not is_local, "Invalid operator (local) must be used for variable declaration.")
else
Expand Down
34 changes: 18 additions & 16 deletions lua/entities/gmod_wire_expression2/core/e2lib.lua
Original file line number Diff line number Diff line change
Expand Up @@ -374,38 +374,40 @@ local Keyword = {
Else = 3,
-- ``local``
Local = 4,
-- ``let``
Let = 5,
-- ``const``
Const = 5,
Const = 6,
-- ``while``
While = 6,
While = 7,
-- ``for``
For = 7,
For = 8,
-- ``break``
Break = 8,
Break = 9,
-- ``continue``
Continue = 9,
Continue = 10,
-- ``switch``
Switch = 10,
Switch = 11,
-- ``case``
Case = 11,
Case = 12,
-- ``default``
Default = 12,
Default = 13,
-- ``foreach``
Foreach = 13,
Foreach = 14,
-- ``function``
Function = 14,
Function = 15,
-- ``return``
Return = 15,
Return = 16,
-- ``#include``
["#Include"] = 16,
["#Include"] = 17,
-- ``try``
Try = 17,
Try = 18,
-- ``catch``
Catch = 18,
Catch = 19,
-- ``do``
Do = 19,
Do = 20,
-- ``event``
Event = 20
Event = 21
}

E2Lib.Keyword = Keyword
Expand Down
1 change: 1 addition & 0 deletions lua/wire/client/text_editor/modes/e2.lua
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,7 @@ local keywords = {
["function"] = { [true] = true },
["return"] = { [true] = true },
["local"] = { [true] = true },
["let"] = { [true] = true },
["const"] = { [true] = true },
["try"] = { [true] = true },
["do"] = { [true] = true },
Expand Down

0 comments on commit 287f001

Please sign in to comment.