Skip to content

Adding a Json BNF and use-case#20

Open
metormaon wants to merge 14 commits intoOriRoth:masterfrom
metormaon:master
Open

Adding a Json BNF and use-case#20
metormaon wants to merge 14 commits intoOriRoth:masterfrom
metormaon:master

Conversation

@metormaon
Copy link
Collaborator

No description provided.

metormaon and others added 14 commits May 23, 2020 01:26
Caching dependencies; Trying to generate sources.
Adding github's token. Will it help?
Removing the debug log, in which I drown...
#2 - reverting, since I could find yet a way with maven(😡) to compile only LoopOverLanguageDefinitions.java and direct dependencies, to generate sources before full compilation.
@metormaon metormaon requested a review from OriRoth May 23, 2020 15:50
@metormaon metormaon closed this May 23, 2020
@metormaon
Copy link
Collaborator Author

I forgot to remove something that was supposed to be useful for me, but will not do good to your project (git acrions workflow that keeps failing).

@metormaon
Copy link
Collaborator Author

Taking it back: it passes. Reopening.

@metormaon metormaon reopened this May 23, 2020
@metormaon metormaon requested a review from yossigil May 23, 2020 15:55
value("f");
value(8);
value(true);
array(); //TODO: how come this is legal?
Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

array() is a legal prefix of your grammar. To terminate a fluent program (and generate AST) you should call $() as well. Notice array().$() should not compile.
You can read on AST generation in the paper.

or(value.with(Number.class)).
or(value.with(Boolean.class)).
or(_null_).
derive(Field).to(key.with(String.class), isSetTo, Element).
Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

If you want, you can try instead isSetTo.with(Element). Fling does support nested APIs. (I.e., API as API function argument.)
Notice inner API calls should not end with a call to $().

// @formatter:off
public class Json {
public static void main(String[] args) {
value("f");
Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

If you want, you can practice AST traversal by, say, pretty-printing the JSON objects. You can check the other use-cases for examples.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants