从EBNF到PEG

Roman R. Redziejowski
{"title":"从EBNF到PEG","authors":"Roman R. Redziejowski","doi":"10.3233/FI-2013-940","DOIUrl":null,"url":null,"abstract":"Parsing Expression Grammar PEG encodes a recursive-descent parser with limited backtracking. The parser has many useful properties, and with the use of memoization, it works in a linear time. In its appearance, PEG is almost identical to a grammar in Extended Backus-Naur Form EBNF, but usually defines a different language. However, in some cases only minor typographical changes are sufficient to convert an EBNF grammar into its PEG parser. As recently shown by Medeiros, this is, in particular, true for LL1 grammars. But this is also true for many non-LL1 grammars, which is interesting because the backtracking of PEG is often a convenient way to circumvent just the LL1 restriction. We formulate a number of conditions for EBNF grammar to become its own PEG parser, and arrive at a condition that we call LL1p, meaning that a top-down parser can choose its next action by looking at the input within the reach of one parsing procedure rather than by looking at the next letter. An extension to LLkp for k > 1 seems possible.","PeriodicalId":286395,"journal":{"name":"International Workshop on Concurrency, Specification and Programming","volume":"19 1","pages":"0"},"PeriodicalIF":0.0000,"publicationDate":"1900-01-01","publicationTypes":"Journal Article","fieldsOfStudy":null,"isOpenAccess":false,"openAccessPdf":"","citationCount":"10","resultStr":"{\"title\":\"From EBNF to PEG\",\"authors\":\"Roman R. Redziejowski\",\"doi\":\"10.3233/FI-2013-940\",\"DOIUrl\":null,\"url\":null,\"abstract\":\"Parsing Expression Grammar PEG encodes a recursive-descent parser with limited backtracking. The parser has many useful properties, and with the use of memoization, it works in a linear time. In its appearance, PEG is almost identical to a grammar in Extended Backus-Naur Form EBNF, but usually defines a different language. However, in some cases only minor typographical changes are sufficient to convert an EBNF grammar into its PEG parser. As recently shown by Medeiros, this is, in particular, true for LL1 grammars. But this is also true for many non-LL1 grammars, which is interesting because the backtracking of PEG is often a convenient way to circumvent just the LL1 restriction. We formulate a number of conditions for EBNF grammar to become its own PEG parser, and arrive at a condition that we call LL1p, meaning that a top-down parser can choose its next action by looking at the input within the reach of one parsing procedure rather than by looking at the next letter. An extension to LLkp for k > 1 seems possible.\",\"PeriodicalId\":286395,\"journal\":{\"name\":\"International Workshop on Concurrency, Specification and Programming\",\"volume\":\"19 1\",\"pages\":\"0\"},\"PeriodicalIF\":0.0000,\"publicationDate\":\"1900-01-01\",\"publicationTypes\":\"Journal Article\",\"fieldsOfStudy\":null,\"isOpenAccess\":false,\"openAccessPdf\":\"\",\"citationCount\":\"10\",\"resultStr\":null,\"platform\":\"Semanticscholar\",\"paperid\":null,\"PeriodicalName\":\"International Workshop on Concurrency, Specification and Programming\",\"FirstCategoryId\":\"1085\",\"ListUrlMain\":\"https://doi.org/10.3233/FI-2013-940\",\"RegionNum\":0,\"RegionCategory\":null,\"ArticlePicture\":[],\"TitleCN\":null,\"AbstractTextCN\":null,\"PMCID\":null,\"EPubDate\":\"\",\"PubModel\":\"\",\"JCR\":\"\",\"JCRName\":\"\",\"Score\":null,\"Total\":0}","platform":"Semanticscholar","paperid":null,"PeriodicalName":"International Workshop on Concurrency, Specification and Programming","FirstCategoryId":"1085","ListUrlMain":"https://doi.org/10.3233/FI-2013-940","RegionNum":0,"RegionCategory":null,"ArticlePicture":[],"TitleCN":null,"AbstractTextCN":null,"PMCID":null,"EPubDate":"","PubModel":"","JCR":"","JCRName":"","Score":null,"Total":0}
引用次数: 10

摘要

解析表达式语法PEG编码一个具有有限回溯的递归下降解析器。解析器有许多有用的属性,通过使用记忆,它可以在线性时间内工作。从外观上看,PEG几乎与扩展backus - aur形式EBNF中的语法相同,但通常定义的是不同的语言。但是,在某些情况下,只需对排版进行微小的更改就足以将EBNF语法转换为其PEG解析器。正如Medeiros最近所展示的,这对于LL1语法来说尤其正确。但是对于许多非LL1语法也是如此,这很有趣,因为PEG的回溯通常是绕过LL1限制的方便方法。我们为EBNF语法制定了许多条件,使其成为自己的PEG解析器,并达到了我们称为LL1p的条件,这意味着自顶向下的解析器可以通过查看一个解析过程范围内的输入来选择下一个动作,而不是查看下一个字母。对k > 1的LLkp的扩展似乎是可能的。
本文章由计算机程序翻译,如有差异,请以英文原文为准。
From EBNF to PEG
Parsing Expression Grammar PEG encodes a recursive-descent parser with limited backtracking. The parser has many useful properties, and with the use of memoization, it works in a linear time. In its appearance, PEG is almost identical to a grammar in Extended Backus-Naur Form EBNF, but usually defines a different language. However, in some cases only minor typographical changes are sufficient to convert an EBNF grammar into its PEG parser. As recently shown by Medeiros, this is, in particular, true for LL1 grammars. But this is also true for many non-LL1 grammars, which is interesting because the backtracking of PEG is often a convenient way to circumvent just the LL1 restriction. We formulate a number of conditions for EBNF grammar to become its own PEG parser, and arrive at a condition that we call LL1p, meaning that a top-down parser can choose its next action by looking at the input within the reach of one parsing procedure rather than by looking at the next letter. An extension to LLkp for k > 1 seems possible.
求助全文
通过发布文献求助,成功后即可免费获取论文全文。 去求助
来源期刊
自引率
0.00%
发文量
0
×
引用
GB/T 7714-2015
复制
MLA
复制
APA
复制
导出至
BibTeX EndNote RefMan NoteFirst NoteExpress
×
提示
您的信息不完整,为了账户安全,请先补充。
现在去补充
×
提示
您因"违规操作"
具体请查看互助需知
我知道了
×
提示
确定
请完成安全验证×
copy
已复制链接
快去分享给好友吧!
我知道了
右上角分享
点击右上角分享
0
联系我们:info@booksci.cn Book学术提供免费学术资源搜索服务,方便国内外学者检索中英文文献。致力于提供最便捷和优质的服务体验。 Copyright © 2023 布克学术 All rights reserved.
京ICP备2023020795号-1
ghs 京公网安备 11010802042870号
Book学术文献互助
Book学术文献互助群
群 号:481959085
Book学术官方微信