dropflow
Version:
A small CSS2 document renderer built from specifications
1,443 lines (1,363 loc) • 390 kB
JavaScript
// Generated by Peggy 2.0.1.
//
// https://peggyjs.org/
import {initial, inherited} from './style.js';
function extractList(list, index) {
return list.map(function(element) { return element[index]; });
}
function buildList(head, tail, index) {
return [head].concat(extractList(tail, index))
.filter(function(element) { return element !== null; });
}
function buildExpression(head, tail) {
return tail.reduce(function(result, element) {
return {
type: 'Expression',
operator: element[0],
left: result,
right: element[1]
};
}, head);
}
function extend(a, b) {
for (var prop in b) {
a[prop] = b[prop];
}
return a;
}
function combine(a) {
return a.reduce(function(obj, next) {
return extend(obj, next);
}, {});
}
function setTopRightBottomLeft(obj, before, after, t, r, b, l) {
obj[before + 'Top' + (after || '')] = t;
obj[before + 'Right' + (after || '')] = r;
obj[before + 'Bottom' + (after || '')] = b;
obj[before + 'Left' + (after || '')] = l;
return obj;
}
function setTopRightBottomLeftOr(x, obj, before, after, t, r, b, l) {
if (!x) return setTopRightBottomLeft(obj, before, after, t, r, b, l);
x = x.toLowerCase();
if (x === '-top') obj[before + 'Top' + (after || '')] = t;
if (x === '-right') obj[before + 'Right' + (after || '')] = r;
if (x === '-bottom') obj[before + 'Bottom' + (after || '')] = b;
if (x === '-left') obj[before + 'Left' + (after || '')] = l;
return obj;
}
const colorMap = new Map([
['maroon', {r: 128, g: 0, b: 0, a: 1}],
['red', {r: 255, g: 0, b: 0, a: 1}],
['orange', {r: 255, g: 165, b: 0, a: 1}],
['yellow', {r: 255, g: 255, b: 0, a: 1}],
['veronicayellow', {r: 255, g: 225, b: 50, a: 1}],
['olive', {r: 128, g: 128, b: 0, a: 1}],
['purple', {r: 128, g: 0, b: 128, a: 1}],
['fuchsia', {r: 255, g: 0, b: 255, a: 1}],
['white', {r: 255, g: 255, b: 255, a: 1}],
['lime', {r: 0, g: 255, b: 0, a: 1}],
['green', {r: 0, g: 128, b: 0, a: 1}],
['navy', {r: 0, g: 0, b: 128, a: 1}],
['blue', {r: 0, g: 0, b: 255, a: 1}],
['aqua', {r: 0, g: 255, b: 255, a: 1}],
['teal', {r: 0, g: 128, b: 128, a: 1}],
['black', {r: 0, g: 0, b: 0, a: 1}],
['silver', {r: 192, g: 192, b: 192, a: 1}],
['gray', {r: 128, g: 128, b: 128, a: 1}],
['transparent', {r: 255, g: 255, b: 255, a: 0}]
]);
let $font = {}, $fontNormals = 0;
function peg$subclass(child, parent) {
function C() { this.constructor = child; }
C.prototype = parent.prototype;
child.prototype = new C();
}
function peg$SyntaxError(message, expected, found, location) {
var self = Error.call(this, message);
// istanbul ignore next Check is a necessary evil to support older environments
if (Object.setPrototypeOf) {
Object.setPrototypeOf(self, peg$SyntaxError.prototype);
}
self.expected = expected;
self.found = found;
self.location = location;
self.name = "SyntaxError";
return self;
}
peg$subclass(peg$SyntaxError, Error);
function peg$padEnd(str, targetLength, padString) {
padString = padString || " ";
if (str.length > targetLength) { return str; }
targetLength -= str.length;
padString += padString.repeat(targetLength);
return str + padString.slice(0, targetLength);
}
peg$SyntaxError.prototype.format = function(sources) {
var str = "Error: " + this.message;
if (this.location) {
var src = null;
var k;
for (k = 0; k < sources.length; k++) {
if (sources[k].source === this.location.source) {
src = sources[k].text.split(/\r\n|\n|\r/g);
break;
}
}
var s = this.location.start;
var loc = this.location.source + ":" + s.line + ":" + s.column;
if (src) {
var e = this.location.end;
var filler = peg$padEnd("", s.line.toString().length, ' ');
var line = src[s.line - 1];
var last = s.line === e.line ? e.column : line.length + 1;
var hatLen = (last - s.column) || 1;
str += "\n --> " + loc + "\n"
+ filler + " |\n"
+ s.line + " | " + line + "\n"
+ filler + " | " + peg$padEnd("", s.column - 1, ' ')
+ peg$padEnd("", hatLen, "^");
} else {
str += "\n at " + loc;
}
}
return str;
};
peg$SyntaxError.buildMessage = function(expected, found) {
var DESCRIBE_EXPECTATION_FNS = {
literal: function(expectation) {
return "\"" + literalEscape(expectation.text) + "\"";
},
class: function(expectation) {
var escapedParts = expectation.parts.map(function(part) {
return Array.isArray(part)
? classEscape(part[0]) + "-" + classEscape(part[1])
: classEscape(part);
});
return "[" + (expectation.inverted ? "^" : "") + escapedParts.join("") + "]";
},
any: function() {
return "any character";
},
end: function() {
return "end of input";
},
other: function(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 = expected.map(describeExpectation);
var i, j;
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 !== undefined ? options : {};
var peg$FAILED = {};
var peg$source = options.grammarSource;
var peg$startRuleFunctions = { start: peg$parsestart };
var peg$startRuleFunction = peg$parsestart;
var peg$c0 = ";";
var peg$c1 = ":";
var peg$c2 = "/";
var peg$c3 = ",";
var peg$c4 = ")";
var peg$c5 = "%";
var peg$c6 = "1";
var peg$c7 = "2";
var peg$c8 = "25";
var peg$c9 = ".";
var peg$c10 = "rgba(";
var peg$c11 = "rgb(";
var peg$c12 = "#";
var peg$c13 = "maroon";
var peg$c14 = "red";
var peg$c15 = "orange";
var peg$c16 = "yellow";
var peg$c17 = "veronicayellow";
var peg$c18 = "olive";
var peg$c19 = "purple";
var peg$c20 = "fuchsia";
var peg$c21 = "white";
var peg$c22 = "lime";
var peg$c23 = "green";
var peg$c24 = "navy";
var peg$c25 = "blue";
var peg$c26 = "aqua";
var peg$c27 = "teal";
var peg$c28 = "black";
var peg$c29 = "silver";
var peg$c30 = "gray";
var peg$c31 = "transparent";
var peg$c32 = "inherit";
var peg$c33 = "initial";
var peg$c34 = "xx-small";
var peg$c35 = "x-small";
var peg$c36 = "small";
var peg$c37 = "medium";
var peg$c38 = "large";
var peg$c39 = "x-large";
var peg$c40 = "xx-large";
var peg$c41 = "smaller";
var peg$c42 = "larger";
var peg$c43 = "normal";
var peg$c44 = "baseline";
var peg$c45 = "middle";
var peg$c46 = "sub";
var peg$c47 = "super";
var peg$c48 = "text-top";
var peg$c49 = "text-bottom";
var peg$c50 = "top";
var peg$c51 = "bottom";
var peg$c52 = "italic";
var peg$c53 = "oblique";
var peg$c54 = "bolder";
var peg$c55 = "lighter";
var peg$c56 = "bold";
var peg$c57 = "small-caps";
var peg$c58 = "ultra-condensed";
var peg$c59 = "extra-condensed";
var peg$c60 = "condensed";
var peg$c61 = "semi-condensed";
var peg$c62 = "semi-expanded";
var peg$c63 = "expanded";
var peg$c64 = "extra-expanded";
var peg$c65 = "ultra-expanded";
var peg$c66 = "ltr";
var peg$c67 = "rtl";
var peg$c68 = "block";
var peg$c69 = "inline-block";
var peg$c70 = "inline";
var peg$c71 = "flow-root";
var peg$c72 = "none";
var peg$c73 = "horizontal-tb";
var peg$c74 = "vertical-lr";
var peg$c75 = "vertical-rl";
var peg$c76 = "nowrap";
var peg$c77 = "pre-wrap";
var peg$c78 = "pre-line";
var peg$c79 = "pre";
var peg$c80 = "absolute";
var peg$c81 = "relative";
var peg$c82 = "static";
var peg$c83 = "auto";
var peg$c84 = "hidden";
var peg$c85 = "dotted";
var peg$c86 = "dashed";
var peg$c87 = "solid";
var peg$c88 = "double";
var peg$c89 = "groove";
var peg$c90 = "ridge";
var peg$c91 = "inset";
var peg$c92 = "outset";
var peg$c93 = "font-size";
var peg$c94 = "line-height";
var peg$c95 = "vertical-align";
var peg$c96 = "font-style";
var peg$c97 = "font-weight";
var peg$c98 = "font-variant";
var peg$c99 = "font-stretch";
var peg$c100 = "font-family";
var peg$c101 = "font";
var peg$c102 = "color";
var peg$c103 = "direction";
var peg$c104 = "display";
var peg$c105 = "writing-mode";
var peg$c106 = "white-space";
var peg$c107 = "tab-size";
var peg$c108 = "position";
var peg$c109 = "margin-top";
var peg$c110 = "margin-right";
var peg$c111 = "margin-bottom";
var peg$c112 = "margin-left";
var peg$c113 = "margin";
var peg$c114 = "padding-top";
var peg$c115 = "padding-right";
var peg$c116 = "padding-bottom";
var peg$c117 = "padding-left";
var peg$c118 = "padding";
var peg$c119 = "border-top-width";
var peg$c120 = "border-right-width";
var peg$c121 = "border-bottom-width";
var peg$c122 = "border-left-width";
var peg$c123 = "border-width";
var peg$c124 = "border-top-style";
var peg$c125 = "border-right-style";
var peg$c126 = "border-bottom-style";
var peg$c127 = "border-left-style";
var peg$c128 = "border-style";
var peg$c129 = "border-top-color";
var peg$c130 = "border-right-color";
var peg$c131 = "border-bottom-color";
var peg$c132 = "border-left-color";
var peg$c133 = "border-color";
var peg$c134 = "-top";
var peg$c135 = "-right";
var peg$c136 = "-bottom";
var peg$c137 = "-left";
var peg$c138 = "border";
var peg$c139 = "background-color";
var peg$c140 = "background-clip";
var peg$c141 = "border-box";
var peg$c142 = "content-box";
var peg$c143 = "padding-box";
var peg$c144 = "text-align";
var peg$c145 = "start";
var peg$c146 = "end";
var peg$c147 = "left";
var peg$c148 = "right";
var peg$c149 = "center";
var peg$c150 = "float";
var peg$c151 = "clear";
var peg$c152 = "both";
var peg$c153 = "z-index";
var peg$c154 = "word-break";
var peg$c155 = "break-word";
var peg$c156 = "overflow-wrap";
var peg$c157 = "word-wrap";
var peg$c158 = "anywhere";
var peg$c159 = "overflow";
var peg$c160 = "visible";
var peg$c161 = "zoom";
var peg$c162 = "width";
var peg$c163 = "height";
var peg$c164 = "box-sizing";
var peg$c165 = "\\";
var peg$c166 = "\r\n";
var peg$c167 = "\"";
var peg$c168 = "'";
var peg$c169 = "/*";
var peg$c170 = "*";
var peg$c171 = "-";
var peg$c172 = "e";
var peg$c173 = "\n";
var peg$c174 = "\r";
var peg$c175 = "\f";
var peg$c176 = "a";
var peg$c177 = "0";
var peg$c178 = "c";
var peg$c179 = "d";
var peg$c180 = "g";
var peg$c181 = "\\g";
var peg$c182 = "h";
var peg$c183 = "\\h";
var peg$c184 = "i";
var peg$c185 = "\\i";
var peg$c186 = "k";
var peg$c187 = "\\k";
var peg$c188 = "l";
var peg$c189 = "\\l";
var peg$c190 = "m";
var peg$c191 = "\\m";
var peg$c192 = "n";
var peg$c193 = "\\n";
var peg$c194 = "o";
var peg$c195 = "\\o";
var peg$c196 = "p";
var peg$c197 = "\\p";
var peg$c198 = "r";
var peg$c199 = "\\r";
var peg$c200 = "s";
var peg$c201 = "\\s";
var peg$c202 = "t";
var peg$c203 = "\\t";
var peg$c204 = "u";
var peg$c205 = "\\u";
var peg$c206 = "x";
var peg$c207 = "\\x";
var peg$c208 = "z";
var peg$c209 = "\\z";
var peg$c210 = "(";
var peg$r0 = /^[0-9]/;
var peg$r1 = /^[0-4]/;
var peg$r2 = /^[0-5]/;
var peg$r3 = /^[a-f0-9]/i;
var peg$r4 = /^[a-f0-9]/;
var peg$r5 = /^[0-9a-f]/i;
var peg$r6 = /^[\x80-\uFFFF]/;
var peg$r7 = /^[ \t\r\n\f]/;
var peg$r8 = /^[^\r\n\f0-9a-f]/i;
var peg$r9 = /^[_a-z]/i;
var peg$r10 = /^[_a-z0-9\-]/i;
var peg$r11 = /^[^\n\r\f\\"]/;
var peg$r12 = /^[^\n\r\f\\']/;
var peg$r13 = /^[^*]/;
var peg$r14 = /^[^\/*]/;
var peg$r15 = /^[+\-]/;
var peg$r16 = /^[!#$%&*-[\]-~]/;
var peg$r17 = /^[Aa]/;
var peg$r18 = /^[Cc]/;
var peg$r19 = /^[Dd]/;
var peg$r20 = /^[Ee]/;
var peg$r21 = /^[Gg]/;
var peg$r22 = /^[Hh]/;
var peg$r23 = /^[Ii]/;
var peg$r24 = /^[Kk]/;
var peg$r25 = /^[Ll]/;
var peg$r26 = /^[Mm]/;
var peg$r27 = /^[Nn]/;
var peg$r28 = /^[Oo]/;
var peg$r29 = /^[Pp]/;
var peg$r30 = /^[Rr]/;
var peg$r31 = /^[Ss]/;
var peg$r32 = /^[Tt]/;
var peg$r33 = /^[Uu]/;
var peg$r34 = /^[Xx]/;
var peg$r35 = /^[Zz]/;
var peg$e0 = peg$literalExpectation(";", false);
var peg$e1 = peg$literalExpectation(":", false);
var peg$e2 = peg$literalExpectation("/", false);
var peg$e3 = peg$literalExpectation(",", false);
var peg$e4 = peg$literalExpectation(")", false);
var peg$e5 = peg$classExpectation([["0", "9"]], false, false);
var peg$e6 = peg$literalExpectation("%", false);
var peg$e7 = peg$literalExpectation("1", false);
var peg$e8 = peg$literalExpectation("2", false);
var peg$e9 = peg$classExpectation([["0", "4"]], false, false);
var peg$e10 = peg$literalExpectation("25", false);
var peg$e11 = peg$classExpectation([["0", "5"]], false, false);
var peg$e12 = peg$literalExpectation(".", false);
var peg$e13 = peg$literalExpectation("rgba(", false);
var peg$e14 = peg$literalExpectation("rgb(", false);
var peg$e15 = peg$literalExpectation("#", false);
var peg$e16 = peg$classExpectation([["a", "f"], ["0", "9"]], false, true);
var peg$e17 = peg$classExpectation([["a", "f"], ["0", "9"]], false, false);
var peg$e18 = peg$literalExpectation("maroon", false);
var peg$e19 = peg$literalExpectation("red", false);
var peg$e20 = peg$literalExpectation("orange", false);
var peg$e21 = peg$literalExpectation("yellow", false);
var peg$e22 = peg$literalExpectation("veronicayellow", false);
var peg$e23 = peg$literalExpectation("olive", false);
var peg$e24 = peg$literalExpectation("purple", false);
var peg$e25 = peg$literalExpectation("fuchsia", false);
var peg$e26 = peg$literalExpectation("white", false);
var peg$e27 = peg$literalExpectation("lime", false);
var peg$e28 = peg$literalExpectation("green", false);
var peg$e29 = peg$literalExpectation("navy", false);
var peg$e30 = peg$literalExpectation("blue", false);
var peg$e31 = peg$literalExpectation("aqua", false);
var peg$e32 = peg$literalExpectation("teal", false);
var peg$e33 = peg$literalExpectation("black", false);
var peg$e34 = peg$literalExpectation("silver", false);
var peg$e35 = peg$literalExpectation("gray", false);
var peg$e36 = peg$literalExpectation("transparent", false);
var peg$e37 = peg$literalExpectation("inherit", false);
var peg$e38 = peg$literalExpectation("initial", false);
var peg$e39 = peg$literalExpectation("xx-small", false);
var peg$e40 = peg$literalExpectation("x-small", false);
var peg$e41 = peg$literalExpectation("small", false);
var peg$e42 = peg$literalExpectation("medium", false);
var peg$e43 = peg$literalExpectation("large", false);
var peg$e44 = peg$literalExpectation("x-large", false);
var peg$e45 = peg$literalExpectation("xx-large", false);
var peg$e46 = peg$literalExpectation("smaller", false);
var peg$e47 = peg$literalExpectation("larger", false);
var peg$e48 = peg$literalExpectation("normal", false);
var peg$e49 = peg$literalExpectation("baseline", false);
var peg$e50 = peg$literalExpectation("middle", false);
var peg$e51 = peg$literalExpectation("sub", false);
var peg$e52 = peg$literalExpectation("super", false);
var peg$e53 = peg$literalExpectation("text-top", false);
var peg$e54 = peg$literalExpectation("text-bottom", false);
var peg$e55 = peg$literalExpectation("top", false);
var peg$e56 = peg$literalExpectation("bottom", false);
var peg$e57 = peg$literalExpectation("italic", false);
var peg$e58 = peg$literalExpectation("oblique", false);
var peg$e59 = peg$literalExpectation("bolder", false);
var peg$e60 = peg$literalExpectation("lighter", false);
var peg$e61 = peg$literalExpectation("bold", false);
var peg$e62 = peg$literalExpectation("small-caps", false);
var peg$e63 = peg$literalExpectation("ultra-condensed", false);
var peg$e64 = peg$literalExpectation("extra-condensed", false);
var peg$e65 = peg$literalExpectation("condensed", false);
var peg$e66 = peg$literalExpectation("semi-condensed", false);
var peg$e67 = peg$literalExpectation("semi-expanded", false);
var peg$e68 = peg$literalExpectation("expanded", false);
var peg$e69 = peg$literalExpectation("extra-expanded", false);
var peg$e70 = peg$literalExpectation("ultra-expanded", false);
var peg$e71 = peg$literalExpectation("ltr", false);
var peg$e72 = peg$literalExpectation("rtl", false);
var peg$e73 = peg$literalExpectation("block", false);
var peg$e74 = peg$literalExpectation("inline-block", false);
var peg$e75 = peg$literalExpectation("inline", false);
var peg$e76 = peg$literalExpectation("flow-root", false);
var peg$e77 = peg$literalExpectation("none", false);
var peg$e78 = peg$literalExpectation("horizontal-tb", false);
var peg$e79 = peg$literalExpectation("vertical-lr", false);
var peg$e80 = peg$literalExpectation("vertical-rl", false);
var peg$e81 = peg$literalExpectation("nowrap", false);
var peg$e82 = peg$literalExpectation("pre-wrap", false);
var peg$e83 = peg$literalExpectation("pre-line", false);
var peg$e84 = peg$literalExpectation("pre", false);
var peg$e85 = peg$literalExpectation("absolute", false);
var peg$e86 = peg$literalExpectation("relative", false);
var peg$e87 = peg$literalExpectation("static", false);
var peg$e88 = peg$literalExpectation("auto", false);
var peg$e89 = peg$literalExpectation("hidden", false);
var peg$e90 = peg$literalExpectation("dotted", false);
var peg$e91 = peg$literalExpectation("dashed", false);
var peg$e92 = peg$literalExpectation("solid", false);
var peg$e93 = peg$literalExpectation("double", false);
var peg$e94 = peg$literalExpectation("groove", false);
var peg$e95 = peg$literalExpectation("ridge", false);
var peg$e96 = peg$literalExpectation("inset", false);
var peg$e97 = peg$literalExpectation("outset", false);
var peg$e98 = peg$literalExpectation("font-size", true);
var peg$e99 = peg$literalExpectation("line-height", true);
var peg$e100 = peg$literalExpectation("vertical-align", true);
var peg$e101 = peg$literalExpectation("font-style", true);
var peg$e102 = peg$literalExpectation("font-weight", true);
var peg$e103 = peg$literalExpectation("font-variant", true);
var peg$e104 = peg$literalExpectation("font-stretch", true);
var peg$e105 = peg$literalExpectation("font-family", true);
var peg$e106 = peg$literalExpectation("font", true);
var peg$e107 = peg$literalExpectation("color", true);
var peg$e108 = peg$literalExpectation("direction", true);
var peg$e109 = peg$literalExpectation("display", true);
var peg$e110 = peg$literalExpectation("writing-mode", true);
var peg$e111 = peg$literalExpectation("white-space", true);
var peg$e112 = peg$literalExpectation("tab-size", true);
var peg$e113 = peg$literalExpectation("position", true);
var peg$e114 = peg$literalExpectation("margin-top", true);
var peg$e115 = peg$literalExpectation("margin-right", true);
var peg$e116 = peg$literalExpectation("margin-bottom", true);
var peg$e117 = peg$literalExpectation("margin-left", true);
var peg$e118 = peg$literalExpectation("margin", true);
var peg$e119 = peg$literalExpectation("padding-top", true);
var peg$e120 = peg$literalExpectation("padding-right", true);
var peg$e121 = peg$literalExpectation("padding-bottom", true);
var peg$e122 = peg$literalExpectation("padding-left", true);
var peg$e123 = peg$literalExpectation("padding", true);
var peg$e124 = peg$literalExpectation("border-top-width", true);
var peg$e125 = peg$literalExpectation("border-right-width", true);
var peg$e126 = peg$literalExpectation("border-bottom-width", true);
var peg$e127 = peg$literalExpectation("border-left-width", true);
var peg$e128 = peg$literalExpectation("border-width", true);
var peg$e129 = peg$literalExpectation("border-top-style", true);
var peg$e130 = peg$literalExpectation("border-right-style", true);
var peg$e131 = peg$literalExpectation("border-bottom-style", true);
var peg$e132 = peg$literalExpectation("border-left-style", true);
var peg$e133 = peg$literalExpectation("border-style", true);
var peg$e134 = peg$literalExpectation("border-top-color", true);
var peg$e135 = peg$literalExpectation("border-right-color", true);
var peg$e136 = peg$literalExpectation("border-bottom-color", true);
var peg$e137 = peg$literalExpectation("border-left-color", true);
var peg$e138 = peg$literalExpectation("border-color", true);
var peg$e139 = peg$literalExpectation("-top", false);
var peg$e140 = peg$literalExpectation("-right", false);
var peg$e141 = peg$literalExpectation("-bottom", false);
var peg$e142 = peg$literalExpectation("-left", false);
var peg$e143 = peg$literalExpectation("border", true);
var peg$e144 = peg$literalExpectation("background-color", true);
var peg$e145 = peg$literalExpectation("background-clip", true);
var peg$e146 = peg$literalExpectation("border-box", false);
var peg$e147 = peg$literalExpectation("content-box", false);
var peg$e148 = peg$literalExpectation("padding-box", false);
var peg$e149 = peg$literalExpectation("text-align", true);
var peg$e150 = peg$literalExpectation("start", false);
var peg$e151 = peg$literalExpectation("end", false);
var peg$e152 = peg$literalExpectation("left", false);
var peg$e153 = peg$literalExpectation("right", false);
var peg$e154 = peg$literalExpectation("center", false);
var peg$e155 = peg$literalExpectation("float", true);
var peg$e156 = peg$literalExpectation("clear", true);
var peg$e157 = peg$literalExpectation("both", false);
var peg$e158 = peg$literalExpectation("z-index", true);
var peg$e159 = peg$literalExpectation("word-break", true);
var peg$e160 = peg$literalExpectation("break-word", false);
var peg$e161 = peg$literalExpectation("overflow-wrap", true);
var peg$e162 = peg$literalExpectation("word-wrap", true);
var peg$e163 = peg$literalExpectation("anywhere", false);
var peg$e164 = peg$literalExpectation("overflow", true);
var peg$e165 = peg$literalExpectation("visible", false);
var peg$e166 = peg$literalExpectation("zoom", true);
var peg$e167 = peg$literalExpectation("width", true);
var peg$e168 = peg$literalExpectation("height", true);
var peg$e169 = peg$literalExpectation("top", true);
var peg$e170 = peg$literalExpectation("right", true);
var peg$e171 = peg$literalExpectation("bottom", true);
var peg$e172 = peg$literalExpectation("left", true);
var peg$e173 = peg$literalExpectation("box-sizing", true);
var peg$e174 = peg$classExpectation([["0", "9"], ["a", "f"]], false, true);
var peg$e175 = peg$classExpectation([["\x80", "\uFFFF"]], false, false);
var peg$e176 = peg$literalExpectation("\\", false);
var peg$e177 = peg$literalExpectation("\r\n", false);
var peg$e178 = peg$classExpectation([" ", "\t", "\r", "\n", "\f"], false, false);
var peg$e179 = peg$classExpectation(["\r", "\n", "\f", ["0", "9"], ["a", "f"]], true, true);
var peg$e180 = peg$classExpectation(["_", ["a", "z"]], false, true);
var peg$e181 = peg$classExpectation(["_", ["a", "z"], ["0", "9"], "-"], false, true);
var peg$e182 = peg$literalExpectation("\"", false);
var peg$e183 = peg$classExpectation(["\n", "\r", "\f", "\\", "\""], true, false);
var peg$e184 = peg$literalExpectation("'", false);
var peg$e185 = peg$classExpectation(["\n", "\r", "\f", "\\", "'"], true, false);
var peg$e186 = peg$literalExpectation("/*", false);
var peg$e187 = peg$classExpectation(["*"], true, false);
var peg$e188 = peg$literalExpectation("*", false);
var peg$e189 = peg$classExpectation(["/", "*"], true, false);
var peg$e190 = peg$literalExpectation("-", false);
var peg$e191 = peg$classExpectation(["+", "-"], false, false);
var peg$e192 = peg$literalExpectation("e", false);
var peg$e193 = peg$classExpectation(["!", "#", "$", "%", "&", ["*", "["], ["]", "~"]], false, false);
var peg$e194 = peg$literalExpectation("\n", false);
var peg$e195 = peg$literalExpectation("\r", false);
var peg$e196 = peg$literalExpectation("\f", false);
var peg$e197 = peg$literalExpectation("a", true);
var peg$e198 = peg$literalExpectation("0", false);
var peg$e199 = peg$classExpectation(["A", "a"], false, false);
var peg$e200 = peg$literalExpectation("c", true);
var peg$e201 = peg$classExpectation(["C", "c"], false, false);
var peg$e202 = peg$literalExpectation("d", true);
var peg$e203 = peg$classExpectation(["D", "d"], false, false);
var peg$e204 = peg$literalExpectation("e", true);
var peg$e205 = peg$classExpectation(["E", "e"], false, false);
var peg$e206 = peg$literalExpectation("g", true);
var peg$e207 = peg$classExpectation(["G", "g"], false, false);
var peg$e208 = peg$literalExpectation("\\g", true);
var peg$e209 = peg$literalExpectation("h", true);
var peg$e210 = peg$classExpectation(["H", "h"], false, false);
var peg$e211 = peg$literalExpectation("\\h", true);
var peg$e212 = peg$literalExpectation("i", true);
var peg$e213 = peg$classExpectation(["I", "i"], false, false);
var peg$e214 = peg$literalExpectation("\\i", true);
var peg$e215 = peg$literalExpectation("k", true);
var peg$e216 = peg$classExpectation(["K", "k"], false, false);
var peg$e217 = peg$literalExpectation("\\k", true);
var peg$e218 = peg$literalExpectation("l", true);
var peg$e219 = peg$classExpectation(["L", "l"], false, false);
var peg$e220 = peg$literalExpectation("\\l", true);
var peg$e221 = peg$literalExpectation("m", true);
var peg$e222 = peg$classExpectation(["M", "m"], false, false);
var peg$e223 = peg$literalExpectation("\\m", true);
var peg$e224 = peg$literalExpectation("n", true);
var peg$e225 = peg$classExpectation(["N", "n"], false, false);
var peg$e226 = peg$literalExpectation("\\n", true);
var peg$e227 = peg$literalExpectation("o", true);
var peg$e228 = peg$classExpectation(["O", "o"], false, false);
var peg$e229 = peg$literalExpectation("\\o", true);
var peg$e230 = peg$literalExpectation("p", true);
var peg$e231 = peg$classExpectation(["P", "p"], false, false);
var peg$e232 = peg$literalExpectation("\\p", true);
var peg$e233 = peg$literalExpectation("r", true);
var peg$e234 = peg$classExpectation(["R", "r"], false, false);
var peg$e235 = peg$literalExpectation("\\r", true);
var peg$e236 = peg$literalExpectation("s", true);
var peg$e237 = peg$classExpectation(["S", "s"], false, false);
var peg$e238 = peg$literalExpectation("\\s", true);
var peg$e239 = peg$literalExpectation("t", true);
var peg$e240 = peg$classExpectation(["T", "t"], false, false);
var peg$e241 = peg$literalExpectation("\\t", true);
var peg$e242 = peg$literalExpectation("u", true);
var peg$e243 = peg$classExpectation(["U", "u"], false, false);
var peg$e244 = peg$literalExpectation("\\u", true);
var peg$e245 = peg$literalExpectation("x", true);
var peg$e246 = peg$classExpectation(["X", "x"], false, false);
var peg$e247 = peg$literalExpectation("\\x", true);
var peg$e248 = peg$literalExpectation("z", true);
var peg$e249 = peg$classExpectation(["Z", "z"], false, false);
var peg$e250 = peg$literalExpectation("\\z", true);
var peg$e251 = peg$otherExpectation("whitespace");
var peg$e252 = peg$otherExpectation("string");
var peg$e253 = peg$otherExpectation("identifier");
var peg$e254 = peg$otherExpectation("hash");
var peg$e255 = peg$otherExpectation("length");
var peg$e256 = peg$otherExpectation("angle");
var peg$e257 = peg$otherExpectation("time");
var peg$e258 = peg$otherExpectation("frequency");
var peg$e259 = peg$otherExpectation("percentage");
var peg$e260 = peg$otherExpectation("number");
var peg$e261 = peg$otherExpectation("uri");
var peg$e262 = peg$literalExpectation("(", true);
var peg$e263 = peg$otherExpectation("function");
var peg$e264 = peg$literalExpectation("(", false);
var peg$f0 = function(declarationsHead, declarationsTail) { return combine(buildList(declarationsHead, declarationsTail, 2)); };
var peg$f1 = function(name, value) {
let r = {};
r['_' + name] = value;
return r;
};
var peg$f2 = function(name) { return name; };
var peg$f3 = function(head, tail) { return buildExpression(head, tail); };
var peg$f4 = function() { return '/'; };
var peg$f5 = function() { return ','; };
var peg$f6 = function(quantity) {
return {
type: 'Quantity',
value: quantity.value,
unit: quantity.unit
};
};
var peg$f7 = function(value) { return { type: 'String', value: value }; };
var peg$f8 = function(value) { return { type: 'URI', value: value }; };
var peg$f9 = function(value) { return value; };
var peg$f10 = function(name, params) {
return { type: 'Function', name: name, params: params };
};
var peg$f11 = function(component) {
return Math.max(0, Math.min(100, parseInt(component, 10))) * 1e-2 * 255
};
var peg$f12 = function(component) {
return parseInt(Array.isArray(component) ? component.join('') : component, 10);
};
var peg$f13 = function(a) {
const component = a.join('');
return Math.max(0, Math.min(100, parseInt(component, 10))) * 1e-2
};
var peg$f14 = function(a, b, c) {
const component = (a ? a.join('') : '') + b + c.join('');
return Math.max(0, Math.min(1, parseFloat(component)));
};
var peg$f15 = function(a) {
return Math.max(0, Math.min(1, parseInt(a.join(''), 10)))
};
var peg$f16 = function(r, g, b, a) {
return {r, g, b, a};
};
var peg$f17 = function(r, g, b) {
return {r, g, b, a: 1};
};
var peg$f18 = function(r, g, b, a) {
return {
r: parseInt(r.join(''), 16),
g: parseInt(g.join(''), 16),
b: parseInt(b.join(''), 16),
a: a ? parseInt(a.join(''), 16) / 255 : 1
}
};
var peg$f19 = function(r, g, b, a) {
return {
r: parseInt(r + r, 16),
g: parseInt(g + g, 16),
b: parseInt(b + b, 16),
a: a ? parseInt(a + a, 16) / 255 : 1
}
};
var peg$f20 = function() {
return colorMap.get(text())
};
var peg$f21 = function() { return inherited; };
var peg$f22 = function() { return initial; };
var peg$f23 = function() { return 9 };
var peg$f24 = function() { return 10 };
var peg$f25 = function() { return 13 };
var peg$f26 = function() { return 16 };
var peg$f27 = function() { return 18 };
var peg$f28 = function() { return 24 };
var peg$f29 = function() { return 32 };
var peg$f30 = function() { return { value: 1/1.2, unit: 'em' } };
var peg$f31 = function() { return { value: 1.2, unit: 'em' } };
var peg$f32 = function(font_size) { return font_size; };
var peg$f33 = function(line_height) { return line_height; };
var peg$f34 = function(vertical_align) { return vertical_align; };
var peg$f35 = function() { return 400; };
var peg$f36 = function() { return 700; };
var peg$f37 = function() { return +text() >= 1 && +text() <= 1000 ? +text() : undefined; };
var peg$f38 = function(family) { return family; };
var peg$f39 = function(head, tail) { return buildList(head, tail, 1).join(' '); };
var peg$f40 = function(f1, fn) {
return [f1].concat(fn ? extractList(fn, 2) : []);
};
var peg$f41 = function(s) {
if ($font) {
if (s === 'normal') {
if (++$fontNormals > 4) $font = undefined;
} else {
if ('fontStyle' in $font) {
$font = undefined;
} else {
$font.fontStyle = s;
++$fontNormals;
}
}
}
};
var peg$f42 = function(s) {
if ($font) {
if (s === undefined || 'fontWeight' in $font) {
$font = undefined;
} else {
$font.fontWeight = s;
++$fontNormals;
}
}
};
var peg$f43 = function(s) {
if ($font) {
if ('fontVariant' in $font) {
$font = undefined;
} else {
$font.fontVariant = s;
++$fontNormals;
}
}
};
var peg$f44 = function(s) {
if ($font) {
if ('fontStretch' in $font) {
$font = undefined;
} else {
$font.fontStretch = s;
++$fontNormals;
}
}
};
var peg$f45 = function() {
const ret = $font;
$font = {};
$fontNormals = 0;
return ret;
};
var peg$f46 = function(x) {
if (x[0] === undefined) return;
const ret = Object.assign({
fontStyle: 'normal',
fontWeight: 400,
fontVariant: 'normal',
fontStretch: 'normal'
}, x[0]);
ret.fontSize = x[1];
ret.lineHeight = x[2][1] === '/' ? x[2][3] : 'normal';
ret.fontFamily = x[3];
return ret;
};
var peg$f47 = function() { return {outer: 'block', inner: 'flow'}; };
var peg$f48 = function() { return {outer: 'inline', inner: 'flow-root'}; };
var peg$f49 = function() { return {outer: 'inline', inner: 'flow'}; };
var peg$f50 = function() { return {outer: 'block', inner: 'flow-root'}; };
var peg$f51 = function() { return {outer: 'none', inner: 'none'}; };
var peg$f52 = function(fontSize) {
return {fontSize};
};
var peg$f53 = function(lineHeight) {
return {lineHeight};
};
var peg$f54 = function(verticalAlign) {
return {verticalAlign};
};
var peg$f55 = function(fontStyle) {
return {fontStyle};
};
var peg$f56 = function(fontWeight) {
return fontWeight && {fontWeight};
};
var peg$f57 = function(fontVariant) {
return {fontVariant};
};
var peg$f58 = function(fontStretch) {
return {fontStretch};
};
var peg$f59 = function(fontFamily) {
return {fontFamily};
};
var peg$f60 = function(font) {
return font && (typeof font === "object" ? font : {font});
};
var peg$f61 = function(color) {
return {color};
};
var peg$f62 = function(direction) {
return {direction};
};
var peg$f63 = function(display) {
return {display};
};
var peg$f64 = function(writingMode) {
return {writingMode};
};
var peg$f65 = function(whiteSpace) {
return {whiteSpace};
};
var peg$f66 = function(tabSize) {
return {tabSize};
};
var peg$f67 = function(position) {
return {position};
};
var peg$f68 = function(marginTop) {
return {marginTop};
};
var peg$f69 = function(marginRight) {
return {marginRight};
};
var peg$f70 = function(marginBottom) {
return {marginBottom};
};
var peg$f71 = function(marginLeft) {
return {marginLeft};
};
var peg$f72 = function(t, r, b, l) {
return setTopRightBottomLeft({}, 'margin', '', t, r, b, l);
};
var peg$f73 = function(t, h, b) {
return setTopRightBottomLeft({}, 'margin', '', t, h, b, h);
};
var peg$f74 = function(v, h) {
return setTopRightBottomLeft({}, 'margin', '', v, h, v, h);
};
var peg$f75 = function(s) {
return setTopRightBottomLeft({}, 'margin', '', s, s, s, s);
};
var peg$f76 = function(paddingTop) {
return {paddingTop};
};
var peg$f77 = function(paddingRight) {
return {paddingRight};
};
var peg$f78 = function(paddingBottom) {
return {paddingBottom};
};
var peg$f79 = function(paddingLeft) {
return {paddingLeft};
};
var peg$f80 = function(t, r, b, l) {
return setTopRightBottomLeft({}, 'padding', '', t, r, b, l);
};
var peg$f81 = function(t, h, b) {
return setTopRightBottomLeft({}, 'padding', '', t, h, b, h);
};
var peg$f82 = function(v, h) {
return setTopRightBottomLeft({}, 'padding', '', v, h, v, h);
};
var peg$f83 = function(s) {
return setTopRightBottomLeft({}, 'padding', '', s, s, s, s);
};
var peg$f84 = function(borderTopWidth) {
return {borderTopWidth};
};
var peg$f85 = function(borderRightWidth) {
return {borderRightWidth};
};
var peg$f86 = function(borderBottomWidth) {
return {borderBottomWidth};
};
var peg$f87 = function(borderLeftWidth) {
return {borderLeftWidth};
};
var peg$f88 = function(t, r, b, l) {
return setTopRightBottomLeft({}, 'border', 'Width', t, r, b, l);
};
var peg$f89 = function(t, h, b) {
return setTopRightBottomLeft({}, 'border', 'Width', t, h, b, h);
};
var peg$f90 = function(v, h) {
return setTopRightBottomLeft({}, 'border', 'Width', v, h, v, h);
};
var peg$f91 = function(s) {
return setTopRightBottomLeft({}, 'border', 'Width', s, s, s, s);
};
var peg$f92 = function(borderTopStyle) {
return {borderTopStyle};
};
var peg$f93 = function(borderRightStyle) {
return {borderRightStyle};
};
var peg$f94 = function(borderBottomStyle) {
return {borderBottomStyle};
};
var peg$f95 = function(borderLeftStyle) {
return {borderLeftStyle};
};
var peg$f96 = function(t, r, b, l) {
return setTopRightBottomLeft({}, 'border', 'Style', t, r, b, l);
};
var peg$f97 = function(t, h, b) {
return setTopRightBottomLeft({}, 'border', 'Style', t, h, b, h);
};
var peg$f98 = function(v, h) {
return setTopRightBottomLeft({}, 'border', 'Style', v, h, v, h);
};
var peg$f99 = function(s) {
return setTopRightBottomLeft({}, 'border', 'Style', s, s, s, s);
};
var peg$f100 = function(borderTopColor) {
return {borderTopColor};
};
var peg$f101 = function(borderRightColor) {
return {borderRightColor};
};
var peg$f102 = function(borderBottomColor) {
return {borderBottomColor};
};
var peg$f103 = function(borderLeftColor) {
return {borderLeftColor};
};
var peg$f104 = function(t, r, b, l) {
return setTopRightBottomLeft({}, 'border', 'Color', t, r, b, l);
};
var peg$f105 = function(t, h, b) {
return setTopRightBottomLeft({}, 'border', 'Color', t, h, b, h);
};
var peg$f106 = function(v, h) {
return setTopRightBottomLeft({}, 'border', 'Color', v, h, v, h);
};
var peg$f107 = function(s) {
return setTopRightBottomLeft({}, 'border', 'Color', s, s, s, s);
};
var peg$f108 = function(t, w, s, c) {
const ret = {};
setTopRightBottomLeftOr(t, ret, 'border', 'Width', w, w, w, w);
setTopRightBottomLeftOr(t, ret, 'border', 'Style', s, s, s, s);
if (c) setTopRightBottomLeftOr(t, ret, 'border', 'Color', c, c, c, c);
return ret;
};
var peg$f109 = function(t, s, w, c) {
const ret = {};
setTopRightBottomLeftOr(t, ret, 'border', 'Width', w, w, w, w);
setTopRightBottomLeftOr(t, ret, 'border', 'Style', s, s, s, s);
if (c) setTopRightBottomLeftOr(t, ret, 'border', 'Color', c, c, c, c);
return ret;
};
var peg$f110 = function(t, w, c, s) {
const ret = {};
setTopRightBottomLeftOr(t, ret, 'border', 'Width', w, w, w, w);
setTopRightBottomLeftOr(t, ret, 'border', 'Color', c, c, c, c);
if (s) setTopRightBottomLeftOr(t, ret, 'border', 'Style', s, s, s, s);
return ret;
};
var peg$f111 = function(t, c, w, s) {
const ret = {};
setTopRightBottomLeftOr(t, ret, 'border', 'Width', w, w, w, w);
setTopRightBottomLeftOr(t, ret, 'border', 'Color', c, c, c, c);
if (s) setTopRightBottomLeftOr(t, ret, 'border', 'Style', s, s, s, s);
return ret;
};
var peg$f112 = function(t, c, s, w) {
const ret = {};
setTopRightBottomLeftOr(t, ret, 'border', 'Color', c, c, c, c);
setTopRightBottomLeftOr(t, ret, 'border', 'Style', s, s, s, s);
if (w) setTopRightBottomLeftOr(t, ret, 'border', 'Width', w, w, w, w);
return ret;
};
var peg$f113 = function(t, s, c, w) {
const ret = {};
setTopRightBottomLeftOr(t, ret, 'border', 'Color', c, c, c, c);
setTopRightBottomLeftOr(t, ret, 'border', 'Style', s, s, s, s);
if (w) setTopRightBottomLeftOr(t, ret, 'border', 'Width', w, w, w, w);
return ret;
};
var peg$f114 = function(t, w) {
return setTopRightBottomLeftOr(t, {}, 'border', 'Width', w, w, w, w);
};
var peg$f115 = function(t, c) {
return setTopRightBottomLeftOr(t, {}, 'border', 'Color', c, c, c, c);
};
var peg$f116 = function(t, s) {
return setTopRightBottomLeftOr(t, {}, 'border', 'Style', s, s, s, s);
};
var peg$f117 = function(t, i) {
const ret = setTopRightBottomLeftOr(t, {}, 'border', 'Style', i, i, i, i);
setTopRightBottomLeftOr(t, ret, 'border', 'Width', i, i, i, i);
setTopRightBottomLeftOr(t, ret, 'border', 'Color', i, i, i, i);
return ret;
};
var peg$f118 = function(backgroundColor) {
return {backgroundColor};
};
var peg$f119 = function(backgroundClip) {
return {backgroundClip};
};
var peg$f120 = function(textAlign) {
return {textAlign};
};
var peg$f121 = function(float) {
return {float};
};
var peg$f122 = function(clear) {
return {clear};
};
var peg$f123 = function(zIndex) {
return {zIndex};
};
var peg$f124 = function(wordBreak) {
return {wordBreak};
};
var peg$f125 = function(overflowWrap) {
return {overflowWrap};
};
var peg$f126 = function(overflow) {
return {overflow};
};
var peg$f127 = function(zoom) {
return {zoom};
};
var peg$f128 = function(width) {
return {width};
};
var peg$f129 = function(height) {
return {height};
};
var peg$f130 = function(top) {
return {top};
};
var peg$f131 = function(right) {
return {right};
};
var peg$f132 = function(bottom) {
return {bottom};
};
var peg$f133 = function(left) {
return {left};
};
var peg$f134 = function(boxSizing) {
return {boxSizing};
};
var peg$f135 = function(digits) {
return String.fromCharCode(parseInt(digits, 16));
};
var peg$f136 = function(ch) { return ch; };
var peg$f137 = function(nl) { return ''; };
var peg$f138 = function(chars) {
return chars.join('');
};
var peg$f139 = function(nl) { return ''; };
var peg$f140 = function(chars) {
return chars.join('');
};
var peg$f141 = function(prefix, start, chars) {
return prefix + start + chars.join('');
};
var peg$f142 = function(chars) { return chars.join(''); };
var peg$f143 = function() {
return parseFloat(text());
};
var peg$f144 = function(chars) { return chars.join(''); };
var peg$f145 = function() { return 'a'; };
var peg$f146 = function() { return 'c'; };
var peg$f147 = function() { return 'd'; };
var peg$f148 = function() { return 'e'; };
var peg$f149 = function() { return 'g'; };
var peg$f150 = function() { return 'h'; };
var peg$f151 = function() { return 'i'; };
var peg$f152 = function() { return 'k'; };
var peg$f153 = function() { return 'l'; };
var peg$f154 = function() { return 'm'; };
var peg$f155 = function() { return 'n'; };
var peg$f156 = function() { return 'o'; };
var peg$f157 = function() { return 'p'; };
var peg$f158 = function() { return 'r'; };
var peg$f159 = function() { return 's'; };
var peg$f160 = function() { return 't'; };
var peg$f161 = function() { return 'u'; };
var peg$f162 = function() { return 'x'; };
var peg$f163 = function() { return 'z'; };
var peg$f164 = function(string) { return string; };
var peg$f165 = function(ident) { return ident; };
var peg$f166 = function(name) { return '#' + name; };
var peg$f167 = function(value) { return { value: value, unit: 'ex' }; };
var peg$f168 = function(value) { return value; };
var peg$f169 = function(value) { return { value: value, unit: 'cm' }; };
var peg$f170 = function(value) { return { value: value, unit: 'mm' }; };
var peg$f171 = function(value) { return { value: value, unit: 'in' }; };
var peg$f172 = function(value) { return { value: value, unit: 'pt' }; };
var peg$f173 = function(value) { return { value: value, unit: 'pc' }; };
var peg$f174 = function(value) { return { value: value, unit: 'em' }; };
var peg$f175 = function() { return 0; };
var peg$f176 = function(value) { return { value: value, unit: 'deg' }; };
var peg$f177 = function(value) { return { value: value, unit: 'rad' }; };
var peg$f178 = function(value) { return { value: value, unit: 'grad' }; };
var peg$f179 = function(value) { return { value: value, unit: 'ms' }; };
var peg$f180 = function(value) { return { value: value, unit: 's' }; };
var peg$f181 = function(value) { return { value: value, unit: 'hz' }; };
var peg$f182 = function(value) { return { value: value, unit: 'kh' }; };
var peg$f183 = function(value) { return { value: value, unit: '%' }; };
var peg$f184 = function(value) { return value; };
var peg$f185 = function(value) { return { value: value, unit: null }; };
var peg$f186 = function(url) { return url; };
var peg$f187 = function(url) { return url; };
var peg$f188 = function(name) { return name; };
var peg$currPos = 0;
var peg$savedPos = 0;
var peg$posDetailsCache = [{ line: 1, column: 1 }];
var peg$maxFailPos = 0;
var peg$maxFailExpected = [];
var peg$silentFails = 0;
var 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 offset() {
return peg$savedPos;
}
function range() {
return {
source: peg$source,
start: peg$savedPos,
end: peg$currPos
};
}
function location() {
return peg$computeLocation(peg$savedPos, peg$currPos);
}
function expected(description, location) {
location = location !== undefined
? 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 !== undefined
? 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];
var 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);
var endPosDetails = peg$computePosDetails(endPos);
return {
source: peg$source,
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, s6, s7;
s0 = peg$currPos;
s1 = [];
s2 = peg$parseS();
while (s2 !== peg$FAILED) {
s1.push(s2);
s2 = peg$parseS();
}
s2 = peg$parsedeclaration();
if (s2 === peg$FAILED) {
s2 = null;
}
s3 = [];
s4 = peg$currPos;
if (input.charCodeAt(peg$currPos) === 59) {
s5 = peg$c0;
peg$currPos++;
} else {