Software zum Installieren eines Smart-Mirror Frameworks , zum Nutzen von hochschulrelevanten Informationen, auf einem Raspberry-Pi.
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

parser.js 70KB

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