-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathexpressions.js
40 lines (40 loc) · 2.74 KB
/
expressions.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
// Generated automatically by nearley, version 2.16.0
// http://github.com/Hardmath123/nearley
(function () {
function id(x) { return x[0]; }
var grammar = {
Lexer: undefined,
ParserRules: [
{"name": "main", "symbols": ["_", "AS", "_"], "postprocess": d => ({ type: "root", arg: d[1] })},
{"name": "P", "symbols": [{"literal":"("}, "_", "AS", "_", {"literal":")"}], "postprocess": d => ({ type: "parens", arg: d[2] })},
{"name": "P", "symbols": ["N"], "postprocess": id},
{"name": "E", "symbols": ["P", "_", {"literal":"^"}, "_", "E"], "postprocess": d => ({ type: "^", base: d[0], exponent: d[4] })},
{"name": "E", "symbols": ["P"], "postprocess": id},
{"name": "MD", "symbols": ["MD", "_", {"literal":"*"}, "_", "E"], "postprocess": d => ({ type: "*", arg1: d[0], arg2: d[4] })},
{"name": "MD", "symbols": ["MD", "_", {"literal":"/"}, "_", "E"], "postprocess": d => ({ type: "/", arg1: d[0], arg2: d[4] })},
{"name": "MD", "symbols": ["E"], "postprocess": id},
{"name": "AS", "symbols": ["AS", "_", {"literal":"+"}, "_", "MD"], "postprocess": d => ({ type: "+", arg1: d[0], arg2: d[4] })},
{"name": "AS", "symbols": ["AS", "_", {"literal":"-"}, "_", "MD"], "postprocess": d => ({ type: "-", arg1: d[0], arg2: d[4] })},
{"name": "AS", "symbols": ["MD"], "postprocess": id},
{"name": "N", "symbols": ["float"], "postprocess": id},
{"name": "N$string$1", "symbols": [{"literal":"s"}, {"literal":"i"}, {"literal":"n"}], "postprocess": function joiner(d) {return d.join('');}},
{"name": "N", "symbols": ["N$string$1", "_", "P"], "postprocess": d => ({ type: "sin", arg: d[2] })},
{"name": "N$string$2", "symbols": [{"literal":"p"}, {"literal":"i"}], "postprocess": function joiner(d) {return d.join('');}},
{"name": "N", "symbols": ["N$string$2"], "postprocess": d => ({ type: "pi" })},
{"name": "float", "symbols": ["int", {"literal":"."}, "int"], "postprocess": d => ({ type: "number", num: parseFloat(d[0] + d[1] + d[2]) })},
{"name": "float", "symbols": ["int"], "postprocess": d => ({ type: "number", num: parseInt(d[0]) })},
{"name": "int$ebnf$1", "symbols": [/[0-9]/]},
{"name": "int$ebnf$1", "symbols": ["int$ebnf$1", /[0-9]/], "postprocess": function arrpush(d) {return d[0].concat([d[1]]);}},
{"name": "int", "symbols": ["int$ebnf$1"], "postprocess": d => d[0].join("")},
{"name": "_$ebnf$1", "symbols": []},
{"name": "_$ebnf$1", "symbols": ["_$ebnf$1", /[\s]/], "postprocess": function arrpush(d) {return d[0].concat([d[1]]);}},
{"name": "_", "symbols": ["_$ebnf$1"], "postprocess": function(d) {return null; }}
]
, ParserStart: "main"
}
if (typeof module !== 'undefined'&& typeof module.exports !== 'undefined') {
module.exports = grammar;
} else {
window.grammar = grammar;
}
})();