bo-selector
Version:
CSS selector parser based on jison
760 lines (717 loc) • 35.9 kB
JavaScript
/* parser generated by jison 0.4.13 */
/*
Returns a Parser object of the following structure:
Parser: {
yy: {}
}
Parser.prototype: {
yy: {},
trace: function(),
symbols_: {associative list: name ==> number},
terminals_: {associative list: number ==> name},
productions_: [...],
performAction: function anonymous(yytext, yyleng, yylineno, yy, yystate, $$, _$),
table: [...],
defaultActions: {...},
parseError: function(str, hash),
parse: function(input),
lexer: {
EOF: 1,
parseError: function(str, hash),
setInput: function(input),
input: function(),
unput: function(str),
more: function(),
less: function(n),
pastInput: function(),
upcomingInput: function(),
showPosition: function(),
test_match: function(regex_match_array, rule_index),
next: function(),
lex: function(),
begin: function(condition),
popState: function(),
_currentRules: function(),
topState: function(),
pushState: function(condition),
options: {
ranges: boolean (optional: true ==> token location info will include a .range[] member)
flex: boolean (optional: true ==> flex-like lexing behaviour where the rules are tested exhaustively to find the longest match)
backtrack_lexer: boolean (optional: true ==> lexer regexes are tested in order and for each matching regex the action code is invoked; the lexer terminates the scan when a token is returned by the action code)
},
performAction: function(yy, yy_, $avoiding_name_collisions, YY_START),
rules: [...],
conditions: {associative list: name ==> set},
}
}
token location info (@$, _$, etc.): {
first_line: n,
last_line: n,
first_column: n,
last_column: n,
range: [start_number, end_number] (where the numbers are indexes into the input string, regular zero-based)
}
the parseError function receives a 'hash' object with these members for lexer and parser errors: {
text: (matched text)
token: (the produced terminal token, if any)
line: (yylineno)
}
while parser (grammar) errors will also provide these members, i.e. parser errors deliver a superset of attributes: {
loc: (yylloc)
expected: (string describing the set of expected tokens)
recoverable: (boolean: TRUE when the parser has a error recovery rule available for this particular error)
}
*/
var parser = (function(){
var parser = {trace: function trace() { },
yy: {},
symbols_: {"error":2,"expressions":3,"selector_list":4,"EOF":5,"comma":6,"selector":7,",":8,"S":9,"combinator_selector":10,"simple_selector":11,"element":12,"constraint_list":13,"padded_child_combinator":14,"padded_tilde":15,"padded_plus":16,">":17,"ident":18,"*":19,"constraint":20,"class":21,"hash":22,"attrib":23,"pseudo":24,".":25,"#":26,"IDENT":27,"n":28,"[":29,"padded_ident":30,"]":31,"=":32,"padded_ident_or_string":33,"CONTAINS":34,"DOES_NOT_CONTAIN":35,"CONTAINS_WORD":36,"CONTAINS_PREFIX":37,"STARTS_WITH":38,"ENDS_WITH":39,"string":40,"~":41,"+":42,"SINGLE_QUOTED_STRING":43,"DOUBLE_QUOTED_STRING":44,":":45,"func":46,"ODD_ARGUMENT":47,"EVEN_ARGUMENT":48,"(":49,"func_arguments":50,")":51,"INTEGER":52,"an_plus_b":53,"odd":54,"even":55,"negative_integer":56,"signed_integer":57,"positive_integer":58,"unsigned_integer":59,"-":60,"NEGATIVE_INTEGER":61,"POSITIVE_INTEGER":62,"$accept":0,"$end":1},
terminals_: {2:"error",5:"EOF",8:",",9:"S",17:">",19:"*",25:".",26:"#",27:"IDENT",28:"n",29:"[",31:"]",32:"=",34:"CONTAINS",35:"DOES_NOT_CONTAIN",36:"CONTAINS_WORD",37:"CONTAINS_PREFIX",38:"STARTS_WITH",39:"ENDS_WITH",41:"~",42:"+",43:"SINGLE_QUOTED_STRING",44:"DOUBLE_QUOTED_STRING",45:":",47:"ODD_ARGUMENT",48:"EVEN_ARGUMENT",49:"(",51:")",52:"INTEGER",54:"odd",55:"even",60:"-",61:"NEGATIVE_INTEGER",62:"POSITIVE_INTEGER"},
productions_: [0,[3,2],[4,3],[4,1],[6,1],[6,2],[7,1],[7,1],[11,2],[11,1],[11,1],[10,3],[10,3],[10,3],[10,3],[10,3],[10,2],[12,1],[12,1],[13,2],[13,1],[20,1],[20,1],[20,1],[20,1],[21,2],[22,2],[18,1],[18,1],[23,3],[23,5],[23,5],[23,5],[23,5],[23,5],[23,5],[23,5],[30,3],[30,2],[30,2],[30,1],[33,1],[33,3],[33,2],[33,2],[33,1],[14,3],[14,2],[14,2],[14,1],[15,3],[15,2],[15,2],[15,1],[16,3],[16,2],[16,2],[16,1],[40,1],[40,1],[24,2],[24,2],[46,2],[46,2],[46,4],[46,4],[46,3],[50,1],[50,1],[53,1],[53,1],[53,3],[53,3],[53,3],[53,3],[53,2],[53,2],[53,2],[57,1],[57,1],[56,1],[58,1],[59,1]],
performAction: function anonymous(yytext, yyleng, yylineno, yy, yystate /* action[1] */, $$ /* vstack */, _$ /* lstack */) {
/* this == yyval */
var $0 = $$.length - 1;
switch (yystate) {
case 1: return $$[$0-1];
break;
case 2: $$[$0-2].selectors.push($$[$0]); this.$ = $$[$0-2]
break;
case 3: this.$ = yy.create({ type: 'selector_list', selectors: [$$[$0]] })
break;
case 8: $$[$0-1].constraints = $$[$0].constraints; this.$ = $$[$0-1]
break;
case 10: this.$ = yy.create(
{ type: 'constraint_list', constraints: $$[$0].constraints }
)
break;
case 11: this.$ = yy.create({ type: 'combinator_selector', left: $$[$0-2], right: $$[$0], combinator: 'child' })
break;
case 12: this.$ = yy.create({ type: 'combinator_selector', left: $$[$0-2], right: $$[$0], combinator: 'descendant' })
break;
case 13: this.$ = yy.create({ type: 'previous_sibling', left: $$[$0-2], right: $$[$0] })
break;
case 14: this.$ = yy.create({ type: 'adjacent_sibling', left: $$[$0-2], right: $$[$0] })
break;
case 15: this.$ = yy.create({ type: 'immediate_child', child: $$[$0], combinator: 'child' })
break;
case 16: this.$ = yy.create({ type: 'immediate_child', child: $$[$0], combinator: 'child' })
break;
case 17: this.$ = yy.create({ type: 'element', name: $$[$0], constraints: [] })
break;
case 18: this.$ = yy.create({ type: 'element', name: $$[$0], constraints: [] })
break;
case 19: $$[$0-1].constraints.push($$[$0]); this.$ = $$[$0-1]
break;
case 20: this.$ = yy.create({ type: 'constraint_list', constraints: [$$[$0]] })
break;
case 25: this.$ = { type: 'class', name: $$[$0] }
break;
case 26: this.$ = { type: 'id', name: $$[$0] }
break;
case 29: this.$ = yy.create({ type: 'has_attribute', name: $$[$0-1] })
break;
case 30: this.$ = yy.create({ type: 'attribute_equals', name: $$[$0-3], value: $$[$0-1] })
break;
case 31: this.$ = yy.create({ type: 'attribute_contains', name: $$[$0-3], value: $$[$0-1] })
break;
case 32: this.$ = yy.create({ type: 'attribute_does_not_contain', name: $$[$0-3], value: $$[$0-1] })
break;
case 33: this.$ = yy.create({ type: 'attribute_contains_word', name: $$[$0-3], value: $$[$0-1] })
break;
case 34: this.$ = yy.create({ type: 'attribute_contains_prefix', name: $$[$0-3], value: $$[$0-1] })
break;
case 35: this.$ = yy.create({ type: 'attribute_starts_with', name: $$[$0-3], value: $$[$0-1] })
break;
case 36: this.$ = yy.create({ type: 'attribute_ends_with', name: $$[$0-3], value: $$[$0-1] })
break;
case 37: this.$ = $$[$0-1]
break;
case 38: this.$ = $$[$0]
break;
case 39: this.$ = $$[$0-1]
break;
case 40: this.$ = $$[$0]
break;
case 42: this.$ = $$[$0-2]
break;
case 43: this.$ = $$[$0]
break;
case 44: this.$ = $$[$0-1]
break;
case 45: this.$ = $$[$0]
break;
case 58: this.$ = $$[$0].substr(1, $$[$0].length - 2)
break;
case 59: this.$ = $$[$0].substr(1, $$[$0].length - 2)
break;
case 60: this.$ = yy.create({ type: 'pseudo_func', func: $$[$0] })
break;
case 61: this.$ = yy.create({ type: 'pseudo_class', name: $$[$0] })
break;
case 62: this.$ = { type: 'function', name: $$[$0-1], args: { type: 'odd' } }
break;
case 63: this.$ = { type: 'function', name: $$[$0-1], args: { type: 'even' } }
break;
case 64: this.$ = { type: 'function', name: $$[$0-3], args: $$[$0-1] }
break;
case 65: this.$ = { type: 'function', name: $$[$0-3], args: $$[$0-1] }
break;
case 66: this.$ = { type: 'function', name: $$[$0-2] }
break;
case 69: this.$ = { type: 'odd' }
break;
case 70: this.$ = { type: 'even' }
break;
case 71: this.$ = { type: 'an_plus_b', a: $$[$0-2], b: $$[$0] }
break;
case 72: this.$ = { type: 'an_plus_b', a: $$[$0-2], b: $$[$0] }
break;
case 73: this.$ = { type: 'an_plus_b', a: $$[$0-2], b: $$[$0] }
break;
case 74: this.$ = { type: 'an_plus_b', a: -1, b: $$[$0] }
break;
case 75: this.$ = { type: 'n_plus_b', b: $$[$0] }
break;
case 76: this.$ = { type: 'an', a: $$[$0-1] }
break;
case 77: this.$ = { type: 'an', a: $$[$0-1] }
break;
case 80: this.$ = Number($$[$0])
break;
case 81: this.$ = Number($$[$0])
break;
case 82: this.$ = Number($$[$0])
break;
}
},
table: [{3:1,4:2,7:3,10:4,11:5,12:7,13:8,17:[1,6],18:9,19:[1,10],20:11,21:14,22:15,23:16,24:17,25:[1,18],26:[1,19],27:[1,12],28:[1,13],29:[1,20],45:[1,21]},{1:[3]},{5:[1,22],6:23,8:[1,24]},{5:[2,3],8:[2,3],9:[1,26],14:25,15:27,16:28,17:[1,29],41:[1,30],42:[1,31],51:[2,3]},{5:[2,6],8:[2,6],9:[2,6],17:[2,6],41:[2,6],42:[2,6],51:[2,6]},{5:[2,7],8:[2,7],9:[2,7],17:[2,7],41:[2,7],42:[2,7],51:[2,7]},{9:[1,32],11:33,12:7,13:8,18:9,19:[1,10],20:11,21:14,22:15,23:16,24:17,25:[1,18],26:[1,19],27:[1,12],28:[1,13],29:[1,20],45:[1,21]},{5:[2,9],8:[2,9],9:[2,9],13:34,17:[2,9],20:11,21:14,22:15,23:16,24:17,25:[1,18],26:[1,19],29:[1,20],41:[2,9],42:[2,9],45:[1,21],51:[2,9]},{5:[2,10],8:[2,10],9:[2,10],17:[2,10],20:35,21:14,22:15,23:16,24:17,25:[1,18],26:[1,19],29:[1,20],41:[2,10],42:[2,10],45:[1,21],51:[2,10]},{5:[2,17],8:[2,17],9:[2,17],17:[2,17],25:[2,17],26:[2,17],29:[2,17],41:[2,17],42:[2,17],45:[2,17],51:[2,17]},{5:[2,18],8:[2,18],9:[2,18],17:[2,18],25:[2,18],26:[2,18],29:[2,18],41:[2,18],42:[2,18],45:[2,18],51:[2,18]},{5:[2,20],8:[2,20],9:[2,20],17:[2,20],25:[2,20],26:[2,20],29:[2,20],41:[2,20],42:[2,20],45:[2,20],51:[2,20]},{5:[2,27],8:[2,27],9:[2,27],17:[2,27],25:[2,27],26:[2,27],29:[2,27],31:[2,27],32:[2,27],34:[2,27],35:[2,27],36:[2,27],37:[2,27],38:[2,27],39:[2,27],41:[2,27],42:[2,27],45:[2,27],47:[2,27],48:[2,27],49:[2,27],51:[2,27]},{5:[2,28],8:[2,28],9:[2,28],17:[2,28],25:[2,28],26:[2,28],29:[2,28],31:[2,28],32:[2,28],34:[2,28],35:[2,28],36:[2,28],37:[2,28],38:[2,28],39:[2,28],41:[2,28],42:[2,28],45:[2,28],47:[2,28],48:[2,28],49:[2,28],51:[2,28]},{5:[2,21],8:[2,21],9:[2,21],17:[2,21],25:[2,21],26:[2,21],29:[2,21],41:[2,21],42:[2,21],45:[2,21],51:[2,21]},{5:[2,22],8:[2,22],9:[2,22],17:[2,22],25:[2,22],26:[2,22],29:[2,22],41:[2,22],42:[2,22],45:[2,22],51:[2,22]},{5:[2,23],8:[2,23],9:[2,23],17:[2,23],25:[2,23],26:[2,23],29:[2,23],41:[2,23],42:[2,23],45:[2,23],51:[2,23]},{5:[2,24],8:[2,24],9:[2,24],17:[2,24],25:[2,24],26:[2,24],29:[2,24],41:[2,24],42:[2,24],45:[2,24],51:[2,24]},{18:36,27:[1,12],28:[1,13]},{18:37,27:[1,12],28:[1,13]},{9:[1,39],18:40,27:[1,12],28:[1,13],30:38},{18:42,27:[1,12],28:[1,13],46:41},{1:[2,1]},{7:43,10:4,11:5,12:7,13:8,17:[1,6],18:9,19:[1,10],20:11,21:14,22:15,23:16,24:17,25:[1,18],26:[1,19],27:[1,12],28:[1,13],29:[1,20],45:[1,21]},{9:[1,44],17:[2,4],19:[2,4],25:[2,4],26:[2,4],27:[2,4],28:[2,4],29:[2,4],45:[2,4]},{11:45,12:7,13:8,18:9,19:[1,10],20:11,21:14,22:15,23:16,24:17,25:[1,18],26:[1,19],27:[1,12],28:[1,13],29:[1,20],45:[1,21]},{11:46,12:7,13:8,17:[1,47],18:9,19:[1,10],20:11,21:14,22:15,23:16,24:17,25:[1,18],26:[1,19],27:[1,12],28:[1,13],29:[1,20],41:[1,48],42:[1,49],45:[1,21]},{11:50,12:7,13:8,18:9,19:[1,10],20:11,21:14,22:15,23:16,24:17,25:[1,18],26:[1,19],27:[1,12],28:[1,13],29:[1,20],45:[1,21]},{11:51,12:7,13:8,18:9,19:[1,10],20:11,21:14,22:15,23:16,24:17,25:[1,18],26:[1,19],27:[1,12],28:[1,13],29:[1,20],45:[1,21]},{9:[1,52],19:[2,49],25:[2,49],26:[2,49],27:[2,49],28:[2,49],29:[2,49],45:[2,49]},{9:[1,53],19:[2,53],25:[2,53],26:[2,53],27:[2,53],28:[2,53],29:[2,53],45:[2,53]},{9:[1,54],19:[2,57],25:[2,57],26:[2,57],27:[2,57],28:[2,57],29:[2,57],45:[2,57]},{11:55,12:7,13:8,18:9,19:[1,10],20:11,21:14,22:15,23:16,24:17,25:[1,18],26:[1,19],27:[1,12],28:[1,13],29:[1,20],45:[1,21]},{5:[2,16],8:[2,16],9:[2,16],17:[2,16],41:[2,16],42:[2,16],51:[2,16]},{5:[2,8],8:[2,8],9:[2,8],17:[2,8],20:35,21:14,22:15,23:16,24:17,25:[1,18],26:[1,19],29:[1,20],41:[2,8],42:[2,8],45:[1,21],51:[2,8]},{5:[2,19],8:[2,19],9:[2,19],17:[2,19],25:[2,19],26:[2,19],29:[2,19],41:[2,19],42:[2,19],45:[2,19],51:[2,19]},{5:[2,25],8:[2,25],9:[2,25],17:[2,25],25:[2,25],26:[2,25],29:[2,25],41:[2,25],42:[2,25],45:[2,25],51:[2,25]},{5:[2,26],8:[2,26],9:[2,26],17:[2,26],25:[2,26],26:[2,26],29:[2,26],41:[2,26],42:[2,26],45:[2,26],51:[2,26]},{31:[1,56],32:[1,57],34:[1,58],35:[1,59],36:[1,60],37:[1,61],38:[1,62],39:[1,63]},{18:64,27:[1,12],28:[1,13]},{9:[1,65],31:[2,40],32:[2,40],34:[2,40],35:[2,40],36:[2,40],37:[2,40],38:[2,40],39:[2,40]},{5:[2,60],8:[2,60],9:[2,60],17:[2,60],25:[2,60],26:[2,60],29:[2,60],41:[2,60],42:[2,60],45:[2,60],51:[2,60]},{5:[2,61],8:[2,61],9:[2,61],17:[2,61],25:[2,61],26:[2,61],29:[2,61],41:[2,61],42:[2,61],45:[2,61],47:[1,66],48:[1,67],49:[1,68],51:[2,61]},{5:[2,2],8:[2,2],9:[1,26],14:25,15:27,16:28,17:[1,29],41:[1,30],42:[1,31],51:[2,2]},{17:[2,5],19:[2,5],25:[2,5],26:[2,5],27:[2,5],28:[2,5],29:[2,5],45:[2,5]},{5:[2,11],8:[2,11],9:[2,11],17:[2,11],41:[2,11],42:[2,11],51:[2,11]},{5:[2,12],8:[2,12],9:[2,12],17:[2,12],41:[2,12],42:[2,12],51:[2,12]},{9:[1,69],19:[2,47],25:[2,47],26:[2,47],27:[2,47],28:[2,47],29:[2,47],45:[2,47]},{9:[1,70],19:[2,51],25:[2,51],26:[2,51],27:[2,51],28:[2,51],29:[2,51],45:[2,51]},{9:[1,71],19:[2,55],25:[2,55],26:[2,55],27:[2,55],28:[2,55],29:[2,55],45:[2,55]},{5:[2,13],8:[2,13],9:[2,13],17:[2,13],41:[2,13],42:[2,13],51:[2,13]},{5:[2,14],8:[2,14],9:[2,14],17:[2,14],41:[2,14],42:[2,14],51:[2,14]},{19:[2,48],25:[2,48],26:[2,48],27:[2,48],28:[2,48],29:[2,48],45:[2,48]},{19:[2,52],25:[2,52],26:[2,52],27:[2,52],28:[2,52],29:[2,52],45:[2,52]},{19:[2,56],25:[2,56],26:[2,56],27:[2,56],28:[2,56],29:[2,56],45:[2,56]},{5:[2,15],8:[2,15],9:[2,15],17:[2,15],41:[2,15],42:[2,15],51:[2,15]},{5:[2,29],8:[2,29],9:[2,29],17:[2,29],25:[2,29],26:[2,29],29:[2,29],41:[2,29],42:[2,29],45:[2,29],51:[2,29]},{9:[1,74],18:40,27:[1,12],28:[1,13],30:73,33:72,40:75,43:[1,76],44:[1,77]},{9:[1,74],18:40,27:[1,12],28:[1,13],30:73,33:78,40:75,43:[1,76],44:[1,77]},{9:[1,74],18:40,27:[1,12],28:[1,13],30:73,33:79,40:75,43:[1,76],44:[1,77]},{9:[1,74],18:40,27:[1,12],28:[1,13],30:73,33:80,40:75,43:[1,76],44:[1,77]},{9:[1,74],18:40,27:[1,12],28:[1,13],30:73,33:81,40:75,43:[1,76],44:[1,77]},{9:[1,74],18:40,27:[1,12],28:[1,13],30:73,33:82,40:75,43:[1,76],44:[1,77]},{9:[1,74],18:40,27:[1,12],28:[1,13],30:73,33:83,40:75,43:[1,76],44:[1,77]},{9:[1,84],31:[2,38],32:[2,38],34:[2,38],35:[2,38],36:[2,38],37:[2,38],38:[2,38],39:[2,38]},{31:[2,39],32:[2,39],34:[2,39],35:[2,39],36:[2,39],37:[2,39],38:[2,39],39:[2,39]},{5:[2,62],8:[2,62],9:[2,62],17:[2,62],25:[2,62],26:[2,62],29:[2,62],41:[2,62],42:[2,62],45:[2,62],51:[2,62]},{5:[2,63],8:[2,63],9:[2,63],17:[2,63],25:[2,63],26:[2,63],29:[2,63],41:[2,63],42:[2,63],45:[2,63],51:[2,63]},{4:88,7:3,10:4,11:5,12:7,13:8,17:[1,6],18:9,19:[1,10],20:11,21:14,22:15,23:16,24:17,25:[1,18],26:[1,19],27:[1,12],28:[1,96],29:[1,20],45:[1,21],50:85,51:[1,87],52:[1,86],53:89,54:[1,90],55:[1,91],56:92,58:93,59:94,60:[1,95],61:[1,97],62:[1,98]},{19:[2,46],25:[2,46],26:[2,46],27:[2,46],28:[2,46],29:[2,46],45:[2,46]},{19:[2,50],25:[2,50],26:[2,50],27:[2,50],28:[2,50],29:[2,50],45:[2,50]},{19:[2,54],25:[2,54],26:[2,54],27:[2,54],28:[2,54],29:[2,54],45:[2,54]},{31:[1,99]},{31:[2,41]},{18:64,27:[1,12],28:[1,13],40:100,43:[1,76],44:[1,77]},{9:[1,101],31:[2,45]},{9:[2,58],31:[2,58]},{9:[2,59],31:[2,59]},{31:[1,102]},{31:[1,103]},{31:[1,104]},{31:[1,105]},{31:[1,106]},{31:[1,107]},{31:[2,37],32:[2,37],34:[2,37],35:[2,37],36:[2,37],37:[2,37],38:[2,37],39:[2,37]},{51:[1,108]},{28:[2,82],51:[1,109]},{5:[2,66],8:[2,66],9:[2,66],17:[2,66],25:[2,66],26:[2,66],29:[2,66],41:[2,66],42:[2,66],45:[2,66],51:[2,66]},{6:23,8:[1,24],51:[2,67]},{51:[2,68]},{51:[2,69]},{51:[2,70]},{28:[1,110]},{28:[1,111]},{28:[1,112]},{28:[1,113]},{8:[2,28],9:[2,28],17:[2,28],25:[2,28],26:[2,28],29:[2,28],41:[2,28],42:[2,28],45:[2,28],51:[2,28],56:116,57:114,58:115,61:[1,97],62:[1,98]},{28:[2,80],51:[2,80]},{28:[2,81],51:[2,81]},{5:[2,30],8:[2,30],9:[2,30],17:[2,30],25:[2,30],26:[2,30],29:[2,30],41:[2,30],42:[2,30],45:[2,30],51:[2,30]},{9:[1,117],31:[2,43]},{31:[2,44]},{5:[2,31],8:[2,31],9:[2,31],17:[2,31],25:[2,31],26:[2,31],29:[2,31],41:[2,31],42:[2,31],45:[2,31],51:[2,31]},{5:[2,32],8:[2,32],9:[2,32],17:[2,32],25:[2,32],26:[2,32],29:[2,32],41:[2,32],42:[2,32],45:[2,32],51:[2,32]},{5:[2,33],8:[2,33],9:[2,33],17:[2,33],25:[2,33],26:[2,33],29:[2,33],41:[2,33],42:[2,33],45:[2,33],51:[2,33]},{5:[2,34],8:[2,34],9:[2,34],17:[2,34],25:[2,34],26:[2,34],29:[2,34],41:[2,34],42:[2,34],45:[2,34],51:[2,34]},{5:[2,35],8:[2,35],9:[2,35],17:[2,35],25:[2,35],26:[2,35],29:[2,35],41:[2,35],42:[2,35],45:[2,35],51:[2,35]},{5:[2,36],8:[2,36],9:[2,36],17:[2,36],25:[2,36],26:[2,36],29:[2,36],41:[2,36],42:[2,36],45:[2,36],51:[2,36]},{5:[2,64],8:[2,64],9:[2,64],17:[2,64],25:[2,64],26:[2,64],29:[2,64],41:[2,64],42:[2,64],45:[2,64],51:[2,64]},{5:[2,65],8:[2,65],9:[2,65],17:[2,65],25:[2,65],26:[2,65],29:[2,65],41:[2,65],42:[2,65],45:[2,65],51:[2,65]},{51:[2,76],56:116,57:118,58:115,61:[1,97],62:[1,98]},{56:116,57:119,58:115,61:[1,97],62:[1,98]},{51:[2,77],56:116,57:120,58:115,61:[1,97],62:[1,98]},{56:116,57:121,58:115,61:[1,97],62:[1,98]},{51:[2,75]},{51:[2,78]},{51:[2,79]},{31:[2,42]},{51:[2,71]},{51:[2,72]},{51:[2,73]},{51:[2,74]}],
defaultActions: {22:[2,1],73:[2,41],89:[2,68],90:[2,69],91:[2,70],101:[2,44],114:[2,75],115:[2,78],116:[2,79],117:[2,42],118:[2,71],119:[2,72],120:[2,73],121:[2,74]},
parseError: function parseError(str, hash) {
if (hash.recoverable) {
this.trace(str);
} else {
throw new Error(str);
}
},
parse: function parse(input) {
var self = this, stack = [0], vstack = [null], lstack = [], table = this.table, yytext = '', yylineno = 0, yyleng = 0, recovering = 0, TERROR = 2, EOF = 1;
var args = lstack.slice.call(arguments, 1);
this.lexer.setInput(input);
this.lexer.yy = this.yy;
this.yy.lexer = this.lexer;
this.yy.parser = this;
if (typeof this.lexer.yylloc == 'undefined') {
this.lexer.yylloc = {};
}
var yyloc = this.lexer.yylloc;
lstack.push(yyloc);
var ranges = this.lexer.options && this.lexer.options.ranges;
if (typeof this.yy.parseError === 'function') {
this.parseError = this.yy.parseError;
} else {
this.parseError = Object.getPrototypeOf(this).parseError;
}
function popStack(n) {
stack.length = stack.length - 2 * n;
vstack.length = vstack.length - n;
lstack.length = lstack.length - n;
}
function lex() {
var token;
token = self.lexer.lex() || EOF;
if (typeof token !== 'number') {
token = self.symbols_[token] || token;
}
return token;
}
var symbol, preErrorSymbol, state, action, a, r, yyval = {}, p, len, newState, expected;
while (true) {
state = stack[stack.length - 1];
if (this.defaultActions[state]) {
action = this.defaultActions[state];
} else {
if (symbol === null || typeof symbol == 'undefined') {
symbol = lex();
}
action = table[state] && table[state][symbol];
}
if (typeof action === 'undefined' || !action.length || !action[0]) {
var errStr = '';
expected = [];
for (p in table[state]) {
if (this.terminals_[p] && p > TERROR) {
expected.push('\'' + this.terminals_[p] + '\'');
}
}
if (this.lexer.showPosition) {
errStr = 'Parse error on line ' + (yylineno + 1) + ':\n' + this.lexer.showPosition() + '\nExpecting ' + expected.join(', ') + ', got \'' + (this.terminals_[symbol] || symbol) + '\'';
} else {
errStr = 'Parse error on line ' + (yylineno + 1) + ': Unexpected ' + (symbol == EOF ? 'end of input' : '\'' + (this.terminals_[symbol] || symbol) + '\'');
}
this.parseError(errStr, {
text: this.lexer.match,
token: this.terminals_[symbol] || symbol,
line: this.lexer.yylineno,
loc: yyloc,
expected: expected
});
}
if (action[0] instanceof Array && action.length > 1) {
throw new Error('Parse Error: multiple actions possible at state: ' + state + ', token: ' + symbol);
}
switch (action[0]) {
case 1:
stack.push(symbol);
vstack.push(this.lexer.yytext);
lstack.push(this.lexer.yylloc);
stack.push(action[1]);
symbol = null;
if (!preErrorSymbol) {
yyleng = this.lexer.yyleng;
yytext = this.lexer.yytext;
yylineno = this.lexer.yylineno;
yyloc = this.lexer.yylloc;
if (recovering > 0) {
recovering--;
}
} else {
symbol = preErrorSymbol;
preErrorSymbol = null;
}
break;
case 2:
len = this.productions_[action[1]][1];
yyval.$ = vstack[vstack.length - len];
yyval._$ = {
first_line: lstack[lstack.length - (len || 1)].first_line,
last_line: lstack[lstack.length - 1].last_line,
first_column: lstack[lstack.length - (len || 1)].first_column,
last_column: lstack[lstack.length - 1].last_column
};
if (ranges) {
yyval._$.range = [
lstack[lstack.length - (len || 1)].range[0],
lstack[lstack.length - 1].range[1]
];
}
r = this.performAction.apply(yyval, [
yytext,
yyleng,
yylineno,
this.yy,
action[1],
vstack,
lstack
].concat(args));
if (typeof r !== 'undefined') {
return r;
}
if (len) {
stack = stack.slice(0, -1 * len * 2);
vstack = vstack.slice(0, -1 * len);
lstack = lstack.slice(0, -1 * len);
}
stack.push(this.productions_[action[1]][0]);
vstack.push(yyval.$);
lstack.push(yyval._$);
newState = table[stack[stack.length - 2]][stack[stack.length - 1]];
stack.push(newState);
break;
case 3:
return true;
}
}
return true;
}};
/* generated by jison-lex 0.2.1 */
var lexer = (function(){
var lexer = {
EOF:1,
parseError:function parseError(str, hash) {
if (this.yy.parser) {
this.yy.parser.parseError(str, hash);
} else {
throw new Error(str);
}
},
// resets the lexer, sets new input
setInput:function (input) {
this._input = input;
this._more = this._backtrack = this.done = false;
this.yylineno = this.yyleng = 0;
this.yytext = this.matched = this.match = '';
this.conditionStack = ['INITIAL'];
this.yylloc = {
first_line: 1,
first_column: 0,
last_line: 1,
last_column: 0
};
if (this.options.ranges) {
this.yylloc.range = [0,0];
}
this.offset = 0;
return this;
},
// consumes and returns one char from the input
input:function () {
var ch = this._input[0];
this.yytext += ch;
this.yyleng++;
this.offset++;
this.match += ch;
this.matched += ch;
var lines = ch.match(/(?:\r\n?|\n).*/g);
if (lines) {
this.yylineno++;
this.yylloc.last_line++;
} else {
this.yylloc.last_column++;
}
if (this.options.ranges) {
this.yylloc.range[1]++;
}
this._input = this._input.slice(1);
return ch;
},
// unshifts one char (or a string) into the input
unput:function (ch) {
var len = ch.length;
var lines = ch.split(/(?:\r\n?|\n)/g);
this._input = ch + this._input;
this.yytext = this.yytext.substr(0, this.yytext.length - len - 1);
//this.yyleng -= len;
this.offset -= len;
var oldLines = this.match.split(/(?:\r\n?|\n)/g);
this.match = this.match.substr(0, this.match.length - 1);
this.matched = this.matched.substr(0, this.matched.length - 1);
if (lines.length - 1) {
this.yylineno -= lines.length - 1;
}
var r = this.yylloc.range;
this.yylloc = {
first_line: this.yylloc.first_line,
last_line: this.yylineno + 1,
first_column: this.yylloc.first_column,
last_column: lines ?
(lines.length === oldLines.length ? this.yylloc.first_column : 0)
+ oldLines[oldLines.length - lines.length].length - lines[0].length :
this.yylloc.first_column - len
};
if (this.options.ranges) {
this.yylloc.range = [r[0], r[0] + this.yyleng - len];
}
this.yyleng = this.yytext.length;
return this;
},
// When called from action, caches matched text and appends it on next action
more:function () {
this._more = true;
return this;
},
// When called from action, signals the lexer that this rule fails to match the input, so the next matching rule (regex) should be tested instead.
reject:function () {
if (this.options.backtrack_lexer) {
this._backtrack = true;
} else {
return this.parseError('Lexical error on line ' + (this.yylineno + 1) + '. You can only invoke reject() in the lexer when the lexer is of the backtracking persuasion (options.backtrack_lexer = true).\n' + this.showPosition(), {
text: "",
token: null,
line: this.yylineno
});
}
return this;
},
// retain first n characters of the match
less:function (n) {
this.unput(this.match.slice(n));
},
// displays already matched input, i.e. for error messages
pastInput:function () {
var past = this.matched.substr(0, this.matched.length - this.match.length);
return (past.length > 20 ? '...':'') + past.substr(-20).replace(/\n/g, "");
},
// displays upcoming input, i.e. for error messages
upcomingInput:function () {
var next = this.match;
if (next.length < 20) {
next += this._input.substr(0, 20-next.length);
}
return (next.substr(0,20) + (next.length > 20 ? '...' : '')).replace(/\n/g, "");
},
// displays the character position where the lexing error occurred, i.e. for error messages
showPosition:function () {
var pre = this.pastInput();
var c = new Array(pre.length + 1).join("-");
return pre + this.upcomingInput() + "\n" + c + "^";
},
// test the lexed token: return FALSE when not a match, otherwise return token
test_match:function (match, indexed_rule) {
var token,
lines,
backup;
if (this.options.backtrack_lexer) {
// save context
backup = {
yylineno: this.yylineno,
yylloc: {
first_line: this.yylloc.first_line,
last_line: this.last_line,
first_column: this.yylloc.first_column,
last_column: this.yylloc.last_column
},
yytext: this.yytext,
match: this.match,
matches: this.matches,
matched: this.matched,
yyleng: this.yyleng,
offset: this.offset,
_more: this._more,
_input: this._input,
yy: this.yy,
conditionStack: this.conditionStack.slice(0),
done: this.done
};
if (this.options.ranges) {
backup.yylloc.range = this.yylloc.range.slice(0);
}
}
lines = match[0].match(/(?:\r\n?|\n).*/g);
if (lines) {
this.yylineno += lines.length;
}
this.yylloc = {
first_line: this.yylloc.last_line,
last_line: this.yylineno + 1,
first_column: this.yylloc.last_column,
last_column: lines ?
lines[lines.length - 1].length - lines[lines.length - 1].match(/\r?\n?/)[0].length :
this.yylloc.last_column + match[0].length
};
this.yytext += match[0];
this.match += match[0];
this.matches = match;
this.yyleng = this.yytext.length;
if (this.options.ranges) {
this.yylloc.range = [this.offset, this.offset += this.yyleng];
}
this._more = false;
this._backtrack = false;
this._input = this._input.slice(match[0].length);
this.matched += match[0];
token = this.performAction.call(this, this.yy, this, indexed_rule, this.conditionStack[this.conditionStack.length - 1]);
if (this.done && this._input) {
this.done = false;
}
if (token) {
return token;
} else if (this._backtrack) {
// recover context
for (var k in backup) {
this[k] = backup[k];
}
return false; // rule action called reject() implying the next rule should be tested instead.
}
return false;
},
// return next match in input
next:function () {
if (this.done) {
return this.EOF;
}
if (!this._input) {
this.done = true;
}
var token,
match,
tempMatch,
index;
if (!this._more) {
this.yytext = '';
this.match = '';
}
var rules = this._currentRules();
for (var i = 0; i < rules.length; i++) {
tempMatch = this._input.match(this.rules[rules[i]]);
if (tempMatch && (!match || tempMatch[0].length > match[0].length)) {
match = tempMatch;
index = i;
if (this.options.backtrack_lexer) {
token = this.test_match(tempMatch, rules[i]);
if (token !== false) {
return token;
} else if (this._backtrack) {
match = false;
continue; // rule action called reject() implying a rule MISmatch.
} else {
// else: this is a lexer rule which consumes input without producing a token (e.g. whitespace)
return false;
}
} else if (!this.options.flex) {
break;
}
}
}
if (match) {
token = this.test_match(match, rules[index]);
if (token !== false) {
return token;
}
// else: this is a lexer rule which consumes input without producing a token (e.g. whitespace)
return false;
}
if (this._input === "") {
return this.EOF;
} else {
return this.parseError('Lexical error on line ' + (this.yylineno + 1) + '. Unrecognized text.\n' + this.showPosition(), {
text: "",
token: null,
line: this.yylineno
});
}
},
// return next match that has a token
lex:function lex() {
var r = this.next();
if (r) {
return r;
} else {
return this.lex();
}
},
// activates a new lexer condition state (pushes the new lexer condition state onto the condition stack)
begin:function begin(condition) {
this.conditionStack.push(condition);
},
// pop the previously active lexer condition state off the condition stack
popState:function popState() {
var n = this.conditionStack.length - 1;
if (n > 0) {
return this.conditionStack.pop();
} else {
return this.conditionStack[0];
}
},
// produce the lexer rule set which is active for the currently active lexer condition state
_currentRules:function _currentRules() {
if (this.conditionStack.length && this.conditionStack[this.conditionStack.length - 1]) {
return this.conditions[this.conditionStack[this.conditionStack.length - 1]].rules;
} else {
return this.conditions["INITIAL"].rules;
}
},
// return the currently active lexer condition state; when an index argument is provided it produces the N-th previous condition state, if available
topState:function topState(n) {
n = this.conditionStack.length - 1 - Math.abs(n || 0);
if (n >= 0) {
return this.conditionStack[n];
} else {
return "INITIAL";
}
},
// alias for begin(condition)
pushState:function pushState(condition) {
this.begin(condition);
},
// return the number of states currently on the stack
stateStackSize:function stateStackSize() {
return this.conditionStack.length;
},
options: {},
performAction: function anonymous(yy,yy_,$avoiding_name_collisions,YY_START) {
var YYSTATE=YY_START;
switch($avoiding_name_collisions) {
case 0:return 28;
break;
case 1:return 27;
break;
case 2:return 5;
break;
case 3:return 36;
break;
case 4:return 34;
break;
case 5:return 37;
break;
case 6:return 35;
break;
case 7:return 38;
break;
case 8:return 39;
break;
case 9:return 43;
break;
case 10:return 44;
break;
case 11:return 62;
break;
case 12:return 61;
break;
case 13:return 52;
break;
case 14:return 47;
break;
case 15:return 48;
break;
case 16:return 26;
break;
case 17:return 8;
break;
case 18:return 25;
break;
case 19:return 29;
break;
case 20:return 31;
break;
case 21:return 32;
break;
case 22:return 45;
break;
case 23:return 49;
break;
case 24:return 51;
break;
case 25:return 17;
break;
case 26:return "'";
break;
case 27:return 19;
break;
case 28:return 41;
break;
case 29:return 42;
break;
case 30:return 60;
break;
case 31:return 9;
break;
}
},
rules: [/^(?:n\b)/,/^(?:[_a-zA-Z][_a-zA-Z0-9-]*)/,/^(?:$)/,/^(?:~=)/,/^(?:\*=)/,/^(?:\|=)/,/^(?:!=)/,/^(?:\^=)/,/^(?:\$=)/,/^(?:"[^\n\r\f\\"]*")/,/^(?:'[^\n\r\f\\']*')/,/^(?:\+\d+)/,/^(?:-\d+)/,/^(?:\d+)/,/^(?:\(odd\))/,/^(?:\(even\))/,/^(?:#)/,/^(?:,)/,/^(?:\.)/,/^(?:\[)/,/^(?:\])/,/^(?:=)/,/^(?::)/,/^(?:\()/,/^(?:\))/,/^(?:>)/,/^(?:')/,/^(?:\*)/,/^(?:~)/,/^(?:\+)/,/^(?:-)/,/^(?:\s+)/],
conditions: {"INITIAL":{"rules":[0,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],"inclusive":true}}
};
return lexer;
})();
parser.lexer = lexer;
function Parser () {
this.yy = {};
}
Parser.prototype = parser;parser.Parser = Parser;
return new Parser;
})();
if (typeof require !== 'undefined' && typeof exports !== 'undefined') {
exports.parser = parser;
exports.Parser = parser.Parser;
exports.parse = function () { return parser.parse.apply(parser, arguments); };
exports.main = function commonjsMain(args) {
if (!args[1]) {
console.log('Usage: '+args[0]+' FILE');
process.exit(1);
}
var source = require('fs').readFileSync(require('path').normalize(args[1]), "utf8");
return exports.parser.parse(source);
};
if (typeof module !== 'undefined' && require.main === module) {
exports.main(process.argv.slice(1));
}
}