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
local lpeg = require 'lpeg' | |
equalcount = lpeg.P{ | |
"S"; -- initial rule name | |
S = "a" * lpeg.V"B" + "b" * lpeg.V"A" + "", | |
A = "a" * lpeg.V"S" + "b" * lpeg.V"A" * lpeg.V"A", | |
-- , '1' added to produce error | |
B = "b", '1' * lpeg.V"S" + "a" * lpeg.V"B" * lpeg.V"B", | |
} * -1 |
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; | |
$Data::Dumper::Indent = 0; | |
$Data::Dumper::Terse = 1; | |
$Data::Dumper::Deepcopy = 1; | |
use Marpa::R2; |
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
# foo.AND(5) at C:\cygwin\home\Ruslan\Marpa-R2-work\q27109840.pl line 52. | |
Invalid Identifier: AND at C:\cygwin\home\Ruslan\Marpa-R2-work\q27109840.pl line 73. | |
# foo.has(bar == 42 AND baz == 23) at C:\cygwin\home\Ruslan\Marpa-R2-work\q27109840.pl line 52. | |
['Expression',['Expression',['Identifier','foo']],['Identifier','has'],['Args',['ArgsList',['Expression',['Expression',['Expression',['Identifier','bar']],['Expression',['NumLiteral','42']]],['Expression',['Expression',['Identifier','baz']],['Expression',['NumLiteral','23']]]]]]] | |
Tool completed successfully |
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
#!perl | |
# Copyright 2015 Jeffrey Kegler | |
# This file is part of Marpa::R2. Marpa::R2 is free software: you can | |
# redistribute it and/or modify it under the terms of the GNU Lesser | |
# General Public License as published by the Free Software Foundation, | |
# either version 3 of the License, or (at your option) any later version. | |
# | |
# Marpa::R2 is distributed in the hope that it will be useful, | |
# but WITHOUT ANY WARRANTY; without even the implied warranty of | |
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU |
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
package MyActions; | |
use Marpa::R2; | |
sub new { | |
my ($class, %args) = @_; | |
return bless \%args, $class; | |
} | |
sub do_A { | |
my ($self, $letter) = @_; |
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
#!perl | |
# Copyright 2015 Jeffrey Kegler | |
# This file is part of Marpa::R2. Marpa::R2 is free software: you can | |
# redistribute it and/or modify it under the terms of the GNU Lesser | |
# General Public License as published by the Free Software Foundation, | |
# either version 3 of the License, or (at your option) any later version. | |
# | |
# Marpa::R2 is distributed in the hope that it will be useful, | |
# but WITHOUT ANY WARRANTY; without even the implied warranty of | |
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU |
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
[ | |
'S', | |
[ | |
'b' | |
], | |
[ | |
'A', | |
[ | |
'd' | |
] |
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
Ambiguous parse: 5 alternatives. | |
# Alternative 1: | |
['hex',['hex',['hex',['hex',['digit','0']],['hex',['digit','1']]],['hex',['letter','F']]],['hex',['letter','E']]] | |
# Alternative 2: | |
['hex',['hex',['hex',['digit','0']],['hex',['hex',['digit','1']],['hex',['letter','F']]]],['hex',['letter','E']]] | |
# Alternative 3: | |
['hex',['hex',['hex',['digit','0']],['hex',['digit','1']]],['hex',['hex',['letter','F']],['hex',['letter','E']]]] | |
# Alternative 4: | |
['hex',['hex',['digit','0']],['hex',['hex',['hex',['digit','1']],['hex',['letter','F']]],['hex',['letter','E']]]] | |
# Alternative 5: |
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
Can't locate object method "rule_describe" via package "Marpa::R2::Grammar" at /usr/lib/perl5/site_perl/5.14/i686-cygwin-threads-64int/Marpa/R2/Value.pm line 489, <DATA> line 5048. | |
Marpa::R2::Internal::Value::rule_describe('Marpa::R2::Grammar=ARRAY(0x206fe128)', 23) called at /usr/lib/perl5/site_perl/5.14/i686-cygwin-threads-64int/Marpa/R2/Value.pm line 472 | |
Marpa::R2::Internal::Value::resolve_rule_by_id('Marpa::R2::Recognizer=ARRAY(0x278bb128)', 23) called at /usr/lib/perl5/site_perl/5.14/i686-cygwin-threads-64int/Marpa/R2/Value.pm line 589 | |
Marpa::R2::Internal::Value::resolve_recce('Marpa::R2::Recognizer=ARRAY(0x278bb128)', 'Marpa::R2::Scanless::R=ARRAY(0x2008d700)') called at /usr/lib/perl5/site_perl/5.14/i686-cygwin-threads-64int/Marpa/R2/ASF.pm line 377 | |
Marpa::R2::ASF::new('Marpa::R2::ASF', 'HASH(0x2008d6d0)') called at /usr/lib/perl5/site_perl/5.14/i686-cygwin-threads-64int/Marpa/R2/SLR.pm line 1413 | |
Marpa::R2::Scanless::R::ambiguous('Marpa::R2::Scanless::R=ARRAY(0x2008d700)') called at C:\cygwin\home |
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 strict; | |
use warnings; | |
use Test::More; | |
use Data::Dumper; | |
$Data::Dumper::Indent = 1; | |
$Data::Dumper::Terse = 1; | |
$Data::Dumper::Deepcopy = 1; |