Skip to content

Instantly share code, notes, and snippets.

/test.p6 Secret

Created June 7, 2017 23:19
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/6a0cfa870759761d18aa365784984869 to your computer and use it in GitHub Desktop.
Save anonymous/6a0cfa870759761d18aa365784984869 to your computer and use it in GitHub Desktop.
#!/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