-
Notifications
You must be signed in to change notification settings - Fork 306
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Grammar Remake #342
Grammar Remake #342
Conversation
This is great! It would be some much better than the hermes grammar that we have now. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Wow! Great work! This ANTLR language looks very clean and learnable. This lowers the threshold for contributing to the grammar immensely.
@@ -0,0 +1,28 @@ | |||
# WDL Python2 Parser |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This is the python3 parser. Something is wrong in the generation script.
# Installing the runtime | ||
|
||
```bash | ||
pip install antlr4-python2-runtime |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Again python2 instead of python3
As a more general comment: Python2 is going to be deprecated within two months.
It might be better to remove the python2 parser all together.
## Parsers | ||
|
||
The grammars themselves cannot be used to parse a WDL as is, they first must be converted into a parser in one of the supported target languages. Currently | ||
Java, Python3, Python2, and JavaScript are supported. For Python and JavaScript you can use the `antlr4` command line tool to generate the required code that is used in the Parsers. For the java target, the easiest way to generate the code is to use the `mvn` plugin defined directly within the `pom.xml`. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Let's not merge a PR that combines "python2" and "supported" in one sentence. Python2 will be deprecated in a few days, but it still has a user base. It's much easier to not ship python2 support now than to get rid of it later.
Wow @rhpvorderman I completely forgot that the deprecation was happening. I will remove python2 support. I have no desire of maintaining deprecated code |
@rhpvorderman I have removed the python 2 code |
Not an official review but this is amazing. I suspect it'll take a long time (perhaps forever) before Cromwell is off of Hermes but this is a huge benefit for WDL in general |
I agree, very awesome indeed! @patmagee a few minor comments -
|
@cjllanwarne Thanks for the comments!
|
In think this should be backported to v1.0 so we can adequately test this against existing workflows before we can think of merging. I will get working on making a v1.0 |
@orodeh I have added support for 1.0 |
@cjllanwarne I have made a number of fixes and Improvements to the grammar based on the feedback from @orodeh as he works through creating a scala library from it. Additionally I have been working on making java bindings from the grammar as well. At the moment I think the grammar is in a good state and seems to be able to handle even a complex wdl (from testing locally). It would be great of you could review this again so we could potentially get it merged soon! |
@patmagee I updated to the latest grammar, and it works nicely with my scala code. This is great! I ran into an issue with For example, the following task is parsed correctly:
However, if you make a mistake and use
The |
In case anyone is interested, the code is at https://github.com/dnanexus-rnd/wdlTools/tree/develop |
Thanks for reviewing this @orodeh. That issue with the comment is strange. I'll test it locally to see if I can replicate it! I would not expect it to happen |
One more thing, name access in an object results in the wrong derivation (I think).
|
@orodeh thanks for the sleuthing! I pushed two fixes for the issue.
|
I pulled the updates, and both problems are fixed now. Thanks! |
I have worked with the grammar, and works very well. If anyone is interested in the Scala abstract syntax it is at AbstractSyntax.scala. 👍 |
Couldn't be more supportive of this. Thanks so much 👍 |
This is amazing 👍 |
Motivation
For a long time I have been bothered by the fact that the current Grammar and Parser language is more or less a dead project. While it has served us well, the knowledge of how to use it has largely since left the openWDL community. This generally means that modification of the Grammars is not an active part of the PR or development process, nor is there an easy way to test changes added the specification which is user accessible.
While writing grammars is not something that absolutely everyone knows how to do, I wanted to choose a langauge that was accessible for even a beginner which fit our needs, and had a large amount of supporting documenation. To that end I chose to write the grammars as
EBNF's
using ANTLR4.By changing the grammar I hope to encourage more community members to edit it as part of the PR process (potentially opening the way of requiring changes as part of the PR), as well as help facilitate testing of new features as being discussed #338
Why ANTLR
There are a large number of languages for writing grammars out there with varying different syntaxes. I originally started by trying to implement the spec strictly as a
BNF
. This quickly ran into issues as 1) there are not alot of tools for parser generation fo strict BNF's 2) WDL is already to complext to properly implement without special rules for command and string interpolation.Antlr4 provided a syntax which was familiar (EBNF), while still providing the ability to create parsers in a 8 different languages while allowing the grammar to be (mostly) agnostic of the target language.
The Changes
hermes
this
andself
referencesVisitors
orListeners
and I do not try to modify any of the tokens/tree that is returned. There are interfaces and base implementations for eachlanguage ofvisitors
andlisteners
that anyone can extend to fit their needsA big shout out to everyone whoe formally edited the hermes files, and for @mlin with their miniwdl implementation in Lark that helped with some decisions