hoaproject / Regex

The Hoa\Regex library.
https://hoa-project.net/
310 stars 17 forks source link

Simple `(...)` capturing group is not present in AST #38

Closed unkind closed 4 years ago

unkind commented 5 years ago
$ast = $compiler->parse('~(foo)(bar)~');
$visitor = new Dump();
$visitor->visit($ast);
>  #expression
>  >  #concatenation
>  >  >  token(literal, ~)
>  >  >  #concatenation
>  >  >  >  token(literal, f)
>  >  >  >  token(literal, o)
>  >  >  >  token(literal, o)
>  >  >  #concatenation
>  >  >  >  token(literal, b)
>  >  >  >  token(literal, a)
>  >  >  >  token(literal, r)
>  >  >  token(literal, ~)

I tried to dump ast via regular var_dump(), but I see no attribute for indexed capturing group. #concatenation is something different.

When I walk through AST, #capturing is never present.

--- Want to back this issue? **[Post a bounty on it!](https://www.bountysource.com/issues/66983752-simple-capturing-group-is-not-present-in-ast?utm_campaign=plugin&utm_content=tracker%2F6167031&utm_medium=issues&utm_source=github)** We accept bounties via [Bountysource](https://www.bountysource.com/?utm_campaign=plugin&utm_content=tracker%2F6167031&utm_medium=issues&utm_source=github).
unkind commented 5 years ago

After fixing Grammar file:

-capturing:
+#capturing:

it works:

>  #expression
>  >  #concatenation
>  >  >  token(literal, ~)
>  >  >  #capturing
>  >  >  >  #concatenation
>  >  >  >  >  token(literal, f)
>  >  >  >  >  token(literal, o)
>  >  >  >  >  token(literal, o)
>  >  >  #capturing
>  >  >  >  #concatenation
>  >  >  >  >  token(literal, b)
>  >  >  >  >  token(literal, a)
>  >  >  >  >  token(literal, r)
>  >  >  token(literal, ~)
Hywan commented 5 years ago

Hey,

Thanks for the clear bug report. Do you want to try a PR?

unkind commented 5 years ago

@Hywan I can make a PR for this diff of course, but I don't see tests and composer install gives

  Problem 1
    - Installation request for hoa/exception dev-master -> satisfiable by hoa/exception[dev-master].
    - hoa/exception dev-master requires hoa/event dev-master -> satisfiable by hoa/event[dev-master] but these conflict with your requirements or minimum-stability.
  Problem 2
    - Installation request for hoa/math dev-master -> satisfiable by hoa/math[dev-master].
    - hoa/math dev-master requires hoa/consistency ~1.0 -> satisfiable by hoa/consistency[1.16.01.11, 1.16.01.14, 1.16.03.03, 1.17.01.10, 1.17.05.02] but these conflict with your requirements or minimum-stability.
  Problem 3
    - hoa/exception dev-master requires hoa/event dev-master -> satisfiable by hoa/event[dev-master] but these conflict with your requirements or minimum-stability.
    - hoa/ustring dev-master requires hoa/exception dev-master -> satisfiable by hoa/exception[dev-master].
    - Installation request for hoa/ustring dev-master -> satisfiable by hoa/ustring[dev-master].

I tried to add

+    },
+    "minimum-stability": "dev"

but issue is still present:

  Problem 1
    - Installation request for hoa/math dev-master -> satisfiable by hoa/math[dev-master].
    - hoa/math dev-master requires hoa/consistency ~1.0 -> satisfiable by hoa/consistency[1.16.01.11, 1.16.01.14, 1.16.03.03, 1.17.01.10, 1.17.05.02] but these conflict with your requirements or minimum-stability.

And so on.

Versioning doesn't look clear.

Hywan commented 5 years ago

Yeah, we are migrating the entire Hoa project to a new version. Open the PR, and I will take care of everything.