Created
January 11, 2014 15:54
-
-
Save rns/8372608 to your computer and use it in GitHub Desktop.
Show symbol_dsl_form()'s of all symbols_ids()
This file contains 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; | |
my $g = Marpa::R2::Scanless::G->new( { | |
bless_package => 'main', | |
source => \(<<'END_OF_SOURCE'), | |
:default ::= action => [values] bless => ::lhs | |
lexeme default = action => [value] bless => ::name | |
seq ::= item+ separator => [,] | |
item ::= item1 | item2 | item3 | |
item1 ~ 'item1' | |
item2 ::= item3 | |
item3 ~ [abcde] | |
:discard ~ whitespace | |
whitespace ~ [\s]+ | |
END_OF_SOURCE | |
} ); | |
say $g->show_symbols(); | |
say $g->show_symbols(0, 'L0'); | |
say "G1 Symbol $_: ", $g->symbol_dsl_form($_) // 'No DSL form', ", Name: ", $g->symbol_name($_) for $g->symbol_ids(); | |
say "L0 Symbol $_: ", $g->symbol_dsl_form($_, 'L0') // 'No DSL form', ", Name: ", $g->symbol_name($_) for $g->symbol_ids('L0'); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment