Created
January 17, 2014 13:20
-
-
Save rns/8473261 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; | |
| 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 => [values] bless => ::lhs | |
| lexeme default = action => [value] bless => ::name | |
| list ::= warning+ separator => [\n] | |
| warning ::= file ('(') line (')') (':' 'warning') code (':') message | |
| # without this, " : warning C4820: " is lexed as | |
| # file rather than 'warning ' code and rejected | |
| :lexeme ~ file forgiving => 1 | |
| file ~ [\w\-:/ \\\.]+ # windows and unix paths | |
| line ~ int | |
| code ~ 'C' int | |
| # without this, | |
| # " : warning C4820: '__unnamed' : '3' bytes padding added after member 'c'" | |
| # is lexed as message rather than 'warning ' code and rejected | |
| :lexeme ~ message forgiving => 1 | |
| 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