Course of Raku / Regexes and grammars / Grammars / What is a grammar / The grammar keyword
Quiz — What is a grammar
What does the following program print?
my token greet { 'hi' }
say so 'hi there' ~~ / <greet> /;| 1 | True |
| 0 | False |
| 0 | 「greet」 |
| 0 | hi |
The named token greet matches the literal text
hi. Calling it as <greet> inside the
pattern looks for that text, which is present at the start of
'hi there', so the match succeeds and so
returns True.