Skip to content

failure using Grammar::Tracer #40

@tbrowder

Description

@tbrowder

The failing code is detailed in gist https://gist.github.com/tbrowder/db2a3a80d09e5fddaf755ecc42178953 and is repeated below:

# cat file: lib/Presenters.pm6
unit module Presenters;
use Grammar::Tracer;
grammar Presenters::PGrammar {
    token TOP {
        [
            | <entry>
            | <blank>
        ]+
    }
    token entry   { <key> <sep> <value> }
    token key     { \h* \w+ }
    token sep     { \h* ':' \h* }
    token value   { \N+ }
    token blank   { \h* \n }
}

# cat file: ./test-presenters.data
id: laue-d 
name: Lauer, Denny 
id: horn-a
name: Hornstein, Anne
id: bran-e
name: Branch, Eddie

# cat file: ./grammar-test-fail.p6
#!/usr/bin/env perl6
use lib <./lib>;
use Presenters;
my $pfil  = "test-presenters.data";
my $mp = Presenters::PGrammar.parse(slurp $pfil);
say "WARNING: Presenters grammar failed to match." if !$mp;
say $mp;

# executing
./grammar-test-fail.p6
TOP
Cannot invoke this object (REPR: Null; VMNull)
  in block  at /usr/local/rakudo.d/share/perl6/site/sources/C0DCFF5AEFDF38901A375AE53AF39C4F12B3F6FC (Grammar::Tracer) line 43
  in regex TOP at /usr/local/people/tbrowde/mydata/tbrowde-home-bzr/mydomains/domains/primary-web-servers/web-sites/computertechnwf.org/public/lib/Presenters.pm6 (Presenters) line 6
  in block  at /usr/local/rakudo.d/share/perl6/site/sources/C0DCFF5AEFDF38901A375AE53AF39C4F12B3F6FC (Grammar::Tracer) line 49
  in block <unit> at ./grammar-test-fail.p6 line 7

After removing "use Grammar::Tracer" the code runs to completion:

# executing
./grammar-test-fail.p6
id: laue-d
name: Lauer, Denny
id: horn-a
name: Hornstein, Anne
id: bran-e
name: Branch, Eddie

 entry => id: laue-d
  key => id
  sep => : 
  value => laue-d
 blank => 

 entry => name: Lauer, Denny
  key => name
  sep => : 
  value => Lauer, Denny
 blank => 

 entry => id: horn-a
  key => id
  sep => : 
  value => horn-a
 blank => 

 entry => name: Hornstein, Anne
  key => name
  sep => : 
  value => Hornstein, Anne
 blank => 

 entry => id: bran-e
  key => id
  sep => : 
  value => bran-e
 blank => 

 entry => name: Branch, Eddie
  key => name
  sep => : 
  value => Branch, Eddie
 blank => 

Note that if I use "Grammar::Tracer::Compact"" all works well.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions