Created
September 7, 2014 12:13
-
-
Save rns/40d83c119ba7ae53a8fc to your computer and use it in GitHub Desktop.
This file contains hidden or 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
| use 5.010; | |
| use strict; | |
| use warnings; | |
| use Data::Dumper; | |
| use Marpa::R2 2.090; # for parse() | |
| my $g = Marpa::R2::Scanless::G->new( { | |
| source => \(<<'END_OF_SOURCE'), | |
| :default ::= action => [symbol, name, value] | |
| lexeme default = action => [symbol, name, value] latm => 1 | |
| e ::= n name => 'num' | |
| | e '*' e name => 'mul' | |
| || e '+' e name => 'add' | |
| n ~ [\d] | |
| :discard ~ whitespace | |
| whitespace ~ [\s]+ | |
| END_OF_SOURCE | |
| } ); | |
| my $input = <<EOI; | |
| 1 + 1 | |
| EOI | |
| say Dumper ${ | |
| $g->parse({ | |
| input => \$input, | |
| # trace_terminals => 1 | |
| }) | |
| }; |
rns
commented
Sep 7, 2014
Author
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment