parser.js 71 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819820821822823824825826827828829830831832833834835836837838839840841842843844845846847848849850851852853854855856857858859860861862863864865866867868869870871872873874875876877878879880881882883884885886887888889890891892893894895896897898899900901902903904905906907908909910911912913914915916917918919920921922923924925926927928929930931932933934935936937938939940941942943944945946947948949950951952953954955956957958959960961962963964965966967968969970971972973974975976977978979980981982983984985986987988989990991992993994995996997998999100010011002100310041005100610071008100910101011101210131014101510161017101810191020102110221023102410251026102710281029103010311032103310341035103610371038103910401041104210431044104510461047104810491050105110521053105410551056105710581059106010611062106310641065106610671068106910701071107210731074107510761077107810791080108110821083108410851086108710881089109010911092109310941095109610971098109911001101110211031104110511061107110811091110111111121113111411151116111711181119112011211122112311241125112611271128112911301131113211331134113511361137113811391140114111421143114411451146114711481149115011511152115311541155115611571158115911601161116211631164116511661167116811691170117111721173117411751176117711781179118011811182118311841185118611871188118911901191119211931194119511961197119811991200120112021203120412051206120712081209121012111212121312141215121612171218121912201221122212231224122512261227122812291230123112321233123412351236123712381239124012411242124312441245124612471248124912501251125212531254125512561257125812591260126112621263126412651266126712681269127012711272127312741275127612771278127912801281128212831284128512861287128812891290129112921293129412951296129712981299130013011302130313041305130613071308130913101311131213131314131513161317131813191320132113221323132413251326132713281329133013311332133313341335133613371338133913401341134213431344134513461347134813491350135113521353135413551356135713581359136013611362136313641365136613671368136913701371137213731374137513761377137813791380138113821383138413851386138713881389139013911392139313941395139613971398139914001401140214031404140514061407140814091410141114121413141414151416141714181419142014211422142314241425142614271428142914301431143214331434143514361437143814391440144114421443144414451446144714481449145014511452145314541455145614571458145914601461146214631464146514661467146814691470147114721473147414751476147714781479148014811482148314841485148614871488148914901491149214931494149514961497149814991500150115021503150415051506150715081509151015111512151315141515151615171518151915201521152215231524152515261527152815291530153115321533153415351536153715381539154015411542154315441545154615471548154915501551155215531554155515561557155815591560156115621563156415651566156715681569157015711572157315741575157615771578157915801581158215831584158515861587158815891590159115921593159415951596159715981599160016011602160316041605160616071608160916101611161216131614161516161617161816191620162116221623162416251626162716281629163016311632163316341635163616371638163916401641164216431644164516461647164816491650165116521653165416551656165716581659166016611662166316641665166616671668166916701671167216731674167516761677167816791680168116821683168416851686168716881689169016911692169316941695169616971698169917001701170217031704170517061707170817091710171117121713171417151716171717181719172017211722172317241725172617271728172917301731173217331734173517361737173817391740174117421743174417451746174717481749175017511752175317541755175617571758175917601761176217631764176517661767176817691770177117721773177417751776177717781779178017811782178317841785178617871788178917901791179217931794179517961797179817991800180118021803180418051806180718081809181018111812181318141815181618171818181918201821182218231824182518261827182818291830183118321833183418351836183718381839184018411842184318441845184618471848184918501851185218531854185518561857185818591860186118621863186418651866186718681869187018711872187318741875187618771878187918801881188218831884188518861887188818891890189118921893189418951896189718981899190019011902190319041905190619071908190919101911191219131914191519161917191819191920192119221923192419251926192719281929193019311932193319341935193619371938193919401941194219431944194519461947194819491950195119521953195419551956195719581959196019611962196319641965196619671968196919701971197219731974197519761977197819791980198119821983198419851986198719881989199019911992199319941995199619971998199920002001200220032004200520062007200820092010201120122013201420152016201720182019202020212022202320242025202620272028202920302031203220332034203520362037203820392040204120422043204420452046204720482049205020512052205320542055205620572058205920602061206220632064206520662067206820692070207120722073207420752076207720782079208020812082208320842085208620872088208920902091209220932094209520962097209820992100210121022103210421052106210721082109211021112112211321142115211621172118211921202121212221232124212521262127212821292130213121322133213421352136213721382139214021412142214321442145214621472148214921502151215221532154215521562157215821592160216121622163216421652166216721682169217021712172217321742175217621772178217921802181218221832184218521862187218821892190219121922193219421952196219721982199220022012202220322042205220622072208220922102211221222132214221522162217221822192220222122222223222422252226222722282229223022312232223322342235223622372238223922402241224222432244224522462247224822492250225122522253225422552256225722582259226022612262226322642265226622672268226922702271227222732274227522762277227822792280228122822283228422852286228722882289229022912292229322942295229622972298229923002301230223032304230523062307230823092310231123122313231423152316231723182319232023212322232323242325232623272328232923302331233223332334233523362337233823392340234123422343234423452346234723482349235023512352235323542355235623572358235923602361236223632364236523662367236823692370237123722373237423752376237723782379238023812382238323842385238623872388238923902391239223932394239523962397239823992400240124022403240424052406240724082409241024112412241324142415241624172418241924202421242224232424242524262427242824292430243124322433243424352436243724382439244024412442244324442445244624472448244924502451245224532454245524562457245824592460246124622463246424652466246724682469247024712472247324742475247624772478247924802481248224832484248524862487248824892490249124922493249424952496249724982499250025012502250325042505250625072508250925102511251225132514251525162517251825192520252125222523252425252526252725282529253025312532253325342535253625372538253925402541254225432544254525462547254825492550255125522553255425552556255725582559256025612562256325642565256625672568256925702571257225732574257525762577257825792580258125822583258425852586258725882589259025912592259325942595259625972598259926002601260226032604260526062607260826092610261126122613261426152616261726182619262026212622262326242625262626272628262926302631263226332634263526362637263826392640264126422643264426452646264726482649265026512652265326542655265626572658265926602661266226632664266526662667266826692670267126722673267426752676267726782679268026812682268326842685268626872688268926902691269226932694
  1. /*
  2. * Generated by PEG.js 0.10.0.
  3. *
  4. * http://pegjs.org/
  5. */
  6. (function(root, factory) {
  7. if (typeof define === "function" && define.amd) {
  8. define([], factory);
  9. } else if (typeof module === "object" && module.exports) {
  10. module.exports = factory();
  11. }
  12. })(this, function() {
  13. "use strict";
  14. function peg$subclass(child, parent) {
  15. function ctor() { this.constructor = child; }
  16. ctor.prototype = parent.prototype;
  17. child.prototype = new ctor();
  18. }
  19. function peg$SyntaxError(message, expected, found, location) {
  20. this.message = message;
  21. this.expected = expected;
  22. this.found = found;
  23. this.location = location;
  24. this.name = "SyntaxError";
  25. if (typeof Error.captureStackTrace === "function") {
  26. Error.captureStackTrace(this, peg$SyntaxError);
  27. }
  28. }
  29. peg$subclass(peg$SyntaxError, Error);
  30. peg$SyntaxError.buildMessage = function(expected, found) {
  31. var DESCRIBE_EXPECTATION_FNS = {
  32. literal: function(expectation) {
  33. return "\"" + literalEscape(expectation.text) + "\"";
  34. },
  35. "class": function(expectation) {
  36. var escapedParts = "",
  37. i;
  38. for (i = 0; i < expectation.parts.length; i++) {
  39. escapedParts += expectation.parts[i] instanceof Array
  40. ? classEscape(expectation.parts[i][0]) + "-" + classEscape(expectation.parts[i][1])
  41. : classEscape(expectation.parts[i]);
  42. }
  43. return "[" + (expectation.inverted ? "^" : "") + escapedParts + "]";
  44. },
  45. any: function(expectation) {
  46. return "any character";
  47. },
  48. end: function(expectation) {
  49. return "end of input";
  50. },
  51. other: function(expectation) {
  52. return expectation.description;
  53. }
  54. };
  55. function hex(ch) {
  56. return ch.charCodeAt(0).toString(16).toUpperCase();
  57. }
  58. function literalEscape(s) {
  59. return s
  60. .replace(/\\/g, '\\\\')
  61. .replace(/"/g, '\\"')
  62. .replace(/\0/g, '\\0')
  63. .replace(/\t/g, '\\t')
  64. .replace(/\n/g, '\\n')
  65. .replace(/\r/g, '\\r')
  66. .replace(/[\x00-\x0F]/g, function(ch) { return '\\x0' + hex(ch); })
  67. .replace(/[\x10-\x1F\x7F-\x9F]/g, function(ch) { return '\\x' + hex(ch); });
  68. }
  69. function classEscape(s) {
  70. return s
  71. .replace(/\\/g, '\\\\')
  72. .replace(/\]/g, '\\]')
  73. .replace(/\^/g, '\\^')
  74. .replace(/-/g, '\\-')
  75. .replace(/\0/g, '\\0')
  76. .replace(/\t/g, '\\t')
  77. .replace(/\n/g, '\\n')
  78. .replace(/\r/g, '\\r')
  79. .replace(/[\x00-\x0F]/g, function(ch) { return '\\x0' + hex(ch); })
  80. .replace(/[\x10-\x1F\x7F-\x9F]/g, function(ch) { return '\\x' + hex(ch); });
  81. }
  82. function describeExpectation(expectation) {
  83. return DESCRIBE_EXPECTATION_FNS[expectation.type](expectation);
  84. }
  85. function describeExpected(expected) {
  86. var descriptions = new Array(expected.length),
  87. i, j;
  88. for (i = 0; i < expected.length; i++) {
  89. descriptions[i] = describeExpectation(expected[i]);
  90. }
  91. descriptions.sort();
  92. if (descriptions.length > 0) {
  93. for (i = 1, j = 1; i < descriptions.length; i++) {
  94. if (descriptions[i - 1] !== descriptions[i]) {
  95. descriptions[j] = descriptions[i];
  96. j++;
  97. }
  98. }
  99. descriptions.length = j;
  100. }
  101. switch (descriptions.length) {
  102. case 1:
  103. return descriptions[0];
  104. case 2:
  105. return descriptions[0] + " or " + descriptions[1];
  106. default:
  107. return descriptions.slice(0, -1).join(", ")
  108. + ", or "
  109. + descriptions[descriptions.length - 1];
  110. }
  111. }
  112. function describeFound(found) {
  113. return found ? "\"" + literalEscape(found) + "\"" : "end of input";
  114. }
  115. return "Expected " + describeExpected(expected) + " but " + describeFound(found) + " found.";
  116. };
  117. function peg$parse(input, options) {
  118. options = options !== void 0 ? options : {};
  119. var peg$FAILED = {},
  120. peg$startRuleFunctions = { start: peg$parsestart },
  121. peg$startRuleFunction = peg$parsestart,
  122. peg$c0 = function(ss) {
  123. return ss.length === 1 ? ss[0] : { type: 'matches', selectors: ss };
  124. },
  125. peg$c1 = function() { return void 0; },
  126. peg$c2 = " ",
  127. peg$c3 = peg$literalExpectation(" ", false),
  128. peg$c4 = /^[^ [\],():#!=><~+.]/,
  129. peg$c5 = peg$classExpectation([" ", "[", "]", ",", "(", ")", ":", "#", "!", "=", ">", "<", "~", "+", "."], true, false),
  130. peg$c6 = function(i) { return i.join(''); },
  131. peg$c7 = ">",
  132. peg$c8 = peg$literalExpectation(">", false),
  133. peg$c9 = function() { return 'child'; },
  134. peg$c10 = "~",
  135. peg$c11 = peg$literalExpectation("~", false),
  136. peg$c12 = function() { return 'sibling'; },
  137. peg$c13 = "+",
  138. peg$c14 = peg$literalExpectation("+", false),
  139. peg$c15 = function() { return 'adjacent'; },
  140. peg$c16 = function() { return 'descendant'; },
  141. peg$c17 = ",",
  142. peg$c18 = peg$literalExpectation(",", false),
  143. peg$c19 = function(s, ss) {
  144. return [s].concat(ss.map(function (s) { return s[3]; }));
  145. },
  146. peg$c20 = function(op, s) {
  147. if (!op) return s;
  148. return { type: op, left: { type: 'exactNode' }, right: s };
  149. },
  150. peg$c21 = function(a, ops) {
  151. return ops.reduce(function (memo, rhs) {
  152. return { type: rhs[0], left: memo, right: rhs[1] };
  153. }, a);
  154. },
  155. peg$c22 = "!",
  156. peg$c23 = peg$literalExpectation("!", false),
  157. peg$c24 = function(subject, as) {
  158. const b = as.length === 1 ? as[0] : { type: 'compound', selectors: as };
  159. if(subject) b.subject = true;
  160. return b;
  161. },
  162. peg$c25 = "*",
  163. peg$c26 = peg$literalExpectation("*", false),
  164. peg$c27 = function(a) { return { type: 'wildcard', value: a }; },
  165. peg$c28 = "#",
  166. peg$c29 = peg$literalExpectation("#", false),
  167. peg$c30 = function(i) { return { type: 'identifier', value: i }; },
  168. peg$c31 = "[",
  169. peg$c32 = peg$literalExpectation("[", false),
  170. peg$c33 = "]",
  171. peg$c34 = peg$literalExpectation("]", false),
  172. peg$c35 = function(v) { return v; },
  173. peg$c36 = /^[><!]/,
  174. peg$c37 = peg$classExpectation([">", "<", "!"], false, false),
  175. peg$c38 = "=",
  176. peg$c39 = peg$literalExpectation("=", false),
  177. peg$c40 = function(a) { return (a || '') + '='; },
  178. peg$c41 = /^[><]/,
  179. peg$c42 = peg$classExpectation([">", "<"], false, false),
  180. peg$c43 = ".",
  181. peg$c44 = peg$literalExpectation(".", false),
  182. peg$c45 = function(a, as) {
  183. return [].concat.apply([a], as).join('');
  184. },
  185. peg$c46 = function(name, op, value) {
  186. return { type: 'attribute', name: name, operator: op, value: value };
  187. },
  188. peg$c47 = function(name) { return { type: 'attribute', name: name }; },
  189. peg$c48 = "\"",
  190. peg$c49 = peg$literalExpectation("\"", false),
  191. peg$c50 = /^[^\\"]/,
  192. peg$c51 = peg$classExpectation(["\\", "\""], true, false),
  193. peg$c52 = "\\",
  194. peg$c53 = peg$literalExpectation("\\", false),
  195. peg$c54 = peg$anyExpectation(),
  196. peg$c55 = function(a, b) { return a + b; },
  197. peg$c56 = function(d) {
  198. return { type: 'literal', value: strUnescape(d.join('')) };
  199. },
  200. peg$c57 = "'",
  201. peg$c58 = peg$literalExpectation("'", false),
  202. peg$c59 = /^[^\\']/,
  203. peg$c60 = peg$classExpectation(["\\", "'"], true, false),
  204. peg$c61 = /^[0-9]/,
  205. peg$c62 = peg$classExpectation([["0", "9"]], false, false),
  206. peg$c63 = function(a, b) {
  207. // Can use `a.flat().join('')` once supported
  208. const leadingDecimals = a ? [].concat.apply([], a).join('') : '';
  209. return { type: 'literal', value: parseFloat(leadingDecimals + b.join('')) };
  210. },
  211. peg$c64 = function(i) { return { type: 'literal', value: i }; },
  212. peg$c65 = "type(",
  213. peg$c66 = peg$literalExpectation("type(", false),
  214. peg$c67 = /^[^ )]/,
  215. peg$c68 = peg$classExpectation([" ", ")"], true, false),
  216. peg$c69 = ")",
  217. peg$c70 = peg$literalExpectation(")", false),
  218. peg$c71 = function(t) { return { type: 'type', value: t.join('') }; },
  219. peg$c72 = /^[imsu]/,
  220. peg$c73 = peg$classExpectation(["i", "m", "s", "u"], false, false),
  221. peg$c74 = "/",
  222. peg$c75 = peg$literalExpectation("/", false),
  223. peg$c76 = /^[^\/]/,
  224. peg$c77 = peg$classExpectation(["/"], true, false),
  225. peg$c78 = function(d, flgs) { return {
  226. type: 'regexp', value: new RegExp(d.join(''), flgs ? flgs.join('') : '') };
  227. },
  228. peg$c79 = function(i, is) {
  229. return { type: 'field', name: is.reduce(function(memo, p){ return memo + p[0] + p[1]; }, i)};
  230. },
  231. peg$c80 = ":not(",
  232. peg$c81 = peg$literalExpectation(":not(", false),
  233. peg$c82 = function(ss) { return { type: 'not', selectors: ss }; },
  234. peg$c83 = ":matches(",
  235. peg$c84 = peg$literalExpectation(":matches(", false),
  236. peg$c85 = function(ss) { return { type: 'matches', selectors: ss }; },
  237. peg$c86 = ":has(",
  238. peg$c87 = peg$literalExpectation(":has(", false),
  239. peg$c88 = function(ss) { return { type: 'has', selectors: ss }; },
  240. peg$c89 = ":first-child",
  241. peg$c90 = peg$literalExpectation(":first-child", false),
  242. peg$c91 = function() { return nth(1); },
  243. peg$c92 = ":last-child",
  244. peg$c93 = peg$literalExpectation(":last-child", false),
  245. peg$c94 = function() { return nthLast(1); },
  246. peg$c95 = ":nth-child(",
  247. peg$c96 = peg$literalExpectation(":nth-child(", false),
  248. peg$c97 = function(n) { return nth(parseInt(n.join(''), 10)); },
  249. peg$c98 = ":nth-last-child(",
  250. peg$c99 = peg$literalExpectation(":nth-last-child(", false),
  251. peg$c100 = function(n) { return nthLast(parseInt(n.join(''), 10)); },
  252. peg$c101 = ":",
  253. peg$c102 = peg$literalExpectation(":", false),
  254. peg$c103 = function(c) {
  255. return { type: 'class', name: c };
  256. },
  257. peg$currPos = 0,
  258. peg$savedPos = 0,
  259. peg$posDetailsCache = [{ line: 1, column: 1 }],
  260. peg$maxFailPos = 0,
  261. peg$maxFailExpected = [],
  262. peg$silentFails = 0,
  263. peg$resultsCache = {},
  264. peg$result;
  265. if ("startRule" in options) {
  266. if (!(options.startRule in peg$startRuleFunctions)) {
  267. throw new Error("Can't start parsing from rule \"" + options.startRule + "\".");
  268. }
  269. peg$startRuleFunction = peg$startRuleFunctions[options.startRule];
  270. }
  271. function text() {
  272. return input.substring(peg$savedPos, peg$currPos);
  273. }
  274. function location() {
  275. return peg$computeLocation(peg$savedPos, peg$currPos);
  276. }
  277. function expected(description, location) {
  278. location = location !== void 0 ? location : peg$computeLocation(peg$savedPos, peg$currPos)
  279. throw peg$buildStructuredError(
  280. [peg$otherExpectation(description)],
  281. input.substring(peg$savedPos, peg$currPos),
  282. location
  283. );
  284. }
  285. function error(message, location) {
  286. location = location !== void 0 ? location : peg$computeLocation(peg$savedPos, peg$currPos)
  287. throw peg$buildSimpleError(message, location);
  288. }
  289. function peg$literalExpectation(text, ignoreCase) {
  290. return { type: "literal", text: text, ignoreCase: ignoreCase };
  291. }
  292. function peg$classExpectation(parts, inverted, ignoreCase) {
  293. return { type: "class", parts: parts, inverted: inverted, ignoreCase: ignoreCase };
  294. }
  295. function peg$anyExpectation() {
  296. return { type: "any" };
  297. }
  298. function peg$endExpectation() {
  299. return { type: "end" };
  300. }
  301. function peg$otherExpectation(description) {
  302. return { type: "other", description: description };
  303. }
  304. function peg$computePosDetails(pos) {
  305. var details = peg$posDetailsCache[pos], p;
  306. if (details) {
  307. return details;
  308. } else {
  309. p = pos - 1;
  310. while (!peg$posDetailsCache[p]) {
  311. p--;
  312. }
  313. details = peg$posDetailsCache[p];
  314. details = {
  315. line: details.line,
  316. column: details.column
  317. };
  318. while (p < pos) {
  319. if (input.charCodeAt(p) === 10) {
  320. details.line++;
  321. details.column = 1;
  322. } else {
  323. details.column++;
  324. }
  325. p++;
  326. }
  327. peg$posDetailsCache[pos] = details;
  328. return details;
  329. }
  330. }
  331. function peg$computeLocation(startPos, endPos) {
  332. var startPosDetails = peg$computePosDetails(startPos),
  333. endPosDetails = peg$computePosDetails(endPos);
  334. return {
  335. start: {
  336. offset: startPos,
  337. line: startPosDetails.line,
  338. column: startPosDetails.column
  339. },
  340. end: {
  341. offset: endPos,
  342. line: endPosDetails.line,
  343. column: endPosDetails.column
  344. }
  345. };
  346. }
  347. function peg$fail(expected) {
  348. if (peg$currPos < peg$maxFailPos) { return; }
  349. if (peg$currPos > peg$maxFailPos) {
  350. peg$maxFailPos = peg$currPos;
  351. peg$maxFailExpected = [];
  352. }
  353. peg$maxFailExpected.push(expected);
  354. }
  355. function peg$buildSimpleError(message, location) {
  356. return new peg$SyntaxError(message, null, null, location);
  357. }
  358. function peg$buildStructuredError(expected, found, location) {
  359. return new peg$SyntaxError(
  360. peg$SyntaxError.buildMessage(expected, found),
  361. expected,
  362. found,
  363. location
  364. );
  365. }
  366. function peg$parsestart() {
  367. var s0, s1, s2, s3;
  368. var key = peg$currPos * 32 + 0,
  369. cached = peg$resultsCache[key];
  370. if (cached) {
  371. peg$currPos = cached.nextPos;
  372. return cached.result;
  373. }
  374. s0 = peg$currPos;
  375. s1 = peg$parse_();
  376. if (s1 !== peg$FAILED) {
  377. s2 = peg$parseselectors();
  378. if (s2 !== peg$FAILED) {
  379. s3 = peg$parse_();
  380. if (s3 !== peg$FAILED) {
  381. peg$savedPos = s0;
  382. s1 = peg$c0(s2);
  383. s0 = s1;
  384. } else {
  385. peg$currPos = s0;
  386. s0 = peg$FAILED;
  387. }
  388. } else {
  389. peg$currPos = s0;
  390. s0 = peg$FAILED;
  391. }
  392. } else {
  393. peg$currPos = s0;
  394. s0 = peg$FAILED;
  395. }
  396. if (s0 === peg$FAILED) {
  397. s0 = peg$currPos;
  398. s1 = peg$parse_();
  399. if (s1 !== peg$FAILED) {
  400. peg$savedPos = s0;
  401. s1 = peg$c1();
  402. }
  403. s0 = s1;
  404. }
  405. peg$resultsCache[key] = { nextPos: peg$currPos, result: s0 };
  406. return s0;
  407. }
  408. function peg$parse_() {
  409. var s0, s1;
  410. var key = peg$currPos * 32 + 1,
  411. cached = peg$resultsCache[key];
  412. if (cached) {
  413. peg$currPos = cached.nextPos;
  414. return cached.result;
  415. }
  416. s0 = [];
  417. if (input.charCodeAt(peg$currPos) === 32) {
  418. s1 = peg$c2;
  419. peg$currPos++;
  420. } else {
  421. s1 = peg$FAILED;
  422. if (peg$silentFails === 0) { peg$fail(peg$c3); }
  423. }
  424. while (s1 !== peg$FAILED) {
  425. s0.push(s1);
  426. if (input.charCodeAt(peg$currPos) === 32) {
  427. s1 = peg$c2;
  428. peg$currPos++;
  429. } else {
  430. s1 = peg$FAILED;
  431. if (peg$silentFails === 0) { peg$fail(peg$c3); }
  432. }
  433. }
  434. peg$resultsCache[key] = { nextPos: peg$currPos, result: s0 };
  435. return s0;
  436. }
  437. function peg$parseidentifierName() {
  438. var s0, s1, s2;
  439. var key = peg$currPos * 32 + 2,
  440. cached = peg$resultsCache[key];
  441. if (cached) {
  442. peg$currPos = cached.nextPos;
  443. return cached.result;
  444. }
  445. s0 = peg$currPos;
  446. s1 = [];
  447. if (peg$c4.test(input.charAt(peg$currPos))) {
  448. s2 = input.charAt(peg$currPos);
  449. peg$currPos++;
  450. } else {
  451. s2 = peg$FAILED;
  452. if (peg$silentFails === 0) { peg$fail(peg$c5); }
  453. }
  454. if (s2 !== peg$FAILED) {
  455. while (s2 !== peg$FAILED) {
  456. s1.push(s2);
  457. if (peg$c4.test(input.charAt(peg$currPos))) {
  458. s2 = input.charAt(peg$currPos);
  459. peg$currPos++;
  460. } else {
  461. s2 = peg$FAILED;
  462. if (peg$silentFails === 0) { peg$fail(peg$c5); }
  463. }
  464. }
  465. } else {
  466. s1 = peg$FAILED;
  467. }
  468. if (s1 !== peg$FAILED) {
  469. peg$savedPos = s0;
  470. s1 = peg$c6(s1);
  471. }
  472. s0 = s1;
  473. peg$resultsCache[key] = { nextPos: peg$currPos, result: s0 };
  474. return s0;
  475. }
  476. function peg$parsebinaryOp() {
  477. var s0, s1, s2, s3;
  478. var key = peg$currPos * 32 + 3,
  479. cached = peg$resultsCache[key];
  480. if (cached) {
  481. peg$currPos = cached.nextPos;
  482. return cached.result;
  483. }
  484. s0 = peg$currPos;
  485. s1 = peg$parse_();
  486. if (s1 !== peg$FAILED) {
  487. if (input.charCodeAt(peg$currPos) === 62) {
  488. s2 = peg$c7;
  489. peg$currPos++;
  490. } else {
  491. s2 = peg$FAILED;
  492. if (peg$silentFails === 0) { peg$fail(peg$c8); }
  493. }
  494. if (s2 !== peg$FAILED) {
  495. s3 = peg$parse_();
  496. if (s3 !== peg$FAILED) {
  497. peg$savedPos = s0;
  498. s1 = peg$c9();
  499. s0 = s1;
  500. } else {
  501. peg$currPos = s0;
  502. s0 = peg$FAILED;
  503. }
  504. } else {
  505. peg$currPos = s0;
  506. s0 = peg$FAILED;
  507. }
  508. } else {
  509. peg$currPos = s0;
  510. s0 = peg$FAILED;
  511. }
  512. if (s0 === peg$FAILED) {
  513. s0 = peg$currPos;
  514. s1 = peg$parse_();
  515. if (s1 !== peg$FAILED) {
  516. if (input.charCodeAt(peg$currPos) === 126) {
  517. s2 = peg$c10;
  518. peg$currPos++;
  519. } else {
  520. s2 = peg$FAILED;
  521. if (peg$silentFails === 0) { peg$fail(peg$c11); }
  522. }
  523. if (s2 !== peg$FAILED) {
  524. s3 = peg$parse_();
  525. if (s3 !== peg$FAILED) {
  526. peg$savedPos = s0;
  527. s1 = peg$c12();
  528. s0 = s1;
  529. } else {
  530. peg$currPos = s0;
  531. s0 = peg$FAILED;
  532. }
  533. } else {
  534. peg$currPos = s0;
  535. s0 = peg$FAILED;
  536. }
  537. } else {
  538. peg$currPos = s0;
  539. s0 = peg$FAILED;
  540. }
  541. if (s0 === peg$FAILED) {
  542. s0 = peg$currPos;
  543. s1 = peg$parse_();
  544. if (s1 !== peg$FAILED) {
  545. if (input.charCodeAt(peg$currPos) === 43) {
  546. s2 = peg$c13;
  547. peg$currPos++;
  548. } else {
  549. s2 = peg$FAILED;
  550. if (peg$silentFails === 0) { peg$fail(peg$c14); }
  551. }
  552. if (s2 !== peg$FAILED) {
  553. s3 = peg$parse_();
  554. if (s3 !== peg$FAILED) {
  555. peg$savedPos = s0;
  556. s1 = peg$c15();
  557. s0 = s1;
  558. } else {
  559. peg$currPos = s0;
  560. s0 = peg$FAILED;
  561. }
  562. } else {
  563. peg$currPos = s0;
  564. s0 = peg$FAILED;
  565. }
  566. } else {
  567. peg$currPos = s0;
  568. s0 = peg$FAILED;
  569. }
  570. if (s0 === peg$FAILED) {
  571. s0 = peg$currPos;
  572. if (input.charCodeAt(peg$currPos) === 32) {
  573. s1 = peg$c2;
  574. peg$currPos++;
  575. } else {
  576. s1 = peg$FAILED;
  577. if (peg$silentFails === 0) { peg$fail(peg$c3); }
  578. }
  579. if (s1 !== peg$FAILED) {
  580. s2 = peg$parse_();
  581. if (s2 !== peg$FAILED) {
  582. peg$savedPos = s0;
  583. s1 = peg$c16();
  584. s0 = s1;
  585. } else {
  586. peg$currPos = s0;
  587. s0 = peg$FAILED;
  588. }
  589. } else {
  590. peg$currPos = s0;
  591. s0 = peg$FAILED;
  592. }
  593. }
  594. }
  595. }
  596. peg$resultsCache[key] = { nextPos: peg$currPos, result: s0 };
  597. return s0;
  598. }
  599. function peg$parsehasSelectors() {
  600. var s0, s1, s2, s3, s4, s5, s6, s7;
  601. var key = peg$currPos * 32 + 4,
  602. cached = peg$resultsCache[key];
  603. if (cached) {
  604. peg$currPos = cached.nextPos;
  605. return cached.result;
  606. }
  607. s0 = peg$currPos;
  608. s1 = peg$parsehasSelector();
  609. if (s1 !== peg$FAILED) {
  610. s2 = [];
  611. s3 = peg$currPos;
  612. s4 = peg$parse_();
  613. if (s4 !== peg$FAILED) {
  614. if (input.charCodeAt(peg$currPos) === 44) {
  615. s5 = peg$c17;
  616. peg$currPos++;
  617. } else {
  618. s5 = peg$FAILED;
  619. if (peg$silentFails === 0) { peg$fail(peg$c18); }
  620. }
  621. if (s5 !== peg$FAILED) {
  622. s6 = peg$parse_();
  623. if (s6 !== peg$FAILED) {
  624. s7 = peg$parsehasSelector();
  625. if (s7 !== peg$FAILED) {
  626. s4 = [s4, s5, s6, s7];
  627. s3 = s4;
  628. } else {
  629. peg$currPos = s3;
  630. s3 = peg$FAILED;
  631. }
  632. } else {
  633. peg$currPos = s3;
  634. s3 = peg$FAILED;
  635. }
  636. } else {
  637. peg$currPos = s3;
  638. s3 = peg$FAILED;
  639. }
  640. } else {
  641. peg$currPos = s3;
  642. s3 = peg$FAILED;
  643. }
  644. while (s3 !== peg$FAILED) {
  645. s2.push(s3);
  646. s3 = peg$currPos;
  647. s4 = peg$parse_();
  648. if (s4 !== peg$FAILED) {
  649. if (input.charCodeAt(peg$currPos) === 44) {
  650. s5 = peg$c17;
  651. peg$currPos++;
  652. } else {
  653. s5 = peg$FAILED;
  654. if (peg$silentFails === 0) { peg$fail(peg$c18); }
  655. }
  656. if (s5 !== peg$FAILED) {
  657. s6 = peg$parse_();
  658. if (s6 !== peg$FAILED) {
  659. s7 = peg$parsehasSelector();
  660. if (s7 !== peg$FAILED) {
  661. s4 = [s4, s5, s6, s7];
  662. s3 = s4;
  663. } else {
  664. peg$currPos = s3;
  665. s3 = peg$FAILED;
  666. }
  667. } else {
  668. peg$currPos = s3;
  669. s3 = peg$FAILED;
  670. }
  671. } else {
  672. peg$currPos = s3;
  673. s3 = peg$FAILED;
  674. }
  675. } else {
  676. peg$currPos = s3;
  677. s3 = peg$FAILED;
  678. }
  679. }
  680. if (s2 !== peg$FAILED) {
  681. peg$savedPos = s0;
  682. s1 = peg$c19(s1, s2);
  683. s0 = s1;
  684. } else {
  685. peg$currPos = s0;
  686. s0 = peg$FAILED;
  687. }
  688. } else {
  689. peg$currPos = s0;
  690. s0 = peg$FAILED;
  691. }
  692. peg$resultsCache[key] = { nextPos: peg$currPos, result: s0 };
  693. return s0;
  694. }
  695. function peg$parseselectors() {
  696. var s0, s1, s2, s3, s4, s5, s6, s7;
  697. var key = peg$currPos * 32 + 5,
  698. cached = peg$resultsCache[key];
  699. if (cached) {
  700. peg$currPos = cached.nextPos;
  701. return cached.result;
  702. }
  703. s0 = peg$currPos;
  704. s1 = peg$parseselector();
  705. if (s1 !== peg$FAILED) {
  706. s2 = [];
  707. s3 = peg$currPos;
  708. s4 = peg$parse_();
  709. if (s4 !== peg$FAILED) {
  710. if (input.charCodeAt(peg$currPos) === 44) {
  711. s5 = peg$c17;
  712. peg$currPos++;
  713. } else {
  714. s5 = peg$FAILED;
  715. if (peg$silentFails === 0) { peg$fail(peg$c18); }
  716. }
  717. if (s5 !== peg$FAILED) {
  718. s6 = peg$parse_();
  719. if (s6 !== peg$FAILED) {
  720. s7 = peg$parseselector();
  721. if (s7 !== peg$FAILED) {
  722. s4 = [s4, s5, s6, s7];
  723. s3 = s4;
  724. } else {
  725. peg$currPos = s3;
  726. s3 = peg$FAILED;
  727. }
  728. } else {
  729. peg$currPos = s3;
  730. s3 = peg$FAILED;
  731. }
  732. } else {
  733. peg$currPos = s3;
  734. s3 = peg$FAILED;
  735. }
  736. } else {
  737. peg$currPos = s3;
  738. s3 = peg$FAILED;
  739. }
  740. while (s3 !== peg$FAILED) {
  741. s2.push(s3);
  742. s3 = peg$currPos;
  743. s4 = peg$parse_();
  744. if (s4 !== peg$FAILED) {
  745. if (input.charCodeAt(peg$currPos) === 44) {
  746. s5 = peg$c17;
  747. peg$currPos++;
  748. } else {
  749. s5 = peg$FAILED;
  750. if (peg$silentFails === 0) { peg$fail(peg$c18); }
  751. }
  752. if (s5 !== peg$FAILED) {
  753. s6 = peg$parse_();
  754. if (s6 !== peg$FAILED) {
  755. s7 = peg$parseselector();
  756. if (s7 !== peg$FAILED) {
  757. s4 = [s4, s5, s6, s7];
  758. s3 = s4;
  759. } else {
  760. peg$currPos = s3;
  761. s3 = peg$FAILED;
  762. }
  763. } else {
  764. peg$currPos = s3;
  765. s3 = peg$FAILED;
  766. }
  767. } else {
  768. peg$currPos = s3;
  769. s3 = peg$FAILED;
  770. }
  771. } else {
  772. peg$currPos = s3;
  773. s3 = peg$FAILED;
  774. }
  775. }
  776. if (s2 !== peg$FAILED) {
  777. peg$savedPos = s0;
  778. s1 = peg$c19(s1, s2);
  779. s0 = s1;
  780. } else {
  781. peg$currPos = s0;
  782. s0 = peg$FAILED;
  783. }
  784. } else {
  785. peg$currPos = s0;
  786. s0 = peg$FAILED;
  787. }
  788. peg$resultsCache[key] = { nextPos: peg$currPos, result: s0 };
  789. return s0;
  790. }
  791. function peg$parsehasSelector() {
  792. var s0, s1, s2;
  793. var key = peg$currPos * 32 + 6,
  794. cached = peg$resultsCache[key];
  795. if (cached) {
  796. peg$currPos = cached.nextPos;
  797. return cached.result;
  798. }
  799. s0 = peg$currPos;
  800. s1 = peg$parsebinaryOp();
  801. if (s1 === peg$FAILED) {
  802. s1 = null;
  803. }
  804. if (s1 !== peg$FAILED) {
  805. s2 = peg$parseselector();
  806. if (s2 !== peg$FAILED) {
  807. peg$savedPos = s0;
  808. s1 = peg$c20(s1, s2);
  809. s0 = s1;
  810. } else {
  811. peg$currPos = s0;
  812. s0 = peg$FAILED;
  813. }
  814. } else {
  815. peg$currPos = s0;
  816. s0 = peg$FAILED;
  817. }
  818. peg$resultsCache[key] = { nextPos: peg$currPos, result: s0 };
  819. return s0;
  820. }
  821. function peg$parseselector() {
  822. var s0, s1, s2, s3, s4, s5;
  823. var key = peg$currPos * 32 + 7,
  824. cached = peg$resultsCache[key];
  825. if (cached) {
  826. peg$currPos = cached.nextPos;
  827. return cached.result;
  828. }
  829. s0 = peg$currPos;
  830. s1 = peg$parsesequence();
  831. if (s1 !== peg$FAILED) {
  832. s2 = [];
  833. s3 = peg$currPos;
  834. s4 = peg$parsebinaryOp();
  835. if (s4 !== peg$FAILED) {
  836. s5 = peg$parsesequence();
  837. if (s5 !== peg$FAILED) {
  838. s4 = [s4, s5];
  839. s3 = s4;
  840. } else {
  841. peg$currPos = s3;
  842. s3 = peg$FAILED;
  843. }
  844. } else {
  845. peg$currPos = s3;
  846. s3 = peg$FAILED;
  847. }
  848. while (s3 !== peg$FAILED) {
  849. s2.push(s3);
  850. s3 = peg$currPos;
  851. s4 = peg$parsebinaryOp();
  852. if (s4 !== peg$FAILED) {
  853. s5 = peg$parsesequence();
  854. if (s5 !== peg$FAILED) {
  855. s4 = [s4, s5];
  856. s3 = s4;
  857. } else {
  858. peg$currPos = s3;
  859. s3 = peg$FAILED;
  860. }
  861. } else {
  862. peg$currPos = s3;
  863. s3 = peg$FAILED;
  864. }
  865. }
  866. if (s2 !== peg$FAILED) {
  867. peg$savedPos = s0;
  868. s1 = peg$c21(s1, s2);
  869. s0 = s1;
  870. } else {
  871. peg$currPos = s0;
  872. s0 = peg$FAILED;
  873. }
  874. } else {
  875. peg$currPos = s0;
  876. s0 = peg$FAILED;
  877. }
  878. peg$resultsCache[key] = { nextPos: peg$currPos, result: s0 };
  879. return s0;
  880. }
  881. function peg$parsesequence() {
  882. var s0, s1, s2, s3;
  883. var key = peg$currPos * 32 + 8,
  884. cached = peg$resultsCache[key];
  885. if (cached) {
  886. peg$currPos = cached.nextPos;
  887. return cached.result;
  888. }
  889. s0 = peg$currPos;
  890. if (input.charCodeAt(peg$currPos) === 33) {
  891. s1 = peg$c22;
  892. peg$currPos++;
  893. } else {
  894. s1 = peg$FAILED;
  895. if (peg$silentFails === 0) { peg$fail(peg$c23); }
  896. }
  897. if (s1 === peg$FAILED) {
  898. s1 = null;
  899. }
  900. if (s1 !== peg$FAILED) {
  901. s2 = [];
  902. s3 = peg$parseatom();
  903. if (s3 !== peg$FAILED) {
  904. while (s3 !== peg$FAILED) {
  905. s2.push(s3);
  906. s3 = peg$parseatom();
  907. }
  908. } else {
  909. s2 = peg$FAILED;
  910. }
  911. if (s2 !== peg$FAILED) {
  912. peg$savedPos = s0;
  913. s1 = peg$c24(s1, s2);
  914. s0 = s1;
  915. } else {
  916. peg$currPos = s0;
  917. s0 = peg$FAILED;
  918. }
  919. } else {
  920. peg$currPos = s0;
  921. s0 = peg$FAILED;
  922. }
  923. peg$resultsCache[key] = { nextPos: peg$currPos, result: s0 };
  924. return s0;
  925. }
  926. function peg$parseatom() {
  927. var s0;
  928. var key = peg$currPos * 32 + 9,
  929. cached = peg$resultsCache[key];
  930. if (cached) {
  931. peg$currPos = cached.nextPos;
  932. return cached.result;
  933. }
  934. s0 = peg$parsewildcard();
  935. if (s0 === peg$FAILED) {
  936. s0 = peg$parseidentifier();
  937. if (s0 === peg$FAILED) {
  938. s0 = peg$parseattr();
  939. if (s0 === peg$FAILED) {
  940. s0 = peg$parsefield();
  941. if (s0 === peg$FAILED) {
  942. s0 = peg$parsenegation();
  943. if (s0 === peg$FAILED) {
  944. s0 = peg$parsematches();
  945. if (s0 === peg$FAILED) {
  946. s0 = peg$parsehas();
  947. if (s0 === peg$FAILED) {
  948. s0 = peg$parsefirstChild();
  949. if (s0 === peg$FAILED) {
  950. s0 = peg$parselastChild();
  951. if (s0 === peg$FAILED) {
  952. s0 = peg$parsenthChild();
  953. if (s0 === peg$FAILED) {
  954. s0 = peg$parsenthLastChild();
  955. if (s0 === peg$FAILED) {
  956. s0 = peg$parseclass();
  957. }
  958. }
  959. }
  960. }
  961. }
  962. }
  963. }
  964. }
  965. }
  966. }
  967. }
  968. peg$resultsCache[key] = { nextPos: peg$currPos, result: s0 };
  969. return s0;
  970. }
  971. function peg$parsewildcard() {
  972. var s0, s1;
  973. var key = peg$currPos * 32 + 10,
  974. cached = peg$resultsCache[key];
  975. if (cached) {
  976. peg$currPos = cached.nextPos;
  977. return cached.result;
  978. }
  979. s0 = peg$currPos;
  980. if (input.charCodeAt(peg$currPos) === 42) {
  981. s1 = peg$c25;
  982. peg$currPos++;
  983. } else {
  984. s1 = peg$FAILED;
  985. if (peg$silentFails === 0) { peg$fail(peg$c26); }
  986. }
  987. if (s1 !== peg$FAILED) {
  988. peg$savedPos = s0;
  989. s1 = peg$c27(s1);
  990. }
  991. s0 = s1;
  992. peg$resultsCache[key] = { nextPos: peg$currPos, result: s0 };
  993. return s0;
  994. }
  995. function peg$parseidentifier() {
  996. var s0, s1, s2;
  997. var key = peg$currPos * 32 + 11,
  998. cached = peg$resultsCache[key];
  999. if (cached) {
  1000. peg$currPos = cached.nextPos;
  1001. return cached.result;
  1002. }
  1003. s0 = peg$currPos;
  1004. if (input.charCodeAt(peg$currPos) === 35) {
  1005. s1 = peg$c28;
  1006. peg$currPos++;
  1007. } else {
  1008. s1 = peg$FAILED;
  1009. if (peg$silentFails === 0) { peg$fail(peg$c29); }
  1010. }
  1011. if (s1 === peg$FAILED) {
  1012. s1 = null;
  1013. }
  1014. if (s1 !== peg$FAILED) {
  1015. s2 = peg$parseidentifierName();
  1016. if (s2 !== peg$FAILED) {
  1017. peg$savedPos = s0;
  1018. s1 = peg$c30(s2);
  1019. s0 = s1;
  1020. } else {
  1021. peg$currPos = s0;
  1022. s0 = peg$FAILED;
  1023. }
  1024. } else {
  1025. peg$currPos = s0;
  1026. s0 = peg$FAILED;
  1027. }
  1028. peg$resultsCache[key] = { nextPos: peg$currPos, result: s0 };
  1029. return s0;
  1030. }
  1031. function peg$parseattr() {
  1032. var s0, s1, s2, s3, s4, s5;
  1033. var key = peg$currPos * 32 + 12,
  1034. cached = peg$resultsCache[key];
  1035. if (cached) {
  1036. peg$currPos = cached.nextPos;
  1037. return cached.result;
  1038. }
  1039. s0 = peg$currPos;
  1040. if (input.charCodeAt(peg$currPos) === 91) {
  1041. s1 = peg$c31;
  1042. peg$currPos++;
  1043. } else {
  1044. s1 = peg$FAILED;
  1045. if (peg$silentFails === 0) { peg$fail(peg$c32); }
  1046. }
  1047. if (s1 !== peg$FAILED) {
  1048. s2 = peg$parse_();
  1049. if (s2 !== peg$FAILED) {
  1050. s3 = peg$parseattrValue();
  1051. if (s3 !== peg$FAILED) {
  1052. s4 = peg$parse_();
  1053. if (s4 !== peg$FAILED) {
  1054. if (input.charCodeAt(peg$currPos) === 93) {
  1055. s5 = peg$c33;
  1056. peg$currPos++;
  1057. } else {
  1058. s5 = peg$FAILED;
  1059. if (peg$silentFails === 0) { peg$fail(peg$c34); }
  1060. }
  1061. if (s5 !== peg$FAILED) {
  1062. peg$savedPos = s0;
  1063. s1 = peg$c35(s3);
  1064. s0 = s1;
  1065. } else {
  1066. peg$currPos = s0;
  1067. s0 = peg$FAILED;
  1068. }
  1069. } else {
  1070. peg$currPos = s0;
  1071. s0 = peg$FAILED;
  1072. }
  1073. } else {
  1074. peg$currPos = s0;
  1075. s0 = peg$FAILED;
  1076. }
  1077. } else {
  1078. peg$currPos = s0;
  1079. s0 = peg$FAILED;
  1080. }
  1081. } else {
  1082. peg$currPos = s0;
  1083. s0 = peg$FAILED;
  1084. }
  1085. peg$resultsCache[key] = { nextPos: peg$currPos, result: s0 };
  1086. return s0;
  1087. }
  1088. function peg$parseattrOps() {
  1089. var s0, s1, s2;
  1090. var key = peg$currPos * 32 + 13,
  1091. cached = peg$resultsCache[key];
  1092. if (cached) {
  1093. peg$currPos = cached.nextPos;
  1094. return cached.result;
  1095. }
  1096. s0 = peg$currPos;
  1097. if (peg$c36.test(input.charAt(peg$currPos))) {
  1098. s1 = input.charAt(peg$currPos);
  1099. peg$currPos++;
  1100. } else {
  1101. s1 = peg$FAILED;
  1102. if (peg$silentFails === 0) { peg$fail(peg$c37); }
  1103. }
  1104. if (s1 === peg$FAILED) {
  1105. s1 = null;
  1106. }
  1107. if (s1 !== peg$FAILED) {
  1108. if (input.charCodeAt(peg$currPos) === 61) {
  1109. s2 = peg$c38;
  1110. peg$currPos++;
  1111. } else {
  1112. s2 = peg$FAILED;
  1113. if (peg$silentFails === 0) { peg$fail(peg$c39); }
  1114. }
  1115. if (s2 !== peg$FAILED) {
  1116. peg$savedPos = s0;
  1117. s1 = peg$c40(s1);
  1118. s0 = s1;
  1119. } else {
  1120. peg$currPos = s0;
  1121. s0 = peg$FAILED;
  1122. }
  1123. } else {
  1124. peg$currPos = s0;
  1125. s0 = peg$FAILED;
  1126. }
  1127. if (s0 === peg$FAILED) {
  1128. if (peg$c41.test(input.charAt(peg$currPos))) {
  1129. s0 = input.charAt(peg$currPos);
  1130. peg$currPos++;
  1131. } else {
  1132. s0 = peg$FAILED;
  1133. if (peg$silentFails === 0) { peg$fail(peg$c42); }
  1134. }
  1135. }
  1136. peg$resultsCache[key] = { nextPos: peg$currPos, result: s0 };
  1137. return s0;
  1138. }
  1139. function peg$parseattrEqOps() {
  1140. var s0, s1, s2;
  1141. var key = peg$currPos * 32 + 14,
  1142. cached = peg$resultsCache[key];
  1143. if (cached) {
  1144. peg$currPos = cached.nextPos;
  1145. return cached.result;
  1146. }
  1147. s0 = peg$currPos;
  1148. if (input.charCodeAt(peg$currPos) === 33) {
  1149. s1 = peg$c22;
  1150. peg$currPos++;
  1151. } else {
  1152. s1 = peg$FAILED;
  1153. if (peg$silentFails === 0) { peg$fail(peg$c23); }
  1154. }
  1155. if (s1 === peg$FAILED) {
  1156. s1 = null;
  1157. }
  1158. if (s1 !== peg$FAILED) {
  1159. if (input.charCodeAt(peg$currPos) === 61) {
  1160. s2 = peg$c38;
  1161. peg$currPos++;
  1162. } else {
  1163. s2 = peg$FAILED;
  1164. if (peg$silentFails === 0) { peg$fail(peg$c39); }
  1165. }
  1166. if (s2 !== peg$FAILED) {
  1167. peg$savedPos = s0;
  1168. s1 = peg$c40(s1);
  1169. s0 = s1;
  1170. } else {
  1171. peg$currPos = s0;
  1172. s0 = peg$FAILED;
  1173. }
  1174. } else {
  1175. peg$currPos = s0;
  1176. s0 = peg$FAILED;
  1177. }
  1178. peg$resultsCache[key] = { nextPos: peg$currPos, result: s0 };
  1179. return s0;
  1180. }
  1181. function peg$parseattrName() {
  1182. var s0, s1, s2, s3, s4, s5;
  1183. var key = peg$currPos * 32 + 15,
  1184. cached = peg$resultsCache[key];
  1185. if (cached) {
  1186. peg$currPos = cached.nextPos;
  1187. return cached.result;
  1188. }
  1189. s0 = peg$currPos;
  1190. s1 = peg$parseidentifierName();
  1191. if (s1 !== peg$FAILED) {
  1192. s2 = [];
  1193. s3 = peg$currPos;
  1194. if (input.charCodeAt(peg$currPos) === 46) {
  1195. s4 = peg$c43;
  1196. peg$currPos++;
  1197. } else {
  1198. s4 = peg$FAILED;
  1199. if (peg$silentFails === 0) { peg$fail(peg$c44); }
  1200. }
  1201. if (s4 !== peg$FAILED) {
  1202. s5 = peg$parseidentifierName();
  1203. if (s5 !== peg$FAILED) {
  1204. s4 = [s4, s5];
  1205. s3 = s4;
  1206. } else {
  1207. peg$currPos = s3;
  1208. s3 = peg$FAILED;
  1209. }
  1210. } else {
  1211. peg$currPos = s3;
  1212. s3 = peg$FAILED;
  1213. }
  1214. while (s3 !== peg$FAILED) {
  1215. s2.push(s3);
  1216. s3 = peg$currPos;
  1217. if (input.charCodeAt(peg$currPos) === 46) {
  1218. s4 = peg$c43;
  1219. peg$currPos++;
  1220. } else {
  1221. s4 = peg$FAILED;
  1222. if (peg$silentFails === 0) { peg$fail(peg$c44); }
  1223. }
  1224. if (s4 !== peg$FAILED) {
  1225. s5 = peg$parseidentifierName();
  1226. if (s5 !== peg$FAILED) {
  1227. s4 = [s4, s5];
  1228. s3 = s4;
  1229. } else {
  1230. peg$currPos = s3;
  1231. s3 = peg$FAILED;
  1232. }
  1233. } else {
  1234. peg$currPos = s3;
  1235. s3 = peg$FAILED;
  1236. }
  1237. }
  1238. if (s2 !== peg$FAILED) {
  1239. peg$savedPos = s0;
  1240. s1 = peg$c45(s1, s2);
  1241. s0 = s1;
  1242. } else {
  1243. peg$currPos = s0;
  1244. s0 = peg$FAILED;
  1245. }
  1246. } else {
  1247. peg$currPos = s0;
  1248. s0 = peg$FAILED;
  1249. }
  1250. peg$resultsCache[key] = { nextPos: peg$currPos, result: s0 };
  1251. return s0;
  1252. }
  1253. function peg$parseattrValue() {
  1254. var s0, s1, s2, s3, s4, s5;
  1255. var key = peg$currPos * 32 + 16,
  1256. cached = peg$resultsCache[key];
  1257. if (cached) {
  1258. peg$currPos = cached.nextPos;
  1259. return cached.result;
  1260. }
  1261. s0 = peg$currPos;
  1262. s1 = peg$parseattrName();
  1263. if (s1 !== peg$FAILED) {
  1264. s2 = peg$parse_();
  1265. if (s2 !== peg$FAILED) {
  1266. s3 = peg$parseattrEqOps();
  1267. if (s3 !== peg$FAILED) {
  1268. s4 = peg$parse_();
  1269. if (s4 !== peg$FAILED) {
  1270. s5 = peg$parsetype();
  1271. if (s5 === peg$FAILED) {
  1272. s5 = peg$parseregex();
  1273. }
  1274. if (s5 !== peg$FAILED) {
  1275. peg$savedPos = s0;
  1276. s1 = peg$c46(s1, s3, s5);
  1277. s0 = s1;
  1278. } else {
  1279. peg$currPos = s0;
  1280. s0 = peg$FAILED;
  1281. }
  1282. } else {
  1283. peg$currPos = s0;
  1284. s0 = peg$FAILED;
  1285. }
  1286. } else {
  1287. peg$currPos = s0;
  1288. s0 = peg$FAILED;
  1289. }
  1290. } else {
  1291. peg$currPos = s0;
  1292. s0 = peg$FAILED;
  1293. }
  1294. } else {
  1295. peg$currPos = s0;
  1296. s0 = peg$FAILED;
  1297. }
  1298. if (s0 === peg$FAILED) {
  1299. s0 = peg$currPos;
  1300. s1 = peg$parseattrName();
  1301. if (s1 !== peg$FAILED) {
  1302. s2 = peg$parse_();
  1303. if (s2 !== peg$FAILED) {
  1304. s3 = peg$parseattrOps();
  1305. if (s3 !== peg$FAILED) {
  1306. s4 = peg$parse_();
  1307. if (s4 !== peg$FAILED) {
  1308. s5 = peg$parsestring();
  1309. if (s5 === peg$FAILED) {
  1310. s5 = peg$parsenumber();
  1311. if (s5 === peg$FAILED) {
  1312. s5 = peg$parsepath();
  1313. }
  1314. }
  1315. if (s5 !== peg$FAILED) {
  1316. peg$savedPos = s0;
  1317. s1 = peg$c46(s1, s3, s5);
  1318. s0 = s1;
  1319. } else {
  1320. peg$currPos = s0;
  1321. s0 = peg$FAILED;
  1322. }
  1323. } else {
  1324. peg$currPos = s0;
  1325. s0 = peg$FAILED;
  1326. }
  1327. } else {
  1328. peg$currPos = s0;
  1329. s0 = peg$FAILED;
  1330. }
  1331. } else {
  1332. peg$currPos = s0;
  1333. s0 = peg$FAILED;
  1334. }
  1335. } else {
  1336. peg$currPos = s0;
  1337. s0 = peg$FAILED;
  1338. }
  1339. if (s0 === peg$FAILED) {
  1340. s0 = peg$currPos;
  1341. s1 = peg$parseattrName();
  1342. if (s1 !== peg$FAILED) {
  1343. peg$savedPos = s0;
  1344. s1 = peg$c47(s1);
  1345. }
  1346. s0 = s1;
  1347. }
  1348. }
  1349. peg$resultsCache[key] = { nextPos: peg$currPos, result: s0 };
  1350. return s0;
  1351. }
  1352. function peg$parsestring() {
  1353. var s0, s1, s2, s3, s4, s5;
  1354. var key = peg$currPos * 32 + 17,
  1355. cached = peg$resultsCache[key];
  1356. if (cached) {
  1357. peg$currPos = cached.nextPos;
  1358. return cached.result;
  1359. }
  1360. s0 = peg$currPos;
  1361. if (input.charCodeAt(peg$currPos) === 34) {
  1362. s1 = peg$c48;
  1363. peg$currPos++;
  1364. } else {
  1365. s1 = peg$FAILED;
  1366. if (peg$silentFails === 0) { peg$fail(peg$c49); }
  1367. }
  1368. if (s1 !== peg$FAILED) {
  1369. s2 = [];
  1370. if (peg$c50.test(input.charAt(peg$currPos))) {
  1371. s3 = input.charAt(peg$currPos);
  1372. peg$currPos++;
  1373. } else {
  1374. s3 = peg$FAILED;
  1375. if (peg$silentFails === 0) { peg$fail(peg$c51); }
  1376. }
  1377. if (s3 === peg$FAILED) {
  1378. s3 = peg$currPos;
  1379. if (input.charCodeAt(peg$currPos) === 92) {
  1380. s4 = peg$c52;
  1381. peg$currPos++;
  1382. } else {
  1383. s4 = peg$FAILED;
  1384. if (peg$silentFails === 0) { peg$fail(peg$c53); }
  1385. }
  1386. if (s4 !== peg$FAILED) {
  1387. if (input.length > peg$currPos) {
  1388. s5 = input.charAt(peg$currPos);
  1389. peg$currPos++;
  1390. } else {
  1391. s5 = peg$FAILED;
  1392. if (peg$silentFails === 0) { peg$fail(peg$c54); }
  1393. }
  1394. if (s5 !== peg$FAILED) {
  1395. peg$savedPos = s3;
  1396. s4 = peg$c55(s4, s5);
  1397. s3 = s4;
  1398. } else {
  1399. peg$currPos = s3;
  1400. s3 = peg$FAILED;
  1401. }
  1402. } else {
  1403. peg$currPos = s3;
  1404. s3 = peg$FAILED;
  1405. }
  1406. }
  1407. while (s3 !== peg$FAILED) {
  1408. s2.push(s3);
  1409. if (peg$c50.test(input.charAt(peg$currPos))) {
  1410. s3 = input.charAt(peg$currPos);
  1411. peg$currPos++;
  1412. } else {
  1413. s3 = peg$FAILED;
  1414. if (peg$silentFails === 0) { peg$fail(peg$c51); }
  1415. }
  1416. if (s3 === peg$FAILED) {
  1417. s3 = peg$currPos;
  1418. if (input.charCodeAt(peg$currPos) === 92) {
  1419. s4 = peg$c52;
  1420. peg$currPos++;
  1421. } else {
  1422. s4 = peg$FAILED;
  1423. if (peg$silentFails === 0) { peg$fail(peg$c53); }
  1424. }
  1425. if (s4 !== peg$FAILED) {
  1426. if (input.length > peg$currPos) {
  1427. s5 = input.charAt(peg$currPos);
  1428. peg$currPos++;
  1429. } else {
  1430. s5 = peg$FAILED;
  1431. if (peg$silentFails === 0) { peg$fail(peg$c54); }
  1432. }
  1433. if (s5 !== peg$FAILED) {
  1434. peg$savedPos = s3;
  1435. s4 = peg$c55(s4, s5);
  1436. s3 = s4;
  1437. } else {
  1438. peg$currPos = s3;
  1439. s3 = peg$FAILED;
  1440. }
  1441. } else {
  1442. peg$currPos = s3;
  1443. s3 = peg$FAILED;
  1444. }
  1445. }
  1446. }
  1447. if (s2 !== peg$FAILED) {
  1448. if (input.charCodeAt(peg$currPos) === 34) {
  1449. s3 = peg$c48;
  1450. peg$currPos++;
  1451. } else {
  1452. s3 = peg$FAILED;
  1453. if (peg$silentFails === 0) { peg$fail(peg$c49); }
  1454. }
  1455. if (s3 !== peg$FAILED) {
  1456. peg$savedPos = s0;
  1457. s1 = peg$c56(s2);
  1458. s0 = s1;
  1459. } else {
  1460. peg$currPos = s0;
  1461. s0 = peg$FAILED;
  1462. }
  1463. } else {
  1464. peg$currPos = s0;
  1465. s0 = peg$FAILED;
  1466. }
  1467. } else {
  1468. peg$currPos = s0;
  1469. s0 = peg$FAILED;
  1470. }
  1471. if (s0 === peg$FAILED) {
  1472. s0 = peg$currPos;
  1473. if (input.charCodeAt(peg$currPos) === 39) {
  1474. s1 = peg$c57;
  1475. peg$currPos++;
  1476. } else {
  1477. s1 = peg$FAILED;
  1478. if (peg$silentFails === 0) { peg$fail(peg$c58); }
  1479. }
  1480. if (s1 !== peg$FAILED) {
  1481. s2 = [];
  1482. if (peg$c59.test(input.charAt(peg$currPos))) {
  1483. s3 = input.charAt(peg$currPos);
  1484. peg$currPos++;
  1485. } else {
  1486. s3 = peg$FAILED;
  1487. if (peg$silentFails === 0) { peg$fail(peg$c60); }
  1488. }
  1489. if (s3 === peg$FAILED) {
  1490. s3 = peg$currPos;
  1491. if (input.charCodeAt(peg$currPos) === 92) {
  1492. s4 = peg$c52;
  1493. peg$currPos++;
  1494. } else {
  1495. s4 = peg$FAILED;
  1496. if (peg$silentFails === 0) { peg$fail(peg$c53); }
  1497. }
  1498. if (s4 !== peg$FAILED) {
  1499. if (input.length > peg$currPos) {
  1500. s5 = input.charAt(peg$currPos);
  1501. peg$currPos++;
  1502. } else {
  1503. s5 = peg$FAILED;
  1504. if (peg$silentFails === 0) { peg$fail(peg$c54); }
  1505. }
  1506. if (s5 !== peg$FAILED) {
  1507. peg$savedPos = s3;
  1508. s4 = peg$c55(s4, s5);
  1509. s3 = s4;
  1510. } else {
  1511. peg$currPos = s3;
  1512. s3 = peg$FAILED;
  1513. }
  1514. } else {
  1515. peg$currPos = s3;
  1516. s3 = peg$FAILED;
  1517. }
  1518. }
  1519. while (s3 !== peg$FAILED) {
  1520. s2.push(s3);
  1521. if (peg$c59.test(input.charAt(peg$currPos))) {
  1522. s3 = input.charAt(peg$currPos);
  1523. peg$currPos++;
  1524. } else {
  1525. s3 = peg$FAILED;
  1526. if (peg$silentFails === 0) { peg$fail(peg$c60); }
  1527. }
  1528. if (s3 === peg$FAILED) {
  1529. s3 = peg$currPos;
  1530. if (input.charCodeAt(peg$currPos) === 92) {
  1531. s4 = peg$c52;
  1532. peg$currPos++;
  1533. } else {
  1534. s4 = peg$FAILED;
  1535. if (peg$silentFails === 0) { peg$fail(peg$c53); }
  1536. }
  1537. if (s4 !== peg$FAILED) {
  1538. if (input.length > peg$currPos) {
  1539. s5 = input.charAt(peg$currPos);
  1540. peg$currPos++;
  1541. } else {
  1542. s5 = peg$FAILED;
  1543. if (peg$silentFails === 0) { peg$fail(peg$c54); }
  1544. }
  1545. if (s5 !== peg$FAILED) {
  1546. peg$savedPos = s3;
  1547. s4 = peg$c55(s4, s5);
  1548. s3 = s4;
  1549. } else {
  1550. peg$currPos = s3;
  1551. s3 = peg$FAILED;
  1552. }
  1553. } else {
  1554. peg$currPos = s3;
  1555. s3 = peg$FAILED;
  1556. }
  1557. }
  1558. }
  1559. if (s2 !== peg$FAILED) {
  1560. if (input.charCodeAt(peg$currPos) === 39) {
  1561. s3 = peg$c57;
  1562. peg$currPos++;
  1563. } else {
  1564. s3 = peg$FAILED;
  1565. if (peg$silentFails === 0) { peg$fail(peg$c58); }
  1566. }
  1567. if (s3 !== peg$FAILED) {
  1568. peg$savedPos = s0;
  1569. s1 = peg$c56(s2);
  1570. s0 = s1;
  1571. } else {
  1572. peg$currPos = s0;
  1573. s0 = peg$FAILED;
  1574. }
  1575. } else {
  1576. peg$currPos = s0;
  1577. s0 = peg$FAILED;
  1578. }
  1579. } else {
  1580. peg$currPos = s0;
  1581. s0 = peg$FAILED;
  1582. }
  1583. }
  1584. peg$resultsCache[key] = { nextPos: peg$currPos, result: s0 };
  1585. return s0;
  1586. }
  1587. function peg$parsenumber() {
  1588. var s0, s1, s2, s3;
  1589. var key = peg$currPos * 32 + 18,
  1590. cached = peg$resultsCache[key];
  1591. if (cached) {
  1592. peg$currPos = cached.nextPos;
  1593. return cached.result;
  1594. }
  1595. s0 = peg$currPos;
  1596. s1 = peg$currPos;
  1597. s2 = [];
  1598. if (peg$c61.test(input.charAt(peg$currPos))) {
  1599. s3 = input.charAt(peg$currPos);
  1600. peg$currPos++;
  1601. } else {
  1602. s3 = peg$FAILED;
  1603. if (peg$silentFails === 0) { peg$fail(peg$c62); }
  1604. }
  1605. while (s3 !== peg$FAILED) {
  1606. s2.push(s3);
  1607. if (peg$c61.test(input.charAt(peg$currPos))) {
  1608. s3 = input.charAt(peg$currPos);
  1609. peg$currPos++;
  1610. } else {
  1611. s3 = peg$FAILED;
  1612. if (peg$silentFails === 0) { peg$fail(peg$c62); }
  1613. }
  1614. }
  1615. if (s2 !== peg$FAILED) {
  1616. if (input.charCodeAt(peg$currPos) === 46) {
  1617. s3 = peg$c43;
  1618. peg$currPos++;
  1619. } else {
  1620. s3 = peg$FAILED;
  1621. if (peg$silentFails === 0) { peg$fail(peg$c44); }
  1622. }
  1623. if (s3 !== peg$FAILED) {
  1624. s2 = [s2, s3];
  1625. s1 = s2;
  1626. } else {
  1627. peg$currPos = s1;
  1628. s1 = peg$FAILED;
  1629. }
  1630. } else {
  1631. peg$currPos = s1;
  1632. s1 = peg$FAILED;
  1633. }
  1634. if (s1 === peg$FAILED) {
  1635. s1 = null;
  1636. }
  1637. if (s1 !== peg$FAILED) {
  1638. s2 = [];
  1639. if (peg$c61.test(input.charAt(peg$currPos))) {
  1640. s3 = input.charAt(peg$currPos);
  1641. peg$currPos++;
  1642. } else {
  1643. s3 = peg$FAILED;
  1644. if (peg$silentFails === 0) { peg$fail(peg$c62); }
  1645. }
  1646. if (s3 !== peg$FAILED) {
  1647. while (s3 !== peg$FAILED) {
  1648. s2.push(s3);
  1649. if (peg$c61.test(input.charAt(peg$currPos))) {
  1650. s3 = input.charAt(peg$currPos);
  1651. peg$currPos++;
  1652. } else {
  1653. s3 = peg$FAILED;
  1654. if (peg$silentFails === 0) { peg$fail(peg$c62); }
  1655. }
  1656. }
  1657. } else {
  1658. s2 = peg$FAILED;
  1659. }
  1660. if (s2 !== peg$FAILED) {
  1661. peg$savedPos = s0;
  1662. s1 = peg$c63(s1, s2);
  1663. s0 = s1;
  1664. } else {
  1665. peg$currPos = s0;
  1666. s0 = peg$FAILED;
  1667. }
  1668. } else {
  1669. peg$currPos = s0;
  1670. s0 = peg$FAILED;
  1671. }
  1672. peg$resultsCache[key] = { nextPos: peg$currPos, result: s0 };
  1673. return s0;
  1674. }
  1675. function peg$parsepath() {
  1676. var s0, s1;
  1677. var key = peg$currPos * 32 + 19,
  1678. cached = peg$resultsCache[key];
  1679. if (cached) {
  1680. peg$currPos = cached.nextPos;
  1681. return cached.result;
  1682. }
  1683. s0 = peg$currPos;
  1684. s1 = peg$parseidentifierName();
  1685. if (s1 !== peg$FAILED) {
  1686. peg$savedPos = s0;
  1687. s1 = peg$c64(s1);
  1688. }
  1689. s0 = s1;
  1690. peg$resultsCache[key] = { nextPos: peg$currPos, result: s0 };
  1691. return s0;
  1692. }
  1693. function peg$parsetype() {
  1694. var s0, s1, s2, s3, s4, s5;
  1695. var key = peg$currPos * 32 + 20,
  1696. cached = peg$resultsCache[key];
  1697. if (cached) {
  1698. peg$currPos = cached.nextPos;
  1699. return cached.result;
  1700. }
  1701. s0 = peg$currPos;
  1702. if (input.substr(peg$currPos, 5) === peg$c65) {
  1703. s1 = peg$c65;
  1704. peg$currPos += 5;
  1705. } else {
  1706. s1 = peg$FAILED;
  1707. if (peg$silentFails === 0) { peg$fail(peg$c66); }
  1708. }
  1709. if (s1 !== peg$FAILED) {
  1710. s2 = peg$parse_();
  1711. if (s2 !== peg$FAILED) {
  1712. s3 = [];
  1713. if (peg$c67.test(input.charAt(peg$currPos))) {
  1714. s4 = input.charAt(peg$currPos);
  1715. peg$currPos++;
  1716. } else {
  1717. s4 = peg$FAILED;
  1718. if (peg$silentFails === 0) { peg$fail(peg$c68); }
  1719. }
  1720. if (s4 !== peg$FAILED) {
  1721. while (s4 !== peg$FAILED) {
  1722. s3.push(s4);
  1723. if (peg$c67.test(input.charAt(peg$currPos))) {
  1724. s4 = input.charAt(peg$currPos);
  1725. peg$currPos++;
  1726. } else {
  1727. s4 = peg$FAILED;
  1728. if (peg$silentFails === 0) { peg$fail(peg$c68); }
  1729. }
  1730. }
  1731. } else {
  1732. s3 = peg$FAILED;
  1733. }
  1734. if (s3 !== peg$FAILED) {
  1735. s4 = peg$parse_();
  1736. if (s4 !== peg$FAILED) {
  1737. if (input.charCodeAt(peg$currPos) === 41) {
  1738. s5 = peg$c69;
  1739. peg$currPos++;
  1740. } else {
  1741. s5 = peg$FAILED;
  1742. if (peg$silentFails === 0) { peg$fail(peg$c70); }
  1743. }
  1744. if (s5 !== peg$FAILED) {
  1745. peg$savedPos = s0;
  1746. s1 = peg$c71(s3);
  1747. s0 = s1;
  1748. } else {
  1749. peg$currPos = s0;
  1750. s0 = peg$FAILED;
  1751. }
  1752. } else {
  1753. peg$currPos = s0;
  1754. s0 = peg$FAILED;
  1755. }
  1756. } else {
  1757. peg$currPos = s0;
  1758. s0 = peg$FAILED;
  1759. }
  1760. } else {
  1761. peg$currPos = s0;
  1762. s0 = peg$FAILED;
  1763. }
  1764. } else {
  1765. peg$currPos = s0;
  1766. s0 = peg$FAILED;
  1767. }
  1768. peg$resultsCache[key] = { nextPos: peg$currPos, result: s0 };
  1769. return s0;
  1770. }
  1771. function peg$parseflags() {
  1772. var s0, s1;
  1773. var key = peg$currPos * 32 + 21,
  1774. cached = peg$resultsCache[key];
  1775. if (cached) {
  1776. peg$currPos = cached.nextPos;
  1777. return cached.result;
  1778. }
  1779. s0 = [];
  1780. if (peg$c72.test(input.charAt(peg$currPos))) {
  1781. s1 = input.charAt(peg$currPos);
  1782. peg$currPos++;
  1783. } else {
  1784. s1 = peg$FAILED;
  1785. if (peg$silentFails === 0) { peg$fail(peg$c73); }
  1786. }
  1787. if (s1 !== peg$FAILED) {
  1788. while (s1 !== peg$FAILED) {
  1789. s0.push(s1);
  1790. if (peg$c72.test(input.charAt(peg$currPos))) {
  1791. s1 = input.charAt(peg$currPos);
  1792. peg$currPos++;
  1793. } else {
  1794. s1 = peg$FAILED;
  1795. if (peg$silentFails === 0) { peg$fail(peg$c73); }
  1796. }
  1797. }
  1798. } else {
  1799. s0 = peg$FAILED;
  1800. }
  1801. peg$resultsCache[key] = { nextPos: peg$currPos, result: s0 };
  1802. return s0;
  1803. }
  1804. function peg$parseregex() {
  1805. var s0, s1, s2, s3, s4;
  1806. var key = peg$currPos * 32 + 22,
  1807. cached = peg$resultsCache[key];
  1808. if (cached) {
  1809. peg$currPos = cached.nextPos;
  1810. return cached.result;
  1811. }
  1812. s0 = peg$currPos;
  1813. if (input.charCodeAt(peg$currPos) === 47) {
  1814. s1 = peg$c74;
  1815. peg$currPos++;
  1816. } else {
  1817. s1 = peg$FAILED;
  1818. if (peg$silentFails === 0) { peg$fail(peg$c75); }
  1819. }
  1820. if (s1 !== peg$FAILED) {
  1821. s2 = [];
  1822. if (peg$c76.test(input.charAt(peg$currPos))) {
  1823. s3 = input.charAt(peg$currPos);
  1824. peg$currPos++;
  1825. } else {
  1826. s3 = peg$FAILED;
  1827. if (peg$silentFails === 0) { peg$fail(peg$c77); }
  1828. }
  1829. if (s3 !== peg$FAILED) {
  1830. while (s3 !== peg$FAILED) {
  1831. s2.push(s3);
  1832. if (peg$c76.test(input.charAt(peg$currPos))) {
  1833. s3 = input.charAt(peg$currPos);
  1834. peg$currPos++;
  1835. } else {
  1836. s3 = peg$FAILED;
  1837. if (peg$silentFails === 0) { peg$fail(peg$c77); }
  1838. }
  1839. }
  1840. } else {
  1841. s2 = peg$FAILED;
  1842. }
  1843. if (s2 !== peg$FAILED) {
  1844. if (input.charCodeAt(peg$currPos) === 47) {
  1845. s3 = peg$c74;
  1846. peg$currPos++;
  1847. } else {
  1848. s3 = peg$FAILED;
  1849. if (peg$silentFails === 0) { peg$fail(peg$c75); }
  1850. }
  1851. if (s3 !== peg$FAILED) {
  1852. s4 = peg$parseflags();
  1853. if (s4 === peg$FAILED) {
  1854. s4 = null;
  1855. }
  1856. if (s4 !== peg$FAILED) {
  1857. peg$savedPos = s0;
  1858. s1 = peg$c78(s2, s4);
  1859. s0 = s1;
  1860. } else {
  1861. peg$currPos = s0;
  1862. s0 = peg$FAILED;
  1863. }
  1864. } else {
  1865. peg$currPos = s0;
  1866. s0 = peg$FAILED;
  1867. }
  1868. } else {
  1869. peg$currPos = s0;
  1870. s0 = peg$FAILED;
  1871. }
  1872. } else {
  1873. peg$currPos = s0;
  1874. s0 = peg$FAILED;
  1875. }
  1876. peg$resultsCache[key] = { nextPos: peg$currPos, result: s0 };
  1877. return s0;
  1878. }
  1879. function peg$parsefield() {
  1880. var s0, s1, s2, s3, s4, s5, s6;
  1881. var key = peg$currPos * 32 + 23,
  1882. cached = peg$resultsCache[key];
  1883. if (cached) {
  1884. peg$currPos = cached.nextPos;
  1885. return cached.result;
  1886. }
  1887. s0 = peg$currPos;
  1888. if (input.charCodeAt(peg$currPos) === 46) {
  1889. s1 = peg$c43;
  1890. peg$currPos++;
  1891. } else {
  1892. s1 = peg$FAILED;
  1893. if (peg$silentFails === 0) { peg$fail(peg$c44); }
  1894. }
  1895. if (s1 !== peg$FAILED) {
  1896. s2 = peg$parseidentifierName();
  1897. if (s2 !== peg$FAILED) {
  1898. s3 = [];
  1899. s4 = peg$currPos;
  1900. if (input.charCodeAt(peg$currPos) === 46) {
  1901. s5 = peg$c43;
  1902. peg$currPos++;
  1903. } else {
  1904. s5 = peg$FAILED;
  1905. if (peg$silentFails === 0) { peg$fail(peg$c44); }
  1906. }
  1907. if (s5 !== peg$FAILED) {
  1908. s6 = peg$parseidentifierName();
  1909. if (s6 !== peg$FAILED) {
  1910. s5 = [s5, s6];
  1911. s4 = s5;
  1912. } else {
  1913. peg$currPos = s4;
  1914. s4 = peg$FAILED;
  1915. }
  1916. } else {
  1917. peg$currPos = s4;
  1918. s4 = peg$FAILED;
  1919. }
  1920. while (s4 !== peg$FAILED) {
  1921. s3.push(s4);
  1922. s4 = peg$currPos;
  1923. if (input.charCodeAt(peg$currPos) === 46) {
  1924. s5 = peg$c43;
  1925. peg$currPos++;
  1926. } else {
  1927. s5 = peg$FAILED;
  1928. if (peg$silentFails === 0) { peg$fail(peg$c44); }
  1929. }
  1930. if (s5 !== peg$FAILED) {
  1931. s6 = peg$parseidentifierName();
  1932. if (s6 !== peg$FAILED) {
  1933. s5 = [s5, s6];
  1934. s4 = s5;
  1935. } else {
  1936. peg$currPos = s4;
  1937. s4 = peg$FAILED;
  1938. }
  1939. } else {
  1940. peg$currPos = s4;
  1941. s4 = peg$FAILED;
  1942. }
  1943. }
  1944. if (s3 !== peg$FAILED) {
  1945. peg$savedPos = s0;
  1946. s1 = peg$c79(s2, s3);
  1947. s0 = s1;
  1948. } else {
  1949. peg$currPos = s0;
  1950. s0 = peg$FAILED;
  1951. }
  1952. } else {
  1953. peg$currPos = s0;
  1954. s0 = peg$FAILED;
  1955. }
  1956. } else {
  1957. peg$currPos = s0;
  1958. s0 = peg$FAILED;
  1959. }
  1960. peg$resultsCache[key] = { nextPos: peg$currPos, result: s0 };
  1961. return s0;
  1962. }
  1963. function peg$parsenegation() {
  1964. var s0, s1, s2, s3, s4, s5;
  1965. var key = peg$currPos * 32 + 24,
  1966. cached = peg$resultsCache[key];
  1967. if (cached) {
  1968. peg$currPos = cached.nextPos;
  1969. return cached.result;
  1970. }
  1971. s0 = peg$currPos;
  1972. if (input.substr(peg$currPos, 5) === peg$c80) {
  1973. s1 = peg$c80;
  1974. peg$currPos += 5;
  1975. } else {
  1976. s1 = peg$FAILED;
  1977. if (peg$silentFails === 0) { peg$fail(peg$c81); }
  1978. }
  1979. if (s1 !== peg$FAILED) {
  1980. s2 = peg$parse_();
  1981. if (s2 !== peg$FAILED) {
  1982. s3 = peg$parseselectors();
  1983. if (s3 !== peg$FAILED) {
  1984. s4 = peg$parse_();
  1985. if (s4 !== peg$FAILED) {
  1986. if (input.charCodeAt(peg$currPos) === 41) {
  1987. s5 = peg$c69;
  1988. peg$currPos++;
  1989. } else {
  1990. s5 = peg$FAILED;
  1991. if (peg$silentFails === 0) { peg$fail(peg$c70); }
  1992. }
  1993. if (s5 !== peg$FAILED) {
  1994. peg$savedPos = s0;
  1995. s1 = peg$c82(s3);
  1996. s0 = s1;
  1997. } else {
  1998. peg$currPos = s0;
  1999. s0 = peg$FAILED;
  2000. }
  2001. } else {
  2002. peg$currPos = s0;
  2003. s0 = peg$FAILED;
  2004. }
  2005. } else {
  2006. peg$currPos = s0;
  2007. s0 = peg$FAILED;
  2008. }
  2009. } else {
  2010. peg$currPos = s0;
  2011. s0 = peg$FAILED;
  2012. }
  2013. } else {
  2014. peg$currPos = s0;
  2015. s0 = peg$FAILED;
  2016. }
  2017. peg$resultsCache[key] = { nextPos: peg$currPos, result: s0 };
  2018. return s0;
  2019. }
  2020. function peg$parsematches() {
  2021. var s0, s1, s2, s3, s4, s5;
  2022. var key = peg$currPos * 32 + 25,
  2023. cached = peg$resultsCache[key];
  2024. if (cached) {
  2025. peg$currPos = cached.nextPos;
  2026. return cached.result;
  2027. }
  2028. s0 = peg$currPos;
  2029. if (input.substr(peg$currPos, 9) === peg$c83) {
  2030. s1 = peg$c83;
  2031. peg$currPos += 9;
  2032. } else {
  2033. s1 = peg$FAILED;
  2034. if (peg$silentFails === 0) { peg$fail(peg$c84); }
  2035. }
  2036. if (s1 !== peg$FAILED) {
  2037. s2 = peg$parse_();
  2038. if (s2 !== peg$FAILED) {
  2039. s3 = peg$parseselectors();
  2040. if (s3 !== peg$FAILED) {
  2041. s4 = peg$parse_();
  2042. if (s4 !== peg$FAILED) {
  2043. if (input.charCodeAt(peg$currPos) === 41) {
  2044. s5 = peg$c69;
  2045. peg$currPos++;
  2046. } else {
  2047. s5 = peg$FAILED;
  2048. if (peg$silentFails === 0) { peg$fail(peg$c70); }
  2049. }
  2050. if (s5 !== peg$FAILED) {
  2051. peg$savedPos = s0;
  2052. s1 = peg$c85(s3);
  2053. s0 = s1;
  2054. } else {
  2055. peg$currPos = s0;
  2056. s0 = peg$FAILED;
  2057. }
  2058. } else {
  2059. peg$currPos = s0;
  2060. s0 = peg$FAILED;
  2061. }
  2062. } else {
  2063. peg$currPos = s0;
  2064. s0 = peg$FAILED;
  2065. }
  2066. } else {
  2067. peg$currPos = s0;
  2068. s0 = peg$FAILED;
  2069. }
  2070. } else {
  2071. peg$currPos = s0;
  2072. s0 = peg$FAILED;
  2073. }
  2074. peg$resultsCache[key] = { nextPos: peg$currPos, result: s0 };
  2075. return s0;
  2076. }
  2077. function peg$parsehas() {
  2078. var s0, s1, s2, s3, s4, s5;
  2079. var key = peg$currPos * 32 + 26,
  2080. cached = peg$resultsCache[key];
  2081. if (cached) {
  2082. peg$currPos = cached.nextPos;
  2083. return cached.result;
  2084. }
  2085. s0 = peg$currPos;
  2086. if (input.substr(peg$currPos, 5) === peg$c86) {
  2087. s1 = peg$c86;
  2088. peg$currPos += 5;
  2089. } else {
  2090. s1 = peg$FAILED;
  2091. if (peg$silentFails === 0) { peg$fail(peg$c87); }
  2092. }
  2093. if (s1 !== peg$FAILED) {
  2094. s2 = peg$parse_();
  2095. if (s2 !== peg$FAILED) {
  2096. s3 = peg$parsehasSelectors();
  2097. if (s3 !== peg$FAILED) {
  2098. s4 = peg$parse_();
  2099. if (s4 !== peg$FAILED) {
  2100. if (input.charCodeAt(peg$currPos) === 41) {
  2101. s5 = peg$c69;
  2102. peg$currPos++;
  2103. } else {
  2104. s5 = peg$FAILED;
  2105. if (peg$silentFails === 0) { peg$fail(peg$c70); }
  2106. }
  2107. if (s5 !== peg$FAILED) {
  2108. peg$savedPos = s0;
  2109. s1 = peg$c88(s3);
  2110. s0 = s1;
  2111. } else {
  2112. peg$currPos = s0;
  2113. s0 = peg$FAILED;
  2114. }
  2115. } else {
  2116. peg$currPos = s0;
  2117. s0 = peg$FAILED;
  2118. }
  2119. } else {
  2120. peg$currPos = s0;
  2121. s0 = peg$FAILED;
  2122. }
  2123. } else {
  2124. peg$currPos = s0;
  2125. s0 = peg$FAILED;
  2126. }
  2127. } else {
  2128. peg$currPos = s0;
  2129. s0 = peg$FAILED;
  2130. }
  2131. peg$resultsCache[key] = { nextPos: peg$currPos, result: s0 };
  2132. return s0;
  2133. }
  2134. function peg$parsefirstChild() {
  2135. var s0, s1;
  2136. var key = peg$currPos * 32 + 27,
  2137. cached = peg$resultsCache[key];
  2138. if (cached) {
  2139. peg$currPos = cached.nextPos;
  2140. return cached.result;
  2141. }
  2142. s0 = peg$currPos;
  2143. if (input.substr(peg$currPos, 12) === peg$c89) {
  2144. s1 = peg$c89;
  2145. peg$currPos += 12;
  2146. } else {
  2147. s1 = peg$FAILED;
  2148. if (peg$silentFails === 0) { peg$fail(peg$c90); }
  2149. }
  2150. if (s1 !== peg$FAILED) {
  2151. peg$savedPos = s0;
  2152. s1 = peg$c91();
  2153. }
  2154. s0 = s1;
  2155. peg$resultsCache[key] = { nextPos: peg$currPos, result: s0 };
  2156. return s0;
  2157. }
  2158. function peg$parselastChild() {
  2159. var s0, s1;
  2160. var key = peg$currPos * 32 + 28,
  2161. cached = peg$resultsCache[key];
  2162. if (cached) {
  2163. peg$currPos = cached.nextPos;
  2164. return cached.result;
  2165. }
  2166. s0 = peg$currPos;
  2167. if (input.substr(peg$currPos, 11) === peg$c92) {
  2168. s1 = peg$c92;
  2169. peg$currPos += 11;
  2170. } else {
  2171. s1 = peg$FAILED;
  2172. if (peg$silentFails === 0) { peg$fail(peg$c93); }
  2173. }
  2174. if (s1 !== peg$FAILED) {
  2175. peg$savedPos = s0;
  2176. s1 = peg$c94();
  2177. }
  2178. s0 = s1;
  2179. peg$resultsCache[key] = { nextPos: peg$currPos, result: s0 };
  2180. return s0;
  2181. }
  2182. function peg$parsenthChild() {
  2183. var s0, s1, s2, s3, s4, s5;
  2184. var key = peg$currPos * 32 + 29,
  2185. cached = peg$resultsCache[key];
  2186. if (cached) {
  2187. peg$currPos = cached.nextPos;
  2188. return cached.result;
  2189. }
  2190. s0 = peg$currPos;
  2191. if (input.substr(peg$currPos, 11) === peg$c95) {
  2192. s1 = peg$c95;
  2193. peg$currPos += 11;
  2194. } else {
  2195. s1 = peg$FAILED;
  2196. if (peg$silentFails === 0) { peg$fail(peg$c96); }
  2197. }
  2198. if (s1 !== peg$FAILED) {
  2199. s2 = peg$parse_();
  2200. if (s2 !== peg$FAILED) {
  2201. s3 = [];
  2202. if (peg$c61.test(input.charAt(peg$currPos))) {
  2203. s4 = input.charAt(peg$currPos);
  2204. peg$currPos++;
  2205. } else {
  2206. s4 = peg$FAILED;
  2207. if (peg$silentFails === 0) { peg$fail(peg$c62); }
  2208. }
  2209. if (s4 !== peg$FAILED) {
  2210. while (s4 !== peg$FAILED) {
  2211. s3.push(s4);
  2212. if (peg$c61.test(input.charAt(peg$currPos))) {
  2213. s4 = input.charAt(peg$currPos);
  2214. peg$currPos++;
  2215. } else {
  2216. s4 = peg$FAILED;
  2217. if (peg$silentFails === 0) { peg$fail(peg$c62); }
  2218. }
  2219. }
  2220. } else {
  2221. s3 = peg$FAILED;
  2222. }
  2223. if (s3 !== peg$FAILED) {
  2224. s4 = peg$parse_();
  2225. if (s4 !== peg$FAILED) {
  2226. if (input.charCodeAt(peg$currPos) === 41) {
  2227. s5 = peg$c69;
  2228. peg$currPos++;
  2229. } else {
  2230. s5 = peg$FAILED;
  2231. if (peg$silentFails === 0) { peg$fail(peg$c70); }
  2232. }
  2233. if (s5 !== peg$FAILED) {
  2234. peg$savedPos = s0;
  2235. s1 = peg$c97(s3);
  2236. s0 = s1;
  2237. } else {
  2238. peg$currPos = s0;
  2239. s0 = peg$FAILED;
  2240. }
  2241. } else {
  2242. peg$currPos = s0;
  2243. s0 = peg$FAILED;
  2244. }
  2245. } else {
  2246. peg$currPos = s0;
  2247. s0 = peg$FAILED;
  2248. }
  2249. } else {
  2250. peg$currPos = s0;
  2251. s0 = peg$FAILED;
  2252. }
  2253. } else {
  2254. peg$currPos = s0;
  2255. s0 = peg$FAILED;
  2256. }
  2257. peg$resultsCache[key] = { nextPos: peg$currPos, result: s0 };
  2258. return s0;
  2259. }
  2260. function peg$parsenthLastChild() {
  2261. var s0, s1, s2, s3, s4, s5;
  2262. var key = peg$currPos * 32 + 30,
  2263. cached = peg$resultsCache[key];
  2264. if (cached) {
  2265. peg$currPos = cached.nextPos;
  2266. return cached.result;
  2267. }
  2268. s0 = peg$currPos;
  2269. if (input.substr(peg$currPos, 16) === peg$c98) {
  2270. s1 = peg$c98;
  2271. peg$currPos += 16;
  2272. } else {
  2273. s1 = peg$FAILED;
  2274. if (peg$silentFails === 0) { peg$fail(peg$c99); }
  2275. }
  2276. if (s1 !== peg$FAILED) {
  2277. s2 = peg$parse_();
  2278. if (s2 !== peg$FAILED) {
  2279. s3 = [];
  2280. if (peg$c61.test(input.charAt(peg$currPos))) {
  2281. s4 = input.charAt(peg$currPos);
  2282. peg$currPos++;
  2283. } else {
  2284. s4 = peg$FAILED;
  2285. if (peg$silentFails === 0) { peg$fail(peg$c62); }
  2286. }
  2287. if (s4 !== peg$FAILED) {
  2288. while (s4 !== peg$FAILED) {
  2289. s3.push(s4);
  2290. if (peg$c61.test(input.charAt(peg$currPos))) {
  2291. s4 = input.charAt(peg$currPos);
  2292. peg$currPos++;
  2293. } else {
  2294. s4 = peg$FAILED;
  2295. if (peg$silentFails === 0) { peg$fail(peg$c62); }
  2296. }
  2297. }
  2298. } else {
  2299. s3 = peg$FAILED;
  2300. }
  2301. if (s3 !== peg$FAILED) {
  2302. s4 = peg$parse_();
  2303. if (s4 !== peg$FAILED) {
  2304. if (input.charCodeAt(peg$currPos) === 41) {
  2305. s5 = peg$c69;
  2306. peg$currPos++;
  2307. } else {
  2308. s5 = peg$FAILED;
  2309. if (peg$silentFails === 0) { peg$fail(peg$c70); }
  2310. }
  2311. if (s5 !== peg$FAILED) {
  2312. peg$savedPos = s0;
  2313. s1 = peg$c100(s3);
  2314. s0 = s1;
  2315. } else {
  2316. peg$currPos = s0;
  2317. s0 = peg$FAILED;
  2318. }
  2319. } else {
  2320. peg$currPos = s0;
  2321. s0 = peg$FAILED;
  2322. }
  2323. } else {
  2324. peg$currPos = s0;
  2325. s0 = peg$FAILED;
  2326. }
  2327. } else {
  2328. peg$currPos = s0;
  2329. s0 = peg$FAILED;
  2330. }
  2331. } else {
  2332. peg$currPos = s0;
  2333. s0 = peg$FAILED;
  2334. }
  2335. peg$resultsCache[key] = { nextPos: peg$currPos, result: s0 };
  2336. return s0;
  2337. }
  2338. function peg$parseclass() {
  2339. var s0, s1, s2;
  2340. var key = peg$currPos * 32 + 31,
  2341. cached = peg$resultsCache[key];
  2342. if (cached) {
  2343. peg$currPos = cached.nextPos;
  2344. return cached.result;
  2345. }
  2346. s0 = peg$currPos;
  2347. if (input.charCodeAt(peg$currPos) === 58) {
  2348. s1 = peg$c101;
  2349. peg$currPos++;
  2350. } else {
  2351. s1 = peg$FAILED;
  2352. if (peg$silentFails === 0) { peg$fail(peg$c102); }
  2353. }
  2354. if (s1 !== peg$FAILED) {
  2355. s2 = peg$parseidentifierName();
  2356. if (s2 !== peg$FAILED) {
  2357. peg$savedPos = s0;
  2358. s1 = peg$c103(s2);
  2359. s0 = s1;
  2360. } else {
  2361. peg$currPos = s0;
  2362. s0 = peg$FAILED;
  2363. }
  2364. } else {
  2365. peg$currPos = s0;
  2366. s0 = peg$FAILED;
  2367. }
  2368. peg$resultsCache[key] = { nextPos: peg$currPos, result: s0 };
  2369. return s0;
  2370. }
  2371. function nth(n) { return { type: 'nth-child', index: { type: 'literal', value: n } }; }
  2372. function nthLast(n) { return { type: 'nth-last-child', index: { type: 'literal', value: n } }; }
  2373. function strUnescape(s) {
  2374. return s.replace(/\\(.)/g, function(match, ch) {
  2375. switch(ch) {
  2376. case 'b': return '\b';
  2377. case 'f': return '\f';
  2378. case 'n': return '\n';
  2379. case 'r': return '\r';
  2380. case 't': return '\t';
  2381. case 'v': return '\v';
  2382. default: return ch;
  2383. }
  2384. });
  2385. }
  2386. peg$result = peg$startRuleFunction();
  2387. if (peg$result !== peg$FAILED && peg$currPos === input.length) {
  2388. return peg$result;
  2389. } else {
  2390. if (peg$result !== peg$FAILED && peg$currPos < input.length) {
  2391. peg$fail(peg$endExpectation());
  2392. }
  2393. throw peg$buildStructuredError(
  2394. peg$maxFailExpected,
  2395. peg$maxFailPos < input.length ? input.charAt(peg$maxFailPos) : null,
  2396. peg$maxFailPos < input.length
  2397. ? peg$computeLocation(peg$maxFailPos, peg$maxFailPos + 1)
  2398. : peg$computeLocation(peg$maxFailPos, peg$maxFailPos)
  2399. );
  2400. }
  2401. }
  2402. return {
  2403. SyntaxError: peg$SyntaxError,
  2404. parse: peg$parse
  2405. };
  2406. });