[njs] Introduced "undefined" as a token in lexer.

Dmitry Volyntsev xeioex at nginx.com
Fri Apr 30 10:11:41 UTC 2021


details:   https://hg.nginx.org/njs/rev/cb99db22e3e5
branches:  
changeset: 1628:cb99db22e3e5
user:      Dmitry Volyntsev <xeioex at nginx.com>
date:      Fri Apr 16 15:25:22 2021 +0000
description:
Introduced "undefined" as a token in lexer.

diffstat:

 src/njs_lexer.h        |   1 +
 src/njs_lexer_tables.h |  20 +++++++++++++-------
 utils/lexer_keyword.py |   1 +
 3 files changed, 15 insertions(+), 7 deletions(-)

diffs (87 lines):

diff -r 282a13ecd193 -r cb99db22e3e5 src/njs_lexer.h
--- a/src/njs_lexer.h	Fri Apr 30 10:10:57 2021 +0000
+++ b/src/njs_lexer.h	Fri Apr 16 15:25:22 2021 +0000
@@ -116,6 +116,7 @@ typedef enum {
     NJS_TOKEN_NULL,
     NJS_TOKEN_NUMBER,
     NJS_TOKEN_TRUE,
+    NJS_TOKEN_UNDEFINED,
     NJS_TOKEN_FALSE,
     NJS_TOKEN_STRING,
 
diff -r 282a13ecd193 -r cb99db22e3e5 src/njs_lexer_tables.h
--- a/src/njs_lexer_tables.h	Fri Apr 30 10:10:57 2021 +0000
+++ b/src/njs_lexer_tables.h	Fri Apr 16 15:25:22 2021 +0000
@@ -10,7 +10,7 @@
 #define _NJS_LEXER_TABLES_H_INCLUDED_
 
 
-static const njs_keyword_t njs_lexer_kws[53] =
+static const njs_keyword_t njs_lexer_kws[54] =
 {
     {
         .entry = { njs_str("arguments") },
@@ -301,6 +301,12 @@ static const njs_keyword_t njs_lexer_kws
     },
 
     {
+        .entry = { njs_str("undefined") },
+        .type = NJS_TOKEN_UNDEFINED,
+        .reserved = 0
+    },
+
+    {
         .entry = { njs_str("var") },
         .type = NJS_TOKEN_VAR,
         .reserved = 1
@@ -364,10 +370,10 @@ static const njs_lexer_keyword_entry_t n
     { "null", &njs_lexer_kws[32], 4, 0 },
     { NULL, NULL, 0, 0 },
     { "do", &njs_lexer_kws[12], 2, 0 },
-    { "var", &njs_lexer_kws[48], 3, 0 },
+    { "var", &njs_lexer_kws[49], 3, 0 },
     { "if", &njs_lexer_kws[23], 2, 7 },
     { "implements", &njs_lexer_kws[24], 10, 0 },
-    { "with", &njs_lexer_kws[51], 4, 0 },
+    { "with", &njs_lexer_kws[52], 4, 0 },
     { NULL, NULL, 0, 0 },
     { "eval", &njs_lexer_kws[15], 4, 9 },
     { NULL, NULL, 0, 0 },
@@ -379,14 +385,14 @@ static const njs_lexer_keyword_entry_t n
     { NULL, NULL, 0, 0 },
     { NULL, NULL, 0, 0 },
     { "default", &njs_lexer_kws[10], 7, 0 },
-    { "void", &njs_lexer_kws[49], 4, 0 },
+    { "void", &njs_lexer_kws[50], 4, 0 },
     { NULL, NULL, 0, 0 },
     { NULL, NULL, 0, 0 },
-    { NULL, NULL, 0, 0 },
+    { "undefined", &njs_lexer_kws[48], 9, 0 },
     { "from", &njs_lexer_kws[21], 4, 0 },
     { "package", &njs_lexer_kws[34], 7, 15 },
     { NULL, NULL, 0, 0 },
-    { "yield", &njs_lexer_kws[52], 5, 0 },
+    { "yield", &njs_lexer_kws[53], 5, 0 },
     { NULL, NULL, 0, 0 },
     { NULL, NULL, 0, 0 },
     { "of", &njs_lexer_kws[33], 2, 0 },
@@ -403,7 +409,7 @@ static const njs_lexer_keyword_entry_t n
     { NULL, NULL, 0, 0 },
     { NULL, NULL, 0, 0 },
     { "for", &njs_lexer_kws[20], 3, 0 },
-    { "while", &njs_lexer_kws[50], 5, 0 },
+    { "while", &njs_lexer_kws[51], 5, 0 },
     { NULL, NULL, 0, 0 },
     { NULL, NULL, 0, 0 },
     { NULL, NULL, 0, 0 },
diff -r 282a13ecd193 -r cb99db22e3e5 utils/lexer_keyword.py
--- a/utils/lexer_keyword.py	Fri Apr 30 10:10:57 2021 +0000
+++ b/utils/lexer_keyword.py	Fri Apr 16 15:25:22 2021 +0000
@@ -6,6 +6,7 @@ global_keywords = {
     "null": 1,
     "false": 1,
     "true": 1,
+    "undefined": 0,
 
     # Operators.
 


More information about the nginx-devel mailing list