Corso di Raku / Espressioni regolari e grammatiche / Grammatiche / Che cos’è una grammatica / La parola chiave grammar
Quiz — Che cos’è una grammatica
Cosa stampa il programma seguente?
my token greet { 'hi' }
say so 'hi there' ~~ / <greet> /;| 1 | True |
| 0 | False |
| 0 | 「greet」 |
| 0 | hi |
Il token con nome greet riconosce il testo letterale
hi. Chiamarlo come <greet> dentro lo
schema cerca quel testo, che è presente all’inizio di
'hi there', quindi la corrispondenza riesce e
so restituisce True.