Skip to content

Instantly share code, notes, and snippets.

@ingydotnet
Created August 16, 2010 08:24
Show Gist options
  • Save ingydotnet/526624 to your computer and use it in GitHub Desktop.
Save ingydotnet/526624 to your computer and use it in GitHub Desktop.
use Pegex;
use Pegex::Compiler;
use XXX;
my $grammar = <<'...';
foo: /foo/ <bar>?
bar: /bar/ <foo>?
...
# XXX 'Pegex::Compiler'->compile($grammar);
pegex($grammar)->parse("foo bar foo bar foo");
--- !!perl/hash:Pegex::Compiler
combined: &1
_FIRST_RULE: foo
bar:
+all:
- +re: bar
- +rule: foo
<: '?'
foo:
+all:
- +re: foo
- +rule: bar
<: '?'
grammar: *1
...
at t.pl line 10
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment