Grammar-Kit icon indicating copy to clipboard operation
Grammar-Kit copied to clipboard

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

Open hurricup opened this issue 5 years ago • 1 comments

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 avatar Aug 10 '20 08:08 hurricup

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

hurricup avatar Aug 10 '20 08:08 hurricup