tribble.io
Interface ParserI

All Known Subinterfaces:
Lr1ParserI, ParserWithParseTreeI, ParserWithSymbolTableI
All Known Implementing Classes:
Lr1Parser

public interface ParserI

Generic parser interface.

This interface is used to implement any kind of parser which reads tokens from an input source stream (implementing the LexerI interface).

Since:
2001-04-16
Version:
$Revision: 1.2 $ $Date: 2003/01/25 19:01:18 $
Author:
David R. Tribble, david@tribble.com
Copyright ©2001-2003 by David R. Tribble, all rights reserved.
Permission is granted to freely use and distribute this source code provided that the original copyright and authorship notices remain intact.
See Also:
LexerI, ParseTreeI, SymbolTableI, ParserWithParseTreeI, ParserWithSymbolTableI

Field Summary
static java.lang.String REV
          Revision information.
 
Method Summary
 void close()
          Closes the input stream.
 boolean parse()
          Parses the input stream, performing syntactical analysis on the stream of input tokens.
 void setInput(LexerI in)
          Establishes the lexical analyzer (lexer) input stream from which to read tokens during parsing.
 void setSourceName(java.lang.String fname)
          Establishes the input source filename.
 

Field Detail

REV

static final java.lang.String REV
Revision information.

See Also:
Constant Field Values
Method Detail

setInput

void setInput(LexerI in)
Establishes the lexical analyzer (lexer) input stream from which to read tokens during parsing.

Parameters:
in - The lexer input stream from which to read tokens.
Since:
1.1, 2001-04-16

setSourceName

void setSourceName(java.lang.String fname)
Establishes the input source filename.

Parameters:
fname - The source filename.
Since:
1.1, 2001-05-31

close

void close()
Closes the input stream.

It is typically not necessary to invoke this method since the input stream is usually closed automatically once parsing has completed, unless it is necessary to close the input stream deliberately or prematurely.

Note that this method does not throw any exceptions.

Since:
1.1, 2001-04-16

parse

boolean parse()
              throws java.lang.Exception
Parses the input stream, performing syntactical analysis on the stream of input tokens.

Returns:
True if the parsing was successful, otherwise false.
Throws:
java.lang.Exception - Thrown if an I/O error or parsing error occurs.
Since:
1.1, 2001-04-16