Skip to content

Commit

Permalink
check unsupported syntax in expressions
Browse files Browse the repository at this point in the history
  • Loading branch information
metelkin committed Feb 7, 2024
1 parent 89972be commit 2d8a465
Showing 1 changed file with 12 additions and 0 deletions.
12 changes: 12 additions & 0 deletions src/core/expression.js
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,18 @@ class Expression {
throw new TypeError('Cannot parse MathExpr properly. ' + e.message);
}

// Check BlockNode and other unsupported syntax
let supportedNodeTypes = [
'SymbolNode', 'OperatorNode', 'FunctionNode', 'ConstantNode', 'ParenthesisNode',
'ConditionalNode',
];
let unsupportedNodes = exprParsed.filter((node) => {
return supportedNodeTypes.indexOf(node.type) === -1;
});
if (unsupportedNodes.length > 0) {
throw new TypeError('Unsupported MathExpr syntax');
}

// additional check of expressions
exprParsed.traverse((node) => { // recursive forEach
/*if (node.type === 'ConditionalNode') { // check that ternary has boolean expression
Expand Down

0 comments on commit 2d8a465

Please sign in to comment.