下载此文档

indentation-sensitive parsing for parsec:压痕敏感分析秒差距.pdf


文档分类:医学/心理学 | 页数:约12页 举报非法文档有奖
1/12
下载提示
  • 1.该资料是网友上传的,本站提供全文预览,预览什么样,下载就什么样。
  • 2.下载该文档所得收入归上传者、原创者。
  • 3.下载的文档,不会出现我们的网址水印。
1/12 下载此文档
文档列表 文档介绍
Indentation-Sensitive Parsing for Parsec Michael D. Adams University of Illinois at Urbana/Champaign / ?mer S. A ?gacan TOBB University of Economics and Technology / Abstract Several popular languages including Haskell and Python use the indentation and layout of code as an essential part of their syntax. In the past, implementations of these languages usedad hoctech- niques to implement layout. Recent work has shown that a simple extension to context-free grammars can replace thesead hoctech- niques and provide both formal foundations and ef?cient parsing algorithms for indentation sensitivity. However, that previous work is limited to bottom-up, LR(k) parsing, and binator-based parsing frameworks including Parsec use top-down algorithms that are outside its scope. This paper remedies this by showing how to add indentation sensitivity to parsing frameworks like Parsec. It explores both the formal semantics of and ef?cient algorithms for indentation sensitivity. It derives a Parsec-based library for indentation-sensitive parsing and presents benchmarks on a real-world language that show its ef?ciency and practicality. Categories and Subject Descriptors [Programming Lan- guages]: Formal De?nitions and Theory—Syntax; [Pro- gramming Languages]: Processors—Parsing; [Mathemati- cal Logic and Formal Languages]: Grammars and Other Rewriting Systems—Parsing General TermsAlgorithms, Languages KeywordsParsing; Parsec; Indentation sensitivity; Layout; Off- side rule 1. Introduction Languages such as Haskell (Marlow (ed.) 2010) and Python (Python) use the indentation of code to delimit various grammati- cal forms. For example, in Haskell, the contents of alet,where, do, orcaseexpression can be indented relative to the surround- ing code instead of being explicitly delimited by curly braces. For example, one may write: umR f = loop where loop acc (x:xs) = (acc’’, x’: xs’) where (acc’’, x’) = f acc’ x (acc’, xs’) = loop acc xs loop acc [] = (acc, []) Copyright

indentation-sensitive parsing for parsec:压痕敏感分析秒差距 来自淘豆网m.daumloan.com转载请标明出处.

非法内容举报中心
文档信息
  • 页数12
  • 收藏数0 收藏
  • 顶次数0
  • 上传人薄荷牛奶
  • 文件大小0 KB
  • 时间2016-04-09