We present ZipLex, a verified framework for invertible linear-time lexical analysis following the longest match (maximal munch) 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 standalone verified imperative hash table. Our hash table offers competitive performance as shown by our evaluation. 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)等。
时间序列复杂网络分析中的可视图方法研究综述
专知会员服务
29+阅读 · 2024年4月2日
【SIGIR2020】学习词项区分性,Learning Term Discrimination
专知会员服务
16+阅读 · 2020年4月28日
R语言时间序列分析
R语言中文社区
12+阅读 · 2018年11月19日
时序异常检测算法概览
论智
29+阅读 · 2018年8月30日
基于 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+阅读 · 2015年12月31日
国家自然科学基金
0+阅读 · 2014年12月31日
国家自然科学基金
0+阅读 · 2014年12月31日
国家自然科学基金
0+阅读 · 2014年12月31日
Arxiv
0+阅读 · 5月29日
VIP会员
最新内容
《通过小型无人机系统将情报能力“作战化”》
消耗优势:美军的“精确规模化”概念
专知会员服务
8+阅读 · 6月15日
《离线语言支持系统:面向空战战术决策》
专知会员服务
10+阅读 · 6月15日
相关VIP内容
时间序列复杂网络分析中的可视图方法研究综述
专知会员服务
29+阅读 · 2024年4月2日
【SIGIR2020】学习词项区分性,Learning Term Discrimination
专知会员服务
16+阅读 · 2020年4月28日
相关资讯
R语言时间序列分析
R语言中文社区
12+阅读 · 2018年11月19日
时序异常检测算法概览
论智
29+阅读 · 2018年8月30日
基于 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+阅读 · 2015年12月31日
国家自然科学基金
0+阅读 · 2014年12月31日
国家自然科学基金
0+阅读 · 2014年12月31日
国家自然科学基金
0+阅读 · 2014年12月31日
Top
微信扫码咨询专知VIP会员