oriroth / fling Goto Github PK
View Code? Open in Web Editor NEWA fluent API generator
Home Page: http://drops.dagstuhl.de/opus/volltexte/2019/10805/
A fluent API generator
Home Page: http://drops.dagstuhl.de/opus/volltexte/2019/10805/
As.set
As.list
etc.
I've spent some time familiarising myself with Fling and I am positively impressed by your work. Naturally, I am starting to hit some limitations as I explore further. So the goal of this issue is to discuss one particular limitation. I'd like to know what you think and whether it is possible to overcome this limitation in Fling.
The limitation comes from the restriction on the class of accepted grammars, which must be LL. Here are some challenges that stem from it:
For example, let's consider a context-free grammar for a language that has predicates and means of combining them:
Condition = Predicate | Condition 'and' Condition | Condition 'or' Condition | '(' Condition ')'
Predicate = ...
Notably, this grammar is not LL as it involves left recursion.
To provide this grammar to Fling, it has first to be transformed:
Condition = Predicate Condition$$ | CompoundCondition
CompoundCondition = '(' Condition ')' Condition$$
Condition$ = 'or' Condition | 'and' Condition
Condition$$ = Condition$ Condition$$ | ε
Now in Fling:
derive(Condition).to(Predicate, Condition$$).or(CompoundCondition).
derive(CompoundCondition).to(begin, Condition, end, Condition$$).
derive(Condition$).to(or, Condition).or(and, Condition).
derive(Condition$$).to(Condition$, Condition$$).orNone().
And the resulting AST:
interface Condition {}
record Condition1(Predicate predicate, Condition$$ condition$$) implements Condition {}
record CompoundCondition(Condition condition, Condition$$ condition$$) implements Condition {}
interface Condition$ {}
record Condition$1(Condition condition) implements Condition$ {}
record Condition$2(Condition condition) implements Condition$ {}
interface Condition$$ {}
record Condition$$1(Condition$ condition$, Condition$$ condition$$) implements Condition$$ {}
record Condition$$2 implements Condition$$ {}
Clearly, such an AST is difficult to reason about because this is the level of LL grammars.
Ideally, an AST corresponding to the original grammar would have the following form:
interface Condition {}
record AndCondition(Condition left, Condition right) implements Condition {}
record OrCondition(Condition left, Condition right) implements Condition {}
record CompoundCondition(Condition cond) implements Condition {}
record Predicate(...) implements Condition {}
And the original grammar would be specified as follows:
specialize(Condition).into(AndCondition, OrCondition, CompoundCondition, Predicate)
derive(AndCondition).to(Condition, and, Condition).
derive(OrCondition).to(Condition, or, Condition).
derive(CompoundCondition).to(begin, Condition, end).
derive(Predicate).to(...).
Overall, it would be great to be able to:
As I already mentioned, I know that CFG to LL translation is possible, so point 1 could be achieved.
The requirement outlined in point 2, however, seems vastly more difficult to achieve. It would
probably also require changes to the parsing algorithm. A mapping between the original and
transformed grammars would need to be maintained and used to construct the desirable AST. I can only
guess at possible approaches, so I strongly wish to hear what the authors of Fling think.
and update the docs.
Place it in fling.examples, and name it:
ExamplesMainRunMeFirst.java
interface FluentLanguageAPI with methdos
On this, create a function that that takes FluentLanguageAPI and
creates Java file/mediator.
In variable.
Move into there all files that should not be user visible.
User visible classes are the ones you need to use the tools: BNF, adapters, Grammar, LL1, etc.
to loop over language definitions.
on fanyEBNF.
nullable, get first, follow, etc. should be in decorator(s)
Requires importing new library
Re paramater types.
from(char).to(char)
use:
fling.examples.grammars
fling.examples.automata
fling.examples.generated
E -> T E'
E' -> + T E' | -TE' |epsilon
T -> F T'
T' -> * F T' | /FT' |epsilon
F -> (E) | int
e.g., by
start(Expression).
derive(Expression).to(Summands).
derive(Summands).to(DegenerateSummands).
derive(Summands).to(Summand,SummandsList).
derive(Summand).to(sum(oneOrMore(Expression)).
derive(SummandsList).to(plus,Summand)
Chagne it to return a String. Do not print from this function
A declarative, efficient, and flexible JavaScript library for building user interfaces.
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
An Open Source Machine Learning Framework for Everyone
The Web framework for perfectionists with deadlines.
A PHP framework for web artisans
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
Some thing interesting about web. New door for the world.
A server is a program made to process requests and deliver data to clients.
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
Some thing interesting about visualization, use data art
Some thing interesting about game, make everyone happy.
We are working to build community through open source technology. NB: members must have two-factor auth.
Open source projects and samples from Microsoft.
Google ❤️ Open Source for everyone.
Alibaba Open Source for everyone
Data-Driven Documents codes.
China tencent open source team.