glamor
Version:
inline css for component systems
1,787 lines (1,710 loc) • 265 kB
JavaScript
/*
* Generated by PEG.js 0.10.0.
*
* http://pegjs.org/
*/
"use strict";
function _defineProperty(obj, key, value) { if (key in obj) { Object.defineProperty(obj, key, { value: value, enumerable: true, configurable: true, writable: true }); } else { obj[key] = value; } return obj; }
function peg$subclass(child, parent) {
function ctor() {
this.constructor = child;
}
ctor.prototype = parent.prototype;
child.prototype = new ctor();
}
function peg$SyntaxError(message, expected, found, location) {
this.message = message;
this.expected = expected;
this.found = found;
this.location = location;
this.name = "SyntaxError";
if (typeof Error.captureStackTrace === "function") {
Error.captureStackTrace(this, peg$SyntaxError);
}
}
peg$subclass(peg$SyntaxError, Error);
peg$SyntaxError.buildMessage = function (expected, found) {
var DESCRIBE_EXPECTATION_FNS = {
literal: function literal(expectation) {
return "\"" + literalEscape(expectation.text) + "\"";
},
"class": function _class(expectation) {
var escapedParts = "",
i;
for (i = 0; i < expectation.parts.length; i++) {
escapedParts += expectation.parts[i] instanceof Array ? classEscape(expectation.parts[i][0]) + "-" + classEscape(expectation.parts[i][1]) : classEscape(expectation.parts[i]);
}
return "[" + (expectation.inverted ? "^" : "") + escapedParts + "]";
},
any: function any(expectation) {
return "any character";
},
end: function end(expectation) {
return "end of input";
},
other: function other(expectation) {
return expectation.description;
}
};
function hex(ch) {
return ch.charCodeAt(0).toString(16).toUpperCase();
}
function literalEscape(s) {
return s.replace(/\\/g, '\\\\').replace(/"/g, '\\"').replace(/\0/g, '\\0').replace(/\t/g, '\\t').replace(/\n/g, '\\n').replace(/\r/g, '\\r').replace(/[\x00-\x0F]/g, function (ch) {
return '\\x0' + hex(ch);
}).replace(/[\x10-\x1F\x7F-\x9F]/g, function (ch) {
return '\\x' + hex(ch);
});
}
function classEscape(s) {
return s.replace(/\\/g, '\\\\').replace(/\]/g, '\\]').replace(/\^/g, '\\^').replace(/-/g, '\\-').replace(/\0/g, '\\0').replace(/\t/g, '\\t').replace(/\n/g, '\\n').replace(/\r/g, '\\r').replace(/[\x00-\x0F]/g, function (ch) {
return '\\x0' + hex(ch);
}).replace(/[\x10-\x1F\x7F-\x9F]/g, function (ch) {
return '\\x' + hex(ch);
});
}
function describeExpectation(expectation) {
return DESCRIBE_EXPECTATION_FNS[expectation.type](expectation);
}
function describeExpected(expected) {
var descriptions = new Array(expected.length),
i,
j;
for (i = 0; i < expected.length; i++) {
descriptions[i] = describeExpectation(expected[i]);
}
descriptions.sort();
if (descriptions.length > 0) {
for (i = 1, j = 1; i < descriptions.length; i++) {
if (descriptions[i - 1] !== descriptions[i]) {
descriptions[j] = descriptions[i];
j++;
}
}
descriptions.length = j;
}
switch (descriptions.length) {
case 1:
return descriptions[0];
case 2:
return descriptions[0] + " or " + descriptions[1];
default:
return descriptions.slice(0, -1).join(", ") + ", or " + descriptions[descriptions.length - 1];
}
}
function describeFound(found) {
return found ? "\"" + literalEscape(found) + "\"" : "end of input";
}
return "Expected " + describeExpected(expected) + " but " + describeFound(found) + " found.";
};
function peg$parse(input, options) {
options = options !== void 0 ? options : {};
var peg$FAILED = {},
peg$startRuleFunctions = { start: peg$parsestart },
peg$startRuleFunction = peg$parsestart,
peg$c0 = function peg$c0(stylesheet) {
return stylesheet;
},
peg$c1 = function peg$c1(rules) {
return {
type: 'StyleSheet',
rules: extractList(rules, 0) };
},
peg$c2 = ";",
peg$c3 = peg$literalExpectation(";", false),
peg$c4 = function peg$c4(dec) {
return dec;
},
peg$c5 = "{",
peg$c6 = peg$literalExpectation("{", false),
peg$c7 = "}",
peg$c8 = peg$literalExpectation("}", false),
peg$c9 = function peg$c9(media, rules) {
return {
type: "MediaRule",
media: media,
rules: rules
};
},
peg$c10 = ",",
peg$c11 = peg$literalExpectation(",", false),
peg$c12 = function peg$c12(head, tail) {
return buildList(head, tail, 2);
},
peg$c13 = "only",
peg$c14 = peg$literalExpectation("only", false),
peg$c15 = "not",
peg$c16 = peg$literalExpectation("not", false),
peg$c17 = "and",
peg$c18 = peg$literalExpectation("and", false),
peg$c19 = function peg$c19(prefix, type, x) {
return x;
},
peg$c20 = function peg$c20(prefix, type, exprs) {
var _ref;
return _ref = {
type: 'MediaQuery',
prefix: prefix
}, _defineProperty(_ref, "type", type), _defineProperty(_ref, "exprs", exprs), _ref;
},
peg$c21 = function peg$c21(head, x) {
return x;
},
peg$c22 = function peg$c22(head, tail) {
return {
type: 'MediaQuery',
exprs: buildList(head, tail, 2)
};
},
peg$c23 = "(",
peg$c24 = peg$literalExpectation("(", false),
peg$c25 = ":",
peg$c26 = peg$literalExpectation(":", false),
peg$c27 = function peg$c27(feat, t) {
return t;
},
peg$c28 = ")",
peg$c29 = peg$literalExpectation(")", false),
peg$c30 = function peg$c30(feat, t) {
return {
type: 'MediaExpr',
feature: feat,
value: t
};
},
peg$c31 = "/",
peg$c32 = peg$literalExpectation("/", false),
peg$c33 = function peg$c33() {
return "/";
},
peg$c34 = function peg$c34() {
return ",";
},
peg$c35 = "+",
peg$c36 = peg$literalExpectation("+", false),
peg$c37 = function peg$c37() {
return "+";
},
peg$c38 = ">",
peg$c39 = peg$literalExpectation(">", false),
peg$c40 = function peg$c40() {
return ">";
},
peg$c41 = function peg$c41(name) {
return name;
},
peg$c42 = function peg$c42(selectorsHead, selectorsTail, declarationsHead, declarationsTail) {
return {
type: "RuleSet",
selectors: buildList(selectorsHead, selectorsTail, 2),
declarations: buildList(declarationsHead, declarationsTail, 2)
};
},
peg$c43 = function peg$c43(combinator, right) {
return {
type: "Selector",
combinator: combinator,
left: { type: 'Contextual' },
right: right
};
},
peg$c44 = function peg$c44(left, combinator, right) {
return {
type: "Selector",
combinator: combinator,
left: left,
right: right
};
},
peg$c45 = function peg$c45(left, right) {
return {
type: "Selector",
combinator: " ",
left: left,
right: right
};
},
peg$c46 = function peg$c46(selector) {
return selector;
},
peg$c47 = function peg$c47(inter) {
return inter;
},
peg$c48 = function peg$c48(element, qualifiers) {
return {
type: "SimpleSelector",
element: element,
all: element === '*',
qualifiers: qualifiers
};
},
peg$c49 = function peg$c49(qualifiers) {
return {
type: "SimpleSelector",
element: "*",
all: false,
qualifiers: qualifiers
};
},
peg$c50 = function peg$c50(stubsHead, stubsTail) {
return {
type: "Stubs",
stubs: buildList(stubsHead, stubsTail, 2)
};
},
peg$c51 = "-",
peg$c52 = peg$literalExpectation("-", false),
peg$c53 = function peg$c53(stub_id) {
return {
type: 'Stub',
id: stub_id.join('').trim()
};
},
peg$c54 = function peg$c54() {
return { type: 'Contextual' };
},
peg$c55 = function peg$c55(id) {
return { type: "IDSelector", id: id };
},
peg$c56 = ".",
peg$c57 = peg$literalExpectation(".", false),
peg$c58 = function peg$c58(class_) {
return { type: "ClassSelector", "class": class_ };
},
peg$c59 = "*",
peg$c60 = peg$literalExpectation("*", false),
peg$c61 = "[",
peg$c62 = peg$literalExpectation("[", false),
peg$c63 = "=",
peg$c64 = peg$literalExpectation("=", false),
peg$c65 = "]",
peg$c66 = peg$literalExpectation("]", false),
peg$c67 = function peg$c67(attribute, operatorAndValue) {
var operator = extractOptional(operatorAndValue, 0);
if (Array.isArray(operator)) {
operator = operator[1];
}
return {
type: "AttributeSelector",
attribute: attribute,
operator: operator,
value: extractOptional(operatorAndValue, 2)
};
},
peg$c68 = function peg$c68(name, params) {
return {
type: "Function",
name: name,
params: params !== null ? [params[0]] : []
};
},
peg$c69 = function peg$c69(value) {
return { type: "PseudoSelector", value: value };
},
peg$c70 = function peg$c70(name, value, prio) {
return {
type: "Declaration",
name: name,
value: value,
important: prio !== null
};
},
peg$c71 = function peg$c71(inter) {
return inter;
},
peg$c72 = function peg$c72(head, tail) {
return buildExpression(head, tail);
},
peg$c73 = function peg$c73(quantity) {
return {
type: "Quantity",
value: quantity.value,
unit: quantity.unit
};
},
peg$c74 = function peg$c74(value) {
return { type: "String", value: value };
},
peg$c75 = function peg$c75(value) {
return { type: "URI", value: value };
},
peg$c76 = function peg$c76(value) {
return { type: "Ident", value: value };
},
peg$c77 = function peg$c77(name, params) {
return { type: "Function", name: name, params: params };
},
peg$c78 = function peg$c78(value) {
return { type: "Hexcolor", value: value };
},
peg$c79 = /^[0-9a-f]/i,
peg$c80 = peg$classExpectation([["0", "9"], ["a", "f"]], false, true),
peg$c81 = /^[\x80-\uFFFF]/,
peg$c82 = peg$classExpectation([["\x80", "\uFFFF"]], false, false),
peg$c83 = "\\",
peg$c84 = peg$literalExpectation("\\", false),
peg$c85 = "\r\n",
peg$c86 = peg$literalExpectation("\r\n", false),
peg$c87 = /^[ \t\r\n\f]/,
peg$c88 = peg$classExpectation([" ", "\t", "\r", "\n", "\f"], false, false),
peg$c89 = function peg$c89(digits) {
return String.fromCharCode(parseInt(digits, 16));
},
peg$c90 = /^[^\r\n\f0-9a-f]/i,
peg$c91 = peg$classExpectation(["\r", "\n", "\f", ["0", "9"], ["a", "f"]], true, true),
peg$c92 = function peg$c92(ch) {
return ch;
},
peg$c93 = /^[_a-z]/i,
peg$c94 = peg$classExpectation(["_", ["a", "z"]], false, true),
peg$c95 = /^[_a-z0-9\-]/i,
peg$c96 = peg$classExpectation(["_", ["a", "z"], ["0", "9"], "-"], false, true),
peg$c97 = "\"",
peg$c98 = peg$literalExpectation("\"", false),
peg$c99 = /^[^\n\r\f\\"]/,
peg$c100 = peg$classExpectation(["\n", "\r", "\f", "\\", "\""], true, false),
peg$c101 = function peg$c101(nl) {
return "";
},
peg$c102 = function peg$c102(chars) {
return chars.join("");
},
peg$c103 = "'",
peg$c104 = peg$literalExpectation("'", false),
peg$c105 = /^[^\n\r\f\\']/,
peg$c106 = peg$classExpectation(["\n", "\r", "\f", "\\", "'"], true, false),
peg$c107 = "/*",
peg$c108 = peg$literalExpectation("/*", false),
peg$c109 = /^[^*]/,
peg$c110 = peg$classExpectation(["*"], true, false),
peg$c111 = /^[^\/*]/,
peg$c112 = peg$classExpectation(["/", "*"], true, false),
peg$c113 = function peg$c113(prefix, start, chars) {
return prefix + start + chars.join("");
},
peg$c114 = function peg$c114(chars) {
return chars.join("");
},
peg$c115 = /^[+\-]/,
peg$c116 = peg$classExpectation(["+", "-"], false, false),
peg$c117 = /^[0-9]/,
peg$c118 = peg$classExpectation([["0", "9"]], false, false),
peg$c119 = "e",
peg$c120 = peg$literalExpectation("e", false),
peg$c121 = function peg$c121() {
return parseFloat(text());
},
peg$c122 = function peg$c122() {
return inter;
},
peg$c123 = /^[!#$%&*-[\]-~]/,
peg$c124 = peg$classExpectation(["!", "#", "$", "%", "&", ["*", "["], ["]", "~"]], false, false),
peg$c125 = function peg$c125(chars) {
chars.join("");
},
peg$c126 = "\n",
peg$c127 = peg$literalExpectation("\n", false),
peg$c128 = "\r",
peg$c129 = peg$literalExpectation("\r", false),
peg$c130 = "\f",
peg$c131 = peg$literalExpectation("\f", false),
peg$c132 = "a",
peg$c133 = peg$literalExpectation("a", true),
peg$c134 = "0",
peg$c135 = peg$literalExpectation("0", false),
peg$c136 = /^[Aa]/,
peg$c137 = peg$classExpectation(["A", "a"], false, false),
peg$c138 = function peg$c138() {
return "a";
},
peg$c139 = "c",
peg$c140 = peg$literalExpectation("c", true),
peg$c141 = /^[Cc]/,
peg$c142 = peg$classExpectation(["C", "c"], false, false),
peg$c143 = function peg$c143() {
return "c";
},
peg$c144 = "d",
peg$c145 = peg$literalExpectation("d", true),
peg$c146 = /^[Dd]/,
peg$c147 = peg$classExpectation(["D", "d"], false, false),
peg$c148 = function peg$c148() {
return "d";
},
peg$c149 = peg$literalExpectation("e", true),
peg$c150 = /^[Ee]/,
peg$c151 = peg$classExpectation(["E", "e"], false, false),
peg$c152 = function peg$c152() {
return "e";
},
peg$c153 = "g",
peg$c154 = peg$literalExpectation("g", true),
peg$c155 = /^[Gg]/,
peg$c156 = peg$classExpectation(["G", "g"], false, false),
peg$c157 = "\\g",
peg$c158 = peg$literalExpectation("\\g", true),
peg$c159 = function peg$c159() {
return "g";
},
peg$c160 = "h",
peg$c161 = peg$literalExpectation("h", true),
peg$c162 = /^[Hh]/,
peg$c163 = peg$classExpectation(["H", "h"], false, false),
peg$c164 = "\\h",
peg$c165 = peg$literalExpectation("\\h", true),
peg$c166 = function peg$c166() {
return "h";
},
peg$c167 = "i",
peg$c168 = peg$literalExpectation("i", true),
peg$c169 = /^[Ii]/,
peg$c170 = peg$classExpectation(["I", "i"], false, false),
peg$c171 = "\\i",
peg$c172 = peg$literalExpectation("\\i", true),
peg$c173 = function peg$c173() {
return "i";
},
peg$c174 = "k",
peg$c175 = peg$literalExpectation("k", true),
peg$c176 = /^[Kk]/,
peg$c177 = peg$classExpectation(["K", "k"], false, false),
peg$c178 = "\\k",
peg$c179 = peg$literalExpectation("\\k", true),
peg$c180 = function peg$c180() {
return "k";
},
peg$c181 = "l",
peg$c182 = peg$literalExpectation("l", true),
peg$c183 = /^[Ll]/,
peg$c184 = peg$classExpectation(["L", "l"], false, false),
peg$c185 = "\\l",
peg$c186 = peg$literalExpectation("\\l", true),
peg$c187 = function peg$c187() {
return "l";
},
peg$c188 = "m",
peg$c189 = peg$literalExpectation("m", true),
peg$c190 = /^[Mm]/,
peg$c191 = peg$classExpectation(["M", "m"], false, false),
peg$c192 = "\\m",
peg$c193 = peg$literalExpectation("\\m", true),
peg$c194 = function peg$c194() {
return "m";
},
peg$c195 = "n",
peg$c196 = peg$literalExpectation("n", true),
peg$c197 = /^[Nn]/,
peg$c198 = peg$classExpectation(["N", "n"], false, false),
peg$c199 = "\\n",
peg$c200 = peg$literalExpectation("\\n", true),
peg$c201 = function peg$c201() {
return "n";
},
peg$c202 = "o",
peg$c203 = peg$literalExpectation("o", true),
peg$c204 = /^[Oo]/,
peg$c205 = peg$classExpectation(["O", "o"], false, false),
peg$c206 = "\\o",
peg$c207 = peg$literalExpectation("\\o", true),
peg$c208 = function peg$c208() {
return "o";
},
peg$c209 = "p",
peg$c210 = peg$literalExpectation("p", true),
peg$c211 = /^[Pp]/,
peg$c212 = peg$classExpectation(["P", "p"], false, false),
peg$c213 = "\\p",
peg$c214 = peg$literalExpectation("\\p", true),
peg$c215 = function peg$c215() {
return "p";
},
peg$c216 = "r",
peg$c217 = peg$literalExpectation("r", true),
peg$c218 = /^[Rr]/,
peg$c219 = peg$classExpectation(["R", "r"], false, false),
peg$c220 = "\\r",
peg$c221 = peg$literalExpectation("\\r", true),
peg$c222 = function peg$c222() {
return "r";
},
peg$c223 = "s",
peg$c224 = peg$literalExpectation("s", true),
peg$c225 = /^[Ss]/,
peg$c226 = peg$classExpectation(["S", "s"], false, false),
peg$c227 = "\\s",
peg$c228 = peg$literalExpectation("\\s", true),
peg$c229 = function peg$c229() {
return "s";
},
peg$c230 = "t",
peg$c231 = peg$literalExpectation("t", true),
peg$c232 = /^[Tt]/,
peg$c233 = peg$classExpectation(["T", "t"], false, false),
peg$c234 = "\\t",
peg$c235 = peg$literalExpectation("\\t", true),
peg$c236 = function peg$c236() {
return "t";
},
peg$c237 = "u",
peg$c238 = peg$literalExpectation("u", true),
peg$c239 = /^[Uu]/,
peg$c240 = peg$classExpectation(["U", "u"], false, false),
peg$c241 = "\\u",
peg$c242 = peg$literalExpectation("\\u", true),
peg$c243 = function peg$c243() {
return "u";
},
peg$c244 = "v",
peg$c245 = peg$literalExpectation("v", true),
peg$c246 = /^[Vv]/,
peg$c247 = peg$classExpectation(["V", "v"], false, false),
peg$c248 = "\\v",
peg$c249 = peg$literalExpectation("\\v", true),
peg$c250 = function peg$c250() {
return "v";
},
peg$c251 = "w",
peg$c252 = peg$literalExpectation("w", true),
peg$c253 = /^[Ww]/,
peg$c254 = peg$classExpectation(["W", "w"], false, false),
peg$c255 = "\\w",
peg$c256 = peg$literalExpectation("\\w", true),
peg$c257 = function peg$c257() {
return "w";
},
peg$c258 = "x",
peg$c259 = peg$literalExpectation("x", true),
peg$c260 = /^[Xx]/,
peg$c261 = peg$classExpectation(["X", "x"], false, false),
peg$c262 = "\\x",
peg$c263 = peg$literalExpectation("\\x", true),
peg$c264 = function peg$c264() {
return "x";
},
peg$c265 = "z",
peg$c266 = peg$literalExpectation("z", true),
peg$c267 = /^[Zz]/,
peg$c268 = peg$classExpectation(["Z", "z"], false, false),
peg$c269 = "\\z",
peg$c270 = peg$literalExpectation("\\z", true),
peg$c271 = function peg$c271() {
return "z";
},
peg$c272 = peg$otherExpectation("ampersand"),
peg$c273 = "&",
peg$c274 = peg$literalExpectation("&", false),
peg$c275 = peg$otherExpectation("whitespace"),
peg$c276 = peg$otherExpectation("<!--"),
peg$c277 = "<!--",
peg$c278 = peg$literalExpectation("<!--", false),
peg$c279 = peg$otherExpectation("-->"),
peg$c280 = "-->",
peg$c281 = peg$literalExpectation("-->", false),
peg$c282 = peg$otherExpectation("~="),
peg$c283 = "~=",
peg$c284 = peg$literalExpectation("~=", false),
peg$c285 = peg$otherExpectation("|="),
peg$c286 = "|=",
peg$c287 = peg$literalExpectation("|=", false),
peg$c288 = peg$otherExpectation("^="),
peg$c289 = "^=",
peg$c290 = peg$literalExpectation("^=", false),
peg$c291 = peg$otherExpectation("$="),
peg$c292 = "$=",
peg$c293 = peg$literalExpectation("$=", false),
peg$c294 = peg$otherExpectation("*="),
peg$c295 = "*=",
peg$c296 = peg$literalExpectation("*=", false),
peg$c297 = peg$otherExpectation("string"),
peg$c298 = function peg$c298(string) {
return string;
},
peg$c299 = peg$otherExpectation("identifier"),
peg$c300 = function peg$c300(ident) {
return ident;
},
peg$c301 = peg$otherExpectation("hash"),
peg$c302 = "#",
peg$c303 = peg$literalExpectation("#", false),
peg$c304 = function peg$c304(name) {
return "#" + name;
},
peg$c305 = peg$otherExpectation("@import"),
peg$c306 = "@",
peg$c307 = peg$literalExpectation("@", false),
peg$c308 = peg$otherExpectation("@media"),
peg$c309 = peg$otherExpectation("!important"),
peg$c310 = "!",
peg$c311 = peg$literalExpectation("!", false),
peg$c312 = peg$otherExpectation("length"),
peg$c313 = function peg$c313(value) {
return { value: value, unit: "em" };
},
peg$c314 = function peg$c314(value) {
return { value: value, unit: "ex" };
},
peg$c315 = function peg$c315(value) {
return { value: value, unit: "px" };
},
peg$c316 = function peg$c316(value) {
return { value: value, unit: "cm" };
},
peg$c317 = function peg$c317(value) {
return { value: value, unit: "mm" };
},
peg$c318 = function peg$c318(value) {
return { value: value, unit: "in" };
},
peg$c319 = function peg$c319(value) {
return { value: value, unit: "pt" };
},
peg$c320 = function peg$c320(value) {
return { value: value, unit: "pc" };
},
peg$c321 = function peg$c321(value) {
return { value: value, unit: "rem" };
},
peg$c322 = function peg$c322(value) {
return { value: value, unit: "vh" };
},
peg$c323 = function peg$c323(value) {
return { value: value, unit: "vw" };
},
peg$c324 = function peg$c324(value) {
return { value: value, unit: "vmin" };
},
peg$c325 = peg$otherExpectation("angle"),
peg$c326 = function peg$c326(value) {
return { value: value, unit: "deg" };
},
peg$c327 = function peg$c327(value) {
return { value: value, unit: "rad" };
},
peg$c328 = function peg$c328(value) {
return { value: value, unit: "grad" };
},
peg$c329 = peg$otherExpectation("time"),
peg$c330 = function peg$c330(value) {
return { value: value, unit: "ms" };
},
peg$c331 = function peg$c331(value) {
return { value: value, unit: "s" };
},
peg$c332 = peg$otherExpectation("frequency"),
peg$c333 = function peg$c333(value) {
return { value: value, unit: "hz" };
},
peg$c334 = function peg$c334(value) {
return { value: value, unit: "kh" };
},
peg$c335 = peg$otherExpectation("percentage"),
peg$c336 = "%",
peg$c337 = peg$literalExpectation("%", false),
peg$c338 = function peg$c338(value) {
return { value: value, unit: "%" };
},
peg$c339 = peg$otherExpectation("number"),
peg$c340 = function peg$c340(value) {
return { value: value, unit: null };
},
peg$c341 = peg$otherExpectation("uri"),
peg$c342 = peg$literalExpectation("(", true),
peg$c343 = function peg$c343(url) {
return url;
},
peg$c344 = peg$otherExpectation("function"),
peg$currPos = 0,
peg$savedPos = 0,
peg$posDetailsCache = [{ line: 1, column: 1 }],
peg$maxFailPos = 0,
peg$maxFailExpected = [],
peg$silentFails = 0,
peg$result;
if ("startRule" in options) {
if (!(options.startRule in peg$startRuleFunctions)) {
throw new Error("Can't start parsing from rule \"" + options.startRule + "\".");
}
peg$startRuleFunction = peg$startRuleFunctions[options.startRule];
}
function text() {
return input.substring(peg$savedPos, peg$currPos);
}
function location() {
return peg$computeLocation(peg$savedPos, peg$currPos);
}
function expected(description, location) {
location = location !== void 0 ? location : peg$computeLocation(peg$savedPos, peg$currPos);
throw peg$buildStructuredError([peg$otherExpectation(description)], input.substring(peg$savedPos, peg$currPos), location);
}
function error(message, location) {
location = location !== void 0 ? location : peg$computeLocation(peg$savedPos, peg$currPos);
throw peg$buildSimpleError(message, location);
}
function peg$literalExpectation(text, ignoreCase) {
return { type: "literal", text: text, ignoreCase: ignoreCase };
}
function peg$classExpectation(parts, inverted, ignoreCase) {
return { type: "class", parts: parts, inverted: inverted, ignoreCase: ignoreCase };
}
function peg$anyExpectation() {
return { type: "any" };
}
function peg$endExpectation() {
return { type: "end" };
}
function peg$otherExpectation(description) {
return { type: "other", description: description };
}
function peg$computePosDetails(pos) {
var details = peg$posDetailsCache[pos],
p;
if (details) {
return details;
} else {
p = pos - 1;
while (!peg$posDetailsCache[p]) {
p--;
}
details = peg$posDetailsCache[p];
details = {
line: details.line,
column: details.column
};
while (p < pos) {
if (input.charCodeAt(p) === 10) {
details.line++;
details.column = 1;
} else {
details.column++;
}
p++;
}
peg$posDetailsCache[pos] = details;
return details;
}
}
function peg$computeLocation(startPos, endPos) {
var startPosDetails = peg$computePosDetails(startPos),
endPosDetails = peg$computePosDetails(endPos);
return {
start: {
offset: startPos,
line: startPosDetails.line,
column: startPosDetails.column
},
end: {
offset: endPos,
line: endPosDetails.line,
column: endPosDetails.column
}
};
}
function peg$fail(expected) {
if (peg$currPos < peg$maxFailPos) {
return;
}
if (peg$currPos > peg$maxFailPos) {
peg$maxFailPos = peg$currPos;
peg$maxFailExpected = [];
}
peg$maxFailExpected.push(expected);
}
function peg$buildSimpleError(message, location) {
return new peg$SyntaxError(message, null, null, location);
}
function peg$buildStructuredError(expected, found, location) {
return new peg$SyntaxError(peg$SyntaxError.buildMessage(expected, found), expected, found, location);
}
function peg$parsestart() {
var s0, s1, s2, s3, s4, s5;
s0 = peg$currPos;
s1 = [];
s2 = peg$parsecomment();
while (s2 !== peg$FAILED) {
s1.push(s2);
s2 = peg$parsecomment();
}
if (s1 !== peg$FAILED) {
s2 = [];
s3 = peg$parseS();
while (s3 !== peg$FAILED) {
s2.push(s3);
s3 = peg$parseS();
}
if (s2 !== peg$FAILED) {
s3 = peg$parsestylesheet();
if (s3 !== peg$FAILED) {
s4 = [];
s5 = peg$parsecomment();
while (s5 !== peg$FAILED) {
s4.push(s5);
s5 = peg$parsecomment();
}
if (s4 !== peg$FAILED) {
peg$savedPos = s0;
s1 = peg$c0(s3);
s0 = s1;
} else {
peg$currPos = s0;
s0 = peg$FAILED;
}
} else {
peg$currPos = s0;
s0 = peg$FAILED;
}
} else {
peg$currPos = s0;
s0 = peg$FAILED;
}
} else {
peg$currPos = s0;
s0 = peg$FAILED;
}
return s0;
}
function peg$parsestylesheet() {
var s0, s1, s2, s3, s4, s5, s6, s7, s8;
s0 = peg$currPos;
s1 = [];
s2 = peg$currPos;
s3 = peg$parsestubs();
if (s3 === peg$FAILED) {
s3 = peg$parseruleset();
if (s3 === peg$FAILED) {
s3 = peg$parsemedia();
if (s3 === peg$FAILED) {
s3 = peg$parsedeclare();
}
}
}
if (s3 !== peg$FAILED) {
s4 = [];
s5 = peg$currPos;
s6 = peg$parseCDO();
if (s6 !== peg$FAILED) {
s7 = [];
s8 = peg$parseS();
while (s8 !== peg$FAILED) {
s7.push(s8);
s8 = peg$parseS();
}
if (s7 !== peg$FAILED) {
s6 = [s6, s7];
s5 = s6;
} else {
peg$currPos = s5;
s5 = peg$FAILED;
}
} else {
peg$currPos = s5;
s5 = peg$FAILED;
}
if (s5 === peg$FAILED) {
s5 = peg$currPos;
s6 = peg$parseCDC();
if (s6 !== peg$FAILED) {
s7 = [];
s8 = peg$parseS();
while (s8 !== peg$FAILED) {
s7.push(s8);
s8 = peg$parseS();
}
if (s7 !== peg$FAILED) {
s6 = [s6, s7];
s5 = s6;
} else {
peg$currPos = s5;
s5 = peg$FAILED;
}
} else {
peg$currPos = s5;
s5 = peg$FAILED;
}
}
while (s5 !== peg$FAILED) {
s4.push(s5);
s5 = peg$currPos;
s6 = peg$parseCDO();
if (s6 !== peg$FAILED) {
s7 = [];
s8 = peg$parseS();
while (s8 !== peg$FAILED) {
s7.push(s8);
s8 = peg$parseS();
}
if (s7 !== peg$FAILED) {
s6 = [s6, s7];
s5 = s6;
} else {
peg$currPos = s5;
s5 = peg$FAILED;
}
} else {
peg$currPos = s5;
s5 = peg$FAILED;
}
if (s5 === peg$FAILED) {
s5 = peg$currPos;
s6 = peg$parseCDC();
if (s6 !== peg$FAILED) {
s7 = [];
s8 = peg$parseS();
while (s8 !== peg$FAILED) {
s7.push(s8);
s8 = peg$parseS();
}
if (s7 !== peg$FAILED) {
s6 = [s6, s7];
s5 = s6;
} else {
peg$currPos = s5;
s5 = peg$FAILED;
}
} else {
peg$currPos = s5;
s5 = peg$FAILED;
}
}
}
if (s4 !== peg$FAILED) {
s3 = [s3, s4];
s2 = s3;
} else {
peg$currPos = s2;
s2 = peg$FAILED;
}
} else {
peg$currPos = s2;
s2 = peg$FAILED;
}
while (s2 !== peg$FAILED) {
s1.push(s2);
s2 = peg$currPos;
s3 = peg$parsestubs();
if (s3 === peg$FAILED) {
s3 = peg$parseruleset();
if (s3 === peg$FAILED) {
s3 = peg$parsemedia();
if (s3 === peg$FAILED) {
s3 = peg$parsedeclare();
}
}
}
if (s3 !== peg$FAILED) {
s4 = [];
s5 = peg$currPos;
s6 = peg$parseCDO();
if (s6 !== peg$FAILED) {
s7 = [];
s8 = peg$parseS();
while (s8 !== peg$FAILED) {
s7.push(s8);
s8 = peg$parseS();
}
if (s7 !== peg$FAILED) {
s6 = [s6, s7];
s5 = s6;
} else {
peg$currPos = s5;
s5 = peg$FAILED;
}
} else {
peg$currPos = s5;
s5 = peg$FAILED;
}
if (s5 === peg$FAILED) {
s5 = peg$currPos;
s6 = peg$parseCDC();
if (s6 !== peg$FAILED) {
s7 = [];
s8 = peg$parseS();
while (s8 !== peg$FAILED) {
s7.push(s8);
s8 = peg$parseS();
}
if (s7 !== peg$FAILED) {
s6 = [s6, s7];
s5 = s6;
} else {
peg$currPos = s5;
s5 = peg$FAILED;
}
} else {
peg$currPos = s5;
s5 = peg$FAILED;
}
}
while (s5 !== peg$FAILED) {
s4.push(s5);
s5 = peg$currPos;
s6 = peg$parseCDO();
if (s6 !== peg$FAILED) {
s7 = [];
s8 = peg$parseS();
while (s8 !== peg$FAILED) {
s7.push(s8);
s8 = peg$parseS();
}
if (s7 !== peg$FAILED) {
s6 = [s6, s7];
s5 = s6;
} else {
peg$currPos = s5;
s5 = peg$FAILED;
}
} else {
peg$currPos = s5;
s5 = peg$FAILED;
}
if (s5 === peg$FAILED) {
s5 = peg$currPos;
s6 = peg$parseCDC();
if (s6 !== peg$FAILED) {
s7 = [];
s8 = peg$parseS();
while (s8 !== peg$FAILED) {
s7.push(s8);
s8 = peg$parseS();
}
if (s7 !== peg$FAILED) {
s6 = [s6, s7];
s5 = s6;
} else {
peg$currPos = s5;
s5 = peg$FAILED;
}
} else {
peg$currPos = s5;
s5 = peg$FAILED;
}
}
}
if (s4 !== peg$FAILED) {
s3 = [s3, s4];
s2 = s3;
} else {
peg$currPos = s2;
s2 = peg$FAILED;
}
} else {
peg$currPos = s2;
s2 = peg$FAILED;
}
}
if (s1 !== peg$FAILED) {
peg$savedPos = s0;
s1 = peg$c1(s1);
}
s0 = s1;
return s0;
}
function peg$parsedeclare() {
var s0, s1, s2, s3, s4, s5;
s0 = peg$currPos;
s1 = peg$parsedeclaration();
if (s1 !== peg$FAILED) {
s2 = [];
s3 = peg$parseS();
while (s3 !== peg$FAILED) {
s2.push(s3);
s3 = peg$parseS();
}
if (s2 !== peg$FAILED) {
if (input.charCodeAt(peg$currPos) === 59) {
s3 = peg$c2;
peg$currPos++;
} else {
s3 = peg$FAILED;
if (peg$silentFails === 0) {
peg$fail(peg$c3);
}
}
if (s3 === peg$FAILED) {
s3 = null;
}
if (s3 !== peg$FAILED) {
s4 = [];
s5 = peg$parseS();
while (s5 !== peg$FAILED) {
s4.push(s5);
s5 = peg$parseS();
}
if (s4 !== peg$FAILED) {
peg$savedPos = s0;
s1 = peg$c4(s1);
s0 = s1;
} else {
peg$currPos = s0;
s0 = peg$FAILED;
}
} else {
peg$currPos = s0;
s0 = peg$FAILED;
}
} else {
peg$currPos = s0;
s0 = peg$FAILED;
}
} else {
peg$currPos = s0;
s0 = peg$FAILED;
}
return s0;
}
function peg$parsemedia() {
var s0, s1, s2, s3, s4, s5, s6, s7, s8, s9;
s0 = peg$currPos;
s1 = peg$parseMEDIA_SYM();
if (s1 !== peg$FAILED) {
s2 = [];
s3 = peg$parseS();
while (s3 !== peg$FAILED) {
s2.push(s3);
s3 = peg$parseS();
}
if (s2 !== peg$FAILED) {
s3 = peg$parsemlist();
if (s3 !== peg$FAILED) {
if (input.charCodeAt(peg$currPos) === 123) {
s4 = peg$c5;
peg$currPos++;
} else {
s4 = peg$FAILED;
if (peg$silentFails === 0) {
peg$fail(peg$c6);
}
}
if (s4 !== peg$FAILED) {
s5 = [];
s6 = peg$parseS();
while (s6 !== peg$FAILED) {
s5.push(s6);
s6 = peg$parseS();
}
if (s5 !== peg$FAILED) {
s6 = [];
s7 = peg$parsestubs();
if (s7 === peg$FAILED) {
s7 = peg$parseruleset();
if (s7 === peg$FAILED) {
s7 = peg$parsedeclare();
}
}
while (s7 !== peg$FAILED) {
s6.push(s7);
s7 = peg$parsestubs();
if (s7 === peg$FAILED) {
s7 = peg$parseruleset();
if (s7 === peg$FAILED) {
s7 = peg$parsedeclare();
}
}
}
if (s6 !== peg$FAILED) {
if (input.charCodeAt(peg$currPos) === 125) {
s7 = peg$c7;
peg$currPos++;
} else {
s7 = peg$FAILED;
if (peg$silentFails === 0) {
peg$fail(peg$c8);
}
}
if (s7 !== peg$FAILED) {
s8 = [];
s9 = peg$parseS();
while (s9 !== peg$FAILED) {
s8.push(s9);
s9 = peg$parseS();
}
if (s8 !== peg$FAILED) {
peg$savedPos = s0;
s1 = peg$c9(s3, s6);
s0 = s1;
} else {
peg$currPos = s0;
s0 = peg$FAILED;
}
} else {
peg$currPos = s0;
s0 = peg$FAILED;
}
} else {
peg$currPos = s0;
s0 = peg$FAILED;
}
} else {
peg$currPos = s0;
s0 = peg$FAILED;
}
} else {
peg$currPos = s0;
s0 = peg$FAILED;
}
} else {
peg$currPos = s0;
s0 = peg$FAILED;
}
} else {
peg$currPos = s0;
s0 = peg$FAILED;
}
} else {
peg$currPos = s0;
s0 = peg$FAILED;
}
return s0;
}
function peg$parsemlist() {
var s0, s1, s2, s3, s4, s5, s6;
s0 = peg$currPos;
s1 = peg$parsemquery();
if (s1 !== peg$FAILED) {
s2 = [];
s3 = peg$currPos;
if (input.charCodeAt(peg$currPos) === 44) {
s4 = peg$c10;
peg$currPos++;
} else {
s4 = peg$FAILED;
if (peg$silentFails === 0) {
peg$fail(peg$c11);
}
}
if (s4 !== peg$FAILED) {
s5 = [];
s6 = peg$parseS();
while (s6 !== peg$FAILED) {
s5.push(s6);
s6 = peg$parseS();
}
if (s5 !== peg$FAILED) {
s6 = peg$parsemquery();
if (s6 !== peg$FAILED) {
s4 = [s4, s5, s6];
s3 = s4;
} else {
peg$currPos = s3;
s3 = peg$FAILED;
}
} else {
peg$currPos = s3;
s3 = peg$FAILED;
}
} else {
peg$currPos = s3;
s3 = peg$FAILED;
}
while (s3 !== peg$FAILED) {
s2.push(s3);
s3 = peg$currPos;
if (input.charCodeAt(peg$currPos) === 44) {
s4 = peg$c10;
peg$currPos++;
} else {
s4 = peg$FAILED;
if (peg$silentFails === 0) {
peg$fail(peg$c11);
}
}
if (s4 !== peg$FAILED) {
s5 = [];
s6 = peg$parseS();
while (s6 !== peg$FAILED) {
s5.push(s6);
s6 = peg$parseS();
}
if (s5 !== peg$FAILED) {
s6 = peg$parsemquery();
if (s6 !== peg$FAILED) {
s4 = [s4, s5, s6];
s3 = s4;
} else {
peg$currPos = s3;
s3 = peg$FAILED;
}
} else {
peg$currPos = s3;
s3 = peg$FAILED;
}
} else {
peg$currPos = s3;
s3 = peg$FAILED;
}
}
if (s2 !== peg$FAILED) {
peg$savedPos = s0;
s1 = peg$c12(s1, s2);
s0 = s1;
} else {
peg$currPos = s0;
s0 = peg$FAILED;
}
} else {
peg$currPos = s0;
s0 = peg$FAILED;
}
return s0;
}
function peg$parsemquery() {
var s0, s1, s2, s3, s4, s5, s6, s7, s8, s9, s10, s11;
s0 = peg$currPos;
if (input.substr(peg$currPos, 4) === peg$c13) {
s1 = peg$c13;
peg$currPos += 4;
} else {
s1 = peg$FAILED;
if (peg$silentFails === 0) {
peg$fail(peg$c14);
}
}
if (s1 === peg$FAILED) {
if (input.substr(peg$currPos, 3) === peg$c15) {
s1 = peg$c15;
peg$currPos += 3;
} else {
s1 = peg$FAILED;
if (peg$silentFails === 0) {
peg$fail(peg$c16);
}
}
}
if (s1 === peg$FAILED) {
s1 = null;
}
if (s1 !== peg$FAILED) {
s2 = [];
s3 = peg$parseS();
while (s3 !== peg$FAILED) {
s2.push(s3);
s3 = peg$parseS();
}
if (s2 !== peg$FAILED) {
s3 = peg$parsestub();
if (s3 === peg$FAILED) {
s3 = peg$parseproperty();
}
if (s3 !== peg$FAILED) {
s4 = [];
s5 = peg$parseS();
while (s5 !== peg$FAILED) {
s4.push(s5);
s5 = peg$parseS();
}
if (s4 !== peg$FAILED) {
s5 = [];
s6 = peg$currPos;
if (input.substr(peg$currPos, 3) === peg$c17) {
s7 = peg$c17;
peg$currPos += 3;
} else {
s7 = peg$FAILED;
if (peg$silentFails === 0) {
peg$fail(peg$c18);
}
}
if (s7 !== peg$FAILED) {
s8 = [];
s9 = peg$parseS();
while (s9 !== peg$FAILED) {
s8.push(s9);
s9 = peg$parseS();
}
if (s8 !== peg$FAILED) {
s9 = peg$parsestub();
if (s9 === peg$FAILED) {
s9 = peg$parsemexpr();
}
if (s9 !== peg$FAILED) {
s10 = [];
s11 = peg$parseS();
while (s11 !== peg$FAILED) {
s10.push(s11);
s11 = peg$parseS();
}
if (s10 !== peg$FAILED) {
peg$savedPos = s6;
s7 = peg$c19(s1, s3, s9);
s6 = s7;
} else {
peg$currPos = s6;
s6 = peg$FAILED;
}
} else {
peg$currPos = s6;
s6 = peg$FAILED;
}
} else {
peg$currPos = s6;
s6 = peg$FAILED;
}
} else {
peg$currPos = s6;
s6 = peg$FAILED;
}
while (s6 !== peg$FAILED) {
s5.push(s6);
s6 = peg$currPos;
if (input.substr(peg$currPos, 3) === peg$c17) {
s7 = peg$c17;
peg$currPos += 3;
} else {
s7 = peg$FAILED;
if (peg$silentFails === 0) {
peg$fail(peg$c18);
}
}
if (s7 !== peg$FAILED) {
s8 = [];
s9 = peg$parseS();
while (s9 !== peg$FAILED) {
s8.push(s9);
s9 = peg$parseS();
}
if (s8 !== peg$FAILED) {
s9 = peg$parsestub();
if (s9 === peg$FAILED) {
s9 = peg$parsemexpr();
}
if (s9 !== peg$FAILED) {
s10 = [];
s11 = peg$parseS();
while (s11 !== peg$FAILED) {
s10.push(s11);
s11 = peg$parseS();
}
if (s10 !== peg$FAILED) {
peg$savedPos = s6;
s7 = peg$c19(s1, s3, s9);
s6 = s7;
} else {
peg$currPos = s6;
s6 = peg$FAILED;
}
} else {
peg$currPos = s6;
s6 = peg$FAILED;
}
} else {
peg$currPos = s6;
s6 = peg$FAILED;
}
} else {
peg$currPos = s6;
s6 = peg$FAILED;
}
}
if (s5 !== peg$FAILED) {
peg$savedPos = s0;
s1 = peg$c20(s1, s3, s5);
s0 = s1;
} else {
peg$currPos = s0;
s0 = peg$FAILED;
}
} else {
peg$currPos = s0;
s0 = peg$FAILED;
}
} else {
peg$currPos = s0;
s0 = peg$FAILED;
}
} else {
peg$currPos = s0;
s0 = peg$FAILED;
}
} else {
peg$currPos = s0;
s0 = peg$FAILED;
}
if (s0 === peg$FAILED) {
s0 = peg$currPos;
s1 = peg$parsestub();
if (s1 === peg$FAILED) {
s1 = peg$parsemexpr();
}
if (s1 !== peg$FAILED) {
s2 = [];
s3 = peg$currPos;
if (input.substr(peg$currPos, 3) === peg$c17) {
s4 = peg$c17;
peg$currPos += 3;
} else {
s4 = peg$FAILED;
if (peg$silentFails === 0) {
peg$fail(peg$c18);
}
}
if (s4 !== peg$FAILED) {
s5 = [];
s6 = peg$parseS();
while (s6 !== peg$FAILED) {
s5.push(s6);
s6 = peg$parseS();
}
if (s5 !== peg$FAILED) {
s6 = peg$parsestub();
if (s6 === peg$FAILED) {
s6 = peg$parsemexpr();
}
if (s6 !== peg$FAILED) {
s7 = [];
s8 = peg$parseS();
while (s8 !== peg$FAILED) {
s7.push(s8);
s8 = peg$parseS();
}
if (s7 !== peg$FAILED) {
peg$savedPos = s3;
s4 = peg$c21(s1, s6);
s3 = s4;
} else {
peg$currPos = s3;
s3 = peg$FAILED;
}
} else {
peg$currPos = s3;
s3 = peg$FAILED;
}
} else {
peg$currPos = s3;
s3 = peg$FAILED;
}
} else {
peg$currPos = s3;
s3 = peg$FAILED;
}
while (s3 !== peg$FAILED) {
s2.push(s3);
s3 = peg$currPos;
if (input.substr(peg$currPos, 3) === peg$c17) {
s4 = peg$c17;
peg$currPos += 3;
} else {
s4 = peg$FAILED;
if (peg$silentFails === 0) {
peg$fail(peg$c18);
}
}
if (s4 !== peg$FAILED) {
s5 = [];
s6 = peg$parseS();
while (s6 !== peg$FAILED) {
s5.push(s6);
s6 = peg$parseS();
}
if (s5 !== peg$FAILED) {
s6 = peg$parsestub();
if (s6 === peg$FAILED) {
s6 = peg$parsemexpr();
}
if (s6 !== peg$FAILED) {
s7 = [];
s8 = peg$parseS();
while (s8 !== peg$FAILED) {
s7.push(s8);
s8 = peg$parseS();
}
if (s7 !== peg$FAILED) {
peg$savedPos = s3;
s4 = peg$c21(s1, s6);
s3 = s4;
} else {
peg$currPos = s3;
s3 = peg$FAILED;
}
} else {
peg$currPos = s3;
s3 = peg$FAILED;
}
} else {
peg$currPos = s3;
s3 = peg$FAILED;
}
} else {
peg$currPos = s3;
s3 = peg$FAILED;
}
}
if (s2 !== peg$FAILED) {
s3 = [];
s4 = peg$parseS();
while (s4 !== peg$FAILED) {
s3.push(s4);
s4 = peg$parseS();
}
if (s3 !== peg$FAILED) {
peg$savedPos = s0;
s1 = peg$c22(s1, s2);
s0 = s1;
} else {
peg$currPos = s0;
s0 = peg$FAILED;
}
} else {
peg$currPos = s0;
s0 = peg$FAILED;
}
} else {
peg$currPos = s0;
s0 = peg$FAILED;
}
}
return s0;
}
function peg$parsemexpr() {
var s0, s1, s2, s3, s4, s5, s6, s7, s8, s9;
s0 = peg$currPos;
if (input.charCodeAt(peg$currPos) === 40) {
s1 = peg$c23;
peg$currPos++;
} else {
s1 = peg$FAILED;
if (peg$silentFails === 0) {
peg$fail(peg$c24);
}
}
if (s1 !== peg$FAILED) {
s2 = [];
s3 = peg$parseS();
while (s3 !== peg$FAILED) {
s2.push(s3);
s3 = peg$parseS();
}
if (s2 !== peg$FAILED) {
s3 = peg$parseproperty();
if (s3 !== peg$FAILED) {
s4 = [];
s5 = peg$parseS();
while (s5 !== peg$FAILED) {
s4.push(s5);
s5 = peg$parseS();
}
if (s4 !== peg$FAILED) {
s5 = [];
s6 = peg$currPos;
if (input.charCodeAt(peg$currPos) === 58) {
s7 = peg$c25;
peg$currPos++;
} else {
s7 = peg$FAILED;
if (peg$silentFails === 0) {
peg$fail(peg$c26);
}
}
if (s7 === peg$FAILED) {
s7 = null;
}
if (s7 !== peg$FAILED) {
s8 = [];
s9 = peg$parseS();
while (s9 !== peg$FAILED) {
s8.push(s9);
s9 = peg$parseS();
}
if (s8 !== peg$FAILED) {
s9 = peg$parseterm();
if (s9 !== peg$FAILED) {
peg$savedPos = s6;
s7 = peg$c27(s3, s