sglr — parses a text file and produces an parse forest conforming to a given grammar.
sglr is a scannerless, generalized LR parser. It interprets a parse table on a given textual input file. The parse table must be generated from an SDF2 grammar definition using the sdf2table tool. If the result of the parse is unambiguous, a parse tree is emitted. In the case of an ambiguity, a parse forest is emitted.
The term "scannerless" refers to the fact that the parser treats characters as tokens. There is no separate token scanner. The term "generalized" indicates that the parser finds all possible derivations for a given input string. Together, these two features allows users to construct ambiguous grammars, if they desire. sglr will not complain about conflicts in the parse table, but output the ambiguous result.
For the ambiguous cases, the user is free to construct problem-specific disambiguation tools which must be applied to the output from sglr. This is useful for dealing with various complicated programming languages that are highly ambiguous and context-sensitive.
The input file is given by the file name
In the absence of the
-i option, sglr will read
The output will be written to the file given by the file name
In the absence of the
-o option, sglr will
The parse table to use, given by the file name
Note: This option is always required.
Refer to the tool sdf2table for how to create parse tables.
Use the binary ATerm (BAF) output format. Default is yes.
Use the AsFix2ME output format. Default is yes.
Use the textual AsFix output format. Default is no.
Use the AsFix2 output format. Default is no.
Treat ambiguities as errors. Default is no.
Toggle cycle detection. Default is on.
Toggle parse tree creation. Default is on.
Toggle filtering, or toggle specific filter. Default is to enable all filters.
a - turn on associativity filter. Default is on.
d - turn on direct eagerness filter. Default is on.
e - turn on eagerness filter. Default is on.
i - turn on injection count. Default is on.
p - turn on priority filter. Default is on.
r - turn on reject filter. Default is on.
Specific start symbol to use in the input grammar. Default is unspecified.
Turn on debugging mode.
Turn on statistics logging.
Display usage information.
Turn on verbose mode.
Show tool name and version number.
Displays the tool name and version.
Assuming you have used sdf2table to generate a parse table for
you language in the file
lang.tbl, and that your input program
is in the file
input.lang, you can apply sglr
$sglr -p lang.tbl -i input.lang -o lang.trm
The resulting parse tree (or possibly parse forest, if your language grammar
allows ambiguities) will be in
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.