skip to main content
article

Silverchain: a fluent API generator

Published:23 October 2017Publication History
Skip Abstract Section

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. Google ScholarGoogle ScholarDigital LibraryDigital Library
  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. Google ScholarGoogle ScholarDigital LibraryDigital Library
  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. Google ScholarGoogle ScholarDigital LibraryDigital Library
  4. Janusz Brzozowski. 1962. Canonical Regular Expressions and Minimal State Graphs for Definite Events. (1962), 529–561.Google ScholarGoogle Scholar
  5. John Cocke. 1969. Programming Languages and Their Compilers: Preliminary Notes. Courant Institute of Mathematical Sciences, New York University.Google ScholarGoogle Scholar
  6. Joel Costigliola. 2014. AssertJ / Fluent assertions for java. (December 2014). Retrieved September 4, 2017 from http://joel-costigliola.github. io/assertj/Google ScholarGoogle Scholar
  7. Bruno Courcelle. 1977. On Jump-Deterministic Pushdown Automata. Mathematical systems theory 11, 1 (Dec 1977), 87–109. Google ScholarGoogle ScholarCross RefCross Ref
  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.pdfGoogle ScholarGoogle Scholar
  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. Google ScholarGoogle ScholarDigital LibraryDigital Library
  10. Martin Fowler. 2005. FluentInterface. (December 2005). Retrieved September 4, 2017 from https://www.martinfowler.com/bliki/FluentI nterface.htmlGoogle ScholarGoogle Scholar
  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. Google ScholarGoogle ScholarCross RefCross Ref
  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/Google ScholarGoogle Scholar
  13. Sheila Greibach. 1965. A New Normal-Form Theorem for ContextFree Phrase Structure Grammars. J. ACM 12, 1 (Jan. 1965), 42–52. Google ScholarGoogle ScholarDigital LibraryDigital Library
  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. Google ScholarGoogle ScholarDigital LibraryDigital Library
  15. Hamcrest. 2012. Hamcrest. (August 2012). Retrieved September 4, 2017 from http://hamcrest.org/Google ScholarGoogle Scholar
  16. Michael Harrison and Ivan Havel. 1972. Real-Time Strict Deterministic Languages. SIAM J. Comput. 1, 4 (1972), 333–349. Google ScholarGoogle ScholarCross RefCross Ref
  17. Paul Hudak. 1996. Building Domain-specific Embedded Languages. ACM Comput. Surv. 28, 4es, Article 196 (Dec. 1996). Google ScholarGoogle ScholarDigital LibraryDigital Library
  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/scalalrGoogle ScholarGoogle Scholar
  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).Google ScholarGoogle Scholar
  20. Tadao Kasami. 1965. An Efficient Recognition and Syntax-Analysis Algorithm for Context-Free Languages. Technical Report. DTIC Document.Google ScholarGoogle Scholar
  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-implementationGoogle ScholarGoogle Scholar
  22. Tomer Levy. 2017. A Fluent API for Automatic Generation of Fluent APIs in Java. Ph.D. Dissertation. Israel Institute of Technology.Google ScholarGoogle Scholar
  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/215Google ScholarGoogle Scholar
  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. Google ScholarGoogle ScholarDigital LibraryDigital Library
  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. Google ScholarGoogle ScholarDigital LibraryDigital Library
  26. Ken Thompson. 1968. Programming Techniques: Regular Expression Search Algorithm. Commun. ACM 11, 6 (June 1968), 419–422. Google ScholarGoogle ScholarDigital LibraryDigital Library
  27. Peter Verhas. 2014. verhas/fluflu: Fluent Api Creator. (July 2014). Retrieved September 4, 2017 from https://github.com/verhas/flufluGoogle ScholarGoogle Scholar
  28. Hao Xu. 2010. EriLex: An Embedded Domain Specific Language Generator. Springer Berlin Heidelberg, Berlin, Heidelberg. 192–212 pages. Google ScholarGoogle ScholarCross RefCross Ref
  29. Daniel Younger. 1967. Recognition and parsing of context-free languages in time n3. Information and Control 10, 2 (1967), 189 – 208. Google ScholarGoogle ScholarCross RefCross Ref

Index Terms

  1. Silverchain: a fluent API generator

      Recommendations

      Comments

      Login options

      Check if you have access through your login credentials or your institution to get full access on this article.

      Sign in

      Full Access

      • Published in

        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
        • 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

        Copyright © 2017 ACM

        Publisher

        Association for Computing Machinery

        New York, NY, United States

        Publication History

        • Published: 23 October 2017

        Check for updates

        Qualifiers

        • article

      PDF Format

      View or Download as a PDF file.

      PDF

      eReader

      View online with eReader.

      eReader
      About Cookies On This Site

      We use cookies to ensure that we give you the best experience on our website.

      Learn more

      Got it!