-
-
Save anonymous/6a0cfa870759761d18aa365784984869 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
#!/usr/bin/env perl6 | |
use v6; | |
use lib 'lib'; | |
use Grammar::Tracer; | |
grammar Gpl::Language | |
{ | |
rule test { <simple_type> <T_ID> <optional_initializer>? } | |
rule simple_type | |
{ | |
<T_INT> || | |
<T_DOUBLE> || | |
<T_STRING> | |
} | |
rule optional_initializer { 'nope' } | |
token T_INT { 'int' } | |
token T_DOUBLE { 'double' } | |
token T_STRING { 'string' } | |
token T_ID { <[a..z A..Z _]><[0..9 a..z A..Z _]>* } | |
# token ws { [ \h || \v ]* } | |
} | |
my $res = Gpl::Language.parse("double x", rule => 'test'); | |
dd $res; | |
say so $res; |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment