> I wonder why you opt to parse this format specifically instead of the generic lisp format though.
As I said, I started from a wrong end. I'm kind of busy working from home and staying there with a wife and three children, so I didn't have time to fix it immediately. Here's a much simpler and faster version, which parses melpa's archive-contents in less than 5 seconds on my machine:
#! /usr/bin/perl
use warnings;
use strict;
use Marpa::R2;
my $dsl = << '__DSL__';
:default ::= action => ::first
lexeme default = latm => 1
List ::= ('(') Elements (')')
Elements ::= Element+ action => [values]
Element ::= List
| Vector
| Atom
| String
| Pair
Vector ::= ('[') Elements (']')
Atom ::= identifier
String ::= ('"') Quoteds ('"')
Quoteds ::= Quoteds Quoted action => concat
| Quoted
Quoted ::= backslash
|| qq
|| plain
Pair ::= Element (dot) Element action => pair
:discard ~ whitespace
whitespace ~ [\s]+
dot ~ '.'
backslash ~ '\\'
qq ~ '\"'
identifier ~ [-\w@:+]+
plain ~ [^\\"]+
__DSL__
sub concat { $_[1] . $_[2] }
sub pair { +{ $_[1] => $_[2] } }
my $grammar = 'Marpa::R2::Scanless::G'->new({source => \$dsl});
my $lisp = do { local $/; <> };
my $value_ref = $grammar->parse(\$lisp, {semantics_package => 'main'})
+;
use Data::Dumper; print Dumper $value_ref;
map{substr$_->[0],$_->[1]||0,1}[\*||{},3],[[]],[ref qr-1,-,-1],[{}],[sub{}^*ARGV,3]