[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Here's a feature request for the next version of SableCC.. implementing
this is probably really easy, or else really hard... :-)
Currently, one parses the input like this:
p = new Parser(new Lexer(input));
topNode = p.parse();
It would be nice if you could parse any arbitrary other node besides
Start, by doing something like this:
p = new Parser(new Lexer(input), PSomeArbitraryProduction.class);
node = p.parse();
The idea being that you throw away all of the grammar except for what
could possibly be in a tree with top node PSomeArbitraryProduction.
So the parser would parse a PSomeArbitraryProduction, followed by EOF,
and then finish.
In my application, for example, stuff gets written to a file and needs
to be read in again later. For example, you write out strings into a
file like this:
string1="This is a \"doubly quoted\" string."
You want to parse everything after the equals sign as a string
token in a way that's consistent with the rest of the application.
So you might send just that input to the parser, and get a PString
I'd be interested in what the right parser strategy for implementing
this might be. Would you just create two new parser states for each node
. node EOF
node . EOF
These states would never be entered during a "complete" parse.
Archie Cobbs * Whistle Communications, Inc. * http://www.whistle.com