Questions tagged [marpa]

Marpa is a new parsing algorithm with a decades-long heritage. Its lineage starts with the algorithm invented by Jay Earley. Marpa is the first algorithm to combine the improvements to Earley's algorithm made by Joop Leo with those discovered by John Aycock and R. Nigel Horspool. Marpa's "situational awareness", and Ruby Slippers parsing, are a new feature.

24 questions
10
votes
1 answer

Can Marpa be used to speed up Perl interpreter's parsing?

Can the existing Marpa parser be used to improve parsing of Perl 5 (e.g., replace all or chunks of existing Perl interpreter's parser)? I am asking on a theoretical level, e.g. ignoring practical considerations such as "if it can, it would cost…
DVK
  • 126,886
  • 32
  • 213
  • 327
8
votes
2 answers

Is it possible to use Perl's Marpa parser for a public network server?

The documentation of Perl's Marpa parser contains the following section about tainted data: Marpa::R2 exists to allow its input to alter execution in flexible and powerful ways. Marpa should not be used with untrusted input. In Perl' s taint mode,…
ceving
  • 21,900
  • 13
  • 104
  • 178
8
votes
1 answer

Marpa::R2 leaks memory

I am using latest release of marpa::r2 (Marpa-R2-2.065_002) and it seems to eat all memory very fast. I wrote the bellow script to test it. use strict; use warnings FATAL => 'all'; use Marpa::R2; use Data::Dumper; my $grammar =…
jvverde
  • 631
  • 3
  • 10
7
votes
1 answer

Case-insensitive matching in Marpa

Related to my earlier question about case-insensitive keyword matching using regular expressions. Is it possible to match strings case-insensitively in Marpa? If so, how? Suppose I have the grammar :start ::= script identifier ~ [\w]+ script ::=…
onitake
  • 1,369
  • 7
  • 14
6
votes
2 answers

Marpa: Can I explicitly disallow keywords as identifiers?

I'm implementing a new DSL in Marpa and (coming from Regexp::Grammars) I'm more than satisfied. My language supports a bunch of unary and binary operators, objects with C-style identifiers and method calls using the familiar dot notation. For…
Stefan Majewsky
  • 5,427
  • 2
  • 28
  • 51
6
votes
1 answer

Does the Marpa parser library support error recovery?

I know Perl's "Marpa" Earley parser has very good error reporting. But I can't find in its documentation or via Googling whether it has error recovery. For instance, most C/C++ compilers have error recovery, which they use to report multiple syntax…
hippietrail
  • 15,848
  • 18
  • 99
  • 158
6
votes
1 answer

Incorrect Tokenization with Marpa

I have a rather large Marpa grammar (for parsing XPath), and I ran into a problem with tokenization. I created a minimal breaking example below: use strict; use warnings; use Marpa::R2; my $grammar = Marpa::R2::Scanless::G->new( { …
Nate Glenn
  • 6,455
  • 8
  • 52
  • 95
5
votes
1 answer

Marpa parser can't seem to cope with optional first symbol?

I've been getting to grips with the Marpa parser and encountered a problem when the first symbol is optional. Here's an example: use strict; use warnings; use 5.10.0; use Marpa::R2; use Data::Dump; my $grammar = Marpa::R2::Scanless::G->new({source…
Adrian Pronk
  • 13,486
  • 7
  • 36
  • 60
5
votes
1 answer

Concise way to make a 0+ length list in Marpa grammar?

I'm new to Marpa. I've tried a couple ways to describe a list of 0 or more terms in my grammar, and I want to avoid multiple parse trees. My language will have exactly 1 component followed by 0+ subcomponents: package => component-rule…
Erik Olson
  • 1,154
  • 8
  • 18
4
votes
1 answer

Exception handling in parser implemented using Marpa::R2

I have implemented a parser using Marpa::R2. Code appears like below: I have a large number of test cases in a .t file, which i run to test my parser. So, if any exception arises in any of the input expression, testing shouldn't stop in mid and it…
zubug55
  • 729
  • 7
  • 27
4
votes
1 answer

What arguments are passed to an Marpa::R2 action?

In the cpan page of Marpa::R2, I understand the BNF (Backus-Naur Form), but I am quite lost with the action callbacks. In this example below, I understand that the two, left and right members are passed to do_multiply. I have no problem with that.…
nowox
  • 25,978
  • 39
  • 143
  • 293
4
votes
2 answers

How to iterate "along" a Marpa parse forest rather than "through" its parse trees?

Say I have a nice ambiguous Marpa grammar and a nice ambiguous input string. I can parse the string with Marpa and end up with a parse forest. I can even iterate through each parse tree in the forest. But how can I iterate "along" the parse…
hippietrail
  • 15,848
  • 18
  • 99
  • 158
4
votes
2 answers

Prevent naïve longest token matching in Marpa::R2::Scanless

In the current implementation of the Scanless Interface (SLIF) in the Marpa parser, the lexer seems to do longest token matching (LTM) in the following fashion: All terminal symbols are tried to match at the current position in the input. All but…
amon
  • 57,091
  • 2
  • 89
  • 149
4
votes
1 answer

Trouble separating G0 and G1 rules in grammar

I'm trying to get what seems like a very basic Marpa grammar working. The code I use is below: use strict; use warnings; use Marpa::R2; use Data::Dumper; my $grammar = Marpa::R2::Scanless::G->new( { source => \(<<'END_OF_SOURCE'), …
Nate Glenn
  • 6,455
  • 8
  • 52
  • 95
3
votes
1 answer

Matching arbitrary delimiters

I've had good success parsing complicated and silly old text formats with Marpa before and I'm trying to do it again. This particular format has hundred and hundreds of different kinds of 'Begin' and 'End' blocks that look like this: Begin BlahBlah …
rjt_jr
  • 303
  • 1
  • 6
1
2