parseExpression
API / publicodes / parseExpression
function parseExpression(rawNode, dottedName): ExprAST
Experimental
Parse a publicodes expression into an JSON object representing the AST.
The parsing is done with the nearley parser
Parameters
Parameter | Type | Description |
---|---|---|
rawNode | string | The expression to parse |
dottedName | string | The dottedName of the rule being parsed |
Returns
The parsing result as a JSON object
Throws
A SyntaxError
if the expression is invalid
Throws
A PublicodesInternalError
if the parser is unable to parse the expression
Example
parseExpression('20.3 * nombre', 'foo . bar')
// returns { "*": [ { constant: { type: "number", nodeValue: 20.3 } }, { variable:"nombre" } ] }