-
Notifications
You must be signed in to change notification settings - Fork 0
/
a.js
123 lines (122 loc) · 5.05 KB
/
a.js
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
{ lex:
{ rules:
[ [ [ '*' ],
'<!---',
'yy.ex.matchedrule(0, this, arguments); return \'null\';' ],
[ [ 'infragtag' ],
'fragment\\b',
'yy.ex.matchedrule(1, this, arguments); return \'FRAG_TAG_START_OPEN\';' ],
[ [ 'infragtag' ],
'\\/fragment\\b',
'yy.ex.matchedrule(2, this, arguments); return \'FRAG_TAG_START_CLOSE\';' ],
[ [ 'infragtag' ],
'--->',
'yy.ex.matchedrule(3, this, arguments); return \'null\';' ],
[ [ 'infragtag' ],
'\\/--->',
'yy.ex.matchedrule(4, this, arguments); return \'null\';' ],
[ [ 'infragtag' ],
'yy.ex.matchedrule(5, this, arguments); return \'null\';' ],
[ [ 'infragtag' ],
'yy.ex.matchedrule(6, this, arguments); return \'null\';' ],
[ [ 'infragtag' ],
'\\.include\\b',
'yy.ex.matchedrule(7, this, arguments); return \'FRAG_TAG_CMD\';' ],
[ [ 'infragtag' ],
'\\.define\\b',
'yy.ex.matchedrule(8, this, arguments); return \'FRAG_TAG_CMD\';' ],
[ [ 'infragtag' ],
'[a-zA-Z]+',
'yy.ex.matchedrule(9, this, arguments); return \'FRAG_TAG_ATR_NAME\';' ],
[ [ 'infragtag' ],
'="',
'yy.ex.matchedrule(10, this, arguments); return \'null\';' ],
[ [ 'infragtagattr' ],
'"',
'yy.ex.matchedrule(11, this, arguments); return \'null\';' ],
[ [ 'infragtagattr' ],
'[^\\"\\n]+',
'yy.ex.matchedrule(12, this, arguments); return \'FRAG_TAG_ATR_VALUE\';' ],
[ '.+',
'yy.ex.matchedrule(13, this, arguments); return \'null\';' ],
[ [ 'INITIAL' ],
'\\n+',
'yy.ex.matchedrule(14, this, arguments); return \'null\';' ],
[ [ 'normal' ],
'[^<\\n]+',
'yy.ex.matchedrule(15, this, arguments); return \'NORM_CONTENT\';' ],
[ [ 'normal' ],
'<',
'yy.ex.matchedrule(16, this, arguments); return \'NORM_CONTENT\';' ],
[ [ 'normal' ],
'\\n+',
'yy.ex.matchedrule(17, this, arguments); return \'NORM_CONTENT\';' ],
[ [ 'normal' ],
'.+',
'yy.ex.matchedrule(18, this, arguments); return \'NORM_CONTENT\';' ],
[ [ '*' ],
'$',
'yy.ex.matchedrule(19, this, arguments); return \'EOF\';' ] ],
macros:
{ COMMENTCLOSE: '--->',
COMMENTOPEN: '<!---',
COMMENTFIRST: '<' },
startConditions:
{ infragtagattr: 1,
infragtag: 1,
normal: 1 } },
start: 'file',
bnf:
{ file:
[ [ 'sections EOF',
'var util = require(\'util\');console.log("We\'re done. DISCO!");console.log(util.inspect($1,false,4,true)); return $1;' ] ],
sections:
[ [ 'section',
'console.log(\'G2:\',$1);$$ = [$1];' ],
[ 'sections section',
'console.log(\'G1:\',$1);$$ = $1.concat($2);' ] ],
section:
[ [ 'fragtag',
'$$ = $1; $$[\'type\']=\'frgtag\';' ],
'normal' ],
fragtag:
[ 'fragtag_selfclosing',
'fragtag_openandclose' ],
fragtag_openandclose:
[ 'fragtag_open fragtag_close',
[ 'fragtag_open normal fragtag_close',
'$$ = $1; $$[\'content\']=$2; $$[\'raw\'] += $2.raw + $3.raw ' ] ],
fragtag_open:
[ [ 'FRAG_TAG_START FRAG_TAG_START_OPEN FRAG_TAG_CMD fragtag_attributes FRAG_TAG_END_OPEN',
'$$ = {command:$3, attributes:$4.hash, raw: \'<!---fragment\' + $3 + $4.raw + \'--->\', raw1: \'<!---fragment\' + $3 + $4.raw + \'--->\', raw3: \'<!---/fragment\' + $3 + \'--->\'};' ],
[ 'FRAG_TAG_START FRAG_TAG_START_OPEN FRAG_TAG_CMD FRAG_TAG_END_OPEN',
'$$ = {command:$3}' ] ],
fragtag_close:
[ [ 'FRAG_TAG_START FRAG_TAG_START_CLOSE FRAG_TAG_CMD FRAG_TAG_END_OPEN',
'$$ = {raw:$1 + $2 + $3 + $4}' ] ],
fragtag_selfclosing:
[ [ 'FRAG_TAG_START FRAG_TAG_START_OPEN FRAG_TAG_CMD fragtag_attributes FRAG_TAG_END_CLOSED',
'$$ ={command:$3, attributes:$4.hash, raw: \'<!---fragment\' + $3 + $4.raw + \'/--->\', raw1: \'<!---fragment\' + $3 + $4.raw + \'--->\', raw3: \'<!---/fragment\' + $3 + \'--->\'}' ] ],
fragtag_attributes:
[ [ 'fragtag_attribute',
'$$ = {hash:{}, raw:\'\'}; $$.hash[$1.name] = $1.value; $$.raw += $1.raw ' ],
[ 'fragtag_attributes fragtag_attribute',
'$$ = $1; $$.hash[$2.name] = $2.value; $$.raw += $2.raw ' ] ],
fragtag_attribute:
[ [ 'FRAG_TAG_ATR_NAME FRAG_TAG_ATR_START FRAG_TAG_ATR_VALUE FRAG_TAG_ATR_END',
'$$ = {name:$1, value:$3, raw: \' \' + $1 + $2 + $3 + $4}' ] ],
fragtag_contents:
[ 'FRAG_TAG_CONTENT',
[ 'FRAG_TAG_CONTENT fragtag_contents',
'$$ = $1 + $2;' ] ],
normal:
[ [ 'normalw',
'$$ = {type:\'normal\', raw:$1};' ] ],
normalw:
[ 'NORM_START',
[ 'NORM_START norm_contents',
'$$ = $1 + $2;' ] ],
norm_contents:
[ 'NORM_CONTENT',
[ 'NORM_CONTENT norm_contents',
'$$ = $1 + $2;' ] ] } }