Lexers and parsers are typically defined separately and connected by a token stream. This separate definition is important for modularity and reduces the potential for parsing ambiguity. However, materializing tokens as data structures and case-switching on tokens comes with a cost. We show how to fuse separately-defined lexers and parsers, drastically improving performance without compromising modularity or increasing ambiguity. We propose a deterministic variant of Greibach Normal Form that ensures deterministic parsing with a single token of lookahead and makes fusion strikingly simple, and prove that normalizing context free expressions into the deterministic normal form is semantics-preserving. Our staged parser combinator library, flap, provides a standard interface, but generates specialized token-free code that runs two to six times faster than ocamlyacc on a range of benchmarks.


翻译:词法分析器与解析器通常分开定义,并通过词法单元流连接。这种分离定义对模块化至关重要,并能降低解析歧义的可能性。然而,将词法单元具体化为数据结构并进行模式分支操作会带来性能开销。我们展示了如何融合分别定义的词法分析器和解析器,在不牺牲模块化或增加歧义的前提下大幅提升性能。我们提出了一种确定性格雷巴赫范式变体,该范式确保仅需单个向前查看词法单元即可实现确定性解析,使融合过程异常简洁,并证明了将上下文无关表达式归一化为该确定范式具有语义保持性。我们的分段解析器组合子库flap提供标准接口,但生成了免词法单元专用代码,在多个基准测试中运行速度比ocamlyacc快两到六倍。

0
下载
关闭预览

相关内容

词法分析(英语:lexical analysis)是计算机科学中将字符序列转换为单词(Token)序列的过程。 词法分析(lexical analysis)包括汉语分词和词性标注两部分。和大部分西方语言不同,汉语书面语词语之间没有明显的空格标记,文本中的句子以字串的形式出现。 因此汉语自然语言处理的首要工作就是要将输入的字串切分为单独的词语,然后在此基础上进行其他更高级的分析,这一步骤称为分词(word segmentation 或tokenization)。除了 分词,词性标注也通常认为是词法分析的一部分。给定一个切好词的句子,词性标注的目的是为每一个词赋予一个类别,这个类别称为词性标记(part-of-speech tag),比如,名词(noun)、动词(verb)、形容词(adjective)等。
抢鲜看!13篇CVPR2020论文链接/开源代码/解读
专知会员服务
50+阅读 · 2020年2月26日
[综述]深度学习下的场景文本检测与识别
专知会员服务
78+阅读 · 2019年10月10日
【哈佛大学商学院课程Fall 2019】机器学习可解释性
专知会员服务
105+阅读 · 2019年10月9日
【SIGGRAPH2019】TensorFlow 2.0深度学习计算机图形学应用
专知会员服务
41+阅读 · 2019年10月9日
已删除
科学网
60+阅读 · 2018年2月9日
【推荐】RNN/LSTM时序预测
机器学习研究会
25+阅读 · 2017年9月8日
国家自然科学基金
0+阅读 · 2013年12月31日
国家自然科学基金
0+阅读 · 2013年12月31日
国家自然科学基金
2+阅读 · 2013年12月31日
国家自然科学基金
0+阅读 · 2012年12月31日
国家自然科学基金
0+阅读 · 2012年12月31日
国家自然科学基金
1+阅读 · 2011年12月31日
国家自然科学基金
0+阅读 · 2010年12月31日
国家自然科学基金
0+阅读 · 2009年12月31日
国家自然科学基金
0+阅读 · 2008年12月31日
国家自然科学基金
0+阅读 · 2008年12月31日
Arxiv
0+阅读 · 2023年5月30日
VIP会员
最新内容
【剑桥博士论文】智能体-环境协同优化
专知会员服务
3+阅读 · 今天14:33
为初级军官战术训练设计生成式人工智能平台
专知会员服务
5+阅读 · 今天6:43
《美军条令:作战伤员后送保障》
专知会员服务
4+阅读 · 今天6:38
《美空军条令出版物 4-0,维持》
专知会员服务
4+阅读 · 今天6:32
《基于仿真的空军任务规划优化》
专知会员服务
4+阅读 · 今天6:21
相关VIP内容
相关基金
国家自然科学基金
0+阅读 · 2013年12月31日
国家自然科学基金
0+阅读 · 2013年12月31日
国家自然科学基金
2+阅读 · 2013年12月31日
国家自然科学基金
0+阅读 · 2012年12月31日
国家自然科学基金
0+阅读 · 2012年12月31日
国家自然科学基金
1+阅读 · 2011年12月31日
国家自然科学基金
0+阅读 · 2010年12月31日
国家自然科学基金
0+阅读 · 2009年12月31日
国家自然科学基金
0+阅读 · 2008年12月31日
国家自然科学基金
0+阅读 · 2008年12月31日
Top
微信扫码咨询专知VIP会员