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.
- 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 Scholar
Digital Library
- 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 Scholar
Digital Library
- 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 Scholar
Digital Library
- Janusz Brzozowski. 1962. Canonical Regular Expressions and Minimal State Graphs for Definite Events. (1962), 529–561.Google Scholar
- John Cocke. 1969. Programming Languages and Their Compilers: Preliminary Notes. Courant Institute of Mathematical Sciences, New York University.Google Scholar
- Joel Costigliola. 2014. AssertJ / Fluent assertions for java. (December 2014). Retrieved September 4, 2017 from http://joel-costigliola.github. io/assertj/Google Scholar
- Bruno Courcelle. 1977. On Jump-Deterministic Pushdown Automata. Mathematical systems theory 11, 1 (Dec 1977), 87–109. Google Scholar
Cross Ref
- 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 Scholar
- 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 Scholar
Digital Library
- Martin Fowler. 2005. FluentInterface. (December 2005). Retrieved September 4, 2017 from https://www.martinfowler.com/bliki/FluentI nterface.htmlGoogle Scholar
- 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 Scholar
Cross Ref
- 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 Scholar
- Sheila Greibach. 1965. A New Normal-Form Theorem for ContextFree Phrase Structure Grammars. J. ACM 12, 1 (Jan. 1965), 42–52. Google Scholar
Digital Library
- 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 Scholar
Digital Library
- Hamcrest. 2012. Hamcrest. (August 2012). Retrieved September 4, 2017 from http://hamcrest.org/Google Scholar
- Michael Harrison and Ivan Havel. 1972. Real-Time Strict Deterministic Languages. SIAM J. Comput. 1, 4 (1972), 333–349. Google Scholar
Cross Ref
- Paul Hudak. 1996. Building Domain-specific Embedded Languages. ACM Comput. Surv. 28, 4es, Article 196 (Dec. 1996). Google Scholar
Digital Library
- 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 Scholar
- 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 Scholar
- Tadao Kasami. 1965. An Efficient Recognition and Syntax-Analysis Algorithm for Context-Free Languages. Technical Report. DTIC Document.Google Scholar
- 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 Scholar
- Tomer Levy. 2017. A Fluent API for Automatic Generation of Fluent APIs in Java. Ph.D. Dissertation. Israel Institute of Technology.Google Scholar
- 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 Scholar
- 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 Scholar
Digital Library
- 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 Scholar
Digital Library
- Ken Thompson. 1968. Programming Techniques: Regular Expression Search Algorithm. Commun. ACM 11, 6 (June 1968), 419–422. Google Scholar
Digital Library
- Peter Verhas. 2014. verhas/fluflu: Fluent Api Creator. (July 2014). Retrieved September 4, 2017 from https://github.com/verhas/flufluGoogle Scholar
- Hao Xu. 2010. EriLex: An Embedded Domain Specific Language Generator. Springer Berlin Heidelberg, Berlin, Heidelberg. 192–212 pages. Google Scholar
Cross Ref
- Daniel Younger. 1967. Recognition and parsing of context-free languages in time n3. Information and Control 10, 2 (1967), 189 – 208. Google Scholar
Cross Ref
Index Terms
Silverchain: a fluent API generator
Recommendations
Generating a fluent API with syntax checking from an LR grammar
This paper proposes a fluent API generator for Scala, Haskell, and C++. It receives a grammar definition and generates a code skeleton of the library in the host programming language. The generated library is accessed through a chain of method calls; ...
Silverchain: a fluent API generator
GPCE 2017: Proceedings of the 16th ACM SIGPLAN International Conference on Generative Programming: Concepts and ExperiencesThis 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 ...
Fluent APIs in Functional Languages
Fluent API is an object-oriented pattern for elegant APIs and embedded DSLs. A smart fluent API can enforce the API protocol or DSL syntax at compile time. Since fluent API implementations typically rely on overloading function names, they are hard ...







Comments