基于标记故障的解析表达式语法错误恢复及其在解析机上的实现

Sérgio Queiroz de Medeiros , Fabio Mascarenhas
{"title":"基于标记故障的解析表达式语法错误恢复及其在解析机上的实现","authors":"Sérgio Queiroz de Medeiros ,&nbsp;Fabio Mascarenhas","doi":"10.1016/j.jvlc.2018.10.003","DOIUrl":null,"url":null,"abstract":"<div><p><span>Parsing Expression Grammars (PEGs) are a formalism used to describe top-down parsers with backtracking. As PEGs do not provide a good error recovery mechanism, PEG-based parsers usually do not recover from syntax errors in the input, or recover from syntax errors using ad-hoc, implementation-specific features. The lack of proper error recovery makes PEG parsers unsuitable for use with Integrated Development Environments (IDEs), which need to build </span>syntactic trees even for incomplete, syntactically invalid programs.</p><p>We discuss a conservative extension, based on PEGs with labeled failures, that adds a syntax error recovery mechanism for PEGs. This extension associates <em>recovery expressions</em><span>to labels, where a label now not only reports a syntax error but also uses this recovery expression to reach a synchronization point<span> in the input and resume parsing. We give an operational semantics of PEGs with this recovery mechanism, as well as an operational semantics for a </span></span><em>parsing machine</em><span>that we can translate labeled PEGs with error recovery to, and prove the correctness of this translation. We use an implementation of labeled PEGs with error recovery via a parsing machine to build robust parsers, which use different recovery strategies, for the Lua language. We evaluate the effectiveness of these parsers, alone and in comparison with a Lua parser with automatic error recovery generated by ANTLR, a popular parser generator .</span></p></div>","PeriodicalId":54754,"journal":{"name":"Journal of Visual Languages and Computing","volume":"49 ","pages":"Pages 17-28"},"PeriodicalIF":0.0000,"publicationDate":"2018-12-01","publicationTypes":"Journal Article","fieldsOfStudy":null,"isOpenAccess":false,"openAccessPdf":"https://sci-hub-pdf.com/10.1016/j.jvlc.2018.10.003","citationCount":"3","resultStr":"{\"title\":\"Error recovery in parsing expression grammars through labeled failures and its implementation based on a parsing machine\",\"authors\":\"Sérgio Queiroz de Medeiros ,&nbsp;Fabio Mascarenhas\",\"doi\":\"10.1016/j.jvlc.2018.10.003\",\"DOIUrl\":null,\"url\":null,\"abstract\":\"<div><p><span>Parsing Expression Grammars (PEGs) are a formalism used to describe top-down parsers with backtracking. As PEGs do not provide a good error recovery mechanism, PEG-based parsers usually do not recover from syntax errors in the input, or recover from syntax errors using ad-hoc, implementation-specific features. The lack of proper error recovery makes PEG parsers unsuitable for use with Integrated Development Environments (IDEs), which need to build </span>syntactic trees even for incomplete, syntactically invalid programs.</p><p>We discuss a conservative extension, based on PEGs with labeled failures, that adds a syntax error recovery mechanism for PEGs. This extension associates <em>recovery expressions</em><span>to labels, where a label now not only reports a syntax error but also uses this recovery expression to reach a synchronization point<span> in the input and resume parsing. We give an operational semantics of PEGs with this recovery mechanism, as well as an operational semantics for a </span></span><em>parsing machine</em><span>that we can translate labeled PEGs with error recovery to, and prove the correctness of this translation. We use an implementation of labeled PEGs with error recovery via a parsing machine to build robust parsers, which use different recovery strategies, for the Lua language. We evaluate the effectiveness of these parsers, alone and in comparison with a Lua parser with automatic error recovery generated by ANTLR, a popular parser generator .</span></p></div>\",\"PeriodicalId\":54754,\"journal\":{\"name\":\"Journal of Visual Languages and Computing\",\"volume\":\"49 \",\"pages\":\"Pages 17-28\"},\"PeriodicalIF\":0.0000,\"publicationDate\":\"2018-12-01\",\"publicationTypes\":\"Journal Article\",\"fieldsOfStudy\":null,\"isOpenAccess\":false,\"openAccessPdf\":\"https://sci-hub-pdf.com/10.1016/j.jvlc.2018.10.003\",\"citationCount\":\"3\",\"resultStr\":null,\"platform\":\"Semanticscholar\",\"paperid\":null,\"PeriodicalName\":\"Journal of Visual Languages and Computing\",\"FirstCategoryId\":\"1085\",\"ListUrlMain\":\"https://www.sciencedirect.com/science/article/pii/S1045926X18301897\",\"RegionNum\":0,\"RegionCategory\":null,\"ArticlePicture\":[],\"TitleCN\":null,\"AbstractTextCN\":null,\"PMCID\":null,\"EPubDate\":\"\",\"PubModel\":\"\",\"JCR\":\"Q3\",\"JCRName\":\"Computer Science\",\"Score\":null,\"Total\":0}","platform":"Semanticscholar","paperid":null,"PeriodicalName":"Journal of Visual Languages and Computing","FirstCategoryId":"1085","ListUrlMain":"https://www.sciencedirect.com/science/article/pii/S1045926X18301897","RegionNum":0,"RegionCategory":null,"ArticlePicture":[],"TitleCN":null,"AbstractTextCN":null,"PMCID":null,"EPubDate":"","PubModel":"","JCR":"Q3","JCRName":"Computer Science","Score":null,"Total":0}
引用次数: 3

摘要

解析表达式语法(PEG)是一种形式主义,用于描述具有回溯的自上而下的解析器。由于PEG不能提供良好的错误恢复机制,基于PEG的解析器通常不会从输入中的语法错误中恢复,也不会使用特定于实现的特殊功能从语法错误中进行恢复。由于缺乏正确的错误恢复,PEG解析器不适合与集成开发环境(IDE)一起使用,即使对于不完整、语法无效的程序,IDE也需要构建语法树。我们讨论了一个基于带有标记故障的PEG的保守扩展,该扩展为PEG添加了语法错误恢复机制。此扩展将恢复表达式与标签相关联,其中标签现在不仅报告语法错误,还使用此恢复表达式到达输入中的同步点并恢复解析。我们给出了具有这种恢复机制的PEG的操作语义,以及我们可以将带有错误恢复的标记PEG翻译到的解析机的操作语义。并证明了这种翻译的正确性。我们通过解析机使用带错误恢复的标记PEG的实现来为Lua语言构建健壮的解析器,该解析器使用不同的恢复策略。我们单独评估了这些解析器的有效性,并与流行的解析器生成器ANTLR生成的具有自动错误恢复功能的Lua解析器进行了比较。
本文章由计算机程序翻译,如有差异,请以英文原文为准。
查看原文
分享 分享
微信好友 朋友圈 QQ好友 复制链接
本刊更多论文
Error recovery in parsing expression grammars through labeled failures and its implementation based on a parsing machine

Parsing Expression Grammars (PEGs) are a formalism used to describe top-down parsers with backtracking. As PEGs do not provide a good error recovery mechanism, PEG-based parsers usually do not recover from syntax errors in the input, or recover from syntax errors using ad-hoc, implementation-specific features. The lack of proper error recovery makes PEG parsers unsuitable for use with Integrated Development Environments (IDEs), which need to build syntactic trees even for incomplete, syntactically invalid programs.

We discuss a conservative extension, based on PEGs with labeled failures, that adds a syntax error recovery mechanism for PEGs. This extension associates recovery expressionsto labels, where a label now not only reports a syntax error but also uses this recovery expression to reach a synchronization point in the input and resume parsing. We give an operational semantics of PEGs with this recovery mechanism, as well as an operational semantics for a parsing machinethat we can translate labeled PEGs with error recovery to, and prove the correctness of this translation. We use an implementation of labeled PEGs with error recovery via a parsing machine to build robust parsers, which use different recovery strategies, for the Lua language. We evaluate the effectiveness of these parsers, alone and in comparison with a Lua parser with automatic error recovery generated by ANTLR, a popular parser generator .

求助全文
通过发布文献求助,成功后即可免费获取论文全文。 去求助
来源期刊
Journal of Visual Languages and Computing
Journal of Visual Languages and Computing 工程技术-计算机:软件工程
CiteScore
1.62
自引率
0.00%
发文量
0
审稿时长
26.8 weeks
期刊介绍: The Journal of Visual Languages and Computing is a forum for researchers, practitioners, and developers to exchange ideas and results for the advancement of visual languages and its implication to the art of computing. The journal publishes research papers, state-of-the-art surveys, and review articles in all aspects of visual languages.
期刊最新文献
Editorial Board Error recovery in parsing expression grammars through labeled failures and its implementation based on a parsing machine Visual augmentation of source code editors: A systematic mapping study Optimizing type-specific instrumentation on the JVM with reflective supertype information Qualitative representation of spatio-temporal knowledge
×
引用
GB/T 7714-2015
复制
MLA
复制
APA
复制
导出至
BibTeX EndNote RefMan NoteFirst NoteExpress
×
×
提示
您的信息不完整,为了账户安全,请先补充。
现在去补充
×
提示
您因"违规操作"
具体请查看互助需知
我知道了
×
提示
现在去查看 取消
×
提示
确定
0
微信
客服QQ
Book学术公众号 扫码关注我们
反馈
×
意见反馈
请填写您的意见或建议
请填写您的手机或邮箱
已复制链接
已复制链接
快去分享给好友吧!
我知道了
×
扫码分享
扫码分享
Book学术官方微信
Book学术文献互助
Book学术文献互助群
群 号:481959085
Book学术
文献互助 智能选刊 最新文献 互助须知 联系我们:info@booksci.cn
Book学术提供免费学术资源搜索服务,方便国内外学者检索中英文文献。致力于提供最便捷和优质的服务体验。
Copyright © 2023 Book学术 All rights reserved.
ghs 京公网安备 11010802042870号 京ICP备2023020795号-1