parse-unit — performs the test cases in a testsuite for an SDF syntax definition


parse-unit [-p file] [--abstract-input] [--no-heuristic-filters] [--single int] [--asfix2] [--ast] [-i file | --input file] [-o file | --input file] [-b] [-S | --silent] [--verbose level] [-k level | --keep level] [--check] [-h | -? | --help] [--about] [--version]


The parse-unit utility is used for testing SDF syntax definitions. Using it, you can check that small code fragements are parsed correctly with your syntax definition.

The testsuites that parse-unit employes, have tests with an input and an expected result. You can specify that a test should succeed, fail or that the abstract syntax tree should have a specific format. The input to parse-unit is a string or the contents of a file.


Parsing Options

-p file

Use parse table from the file file. Refer to the sdf2table tool for how to create one.


Indicates to parse-unit that the testsuite input is already in abstract syntax.


Do not use heuristic disambiguation filters. It is recommended to enable this options.

--single num

Run parse test number num and output the result.


Enable production of an AsFix2 parse tree instead of an abstract syntax tree.


Enable production of an abstract syntax tree. This is the default.

Common Input/Output Options

-i file

The input term given by the file name file.

In the absence of the -i option, input will be read from stdin.

-o file

The output will be written to the file given by the file name file.

In the absence of the -o option, output will be written to stdout.


The output will be written in the binary (BAF) ATerm format.

ATerms in the BAF format require a lot less space than ones in the TAF format, but the Java ATerm library does not currently support baf ATerms. ATerms in the baf format is the preferred format of exchange between Stratego tools.

Common Debugging Options


See --version.

-h, -?, --help

Display usage information.

--keep int

Keep intermediate results produced by the internal stages in the pretty-printing process. This is only useful for debugging. A high value of int indicates increased eagerness for keeping intermediate results.

Default setting is 0, indicating that no intermediates will be kept.

-S, --silent

Silent execution. Same as --verbose 0.

--verbose int

Set verbosity level to numerical value int. The higher the number, the more information about pp-aterm's inner workings are printed.

Alternatively, int can be set to either of the following verbosity levels, given in increasing order of verbosity: emergency, alert, critical, error, warning, notice, info, debug, vomit.


Displays the tool name and version.


Refer to the chapter Unit Testing with Parse-unit for a full discussion of parse-unit in action.

Given an appropriate language parse table in lang.tbl, you can run the fifth test available from the testsuite mytests.testsuite as follows:

$ parse-unit --single 5 -p lang.tbl -i mytests.testsuite

Reporting Bugs

Please report bugs to


Copyright (C) 2002-2005 Eelco Visser

This library is free software; you can redistribute it and/or modify it under the terms of the GNU Lesser General Public License as published by the Free Software Foundation; either version 2 of the License, or (at your option) any later version.