Upgrade of Lark Compiler Generator to Support Attribute Grammars

Authors Daniel Faria, Tiago João Baptista, Pedro Rangel Henriques



PDF
Thumbnail PDF

File

OASIcs.SLATE.2024.7.pdf
  • Filesize: 0.58 MB
  • 16 pages

Document Identifiers

Author Details

Daniel Faria
  • ALGORITMI Research Centre/LASI - DI, University of Minho, Braga, Portugal
Tiago João Baptista
  • ALGORITMI Research Centre/LASI - DI, University of Minho, Braga, Portugal
Pedro Rangel Henriques
  • ALGORITMI Research Centre/LASI - DI, University of Minho, Braga, Portugal

Cite As Get BibTex

Daniel Faria, Tiago João Baptista, and Pedro Rangel Henriques. Upgrade of Lark Compiler Generator to Support Attribute Grammars. In 13th Symposium on Languages, Applications and Technologies (SLATE 2024). Open Access Series in Informatics (OASIcs), Volume 120, pp. 7:1-7:16, Schloss Dagstuhl – Leibniz-Zentrum für Informatik (2024) https://doi.org/10.4230/OASIcs.SLATE.2024.7

Abstract

This document presents an initiative aimed at advancing parsing and language processing through the integration of Attribute Grammars (AG) into the Lark Compiler Generator, a flexible tool frequently used for these tasks. In order to achieve a successful integration of AGs into Lark, a study on the concept and example analysis of AG based specifications needed to be conducted. This provided an insight on their advantages in order to extend Lark with the ability to use AG, that will be presented in this article. With this project, named LarkAG, we aim at providing Lark with a conventional and well studied formalism to specify rigorously the static and dynamic semantics of programming languages, on top of its recognized syntactic analysis capabilities. Along the paper, LarkAG architecture, development and usage are also discussed. The DSL designed to provide a proper notation for attribute occurrences selection and for writing semantic rules and context conditions is also presented. This addition of AG support to Lark will enable the construction of compilers and language processors of greater reliability. It is not a major breakthrough since AGs based tools already exist and are well studied, but rather an extension that can bring great value to a modern framework such as Lark.

Subject Classification

ACM Subject Classification
  • Theory of computation → Grammars and context-free languages
Keywords
  • Formal Language Specification
  • Formal Language Processing
  • Attribute Grammars
  • Compiler Generation
  • Lark

Metrics

  • Access Statistics
  • Total Accesses (updated on a weekly basis)
    0
    PDF Downloads

References

  1. Henk Alblas. Attribute evaluation methods. In International Summer School on Attribute Grammars, Applications, and Systems, pages 48-113. Springer, 1991. URL: https://doi.org/10.1007/3-540-54572-7_3.
  2. Bijan Arbab. Compiling circular attribute grammars into prolog. Journal of Research and Development, 30(3):294-309, May 1986. URL: https://doi.org/10.1147/RD.303.0294.
  3. Lex Augsteijn. The elegant compiler generator. In P. Deransart and M. Jourdan, editors, WAGA-90, pages 238-254. Springer-Verlag, September 1990. LNCS 461. Google Scholar
  4. Rina Cohen and Eli Harry. Automatic generation of near-optimal linear-time translators for non-circular attribute grammars. In Proceedings of the 6th ACM SIGACT-SIGPLAN Symposium on Principles of Programming Languages, POPL '79, pages 121-134, New York, NY, USA, 1979. Association for Computing Machinery. URL: https://doi.org/10.1145/567752.567764.
  5. P. Deransart and M. Jourdan, editors. Attribute Grammars and their Applications. INRIA, Springer-Verlag, September 1990. Lecture Notes in Computer Science, nu. 461. Google Scholar
  6. Pierre Deransart, Martin Jourdan, and Bernard Lorho. Attribute grammars: Main results, existing systems and bibliography. In LNCS 341. Springer-Verlag, 1988. Google Scholar
  7. João Paulo Fernandes, Pedro Martins, Alberto Pardo, João Saraiva, and Marcos Viera. Memoized zipper-based attribute grammars. In Programming Languages: 20th Brazilian Symposium, SBLP 2016, Maringá, Brazil, September 22-23, 2016, Proceedings 20, pages 46-61. Springer, 2016. URL: https://doi.org/10.1007/978-3-319-45279-1_4.
  8. Python Software Foundation. Python language reference, version 3.12, 2024. URL: https://docs.python.org/3.12/.
  9. R. Gray, V. Heuring, S. Kram, A. Sloane, and W. Waite. Eli: A complete, flexible compiler construction system. Research report, Univ. of Colorado at Boulder, October 1990. Google Scholar
  10. Görel Hedin. Incremental static semantic analysis for object-oriented languages using Door Attribute Grammars. Research Report LU-CS-TR:91-79, Dep. of Computer Science, Lund Institute of Technology, August 1991. Google Scholar
  11. Görel Hedin and Eva Magnusson. JastAdd—an aspect-oriented compiler construction system. Science of Computer Programming, 47(1):37-58, 2003. Special Issue on Language Descriptions, Tools and Applications (L DTA'01). URL: https://doi.org/10.1016/S0167-6423(02)00109-0.
  12. Jan Heering and Paul Klint. Semantics of programming languages: A tool-oriented approach. ACM SIGPLAN Notices, 35:2000, 1999. Google Scholar
  13. Pedro R. Henriques. A semantic evaluator generating system in PROLOG. In P. Deransart, B. Lorho, and J. Maluszynski, editors, Programming Languages Implementation and Logic Programming, pages 201-218. Springer-Verlag, May 1988. LNCS 348. Google Scholar
  14. Pedro Rangel Henriques. Brincando às Linguagens com Rigor: Engenharia Gramatical. Habilitation in Computer Science (Technical Report), Dep. de Informática, Escola de Engenharia da Universidade do Minho, October 2011. Habilitation monography presented and discussed in a public session held in April 2012 at UM/Braga. Google Scholar
  15. John E. Hopcroft, Rajeev Motwani, and Jeffrey D. Ullman. Introduction to Automata Theory, Languages, and Computation (3rd Edition). Addison-Wesley Longman Publishing Co., Inc., USA, 2006. Google Scholar
  16. Stephen C. Johnson. YACC Yet Another Compiler Compiler. Computing Science Technical Report CSTR32, Bell Laboratories - Murray Hill, New Jersey, 1975. Google Scholar
  17. Martin Jourdan. An efficient recursive evaluator for strongly non-circular attribute grammars. Rapport de Recherche 235, INRIA, Rocquencourt, October 1983. Google Scholar
  18. Martin Jourdan, Carole Le Bellec, and Didier Parigot. The OLGA Attribute Grammar Description Language: Design, implementation and evaluation. In P. Deransart and M. Jourdan, editors, Attribute Grammars and their Applications, pages 222-237. Springer-Verlag, September 1990. LNCS 461. URL: https://doi.org/10.1007/3-540-53101-7_16.
  19. Uwe Kastens. Ordered attribute grammars. Acta Informatica, 13(3):229-256, 1980. URL: https://doi.org/10.1007/BF00288644.
  20. Uwe Kastens, B. Hutt, and E. Zimmermann. GAG: A practical compiler generator. In LNCS 141. Springer-Verlag, 1982. Google Scholar
  21. Donald E. Knuth. Semantics of context-free languages. Mathematical Systems Theory, 2(2):127-145, 1968. URL: https://doi.org/10.1007/BF01692511.
  22. Kai Koskimies, T. Elomaa, T. Lehtonen, and J. Paakki. Tools/hlp84 report and user manual. Research Report A-1988-2, Univ. of Helsinki, Depart. of Computer Science, 1988. Google Scholar
  23. Kai Koskimies, O. Nurmi, J. Paakki, and S. Sippu. The design of the language processor generator hlp84. Techn. Report A-1986-4, Univ. of Helsinki, Depart. of Computer Science, 1986. Google Scholar
  24. Kai Koskimies and Jukka Paakki. Tools: An unifying approach to object-oriented language interpretation. Research report, Univ. of Helsinki, Depart. of Computer Science, 1987. (draft). Google Scholar
  25. Matthijs Kuiper and João Saraiva. Lrc - a generator for incremental language-oriented tools. In Kai Koskimies, editor, Compiler Construction, pages 298-301, Berlin, Heidelberg, 1998. Springer Berlin Heidelberg. URL: https://doi.org/10.1007/BFB0026440.
  26. M. E. Lesk and E. Schmidt. Lex - A Lexical Analyzer Generator. Computing Science Technical Report 39, Bell Laboratories - Murray Hill, New Jersey, 1975. Google Scholar
  27. Bernard Lorho. Semantics attributes processing in the system DELTA. In A. Ershov and C.H.A. Koster, editors, Methods of Algorithmic Language Implementation, pages 21-40. Springer-Verlag, 1977. LNCS 47. Google Scholar
  28. Marjan Mernik, Jan Heering, and Anthony Sloane. When and how to develop domain-specific languages. ACM Comput. Surv., 37:316-, December 2005. URL: https://doi.org/10.1145/1118890.1118892.
  29. Marjan Mernik, Mitja Lenic, Enis Avdicausevic, and Viljem Zumer. Compiler/interpreter generator system LISA. In IEEE Proceedings of 33rd Hawaii International Conference on System Sciences, 2000. Google Scholar
  30. Jukka Paakki. Attribute grammar paradigms—a high-level methodology in language implementation. ACM Computing Surveys (CSUR), 27(2):196-255, 1995. URL: https://doi.org/10.1145/210376.197409.
  31. T. J. Parr, H. G. Dietz, and W. E. Cohen. PCCTS reference manual: version 1.00. ACM SIGPLAN Notices, 27(2):88-165, February 1992. URL: https://doi.org/10.130973.130980.
  32. Terence Parr. The Definitive ANTLR 4 Reference. The Pragmatic Bookshelf, 2nd edition edition, January 2013. Google Scholar
  33. Terence Parr and Russell W. Quong. Antlr: A predicated-ll(k) parser generator. Software Practice and Experience, 25(7):789-810, July 1995. URL: https://doi.org/10.1002/SPE.4380250705.
  34. K.J. Räihä, M. Saarinen, M. Sarjakoski, S. Sippu, E. Soisalon-Soininen, and M. Tienari. Revised report on the compiler writing system hlp78. Techn. Report A-1983-1, Univ. of Helsinki, Depart. of Computer Science, 1983. Google Scholar
  35. N. Ringo, L. Kramer, and E. Van Wyk. Nanopass Attribute Grammars. In J. Saraiva, T. Degueule, and E. Scott, editors, 16th ACM SIGPLAN International Conference on Software Language Engineering (SLE2023, Co-located with SPLASH2023), pages 70-83. Association for Computing Machinery, Inc., 2023. URL: https://doi.org/10.1145/3623476.3623514.
  36. João Saraiva, S. Swierstra, and Matthijs Kuiper. Functional Incremental Attribute Evaluation. In David A. Watt, editor, Compiler Construction, pages 279-294, Berlin, Heidelberg, March 2000. Springer Berlin Heidelberg. URL: https://doi.org/10.1007/3-540-46423-9_19.
  37. Erez Shinan. Lark documentation, 2020. URL: https://lark-parser.readthedocs.io/en/latest/index.html.
  38. S.D. Swierstra and H.H. Vogt. Higher Order Attribute Grammars: a Merge between Functional and Object Oriented Programming. Research Report RUU-CS-90-12, Dep. of Computer Science / Utrecht Univ., March 1990. Google Scholar
  39. Martti Tienari. On the definition of an attribute grammar. In Neil D. Jones, editor, Semantics-Directed Compiler Generation, pages 408-414. Springer Berlin Heidelberg, 1980. URL: https://doi.org/10.1007/3-540-10250-7_31.
  40. Eric Van Wyk, Derek Bodin, Jimin Gao, and Lijesh Krishnan. Silver: an Extensible Attribute Grammar System. Science of Computer Programming, 75((1-2)):39-54, January 2010. URL: https://doi.org/10.1016/J.SCICO.2009.07.004.
Questions / Remarks / Feedback
X

Feedback for Dagstuhl Publishing


Thanks for your feedback!

Feedback submitted

Could not send message

Please try again later or send an E-mail