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

It's not possible to collapse rule to the token when it extends parent node #246

Open
hurricup opened this issue Aug 10, 2020 · 1 comment

Comments

@hurricup
Copy link
Contributor

hurricup commented Aug 10, 2020

E.g.

expr ::=
....
   | terminal_expr

terminal_expr ::= lazy_string {extends=expr}

lazy_string ::= some_content_collapsed_by_lexer {elementType=string hooks=[collapse]}
string ::= quote content quote {extraRoot=true extends=expr}

Instead of producing nice collapsed string, it does something like

string
  string
    some_content_collapsed_by_lexer

If I remove extends=expr from string rule, works fine (without extension), like:

terminal_expr
  string
    quote content quote

Ideally would be nice to be able to use just a string token produced by lexer, which should be parsed later. But for now it's not possible without producing wraping terminal_expr (at least I could not figure out how to do that)

@hurricup
Copy link
Contributor Author

hurricup commented Aug 10, 2020

Feels like information is lost somewhere here: GeneratedParserUtilBase.java:660. When extending elements to compact ast, we are copying element type and dropping optional data, like collapsed

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

1 participant