Skip to content

Commit 1383cd2

Browse files
linusgawesomekling
authored andcommitted
LibJS: Add missing keywords/tokens
Some of these are required for syntax we have not implemented yet, some are future reserved words in strict mode.
1 parent 388ae07 commit 1383cd2

File tree

2 files changed

+19
-1
lines changed

2 files changed

+19
-1
lines changed

Libraries/LibJS/Lexer.cpp

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -54,18 +54,22 @@ Lexer::Lexer(StringView source)
5454
s_keywords.set("delete", TokenType::Delete);
5555
s_keywords.set("do", TokenType::Do);
5656
s_keywords.set("else", TokenType::Else);
57+
s_keywords.set("enum", TokenType::Enum);
58+
s_keywords.set("export", TokenType::Export);
59+
s_keywords.set("extends", TokenType::Extends);
5760
s_keywords.set("false", TokenType::BoolLiteral);
5861
s_keywords.set("finally", TokenType::Finally);
5962
s_keywords.set("for", TokenType::For);
6063
s_keywords.set("function", TokenType::Function);
6164
s_keywords.set("if", TokenType::If);
65+
s_keywords.set("import", TokenType::Import);
6266
s_keywords.set("in", TokenType::In);
6367
s_keywords.set("instanceof", TokenType::Instanceof);
64-
s_keywords.set("interface", TokenType::Interface);
6568
s_keywords.set("let", TokenType::Let);
6669
s_keywords.set("new", TokenType::New);
6770
s_keywords.set("null", TokenType::NullLiteral);
6871
s_keywords.set("return", TokenType::Return);
72+
s_keywords.set("super", TokenType::Super);
6973
s_keywords.set("switch", TokenType::Switch);
7074
s_keywords.set("this", TokenType::This);
7175
s_keywords.set("throw", TokenType::Throw);
@@ -75,6 +79,7 @@ Lexer::Lexer(StringView source)
7579
s_keywords.set("var", TokenType::Var);
7680
s_keywords.set("void", TokenType::Void);
7781
s_keywords.set("while", TokenType::While);
82+
s_keywords.set("with", TokenType::With);
7883
s_keywords.set("yield", TokenType::Yield);
7984
}
8085

Libraries/LibJS/Token.h

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -38,6 +38,7 @@ namespace JS {
3838
__ENUMERATE_JS_TOKEN(Asterisk) \
3939
__ENUMERATE_JS_TOKEN(DoubleAsteriskEquals) \
4040
__ENUMERATE_JS_TOKEN(AsteriskEquals) \
41+
__ENUMERATE_JS_TOKEN(Async) \
4142
__ENUMERATE_JS_TOKEN(Await) \
4243
__ENUMERATE_JS_TOKEN(BoolLiteral) \
4344
__ENUMERATE_JS_TOKEN(BracketClose) \
@@ -63,20 +64,25 @@ namespace JS {
6364
__ENUMERATE_JS_TOKEN(DoublePipe) \
6465
__ENUMERATE_JS_TOKEN(DoubleQuestionMark) \
6566
__ENUMERATE_JS_TOKEN(Else) \
67+
__ENUMERATE_JS_TOKEN(Enum) \
6668
__ENUMERATE_JS_TOKEN(Eof) \
6769
__ENUMERATE_JS_TOKEN(Equals) \
6870
__ENUMERATE_JS_TOKEN(EqualsEquals) \
6971
__ENUMERATE_JS_TOKEN(EqualsEqualsEquals) \
7072
__ENUMERATE_JS_TOKEN(ExclamationMark) \
7173
__ENUMERATE_JS_TOKEN(ExclamationMarkEquals) \
7274
__ENUMERATE_JS_TOKEN(ExclamationMarkEqualsEquals) \
75+
__ENUMERATE_JS_TOKEN(Export) \
76+
__ENUMERATE_JS_TOKEN(Extends) \
7377
__ENUMERATE_JS_TOKEN(Finally) \
7478
__ENUMERATE_JS_TOKEN(For) \
7579
__ENUMERATE_JS_TOKEN(Function) \
7680
__ENUMERATE_JS_TOKEN(GreaterThan) \
7781
__ENUMERATE_JS_TOKEN(GreaterThanEquals) \
7882
__ENUMERATE_JS_TOKEN(Identifier) \
7983
__ENUMERATE_JS_TOKEN(If) \
84+
__ENUMERATE_JS_TOKEN(Implements) \
85+
__ENUMERATE_JS_TOKEN(Import) \
8086
__ENUMERATE_JS_TOKEN(In) \
8187
__ENUMERATE_JS_TOKEN(Instanceof) \
8288
__ENUMERATE_JS_TOKEN(Interface) \
@@ -90,6 +96,7 @@ namespace JS {
9096
__ENUMERATE_JS_TOKEN(New) \
9197
__ENUMERATE_JS_TOKEN(NullLiteral) \
9298
__ENUMERATE_JS_TOKEN(NumericLiteral) \
99+
__ENUMERATE_JS_TOKEN(Package) \
93100
__ENUMERATE_JS_TOKEN(ParenClose) \
94101
__ENUMERATE_JS_TOKEN(ParenOpen) \
95102
__ENUMERATE_JS_TOKEN(Percent) \
@@ -100,6 +107,9 @@ namespace JS {
100107
__ENUMERATE_JS_TOKEN(Plus) \
101108
__ENUMERATE_JS_TOKEN(PlusEquals) \
102109
__ENUMERATE_JS_TOKEN(PlusPlus) \
110+
__ENUMERATE_JS_TOKEN(Private) \
111+
__ENUMERATE_JS_TOKEN(Protected) \
112+
__ENUMERATE_JS_TOKEN(Public) \
103113
__ENUMERATE_JS_TOKEN(QuestionMark) \
104114
__ENUMERATE_JS_TOKEN(QuestionMarkPeriod) \
105115
__ENUMERATE_JS_TOKEN(RegexLiteral) \
@@ -111,7 +121,9 @@ namespace JS {
111121
__ENUMERATE_JS_TOKEN(ShiftRightEquals) \
112122
__ENUMERATE_JS_TOKEN(Slash) \
113123
__ENUMERATE_JS_TOKEN(SlashEquals) \
124+
__ENUMERATE_JS_TOKEN(Static) \
114125
__ENUMERATE_JS_TOKEN(StringLiteral) \
126+
__ENUMERATE_JS_TOKEN(Super) \
115127
__ENUMERATE_JS_TOKEN(Switch) \
116128
__ENUMERATE_JS_TOKEN(TemplateLiteralEnd) \
117129
__ENUMERATE_JS_TOKEN(TemplateLiteralExprEnd) \
@@ -131,6 +143,7 @@ namespace JS {
131143
__ENUMERATE_JS_TOKEN(Var) \
132144
__ENUMERATE_JS_TOKEN(Void) \
133145
__ENUMERATE_JS_TOKEN(While) \
146+
__ENUMERATE_JS_TOKEN(With) \
134147
__ENUMERATE_JS_TOKEN(Yield)
135148

136149
enum class TokenType {

0 commit comments

Comments
 (0)