Skip to content
New issue

Have a question about this project? # for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “#”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? # to your account

Support root level wildcards #7

Merged
merged 3 commits into from
Jul 9, 2013
Merged

Support root level wildcards #7

merged 3 commits into from
Jul 9, 2013

Conversation

jamesls
Copy link
Member

@jamesls jamesls commented Jul 7, 2013

Fixes #4

This PR also cleans up some of the grammar and fixes some of the quirky parts of the AST. The simplified subexpression grammar is roughly:

        expression : subexpression
                   : STAR

        subexpression : expression DOT expression

I also removed the ElementsBranch and ValuesBranch which was unnecessary. The parsing rules have been unified to just used subexpressions so instead of ElementsBranch(Field(foo)) it's just SubExpression(Field(foo), WildcardIndex()) for foo[*]. Similar thing for WildcardValues. This means that root level wildcards (in the case of a subexpression) is just SubExpression(WildcardValues(), Field(foo)) which has a nice symmetry to the now simplified inverted rule for field.*: SubExpression(Field(foo), WildcardValues())

jamesls added 3 commits July 7, 2013 14:38
The ElementsBranch node has been removed, it can be represented
with the new WildcardIndex.  Previously foo[0] and foo[*] parsed
to two different structures.  Now both use a SubExpression node and
the wildcard is just represented as a WildcardIndex instead of an
Index node::

    SubExpression(AST(...), WildcardIndex())

Which makes the constructed ASTs more consistent.

I've also updated the parser grammar to not require separate rules
for root indices vs. indices in a subexpression.
Similar to wildcard index simplification, now
foo.* is written with a subexpression node::

    SubExpression(Field(foo), WildcardValues())

where WildcardValues just multimatches the values of the dict.
This also simplified the grammar such that another rule could be
collapsed into the existing subexpression rule.
Fixes #4.

This also cleans up some of the grammar rules::

    expression : subexpression
               : STAR

    subexpression : expression DOT expression
@toastdriven
Copy link

🎉 ♣️ = :shipit:

@mtdowling
Copy link
Contributor

🚢

@jamesls jamesls merged commit d3cc657 into develop Jul 9, 2013
@jamesls jamesls deleted the root-wildcard branch November 28, 2013 17:44
# for free to join this conversation on GitHub. Already have an account? # to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Allow root level wildcards
3 participants