summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorBlaise2022-10-28 15:19:44 -0500
committerBlaise2022-10-28 15:38:07 -0500
commitb3fa7450e80485f89e11d93e40de069d86d846c2 (patch)
tree139caa6715045e9b36b144afcd9e0b4f945f8ad1
parent65f30a977ce05f0d2ba88bfbbc4c9b5d8996f5d2 (diff)
Don't interpret include directives as comments
-rw-r--r--microlight.js7
1 files changed, 4 insertions, 3 deletions
diff --git a/microlight.js b/microlight.js
index 65a9401..202cc0c 100644
--- a/microlight.js
+++ b/microlight.js
@@ -118,7 +118,7 @@
118 tokenType > 3 ? 3 : 118 tokenType > 3 ? 3 :
119 // otherwise tokenType == 3, (key)word 119 // otherwise tokenType == 3, (key)word
120 // (1 if regexp matches, 0 otherwise) 120 // (1 if regexp matches, 0 otherwise)
121 + /^(a(bstract|lias|nd|rguments|rray|s(m|sert)?|uto)|b(ase|egin|ool(ean)?|reak|yte)|c(ase|atch|har|hecked|lass|lone|ompl|onst|ontinue)|de(bugger|cimal|clare|f(ault|er)?|init|l(egate|ete)?)|do|double|e(cho|ls?if|lse(if)?|nd|nsure|num|vent|x(cept|ec|p(licit|ort)|te(nds|nsion|rn)))|f(allthrough|alse|inal(ly)?|ixed|loat|or(each)?|riend|rom|unc(tion)?)|global|goto|guard|i(f|mp(lements|licit|ort)|n(it|clude(_once)?|line|out|stanceof|t(erface|ernal)?)?|s)|l(ambda|et|ock|ong)|m(icrolight|odule|utable)|NaN|n(amespace|ative|ext|ew|il|ot|ull)|o(bject|perator|r|ut|verride)|p(ackage|arams|rivate|rotected|rotocol|ublic)|r(aise|e(adonly|do|f|gister|peat|quire(_once)?|scue|strict|try|turn))|s(byte|ealed|elf|hort|igned|izeof|tatic|tring|truct|ubscript|uper|ynchronized|witch)|t(emplate|hen|his|hrows?|ransient|rue|ry|ype(alias|def|id|name|of))|u(n(checked|def(ined)?|ion|less|signed|til)|se|sing)|v(ar|irtual|oid|olatile)|w(char_t|hen|here|hile|ith)|xor|yield)$/[test](token) 121 + /^(a(bstract|lias|nd|rguments|rray|s(m|sert)?|uto)|b(ase|egin|ool(ean)?|reak|yte)|c(ase|atch|har|hecked|lass|lone|ompl|onst|ontinue)|de(bugger|cimal|clare|f(ault|er)?|init|l(egate|ete)?)|do|double|e(cho|ls?if|lse(if)?|nd|nsure|num|vent|x(cept|ec|p(licit|ort)|te(nds|nsion|rn)))|f(allthrough|alse|inal(ly)?|ixed|loat|or(each)?|riend|rom|unc(tion)?)|global|goto|guard|#?i(f|mp(lements|licit|ort)|n(it|clude(_once)?|line|out|stanceof|t(erface|ernal)?)?|s)|l(ambda|et|ock|ong)|m(icrolight|odule|utable)|NaN|n(amespace|ative|ext|ew|il|ot|ull)|o(bject|perator|r|ut|verride)|p(ackage|arams|rivate|rotected|rotocol|ublic)|r(aise|e(adonly|do|f|gister|peat|quire(_once)?|scue|strict|try|turn))|s(byte|ealed|elf|hort|igned|izeof|tatic|tring|truct|ubscript|uper|ynchronized|witch)|t(emplate|hen|his|hrows?|ransient|rue|ry|ype(alias|def|id|name|of))|u(n(checked|def(ined)?|ion|less|signed|til)|se|sing)|v(ar|irtual|oid|olatile)|w(char_t|hen|here|hile|ith)|xor|yield)$/[test](token)
122 )); 122 ));
123 123
124 node[appendChild](_document.createTextNode(token)); 124 node[appendChild](_document.createTextNode(token));
@@ -142,7 +142,7 @@
142 // 1: operator or braces 142 // 1: operator or braces
143 /[\/{}[(\-+*=<>:;|\\.,?!&@~]/[test](chr), 143 /[\/{}[(\-+*=<>:;|\\.,?!&@~]/[test](chr),
144 /[\])]/[test](chr), // 2: closing brace 144 /[\])]/[test](chr), // 2: closing brace
145 /[$\w]/[test](chr), // 3: (key)word 145 /[#$\w]/[test](chr), // 3: (key)word
146 chr == '/' && // 4: regex 146 chr == '/' && // 4: regex
147 // previous token was an 147 // previous token was an
148 // opening brace or an 148 // opening brace or an
@@ -158,7 +158,8 @@
158 chr+next1+text[pos+1]+text[pos+2] == '<!--', 158 chr+next1+text[pos+1]+text[pos+2] == '<!--',
159 chr+next1 == '/*', // 8: multiline comment 159 chr+next1 == '/*', // 8: multiline comment
160 chr+next1 == '//', // 9: single-line comment 160 chr+next1 == '//', // 9: single-line comment
161 chr == '#' // 10: hash-style comment 161 // 10: hash-style comment
162 chr == '#' && next1+text[pos+1]+text[pos+2] != 'inc'
162 ][--tokenType]); 163 ][--tokenType]);
163 } 164 }
164 165