We present ZipLex, a verified framework for invertible linear-time lexical analysis following the longest match semantics. Unlike past verified lexers that focus only on satisfying the semantics of regular expressions and the longest match property, ZipLex also guarantees that lexing and printing are mutual inverses. Thanks to verified memoization, it also ensures that the lexical analysis of a string is linear in the size of the string. Our design and implementation rely on two sets of ideas: (1) a new abstraction of token sequences that captures the separability of tokens in a sequence while supporting their efficient manipulation, and (2) a combination of verified data structures and optimizations, including Huet's zippers and memoization with a verified imperative hash table. We implemented and verified ZipLex using the Stainless deductive verifier for Scala. Our evaluation demonstrates that ZipLex supports realistic applications such as JSON processing and lexers of programming languages, and behaves linearly even in cases that make flex-style approaches quadratic. ZipLex is two orders of magnitude faster than Verbatim++, showing that verified invertibility and linear-time algorithms can be developed without prohibitive cost. Compared to Coqlex, ZipLex also offers linear (instead of quadratic) time lexing, and is the first lexer that comes with invertibility proofs for printing token sequences.


翻译:本文提出ZipLex,一个遵循最长匹配语义的可验证线性时间可逆词法分析框架。与以往仅关注满足正则表达式语义和最长匹配特性的验证型词法分析器不同,ZipLex还保证词法分析与打印操作互为逆过程。通过验证的记忆化技术,该框架进一步确保字符串的词法分析时间复杂度与字符串长度呈线性关系。我们的设计与实现基于两组核心理念:(1) 提出一种新的词符序列抽象方法,既能捕捉序列中词符的可分离性,又能支持其高效操作;(2)结合经过验证的数据结构与优化技术,包括Huet拉链结构以及采用验证型命令式哈希表实现的记忆化机制。我们使用Scala语言的Stainless演绎验证器实现并验证了ZipLex。评估结果表明,ZipLex能够支持JSON处理及编程语言词法分析器等实际应用场景,即使在导致flex类方法出现二次复杂度的案例中仍保持线性行为。ZipLex的运行速度比Verbatim++快两个数量级,证明可验证的可逆性与线性时间算法可以在可接受的成本内实现。与Coqlex相比,ZipLex提供线性(而非二次)时间复杂度的词法分析,并且是首个附带词符序列打印可逆性证明的词法分析器。

0
下载
关闭预览

相关内容

词法分析(英语:lexical analysis)是计算机科学中将字符序列转换为单词(Token)序列的过程。 词法分析(lexical analysis)包括汉语分词和词性标注两部分。和大部分西方语言不同,汉语书面语词语之间没有明显的空格标记,文本中的句子以字串的形式出现。 因此汉语自然语言处理的首要工作就是要将输入的字串切分为单独的词语,然后在此基础上进行其他更高级的分析,这一步骤称为分词(word segmentation 或tokenization)。除了 分词,词性标注也通常认为是词法分析的一部分。给定一个切好词的句子,词性标注的目的是为每一个词赋予一个类别,这个类别称为词性标记(part-of-speech tag),比如,名词(noun)、动词(verb)、形容词(adjective)等。
时间序列复杂网络分析中的可视图方法研究综述
专知会员服务
31+阅读 · 2024年3月9日
【SIGIR2020】学习词项区分性,Learning Term Discrimination
专知会员服务
16+阅读 · 2020年4月28日
R语言时间序列分析
R语言中文社区
12+阅读 · 2018年11月19日
基于 Keras 用深度学习预测时间序列
R语言中文社区
23+阅读 · 2018年7月27日
NetworkMiner - 网络取证分析工具
黑白之道
16+阅读 · 2018年6月29日
R语言之数据分析高级方法「时间序列」
R语言中文社区
17+阅读 · 2018年4月24日
机器学习(4)之线性判别式(附Python源码)
机器学习算法与Python学习
13+阅读 · 2017年7月11日
国家自然科学基金
0+阅读 · 2017年12月31日
国家自然科学基金
1+阅读 · 2015年12月31日
国家自然科学基金
0+阅读 · 2015年12月31日
国家自然科学基金
0+阅读 · 2015年12月31日
国家自然科学基金
0+阅读 · 2015年12月31日
国家自然科学基金
0+阅读 · 2014年12月31日
国家自然科学基金
0+阅读 · 2014年12月31日
国家自然科学基金
0+阅读 · 2014年12月31日
国家自然科学基金
0+阅读 · 2014年12月31日
Arxiv
0+阅读 · 2月19日
VIP会员
最新内容
《人工智能赋能电磁战》(报告)
专知会员服务
2+阅读 · 4月17日
【CMU博士论文】迈向可扩展的开放世界三维感知
前馈式三维场景建模
专知会员服务
1+阅读 · 4月17日
(译文)认知战:以士兵为目标,塑造战略
专知会员服务
3+阅读 · 4月17日
相关资讯
R语言时间序列分析
R语言中文社区
12+阅读 · 2018年11月19日
基于 Keras 用深度学习预测时间序列
R语言中文社区
23+阅读 · 2018年7月27日
NetworkMiner - 网络取证分析工具
黑白之道
16+阅读 · 2018年6月29日
R语言之数据分析高级方法「时间序列」
R语言中文社区
17+阅读 · 2018年4月24日
机器学习(4)之线性判别式(附Python源码)
机器学习算法与Python学习
13+阅读 · 2017年7月11日
相关基金
国家自然科学基金
0+阅读 · 2017年12月31日
国家自然科学基金
1+阅读 · 2015年12月31日
国家自然科学基金
0+阅读 · 2015年12月31日
国家自然科学基金
0+阅读 · 2015年12月31日
国家自然科学基金
0+阅读 · 2015年12月31日
国家自然科学基金
0+阅读 · 2014年12月31日
国家自然科学基金
0+阅读 · 2014年12月31日
国家自然科学基金
0+阅读 · 2014年12月31日
国家自然科学基金
0+阅读 · 2014年12月31日
Top
微信扫码咨询专知VIP会员