TAP Parser ^

This is a TAP (Test Anything Protocol) parser. It is designed to show how to use PGE to write a top-down (recursive-descent) parser. It has not yet been decided as to whether this will also become a TAP generator.

This effort shows how TAP output is parsed, and in the future may be used to (among other things) test that HLLs generate proper TAP output. So, creating useful test cases and extending the grammar to cover more of TAP is welcome.

Parsing ^

The TAP parser lives in the TAP.pbc file. To create this file, simply issue the command

  $ make

To invoke the parser from a shell on a TAP input file named "foo.tap", use:

  $ parrot TAP.pbc --target=parse foo.tap

To run interactively, entering single-line statements:

  $ parrot TAP.pbc --target=parse

Files ^

The "top" file for the parser is TAP.pir which is used to create the TAP.pbc file. It initializes the overall parsing system and registers the parser as a Parrot "TAP" compiler.

The other files needed for the compiler are in the src/ subdirectory.

The src/TAP.pg file defines the "top-down" grammar used for TAP output structures, defined using rules in Perl 6 rules syntax. PGE's "pgc.pir" compiler is then used to compile the grammar file into src/TAP_gen.pir, which is included by TAP.pir.

The src/main.pir file controls what happens when TAP.pbc is invoked directly from parrot (as opposed to being loaded via the load_bytecode op.)

The PIR files in src/ are included as part of compiling TAP.pir to produce TAP.pbc.

The TAP.pbc file can also be used to parse TAP output from PIR:

    load_bytecode "TAP.pbc"
    $S0 = <<'TAP'
    1..2
    ok 1
    not ok 2 # todo
    TAP
    $P0 = compreg("TAP")                 # obtain the compiler
    $P1 = $P0($S0, 'target'=>'parse')    # parse source code

AUTHOR ^

Chris Dolan (mailto:chris@clotho.net) and Jerry Gay (mailto:jerry.gay@gmail.com) are the authors and maintainers. Patches and suggestions should be sent to the Parrot Porters list (mailto:parrot-porters@perl.org).


parrot