You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Right now extras is recursive: meaning that if there is a complicated (non-token) extra rule, other extras (including the rule itself!) could appear anywhere inside. While this is sometimes desirable, for example, one could get a nested /**/ comments just by adding an extra rule
comment: $=>seq('/*',repeat(/./),'*/')
but this could also be confusing:
What if my language doesn't actually support nesting and this was not intended?
Even if I want to support nested comments, I most likely don't want to show them as separate syntax nodes, just the top-level one, and there doesn't seem to be a way to achieve this.
Worse than that, if I also have a single line comments //, defined as
sl_comment: $=>seq('//',/[^\n]*/,'\n')
as another extra rule, that can also appear inside comment, potentially breaking the /* balancing, such that
/* /* // */
*/
is invalid. Again, this might be what you want, but there is no control over it.
Expected behavior
I think the easiest thing is to just make extras non-recursive: rules listed in extras can appear anywhere expect for the rules listed in extras themselves. I guess there are not many extras usually, so there nesting is desired, it could be added explicitly.
Alternatively, there could be an additional configuration for extras, specifying for every pair of extra rules, if one could appear inside another, but that's probably an overkill.
The text was updated successfully, but these errors were encountered:
Problem
Right now
extras
is recursive: meaning that if there is a complicated (non-token) extra rule, other extras (including the rule itself!) could appear anywhere inside. While this is sometimes desirable, for example, one could get a nested/*
*/
comments just by adding an extra rulebut this could also be confusing:
//
, defined ascomment
, potentially breaking the/*
balancing, such thatExpected behavior
I think the easiest thing is to just make
extras
non-recursive: rules listed inextras
can appear anywhere expect for the rules listed inextras
themselves. I guess there are not manyextras
usually, so there nesting is desired, it could be added explicitly.Alternatively, there could be an additional configuration for
extras
, specifying for every pair of extra rules, if one could appear inside another, but that's probably an overkill.The text was updated successfully, but these errors were encountered: