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

another position error with php5 #38

Closed
imuli opened this issue Jun 8, 2018 · 1 comment
Closed

another position error with php5 #38

imuli opened this issue Jun 8, 2018 · 1 comment

Comments

@imuli
Copy link
Contributor

imuli commented Jun 8, 2018

Again, the php7 parser produces sane output. This one looks like it's stemming from expr.Variable.

Sorry not to be submiting patches with these, I've never touched yacc before and am finding the parser a bit hard to follow. If I find more of these should I continue opening new bugs or just reopen this one with more info?

<?php
$here->where();
==> method_call.php
  | [*node.Root]
  |   "Position": Pos{Line: 2-2 Pos: 19-21};    # ought to be 7-21
  |   "Stmts":
  |     [*stmt.Expression]
  |       "Position": Pos{Line: 2-2 Pos: 19-21};    # ought to be 7-21
  |       "Expr":
  |         [*expr.MethodCall]
  |           "Position": Pos{Line: 2-2 Pos: 19-20};    # ought to be 7-20
  |           "Variable":
  |             [*expr.Variable]
  |               "Position": Pos{Line: 2-2 Pos: 7-20};    # ought to be 7-11
  |               "VarName":
  |                 [*node.Identifier]
  |                   "Position": Pos{Line: 2-2 Pos: 7-11};
  |                   "Value": here;
  |           "Method":
  |             [*node.Identifier]
  |               "Position": Pos{Line: 2-2 Pos: 14-18};
  |               "Value": where;
  |           "ArgumentList":
  |             [*node.ArgumentList]
  |               "Position": Pos{Line: 2-2 Pos: 19-20};
z7zmey added a commit that referenced this issue Jun 10, 2018
@z7zmey
Copy link
Owner

z7zmey commented Jun 10, 2018

Now dump looks like:

==> /Users/Vadim/work/go/src/github.com/z7zmey/php-parser/example.php
  | [*node.Root]
  |   "Position": Pos{Line: 2-2 Pos: 7-21};
  |   "Stmts":
  |     [*stmt.Expression]
  |       "Position": Pos{Line: 2-2 Pos: 7-21}; // represents `$here->where();`
  |       "Expr":
  |         [*expr.MethodCall]
  |           "Position": Pos{Line: 2-2 Pos: 7-20}; // represents `$here->where()`
  |           "Variable":
  |             [*expr.Variable]
  |               "Position": Pos{Line: 2-2 Pos: 7-11}; // represents `$here`
  |               "VarName":
  |                 [*node.Identifier]
  |                   "Position": Pos{Line: 2-2 Pos: 7-11}; // represents `$here`
  |                   "Value": here;
  |           "Method":
  |             [*node.Identifier]
  |               "Position": Pos{Line: 2-2 Pos: 14-18}; // represents `where`
  |               "Value": where;
  |           "ArgumentList":
  |             [*node.ArgumentList]
  |               "Position": Pos{Line: 2-2 Pos: 19-20}; // represents `()`

Feel free to opening issues. I will fix them as soon as possible.
Unfortunately, positions do not cover by tests yet.

z7zmey added a commit that referenced this issue Jun 10, 2018
@z7zmey z7zmey closed this as completed Jun 10, 2018
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

No branches or pull requests

2 participants