haml-more 0.4.0.a
Sign up to get free protection for your applications and to get access to all the features.
- data/README.md +79 -0
- data/lib/haml/more/coffee_script.rb +137 -0
- data/lib/haml/more/content_for.rb +25 -0
- data/lib/haml/more.rb +45 -0
- data/lib/haml-more.rb +1 -0
- data/lib/sass/more.rb +16 -0
- data/lib/sass-more.rb +1 -0
- data/spec/sass/more_spec.rb +21 -0
- data/vendor/coffee-script/Cakefile +57 -0
- data/vendor/coffee-script/LICENSE +22 -0
- data/vendor/coffee-script/README +41 -0
- data/vendor/coffee-script/Rakefile +20 -0
- data/vendor/coffee-script/bin/cake +7 -0
- data/vendor/coffee-script/bin/coffee +7 -0
- data/vendor/coffee-script/documentation/coffee/aliases.coffee +9 -0
- data/vendor/coffee-script/documentation/coffee/arguments.coffee +4 -0
- data/vendor/coffee-script/documentation/coffee/array_comprehensions.coffee +7 -0
- data/vendor/coffee-script/documentation/coffee/assignment.coffee +2 -0
- data/vendor/coffee-script/documentation/coffee/cake_tasks.coffee +5 -0
- data/vendor/coffee-script/documentation/coffee/comparisons.coffee +5 -0
- data/vendor/coffee-script/documentation/coffee/conditionals.coffee +9 -0
- data/vendor/coffee-script/documentation/coffee/embedded.coffee +5 -0
- data/vendor/coffee-script/documentation/coffee/existence.coffee +8 -0
- data/vendor/coffee-script/documentation/coffee/expressions.coffee +9 -0
- data/vendor/coffee-script/documentation/coffee/expressions_assignment.coffee +1 -0
- data/vendor/coffee-script/documentation/coffee/expressions_comprehension.coffee +3 -0
- data/vendor/coffee-script/documentation/coffee/expressions_try.coffee +6 -0
- data/vendor/coffee-script/documentation/coffee/fat_arrow.coffee +6 -0
- data/vendor/coffee-script/documentation/coffee/functions.coffee +2 -0
- data/vendor/coffee-script/documentation/coffee/heredocs.coffee +5 -0
- data/vendor/coffee-script/documentation/coffee/multiple_return_values.coffee +5 -0
- data/vendor/coffee-script/documentation/coffee/object_comprehensions.coffee +4 -0
- data/vendor/coffee-script/documentation/coffee/object_extraction.coffee +13 -0
- data/vendor/coffee-script/documentation/coffee/objects_and_arrays.coffee +13 -0
- data/vendor/coffee-script/documentation/coffee/overview.coffee +29 -0
- data/vendor/coffee-script/documentation/coffee/parallel_assignment.coffee +4 -0
- data/vendor/coffee-script/documentation/coffee/range_comprehensions.coffee +6 -0
- data/vendor/coffee-script/documentation/coffee/scope.coffee +5 -0
- data/vendor/coffee-script/documentation/coffee/slices.coffee +6 -0
- data/vendor/coffee-script/documentation/coffee/soaks.coffee +1 -0
- data/vendor/coffee-script/documentation/coffee/splats.coffee +25 -0
- data/vendor/coffee-script/documentation/coffee/splices.coffee +5 -0
- data/vendor/coffee-script/documentation/coffee/strings.coffee +8 -0
- data/vendor/coffee-script/documentation/coffee/super.coffee +34 -0
- data/vendor/coffee-script/documentation/coffee/switch.coffee +10 -0
- data/vendor/coffee-script/documentation/coffee/try.coffee +7 -0
- data/vendor/coffee-script/documentation/coffee/while.coffee +10 -0
- data/vendor/coffee-script/documentation/css/docs.css +213 -0
- data/vendor/coffee-script/documentation/css/idle.css +63 -0
- data/vendor/coffee-script/documentation/css/logo.png +0 -0
- data/vendor/coffee-script/documentation/index.html.erb +967 -0
- data/vendor/coffee-script/documentation/js/aliases.js +14 -0
- data/vendor/coffee-script/documentation/js/arguments.js +8 -0
- data/vendor/coffee-script/documentation/js/array_comprehensions.js +26 -0
- data/vendor/coffee-script/documentation/js/assignment.js +5 -0
- data/vendor/coffee-script/documentation/js/cake_tasks.js +14 -0
- data/vendor/coffee-script/documentation/js/comparisons.js +5 -0
- data/vendor/coffee-script/documentation/js/conditionals.js +12 -0
- data/vendor/coffee-script/documentation/js/embedded.js +6 -0
- data/vendor/coffee-script/documentation/js/existence.js +7 -0
- data/vendor/coffee-script/documentation/js/expressions.js +13 -0
- data/vendor/coffee-script/documentation/js/expressions_assignment.js +4 -0
- data/vendor/coffee-script/documentation/js/expressions_comprehension.js +12 -0
- data/vendor/coffee-script/documentation/js/expressions_try.js +9 -0
- data/vendor/coffee-script/documentation/js/fat_arrow.js +15 -0
- data/vendor/coffee-script/documentation/js/functions.js +9 -0
- data/vendor/coffee-script/documentation/js/heredocs.js +4 -0
- data/vendor/coffee-script/documentation/js/intro.js +7 -0
- data/vendor/coffee-script/documentation/js/multiple_return_values.js +11 -0
- data/vendor/coffee-script/documentation/js/object_comprehensions.js +17 -0
- data/vendor/coffee-script/documentation/js/object_extraction.js +17 -0
- data/vendor/coffee-script/documentation/js/objects_and_arrays.js +10 -0
- data/vendor/coffee-script/documentation/js/overview.js +43 -0
- data/vendor/coffee-script/documentation/js/parallel_assignment.js +8 -0
- data/vendor/coffee-script/documentation/js/punctuation.js +8 -0
- data/vendor/coffee-script/documentation/js/range_comprehensions.js +21 -0
- data/vendor/coffee-script/documentation/js/scope.js +10 -0
- data/vendor/coffee-script/documentation/js/slices.js +6 -0
- data/vendor/coffee-script/documentation/js/soaks.js +4 -0
- data/vendor/coffee-script/documentation/js/splats.js +16 -0
- data/vendor/coffee-script/documentation/js/splices.js +5 -0
- data/vendor/coffee-script/documentation/js/strings.js +9 -0
- data/vendor/coffee-script/documentation/js/super.js +37 -0
- data/vendor/coffee-script/documentation/js/switch.js +18 -0
- data/vendor/coffee-script/documentation/js/try.js +10 -0
- data/vendor/coffee-script/documentation/js/while.js +22 -0
- data/vendor/coffee-script/documentation/underscore.html +627 -0
- data/vendor/coffee-script/examples/beautiful_code/binary_search.coffee +16 -0
- data/vendor/coffee-script/examples/beautiful_code/quicksort_runtime.coffee +13 -0
- data/vendor/coffee-script/examples/beautiful_code/regular_expression_matcher.coffee +34 -0
- data/vendor/coffee-script/examples/blocks.coffee +57 -0
- data/vendor/coffee-script/examples/code.coffee +173 -0
- data/vendor/coffee-script/examples/computer_science/README +4 -0
- data/vendor/coffee-script/examples/computer_science/binary_search.coffee +25 -0
- data/vendor/coffee-script/examples/computer_science/bubble_sort.coffee +11 -0
- data/vendor/coffee-script/examples/computer_science/linked_list.coffee +106 -0
- data/vendor/coffee-script/examples/computer_science/luhn_algorithm.coffee +36 -0
- data/vendor/coffee-script/examples/computer_science/merge_sort.coffee +19 -0
- data/vendor/coffee-script/examples/computer_science/selection_sort.coffee +23 -0
- data/vendor/coffee-script/examples/poignant.coffee +186 -0
- data/vendor/coffee-script/examples/potion.coffee +205 -0
- data/vendor/coffee-script/examples/underscore.coffee +603 -0
- data/vendor/coffee-script/examples/web_server.coffee +12 -0
- data/vendor/coffee-script/extras/CoffeeScript.tmbundle/Preferences/CoffeeScript.tmPreferences +24 -0
- data/vendor/coffee-script/extras/CoffeeScript.tmbundle/Syntaxes/CoffeeScript.tmLanguage +361 -0
- data/vendor/coffee-script/extras/CoffeeScript.tmbundle/info.plist +10 -0
- data/vendor/coffee-script/extras/EXTRAS +20 -0
- data/vendor/coffee-script/extras/coffee.vim +117 -0
- data/vendor/coffee-script/index.html +1847 -0
- data/vendor/coffee-script/lib/bin/cake +7 -0
- data/vendor/coffee-script/lib/bin/coffee +7 -0
- data/vendor/coffee-script/lib/cake.js +80 -0
- data/vendor/coffee-script/lib/coffee-script.js +61 -0
- data/vendor/coffee-script/lib/command_line.js +201 -0
- data/vendor/coffee-script/lib/grammar.js +564 -0
- data/vendor/coffee-script/lib/lexer.js +405 -0
- data/vendor/coffee-script/lib/narwhal.js +44 -0
- data/vendor/coffee-script/lib/nodes.js +1328 -0
- data/vendor/coffee-script/lib/optparse.js +117 -0
- data/vendor/coffee-script/lib/parser.js +536 -0
- data/vendor/coffee-script/lib/repl.js +32 -0
- data/vendor/coffee-script/lib/rewriter.js +383 -0
- data/vendor/coffee-script/lib/scope.js +114 -0
- data/vendor/coffee-script/package.json +7 -0
- data/vendor/coffee-script/src/cake.coffee +45 -0
- data/vendor/coffee-script/src/coffee-script.coffee +45 -0
- data/vendor/coffee-script/src/command_line.coffee +130 -0
- data/vendor/coffee-script/src/grammar.coffee +456 -0
- data/vendor/coffee-script/src/lexer.coffee +327 -0
- data/vendor/coffee-script/src/narwhal.coffee +42 -0
- data/vendor/coffee-script/src/nodes.coffee +1045 -0
- data/vendor/coffee-script/src/optparse.coffee +79 -0
- data/vendor/coffee-script/src/repl.coffee +23 -0
- data/vendor/coffee-script/src/rewriter.coffee +253 -0
- data/vendor/coffee-script/src/scope.coffee +75 -0
- data/vendor/coffee-script/test/test_arguments.coffee +34 -0
- data/vendor/coffee-script/test/test_array_comprehension.coffee +42 -0
- data/vendor/coffee-script/test/test_assignment.coffee +26 -0
- data/vendor/coffee-script/test/test_blocks.coffee +4 -0
- data/vendor/coffee-script/test/test_calling_super.coffee +42 -0
- data/vendor/coffee-script/test/test_chained_calls.coffee +25 -0
- data/vendor/coffee-script/test/test_destructuring_assignment.coffee +62 -0
- data/vendor/coffee-script/test/test_everything.coffee +29 -0
- data/vendor/coffee-script/test/test_exceptions.coffee +2 -0
- data/vendor/coffee-script/test/test_existence.coffee +81 -0
- data/vendor/coffee-script/test/test_expressions.coffee +30 -0
- data/vendor/coffee-script/test/test_fancy_if_statement.coffee +26 -0
- data/vendor/coffee-script/test/test_functions.coffee +80 -0
- data/vendor/coffee-script/test/test_funky_comments.coffee +25 -0
- data/vendor/coffee-script/test/test_heredocs.coffee +46 -0
- data/vendor/coffee-script/test/test_lexical_scope.coffee +10 -0
- data/vendor/coffee-script/test/test_literals.coffee +56 -0
- data/vendor/coffee-script/test/test_nested_comprehensions.coffee +11 -0
- data/vendor/coffee-script/test/test_newline_escaping.coffee +6 -0
- data/vendor/coffee-script/test/test_operations.coffee +18 -0
- data/vendor/coffee-script/test/test_range_comprehension.coffee +20 -0
- data/vendor/coffee-script/test/test_ranges_and_slices.coffee +16 -0
- data/vendor/coffee-script/test/test_splats.coffee +47 -0
- data/vendor/coffee-script/test/test_splices.coffee +5 -0
- data/vendor/coffee-script/test/test_switch.coffee +64 -0
- data/vendor/coffee-script/test/test_while.coffee +30 -0
- data/vendor/coffee-script/vendor/jison/Jakefile +31 -0
- data/vendor/coffee-script/vendor/jison/README.md +347 -0
- data/vendor/coffee-script/vendor/jison/bin/jison +3 -0
- data/vendor/coffee-script/vendor/jison/bin/json2jison +3 -0
- data/vendor/coffee-script/vendor/jison/examples/ansic.jison +415 -0
- data/vendor/coffee-script/vendor/jison/examples/basic.json +8 -0
- data/vendor/coffee-script/vendor/jison/examples/basic2.json +9 -0
- data/vendor/coffee-script/vendor/jison/examples/basic2_lex.json +16 -0
- data/vendor/coffee-script/vendor/jison/examples/basic_lex.json +15 -0
- data/vendor/coffee-script/vendor/jison/examples/calculator.jison +38 -0
- data/vendor/coffee-script/vendor/jison/examples/calculator.jisonlex +14 -0
- data/vendor/coffee-script/vendor/jison/examples/calculator.json +42 -0
- data/vendor/coffee-script/vendor/jison/examples/classy.json +105 -0
- data/vendor/coffee-script/vendor/jison/examples/classy_ast.json +126 -0
- data/vendor/coffee-script/vendor/jison/examples/dism.json +25 -0
- data/vendor/coffee-script/vendor/jison/examples/dism_lr0.json +26 -0
- data/vendor/coffee-script/vendor/jison/examples/json.js +80 -0
- data/vendor/coffee-script/vendor/jison/examples/json_ast.js +83 -0
- data/vendor/coffee-script/vendor/jison/examples/precedence.json +26 -0
- data/vendor/coffee-script/vendor/jison/examples/reduce_conflict.json +13 -0
- data/vendor/coffee-script/vendor/jison/lib/jison/bnf.js +43 -0
- data/vendor/coffee-script/vendor/jison/lib/jison/jisonlex.js +18 -0
- data/vendor/coffee-script/vendor/jison/lib/jison/json2jison.js +146 -0
- data/vendor/coffee-script/vendor/jison/lib/jison/lexer.js +224 -0
- data/vendor/coffee-script/vendor/jison/lib/jison/util/bnf-parser.js +383 -0
- data/vendor/coffee-script/vendor/jison/lib/jison/util/lex-parser.js +407 -0
- data/vendor/coffee-script/vendor/jison/lib/jison/util/set.js +94 -0
- data/vendor/coffee-script/vendor/jison/lib/jison/util/typal.js +90 -0
- data/vendor/coffee-script/vendor/jison/lib/jison.js +1414 -0
- data/vendor/coffee-script/vendor/jison/package.json +14 -0
- data/vendor/coffee-script/vendor/jison/src/bnf.jison +110 -0
- data/vendor/coffee-script/vendor/jison/src/bnf.jisonlex +25 -0
- data/vendor/coffee-script/vendor/jison/src/bnf.lex.json +24 -0
- data/vendor/coffee-script/vendor/jison/src/jisonlex.jison +129 -0
- data/vendor/coffee-script/vendor/jison/src/jisonlex.jisonlex +31 -0
- data/vendor/coffee-script/vendor/jison/src/jisonlex.lex.json +30 -0
- data/vendor/coffee-script/vendor/jison/tests/all-tests.js +8 -0
- data/vendor/coffee-script/vendor/jison/tests/grammar/bnf.js +91 -0
- data/vendor/coffee-script/vendor/jison/tests/grammar/bnf_parse.js +65 -0
- data/vendor/coffee-script/vendor/jison/tests/grammar/grammar-tests.js +10 -0
- data/vendor/coffee-script/vendor/jison/tests/grammar/json2jison.js +24 -0
- data/vendor/coffee-script/vendor/jison/tests/grammar/lex/ansic.jisonlex +115 -0
- data/vendor/coffee-script/vendor/jison/tests/grammar/lex/bnf.jisonlex +25 -0
- data/vendor/coffee-script/vendor/jison/tests/grammar/lex/bnf.lex.json +24 -0
- data/vendor/coffee-script/vendor/jison/tests/grammar/lex/lex_grammar.jisonlex +31 -0
- data/vendor/coffee-script/vendor/jison/tests/grammar/lex/lex_grammar.lex.json +30 -0
- data/vendor/coffee-script/vendor/jison/tests/grammar/lex.jison +119 -0
- data/vendor/coffee-script/vendor/jison/tests/grammar/lex.js +58 -0
- data/vendor/coffee-script/vendor/jison/tests/grammar/lex_parse.js +117 -0
- data/vendor/coffee-script/vendor/jison/tests/lexer/lexer-tests.js +6 -0
- data/vendor/coffee-script/vendor/jison/tests/lexer/regexplexer.js +417 -0
- data/vendor/coffee-script/vendor/jison/tests/parser/actions.js +311 -0
- data/vendor/coffee-script/vendor/jison/tests/parser/api.js +236 -0
- data/vendor/coffee-script/vendor/jison/tests/parser/generator.js +196 -0
- data/vendor/coffee-script/vendor/jison/tests/parser/lalr.js +183 -0
- data/vendor/coffee-script/vendor/jison/tests/parser/lr0.js +72 -0
- data/vendor/coffee-script/vendor/jison/tests/parser/lr1.js +119 -0
- data/vendor/coffee-script/vendor/jison/tests/parser/parser-tests.js +14 -0
- data/vendor/coffee-script/vendor/jison/tests/parser/precedence.js +237 -0
- data/vendor/coffee-script/vendor/jison/tests/parser/slr.js +52 -0
- data/vendor/coffee-script/vendor/jison/tests/parser/tables.js +126 -0
- data/vendor/coffee-script/vendor/jison/tests/performance.js +110 -0
- data/vendor/coffee-script/vendor/jison/tests/setup.js +3 -0
- metadata +324 -0
@@ -0,0 +1,224 @@
|
|
1
|
+
// Basic RegExp Lexer
|
2
|
+
// MIT Licensed
|
3
|
+
// Zachary Carter <zach@carter.name>
|
4
|
+
|
5
|
+
var RegExpLexer = (function () {
|
6
|
+
|
7
|
+
// expand macros and convert matchers to RegExp's
|
8
|
+
function prepareRules(rules, macros, actions, tokens) {
|
9
|
+
var m,i,k,action,
|
10
|
+
newRules = [];
|
11
|
+
|
12
|
+
actions.push('switch(arguments[2]) {');
|
13
|
+
|
14
|
+
for (i=0;i < rules.length; i++) {
|
15
|
+
m = rules[i][0];
|
16
|
+
for (k in macros) {
|
17
|
+
if (macros.hasOwnProperty(k) && typeof m === 'string') {
|
18
|
+
m = m.split("{"+k+"}").join(macros[k]);
|
19
|
+
}
|
20
|
+
}
|
21
|
+
if (typeof m === 'string') {
|
22
|
+
m = new RegExp("^"+m);
|
23
|
+
}
|
24
|
+
newRules.push(m);
|
25
|
+
if (typeof rules[i][1] === 'function') {
|
26
|
+
rules[i][1] = String(rules[i][1]).replace(/^\s*function \(\) \{/, '').replace(/\}\s*$/, '');
|
27
|
+
}
|
28
|
+
action = rules[i][1];
|
29
|
+
if (tokens && action.match(/return '[^']+'/)) {
|
30
|
+
action = action.replace(/return '([^']+)'/, function (str, pl) {
|
31
|
+
return "return "+(tokens[pl] ? tokens[pl] : "'"+pl+"'");
|
32
|
+
});
|
33
|
+
}
|
34
|
+
actions.push('case '+i+':' +action+'\nbreak;');
|
35
|
+
}
|
36
|
+
actions.push("}");
|
37
|
+
|
38
|
+
return newRules;
|
39
|
+
}
|
40
|
+
|
41
|
+
function buildActions (dict, tokens) {
|
42
|
+
var actions = [dict.actionInclude || ''];
|
43
|
+
var tok;
|
44
|
+
var toks = {};
|
45
|
+
|
46
|
+
for (tok in tokens) {
|
47
|
+
toks[tokens[tok]] = tok;
|
48
|
+
}
|
49
|
+
|
50
|
+
this.rules = prepareRules(dict.rules, dict.macros, actions, tokens && toks);
|
51
|
+
var fun = actions.join("\n");
|
52
|
+
"yytext yyleng yylineno".split(' ').forEach(function (yy) {
|
53
|
+
fun = fun.replace(new RegExp("("+yy+")", "g"), "yy_.$1");
|
54
|
+
});
|
55
|
+
|
56
|
+
return Function("yy", "yy_", fun);
|
57
|
+
}
|
58
|
+
|
59
|
+
function RegExpLexer (dict, input, tokens) {
|
60
|
+
if (typeof dict === 'string') {
|
61
|
+
dict = require("./jisonlex").parse(dict);
|
62
|
+
}
|
63
|
+
dict = dict || {};
|
64
|
+
|
65
|
+
this.performAction = buildActions.call(this, dict, tokens);
|
66
|
+
|
67
|
+
this.yy = {};
|
68
|
+
if (input) {
|
69
|
+
this.setInput(input);
|
70
|
+
}
|
71
|
+
}
|
72
|
+
|
73
|
+
RegExpLexer.prototype = {
|
74
|
+
EOF: '',
|
75
|
+
parseError: function parseError(str, hash) {
|
76
|
+
if (this.yy.parseError) {
|
77
|
+
this.yy.parseError(str, hash);
|
78
|
+
} else {
|
79
|
+
throw new Error(str);
|
80
|
+
}
|
81
|
+
},
|
82
|
+
|
83
|
+
// resets the lexer, sets new input
|
84
|
+
setInput: function (input) {
|
85
|
+
this._input = input;
|
86
|
+
this._more = this._less = this.done = false;
|
87
|
+
this.yylineno = this.yyleng = 0;
|
88
|
+
this.yytext = this.matched = this.match = '';
|
89
|
+
return this;
|
90
|
+
},
|
91
|
+
// consumes and returns one char from the input
|
92
|
+
input: function () {
|
93
|
+
var ch = this._input[0];
|
94
|
+
this.yytext+=ch;
|
95
|
+
this.yyleng++;
|
96
|
+
this.match+=ch;
|
97
|
+
this.matched+=ch;
|
98
|
+
var lines = ch.match(/\n/);
|
99
|
+
if (lines) this.yylineno++;
|
100
|
+
this._input = this._input.slice(1);
|
101
|
+
return ch;
|
102
|
+
},
|
103
|
+
// unshifts one char into the input
|
104
|
+
unput: function (ch) {
|
105
|
+
this._input = ch + this._input;
|
106
|
+
return this;
|
107
|
+
},
|
108
|
+
// When called from action, caches matched text and appends it on next action
|
109
|
+
more: function () {
|
110
|
+
this._more = true;
|
111
|
+
return this;
|
112
|
+
},
|
113
|
+
// displays upcoming input, i.e. for error messages
|
114
|
+
pastInput: function () {
|
115
|
+
var past = this.matched.substr(0, this.matched.length - this.match.length);
|
116
|
+
return (past.length > 20 ? '...':'') + past.substr(-20).replace(/\n/g, "");
|
117
|
+
},
|
118
|
+
// displays upcoming input, i.e. for error messages
|
119
|
+
upcomingInput: function () {
|
120
|
+
var next = this.match;
|
121
|
+
if (next.length < 20) {
|
122
|
+
next += this._input.substr(0, 20-next.length);
|
123
|
+
}
|
124
|
+
return (next.substr(0,20)+(next.length > 20 ? '...':'')).replace(/\n/g, "");
|
125
|
+
},
|
126
|
+
// displays upcoming input, i.e. for error messages
|
127
|
+
showPosition: function () {
|
128
|
+
var pre = this.pastInput();
|
129
|
+
var c = new Array(pre.length + 1).join("-");
|
130
|
+
return pre + this.upcomingInput() + "\n" + c+"^";
|
131
|
+
},
|
132
|
+
|
133
|
+
// return next match in input
|
134
|
+
next: function () {
|
135
|
+
if (this.done) {
|
136
|
+
return this.EOF;
|
137
|
+
}
|
138
|
+
if (!this._input) this.done = true;
|
139
|
+
|
140
|
+
var token,
|
141
|
+
match,
|
142
|
+
lines;
|
143
|
+
if (!this._more) {
|
144
|
+
this.yytext = '';
|
145
|
+
this.match = '';
|
146
|
+
}
|
147
|
+
for (var i=0;i < this.rules.length; i++) {
|
148
|
+
match = this._input.match(this.rules[i]);
|
149
|
+
if (match) {
|
150
|
+
lines = match[0].match(/\n/g);
|
151
|
+
if (lines) this.yylineno += lines.length;
|
152
|
+
this.yytext += match[0];
|
153
|
+
this.match += match[0];
|
154
|
+
this.matches = match;
|
155
|
+
this.yyleng = this.yytext.length;
|
156
|
+
this._more = false;
|
157
|
+
this._input = this._input.slice(match[0].length);
|
158
|
+
this.matched += match[0];
|
159
|
+
token = this.performAction.call(this, this.yy, this, i);
|
160
|
+
if (token) return token;
|
161
|
+
else return;
|
162
|
+
}
|
163
|
+
}
|
164
|
+
if (this._input == this.EOF) {
|
165
|
+
return this.EOF;
|
166
|
+
} else {
|
167
|
+
this.parseError('Lexical error on line '+(this.yylineno+1)+'. Unrecognized text.\n'+this.showPosition(),
|
168
|
+
{text: "", token: null, line: this.yylineno});
|
169
|
+
}
|
170
|
+
},
|
171
|
+
|
172
|
+
// return next match that has a token
|
173
|
+
lex: function () {
|
174
|
+
var r = this.next();
|
175
|
+
if (typeof r !== 'undefined') {
|
176
|
+
return r;
|
177
|
+
} else {
|
178
|
+
return this.lex();
|
179
|
+
}
|
180
|
+
},
|
181
|
+
|
182
|
+
generate: function generate(opt) {
|
183
|
+
var code = "";
|
184
|
+
if (opt.commonjs)
|
185
|
+
code = this.generateCommonJSModule(opt);
|
186
|
+
else
|
187
|
+
code = this.generateModule(opt);
|
188
|
+
|
189
|
+
return code;
|
190
|
+
},
|
191
|
+
generateModule: function generateModule(opt) {
|
192
|
+
opt = opt || {};
|
193
|
+
var out = "/* Jison generated lexer */",
|
194
|
+
moduleName = opt.moduleName || "lexer";
|
195
|
+
out += "\nvar "+moduleName+" = (function(){var lexer = ({";
|
196
|
+
var p = [];
|
197
|
+
for (var k in RegExpLexer.prototype)
|
198
|
+
if (RegExpLexer.prototype.hasOwnProperty(k) && k.indexOf("generate") === -1)
|
199
|
+
p.push(k + ":" + (RegExpLexer.prototype[k].toString() || '""'));
|
200
|
+
out += p.join(",\n");
|
201
|
+
out += "})";
|
202
|
+
out += ";\nlexer.performAction = "+String(this.performAction);
|
203
|
+
out += ";\nlexer.rules = "+uneval(this.rules);
|
204
|
+
out += ";return lexer;})()";
|
205
|
+
return out;
|
206
|
+
},
|
207
|
+
generateCommonJSModule: function generateCommonJSModule(opt) {
|
208
|
+
opt = opt || {};
|
209
|
+
var out = "/* Jison generated lexer as commonjs module */",
|
210
|
+
moduleName = opt.moduleName || "lexer";
|
211
|
+
out += this.generateModule(opt);
|
212
|
+
out += "\nexports.lexer = "+moduleName;
|
213
|
+
out += ";\nexports.lex = function () { return "+moduleName+".lex.apply(lexer, arguments); };";
|
214
|
+
return out;
|
215
|
+
}
|
216
|
+
};
|
217
|
+
|
218
|
+
return RegExpLexer;
|
219
|
+
|
220
|
+
})()
|
221
|
+
|
222
|
+
if (typeof exports !== 'undefined')
|
223
|
+
exports.RegExpLexer = RegExpLexer;
|
224
|
+
|
@@ -0,0 +1,383 @@
|
|
1
|
+
/* Jison generated parser */
|
2
|
+
var bnf = (function(){
|
3
|
+
var parser = {trace: function trace() {
|
4
|
+
},
|
5
|
+
yy: {},
|
6
|
+
symbols_: {"spec":2,"declaration_list":3,"%%":4,"grammar":5,"EOF":6,"declaration":7,"START":8,"id":9,"operator":10,"associativity":11,"token_list":12,"LEFT":13,"RIGHT":14,"NONASSOC":15,"symbol":16,"production_list":17,"production":18,":":19,"handle_list":20,";":21,"|":22,"handle_action":23,"handle":24,"action":25,"prec":26,"PREC":27,"STRING":28,"ID":29,"ACTION":30,"$accept":0,"$end":1},
|
7
|
+
terminals_: {"4":"%%","6":"EOF","8":"START","13":"LEFT","14":"RIGHT","15":"NONASSOC","19":":","21":";","22":"|","27":"PREC","28":"STRING","29":"ID","30":"ACTION"},
|
8
|
+
productions_: [0,[2,4],[2,5],[3,2],[3,0],[7,2],[7,1],[10,2],[11,1],[11,1],[11,1],[12,2],[12,1],[5,1],[17,2],[17,1],[18,4],[20,3],[20,1],[23,3],[24,2],[24,0],[26,2],[26,0],[16,1],[16,1],[9,1],[25,1],[25,0]],
|
9
|
+
performAction: function anonymous(yytext, yyleng, yylineno, yy) {
|
10
|
+
var $$ = arguments[5], $0 = arguments[5].length;
|
11
|
+
switch (arguments[4]) {
|
12
|
+
case 1:
|
13
|
+
this.$ = $$[$0 - 4 + 1 - 1];
|
14
|
+
this.$.bnf = $$[$0 - 4 + 3 - 1];
|
15
|
+
return this.$;
|
16
|
+
break;
|
17
|
+
case 2:
|
18
|
+
this.$ = $$[$0 - 5 + 1 - 1];
|
19
|
+
this.$.bnf = $$[$0 - 5 + 3 - 1];
|
20
|
+
return this.$;
|
21
|
+
break;
|
22
|
+
case 3:
|
23
|
+
this.$ = $$[$0 - 2 + 1 - 1];
|
24
|
+
yy.addDeclaration(this.$, $$[$0 - 2 + 2 - 1]);
|
25
|
+
break;
|
26
|
+
case 4:
|
27
|
+
this.$ = {};
|
28
|
+
break;
|
29
|
+
case 5:
|
30
|
+
this.$ = {start: $$[$0 - 2 + 2 - 1]};
|
31
|
+
break;
|
32
|
+
case 6:
|
33
|
+
this.$ = {operator: $$[$0 - 1 + 1 - 1]};
|
34
|
+
break;
|
35
|
+
case 7:
|
36
|
+
this.$ = [$$[$0 - 2 + 1 - 1]];
|
37
|
+
this.$.push.apply(this.$, $$[$0 - 2 + 2 - 1]);
|
38
|
+
break;
|
39
|
+
case 8:
|
40
|
+
this.$ = "left";
|
41
|
+
break;
|
42
|
+
case 9:
|
43
|
+
this.$ = "right";
|
44
|
+
break;
|
45
|
+
case 10:
|
46
|
+
this.$ = "nonassoc";
|
47
|
+
break;
|
48
|
+
case 11:
|
49
|
+
this.$ = $$[$0 - 2 + 1 - 1];
|
50
|
+
this.$.push($$[$0 - 2 + 2 - 1]);
|
51
|
+
break;
|
52
|
+
case 12:
|
53
|
+
this.$ = [$$[$0 - 1 + 1 - 1]];
|
54
|
+
break;
|
55
|
+
case 13:
|
56
|
+
this.$ = $$[$0 - 1 + 1 - 1];
|
57
|
+
break;
|
58
|
+
case 14:
|
59
|
+
this.$ = $$[$0 - 2 + 1 - 1];
|
60
|
+
this.$[$$[$0 - 2 + 2 - 1][0]] = $$[$0 - 2 + 2 - 1][1];
|
61
|
+
break;
|
62
|
+
case 15:
|
63
|
+
this.$ = {};
|
64
|
+
this.$[$$[$0 - 1 + 1 - 1][0]] = $$[$0 - 1 + 1 - 1][1];
|
65
|
+
break;
|
66
|
+
case 16:
|
67
|
+
this.$ = [$$[$0 - 4 + 1 - 1], $$[$0 - 4 + 3 - 1]];
|
68
|
+
break;
|
69
|
+
case 17:
|
70
|
+
this.$ = $$[$0 - 3 + 1 - 1];
|
71
|
+
this.$.push($$[$0 - 3 + 3 - 1]);
|
72
|
+
break;
|
73
|
+
case 18:
|
74
|
+
this.$ = [$$[$0 - 1 + 1 - 1]];
|
75
|
+
break;
|
76
|
+
case 19:
|
77
|
+
this.$ = [$$[$0 - 3 + 1 - 1].length ? $$[$0 - 3 + 1 - 1].join(" ") : ""];
|
78
|
+
if ($$[$0 - 3 + 2 - 1]) {
|
79
|
+
this.$.push($$[$0 - 3 + 2 - 1]);
|
80
|
+
}
|
81
|
+
if ($$[$0 - 3 + 3 - 1]) {
|
82
|
+
this.$.push($$[$0 - 3 + 3 - 1]);
|
83
|
+
}
|
84
|
+
if (this.$.length === 1) {
|
85
|
+
this.$ = this.$[0];
|
86
|
+
}
|
87
|
+
break;
|
88
|
+
case 20:
|
89
|
+
this.$ = $$[$0 - 2 + 1 - 1];
|
90
|
+
this.$.push($$[$0 - 2 + 2 - 1]);
|
91
|
+
break;
|
92
|
+
case 21:
|
93
|
+
this.$ = [];
|
94
|
+
break;
|
95
|
+
case 22:
|
96
|
+
this.$ = {prec: $$[$0 - 2 + 2 - 1]};
|
97
|
+
break;
|
98
|
+
case 23:
|
99
|
+
this.$ = null;
|
100
|
+
break;
|
101
|
+
case 24:
|
102
|
+
this.$ = $$[$0 - 1 + 1 - 1];
|
103
|
+
break;
|
104
|
+
case 25:
|
105
|
+
this.$ = yytext;
|
106
|
+
break;
|
107
|
+
case 26:
|
108
|
+
this.$ = yytext;
|
109
|
+
break;
|
110
|
+
case 27:
|
111
|
+
this.$ = yytext;
|
112
|
+
break;
|
113
|
+
case 28:
|
114
|
+
this.$ = "";
|
115
|
+
break;
|
116
|
+
default:;
|
117
|
+
}
|
118
|
+
},
|
119
|
+
table: [{"2":1,"3":2,"4":[[2,4]],"15":[[2,4]],"14":[[2,4]],"13":[[2,4]],"8":[[2,4]]},{"1":[[3]]},{"4":[[1,3]],"7":4,"8":[[1,5]],"10":6,"11":7,"13":[[1,8]],"14":[[1,9]],"15":[[1,10]]},{"5":11,"17":12,"18":13,"9":14,"29":[[1,15]]},{"4":[[2,3]],"15":[[2,3]],"14":[[2,3]],"13":[[2,3]],"8":[[2,3]]},{"9":16,"29":[[1,15]]},{"8":[[2,6]],"13":[[2,6]],"14":[[2,6]],"15":[[2,6]],"4":[[2,6]]},{"12":17,"16":18,"9":19,"28":[[1,20]],"29":[[1,15]]},{"29":[[2,8]],"28":[[2,8]]},{"29":[[2,9]],"28":[[2,9]]},{"29":[[2,10]],"28":[[2,10]]},{"6":[[1,21]],"4":[[1,22]]},{"18":23,"9":14,"29":[[1,15]],"6":[[2,13]],"4":[[2,13]]},{"4":[[2,15]],"6":[[2,15]],"29":[[2,15]]},{"19":[[1,24]]},{"19":[[2,26]],"4":[[2,26]],"15":[[2,26]],"14":[[2,26]],"13":[[2,26]],"8":[[2,26]],"28":[[2,26]],"29":[[2,26]],"21":[[2,26]],"22":[[2,26]],"27":[[2,26]],"30":[[2,26]]},{"8":[[2,5]],"13":[[2,5]],"14":[[2,5]],"15":[[2,5]],"4":[[2,5]]},{"16":25,"9":19,"28":[[1,20]],"29":[[1,15]],"4":[[2,7]],"15":[[2,7]],"14":[[2,7]],"13":[[2,7]],"8":[[2,7]]},{"8":[[2,12]],"13":[[2,12]],"14":[[2,12]],"15":[[2,12]],"4":[[2,12]],"28":[[2,12]],"29":[[2,12]]},{"29":[[2,24]],"28":[[2,24]],"4":[[2,24]],"15":[[2,24]],"14":[[2,24]],"13":[[2,24]],"8":[[2,24]],"30":[[2,24]],"27":[[2,24]],"22":[[2,24]],"21":[[2,24]]},{"29":[[2,25]],"28":[[2,25]],"4":[[2,25]],"15":[[2,25]],"14":[[2,25]],"13":[[2,25]],"8":[[2,25]],"30":[[2,25]],"27":[[2,25]],"22":[[2,25]],"21":[[2,25]]},{"1":[[2,1]]},{"6":[[1,26]]},{"4":[[2,14]],"6":[[2,14]],"29":[[2,14]]},{"20":27,"23":28,"24":29,"21":[[2,21]],"22":[[2,21]],"27":[[2,21]],"30":[[2,21]],"28":[[2,21]],"29":[[2,21]]},{"8":[[2,11]],"13":[[2,11]],"14":[[2,11]],"15":[[2,11]],"4":[[2,11]],"28":[[2,11]],"29":[[2,11]]},{"1":[[2,2]]},{"21":[[1,30]],"22":[[1,31]]},{"21":[[2,18]],"22":[[2,18]]},{"25":32,"16":33,"30":[[1,34]],"9":19,"28":[[1,20]],"29":[[1,15]],"21":[[2,28]],"22":[[2,28]],"27":[[2,28]]},{"29":[[2,16]],"6":[[2,16]],"4":[[2,16]]},{"23":35,"24":29,"21":[[2,21]],"22":[[2,21]],"27":[[2,21]],"30":[[2,21]],"28":[[2,21]],"29":[[2,21]]},{"26":36,"27":[[1,37]],"21":[[2,23]],"22":[[2,23]]},{"21":[[2,20]],"22":[[2,20]],"27":[[2,20]],"30":[[2,20]],"28":[[2,20]],"29":[[2,20]]},{"21":[[2,27]],"22":[[2,27]],"27":[[2,27]]},{"21":[[2,17]],"22":[[2,17]]},{"22":[[2,19]],"21":[[2,19]]},{"16":38,"9":19,"28":[[1,20]],"29":[[1,15]]},{"21":[[2,22]],"22":[[2,22]]}],
|
120
|
+
parseError: function parseError(str, hash) {
|
121
|
+
throw new Error(str);
|
122
|
+
},
|
123
|
+
parse: function parse(input) {
|
124
|
+
var self = this, stack = [0], vstack = [null], table = this.table, yytext = "", yylineno = 0, yyleng = 0, shifts = 0, reductions = 0;
|
125
|
+
this.lexer.setInput(input);
|
126
|
+
this.lexer.yy = this.yy;
|
127
|
+
var parseError = this.yy.parseError = this.yy.parseError || this.parseError;
|
128
|
+
|
129
|
+
function lex() {
|
130
|
+
var token;
|
131
|
+
token = self.lexer.lex() || 1;
|
132
|
+
if (typeof token !== "number") {
|
133
|
+
token = self.symbols_[token];
|
134
|
+
}
|
135
|
+
return token;
|
136
|
+
}
|
137
|
+
|
138
|
+
var symbol, state, action, a, r, yyval = {}, p, len, ip = 0, newState, expected;
|
139
|
+
symbol = lex();
|
140
|
+
while (true) {
|
141
|
+
state = stack[stack.length - 1];
|
142
|
+
action = table[state] && table[state][symbol];
|
143
|
+
if (typeof action == "undefined" || !action.length || !action[0]) {
|
144
|
+
expected = [];
|
145
|
+
for (p in table[state]) {
|
146
|
+
if (this.terminals_[p] && p != 1) {
|
147
|
+
expected.push("'" + this.terminals_[p] + "'");
|
148
|
+
}
|
149
|
+
}
|
150
|
+
if (this.lexer.showPosition) {
|
151
|
+
parseError("Parse error on line " + (yylineno + 1) + ":\n" + this.lexer.showPosition() + "\nExpecting " + expected.join(", "), {text: this.lexer.match, token: this.terminals_[symbol], line: this.lexer.yylineno, expected: expected});
|
152
|
+
} else {
|
153
|
+
parseError("Parse error on line " + (yylineno + 1) + ": Unexpected '" + this.terminals_[symbol] + "'", {text: this.lexer.match, token: this.terminals_[symbol], line: this.lexer.yylineno, expected: expected});
|
154
|
+
}
|
155
|
+
}
|
156
|
+
this.trace("action:", action);
|
157
|
+
if (action.length > 1) {
|
158
|
+
throw new Error("Parse Error: multiple actions possible at state: " + state + ", token: " + symbol);
|
159
|
+
}
|
160
|
+
a = action[0];
|
161
|
+
switch (a[0]) {
|
162
|
+
case 1:
|
163
|
+
shifts++;
|
164
|
+
stack.push(symbol);
|
165
|
+
++ip;
|
166
|
+
yyleng = this.lexer.yyleng;
|
167
|
+
yytext = this.lexer.yytext;
|
168
|
+
yylineno = this.lexer.yylineno;
|
169
|
+
symbol = lex();
|
170
|
+
vstack.push(null);
|
171
|
+
stack.push(a[1]);
|
172
|
+
break;
|
173
|
+
case 2:
|
174
|
+
reductions++;
|
175
|
+
len = this.productions_[a[1]][1];
|
176
|
+
yyval.$ = vstack[vstack.length - len];
|
177
|
+
r = this.performAction.call(yyval, yytext, yyleng, yylineno, this.yy, a[1], vstack);
|
178
|
+
if (typeof r !== "undefined") {
|
179
|
+
return r;
|
180
|
+
}
|
181
|
+
if (len) {
|
182
|
+
stack = stack.slice(0, -1 * len * 2);
|
183
|
+
vstack = vstack.slice(0, -1 * len);
|
184
|
+
}
|
185
|
+
stack.push(this.productions_[a[1]][0]);
|
186
|
+
vstack.push(yyval.$);
|
187
|
+
newState = table[stack[stack.length - 2]][stack[stack.length - 1]];
|
188
|
+
stack.push(newState);
|
189
|
+
break;
|
190
|
+
case 3:
|
191
|
+
this.reductionCount = reductions;
|
192
|
+
this.shiftCount = shifts;
|
193
|
+
return true;
|
194
|
+
default:;
|
195
|
+
}
|
196
|
+
}
|
197
|
+
return true;
|
198
|
+
}};/* Jison generated lexer */
|
199
|
+
var lexer = (function(){var lexer = ({EOF:"",
|
200
|
+
parseError:function parseError(str, hash) {
|
201
|
+
if (this.yy.parseError) {
|
202
|
+
this.yy.parseError(str, hash);
|
203
|
+
} else {
|
204
|
+
throw new Error(str);
|
205
|
+
}
|
206
|
+
},
|
207
|
+
setInput:function (input) {
|
208
|
+
this._input = input;
|
209
|
+
this._more = this._less = this.done = false;
|
210
|
+
this.yylineno = this.yyleng = 0;
|
211
|
+
this.yytext = this.matched = this.match = "";
|
212
|
+
return this;
|
213
|
+
},
|
214
|
+
input:function () {
|
215
|
+
var ch = this._input[0];
|
216
|
+
this.yytext += ch;
|
217
|
+
this.yyleng++;
|
218
|
+
this.match += ch;
|
219
|
+
this.matched += ch;
|
220
|
+
var lines = ch.match(/\n/);
|
221
|
+
if (lines) {
|
222
|
+
this.yylineno++;
|
223
|
+
}
|
224
|
+
this._input = this._input.slice(1);
|
225
|
+
return ch;
|
226
|
+
},
|
227
|
+
unput:function (ch) {
|
228
|
+
this._input = ch + this._input;
|
229
|
+
return this;
|
230
|
+
},
|
231
|
+
more:function () {
|
232
|
+
this._more = true;
|
233
|
+
return this;
|
234
|
+
},
|
235
|
+
pastInput:function () {
|
236
|
+
var past = this.matched.substr(0, this.matched.length - this.match.length);
|
237
|
+
return (past.length > 20 ? "..." : "") + past.substr(-20).replace(/\n/g, "");
|
238
|
+
},
|
239
|
+
upcomingInput:function () {
|
240
|
+
var next = this.match;
|
241
|
+
if (next.length < 20) {
|
242
|
+
next += this._input.substr(0, 20 - next.length);
|
243
|
+
}
|
244
|
+
return (next.substr(0, 20) + (next.length > 20 ? "..." : "")).replace(/\n/g, "");
|
245
|
+
},
|
246
|
+
showPosition:function () {
|
247
|
+
var pre = this.pastInput();
|
248
|
+
var c = (new Array(pre.length + 1)).join("-");
|
249
|
+
return pre + this.upcomingInput() + "\n" + c + "^";
|
250
|
+
},
|
251
|
+
next:function () {
|
252
|
+
if (this.done) {
|
253
|
+
return this.EOF;
|
254
|
+
}
|
255
|
+
if (!this._input) {
|
256
|
+
this.done = true;
|
257
|
+
}
|
258
|
+
var token, match, lines;
|
259
|
+
if (!this._more) {
|
260
|
+
this.yytext = "";
|
261
|
+
this.match = "";
|
262
|
+
}
|
263
|
+
for (var i = 0; i < this.rules.length; i++) {
|
264
|
+
match = this._input.match(this.rules[i]);
|
265
|
+
if (match) {
|
266
|
+
lines = match[0].match(/\n/g);
|
267
|
+
if (lines) {
|
268
|
+
this.yylineno += lines.length;
|
269
|
+
}
|
270
|
+
this.yytext += match[0];
|
271
|
+
this.match += match[0];
|
272
|
+
this.matches = match;
|
273
|
+
this.yyleng = this.yytext.length;
|
274
|
+
this._more = false;
|
275
|
+
this._input = this._input.slice(match[0].length);
|
276
|
+
this.matched += match[0];
|
277
|
+
token = this.performAction.call(this, this.yy, this, i);
|
278
|
+
if (token) {
|
279
|
+
return token;
|
280
|
+
} else {
|
281
|
+
return;
|
282
|
+
}
|
283
|
+
}
|
284
|
+
}
|
285
|
+
if (this._input == this.EOF) {
|
286
|
+
return this.EOF;
|
287
|
+
} else {
|
288
|
+
this.parseError("Lexical error on line " + (this.yylineno + 1) + ". Unrecognized text.\n" + this.showPosition(), {text: "", token: null, line: this.yylineno});
|
289
|
+
}
|
290
|
+
},
|
291
|
+
lex:function () {
|
292
|
+
var r = this.next();
|
293
|
+
if (typeof r !== "undefined") {
|
294
|
+
return r;
|
295
|
+
} else {
|
296
|
+
return this.lex();
|
297
|
+
}
|
298
|
+
}});
|
299
|
+
lexer.performAction = function anonymous(yy, yy_) {
|
300
|
+
switch (arguments[2]) {
|
301
|
+
case 0:
|
302
|
+
break;
|
303
|
+
case 1:
|
304
|
+
return yy.lexComment(this);
|
305
|
+
break;
|
306
|
+
case 2:
|
307
|
+
return 29;
|
308
|
+
break;
|
309
|
+
case 3:
|
310
|
+
yy_.yytext = yy_.yytext.substr(1, yy_.yyleng - 2);
|
311
|
+
return 28;
|
312
|
+
break;
|
313
|
+
case 4:
|
314
|
+
yy_.yytext = yy_.yytext.substr(1, yy_.yyleng - 2);
|
315
|
+
return 28;
|
316
|
+
break;
|
317
|
+
case 5:
|
318
|
+
return 19;
|
319
|
+
break;
|
320
|
+
case 6:
|
321
|
+
return 21;
|
322
|
+
break;
|
323
|
+
case 7:
|
324
|
+
return 22;
|
325
|
+
break;
|
326
|
+
case 8:
|
327
|
+
return 4;
|
328
|
+
break;
|
329
|
+
case 9:
|
330
|
+
return 27;
|
331
|
+
break;
|
332
|
+
case 10:
|
333
|
+
return 8;
|
334
|
+
break;
|
335
|
+
case 11:
|
336
|
+
return 13;
|
337
|
+
break;
|
338
|
+
case 12:
|
339
|
+
return 14;
|
340
|
+
break;
|
341
|
+
case 13:
|
342
|
+
return 15;
|
343
|
+
break;
|
344
|
+
case 14:
|
345
|
+
break;
|
346
|
+
case 15:
|
347
|
+
return yy.lexAction(this);
|
348
|
+
break;
|
349
|
+
case 16:
|
350
|
+
yy_.yytext = yy_.yytext.substr(1, yy_.yyleng - 2);
|
351
|
+
return 30;
|
352
|
+
break;
|
353
|
+
case 17:
|
354
|
+
yy_.yytext = yy_.yytext.substr(1, yy_.yyleng - 2);
|
355
|
+
return 30;
|
356
|
+
break;
|
357
|
+
case 18:
|
358
|
+
break;
|
359
|
+
case 19:
|
360
|
+
return 6;
|
361
|
+
break;
|
362
|
+
default:;
|
363
|
+
}
|
364
|
+
};
|
365
|
+
lexer.rules = [/^\s+/, /^\/\*[^*]*\*/, /^[a-zA-Z][a-zA-Z0-9_-]*/, /^"[^"]+"/, /^'[^']+'/, /^:/, /^;/, /^\|/, /^%%/, /^%prec\b/, /^%start\b/, /^%left\b/, /^%right\b/, /^%nonassoc\b/, /^%[a-zA-Z]+[^\n]*/, /^\{\{[^}]*\}/, /^\{[^}]*\}/, /^<[^>]*>/, /^./, /^$/];return lexer;})()
|
366
|
+
parser.lexer = lexer;
|
367
|
+
return parser;
|
368
|
+
})();
|
369
|
+
if (typeof require !== 'undefined') {
|
370
|
+
exports.parser = bnf;
|
371
|
+
exports.parse = function () { return bnf.parse.apply(bnf, arguments); }
|
372
|
+
exports.main = function commonjsMain(args) {
|
373
|
+
var cwd = require("file").path(require("file").cwd());
|
374
|
+
if (!args[1]) {
|
375
|
+
throw new Error("Usage: " + args[0] + " FILE");
|
376
|
+
}
|
377
|
+
var source = cwd.join(args[1]).read({charset: "utf-8"});
|
378
|
+
this.parse(source);
|
379
|
+
}
|
380
|
+
if (require.main === module) {
|
381
|
+
exports.main(require("system").args);
|
382
|
+
}
|
383
|
+
}
|