I was surprised when some of the previous rules in a list of rules got scopes from subsequent rules
Below is a minimal reproduction: there are 2 rules with 2 scopes (one per rule). The issue is that the scope punctuation.separator.id from the second rule creeps into all the 2nd+ terminals in the 1st rule
main : type id;
type{scope_type} : '\(' 'ttype' '\)' ; # 1a 'ttype)' also gets unnecessary punctuation.separator.id
#type{scope_type} : '\(tty' 'pe\)' ; # 1b 'tty' only has its own scope, 'pe)' gets an extra
id{punctuation.separator.id} : 'tid' ; # 2
The test string is (ttype)tid, I'd expect
rule 1a type above
to match 3 tokens (ttype and ) (it does)
assign a scope_type to them (it does)
then hand over to rule 2 id (it does)
then rule 2 id to simply match the following text tid and assign its own scope.
BUT for some reason rule 2 id also applies its scope to the text ttype) (except for the first match () that rule 1a already dealt with. (1b highlights that the issue seems to be with all the subsequent rules in 1atype, the first in the list is somehow special and not affected)
Is there a way to limit the damage from rule 2? If I wanted to attach a meta scope to (ttype), I'd just add it directly on the left hand side, and if I wanted to attach some scope to 2nd+ rules ttype and ) within 1 type, I'd do the same thing directly in the terminals
I was surprised when some of the previous rules in a list of rules got scopes from subsequent rules
Below is a minimal reproduction: there are 2 rules with 2 scopes (one per rule). The issue is that the scope
punctuation.separator.id
from the second rule creeps into all the 2nd+ terminals in the 1st ruleThe test string is
(ttype)tid
, I'd expect1a type
above(
ttype
and)
(it does)scope_type
to them (it does)2 id
(it does)2 id
to simply match the following texttid
and assign its own scope.BUT for some reason rule
2 id
also applies its scope to the textttype)
(except for the first match(
) that rule1a
already dealt with. (1b
highlights that the issue seems to be with all the subsequent rules in1a
type
, the first in the list is somehow special and not affected)Is there a way to limit the damage from rule
2
? If I wanted to attach a meta scope to(ttype)
, I'd just add it directly on the left hand side, and if I wanted to attach some scope to 2nd+ rulesttype
and)
within1 type
, I'd do the same thing directly in the terminals