Generic Interpreter 0.9
Public API

gi
Class Lexicon

java.lang.Object
  |
  +--gi.Lexicon
Direct Known Subclasses:
Grammar

public class Lexicon
extends Object

This class implements a Lexicon.

Version:
0.9
Author:
© 1999-2000 Craig A. Rich <carich@acm.org>
See Also:
Source code

Method Summary
 Object grab(BufferedReader source)
          Grabs a terminal from a source character stream using this Lexicon.
 String word()
          Returns the word most recently grabbed using this Lexicon.
 
Methods inherited from class java.lang.Object
equals, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Method Detail

grab

public Object grab(BufferedReader source)
            throws gi.Lexicon.Exception

Grabs a terminal from a source character stream using this Lexicon. The variable returned by word() is set to the longest nonempty prefix of the remaining source characters matching an Expression in this Lexicon. If no nonempty prefix matches an Expression, a Lexicon.Exception is thrown. If the longest matching prefix matches more than one Expression, the terminal associated with the Expression most recently constructed is returned. Blocks until a character is available, an I/O error occurs, or the end of the source stream is reached.

Parameters:
source - the source character stream.
Returns:
the terminal grabbed from source.
Throws:
gi.Lexicon.Exception - if an I/O or lexical error occurs.

word

public String word()

Returns the word most recently grabbed using this Lexicon.

Returns:
the word most recently grabbed by grab(source).

 

© 1999-2000 Craig A. Rich <carich@acm.org>