Created
April 26, 2010 15:30
-
-
Save snarkyboojum/379470 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
use v6; | |
my $VERSION = '2010.05'; | |
grammar Yapsi::Perl6::Grammar { | |
regex TOP { ^ <statementlist> $ } | |
regex statementlist { <statement> ** <eat_terminator> } | |
token statement { <expression> } | |
token eat_terminator { <?after '}'> \n || <.ws> ';' <.ws> } | |
token expression { <assignment> || <binding> || <variable> || <literal> | |
|| <declaration> || <saycall> || <increment> | |
|| <block> || <empty> } | |
token lvalue { <declaration> || <variable> || <increment> } | |
token value { <variable> || <literal> || <declaration> || <saycall> | |
|| <increment> } | |
token variable { '$' \w+ } | |
token literal { \d+ } | |
token empty { '' } | |
rule declaration { 'my' <variable> } | |
rule assignment { <lvalue> '=' <expression> } | |
rule binding { <lvalue> ':=' <expression> } | |
rule saycall { 'say' <expression> } # very temporary solution | |
rule increment { '++' <value> } | |
token block { <.ws> '{' <.ws> <statementlist> <.ws> '}' } | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment