## Copyright (C) 2006, The Perl Foundation.
## $Id: TAP_grammar.pg 16424 2007-01-05 22:49:21Z particle $

grammar TAP::Grammar;

## Ovid's TAP grammar, translated, corrected, and rendered idiomatic
## NOTE: not yet extended to deal with 'Bail out!' etc.
token tap         { <plan> <lines> | <lines> <plan> <comment>* }
token plan        { <'1..'> \d+ \n }
token lines       { <line>+ }
token line        { <test> | <comment> }
token test        {
    <status>
    [ <' '> (<[1..9]> \d*) ]?              ## assumes a single space, not \h+
    \h* <description>? \h* <directive>? \n
                  }
token status      { <'not '>? <'ok'> }
token description { <after \h> <-[#\n]>+ }
token directive   { <after \h> <'# '> [:i todo | skip ] \N* }
token comment     { <'#'> \N* \n }

=pod

## Ovid's TAP grammar, original
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}

=cut

## vim: expandtab sw=4
