Stories
Slash Boxes
Comments
NOTE: use Perl; is on undef hiatus. You can read content, but you can't post it. More info will be forthcoming forthcomingly.

All the Perl that's Practical to Extract and Report

use Perl Log In

Log In

[ Create a new account ]

Ovid (2709)

Ovid
  (email not shown publicly)
http://publius-ovidius.livejournal.com/
AOL IM: ovidperl (Add Buddy, Send Message)

Stuff with the Perl Foundation. A couple of patches in the Perl core. A few CPAN modules. That about sums it up.

Journal of Ovid (2709)

Thursday September 14, 2006
02:26 AM

Revised TAP Grammar

[ #30990 ]

This is my revised TAP grammar. If you're not familiar with reading this style of grammar, here are a few comments:

I'm using POSIX character classes to represent digits and printable characters. If you want to manually encode all of the Unicode characters for [:print:], be my guest :)

The following means "all printable characters except the newline".

([:print:] - "\n")

The following means, a digit followed by zero or more digits.

digit {digit}

A question mark after an atom means it's optional.

I'm not particularly gifted with grammars, so corrections welcome.

The corrected TAP grammar:

digit              ::= [:digit:]
character          ::= ([:print:] - "\n")
positiveInteger    ::= ( digit - '0' ) {digit}
nonNegativeInteger ::= digit {digit}

tap         ::= plan tests | tests plan {comment}
plan        ::= '1..' nonNegativeInteger "\n"
lines       ::= line {lines}
line        ::= (comment | test) "\n"
tests       ::= test {test}
test        ::= status positiveInteger? description? directive?
status      ::= 'not '? 'ok '
description ::= (character - (digit '#')) {character - '#'}
directive   ::= '#' ( 'TODO' | 'SKIP' ) ' ' {character}
comment     ::= '#' {character}

For purposes of forward compatability, all lines which do not match the grammar are labeled as TAPx::Parser::Result::Unknown and are not considered parse errors.

The Fine Print: The following comments are owned by whoever posted them. We are not responsible for them in any way.
 Full
 Abbreviated
 Hidden
More | Login | Reply
Loading... please wait.
  • A couple of minor points in your grammar:

    You define the tokens 'line' and 'lines' but don't use them anywhere.
    Also your 'test' does'nt have the terminating "\n", so the entire set of tests are all on one line.

    Possibly you should define
          tests ::= lines

    and have tests as the starting point of the grammar. That should do it - I think.