找回密码
 快速注册
搜索
查看: 59|回复: 0

嵌套堆栈自动机

[复制链接]

3149

主题

8386

回帖

6万

积分

$\style{scale:11;fill:#eff}꩜$

积分
65391
QQ

显示全部楼层

hbghlyj 发表于 2022-9-3 10:07 |阅读模式
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

手机版|悠闲数学娱乐论坛(第3版)

GMT+8, 2025-3-4 15:30

Powered by Discuz!

× 快速回复 返回顶部 返回列表