-
Notifications
You must be signed in to change notification settings - Fork 25
/
Copy pathlanguage.js
68 lines (63 loc) · 1.47 KB
/
language.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
var Set = require("collections/set");
var Map = require("collections/map");
var precedence = exports.precedence = new Map();
var levels = exports.precedenceLevels = [
["tuple", "record"],
[
"literal",
"value",
"parameters",
"property",
"element",
"component",
"mapBlock",
"filterBlock",
"sortedBlock",
"groupBlock",
"groupMapBlock",
"with"
],
["not", "neg", "number", "parent"],
["scope"],
["default"],
["pow", "root", "log"],
["mul", "div", "mod", "rem"],
["add", "sub"],
["equals", "lt", "gt", "le", "ge", "compare"],
["and"],
["or"],
["if"]
];
for(var i=0, countI = levels.length, predecessors, level, j, countJ; i<countI; i++) {
level = levels[i];
predecessors = new Set(precedence.keysArray());
for(j=0, countJ = level.length; j<countJ; j++) {
precedence.set(level[j], predecessors);
}
}
var operatorTokens = exports.operatorTokens = Map.from({
"**": "pow",
"//": "root",
"%%": "log",
"*": "mul",
"/": "div",
"%": "mod",
"rem": "rem",
"+": "add",
"-": "sub",
"<": "lt",
">": "gt",
"<=": "le",
">=": "ge",
"==": "equals",
"<=>": "compare",
"!=": "notEquals",
"??": "default",
"&&": "and",
"||": "or",
"?": "then",
":": "else"
});
exports.operatorTypes = new Map(operatorTokens.map(function (type, token) {
return [type, token];
}));