A text-based syntax completion method using LR parsing

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.

[1]  Susumu Katayama Systematic search for lambda expressions , 2005, Trends in Functional Programming.

[2]  김익순,et al.  Parser Generators Sharing LR Automaton Generators and Accepting General Purpose Programming Language-based Specifications , 2020, Journal of KIISE.

[3]  Bernard Lang,et al.  Programming Environments Based on Structured Editors: The MENTOR Experience, , 1980 .

[4]  George C. Necula,et al.  Elkhound: A Fast, Practical GLR Parser Generator , 2003, CC.

[5]  S. Doaitse Swierstra,et al.  Higher order attribute grammars , 1989, PLDI '89.

[6]  Sumit Gulwani,et al.  Type-directed completion of partial expressions , 2012, PLDI.

[7]  Isao Sasano Toward Modular Implementation of Practical Identifier Completion on Incomplete Program Text , 2014, BICT.

[8]  Masaru Tomita,et al.  Efficient Parsing for Natural Language: A Fast Algorithm for Practical Systems , 1985 .

[9]  Janusz A. Brzozowski,et al.  Derivatives of Regular Expressions , 1964, JACM.

[10]  Tim A. Wagner,et al.  Efficient and flexible incremental parsing , 1998, TOPL.

[11]  Eelco Visser,et al.  Natural and Flexible Error Recovery for Generated Modular Language Environments , 2012, TOPL.

[12]  Ruzica Piskac,et al.  Code Completion using Quantitative Type Inhabitation , 2011 .

[13]  Gabriel Scherer,et al.  Merlin: a language server for OCaml (experience report) , 2018, Proc. ACM Program. Lang..

[14]  Guido Wachsmuth,et al.  Principled syntactic code completion using placeholders , 2016, SLE.

[15]  Marinus J. Plasmeijer,et al.  Systematic synthesis of functions , 2006, Trends in Functional Programming.

[16]  David Darais,et al.  Parsing with derivatives: a functional pearl , 2011, ICFP.

[17]  João Saraiva,et al.  Lrc - A Generator for Incremental Language-Oriented Tools , 1998, International Conference on Compiler Construction.

[18]  Eelco Visser,et al.  Towards Language-Parametric Semantic Editor Services Based on Declarative Type System Specifications (Brave New Idea Paper) , 2019, ECOOP.

[19]  Johan Jeuring,et al.  Generating generic functions , 2006, WGP '06.

[20]  Markus Völter,et al.  Robust projectional editing , 2017, SLE.

[21]  Kevin A. Schneider,et al.  Grammar programming in TXL , 2002, Proceedings. Second IEEE International Workshop on Source Code Analysis and Manipulation.

[22]  Colin Runciman,et al.  Retrieving re-usable software components by polymorphic type , 1989, Journal of Functional Programming.

[23]  Terence Parr,et al.  LL(*): the foundation of the ANTLR parser generator , 2011, PLDI '11.

[24]  Romain Robbes,et al.  How Program History Can Improve Code Completion , 2008, 2008 23rd IEEE/ACM International Conference on Automated Software Engineering.

[25]  Isao Sasano,et al.  An approach to completing variable names for implicitly typed functional languages , 2012, PEPM '12.

[26]  Mikael Rittri,et al.  Using types as search keys in function libraries , 1989, Journal of Functional Programming.

[27]  Thomas W. Reps,et al.  The synthesizer generator , 1984, SDE 1.

[28]  João Saraiva Component-Based Programming for Higher-Order Attribute Grammars , 2002, GPCE.

[29]  Bruce McKenzie Generating Strings at Random from a Context Free Grammar , 1997 .

[30]  A. Denise,et al.  Random generation of words of context-free languages according to the frequencies of letters , 2000 .