Skip to content

Instantly share code, notes, and snippets.

Created April 18, 2009 13:31
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save anonymous/97606 to your computer and use it in GitHub Desktop.
Save anonymous/97606 to your computer and use it in GitHub Desktop.
## This is my attempt at writing a simple grammar in perl6
class EasyCMS::Template {
method render (Str $in, %vars) {
my $parsetree;
given $in {
$parsetree = m/<EasyCMS::Template::Grammar.template>/;
}
warn $parsetree.perl;
return $in;
}
}
grammar EasyCMS::Template::Grammar {
rule template { <statement>* }
rule statement { <expression> | <text> }
token text { [\w | \s]+ }
rule expression { \[ \% \s? <command> \s? \% \] }
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment