MCPcopy Create free account
hub / github.com/estools/esquery / peg$parse

Function peg$parse

parser.js:142–2688  ·  view source on GitHub ↗
(input, options)

Source from the content-addressed store, hash-verified

140 };
141
142 function peg$parse(input, options) {
143 options = options !== void 0 ? options : {};
144
145 var peg$FAILED = {},
146
147 peg$startRuleFunctions = { start: peg$parsestart },
148 peg$startRuleFunction = peg$parsestart,
149
150 peg$c0 = function(ss) {
151 return ss.length === 1 ? ss[0] : { type: 'matches', selectors: ss };
152 },
153 peg$c1 = function() { return void 0; },
154 peg$c2 = " ",
155 peg$c3 = peg$literalExpectation(" ", false),
156 peg$c4 = /^[^ [\],():#!=><~+.]/,
157 peg$c5 = peg$classExpectation([" ", "[", "]", ",", "(", ")", ":", "#", "!", "=", ">", "<", "~", "+", "."], true, false),
158 peg$c6 = function(i) { return i.join(''); },
159 peg$c7 = ">",
160 peg$c8 = peg$literalExpectation(">", false),
161 peg$c9 = function() { return 'child'; },
162 peg$c10 = "~",
163 peg$c11 = peg$literalExpectation("~", false),
164 peg$c12 = function() { return 'sibling'; },
165 peg$c13 = "+",
166 peg$c14 = peg$literalExpectation("+", false),
167 peg$c15 = function() { return 'adjacent'; },
168 peg$c16 = function() { return 'descendant'; },
169 peg$c17 = ",",
170 peg$c18 = peg$literalExpectation(",", false),
171 peg$c19 = function(s, ss) {
172 return [s].concat(ss.map(function (s) { return s[3]; }));
173 },
174 peg$c20 = function(op, s) {
175 if (!op) return s;
176 return { type: op, left: { type: 'exactNode' }, right: s };
177 },
178 peg$c21 = function(a, ops) {
179 return ops.reduce(function (memo, rhs) {
180 return { type: rhs[0], left: memo, right: rhs[1] };
181 }, a);
182 },
183 peg$c22 = "!",
184 peg$c23 = peg$literalExpectation("!", false),
185 peg$c24 = function(subject, as) {
186 const b = as.length === 1 ? as[0] : { type: 'compound', selectors: as };
187 if(subject) b.subject = true;
188 return b;
189 },
190 peg$c25 = "*",
191 peg$c26 = peg$literalExpectation("*", false),
192 peg$c27 = function(a) { return { type: 'wildcard', value: a }; },
193 peg$c28 = "#",
194 peg$c29 = peg$literalExpectation("#", false),
195 peg$c30 = function(i) { return { type: 'identifier', value: i }; },
196 peg$c31 = "[",
197 peg$c32 = peg$literalExpectation("[", false),
198 peg$c33 = "]",
199 peg$c34 = peg$literalExpectation("]", false),

Callers

nothing calls this directly

Calls 7

peg$literalExpectationFunction · 0.85
peg$classExpectationFunction · 0.85
peg$anyExpectationFunction · 0.85
peg$failFunction · 0.85
peg$endExpectationFunction · 0.85
peg$buildStructuredErrorFunction · 0.85
peg$computeLocationFunction · 0.85

Tested by

no test coverage detected