-
-
Save FROGGS/acffbcdec3956092e1db 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 MONKEY-SEE-NO-EVAL; | |
grammar Tabula { | |
rule TOP { <Scenario> } | |
rule Scenario { ^^ [:i scenario] ':' <Name=String> <Statement>+ } | |
rule Statement { ^^ <Step> <Comment>? } | |
rule Step { '?'? <Symbol> + } | |
token Symbol { <Word> || <Term> } | |
token Word { [<:Letter> || '_'] \w* } # using just \w+, numbers were words. | |
token Term { [ <Number> || <String> || <ID> ] } | |
token Comment { '//' \N+ } | |
token Number { \d+ } | |
token String { '"' <-[ " ]>+ '"' } | |
token ID { '#' <Word> } | |
} | |
my $input-tabula = 'scenario: "Eat the ripe apples" | |
spawn 7 ripe apples | |
spawn 3 unripe apples | |
pick apples // should only pick ripe | |
? verify 7 in basket | |
eat 2 | |
? verify they were tasty | |
? verify 5 in basket'; | |
my $g = Tabula.new; | |
my $parse = $g.parse( $input-tabula ); | |
say so $parse; | |
say $g.subparse( $input-tabula ); | |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment