|
input/tex/StackItem.ts
* TeX parsing in MathJax is essentially implemented via a nested stack automaton. That is the tex parser works on a stack, and each item on the stack can have a data stack of its own. Data on the stack is either a stack item or a node.
* The checkItem method effectively implements the recursive checking of input data from the parser against data recursively given on the stack.
* I.e., new input is parsed resulting in a new item. When pushed on the stack it is checked against the top most item on the stack. This either leads to the item being pushed onto the stack or combined with the top most element(s), pushing a new item, which is recursively checked, unless an error is thrown.
* A simple example: If \\end{foo} is parsed, an endItem is created, pushed on the stack. Nodes on the stack are collapsed into content of the 'foo' environment, until a beginItem for 'foo' is found. If a beginItem is not for 'foo' or does not exist an error is thrown.
en.wikipedia.org/wiki/Nested_stack_automaton |
|