MCPcopy
hub / github.com/josdejong/mathjs / parseStart

Function parseStart

src/expression/parse.js:614–635  ·  view source on GitHub ↗

* Start of the parse levels below, in order of precedence * @return {Node} node * @private

(expression, extraNodes)

Source from the content-addressed store, hash-verified

612 * @private
613 */
614 function parseStart (expression, extraNodes) {
615 const state = initialState()
616 Object.assign(state, { expression, extraNodes })
617 getToken(state)
618
619 const node = parseBlock(state)
620
621 // check for garbage at the end of the expression
622 // an expression ends with a empty character '' and tokenType DELIMITER
623 if (state.token !== '') {
624 if (state.tokenType === TOKENTYPE.DELIMITER) {
625 // user entered a not existing operator like "//"
626
627 // TODO: give hints for aliases, for example with "<>" give as hint " did you mean !== ?"
628 throw createError(state, 'Unexpected operator ' + state.token)
629 } else {
630 throw createSyntaxError(state, 'Unexpected part "' + state.token + '"')
631 }
632 }
633
634 return node
635 }
636
637 /**
638 * Parse a block with expressions. Expressions can be separated by a newline

Callers 2

parse.jsFile · 0.85
parseMultipleFunction · 0.85

Calls 5

initialStateFunction · 0.85
getTokenFunction · 0.85
parseBlockFunction · 0.85
createErrorFunction · 0.85
createSyntaxErrorFunction · 0.85

Tested by

no test coverage detected

Used in the wild real call sites across dependent graphs

searching dependent graphs…