-
-
Notifications
You must be signed in to change notification settings - Fork 10
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
feat: add item predicate syntax and inline loot arguments #297
Conversation
Did you make |
Yeah that's the bulk of the problem. The issue is that item predicates allow a complex syntax including |
fa0b4e6
to
7395ba4
Compare
7395ba4
to
dacccbb
Compare
I'm happy with the PR now. Feel free to review @vberlier @RitikShah |
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'm not as familiar with the Mecha codebase but this implementation from the last commit seems cleaner.
mecha/serialize.py
Outdated
yield node.value | ||
|
||
@rule(AstItemTestGroup) | ||
def item_test_group(self, node: AstItemTestGroup, result: List[str]): |
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 don't really understand this implementation. what's with sep
and comma
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.
ohh, it's just adjusting what's outputted based on how many items need to be outputted..
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 mostly took this from self.collection
, but that always requires some kind of surrounding brackets and uses commas as separators, which was too limiting
After looking at the PR and investigating the official changelog I thought it would probably be more useful down the line if we split AstItem into separate node types AstItemStack and AstItemPredicate, so that's what I did and released in |
This PR adds support for the new item predicate syntax.
I would like some feedback, mostly on the AST structure and maybe on the parser (could it be split up, does it need anything special to support multiline?)
Also the tests are failing, probably because I changed the AST result of the
item_predicate
format, it's no longer anAstItem
, but now anAstItemPredicate
. Would it be better to have a single AST that supports both?