parser.js 69 KB

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