visamb — displays the ambiguities in a parse tree represented in AsFix2
file | --input
file | --output
[-S | --silent]
level | --keep
[-h | -? | --help]
The visamb utility extracts ambiguities from a parse tree and displays these in a readable format. Ambiguities are displayed by printing the non-terminals of the nodes of the parse trees in the ambiguities.
The SDF2 implementation caters for arbitrary context-free grammars. That is, even for
ambiguous grammars the parser will produce a parse trees containing a concise encoding
of all possible parses. Ambiguities are represented by means of
nodes that contain a list of possible parse trees at that point. For most applications,
however, it is desirable to develop unambiguous grammars.
Common Input/Output Options
The input term given by the file name
In the absence of the
-i option, input
will be read from
The output will be written to the file given by the file name
In the absence of the
output will be written to
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
Display usage information.
Keep intermediate results produced by the internal stages in the
pretty-printing process. This is only useful for debugging. A high
int indicates increased eagerness
for keeping intermediate results.
Default setting is 0, indicating that no intermediates will be kept.
Silent execution. Same as
Set verbosity level to numerical value
higher the number, the more information about pp-aterm's inner workings are
int can be set to either of the
following verbosity levels, given in increasing order of verbosity:
Displays the tool name and version.
Consider the following syntax definition:
definition module Main exports sorts Exp lexical syntax [\ \t\n] -> LAYOUT context-free syntax "id" -> Exp Exp Exp -> Exp
The following command will convert this into a parse table, suitable for visamb.
$sdf2table -i Exp.sdf -o Exp.tbl
Next, we can see how the expression
id id id is ambiguous
with this grammar, by doing:
$echo "id id id" | sglr -2 -p Exp.tbl | visamb
The result is:
# ambiguities = 1 + * id id id <Exp-CF> <Exp-CF> <Exp-CF> id <LAYOUT?-CF> <LAYOUT-CF> <Exp-CF> id <LAYOUT?-CF> <LAYOUT-CF> <Exp-CF> id <Exp-CF> <Exp-CF> id <LAYOUT?-CF> <LAYOUT-CF> <Exp-CF> <Exp-CF> id <LAYOUT?-CF> <LAYOUT-CF> <Exp-CF> id
Only the inner ambiguities are displayed, i.e., if a phrase and one of its sub-phrases are ambiguous, only the ambiguities of the sub-phrase are displayed.
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.