From fa0534d18a7b0831389019ce4d0705baf8993e4a Mon Sep 17 00:00:00 2001 From: RaiKoHoff Date: Thu, 13 Feb 2020 16:12:46 +0100 Subject: [PATCH] + chg: HTML JS VB: shared keyword-lists --- src/StyleLexers/EditLexer.h | 23 +++++++++++++++++++ src/StyleLexers/styleLexHTML.c | 12 ++-------- src/StyleLexers/styleLexJS.c | 5 +--- src/StyleLexers/styleLexVB.c | 11 +-------- .../StyleLexers/styleLexJS/codepen.js | 0 .../StyleLexers/styleLexJS/test_script.js | 7 ++++++ 6 files changed, 34 insertions(+), 24 deletions(-) create mode 100644 test/test_files/StyleLexers/styleLexJS/codepen.js create mode 100644 test/test_files/StyleLexers/styleLexJS/test_script.js diff --git a/src/StyleLexers/EditLexer.h b/src/StyleLexers/EditLexer.h index 3d33378f5..a0ffd211a 100644 --- a/src/StyleLexers/EditLexer.h +++ b/src/StyleLexers/EditLexer.h @@ -137,6 +137,29 @@ extern EDITLEXER lexHTML; // Web Source Code extern EDITLEXER lexXML; // XML Document extern EDITLEXER lexYAML; // YAML +// ----------------------------------------------------------------------------- +// common defines +// ----------------------------------------------------------------------------- + +#define NP3_LEXER_JS_KEYWORD_LIST \ +"abstract as async await boolean break byte case catch char class const continue debugger default delete do double "\ +"each else enum export extends false final finally float for from function get goto if implements import in instanceof int "\ +"interface let long native new null of package private protected public return set short static super switch "\ +"synchronized this throw throws transient true try typeof var void volatile while with yield" + + +#define NP3_LEXER_VB_KEYWORD_LIST \ +"addhandler addressof alias and andalso ansi any as assembly attribute auto begin boolean byref byte byval "\ +"call case catch cbool cbyte cchar cdate cdbl cdec char cint class clng cobj compare const continue cshort csng cstr ctype currency "\ +"date decimal declare default delegate dim directcast do double each else elseif empty end enum eqv erase error event "\ +"exit explicit externalsource false finally for friend function get gettype global gosub goto handles if "\ +"imp implement implements imports in inherits integer interface is let lib like load long loop lset me mid mod module mustinherit "\ +"mustoverride mybase myclass namespace new next not nothing notinheritable notoverridable null object on option "\ +"optional or orelse overloads overridable overrides paramarray preserve private property protected public "\ +"raiseevent randomize readonly redim rem removehandler resume return rset select set shadows shared short "\ +"single static step stop strict string structure sub synclock then throw to true try type typeof unicode unload until "\ +"variant wend when while with withevents writeonly xor" + // ----------------------------------------------------------------------------- #endif // _EDIT_LEXER_H_ diff --git a/src/StyleLexers/styleLexHTML.c b/src/StyleLexers/styleLexHTML.c index 4cb8f87bc..8f57aa571 100644 --- a/src/StyleLexers/styleLexHTML.c +++ b/src/StyleLexers/styleLexHTML.c @@ -34,17 +34,9 @@ KEYWORDLIST KeyWords_HTML = { "translate tt type typemustmatch u ul usemap valign value valuetype var version video vlink vspace wbr " "width wrap xml xmlns", // JavaScript keywords (sync with lexJS::KeyWords_JS) -"abstract as async await boolean break byte case catch char class const continue debugger default delete do double " -"each else enum export extends false final finally float for from function get goto if implements import in instanceof int " -"interface let long native new null of package private protected public return set short static super switch " -"synchronized this throw throws transient true try typeof var void volatile while with yield", +NP3_LEXER_JS_KEYWORD_LIST, // VBScript keywords -"alias and as attribute begin boolean byref byte byval call case class compare const continue currency date " -"declare dim do double each else elseif empty end enum eqv erase error event exit explicit false for " -"friend function get global gosub goto if imp implement in integer is let lib load long loop lset me mid " -"mod module new next not nothing null object on option optional or preserve private property public " -"raiseevent redim rem resume return rset select set single static stop string sub then to true type unload " -"until variant wend while with withevents xor", +NP3_LEXER_VB_KEYWORD_LIST, // Python keywords "", // PHP keywords diff --git a/src/StyleLexers/styleLexJS.c b/src/StyleLexers/styleLexJS.c index 6ca24c330..4d6b44cea 100644 --- a/src/StyleLexers/styleLexJS.c +++ b/src/StyleLexers/styleLexJS.c @@ -4,10 +4,7 @@ // JavaScript keywords (sync with lexHTML::KeyWords_HTML for embedded JS) KEYWORDLIST KeyWords_JS = { -"abstract as async await boolean break byte case catch char class const continue debugger default delete do double " -"each else enum export extends false final finally float for from function get goto if implements import in instanceof int " -"interface let long native new null of package private protected public return set short static super switch " -"synchronized this throw throws transient true try typeof var void volatile while with yield", + NP3_LEXER_JS_KEYWORD_LIST, NULL, }; diff --git a/src/StyleLexers/styleLexVB.c b/src/StyleLexers/styleLexVB.c index d443891bd..1d4072d82 100644 --- a/src/StyleLexers/styleLexVB.c +++ b/src/StyleLexers/styleLexVB.c @@ -3,16 +3,7 @@ // ---------------------------------------------------------------------------- KEYWORDLIST KeyWords_VB = { -"addhandler addressof alias and andalso ansi any as assembly auto boolean byref byte byval call case catch " -"cbool cbyte cchar cdate cdbl cdec char cint class clng cobj compare const cshort csng cstr ctype date " -"decimal declare default delegate dim directcast do double each else elseif end enum erase error event " -"exit explicit externalsource false finally for friend function get gettype gosub goto handles if " -"implements imports in inherits integer interface is let lib like long loop me mid mod module mustinherit " -"mustoverride mybase myclass namespace new next not nothing notinheritable notoverridable object on option " -"optional or orelse overloads overridable overrides paramarray preserve private property protected public " -"raiseevent randomize readonly redim rem removehandler resume return select set shadows shared short " -"single static step stop strict string structure sub synclock then throw to true try typeof unicode until " -"variant when while with withevents writeonly xor", + NP3_LEXER_VB_KEYWORD_LIST, NULL, }; diff --git a/test/test_files/StyleLexers/styleLexJS/codepen.js b/test/test_files/StyleLexers/styleLexJS/codepen.js new file mode 100644 index 000000000..e69de29bb diff --git a/test/test_files/StyleLexers/styleLexJS/test_script.js b/test/test_files/StyleLexers/styleLexJS/test_script.js new file mode 100644 index 000000000..f0d17af89 --- /dev/null +++ b/test/test_files/StyleLexers/styleLexJS/test_script.js @@ -0,0 +1,7 @@ +var x; +const y; +let z; + +for (let el of arr) { + console.log(el); +}