Subject: [tap] ANNOUNCE: TAP::Spec::Parser - a TAP parser based on the draft grammar

From: Andrew Rodland <[email-masked]>
Date: Mon, 28 Jun 2010 03:07:48 -0500

(Reposted here from tap-l, which was apparently the wrong list)

Per Schwern's request at YAPC, I've written a parser based on the grammar in 
the IETF draft standard 
<http://testanything.org/wiki/index.php/TAP_at_IETF:_Draft_Standard> to help 
make sure that it's correct and well-exercised. The code is at 
http://github.com/arodland/TAP-Spec-Parser and it's currently in a working 
alpha state. It uses a Regexp::Grammars grammar, with the relevant portions of 
the spec grammar interleaved in comments.

Current TODOs for TAP::Spec::Parser:
* Implement skipping "junk" lines.
* (Optionally?) remove the '' key (which stores the entire matched text) from 
  result hashes.
* Convince Regexp::Grammars to call object constructors instead of just
  blessing hashes (to play better with Moose)
* Investigate segfaults in global destruction after parsing.

Draft grammar issues identified so far:
* The Description rule doesn't make any mention of the optional "-" SP at the
  beginning of the description (discussed with Schwern).
* Plan-Todo looks like it should have SP before "todo".

Andrew

---

From: Ovid <[email-masked]>
Date: Mon, 28 Jun 2010 04:49:35 -0700 (PDT)

--- On Mon, 28/6/10, Andrew Rodland <[email-masked]> wrote:

> From: Andrew Rodland <[email-masked]>

> the spec grammar interleaved in comments.

I haven't looked at this too closely, but one thing you might want to consider it that TAP is stream-oriented, not document-oriented.  When I wrote the parser for new the Test::Harness, I was going to use a full lexer/grammar solution, only to realize that the nature of a stream means I wouldn't have the full document up front.  This is a deliberate design feature of TAP to allow results to be output as they occur, rather than waiting for the end of the test run (such as requiring a full XML document requires).

Does Regexp::Grammars allow you to handle that case? I didn't think so, but I could be mistaken.

Cheers,
Ovid
--
Buy the book         - http://www.oreilly.com/catalog/perlhks/
Tech blog            - http://blogs.perl.org/users/ovid/
Twitter              - http://twitter.com/OvidPerl
Official Perl 6 Wiki - http://www.perlfoundation.org/perl6

---

From: Andrew Rodland <[email-masked]>
Date: Mon, 28 Jun 2010 21:14:23 -0500

On Monday, June 28, 2010 06:49:35 am you wrote:
> I haven't looked at this too closely, but one thing you might want to
> consider it that TAP is stream-oriented, not document-oriented.  When I
> wrote the parser for new the Test::Harness, I was going to use a full
> lexer/grammar solution, only to realize that the nature of a stream means
> I wouldn't have the full document up front.  This is a deliberate design
> feature of TAP to allow results to be output as they occur, rather than
> waiting for the end of the test run (such as requiring a full XML document
> requires).
> 
Appreciated, and no, Regexp::Grammars doesn't do streaming, but I don't think 
that's the most important concern here. The idea of the parser is to act as a 
tool to validate the correctness of the grammar in the draft spec (and perhaps 
later, if it does the job, to validate the correctness of others parsers 
*against* the spec). I'm not overly concerned for its usefulness as a parser 
in production. And the Regexp::Grammars syntax parallels the ABNF in the spec 
really well.

Andrew

---

From: Eric Wilhelm <[email-masked]>
Date: Tue, 29 Jun 2010 10:58:46 -0700

# from Andrew Rodland
# on Monday 28 June 2010 19:14:

>Appreciated, and no, Regexp::Grammars doesn't do streaming, but I
> don't think that's the most important concern here.

It is certainly useful to do validation without streaming, but a 
streaming parser built out of the same grammar as the validator would 
make it easier to maintain a correct streaming parser.  Is it possible 
to compose the document grammar out of smaller pieces such that a 
streaming parser would only need to implement the flow control and 
state-change logic?

--Eric
-- 
... unsustainable.  And that word means something -- it doesn't just 
mean "we don't like it".
--Michael Pollan
---------------------------------------------------
    http://scratchcomputing.com
---------------------------------------------------

---

From: Michael G Schwern <[email-masked]>
Date: Wed, 30 Jun 2010 02:07:40 -0700

> the spec grammar interleaved in comments.

Awesome!  I've done some work on it by adding minimal specification tests so
you can write tests as TAP and how its to be interpreted.

There were a pile of these written in Oslo and I always forget where they
wound up.  Anyone remember?

> * (Optionally?) remove the '' key (which stores the entire matched text) from 

I'd keep it in.  Its handy for debugging.  Make it a less cryptic name.
"raw_text" maybe.

> * Plan-Todo looks like it should have SP before "todo".

Please edit the draft as you find issues with the grammar.

-- 
94. Crucifixes do not ward off officers, and I should not test that.
    -- The 213 Things Skippy Is No Longer Allowed To Do In The U.S. Army
           http://skippyslist.com/list/