Last active
March 25, 2021 22:27
-
-
Save cognominal/5846277 to your computer and use it in GitHub Desktop.
strange behavior of a grammar test in the Perl 6 shell. [see the comments. The problem is not what I originally described]The first two results are expected but not the third and the fourth that should match as well.Expected results : the b rules matches except at the second iteration. Because of the procedural alternation with the rule bdesigne…
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
> for '', 'a', 'aa', 'aaa' -> $t { say $! unless try say ( grammar { token TOP { <a> || <b> } ; token a { '[' ~ ']' a }; token b { "[$t]" } }).parse: "[$t]" } | |
「[]」 | |
b => 「[]」 | |
「[a]」 | |
a => 「[a]」 | |
Unable to parse expression in a; couldn't find final ']' | |
in any FAILGOAL at src/stage2/QRegex.nqp:1037 | |
in method parse at src/gen/CORE.setting:10695 | |
in method reify at src/gen/CORE.setting:6010 | |
in method reify at src/gen/CORE.setting:5905 | |
in method gimme at src/gen/CORE.setting:6333 | |
Unable to parse expression in a; couldn't find final ']' | |
in any FAILGOAL at src/stage2/QRegex.nqp:1037 | |
in method parse at src/gen/CORE.setting:10695 | |
in method reify at src/gen/CORE.setting:6010 | |
in method reify at src/gen/CORE.setting:5905 | |
in method gimme at src/gen/CORE.setting:6333 | |
> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
grammar A { | |
token TOP { <a> || <b> } ; | |
token a { '[' ~ ']' a }; | |
token b { { say $*t.perl } "[$*t]" } | |
}; | |
for '', 'a', 'aa', 'aaa' { | |
say "+$_"; | |
try { | |
say "-$_"; | |
my $*t = "[$_]"; | |
$/ = A.parse: $*t; | |
say $/.perl; | |
} | |
} |
Indeed I missed the pmichaud comment about "fail the match" for the ~ construct when it fails. I can't give the link beause irc log is down.
I don't see anything about "fail the whole match" for the tilda operator in S05
the ~ construct adds a "fail the match" component source: http://colabti.org/irclogger/irclogger_log/perl6?date=2013-06-23#l1118
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
I think the first result must be rejected if 'the ~ construct adds a "fail the match" component'