Skip to content

Instantly share code, notes, and snippets.

@rns
Created January 25, 2014 23:17
Show Gist options
  • Select an option

  • Save rns/8625302 to your computer and use it in GitHub Desktop.

Select an option

Save rns/8625302 to your computer and use it in GitHub Desktop.
use 5.010;
use strict;
use warnings;
use Data::Dumper;
$Data::Dumper::Indent = 0;
$Data::Dumper::Terse = 1;
use Marpa::R2;
my $input = <<EOI;
../cpan/lib/dev/file.c(11824) : warning C4820: '__unnamed' : '3' bytes padding added after member 'c'
../cpan/lib/dev/file.c(12464) : warning C4100: 'param' : unreferenced formal parameter
file.c(12538) : warning C4127: conditional expression is constant
EOI
my $g = Marpa::R2::Scanless::G->new( {
bless_package => 'main',
source => \(<<'END_OF_SOURCE'),
:default ::= action => [lhs,values]
lexeme default = action => [lhs,value] forgiving => 1
list ::= warning+ separator => [\n]
warning ::= file ('(') line (')') (':' 'warning') code (':') message
file ~ [\w\-:/ \\\.]+ # windows and unix paths
line ~ int
code ~ 'C' int
message ~ [\w' \-:]+ #'
int ~ [\d]+
:discard ~ whitespace
whitespace ~ [ ]+
END_OF_SOURCE
} );
my $r = Marpa::R2::Scanless::R->new( { grammar => $g } );
$r->read(\$input);
say Dumper ${ $r->value() };
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment