All Packages  Class Hierarchy  This Package  Previous  Next  Index

Interface fr.inria.openmath.omapi.Parser

public interface Parser
Basic interface for OpenMath parsers.

All OpenMath parsers must implement this basic interface: it allows applications to register handlers for different types of events and to initiate a parse from a character stream.

All OpenMath parsers must also implement a zero-argument constructor for Beans support. (though other constructors are also allowed).

OpenMath parsers are reusable but not re-entrant: the application may reuse a parser object (possibly with a different input source) once the first parse has completed successfully, but it may not invoke the parse() methods recursively within a parse.

See Also:
ParserHandler, ParserErrorHandler, pipeParserHandler, debugParserHandler, treeParserHandler

Method Index

 o getParserErrorHandler()
Get the current parser error handler.
 o getParserHandler()
Get the current parser handler.
 o initParse(InputStream)
Initializes parsing on a new input source.
 o parse(InputStream)
Parses OpenMath objects until source is exhausted.
 o parseElement(InputStream)
Parses an OpenMath element.
 o parseObject(InputStream)
Parses an OpenMath object.
 o setParserErrorHandler(ParserErrorHandler)
Allows an application to register a parsing error event handler.
 o setParserHandler(ParserHandler)
Allows an application to register a parse event handler.

Methods

 o setParserHandler
 public abstract void setParserHandler(ParserHandler handler)
Allows an application to register a parse event handler.

If the application does not register an parse handler, all events reported by the OpenMath parser will be silently ignored (this is the default behaviour implemented by ParserAdapter).

Applications may register a new or different handler in the middle of a parse, and the OpenMath parser must begin using the new handler immediately.

Parameters:
handler - The object handler.
See Also:
ParserHandler, ParserAdapter
 o getParserHandler
 public abstract ParserHandler getParserHandler()
Get the current parser handler.

See Also:
setParserHandler
 o setParserErrorHandler
 public abstract void setParserErrorHandler(ParserErrorHandler handler)
Allows an application to register a parsing error event handler.

If the application does not register an error event handler, all error events reported by the OpenMath parser will be silently ignored, except for fatalError, which will throw a OMException (this is the default behaviour implemented by ParserAdapter).

Applications may register a new or different handler in the middle of a parse, and the OpenMath parser must begin using the new handler immediately.

Parameters:
handler - The error handler.
See Also:
ParserErrorHandler, OMException, ParserAdapter
 o getParserErrorHandler
 public abstract ParserErrorHandler getParserErrorHandler()
Get the current parser error handler.

See Also:
setParserErrorHandler
 o initParse
 public abstract void initParse(InputStream source) throws OMException
Initializes parsing on a new input source.

The application must use this method to instruct the OpenMath parser to reset its state. Each time you change input source you need to call this function before using parse* methods.

Parameters:
source - The input source.
Throws: OMException
Any OpenMath exception
 o parseElement
 public abstract void parseElement(InputStream source) throws OMException
Parses an OpenMath element.

The application can use this method to instruct the OpenMath parser to begin parsing an OpenMath element from any valid input source (a character stream, a byte stream...).

Applications may not invoke this method while a parse is in progress (they should create a new Parser for each additional input source). Once a parse is complete, an application may reuse the same Parser object to parse another OpenMath object on the same input source or possibly with a completly different input source.

Parameters:
source - The input source.
Throws: OMException
Any OpenMath exception
See Also:
initParse, setParserHandler, setParserErrorHandler, ParserAdapter, ParserErrorAdapter
 o parseObject
 public abstract void parseObject(InputStream source) throws OMException
Parses an OpenMath object.

The application can use this method to instruct the OpenMath parser to begin parsing an OpenMath Object from any valid input source (a character stream, a byte stream...).

Applications may not invoke this method while a parse is in progress (they should create a new Parser for each additional input source). Once a parse is complete, an application may reuse the same Parser object to parse another OpenMath object on the same input source or possibly with a completly different input source.

Parameters:
source - The input source.
Throws: OMException
Any OpenMath exception
See Also:
initParse, setParserHandler, setParserErrorHandler, ParserAdapter, ParserErrorAdapter
 o parse
 public abstract void parse(InputStream source) throws OMException
Parses OpenMath objects until source is exhausted.

The application can use this method to instruct the OpenMath parser to begin parsing OpenMath Objects from any valid input source (a character stream, a byte stream...).

Applications may not invoke this method while a parse is in progress (they should create a new Parser for each additional input source). Once a parse is complete, an application may reuse the same Parser object to parse another OpenMath object on the same input source or possibly with a completly different input source.

Parameters:
source - The input source.
Throws: OMException
Any OpenMath exception
See Also:
initParse, setParserHandler, setParserErrorHandler, ParserAdapter, ParserErrorAdapter

All Packages  Class Hierarchy  This Package  Previous  Next  Index