Skip to content

Instantly share code, notes, and snippets.

@rns
Last active August 29, 2015 14:06
Show Gist options
  • Save rns/3e11d82428fa6f3c7696 to your computer and use it in GitHub Desktop.
Save rns/3e11d82428fa6f3c7696 to your computer and use it in GitHub Desktop.
---
- S
-
  - S
  -
    - S
    - a
  -
    - S
    - a
  - +
-
  - S
  - a
- '*'
use 5.010;
use strict;
use warnings;
use Marpa::R2;
my $g = Marpa::R2::Scanless::G->new( {
source => \(<<'END_OF_SOURCE'),
:default ::= action => [ name, value]
lexeme default = action => [ value ] latm => 1
S ::= S S '+' | S S '*' | 'a'
:discard ~ whitespace
whitespace ~ [\s]+
END_OF_SOURCE
} );
my $input = <<EOI;
aa+a*
EOI
use YAML qw{ Dump };
say Dump ${ $g->parse( \$input ) };
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment