A Typed, Algebraic Approach to Parsing

被引:13
作者
Krishnaswami, Neelakantan R. [1 ]
Yallop, Jeremy [1 ]
机构
[1] Univ Cambridge, Cambridge, England
来源
PROCEEDINGS OF THE 40TH ACM SIGPLAN CONFERENCE ON PROGRAMMING LANGUAGE DESIGN AND IMPLEMENTATION (PLDI '19) | 2019年
关键词
parsing; context-free languages; type theory; Kleene algebra;
D O I
10.1145/3314221.3314625
中图分类号
TP31 [计算机软件];
学科分类号
081202 ; 0835 ;
摘要
In this paper, we recall the definition of the context-free expressions (or mu-regular expressions), an algebraic presentation of the context-free languages. Then, we define a core type system for the context-free expressions which gives a compositional criterion for identifying those context-free expressions which can be parsed unambiguously by predictive algorithms in the style of recursive descent or LL(1). Next, we show how these typed grammar expressions can be used to derive a parser combinator library which both guarantees linear-time parsing with no backtracking and single-token lookahead, and which respects the natural denotational semantics of context-free expressions. Finally, we show how to exploit the type information to write a staged version of this library, which produces dramatic increases in performance, even outperforming code generated by the standard parser generator tool ocamlyacc.
引用
收藏
页码:379 / 393
页数:15
相关论文
共 35 条
  • [1] Ager Mads Sig, 2003, RS0314 BRICS
  • [2] Atkey R, 2013, ACM SIGPLAN NOTICES, V48, P197, DOI [10.1145/2500365.2500597, 10.1145/2544174.2500597]
  • [3] Atkey R, 2009, HASKELL'09: PROCEEDINGS OF THE 2009 ACM SIGPLAN HASKELL SYMPOSIUM, P37
  • [4] Bekic H., 1984, LNCS, V177, DOI DOI 10.1007/BFB0048933
  • [5] Bondorf A., 1992, Proceedings of the 1992 ACM Conference on Lisp and Functional Programming, P1, DOI 10.1145/141471.141483
  • [6] Bruggemann-Klein Anne., 1992, STACS 92, 9th Annual Symposium on Theoretical Aspects of Computer Science, Cachan, France, February 13-15, 1992, Proceedings, volume 577 of Lecture Notes in Computer Science, P173, DOI [DOI 10.1007/3-540-55210-3_182, 10.1007/3-540-55210- 3_ 182]
  • [7] DERIVATIVES OF REGULAR EXPRESSIONS
    BRZOZOWSKI, JA
    [J]. JOURNAL OF THE ACM, 1964, 11 (04) : 481 - &
  • [8] Eta-expansion does the trick
    Danvy, O
    Malmkjaer, K
    Palsberg, J
    [J]. ACM TRANSACTIONS ON PROGRAMMING LANGUAGES AND SYSTEMS, 1996, 18 (06): : 730 - 751
  • [9] Davies R., 1996, Conference Record of POPL '96: The 23rd ACM SIGPLAN-SIGACT Symposium on Principles of Programming Languages, P258, DOI 10.1145/237721.237788
  • [10] Doaitse Swierstra S., 1996, Advanced Functional Programming. Second International School. Tutorial Text, P184