baby Marpa::R2 haml Error in SLIF parse: No lexemes accepted

Why isn't oneliner matching? Why is   <terminated oneliner> rejected?

#!/usr/bin/perl -- use strict; use warnings; use Data::Dump qw/ dd /; use Marpa::R2; my $hamlInput = q{-# haml comment %p a paragraph %p %span foo inside span inside p }; my $syntax = <<'__SYNTAX__'; :default ::= action => [values] :start ::= haml haml ::= comments | oneliners oneliners ::= oneliner+ comments ::= comment+ comment ::= <hash style comment> # oneliner ::= <terminated oneliner> | <unterminated oneliner> oneliner ::= <terminated oneliner> oneliner ::= <unterminated oneliner> <terminated oneliner> ~ '%' tagname <oneline body> <vert +ical space char> <unterminated oneliner> ~ '%' tagname <oneline body> <oneline body> ~ <hash comment char>+ tagname ~ [a-zA-Z]+ # Hash comment handling copied from Marpa::R2's metag.bnf. <hash style comment> ~ <terminated hash comment> + | <unterminated final hash comment> <terminated hash comment> ~ '-#' <hash comment body> <vertic +al space char> <unterminated final hash comment> ~ '-#' <hash comment body> <hash comment body> ~ <hash comment char>* <vertical space char> ~ [\x{0A}\x{0B}\x{0C}\x{0D}\x{2028 +}\x{2029}] <hash comment char> ~ [^\x{0A}\x{0B}\x{0C}\x{0D}\x{202 +8}\x{2029}] __SYNTAX__ my $grammar = Marpa::R2::Scanless::G->new({source => \$syntax}); my $recce = Marpa::R2::Scanless::R->new( { grammar => $grammar , trace_values => 1, trace_terminals => 1, } ); eval { dd( $recce->read( \$hamlInput, ) ); #~ dd( $recce->read( \$hamlInput, 0,16 ) ); 1; } or warn $@; my $value_ref = $recce->value(); dd( $value_ref ); #~ dd( $recce, $grammar ); __END__ Setting trace_terminals option Setting trace_values option Accepted lexeme L1c1-16 e1: <hash style comment>; value="-# haml comme +nt " Rejected lexeme L2c1-15: <terminated oneliner>; value="%p a paragraph " Error in SLIF parse: No lexemes accepted at line 2, column 1 Rejected lexeme #0: <terminated oneliner>; value="%p a paragraph "; length = 15 * String before error: -# haml comment\n * The error was at line 2, column 1, and at character 0x0025 '%', ... * here: %p a paragraph\n%p\n %span foo inside span inside Marpa::R2 exception at - line 60. \[[["-# haml comment\n"]]]

Inspired by Whitespace-important parsing with Parse::RecDescent (eg. HAML, Python)


In reply to baby Marpa::R2 haml Error in SLIF parse: No lexemes accepted by Anonymous Monk

Title:
Use:  <p> text here (a paragraph) </p>
and:  <code> code here </code>
to format your post, it's "PerlMonks-approved HTML":



  • Posts are HTML formatted. Put <p> </p> tags around your paragraphs. Put <code> </code> tags around your code and data!
  • Titles consisting of a single word are discouraged, and in most cases are disallowed outright.
  • Read Where should I post X? if you're not absolutely sure you're posting in the right place.
  • Please read these before you post! —
  • Posts may use any of the Perl Monks Approved HTML tags:
    a, abbr, b, big, blockquote, br, caption, center, col, colgroup, dd, del, details, div, dl, dt, em, font, h1, h2, h3, h4, h5, h6, hr, i, ins, li, ol, p, pre, readmore, small, span, spoiler, strike, strong, sub, summary, sup, table, tbody, td, tfoot, th, thead, tr, tt, u, ul, wbr
  • You may need to use entities for some characters, as follows. (Exception: Within code tags, you can put the characters literally.)
            For:     Use:
    & &amp;
    < &lt;
    > &gt;
    [ &#91;
    ] &#93;
  • Link using PerlMonks shortcuts! What shortcuts can I use for linking?
  • See Writeup Formatting Tips and other pages linked from there for more info.