skip to main content
10.1145/3136040.3136041acmconferencesArticle/Chapter ViewAbstractPublication PagesgpceConference Proceedingsconference-collections
research-article

Silverchain: a fluent API generator

Published: 23 October 2017 Publication History

Abstract

This paper presents a tool named Silverchain, which generates class definitions for a fluent API from the grammar of the API. A fluent API is an API that is used by method chaining and its grammar is a BNF-like set of rules that defines method chains accepted in type checking. Fluent APIs generated by Silverchain provide two styles of APIs: One is for building a chain by concatenating all method calls in series. The other is for building a chain from partial chains by passing child chains to method calls in the parent chain as their arguments. To generate such a fluent API, Silverchain first translates given grammar into a set of deterministic pushdown automata without ϵ-transitions, then encodes these automata into class definitions. Each constructed automata corresponds to a nonterminal in given grammar and recognizes symbol sequences produced from its corresponding nonterminal.

References

[1]
Rajeev Alur and Parthasarathy Madhusudan. 2004. Visibly Pushdown Languages. In Proceedings of the Thirty-sixth Annual ACM Symposium on Theory of Computing (STOC ’04). ACM, New York, NY, USA, 202–211.
[2]
Eric Bodden. 2010. Efficient Hybrid Typestate Analysis by Determining Continuation-equivalent States. In Proceedings of the 32Nd ACM/IEEE International Conference on Software Engineering - Volume 1 (ICSE ’10). ACM, New York, NY, USA, 5–14.
[3]
Eric Bodden. 2014. TS4J: A Fluent Interface for Defining and Computing Typestate Analyses. In Proceedings of the 3rd ACM SIGPLAN International Workshop on the State of the Art in Java Program Analysis (SOAP ’14). ACM, New York, NY, USA, 1–6.
[4]
Janusz Brzozowski. 1962. Canonical Regular Expressions and Minimal State Graphs for Definite Events. (1962), 529–561.
[5]
John Cocke. 1969. Programming Languages and Their Compilers: Preliminary Notes. Courant Institute of Mathematical Sciences, New York University.
[6]
Joel Costigliola. 2014. AssertJ / Fluent assertions for java. (December 2014). Retrieved September 4, 2017 from http://joel-costigliola.github. io/assertj/
[7]
Bruno Courcelle. 1977. On Jump-Deterministic Pushdown Automata. Mathematical systems theory 11, 1 (Dec 1977), 87–109.
[8]
Joseph Darcy. 2016. JDK 9 Language, Tooling, and Library Features. (September 2016). Retrieved September 4, 2017 from https: //cdn.app.compendium.com/uploads/user/e7c690e8-6ff9-102a-ac6d -e4aebca50425/f4a5b21d-66fa-4885-92bf-c4e81c06d916/File/e1950f 4e52d2b112757b70cf28caa117/j1_2016_jdk9_lang_tools_libs.pdf
[9]
Sebastian Erdweg, Tillmann Rendel, Christian Kästner, and Klaus Ostermann. 2011. SugarJ: Library-based Syntactic Language Extensibility. In Proceedings of the 2011 ACM International Conference on Object Oriented Programming Systems Languages and Applications (OOPSLA ’11). ACM, New York, NY, USA, 391–406.
[10]
Martin Fowler. 2005. FluentInterface. (December 2005). Retrieved September 4, 2017 from https://www.martinfowler.com/bliki/FluentI nterface.html
[11]
Yossi Gil and Tomer Levy. 2016. Formal Language Recognition with the Java Type Checker. In 30th European Conference on Object-Oriented Programming (ECOOP 2016), Shriram Krishnamurthi and Benjamin S. Lerner (Eds.), Vol. 56. Schloss Dagstuhl–Leibniz-Zentrum fuer Informatik, Dagstuhl, Germany, 10:1–10:27.
[12]
Data Geekery GmbH. 2017. jOOQ: The easiest way to write SQL in Java. (September 2017). Retrieved September 4, 2017 from https: //www.jooq.org/
[13]
Sheila Greibach. 1965. A New Normal-Form Theorem for ContextFree Phrase Structure Grammars. J. ACM 12, 1 (Jan. 1965), 42–52.
[14]
Radu Grigore. 2017. Java Generics Are Turing Complete. In Proceedings of the 44th ACM SIGPLAN Symposium on Principles of Programming Languages (POPL 2017). ACM, New York, NY, USA, 73–85.
[15]
Hamcrest. 2012. Hamcrest. (August 2012). Retrieved September 4, 2017 from http://hamcrest.org/
[16]
Michael Harrison and Ivan Havel. 1972. Real-Time Strict Deterministic Languages. SIAM J. Comput. 1, 4 (1972), 333–349.
[17]
Paul Hudak. 1996. Building Domain-specific Embedded Languages. ACM Comput. Surv. 28, 4es, Article 196 (Dec. 1996).
[18]
Kazuhiro Ichikawa. 2016. phenan/scalalr: ScaLALR : LALR parser generator for embedded DSLs in Scala. (December 2016). Retrieved September 4, 2017 from https://github.com/phenan/scalalr
[19]
Kazuhiro Ichikawa and Shigeru Chiba. 2017. User-Defined Operators Including Name Binding for New Language Constructs. The Art, Science, and Engineering of Programming 1, 2, Article 15 (2017).
[20]
Tadao Kasami. 1965. An Efficient Recognition and Syntax-Analysis Algorithm for Context-Free Languages. Technical Report. DTIC Document.
[21]
Ansgar Konermann. 2010. Emulating "self types" using Java Generics to simplify fluent API implementation. (November 2010). Retrieved September 4, 2017 from http://web.archive.org/web/20130721224442/http: /passion.forco.de/content/emulating-self-types-using-java-generics -simplify-fluent-api-implementation
[22]
Tomer Levy. 2017. A Fluent API for Automatic Generation of Fluent APIs in Java. Ph.D. Dissertation. Israel Institute of Technology.
[23]
Vicente Romero and Maurizio Cimadamore. 2016. JEP 215: Tiered Attribution for javac. (July 2016). Retrieved September 4, 2017 from http://openjdk.java.net/jeps/215
[24]
Daniel Rosenkrantz and Richard Stearns. 1969. Properties of Deterministic Top Down Grammars. In Proceedings of the First Annual ACM Symposium on Theory of Computing (STOC ’69). ACM, New York, NY, USA, 165–180.
[25]
Robert Strom and Shaula Yemini. 1986. Typestate: A programming language concept for enhancing software reliability. IEEE Transactions on Software Engineering SE-12, 1 (Jan 1986), 157–171.
[26]
Ken Thompson. 1968. Programming Techniques: Regular Expression Search Algorithm. Commun. ACM 11, 6 (June 1968), 419–422.
[27]
Peter Verhas. 2014. verhas/fluflu: Fluent Api Creator. (July 2014). Retrieved September 4, 2017 from https://github.com/verhas/fluflu
[28]
Hao Xu. 2010. EriLex: An Embedded Domain Specific Language Generator. Springer Berlin Heidelberg, Berlin, Heidelberg. 192–212 pages.
[29]
Daniel Younger. 1967. Recognition and parsing of context-free languages in time n3. Information and Control 10, 2 (1967), 189 – 208.

Cited By

View all

Recommendations

Comments

Information & Contributors

Information

Published In

cover image ACM Conferences
GPCE 2017: Proceedings of the 16th ACM SIGPLAN International Conference on Generative Programming: Concepts and Experiences
October 2017
258 pages
ISBN:9781450355247
DOI:10.1145/3136040
  • cover image ACM SIGPLAN Notices
    ACM SIGPLAN Notices  Volume 52, Issue 12
    GPCE '17
    December 2017
    258 pages
    ISSN:0362-1340
    EISSN:1558-1160
    DOI:10.1145/3170492
    Issue’s Table of Contents
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

In-Cooperation

Publisher

Association for Computing Machinery

New York, NY, United States

Publication History

Published: 23 October 2017

Permissions

Request permissions for this article.

Check for updates

Author Tags

  1. Embedded DSL
  2. Fluent API

Qualifiers

  • Research-article

Conference

SPLASH '17
Sponsor:

Acceptance Rates

Overall Acceptance Rate 56 of 180 submissions, 31%

Contributors

Other Metrics

Bibliometrics & Citations

Bibliometrics

Article Metrics

  • Downloads (Last 12 months)23
  • Downloads (Last 6 weeks)10
Reflects downloads up to 06 Nov 2024

Other Metrics

Citations

Cited By

View all

View Options

Get Access

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