-
Notifications
You must be signed in to change notification settings - Fork 44
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
Adding grammar for v0.10.0 #66
Conversation
Codecov Report
@@ Coverage Diff @@
## master #66 +/- ##
==========================================
+ Coverage 82.24% 84.31% +2.07%
==========================================
Files 33 35 +2
Lines 1667 2098 +431
==========================================
+ Hits 1371 1769 +398
- Misses 296 329 +33
Continue to review full report at Codecov.
|
Questions about the grammar
|
This is great stuff @fekad , please request reviews when you're ready so we can get this in! |
Suggestions/ideas/questions about the specificationWe can also suggest the following tiny modification(s) in the spec:
Note: Please free to modify/extend this list! |
@ml-evs Please feel free the review/modify/add stuff to this branch anytime (Eventually that was the main reason to use a branch instead of my own repo :)). There is also a new |
This seems like a very straight-forward and logical suggestion. I would probably put @sauliusg, @merkys, and @rartino as reviewers. |
Co-Authored-By: Casper Welzel Andersen <[email protected]>
Co-Authored-By: Casper Welzel Andersen <[email protected]>
Co-Authored-By: Casper Welzel Andersen <[email protected]>
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.
A couple of comments more :)
And by the way, for the run.py
, I actually do not mind having it in. Indeed, if anyone decides to develop a server in a Windows environment, it may be prudent to not have a bash script to start the server as a standard.
But it should be one or the other. And if it's run.py
, we need to update .travis.yml
. Thinking more about this, I will make an issue for this and a separate PR, since it's not within the scope of the current one.
from .lark_parser import LarkParser, ParserError | ||
|
||
__all__ = [LarkParser, ParserError] |
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.
To make this more dynamic, you could do a *
import and specify the __all__
in lark_parser.py
.
This __all__
then becomes lark_parser.__all__
.
In this way, if you decide to reveal other classes from lark_parser
, you'll add them to that file's __all__
instead of the __init__.py
.
See, e.g., here.
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.
Personally, I don't like to usage of *
in imports. There are a lot of articles in favour and against its usage (this is just the first match on google). It is similar to the usage of global
variable.
Of course, I will modify it as you suggested to keep the repo consistent.
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.
I understand. We should at some point have a consensus concerning this package of what we do.
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.
The last * imports is not crucial for the merging of this PR, only for consistency with the rest of the repository.
So I vote to just get this is now, so that we can start developing our Transformer
s :)
Thank you immensely for this contribution @fekad 👍
Before merging, I would like the approval of @ml-evs as well - or I will at least leave a time-window of opportunity before merging 😅
Working on it! I think you've sorted out any requested changes to the code, so I'll just focus on double checking it all works in the example server. Would you mind commenting if you get a chance @fekad? I'm sure most of them are my fault... Current issues:
|
As far as I can see, these are all valid queries (if I infer some % terminology). The only HAS that is currently implemented is property HAS value. Nothing else. Also LENGTH is not implemented. |
Ah okay, I was trying to match the grammar tests but I guess you mean its not implemented in the transformer? In that case I'm happy to add skips to these tests until we have them in. They do currently raise Lark errors rather than the NotImplementedError I'd expect from the code. I assume the same thing doesn't apply to the pagination though? |
A slight curiosity is that |
Hi, thanks for the test cases and the review @ml-evs @CasperWA. This bug is actually caused by the More about this here: #66 (comment) |
Yeah, only the implementation of the Unfortunately Lark code catches my NotImplementedError and raises its own error.
This was a tricky one :). You have to use |
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.
Thanks @fekad , I was definitely being stupid for a few of those, but the fixes/responses look good. Happy to accept as is, but I'll leave merging to you!
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.
Could you clarify what has happened concerning the predicate_comparison
, i.e., should we simply merge here, and if this PR will change (again) before being merged, we "bug-fix" the grammar/transformer? Or should we wait until the spec. PR has been merged?
In my opinion, since we do not have 1 commit per 1 concept, it doesn't matter. More concretely, since the v0.10.0 grammar addition cannot be pinpointed to a specific commit, but rather has been implemented over several commits (and will be merged in like this via this PR), another commit to alter it after this PR has been merged, will not make a difference in the git history.
What do you think @fekad and @ml-evs? If we all agree, I will approve and merge.
Since there have been no response, I will merge this and take it that you agree; we can "bug-fix" when the spec. PR has been merged, if needed. |
Thank for the previous work of @waychal, this is a PR for the grammar of the v0.10.0 specification. This grammar maps the original specification of the "Filter Language EBNF Grammar" into lark format. Although I applied some simplifications (like ignoring white space, used some definition from the common library...), all of them just makes the filters more robust.
Note: It also contains all the optional features, but they can be ignored during the transformation by using the
__default__
method of theTransformer
classes..g
to.lark
for allowing syntax highlightsTransformer
class