Skip to content
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 extensions #10

Merged
merged 3 commits into from
Mar 5, 2015
Merged

Conversation

msantos
Copy link
Contributor

@msantos msantos commented Mar 5, 2015

Some small changes so you can do:

d = {'country-code': "US"}
filter = compileExpression('\'country-code\' ~= "^(US|CA)"')
filter(d)

The use of regular expression might break one of the guarantees (predictable).

Commit 80e8c12 (Restrict Object prototype functions) was applied to the
generated file rather than the source file.
A JSON key (referred to as a symbol by the filtrex grammar) is a string
that may contain operators. For example, a JSON key containing a dash is
valid but will be parsed as an arithmetic operation:

    {"country-code": "US"}
    compileExpression.parser.parse("country-code == \"US\"")

Results in:

    country - code == "US"

Indicate a literal symbol by using a single quote:

    compileExpression.parser.parse("'country-code' == \"US\"")

Similar to double quotes in strings, single quotes in symbols are
not valid: 'invalid\'symbol'
Introduce an operator (~=) to perform matches using regular expressions:

    {country: "US"}
    country ~= "^(US|CA)"
joewalnes added a commit that referenced this pull request Mar 5, 2015
@joewalnes joewalnes merged commit 3e85f75 into joewalnes:master Mar 5, 2015
@joewalnes
Copy link
Owner

Merged. Thanks!

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