Is there a way to configure Raku actions to only execute after a parse has completed successfully? For example, the program below outputs "Jane is telling us her age….", even with malformed input.
grammar Foo {
rule TOP { <name> is \d+ }
token name { [Anne | Jane] { say "$/ is telling us her age...."; } }
}
say so Foo.parse('Anne is 100'); # True
say so Foo.parse('Jane is Leaf'); # False
Best Answer
You could move the code block to the rule
TOP
;using the routines
make
andmade
;or their combination.
Remember that for more complex problems, you can explore using Actions.