* Parse a custom node handler. A node handler can be used to process * nodes in a custom way, for example for handling a plot. * * A handler must be passed as second argument of the parse function. * - must extend math.Node * - must contain a function _compile(defs: Object) : string
(state)
| 1335 | * @private |
| 1336 | */ |
| 1337 | function parseCustomNodes (state) { |
| 1338 | let params = [] |
| 1339 | |
| 1340 | if (state.tokenType === TOKENTYPE.SYMBOL && hasOwnProperty(state.extraNodes, state.token)) { |
| 1341 | const CustomNode = state.extraNodes[state.token] |
| 1342 | |
| 1343 | getToken(state) |
| 1344 | |
| 1345 | // parse parameters |
| 1346 | if (state.token === '(') { |
| 1347 | params = [] |
| 1348 | |
| 1349 | openParams(state) |
| 1350 | getToken(state) |
| 1351 | |
| 1352 | if (state.token !== ')') { |
| 1353 | params.push(parseAssignment(state)) |
| 1354 | |
| 1355 | // parse a list with parameters |
| 1356 | while (state.token === ',') { // eslint-disable-line no-unmodified-loop-condition |
| 1357 | getToken(state) |
| 1358 | params.push(parseAssignment(state)) |
| 1359 | } |
| 1360 | } |
| 1361 | |
| 1362 | if (state.token !== ')') { |
| 1363 | throw createSyntaxError(state, 'Parenthesis ) expected') |
| 1364 | } |
| 1365 | closeParams(state) |
| 1366 | getToken(state) |
| 1367 | } |
| 1368 | |
| 1369 | // create a new custom node |
| 1370 | // noinspection JSValidateTypes |
| 1371 | return new CustomNode(params) |
| 1372 | } |
| 1373 | |
| 1374 | return parseSymbol(state) |
| 1375 | } |
| 1376 | |
| 1377 | /** |
| 1378 | * parse symbols: functions, variables, constants, units |
no test coverage detected
searching dependent graphs…