将匹配模式组合成单次传递

Combining match patterns into a single pass

谁能告诉我可以使用哪些算法、学术论文和框架来允许单次传递具有任意数量匹配模式的数据?

任何 regular grammar, i.e. matches that can be described without referring to other parts of the input (such as matching brackets), can be implemented as a deterministic finite automaton and matched very efficiently in one pass. Multiple regular expressions/finite automata can be merged using the powerset construction 算法(通过将输入 DFA 视为 NFA)。

至于需要context-free grammars, algorithms generally need only one top-to-bottom pass. However, some algorithms require backtracking i.e. rewinding guesses, therefore reading part of the input more than once (possible several times). Specifically, if your grammar can be written as LR, it can be parsed without backtracking, otherwise a backtracking LL parser的更复杂的匹配。

您可以在 this post.

中找到更多具体信息