Skip to content

Function parser

Adam Dernis edited this page May 22, 2020 · 2 revisions

Functions are parsed in a function parser. The root parser determines which function parser should be used. When a function is being parsed, all characters are forwarded from the root parser to the function parser until the function parser returns a node for the expression tree (this node is guaranteed to by an operator node). After a node is returned, the function parser is deleted and the node is added to the root tree as a child of the active_node.

Each function parser keeps track of depth_. Most rely on '{' to indicate the start and '}' to close. The depth is used to determine if a '}' is used for closing the current function or a child function. depth_ is incremented for every '{' and decremented for every '}'.

Sample: 5*\sin{5x+\sin{10}}

Clone this wiki locally