parser.js 77 KB

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