skip to main content
10.1145/3441296.3441395acmconferencesArticle/Chapter ViewAbstractPublication PagespepmConference Proceedingsconference-collections
research-article

A text-based syntax completion method using LR parsing

Published: 17 January 2021 Publication History

Abstract

This paper presents a text-based syntax completion method using an LR parser. We propose formal definitions of candidate text to be completed based on the sentential forms, and we design algorithms for computing candidates through reductions in the LR parsing. This is in contrast to the existing methods that have not clearly stated what candidates they intend to produce. This is also different from a transformation approach using an LR parser, which transforms the grammar of the programming language, a burdensome task at this moment. The advantage of our method is that LR parsers can be adopted without modification, and a syntax completion system can be built using them, without incurring efforts. We implemented the algorithms as an Emacs server to demonstrate the feasibility of their application.

Supplementary Material

MP4 File (3441296.3441395.mp4)
Video Presentation

References

[1]
Alfred V. Aho, Monica S. Lam, Ravi Sethi, and Jefrey D. Ullman. 2007. Compilers-principles, techniques, and tools, 2nd edition. Addison Wesley.
[2]
Luís Eduardo de Souza Amorim, Sebastian Erdweg, Guido Wachsmuth, and Eelco Visser. 2016. Principled syntactic code completion using placeholders. In Proceedings of the 2016 ACM SIGPLAN International Conference on Software Language Engineering (SLE 2016 ). ACM, Amsterdam, Netherlands, 163-175. htps://doi.org/10.1145/2997364.2997374
[3]
Frédéric Bour, Thomas Refis, and Gabriel Scherer. 2018. Merlin: A language server for OCaml (Experience report). Proc. ACM Program. Lang. 2, ICFP, Article 103 ( July 2018 ), 15 pages. htps://doi.org/10. 1145/3236798
[4]
Janusz A. Brzozowski. 1964. Derivatives of regular expressions. J. ACM 11, 4 ( 1964 ), 481-494. htps://doi.org/10.1145/321239.321249
[5]
Maartje de Jonge, Lennart C. L. Kats, Eelco Visser, and Emma Söderberg. 2012. Natural and flexible error recovery for generated modular language environments. ACM Trans. Program. Lang. Syst. 34, 4, Article 15 ( 2012 ), 15 : 1-15 :50 pages. htps://doi.org/10.1145/2400676.2400678
[6]
Thomas R. Dean, James R. Cordy, Andrew J. Malton, and Kevin A. Schneider. 2002. Grammar programming in TXL. In Proceedings of the Second IEEE International Workshop on Source Code Analysis and Manipulation (SCAM '02). IEEE Computer Society, 93. htps://doi.org/ 10.1109/SCAM. 2002.1134109
[7]
Alain Denise, Olivier Roques, and Michel Termier. 2000. Random generation of words of context-free languages according to the frequencies of letters. In Mathematics and Computer Science, Danièle Gardy and Abdelkader Mokkadem (Eds.). Birkhäuser Basel, Basel, 113-125. htps://doi.org/10.1007/978-3-0348-8405-1_10
[8]
Veronique Donzeau-Gouge, Gerard Huet, Bernard Lang, and Gilles Kahn. 1980. Programming environments based on structured editors: the MENTOR experience. Technical Report RR-0026. INRIA.
[9]
Tihomir Gvero, Viktor Kuncak, and Ruzica Piskac. 2011. Code completion using quantitative type inhabitation. Technical Report EPFLREPORT-170040. Ecole Polytechnique Federale de Lausanne.
[10]
Masatomo Hashimoto. 1998. First-class contexts in ML. In Asian Computing Science Conference (Lecture Notes in Computer Science, Vol. 1538 ). Springer, 206-223. htps://doi.org/10.1007/3-540-49366-2_16
[11]
Johan Jeuring, Alexey Rodriguez, and Gideon Smeding. 2006. Generating generic functions. In Proceedings of the 2006 ACM SIGPLAN Workshop on Generic Programming (WGP '06). Portland, Oregon, USA, 23-32. htps://doi.org/10.1145/1159861.1159865
[12]
Susumu Katayama. 2005. Systematic search for lambda expressions. In Trends in Functional Programming. 111-126.
[13]
Pieter W. M. Koopman and Rinus Plasmeijer. 2006. Systematic synthesis of functions. In Trends in Functional Programming (Trends in Functional Programming, Vol. 7 ), Henrik Nilsson (Ed.). Intellect, 35-54.
[14]
Matthijs F. Kuiper and João Saraiva. 1998. LRC-A generator for incremental language-oriented tools. In Proceedings of the 7th International Conference on Compiler Construction (CC '98). Springer-Verlag, London, UK, 298-301. htps://doi.org/10.1007/BFb0026440
[15]
Bernard Lang. 1974. Deterministic techniques for eficient nondeterministic parsers. In Proceedings of the 2nd International Colloquium on Automata, Languages and Programming (ICALP '74) (Lecture Notes in Computer Science, Vol. 14 ). Springer-Verlag, 255-269. htps://doi.org/10.1007/978-3-662-21545-6_18
[16]
Jintaeck Lim, Gayoung Kim, Seunghyun Shin, Kwanghoon Choi, and Iksoon Kim. 2020. Parser generators sharing LR automaton generators and accepting general purpose programming languagebased specifications. Journal of KIISE 47, 1 ( 2020 ), 52-60. htps: //doi.org/10.5626/JOK. 2020. 47.1.52 (in Korean).
[17]
Bruce McKenzie. 1997. Generating strings at random from a context free grammar. Technical Report TR-COSC 10/97. University of Canterbury.
[18]
Scott McPeak and George C. Necula. 2004. Elkhound: A fast, practical GLR parser generator. In Compiler Construction, Evelyn Duesterwald (Ed.). Springer Berlin Heidelberg, Berlin, Heidelberg, 73-88. htps: //doi.org/10.1007/978-3-540-24723-4_6
[19]
Matthew Might, David Darais, and Daniel Spiewak. 2011. Parsing with derivatives: A functional pearl. In Proceedings of the 16th ACM SIGPLAN International Conference on Functional Programming (Tokyo, Japan) ( ICFP '11). Association for Computing Machinery, New York, NY, USA, 189-195. htps://doi.org/10.1145/2034773.2034801
[20]
Terence Parr and Kathleen Fisher. 2011. LL(*): The foundation of the ANTLR parser generator. In Proceedings of the 32Nd ACM SIGPLAN Conference on Programming Language Design and Implementation (San Jose, California, USA) ( PLDI '11). 425-436. htps://doi.org/10.1145/ 1993498.1993548
[21]
Daniel A. A. Pelsmaeker, Hendrik van Antwerpen, and Eelco Visser. 2019. Towards language-parametric semantic editor services based on declarative type system specifications (Brave new idea paper). In 33rd European Conference on Object-Oriented Programming (ECOOP 2019 ) (Leibniz International Proceedings in Informatics (LIPIcs), Vol. 134 ), Alastair F. Donaldson (Ed.). Schloss Dagstuhl-Leibniz-Zentrum fuer Informatik, Dagstuhl, Germany, 26 : 1-26 : 18. htps://doi.org/10.1145/ 3359061.3362782
[22]
Daniel Perelman, Sumit Gulwani, Thomas Ball, and Dan Grossman. 2012. Type-directed completion of partial expressions. In Proceedings of the 33rd ACM SIGPLAN conference on Programming Language Design and Implementation (PLDI '12). ACM Press, Beijing, China, 275-286. htps://doi.org/10.1145/2254064.2254098
[23]
Thomas Reps and Tim Teitelbaum. 1984. The Synthesizer Generator. In Proceedings of the first ACM SIGSOFT/SIGPLAN software engineering symposium on Practical software development environments. 42-48. htps://doi.org/10.1145/800020.808247
[24]
Mikael Rittri. 1989. Using types as search keys in function libraries. In Proceedings of the fourth international conference on Functional programming languages and computer architecture (FPCA '89). 174-183. htps://doi.org/10.1145/99370.99384
[25]
Romain Robbes and Michele Lanza. 2008. How program history can improve code completion. In Proceedings of the 2008 23rd IEEE/ACM International Conference on Automated Software Engineering (ASE '08). 317-326. htps://doi.org/10.1109/ASE. 2008.42
[26]
Colin Runciman and Ian Toyn. 1989. Retrieving re-usable software components by polymorphic type. In Proceedings of the fourth international conference on Functional programming languages and computer architecture (FPCA '89). ACM Press, Imperial College, London, United Kingdom, 166-173. htps://doi.org/10.1145/99370.99383
[27]
João Saraiva. 2002. Component-based programming for higher-order attribute grammars. In Proceedings of the 1st ACM SIGPLAN/SIGSOFT Conference on Generative Programming and Component Engineering (GPCE '02). Springer-Verlag, London, UK, 268-282. htps://doi.org/10. 1007/3-540-45821-2_17
[28]
Isao Sasano. 2014. Toward modular implementation of practical identifier completion on incomplete program text. In Proceedings of the 8th International Conference on Bioinspired Information and Communications Technologies (BICT '14). ICST (Institute for Computer Sciences, Social-Informatics and Telecommunications Engineering), Boston, Massachusetts, 231-234. htps://doi.org/10.4108/icst.bict. 2014.257909
[29]
Isao Sasano. 2020. An approach to generate text-based IDEs for syntax completion based on syntax specification. In Proceedings of the 2020 ACM SIGPLAN Workshop on Partial Evaluation and Program Manipulation ( New Orleans, LA, USA) ( PEPM 2020 ). Association for Computing Machinery, New York, NY, USA, 38-44. htps: //doi.org/10.1145/3372884.3373158
[30]
Isao Sasano and Takumi Goto. 2013. An approach to completing variable names for implicitly typed functional languages. HigherOrder and Symbolic Computation 25, 1 ( 2013 ), 127-163. htps://doi. org/10.1007/s10990-013-9095-x
[31]
Maarten P. Sijm. 2019. Incremental scannerless generalized LR parsing. In Proceedings Companion of the 2019 ACM SIGPLAN International Conference on Systems, Programming, Languages, and Applications: Software for Humanity (Athens, Greece) ( SPLASH Companion 2019 ). Association for Computing Machinery, New York, NY, USA, 54-56. htps://doi.org/10.1145/3359061.3361085
[32]
Friedrich Steimann, Marcus Frenkel, and Markus Voelter. 2017. Robust projectional editing. In Proceedings of the 10th ACM SIGPLAN International Conference on Software Language Engineering (SLE 2017 ). ACM, Vancouver, BC, Canada, 79-90. htps://doi.org/10.1145/3136014. 3136034
[33]
Masaru Tomita. 1985. Eficient parsing for natural language: A fast algorithm for practical systems. Kluwer Academic Publishers. htps: //doi.org/10.1007/978-1-4757-1885-0
[34]
Harald Vogt, Doaitse Swierstra, and Matthijs Kuiper. 1989. Higher order attribute grammars. In Proceedings of the ACM SIGPLAN 1989 Conference on Programming Language Design and Implementation (Portland, Oregon, USA) ( PLDI '89). ACM, 131-145. htps://doi.org/10.1145/ 73141.74830
[35]
Tim A. Wagner and Susan L. Graham. 1998. Eficient and flexible incremental parsing. ACM Transactions on Programming Languages and Systems 20, 5 ( 1998 ), 980-1013. htps://doi.org/10.1145/293677. 293678

Cited By

View all
  • (2024)Ranked Syntax Completion With LR ParsingProceedings of the 39th ACM/SIGAPP Symposium on Applied Computing10.1145/3605098.3635944(1242-1251)Online publication date: 8-Apr-2024
  • (2023)A text-based syntax completion method using LR parsing and its evaluationScience of Computer Programming10.1016/j.scico.2023.102957228:COnline publication date: 5-Jun-2023
  • (2022)Language-parametric static semantic code completionProceedings of the ACM on Programming Languages10.1145/35273296:OOPSLA1(1-30)Online publication date: 29-Apr-2022
  • Show More Cited By

Recommendations

Comments

Information & Contributors

Information

Published In

cover image ACM Conferences
PEPM 2021: Proceedings of the 2021 ACM SIGPLAN Workshop on Partial Evaluation and Program Manipulation
January 2021
89 pages
ISBN:9781450383059
DOI:10.1145/3441296
Permission to make digital or hard copies of all or part of this work for personal or classroom use is granted without fee provided that copies are not made or distributed for profit or commercial advantage and that copies bear this notice and the full citation on the first page. Copyrights for components of this work owned by others than ACM must be honored. Abstracting with credit is permitted. To copy otherwise, or republish, to post on servers or to redistribute to lists, requires prior specific permission and/or a fee. Request permissions from [email protected]

Sponsors

Publisher

Association for Computing Machinery

New York, NY, United States

Publication History

Published: 17 January 2021

Permissions

Request permissions for this article.

Check for updates

Author Tags

  1. LR parsing
  2. integrated development environments
  3. parser generator
  4. reduction
  5. sentential forms
  6. syntax completion

Qualifiers

  • Research-article

Funding Sources

  • JSPS KAKENHI
  • NRF of Korea

Conference

POPL '21
Sponsor:

Acceptance Rates

Overall Acceptance Rate 66 of 120 submissions, 55%

Contributors

Other Metrics

Bibliometrics & Citations

Bibliometrics

Article Metrics

  • Downloads (Last 12 months)20
  • Downloads (Last 6 weeks)1
Reflects downloads up to 22 Jan 2025

Other Metrics

Citations

Cited By

View all
  • (2024)Ranked Syntax Completion With LR ParsingProceedings of the 39th ACM/SIGAPP Symposium on Applied Computing10.1145/3605098.3635944(1242-1251)Online publication date: 8-Apr-2024
  • (2023)A text-based syntax completion method using LR parsing and its evaluationScience of Computer Programming10.1016/j.scico.2023.102957228:COnline publication date: 5-Jun-2023
  • (2022)Language-parametric static semantic code completionProceedings of the ACM on Programming Languages10.1145/35273296:OOPSLA1(1-30)Online publication date: 29-Apr-2022
  • (2022)VSCODE- Code With Voice Using Natural Language Processing(NLP)2022 International Conference on Computer, Power and Communications (ICCPC)10.1109/ICCPC55978.2022.10072106(571-574)Online publication date: 14-Dec-2022
  • (2021)Visual Studio Code Extension and Auto-completion for Mizar Language2021 Ninth International Symposium on Computing and Networking (CANDAR)10.1109/CANDAR53791.2021.00033(182-188)Online publication date: Nov-2021

View Options

Login options

View options

PDF

View or Download as a PDF file.

PDF

eReader

View online with eReader.

eReader

Media

Figures

Other

Tables

Share

Share

Share this Publication link

Share on social media