MCPcopy Create free account
hub / github.com/objectivehtml/FlipClock / peg$parse

Function peg$parse

src/helpers/parser.js:156–498  ·  view source on GitHub ↗
(input, options)

Source from the content-addressed store, hash-verified

154}
155
156function peg$parse(input, options) {
157 options = options !== undefined ? options : {};
158
159 const peg$FAILED = {};
160 const peg$source = options.grammarSource;
161
162 const peg$startRuleFunctions = {
163 array: peg$parsearray,
164 };
165 let peg$startRuleFunction = peg$parsearray;
166
167 const peg$c0 = "[";
168 const peg$c1 = "]";
169
170 const peg$r0 = /^[[\]]/;
171
172 const peg$e0 = peg$literalExpectation("[", false);
173 const peg$e1 = peg$literalExpectation("]", false);
174 const peg$e2 = peg$classExpectation(["[", "]"], false, false, false);
175 const peg$e3 = peg$anyExpectation();
176
177 function peg$f0(value) { return () => value; }
178 function peg$f1(value) { return value; }
179 function peg$f2(value) {
180 for (const item of value) {
181 if (typeof item === 'function') {
182 value.splice(value.indexOf(item), 1, ...item());
183 }
184 }
185
186 return value;
187 }
188 function peg$f3(value) { return value.flat(1).filter(Boolean); }
189 let peg$currPos = options.peg$currPos | 0;
190 let peg$savedPos = peg$currPos;
191 const peg$posDetailsCache = [{ line: 1, column: 1 }];
192 let peg$maxFailPos = peg$currPos;
193 let peg$maxFailExpected = options.peg$maxFailExpected || [];
194 let peg$silentFails = options.peg$silentFails | 0;
195
196 let peg$result;
197
198 if (options.startRule) {
199 if (!(options.startRule in peg$startRuleFunctions)) {
200 throw new Error("Can't start parsing from rule \"" + options.startRule + "\".");
201 }
202
203 peg$startRuleFunction = peg$startRuleFunctions[options.startRule];
204 }
205
206 function peg$getUnicode(pos = peg$currPos) {
207 const cp = input.codePointAt(pos);
208 if (cp === undefined) {
209 return "";
210 }
211 return String.fromCodePoint(cp);
212 }
213

Callers

nothing calls this directly

Calls 4

peg$literalExpectationFunction · 0.85
peg$classExpectationFunction · 0.85
peg$anyExpectationFunction · 0.85
peg$throwFunction · 0.85

Tested by

no test coverage detected