-
Notifications
You must be signed in to change notification settings - Fork 13
/
Copy pathselect.js
34 lines (29 loc) · 830 Bytes
/
select.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
var grammar = {
"lex": {
"rules": [
["\\s+", "/* skip whitespace */"],
["\\,", "return 'COMMA';"],
["\\w\[^\\s\\,]+(\\b|%)", "return 'WORD';"],
["$", "return 'EOF';"]
]
},
"bnf": {
"select": [
["s EOF", "return $1;"]
],
"s": [
["WORD COMMA s", "$$ = $3; $$[$1] = 1;"],
["WORD", "$$ = new Object; $$[$1] = 1;"]
]
}
};
var Parser = require("jison").Parser;
var parser = new Parser(grammar);
module.exports = function(input) {
if (typeof(input) == 'string' && input != "") {
return parser.parse(decodeURI(input));
}
else {
return {};
}
};