8
<INITIAL>[\s\S]+?(?="#(") { this.pushState('trans'); return 'TEXT'; }
9
<INITIAL>[\s\S]+ { return 'TEXT'; }
11
<trans>"#"(?="(") { return 'TOPIC_SIGILS'; }
12
<trans>"(" { this.popState(); this.pushState('codes'); return 'DOWN'; }
14
<codes>[\$@#]+(?=[\r\n\s)]) { return 'TOPIC_SIGILS_EMPTY'; }
15
<codes>[\$@#]+ { return 'TOPIC_SIGILS'; }
16
<codes>"(" { this.pushState('codes'); return 'DOWN'; }
18
<codes>"\""{3}[\s\S]*?"\""{3,} { return 'QUOTES3'; }
19
<codes>"'"{3}[\s\S]*?"'"{3,} { return 'QUOTES3'; }
21
<codes>"\""(?:[^"\x5c]|\\[\s\S])*?"\"" { return 'QUOTES1'; }
22
<codes>"'"(?:[^'\x5c]|\\[\s\S])*?"'" { return 'QUOTES1'; }
24
<codes>[^\r\n\s)]+ { return 'QUOTES0'; }
26
<codes>")" { this.popState(); return 'UP'; }
27
<codes>[\r\n\s]+ /* skip */
37
: { $$ = []; return $$; }
38
| items { $$ = $1; return $$; }
43
| items item { $$ = $1.concat([$2]); }
46
item : literal | string | node ;
49
: TEXT { $$ = MARKUP.literalText($1); }
53
: string_nosigil { $$ = $1; }
54
| TOPIC_SIGILS string_nosigil { $$ = MARKUP.withSigils($1,$2); }
58
: QUOTES3 { $$ = MARKUP.quote3($1.slice(3,-3), $1.slice(0,3)); }
59
| QUOTES1 { $$ = MARKUP.quote1($1.slice(1,-1), $1.slice(0,1)); }
60
| QUOTES0 { $$ = MARKUP.quote0($1); }
65
| TOPIC_SIGILS node_nosigil { $$ = MARKUP.withSigils($1,$2); }
66
| TOPIC_SIGILS_EMPTY { $$ = MARKUP.withSigils($1, MARKUP.quoteImpliedEmpty()); }
70
: DOWN items UP { $$ = MARKUP.node($2) }
77
each : function(map, fn) {
79
if(Object.prototype.hasOwnProperty.call(map, k)) {
80
if(fn(map[k], k) === false) break;
84
tag : function(name, data, more) {
85
return MARKUP.tagObject(name, data, more);
87
tagObject : function(name, data, more) {
89
MARKUP.each(more, function(v,k) {
92
if(String(name) === name)
94
if(!(data === null || data === void(0)))
98
withOneSigil : function(sigil, item) {
99
return MARKUP.tag("sigils", item, { sigil : sigil });
101
withSigils : function(sigils, item) {
102
return (sigils.length <= 1) ?
103
MARKUP.withOneSigil(sigils, item) :
104
MARKUP.withOneSigil(sigils.slice(0,1), MARKUP.withSigils(sigils.slice(1), item));
106
quote3 : function(rawText, quote) {
107
return MARKUP.tag("string", rawText, { quote : quote });
109
quote1 : function(rawText, quote) {
110
var text = rawText.replace(/\\(?:x([0-9A-Fa-f]{2})|u([0-9A-Fa-f]{4})|([\S\s]))/g, function(match, xc, uc, sc, offset, string) {
111
if(String(sc) === sc) {
115
var h = parseInt( (String(xc) === xc) ? xc : uc, 16 );
116
return String.fromCharCode(h);
119
return MARKUP.tag("string", text, { quote : quote, rawText : rawText });
121
quote0 : function(rawText) {
122
return MARKUP.tag("string", rawText);
124
quoteImpliedEmpty : function() {
125
return MARKUP.tag("string");
127
literalText : function(text) {
128
return MARKUP.tag("literal", text);
130
node : function(list) {
131
return MARKUP.tag("node", list);