1- import { insertBefore } from '../util/language-util.js' ;
21import csharp from './csharp.js' ;
32import markup from './markup.js' ;
43
@@ -16,42 +15,11 @@ export default {
1615 pattern : / < % \s * ?[ $ = % # : ] { 0 , 2 } | % > / ,
1716 alias : 'tag' ,
1817 } ,
19- $rest : /** @type { Grammar['$rest'] } */ ( ' csharp') ,
18+ $rest : ' csharp',
2019 } ,
2120 } ) ;
2221
23- const tag =
24- /** @type {GrammarToken & { inside: { 'attr-value': { inside: Grammar } } } } */ (
25- base [ 'tag' ]
26- ) ;
27-
28- // Regexp copied from markup, with a negative look-ahead added
29- tag . pattern =
30- / < (? ! % ) \/ ? [ ^ \s > \/ ] + (?: \s + [ ^ \s > \/ = ] + (?: = (?: ( " | ' ) (?: \\ [ \s \S ] | (? ! \1) [ ^ \\ ] ) * \1| [ ^ \s ' " > = ] + ) ) ? ) * \s * \/ ? > / ;
31-
32- // match directives of attribute value foo="<% Bar %>"
33- insertBefore ( tag . inside [ 'attr-value' ] . inside , 'punctuation' , {
34- 'directive' : directive ,
35- } ) ;
36-
37- insertBefore ( base , 'comment' , {
38- 'asp-comment' : {
39- pattern : / < % - - [ \s \S ] * ?- - % > / ,
40- alias : [ 'asp' , 'comment' ] ,
41- } ,
42- } ) ;
43-
44- // script runat="server" contains csharp, not javascript
45- insertBefore ( base , 'script' in base ? 'script' : 'tag' , {
46- 'asp-script' : {
47- pattern : / ( < s c r i p t (? = .* r u n a t = [ ' " ] ? s e r v e r \b ) [ ^ > ] * > ) [ \s \S ] * ?(? = < \/ s c r i p t > ) / i,
48- lookbehind : true ,
49- alias : [ 'asp' , 'script' ] ,
50- inside : 'csharp' ,
51- } ,
52- } ) ;
53-
54- return /** @type {Grammar } */ ( {
22+ return {
5523 'page-directive' : {
5624 pattern : / < % \s * @ .* % > / ,
5725 alias : 'tag' ,
@@ -61,15 +29,42 @@ export default {
6129 / < % \s * @ \s * (?: A s s e m b l y | C o n t r o l | I m p l e m e n t s | I m p o r t | M a s t e r (?: T y p e ) ? | O u t p u t C a c h e | P a g e | P r e v i o u s P a g e T y p e | R e f e r e n c e | R e g i s t e r ) ? | % > / i,
6230 alias : 'tag' ,
6331 } ,
64- $rest : /** @type {Grammar['$rest'] } */ ( tag . inside ) ,
32+ $rest : /** @type {GrammarToken } */ ( base [ ' tag' ] ) . inside ,
6533 } ,
6634 } ,
6735 'directive' : directive ,
68- } ) ;
36+ $merge : {
37+ 'tag' : {
38+ // Regexp copied from markup, with a negative look-ahead added
39+ pattern :
40+ / < (? ! % ) \/ ? [ ^ \s > \/ ] + (?: \s + [ ^ \s > \/ = ] + (?: = (?: ( " | ' ) (?: \\ [ \s \S ] | (? ! \1) [ ^ \\ ] ) * \1| [ ^ \s ' " > = ] + ) ) ? ) * \s * \/ ? > / ,
41+ } ,
42+ } ,
43+ $insertBefore : {
44+ 'tag/attr-value/punctuation' : {
45+ // match directives of attribute value foo="<% Bar %>"
46+ 'directive' : directive ,
47+ } ,
48+ 'comment' : {
49+ 'asp-comment' : {
50+ pattern : / < % - - [ \s \S ] * ?- - % > / ,
51+ alias : [ 'asp' , 'comment' ] ,
52+ } ,
53+ } ,
54+ // script runat="server" contains csharp, not javascript
55+ [ 'script' in base ? 'script' : 'tag' ] : {
56+ 'asp-script' : {
57+ pattern : / ( < s c r i p t (? = .* r u n a t = [ ' " ] ? s e r v e r \b ) [ ^ > ] * > ) [ \s \S ] * ?(? = < \/ s c r i p t > ) / i,
58+ lookbehind : true ,
59+ alias : [ 'asp' , 'script' ] ,
60+ inside : 'csharp' ,
61+ } ,
62+ } ,
63+ } ,
64+ } ;
6965 } ,
7066} ;
7167
7268/**
73- * @typedef {import('../types.d.ts').Grammar } Grammar
7469 * @typedef {import('../types.d.ts').GrammarToken } GrammarToken
7570 */
0 commit comments