rascal icon indicating copy to clipboard operation
rascal copied to clipboard

Align the behavior of syntactical and lexical nonterminals in TreeAsNode

Open rodinaarssen opened this issue 3 years ago • 3 comments

Is your feature request related to a problem? Please describe. Currently, the behavior of generated abstract syntax constructors (i.e., TreeAsNode) differs between syntax and lexical nonterminals: for syntax nonterminals, terminal symbols in the production are ignored, whereas they are not for lexical nonterminals.

rascal>lexical A = a: [a]+;
ok
rascal>lexical B = b: A lhs "." A rhs;
ok
rascal>syntax C = c: A lhs "." A rhs;
ok
rascal>c(_, _) := (C)`a.a`
bool: true
rascal>b(_, _) := (B)`a.a`
bool: false
rascal>if (b(_, dot, _) := (B)`a.a`) println(dot);
.
ok

NB: the typechecker currently expects syntax-like behavior for lexical nonterminals

rodinaarssen avatar Jan 12 '22 16:01 rodinaarssen

@PaulKlint @DavyLandman @tvdstorm this is a really easy change in the interpreter. I don't think our users use this feature much since it is not well-documented (or even documented at all).

  • what would be the impact of the change in existing Rascal code? parser generator, type-checker, compiler, salix?
  • other concerns?

jurgenvinju avatar Jan 13 '22 08:01 jurgenvinju

I was recently confused by this behavior as well. I think it should be more like the syntax behavior.

I agree with the analysis that there will not be a big impact of this change.

DavyLandman avatar Jan 13 '22 08:01 DavyLandman

Changing the interpreter will not be a big thing in itself, but if the feature is used in the parser generator or the type-checker or the compiler, then the impact could be significant enough to plan a project for this change and a RAP. If not then we can "just" change it.

jurgenvinju avatar Jan 13 '22 09:01 jurgenvinju