Skip to content

Instantly share code, notes, and snippets.

@masak
Created April 25, 2010 13:54
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 masak/378420 to your computer and use it in GitHub Desktop.
Save masak/378420 to your computer and use it in GitHub Desktop.
$ cat examples/mygrammar
use v6;
use GGE;
my $debug = False;
class MyGrammar is GGE::Grammar {
GGE::Perl6Regex.new("<bar>", :$debug, :grammar<MyGrammar>, :name<TOP>);
GGE::Perl6Regex.new("'OH HAI'", :$debug, :grammar<MyGrammar>, :name<bar>);
}
my GGE::Match $match
= MyGrammar.parse('this string contains "OH HAI" as a substring', :$debug);
say $match ?? $match.dump_str('mob', ' ', '') !! "No match\n";
$ alpha examples/mygrammar
mob: <OH HAI @ 22>
mob<bar>: <OH HAI @ 22>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment