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

Error reported for negative indexed location tracking references, e.g. @-1 #29

Open
GerHobbelt opened this issue Nov 9, 2017 · 1 comment
Labels
Milestone

Comments

@GerHobbelt
Copy link
Owner

bison+jison-gho support $n for n <= 0:

Quoting the bison manual at https://www.gnu.org/software/bison/manual/html_node/Actions.html (bold emphasis mine):

$n with n zero or negative is allowed for reference to tokens and groupings on the stack before those that match the current rule.
This is a very risky practice, and to use it reliably you must be certain of the context in which the rule is applied. Here is a case in which you can use this reliably:

foo:
  expr bar '+' expr  { … }
| expr bar '-' expr  { … }
;
bar:
  %empty    { previous_expr = $0; }
;

As long as bar is used only in the fashion shown here, $0 always refers to the expr which precedes bar in the definition of foo.

As bison/jison/jison-gho support location references as well, format @n or @label, the above implies @-1 is a legal location ref.

That FAILS since 0.6.0-??? when we switched to parsing / validating action code chunks via a patched recast library: https://github.com/GerHobbelt/recast :: https://www.npmjs.com/package/@gerhobbelt/recast which recognizes all jison-gho supported reference types: $n, @n, #n, ##n, #label#... but still barfs on @-1.

Note

Given this, I expect my patched recast/esprima also barfs on #-1 and ##-1...

@GerHobbelt GerHobbelt added the bug label Nov 9, 2017
@GerHobbelt
Copy link
Owner Author

Observed while checking out #28 + #27.

GerHobbelt added a commit that referenced this issue Nov 9, 2017
…lon rule (which has no location info); add / introduce the `lexer::deriveLocationInfo()` API to help you & us to construct a more-or-less useful/sane location info object from the context surrounding it when the requested location info itself is not available.
GerHobbelt added a commit to GerHobbelt/esprima that referenced this issue Nov 10, 2017
…eference location, token and index variables fails for negative indexes
@GerHobbelt GerHobbelt added this to the 0.6.5 milestone Jun 17, 2018
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

1 participant