【24h】

Parsing expression grammars

机译:解析表达语法

获取原文

摘要

For decades we have been using Chomsky's generative system of grammars, particularly context-free grammars (CFGs) and regular expressions (REs), to express the syntax of programming languages and protocols. The power of generative grammars to express ambiguity is crucial to their original purpose of modelling natural languages, but this very power makes it unnecessarily difficult both to express and to parse machine-oriented languages using CFGs. Parsing Expression Grammars (PEGs) provide an alternative, recognition-based formal foundation for describing machine-oriented syntax, which solves the ambiguity problem by not introducing ambiguity in the first place. Where CFGs express nondeterministic choice between alternatives, PEGs instead use prioritized choice. PEGs address frequently felt expressiveness limitations of CFGs and REs, simplifying syntax definitions and making it unnecessary to separate their lexical and hierarchical components. A linear-time parser can be built for any PEG, avoiding both the complexity and fickleness of LR parsers and the inefficiency of generalized CFG parsing. While PEGs provide a rich set of operators for constructing grammars, they are reducible to two minimal recognition schemas developed around 1970, TS/TDPL and gTS/GTDPL, which are here proven equivalent in effective recognition power.
机译:数十年来,我们一直在使用乔姆斯基的语法生成系统,尤其是无上下文语法(CFG)和正则表达式(RE)来表达编程语言和协议的语法。生成语法表达歧义的能力对于其建模自然语言的初衷至关重要,但是这种能力使得使用CFG来表达和解析面向机器的语言变得不必要地困难。语法分析语法(PEG)为描述面向机器的语法提供了另一种基于识别的形式化基础,该语法通过首先不引入歧义来解决歧义问题。如果CFG在替代方案之间表达不确定性选择,则PEG会使用优先选择。 PEG解决了CFG和RE经常表现出的表达限制,简化了语法定义,并且没有必要分离其词法和层次结构组成部分。可以为任何PEG构建线性时间解析器,从而避免了LR解析器的复杂性和灵活性以及通用CFG解析的效率低下。尽管PEG为构建语法提供了丰富的运算符集,但它们可简化为1970年左右开发的两种最小识别方案,即TS / TDPL和gTS / GTDPL,在这里,它们被证明等效于有效的识别能力。

著录项

相似文献

  • 外文文献
  • 中文文献
  • 专利
获取原文

客服邮箱:kefu@zhangqiaokeyan.com

京公网安备:11010802029741号 ICP备案号:京ICP备15016152号-6 六维联合信息科技 (北京) 有限公司©版权所有
  • 客服微信

  • 服务号