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
Above example shows a common design: assume we have some keyword (x in this example), so it can not be parsed as a Ident in whole program, we want use a special symbol % to remove this limit: if prefix with %, allow use a keyword as ident.
When testing it, aa + bb is parsed succefully, x + y will failed because x is a keyword, not a ident, as excepted.
Next it parse %x + y, and panic.
If we change pattern of ident to [[:alpha:]][[:alnum:]]* (Just remove the inner group, or add ?: make it non-capture), it will works fine.
Maybe caused by here, the pattern of Ident call FindStringSubmatchIndex with data x + y will return a [0, 1, -1, -1], the last two -1 means the inner group ([[:alnum:]]) never captures:
The simplest way to fixes this may be add a guard:
But I'm not sure how this group intergrate with Action interface, may be it needs some type to indicate the empty capture? So I just open this issue, not a PR.
The text was updated successfully, but these errors were encountered:
I think this is probably occurring because Participle allows you to use references like \1 in the destination state, to refer to captured groups from the parent state. Because you have a capture group that doesn't capture anything, it's failing. It needs to cater to that case though.
Above example shows a common design: assume we have some keyword (
x
in this example), so it can not be parsed as aIdent
in whole program, we want use a special symbol%
to remove this limit: if prefix with%
, allow use a keyword asident
.When testing it,
aa + bb
is parsed succefully,x + y
will failed becausex
is a keyword, not aident
, as excepted.Next it parse
%x + y
, and panic.If we change pattern of
ident
to[[:alpha:]][[:alnum:]]*
(Just remove the inner group, or add?:
make it non-capture), it will works fine.Test code
Maybe caused by here, the pattern of
Ident
callFindStringSubmatchIndex
with datax + y
will return a[0, 1, -1, -1]
, the last two-1
means the inner group([[:alnum:]])
never captures:The simplest way to fixes this may be add a guard:
But I'm not sure how this group intergrate with Action interface, may be it needs some type to indicate the empty capture? So I just open this issue, not a PR.
The text was updated successfully, but these errors were encountered: