MCPcopy Index your code
hub / github.com/bigskysoftware/_hyperscript / parse

Method parse

src/core/kernel.js:428–455  ·  view source on GitHub ↗
(tokenizer, src)

Source from the content-addressed store, hash-verified

426 }
427
428 parse(tokenizer, src) {
429 var tokens = tokenizer.tokenize(src);
430 var parser = new Parser(this, tokens);
431 var result, lastError;
432 try {
433 if (parser.commandStart(tokens.currentToken())) {
434 result = this.requireElement("commandList", parser);
435 if (tokens.hasMore()) parser.raiseError();
436 parser.ensureTerminated(result);
437 } else if (parser.featureStart(tokens.currentToken())) {
438 result = this.requireElement("hyperscript", parser);
439 if (tokens.hasMore()) parser.raiseError();
440 } else {
441 result = this.requireElement("expression", parser);
442 if (tokens.hasMore()) parser.raiseError();
443 }
444 } catch (e) {
445 if (!(e instanceof ParseRecoverySentinel)) throw e;
446 lastError = e.parseError;
447 }
448 if (!result && lastError) {
449 result = { type: "empty", errors: [lastError] };
450 } else if (result) {
451 result.errors = result.collectErrors();
452 if (lastError) result.errors.push(lastError);
453 }
454 return result;
455 }
456
457}

Callers 1

conversions.jsFile · 0.45

Calls 9

commandStartMethod · 0.95
requireElementMethod · 0.95
raiseErrorMethod · 0.95
ensureTerminatedMethod · 0.95
featureStartMethod · 0.95
tokenizeMethod · 0.45
currentTokenMethod · 0.45
hasMoreMethod · 0.45
collectErrorsMethod · 0.45

Tested by

no test coverage detected