We achieved a lot by learning about grammars in Perl 6. Just imagine the program we created can parse another program written in Perl 6!
There is still much room for improvement but you will definitely be able to do that. For example, you can start with implementing support for arrays.
Here is the full code of the compiler that we created in this chapter:
grammar G {
rule TOP {
^
[ <statement> \s* <comment>? ]*
$
}
rule statement {
[
| <variable-declaration>
| <assignment>
| <say-function>
]
';'
}
rule comment {
'#' <-[\n]>*
}
rule variable-declaration {
'my' <variable>
}
token variable {
<sigil> <identifier>
}
token sigil {
&apos...