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

After a parse fails, parse.yy.ast is carrying left overs from the partially successful parse. #9

Closed
sdawood opened this issue May 14, 2015 · 1 comment

Comments

@sdawood
Copy link
Contributor

sdawood commented May 14, 2015

Currently after a parse error, parse.yy.ast is carrying left overs from the partially successful parse.
If the next path string has an identical "correct" prefix or the next path string has the same number of components or more, the bug goes unnoticed.

Example:

test('parser ast is reinitialized after parse() throws', function() {
assert.throws(function() { var path = jp.parse('store.book...') })
var path = jp.parse('$..price');
assert.deepEqual(path, [
{ "expression": { "type": "root", "value": "$" } },
{ "expression": { "type": "identifier", "value": "price" }, "operation": "member", "scope": "descendant"}
])
});

// Notice left-over component: { expression: { type: 'identifier', value: 'book' }, ... }

  1. parse-negative parser ast is reinitialized after parse() throws:
    AssertionError: [ { expression: { type: 'root', value: '$' } },
    { expression: { type: 'identifier', value: 'book' },
    scope: 'child',
    o deepEqual [ { expression: { type: 'root', value: '$' } },
    { expression: { type: 'identifier', value: 'price' },
    operation: 'member',
@sdawood
Copy link
Contributor Author

sdawood commented May 20, 2015

Problem still persists, pull request #10 would pass the tests but doesn't fit well with the JSONPath instance design

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 a pull request may close this issue.

1 participant