Hi!
The example in the Marpa::R2 documentation
(https://metacpan.org/pod/Marpa::R2) cannot handle expressions like 1 + 1 +
1.
how do I get them to work?
Best regards,
Alex
--
You received this message because you are subscribed to the Google Groups
marpa parser group.
To unsubscribe from
Here are some more details:
I just copied the example script from the synopsis section and changed the
$input:
#!perl
use strict;
use warnings;
use Marpa::R2;
my $dsl = 'END_OF_DSL';
:default ::= action = [name,values]
lexeme default = latm = 1
Expression ::= Term action = ::first
Term ::=
Solution found on IRC. Recursion for Expression was missing.
This will make it work:
my $dsl = 'END_OF_DSL';
:default ::= action = [name,values]
lexeme default = latm = 1
Expression ::=
Expression '+' Term action = do_add
| Term action = ::first
Term ::=
Term '*' Factor action =
#!perl
use strict;
use warnings;
use Data::Dumper qw/Dumper/;
use Marpa::R2;
$Data::Dumper::Deepcopy = 1;
my $dsl = 'END_OF_DSL';
:default ::= action = [name,values]
lexeme default = latm = 1
Expression ::=
Expression '=' Expression
| QuotedWord
| Word
QuotedWord ::= '' Word ''
Hi!
I'm sorry, this is not what I was looking for. My description lacked this
specific point - sorry.
These multi words can be arbitrary text even without any white space at
all. Thus, matching the string multi word followed by a or b will not
work.
I updated the example code to show it more
#!perl
use strict;
use warnings;
use Data::Dumper qw/Dumper/;
use Marpa::R2;
use String::Random;
$Data::Dumper::Deepcopy = 1;
my $dsl = 'END_OF_DSL';
:default ::= action = [name,values]
lexeme default = latm = 1
Expression ::=
Expression '=' Expression
| QuotedWord
| Word
Hi!
Still not what I was looking for, but I stumbled across the solution. I
forgot to specify \s in the character class of charsnwhite:
charsnwhite ~ [\w\s]+
With this, I can parse a string like:
my $input = String::Random-new-randregex('\w{5,8}\s\w{6,9} =
\w{5,8}\s\w{6,9}');
Here is
NB: you can get an overview over build status for ActiveState Perl here:
http://code.activestate.com/ppm/Marpa-R2/
It isn't tied to CPAN testers, but as it compiled modules for Windows, I
always find it worth a look. And I use it, so I prefer modules that build
for ActiveState Perl :)
Am