Silverchain: A Fluent API Generator

Опубликовано: 25 Апрель 2026
на канале: Splash Conference 2017
125
1

Tomoki Nakamaru, Kazuhiro Ichikawa, Tetsuro Yamazaki, Shigeru Chiba
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 $\epsilon$-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.