[gtksourceview: 8/13] javascript.lang (and family): Replace word boundaries with custom regex
- From: Christian Hergert <chergert src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [gtksourceview: 8/13] javascript.lang (and family): Replace word boundaries with custom regex
- Date: Tue, 2 Jun 2020 18:35:11 +0000 (UTC)
commit b4820eb3018c7355e0781ddd0880d367ffbc2198
Author: Jeffery To <jeffery to gmail com>
Date: Sun May 31 07:32:42 2020 +0800
javascript.lang (and family): Replace word boundaries with custom regex
The \%[ and \%] word boundaries test both sides of the boundary, specifically:
* \%[ is (?<![chars])(?=[chars])
* \%] is (?<=[chars])(?![chars])
where [chars] is the pattern defined in <keyword-char-class>.
When used with an actual keyword, e.g. \%[function\%], the "inside"
tests are unnecessary.
This replaces uses of \%[ and \%] with custom regexes that only test
"outside" the keyword.
data/language-specs/javascript-expressions.lang | 9 +--
.../javascript-functions-classes.lang | 18 +++--
data/language-specs/javascript-literals.lang | 6 +-
data/language-specs/javascript-modules.lang | 23 +++++--
data/language-specs/javascript-statements.lang | 78 ++++++++++++++++------
data/language-specs/javascript-values.lang | 10 ++-
data/language-specs/javascript.lang | 16 +++--
data/language-specs/jsdoc.lang | 22 +++---
data/language-specs/objj.lang | 44 ++++++++----
data/language-specs/typescript-js-expressions.lang | 4 +-
.../typescript-js-functions-classes.lang | 16 +++--
data/language-specs/typescript-js-modules.lang | 14 ++--
data/language-specs/typescript-js-statements.lang | 22 +++---
data/language-specs/typescript-js-values.lang | 7 +-
data/language-specs/typescript-jsx.lang | 6 +-
.../typescript-type-expressions.lang | 32 ++++++---
data/language-specs/typescript-type-generics.lang | 8 ++-
data/language-specs/typescript-type-literals.lang | 14 ++--
data/language-specs/typescript.lang | 20 +++---
19 files changed, 259 insertions(+), 110 deletions(-)
---
diff --git a/data/language-specs/javascript-expressions.lang b/data/language-specs/javascript-expressions.lang
index aebd66fd..877ba2f3 100644
--- a/data/language-specs/javascript-expressions.lang
+++ b/data/language-specs/javascript-expressions.lang
@@ -60,7 +60,7 @@
<!-- ES2017, cannot be followed by line terminator -->
<context id="_async-pre-primary-expression-keywords" style-ref="js:keyword">
<match extended="true">
- \%[ async \%]
+ \%{js:keyword-start} async \%{js:keyword-end}
(?= # preceeds arrow function
\%{js:optional-whitespace-or-comments}
(?:
@@ -72,14 +72,15 @@
)
(?! # does not preceed "function" (leave to function
expression)
\%{js:optional-whitespace-or-comments}
- \%[ function \%]
+ \%{js:keyword-start} function \%{js:keyword-end}
)
</match>
</context> <!-- /_async-pre-primary-expression-keywords -->
<context id="_new-pre-primary-expression-keywords" style-ref="js:keyword">
<match extended="true">
- \%[ new \%] (?! \%{js:new-target-object-keyword-suffix} )
+ \%{js:keyword-start} new \%{js:keyword-end}
+ (?! \%{js:new-target-object-keyword-suffix} )
</match>
</context> <!-- /_new-pre-primary-expression-keywords -->
@@ -588,7 +589,7 @@
<!-- # Binary operators -->
<define-regex id="_keyword-binary-operator" extended="true">
- \%[ (?: instanceof | in ) \%]
+ \%{js:keyword-start} (?: instanceof | in ) \%{js:keyword-end}
</define-regex> <!-- /_keyword-binary-operator -->
<!-- excluding comma operator -->
diff --git a/data/language-specs/javascript-functions-classes.lang
b/data/language-specs/javascript-functions-classes.lang
index 81dd7ee9..736fea81 100644
--- a/data/language-specs/javascript-functions-classes.lang
+++ b/data/language-specs/javascript-functions-classes.lang
@@ -44,7 +44,9 @@
<!-- ## Function expression keyword -->
<context id="_function-expression-async-keyword" style-ref="js:keyword" once-only="true">
- <match>\%[async\%]</match>
+ <match extended="true">
+ \%{js:keyword-start} async \%{js:keyword-end}
+ </match>
</context> <!-- /_function-expression-async-keyword -->
<context id="_ordered-function-expression-async-keyword" once-only="true">
@@ -56,7 +58,9 @@
</context> <!-- /_ordered-function-expression-async-keyword -->
<context id="_function-expression-function-keyword" style-ref="js:keyword" once-only="true">
- <match>\%[function\%]</match>
+ <match extended="true">
+ \%{js:keyword-start} function \%{js:keyword-end}
+ </match>
</context> <!-- /_function-expression-function-keyword -->
<context id="_ordered-function-expression-function-keyword" once-only="true">
@@ -245,7 +249,7 @@
<!-- ES2017, cannot be followed by line terminator -->
<context id="_choice-async-method-definition-modifier-keyword" style-ref="js:keyword"
end-parent="true">
<match extended="true">
- \%[ async \%]
+ \%{js:keyword-start} async \%{js:keyword-end}
(?=
\%{js:optional-whitespace-or-comments}
(?:
@@ -322,7 +326,9 @@
<include>
<context id="_choice-class-optional-name-ignore-extends" end-parent="true">
- <start>(?=\%[extends\%])</start>
+ <start extended="true">
+ (?= \%{js:keyword-start} extends \%{js:keyword-end} )
+ </start>
<end>\%{def:always-match}</end>
</context> <!-- /_choice-class-optional-name-ignore-extends -->
@@ -344,7 +350,9 @@
<!-- ## Class extends clause -->
<context id="_class-extends-clause" once-only="true">
- <start>\%[extends\%]</start>
+ <start extended="true">
+ \%{js:keyword-start} extends \%{js:keyword-end}
+ </start>
<end>\%{js:before-next-token}</end>
<include>
<context sub-pattern="0" where="start" style-ref="js:keyword"/>
diff --git a/data/language-specs/javascript-literals.lang b/data/language-specs/javascript-literals.lang
index 59537cf7..c77bf722 100644
--- a/data/language-specs/javascript-literals.lang
+++ b/data/language-specs/javascript-literals.lang
@@ -39,7 +39,9 @@
<!-- <NullLiteral> -->
<context id="null-value" style-ref="js:null-value">
- <match>\%[null\%]</match>
+ <match extended="true">
+ \%{js:keyword-start} null \%{js:keyword-end}
+ </match>
</context> <!-- /null-value -->
<!-- <BooleanLiteral> -->
@@ -310,7 +312,7 @@
<context ref="choice-string"/>
<define-regex id="_special-property-names" extended="true">
- \%[ constructor \%]
+ \%{js:keyword-start} constructor \%{js:keyword-end}
</define-regex> <!-- /_special-property-names -->
<context id="_choice-special-property-name" style-ref="js:built-in-method" end-parent="true">
diff --git a/data/language-specs/javascript-modules.lang b/data/language-specs/javascript-modules.lang
index 44faf61c..8215d1db 100644
--- a/data/language-specs/javascript-modules.lang
+++ b/data/language-specs/javascript-modules.lang
@@ -43,7 +43,9 @@
-->
<context id="_from-module" once-only="true">
- <start>\%[from\%]</start>
+ <start extended="true">
+ \%{js:keyword-start} from \%{js:keyword-end}
+ </start>
<end>\%{js:before-next-token}</end>
<include>
<context sub-pattern="0" where="start" style-ref="js:keyword"/>
@@ -74,7 +76,9 @@
-->
<context id="_as-namespace" once-only="true">
- <start>\%[as\%]</start>
+ <start extended="true">
+ \%{js:keyword-start} as \%{js:keyword-end}
+ </start>
<end>\%{js:before-next-token}</end>
<include>
<context sub-pattern="0" where="start" style-ref="js:keyword"/>
@@ -147,7 +151,9 @@
</context> <!-- /_name-group-identifier -->
<context id="_name-group-as-identifier" once-only="true">
- <start>\%[as\%]</start>
+ <start extended="true">
+ \%{js:keyword-start} as \%{js:keyword-end}
+ </start>
<end>\%{js:before-next-token}</end>
<include>
<context sub-pattern="0" where="start" style-ref="js:keyword"/>
@@ -250,7 +256,9 @@
-->
<context id="_choice-export-default" end-parent="true">
- <start>\%[default\%]</start>
+ <start extended="true">
+ \%{js:keyword-start} default \%{js:keyword-end}
+ </start>
<end>\%{js:statement-end}</end>
<include>
<context sub-pattern="0" where="start" style-ref="js:keyword"/>
@@ -279,7 +287,9 @@
<!-- <ExportDeclaration> -->
<context id="export-declarations" style-ref="js:export-import-declaration">
- <start>\%[export\%]</start>
+ <start extended="true">
+ \%{js:keyword-start} export \%{js:keyword-end}
+ </start>
<end>\%{js:before-next-token}</end>
<include>
<context sub-pattern="0" where="start" style-ref="js:keyword"/>
@@ -394,7 +404,8 @@
<!-- <ImportDeclaration> -->
<context id="import-declarations" style-ref="js:export-import-declaration">
<start extended="true">
- \%[ import \%] (?! \%{js:import-function-keyword-suffix} )
+ \%{js:keyword-start} import \%{js:keyword-end}
+ (?! \%{js:import-function-keyword-suffix} )
</start>
<end>\%{js:before-next-token}</end>
<include>
diff --git a/data/language-specs/javascript-statements.lang b/data/language-specs/javascript-statements.lang
index 8f8c8c1e..f8d04909 100644
--- a/data/language-specs/javascript-statements.lang
+++ b/data/language-specs/javascript-statements.lang
@@ -117,7 +117,9 @@
<!-- <BreakStatement> -->
<context id="_break-statements" style-ref="js:break-statement">
- <start>\%[break\%]</start>
+ <start extended="true">
+ \%{js:keyword-start} break \%{js:keyword-end}
+ </start>
<end>\%{js:statement-end-or-end-of-line}</end>
<include>
<context sub-pattern="0" where="start" style-ref="js:keyword"/>
@@ -165,7 +167,9 @@
<!-- <ContinueStatement> -->
<context id="_continue-statements" style-ref="js:continue-statement">
- <start>\%[continue\%]</start>
+ <start extended="true">
+ \%{js:keyword-start} continue \%{js:keyword-end}
+ </start>
<end>\%{js:statement-end-or-end-of-line}</end>
<include>
<context sub-pattern="0" where="start" style-ref="js:keyword"/>
@@ -189,7 +193,9 @@
<!-- <DebuggerStatement> -->
<context id="_debugger-statements" style-ref="js:debugger-statement">
- <start>\%[debugger\%]</start>
+ <start extended="true">
+ \%{js:keyword-start} debugger \%{js:keyword-end}
+ </start>
<end>\%{js:statement-end}</end>
<include>
<context sub-pattern="0" where="start" style-ref="js:keyword"/>
@@ -318,7 +324,9 @@
</context> <!-- /_for-statement-test -->
<context id="_for-statement-in" once-only="true">
- <start>\%[in\%]</start>
+ <start extended="true">
+ \%{js:keyword-start} in \%{js:keyword-end}
+ </start>
<end>\%{js:before-next-token}</end>
<include>
<context sub-pattern="0" where="start" style-ref="js:keyword"/>
@@ -335,7 +343,9 @@
</context> <!-- /_for-statement-in -->
<context id="_for-statement-of" once-only="true">
- <start>\%[of\%]</start>
+ <start extended="true">
+ \%{js:keyword-start} of \%{js:keyword-end}
+ </start>
<end>\%{js:before-next-token}</end>
<include>
<context sub-pattern="0" where="start" style-ref="js:keyword"/>
@@ -379,7 +389,9 @@
<!-- <IterationStatement> (part of) -->
<context id="_for-statements" style-ref="js:for-statement">
- <start>\%[for\%]</start>
+ <start extended="true">
+ \%{js:keyword-start} for \%{js:keyword-end}
+ </start>
<end>\%{js:before-next-token}</end>
<include>
<context sub-pattern="0" where="start" style-ref="js:keyword"/>
@@ -428,7 +440,9 @@
<!-- <IfStatement> (part of) -->
<context id="_if-statements" style-ref="js:if-statement">
- <start>\%[if\%]</start>
+ <start extended="true">
+ \%{js:keyword-start} if \%{js:keyword-end}
+ </start>
<end>\%{js:before-next-token}</end>
<include>
<context sub-pattern="0" where="start" style-ref="js:keyword"/>
@@ -446,7 +460,9 @@
<!-- <IfStatement> (part of) -->
<context id="_else-statements" style-ref="js:else-statement">
- <start>\%[else\%]</start>
+ <start extended="true">
+ \%{js:keyword-start} else \%{js:keyword-end}
+ </start>
<end>\%{js:before-next-token}</end>
<include>
<context sub-pattern="0" where="start" style-ref="js:keyword"/>
@@ -505,7 +521,9 @@
<!-- <ReturnStatement> -->
<context id="_return-statements" style-ref="js:return-statement">
- <start>\%[return\%]</start>
+ <start extended="true">
+ \%{js:keyword-start} return \%{js:keyword-end}
+ </start>
<end>\%{js:statement-end-or-end-of-line}</end>
<include>
<context sub-pattern="0" where="start" style-ref="js:keyword"/>
@@ -532,7 +550,9 @@
-->
<context id="_case-clauses">
- <start>\%[case\%]</start>
+ <start extended="true">
+ \%{js:keyword-start} case \%{js:keyword-end}
+ </start>
<end>:</end>
<include>
<context sub-pattern="0" where="start" style-ref="js:keyword"/>
@@ -549,7 +569,9 @@
</context> <!-- /_case-clauses -->
<context id="_default-clauses">
- <start>\%[default\%]</start>
+ <start extended="true">
+ \%{js:keyword-start} default \%{js:keyword-end}
+ </start>
<end>:</end>
<include>
<context sub-pattern="0" where="start" style-ref="js:keyword"/>
@@ -589,7 +611,9 @@
<!-- <SwitchStatement> -->
<context id="_switch-statements" style-ref="js:switch-statement">
- <start>\%[switch\%]</start>
+ <start extended="true">
+ \%{js:keyword-start} switch \%{js:keyword-end}
+ </start>
<end>\%{js:before-next-token}</end>
<include>
<context sub-pattern="0" where="start" style-ref="js:keyword"/>
@@ -614,7 +638,9 @@
<!-- <ThrowStatement> -->
<context id="_throw-statements" style-ref="js:throw-statement">
- <start>\%[throw\%]</start>
+ <start extended="true">
+ \%{js:keyword-start} throw \%{js:keyword-end}
+ </start>
<end>\%{js:statement-end-or-end-of-line}</end>
<include>
<context sub-pattern="0" where="start" style-ref="js:keyword"/>
@@ -662,7 +688,9 @@
<!-- <TryStatement> -->
<context id="_try-statements" style-ref="js:try-catch-statement">
- <start>\%[try\%]</start>
+ <start extended="true">
+ \%{js:keyword-start} try \%{js:keyword-end}
+ </start>
<end>\%{js:before-next-token}</end>
<include>
<context sub-pattern="0" where="start" style-ref="js:keyword"/>
@@ -705,7 +733,9 @@
<!-- <Catch> -->
<context id="_catch-statements" style-ref="js:try-catch-statement">
- <start>\%[catch\%]</start>
+ <start extended="true">
+ \%{js:keyword-start} catch \%{js:keyword-end}
+ </start>
<end>\%{js:before-next-token}</end>
<include>
<context sub-pattern="0" where="start" style-ref="js:keyword"/>
@@ -724,7 +754,9 @@
<!-- <Finally> -->
<context id="_finally-statements" style-ref="js:try-catch-statement">
- <start>\%[finally\%]</start>
+ <start extended="true">
+ \%{js:keyword-start} finally \%{js:keyword-end}
+ </start>
<end>\%{js:before-next-token}</end>
<include>
<context sub-pattern="0" where="start" style-ref="js:keyword"/>
@@ -749,7 +781,7 @@
-->
<define-regex id="_variable-declaration-keyword" extended="true">
- \%[ (?: const | let | var ) \%]
+ \%{js:keyword-start} (?: const | let | var ) \%{js:keyword-end}
</define-regex> <!-- /_variable-declaration-keyword -->
<context id="_variable-declaration-item-content">
@@ -830,7 +862,9 @@
<!-- <IterationStatement> (part of) -->
<context id="_while-statements" style-ref="js:while-statement">
- <start>\%[while\%]</start>
+ <start extended="true">
+ \%{js:keyword-start} while \%{js:keyword-end}
+ </start>
<end>\%{js:statement-end}</end>
<include>
<context sub-pattern="0" where="start" style-ref="js:keyword"/>
@@ -848,7 +882,9 @@
<!-- <IterationStatement> (part of) -->
<context id="_do-statements" style-ref="js:while-statement">
- <start>\%[do\%]</start>
+ <start extended="true">
+ \%{js:keyword-start} do \%{js:keyword-end}
+ </start>
<end>\%{js:before-next-token}</end>
<include>
<context sub-pattern="0" where="start" style-ref="js:keyword"/>
@@ -869,7 +905,9 @@
<!-- <WithStatement> -->
<context id="_with-statements" style-ref="js:with-statement">
- <start>\%[with\%]</start>
+ <start extended="true">
+ \%{js:keyword-start} with \%{js:keyword-end}
+ </start>
<end>\%{js:before-next-token}</end>
<include>
<context sub-pattern="0" where="start" style-ref="js:keyword"/>
diff --git a/data/language-specs/javascript-values.lang b/data/language-specs/javascript-values.lang
index f1f7e349..21d50bcd 100644
--- a/data/language-specs/javascript-values.lang
+++ b/data/language-specs/javascript-values.lang
@@ -122,7 +122,8 @@
<context id="_import-function-keywords">
<start extended="true">
- \%[ import \%] (?= \%{js:import-function-keyword-suffix} )
+ \%{js:keyword-start} import \%{js:keyword-end}
+ (?= \%{js:import-function-keyword-suffix} )
</start>
<end>(?=\()</end>
<include>
@@ -134,9 +135,12 @@
<context id="_new-target-object-keywords">
<start extended="true">
- \%[ new \%] (?= \%{js:new-target-object-keyword-suffix} )
+ \%{js:keyword-start} new \%{js:keyword-end}
+ (?= \%{js:new-target-object-keyword-suffix} )
</start>
- <end>\%[target\%]</end>
+ <end extended="true">
+ \%{js:keyword-start} target \%{js:keyword-end}
+ </end>
<include>
<context sub-pattern="0" where="start" style-ref="js:keyword"/>
<context sub-pattern="0" where="end" style-ref="js:keyword"/>
diff --git a/data/language-specs/javascript.lang b/data/language-specs/javascript.lang
index d0269216..2c87661a 100644
--- a/data/language-specs/javascript.lang
+++ b/data/language-specs/javascript.lang
@@ -218,6 +218,14 @@
\%{identifier-start} \%{identifier-part}*
</define-regex> <!-- /identifier-->
+ <define-regex id="keyword-start" extended="true">
+ (?<! \%{identifier-char} )
+ </define-regex> <!-- /keyword-start -->
+
+ <define-regex id="keyword-end" extended="true">
+ (?! \%{identifier-char} )
+ </define-regex> <!-- /keyword-end -->
+
<!-- <WhiteSpace> -->
<!-- does not include characters from <LineTerminator>,
to only allow space separators when we want match a
@@ -283,21 +291,21 @@
\%{optional-whitespace-or-comments}
\.
\%{optional-whitespace-or-comments}
- target \%]
+ target \%{keyword-end}
</define-regex> <!-- /new-target-object-keyword-suffix -->
<!-- async function (ES2017)
no line terminator allowed between "async" and "function" -->
<define-regex id="function-expression-keyword" extended="true">
(?:
- \%[ async \%]
+ \%{keyword-start} async \%{keyword-end}
\%{optional-whitespace-or-comments}
)?
- \%[ function \%]
+ \%{keyword-start} function \%{keyword-end}
</define-regex> <!-- /function-expression-keyword -->
<define-regex id="class-expression-keyword" extended="true">
- \%[ class \%]
+ \%{keyword-start} class \%{keyword-end}
</define-regex> <!-- /class-expression-keyword -->
<!-- ## Embedded lang hooks
diff --git a/data/language-specs/jsdoc.lang b/data/language-specs/jsdoc.lang
index 35385ccc..b7cc67ff 100644
--- a/data/language-specs/jsdoc.lang
+++ b/data/language-specs/jsdoc.lang
@@ -94,7 +94,7 @@
tutorial |
variation
)
- \%]
+ \%{js:keyword-end}
</start>
<end>(?=\S)</end>
<include>
@@ -113,7 +113,7 @@
fires |
listens
)
- \%]
+ \%{js:keyword-end}
</start>
<end>(?=\S)</end>
<include>
@@ -130,7 +130,7 @@
access |
kind
)
- \%]
+ \%{js:keyword-end}
</start>
<end>(?=\S)</end>
<include>
@@ -168,7 +168,7 @@
typeParam | # tsdoc
this
)
- \%]
+ \%{js:keyword-end}
)
</start>
<end>(?=\S)</end>
@@ -198,7 +198,7 @@
typedef |
var
)
- \%]
+ \%{js:keyword-end}
</start>
<end>(?=\S)</end>
<include>
@@ -210,7 +210,9 @@
</context>
<context id="borrows-block-tag" end-at-line-end="true">
- <start>@borrows\%]</start>
+ <start extended="true">
+ @borrows \%{js:keyword-end}
+ </start>
<end>(?=\S)</end>
<include>
<context sub-pattern="0" where="start" style-ref="block-tag"/>
@@ -221,7 +223,9 @@
</context>
<context end-parent="true">
- <start>\%[as\%]</start>
+ <start extended="true">
+ \%{js:keyword-start} as \%{js:keyword-end}
+ </start>
<end>(?=\S)</end>
<include>
<context ref="argument" style-ref="namepath"/>
@@ -232,7 +236,9 @@
</context>
<context id="note-block-tag" style-ref="block-tag">
- <match>@todo\%]</match>
+ <match extended="true">
+ @todo \%{js:keyword-end}
+ </match>
<include>
<context sub-pattern="0" style-ref="note"/>
</include>
diff --git a/data/language-specs/objj.lang b/data/language-specs/objj.lang
index b99b0f98..7fd00d16 100644
--- a/data/language-specs/objj.lang
+++ b/data/language-specs/objj.lang
@@ -84,7 +84,7 @@
undef |
warning
)
- \%]
+ \%{js:keyword-end}
</start>
<include>
<context ref="def:line-continue"/>
@@ -143,7 +143,9 @@
<!-- # @class statement -->
<context id="at-class-statements">
- <start>@class\%]</start>
+ <start extended="true">
+ @class \%{js:keyword-end}
+ </start>
<end>\%{js:identifier}</end>
<include>
<context sub-pattern="0" where="start" style-ref="js:keyword"/>
@@ -157,7 +159,9 @@
<!-- # @global statement -->
<context id="at-global-statements">
- <start>@global\%]</start>
+ <start extended="true">
+ @global \%{js:keyword-end}
+ </start>
<end>\%{js:identifier}</end>
<include>
<context sub-pattern="0" where="start" style-ref="js:keyword"/>
@@ -198,7 +202,9 @@
</context> <!-- /_at-implementation-variable-declaration-accessor-modifiers-end-parent -->
<context id="_at-implementation-variable-declaration-accessors">
- <start>@accessors\%]</start>
+ <start extended="true">
+ @accessors \%{js:keyword-end}
+ </start>
<end>\%{js:before-next-token}</end>
<include>
<context sub-pattern="0" where="start" style-ref="js:keyword"/>
@@ -264,8 +270,12 @@
<!-- ## @implementation declaration -->
<context id="at-implementation-declarations">
- <start>@implementation\%]</start>
- <end>@end\%]</end>
+ <start extended="true">
+ @implementation \%{js:keyword-end}
+ </start>
+ <end extended="true">
+ @end \%{js:keyword-end}
+ </end>
<include>
<context sub-pattern="0" where="start" style-ref="js:keyword"/>
<context sub-pattern="0" where="end" style-ref="js:keyword"/>
@@ -286,7 +296,9 @@
<!-- # @import statement -->
<context id="at-import-statements" style-ref="js:directive">
- <start>@import\%]</start>
+ <start extended="true">
+ @import \%{js:keyword-end}
+ </start>
<include>
<context ref="js:embedded-lang-hooks"/>
<context ref="js:comments"/>
@@ -310,8 +322,12 @@
<!-- # @protocol declaration -->
<context id="at-protocol-declarations">
- <start>@protocol\%]</start>
- <end>@end\%]</end>
+ <start extended="true">
+ @protocol \%{js:keyword-end}
+ </start>
+ <end extended="true">
+ @end \%{js:keyword-end}
+ </end>
<include>
<context sub-pattern="0" where="start" style-ref="js:keyword"/>
<context sub-pattern="0" where="end" style-ref="js:keyword"/>
@@ -343,7 +359,9 @@
<!-- # @typedef statements -->
<context id="at-typedef-statements">
- <start>@typedef\%]</start>
+ <start extended="true">
+ @typedef \%{js:keyword-end}
+ </start>
<end>\%{js:identifier}</end>
<include>
<context sub-pattern="0" where="start" style-ref="js:keyword"/>
@@ -400,7 +418,7 @@
<!-- ## Literals -->
<define-regex id="_at-function-keyword" extended="true">
- @ (?: deref | ref ) \%]
+ @ (?: deref | ref ) \%{js:keyword-end}
</define-regex> <!-- /_at-function-keyword -->
<context id="_choice-at-function-keyword" style-ref="js:keyword" end-parent="true">
@@ -409,7 +427,9 @@
</context> <!-- /_choice-at-function-keyword -->
<context id="_choice-at-selector-literal" end-parent="true">
- <start>@selector\%]</start>
+ <start extended="true">
+ @selector \%{js:keyword-end}
+ </start>
<include>
<context sub-pattern="0" where="start" style-ref="js:keyword"/>
<context ref="js:embedded-lang-hooks"/>
diff --git a/data/language-specs/typescript-js-expressions.lang
b/data/language-specs/typescript-js-expressions.lang
index 4c8bad26..0460c634 100644
--- a/data/language-specs/typescript-js-expressions.lang
+++ b/data/language-specs/typescript-js-expressions.lang
@@ -167,7 +167,9 @@
-->
<context id="_as-operators">
- <start>\%[as\%]</start>
+ <start extended="true">
+ \%{js:keyword-start} as \%{js:keyword-end}
+ </start>
<end>\%{js:before-next-token}</end>
<include>
<context sub-pattern="0" where="start" style-ref="typescript:type-keyword"/>
diff --git a/data/language-specs/typescript-js-functions-classes.lang
b/data/language-specs/typescript-js-functions-classes.lang
index 086cf20a..6c629bff 100644
--- a/data/language-specs/typescript-js-functions-classes.lang
+++ b/data/language-specs/typescript-js-functions-classes.lang
@@ -171,7 +171,9 @@
<!-- ## Class expression keyword -->
<context id="_class-expression-abstract-keyword" style-ref="js:keyword" once-only="true">
- <match>\%[abstract\%]</match>
+ <match extended="true">
+ \%{js:keyword-start} abstract \%{js:keyword-end}
+ </match>
</context> <!-- /_class-expression-abstract-keyword -->
<context id="_ordered-class-expression-abstract-keyword" once-only="true">
@@ -183,7 +185,9 @@
</context> <!-- /_ordered-class-expression-abstract-keyword -->
<context id="_class-expression-class-keyword" style-ref="js:keyword" once-only="true">
- <match>\%[class\%]</match>
+ <match extended="true">
+ \%{js:keyword-start} class \%{js:keyword-end}
+ </match>
</context> <!-- /_class-expression-class-keyword -->
<context id="_ordered-class-expression-class-keyword" once-only="true">
@@ -201,7 +205,9 @@
<include>
<context id="_choice-class-optional-name-ignore-implements" end-parent="true">
- <start>(?=\%[implements\%])</start>
+ <start extended="true">
+ (?= \%{js:keyword-start} implements \%{js:keyword-end} )
+ </start>
<end>\%{def:always-match}</end>
</context> <!-- /_choice-class-optional-name-ignore-implements -->
@@ -222,7 +228,9 @@
<!-- ## Class implements clause -->
<context id="_class-implements-clause" once-only="true">
- <start>\%[implements\%]</start>
+ <start extended="true">
+ \%{js:keyword-start} implements \%{js:keyword-end}
+ </start>
<end>\%{js:before-next-token}</end>
<include>
<context sub-pattern="0" where="start" style-ref="typescript:type-keyword"/>
diff --git a/data/language-specs/typescript-js-modules.lang b/data/language-specs/typescript-js-modules.lang
index c3b5296a..cb829421 100644
--- a/data/language-specs/typescript-js-modules.lang
+++ b/data/language-specs/typescript-js-modules.lang
@@ -39,7 +39,9 @@
-->
<context id="_export-as-namespace-keyword" style-ref="js:keyword" once-only="true">
- <match>\%[namespace\%]</match>
+ <match extended="true">
+ \%{js:keyword-start} namespace \%{js:keyword-end}
+ </match>
</context> <!-- /_export-as-namespace-keyword -->
<context id="_ordered-export-as-namespace-keyword" once-only="true">
@@ -51,7 +53,9 @@
</context> <!-- /_ordered-export-as-namespace-keyword -->
<context id="_choice-export-as-namespace" end-parent="true">
- <start>\%[as\%]</start>
+ <start extended="true">
+ \%{js:keyword-start} as \%{js:keyword-end}
+ </start>
<end>\%{js:statement-end}</end>
<include>
<context sub-pattern="0" where="start" style-ref="js:keyword"/>
@@ -120,7 +124,9 @@
-->
<context id="_choice-import-require" end-parent="true">
- <start>\%[require\%]</start>
+ <start extended="true">
+ \%{js:keyword-start} require \%{js:keyword-end}
+ </start>
<end>\%{js:statement-end}</end>
<include>
<context sub-pattern="0" where="start" style-ref="js:keyword"/>
@@ -196,7 +202,7 @@
<!-- ## Import declaration -->
<define-regex id="_import-declaration-keyword" extended="true">
- \%[ import \%]
+ \%{js:keyword-start} import \%{js:keyword-end}
(?! \%{js:import-function-keyword-suffix} )
(?! \%{typescript:import-meta-object-keyword-suffix} )
</define-regex>
diff --git a/data/language-specs/typescript-js-statements.lang
b/data/language-specs/typescript-js-statements.lang
index 70e13fb1..2ea63ec8 100644
--- a/data/language-specs/typescript-js-statements.lang
+++ b/data/language-specs/typescript-js-statements.lang
@@ -72,11 +72,13 @@
-->
<define-regex id="_ambient-declaration-keyword" extended="true">
- \%[ declare \%]
+ \%{js:keyword-start} declare \%{js:keyword-end}
</define-regex> <!-- /_ambient-declaration-keyword -->
<context id="_choice-global-augmentation" style-ref="typescript:global-augmentation" end-parent="true">
- <start>\%[global\%]</start>
+ <start extended="true">
+ \%{js:keyword-start} global \%{js:keyword-end}
+ </start>
<end>\%{js:before-next-token}</end>
<include>
<context sub-pattern="0" where="start" style-ref="js:keyword"/>
@@ -136,7 +138,7 @@
-->
<define-regex id="_const-declaration-keyword" extended="true">
- \%[ const \%]
+ \%{js:keyword-start} const \%{js:keyword-end}
</define-regex> <!-- /_const-declaration-keyword -->
<context id="_const-declaration-content">
@@ -182,7 +184,7 @@
-->
<define-regex id="_enum-declaration-keyword" extended="true">
- \%[ enum \%]
+ \%{js:keyword-start} enum \%{js:keyword-end}
</define-regex> <!-- /_enum-declaration-keyword -->
<context id="_enum-member-content">
@@ -271,11 +273,13 @@
-->
<define-regex id="_interface-declaration-keyword" extended="true">
- \%[ interface \%]
+ \%{js:keyword-start} interface \%{js:keyword-end}
</define-regex> <!-- /_interface-declaration-keyword -->
<context id="_interface-extends-clause" once-only="true">
- <start>\%[extends\%]</start>
+ <start extended="true">
+ \%{js:keyword-start} extends \%{js:keyword-end}
+ </start>
<end>\%{js:before-next-token}</end>
<include>
<context sub-pattern="0" where="start" style-ref="typescript:type-keyword"/>
@@ -338,7 +342,7 @@
-->
<define-regex id="_module-declaration-keyword" extended="true">
- \%[ module \%]
+ \%{js:keyword-start} module \%{js:keyword-end}
</define-regex> <!-- /_module-declaration-keyword -->
<context id="_module-identifier-or-string" once-only="true">
@@ -401,7 +405,7 @@
-->
<define-regex id="_namespace-declaration-keyword" extended="true">
- \%[ namespace \%]
+ \%{js:keyword-start} namespace \%{js:keyword-end}
</define-regex> <!-- /_namespace-declaration-keyword -->
<context id="_namespace-body" once-only="true">
@@ -468,7 +472,7 @@
-->
<define-regex id="_type-alias-declaration-keyword" extended="true">
- \%[ type \%]
+ \%{js:keyword-start} type \%{js:keyword-end}
</define-regex> <!-- /_type-alias-declaration-keyword -->
<context id="_type-alias-value" once-only="true">
diff --git a/data/language-specs/typescript-js-values.lang b/data/language-specs/typescript-js-values.lang
index 1365356f..0aae2c59 100644
--- a/data/language-specs/typescript-js-values.lang
+++ b/data/language-specs/typescript-js-values.lang
@@ -40,9 +40,12 @@
<!-- import.meta: stage 3 proposal -->
<context id="_import-meta-object-keywords">
<start extended="true">
- \%[ import \%] (?= \%{typescript:import-meta-object-keyword-suffix} )
+ \%{js:keyword-start} import \%{js:keyword-end}
+ (?= \%{typescript:import-meta-object-keyword-suffix} )
</start>
- <end>\%[meta\%]</end>
+ <end extended="true">
+ \%{js:keyword-start} meta \%{js:keyword-end}
+ </end>
<include>
<context sub-pattern="0" where="start" style-ref="js:keyword"/>
<context sub-pattern="0" where="end" style-ref="js:keyword"/>
diff --git a/data/language-specs/typescript-jsx.lang b/data/language-specs/typescript-jsx.lang
index b8fecc4e..548d86dc 100644
--- a/data/language-specs/typescript-jsx.lang
+++ b/data/language-specs/typescript-jsx.lang
@@ -61,7 +61,7 @@
any definitive documentation -->
<context id="_jsx-comment-pragmas" style-ref="js:directive" class="comment">
<start case-sensitive="false" extended="true">
- /\*\*? \%{js:whitespace}* @jsx \%]
+ /\*\*? \%{js:whitespace}* @jsx \%{js:keyword-end}
</start>
<end>\*/</end>
<include>
@@ -71,7 +71,7 @@
<context id="_jsx-comment-pragmas-no-extend-parent" style-ref="js:directive" class="comment"
extend-parent="false">
<start extended="true">
- /\*\*? \%{js:whitespace}* @jsx \%]
+ /\*\*? \%{js:whitespace}* @jsx \%{js:keyword-end}
</start>
<end>\*/</end>
<include>
@@ -132,7 +132,7 @@
\%{js:identifier}
\%{js:optional-whitespace-or-comments}
(?:
- \%[ extends \%] |
+ \%{js:keyword-start} extends \%{js:keyword-end} |
, |
=
)
diff --git a/data/language-specs/typescript-type-expressions.lang
b/data/language-specs/typescript-type-expressions.lang
index 9f3c34c3..6a5816ad 100644
--- a/data/language-specs/typescript-type-expressions.lang
+++ b/data/language-specs/typescript-type-expressions.lang
@@ -41,7 +41,9 @@
-->
<context id="_choice-infer-declaration" end-parent="true">
- <start>\%[infer\%]</start>
+ <start extended="true">
+ \%{js:keyword-start} infer \%{js:keyword-end}
+ </start>
<end>\%{js:before-next-token}</end>
<include>
<context sub-pattern="0" where="start" style-ref="typescript:type-keyword"/>
@@ -72,21 +74,29 @@
<context ref="typescript-type-gen:type-parameters-list"/>
<context id="_asserts-type-predicate" style-ref="typescript:type-keyword" once-only="true">
- <match>\%[asserts\%]</match>
+ <match extended="true">
+ \%{js:keyword-start} asserts \%{js:keyword-end}
+ </match>
</context> <!-- /_asserts-type-predicate -->
<context id="_indexed-type-query" style-ref="typescript:type-keyword" once-only="true">
- <match>\%[keyof\%]</match>
+ <match extended="true">
+ \%{js:keyword-start} keyof \%{js:keyword-end}
+ </match>
</context> <!-- /_indexed-type-query -->
<context id="_readonly-type-modifier" style-ref="typescript:type-keyword" once-only="true">
- <match>\%[readonly\%]</match>
+ <match extended="true">
+ \%{js:keyword-start} readonly \%{js:keyword-end}
+ </match>
</context> <!-- /_readonly-type-modifier -->
<!-- for unique symbol subtype, can contain newlines between
"unique" and "symbol" -->
<context id="_unique-symbol-subtype" style-ref="typescript:basic-type" once-only="true">
- <match>\%[unique\%]</match>
+ <match extended="true">
+ \%{js:keyword-start} unique \%{js:keyword-end}
+ </match>
</context> <!-- /_unique-symbol-subtype -->
</include>
@@ -279,7 +289,9 @@
<!-- <TypeQuery> -->
<context id="_choice-type-query" style-ref="typescript:type-query" end-parent="true">
- <start>\%[typeof\%]</start>
+ <start extended="true">
+ \%{js:keyword-start} typeof \%{js:keyword-end}
+ </start>
<end>\%{js:before-next-token}</end>
<include>
<context sub-pattern="0" where="start" style-ref="typescript:type-keyword"/>
@@ -394,7 +406,9 @@
</context> <!-- /_choice-conditional-type-operator-super-type -->
<context id="_conditional-type-operators">
- <start>\%[extends\%]</start>
+ <start extended="true">
+ \%{js:keyword-start} extends \%{js:keyword-end}
+ </start>
<end>\%{js:before-next-token}</end>
<include>
<context sub-pattern="0" where="start" style-ref="typescript:type-keyword"/>
@@ -461,7 +475,9 @@
</context> <!-- /_union-intersection-type-operators -->
<context id="_type-predicate-operators">
- <start>\%[is\%]</start>
+ <start extended="true">
+ \%{js:keyword-start} is \%{js:keyword-end}
+ </start>
<end>\%{js:before-next-token}</end>
<include>
<context sub-pattern="0" where="start" style-ref="typescript:type-keyword"/>
diff --git a/data/language-specs/typescript-type-generics.lang
b/data/language-specs/typescript-type-generics.lang
index 6229349e..1135283b 100644
--- a/data/language-specs/typescript-type-generics.lang
+++ b/data/language-specs/typescript-type-generics.lang
@@ -39,7 +39,9 @@
<!-- <Constraint> -->
<context id="_type-parameter-constraint" once-only="true">
- <start>\%[extends\%]</start>
+ <start extended="true">
+ \%{js:keyword-start} extends \%{js:keyword-end}
+ </start>
<end>\%{js:before-next-token}</end>
<include>
<context sub-pattern="0" where="start" style-ref="typescript:type-keyword"/>
@@ -151,7 +153,9 @@
-->
<context id="const-type-assertion-keyword-end-parent" style-ref="typescript:type-keyword"
end-parent="true">
- <start>(?=\%[const\%])</start>
+ <start extended="true">
+ (?= \%{js:keyword-start} const \%{js:keyword-end} )
+ </start>
<end>const</end>
</context> <!-- /const-type-assertion-keyword-end-parent -->
diff --git a/data/language-specs/typescript-type-literals.lang
b/data/language-specs/typescript-type-literals.lang
index 2ba3ad51..541e17dd 100644
--- a/data/language-specs/typescript-type-literals.lang
+++ b/data/language-specs/typescript-type-literals.lang
@@ -38,7 +38,7 @@
-->
<define-regex id="_basic-types" extended="true">
- \%[
+ \%{js:keyword-start}
(?:
any |
bigint |
@@ -53,7 +53,7 @@
unknown |
void
)
- \%]
+ \%{js:keyword-end}
</define-regex> <!-- /_basic-types -->
<!-- <PredefinedType> -->
@@ -70,7 +70,7 @@
-->
<define-regex id="_boolean-types" extended="true">
- \%[ (?: false | true ) \%]
+ \%{js:keyword-start} (?: false | true ) \%{js:keyword-end}
</define-regex> <!-- /_boolean-literal-types -->
<!-- <PredefinedType> -->
@@ -107,7 +107,9 @@
<!-- <ThisType> -->
<context id="choice-this-type" style-ref="typescript:basic-type" end-parent="true">
- <start>(?=\%[this\%])</start>
+ <start extended="true">
+ (?= \%{js:keyword-start} this \%{js:keyword-end} )
+ </start>
<end>this</end>
</context> <!-- /choice-this-type -->
@@ -235,7 +237,9 @@
<context ref="typescript:choice-type-annotation"/>
<context id="_choice-mapped-type" end-parent="true">
- <start>\%[in\%]</start>
+ <start extended="true">
+ \%{js:keyword-start} in \%{js:keyword-end}
+ </start>
<end>\%{js:before-next-token}</end>
<include>
<context sub-pattern="0" where="start" style-ref="typescript:type-keyword"/>
diff --git a/data/language-specs/typescript.lang b/data/language-specs/typescript.lang
index 0b182830..33e2c4c9 100644
--- a/data/language-specs/typescript.lang
+++ b/data/language-specs/typescript.lang
@@ -115,7 +115,7 @@
\%{js:optional-whitespace-or-comments}
\.
\%{js:optional-whitespace-or-comments}
- meta \%]
+ meta \%{js:keyword-end}
</define-regex> <!-- /import-meta-object-keyword-suffix -->
<!-- no line terminator allowed between "abstract" and "class"
@@ -123,10 +123,10 @@
abstract class expressions -->
<define-regex id="class-expression-keyword" extended="true">
(?:
- \%[ abstract \%]
+ \%{js:keyword-start} abstract \%{js:keyword-end}
\%{js:optional-whitespace-or-comments}
)?
- \%[ class \%]
+ \%{js:keyword-start} class \%{js:keyword-end}
</define-regex> <!-- / -->
<context id="js-ordered-string" once-only="true">
@@ -149,7 +149,7 @@
-->
<context id="_ts-ignore-comment-pragmas" style-ref="js:directive" end-at-line-end="true" class="comment">
<start extended="true">
- ///? \%{js:whitespace}* @ts-ignore \%]
+ ///? \%{js:whitespace}* @ts-ignore \%{js:keyword-end}
</start>
<include>
<context ref="js:_comment-content"/>
@@ -158,7 +158,7 @@
<context id="_ts-ignore-comment-pragmas-no-extend-parent" style-ref="js:directive"
end-at-line-end="true" class="comment" extend-parent="false">
<start extended="true">
- ///? \%{js:whitespace}* @ts-ignore \%]
+ ///? \%{js:whitespace}* @ts-ignore \%{js:keyword-end}
</start>
<include>
<context ref="js:_comment-content"/>
@@ -176,7 +176,7 @@
<context id="_ts-nocheck-comment-pragmas" style-ref="js:directive" end-at-line-end="true"
class="comment">
<start case-sensitive="false" extended="true">
- ///? \s* @ts-nocheck \%]
+ ///? \s* @ts-nocheck \%{js:keyword-end}
</start>
<include>
<context ref="js:_comment-content"/>
@@ -324,7 +324,9 @@
<include>
<context id="_choice-this-parameter" style-ref="js:keyword" end-parent="true">
- <match>\%[this\%]</match>
+ <match extended="true">
+ \%{js:keyword-start} this \%{js:keyword-end}
+ </match>
</context> <!-- /_choice-this-parameter -->
<context id="_js-choice-binding" end-parent="true">
@@ -548,7 +550,9 @@
</context> <!-- /_ordered-import-type-trailing-dot -->
<context id="_import-type" once-only="true">
- <start>\%[import\%]</start>
+ <start extended="true">
+ \%{js:keyword-start} import \%{js:keyword-end}
+ </start>
<end>\%{js:before-next-token}</end>
<include>
<context sub-pattern="0" where="start" style-ref="type-keyword"/>
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]