-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathcsscolor.js
122 lines (122 loc) · 8.55 KB
/
csscolor.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
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
// Generated automatically by nearley, version 2.19.5
// http://github.com/Hardmath123/nearley
(function () {
function id(x) { return x[0]; }
var grammar = {
Lexer: undefined,
ParserRules: [
{"name": "_$ebnf$1", "symbols": []},
{"name": "_$ebnf$1", "symbols": ["_$ebnf$1", "wschar"], "postprocess": function arrpush(d) {return d[0].concat([d[1]]);}},
{"name": "_", "symbols": ["_$ebnf$1"], "postprocess": function(d) {return null;}},
{"name": "__$ebnf$1", "symbols": ["wschar"]},
{"name": "__$ebnf$1", "symbols": ["__$ebnf$1", "wschar"], "postprocess": function arrpush(d) {return d[0].concat([d[1]]);}},
{"name": "__", "symbols": ["__$ebnf$1"], "postprocess": function(d) {return null;}},
{"name": "wschar", "symbols": [/[ \t\n\v\f]/], "postprocess": id},
{"name": "unsigned_int$ebnf$1", "symbols": [/[0-9]/]},
{"name": "unsigned_int$ebnf$1", "symbols": ["unsigned_int$ebnf$1", /[0-9]/], "postprocess": function arrpush(d) {return d[0].concat([d[1]]);}},
{"name": "unsigned_int", "symbols": ["unsigned_int$ebnf$1"], "postprocess":
function(d) {
return parseInt(d[0].join(""));
}
},
{"name": "int$ebnf$1$subexpression$1", "symbols": [{"literal":"-"}]},
{"name": "int$ebnf$1$subexpression$1", "symbols": [{"literal":"+"}]},
{"name": "int$ebnf$1", "symbols": ["int$ebnf$1$subexpression$1"], "postprocess": id},
{"name": "int$ebnf$1", "symbols": [], "postprocess": function(d) {return null;}},
{"name": "int$ebnf$2", "symbols": [/[0-9]/]},
{"name": "int$ebnf$2", "symbols": ["int$ebnf$2", /[0-9]/], "postprocess": function arrpush(d) {return d[0].concat([d[1]]);}},
{"name": "int", "symbols": ["int$ebnf$1", "int$ebnf$2"], "postprocess":
function(d) {
if (d[0]) {
return parseInt(d[0][0]+d[1].join(""));
} else {
return parseInt(d[1].join(""));
}
}
},
{"name": "unsigned_decimal$ebnf$1", "symbols": [/[0-9]/]},
{"name": "unsigned_decimal$ebnf$1", "symbols": ["unsigned_decimal$ebnf$1", /[0-9]/], "postprocess": function arrpush(d) {return d[0].concat([d[1]]);}},
{"name": "unsigned_decimal$ebnf$2$subexpression$1$ebnf$1", "symbols": [/[0-9]/]},
{"name": "unsigned_decimal$ebnf$2$subexpression$1$ebnf$1", "symbols": ["unsigned_decimal$ebnf$2$subexpression$1$ebnf$1", /[0-9]/], "postprocess": function arrpush(d) {return d[0].concat([d[1]]);}},
{"name": "unsigned_decimal$ebnf$2$subexpression$1", "symbols": [{"literal":"."}, "unsigned_decimal$ebnf$2$subexpression$1$ebnf$1"]},
{"name": "unsigned_decimal$ebnf$2", "symbols": ["unsigned_decimal$ebnf$2$subexpression$1"], "postprocess": id},
{"name": "unsigned_decimal$ebnf$2", "symbols": [], "postprocess": function(d) {return null;}},
{"name": "unsigned_decimal", "symbols": ["unsigned_decimal$ebnf$1", "unsigned_decimal$ebnf$2"], "postprocess":
function(d) {
return parseFloat(
d[0].join("") +
(d[1] ? "."+d[1][1].join("") : "")
);
}
},
{"name": "decimal$ebnf$1", "symbols": [{"literal":"-"}], "postprocess": id},
{"name": "decimal$ebnf$1", "symbols": [], "postprocess": function(d) {return null;}},
{"name": "decimal$ebnf$2", "symbols": [/[0-9]/]},
{"name": "decimal$ebnf$2", "symbols": ["decimal$ebnf$2", /[0-9]/], "postprocess": function arrpush(d) {return d[0].concat([d[1]]);}},
{"name": "decimal$ebnf$3$subexpression$1$ebnf$1", "symbols": [/[0-9]/]},
{"name": "decimal$ebnf$3$subexpression$1$ebnf$1", "symbols": ["decimal$ebnf$3$subexpression$1$ebnf$1", /[0-9]/], "postprocess": function arrpush(d) {return d[0].concat([d[1]]);}},
{"name": "decimal$ebnf$3$subexpression$1", "symbols": [{"literal":"."}, "decimal$ebnf$3$subexpression$1$ebnf$1"]},
{"name": "decimal$ebnf$3", "symbols": ["decimal$ebnf$3$subexpression$1"], "postprocess": id},
{"name": "decimal$ebnf$3", "symbols": [], "postprocess": function(d) {return null;}},
{"name": "decimal", "symbols": ["decimal$ebnf$1", "decimal$ebnf$2", "decimal$ebnf$3"], "postprocess":
function(d) {
return parseFloat(
(d[0] || "") +
d[1].join("") +
(d[2] ? "."+d[2][1].join("") : "")
);
}
},
{"name": "percentage", "symbols": ["decimal", {"literal":"%"}], "postprocess":
function(d) {
return d[0]/100;
}
},
{"name": "jsonfloat$ebnf$1", "symbols": [{"literal":"-"}], "postprocess": id},
{"name": "jsonfloat$ebnf$1", "symbols": [], "postprocess": function(d) {return null;}},
{"name": "jsonfloat$ebnf$2", "symbols": [/[0-9]/]},
{"name": "jsonfloat$ebnf$2", "symbols": ["jsonfloat$ebnf$2", /[0-9]/], "postprocess": function arrpush(d) {return d[0].concat([d[1]]);}},
{"name": "jsonfloat$ebnf$3$subexpression$1$ebnf$1", "symbols": [/[0-9]/]},
{"name": "jsonfloat$ebnf$3$subexpression$1$ebnf$1", "symbols": ["jsonfloat$ebnf$3$subexpression$1$ebnf$1", /[0-9]/], "postprocess": function arrpush(d) {return d[0].concat([d[1]]);}},
{"name": "jsonfloat$ebnf$3$subexpression$1", "symbols": [{"literal":"."}, "jsonfloat$ebnf$3$subexpression$1$ebnf$1"]},
{"name": "jsonfloat$ebnf$3", "symbols": ["jsonfloat$ebnf$3$subexpression$1"], "postprocess": id},
{"name": "jsonfloat$ebnf$3", "symbols": [], "postprocess": function(d) {return null;}},
{"name": "jsonfloat$ebnf$4$subexpression$1$ebnf$1", "symbols": [/[+-]/], "postprocess": id},
{"name": "jsonfloat$ebnf$4$subexpression$1$ebnf$1", "symbols": [], "postprocess": function(d) {return null;}},
{"name": "jsonfloat$ebnf$4$subexpression$1$ebnf$2", "symbols": [/[0-9]/]},
{"name": "jsonfloat$ebnf$4$subexpression$1$ebnf$2", "symbols": ["jsonfloat$ebnf$4$subexpression$1$ebnf$2", /[0-9]/], "postprocess": function arrpush(d) {return d[0].concat([d[1]]);}},
{"name": "jsonfloat$ebnf$4$subexpression$1", "symbols": [/[eE]/, "jsonfloat$ebnf$4$subexpression$1$ebnf$1", "jsonfloat$ebnf$4$subexpression$1$ebnf$2"]},
{"name": "jsonfloat$ebnf$4", "symbols": ["jsonfloat$ebnf$4$subexpression$1"], "postprocess": id},
{"name": "jsonfloat$ebnf$4", "symbols": [], "postprocess": function(d) {return null;}},
{"name": "jsonfloat", "symbols": ["jsonfloat$ebnf$1", "jsonfloat$ebnf$2", "jsonfloat$ebnf$3", "jsonfloat$ebnf$4"], "postprocess":
function(d) {
return parseFloat(
(d[0] || "") +
d[1].join("") +
(d[2] ? "."+d[2][1].join("") : "") +
(d[3] ? "e" + (d[3][1] || "+") + d[3][2].join("") : "")
);
}
},
{"name": "csscolor", "symbols": [{"literal":"#"}, "hexdigit", "hexdigit", "hexdigit", "hexdigit", "hexdigit", "hexdigit"]},
{"name": "csscolor", "symbols": [{"literal":"#"}, "hexdigit", "hexdigit", "hexdigit"]},
{"name": "csscolor$string$1", "symbols": [{"literal":"r"}, {"literal":"g"}, {"literal":"b"}], "postprocess": function joiner(d) {return d.join('');}},
{"name": "csscolor", "symbols": ["csscolor$string$1", "_", {"literal":"("}, "_", "colnum", "_", {"literal":","}, "_", "colnum", "_", {"literal":","}, "_", "colnum", "_", {"literal":")"}]},
{"name": "csscolor$string$2", "symbols": [{"literal":"h"}, {"literal":"s"}, {"literal":"l"}], "postprocess": function joiner(d) {return d.join('');}},
{"name": "csscolor", "symbols": ["csscolor$string$2", "_", {"literal":"("}, "_", "colnum", "_", {"literal":","}, "_", "colnum", "_", {"literal":","}, "_", "colnum", "_", {"literal":")"}]},
{"name": "csscolor$string$3", "symbols": [{"literal":"r"}, {"literal":"g"}, {"literal":"b"}, {"literal":"a"}], "postprocess": function joiner(d) {return d.join('');}},
{"name": "csscolor", "symbols": ["csscolor$string$3", "_", {"literal":"("}, "_", "colnum", "_", {"literal":","}, "_", "colnum", "_", {"literal":","}, "_", "colnum", "_", {"literal":","}, "_", "decimal", "_", {"literal":")"}]},
{"name": "csscolor$string$4", "symbols": [{"literal":"h"}, {"literal":"s"}, {"literal":"l"}, {"literal":"a"}], "postprocess": function joiner(d) {return d.join('');}},
{"name": "csscolor", "symbols": ["csscolor$string$4", "_", {"literal":"("}, "_", "colnum", "_", {"literal":","}, "_", "colnum", "_", {"literal":","}, "_", "colnum", "_", {"literal":","}, "_", "decimal", "_", {"literal":")"}]},
{"name": "hexdigit", "symbols": [/[a-fA-F0-9]/]},
{"name": "colnum", "symbols": ["int"]},
{"name": "colnum", "symbols": ["percentage"]}
]
, ParserStart: "csscolor"
}
if (typeof module !== 'undefined'&& typeof module.exports !== 'undefined') {
module.exports = grammar;
} else {
window.grammar = grammar;
}
})();