org.sc3d.apt.sss.v3
Class Lex

java.lang.Object
  extended by org.sc3d.apt.sss.v3.Lex

public class Lex
extends java.lang.Object

Represents a lexical analysis of a Sentence. The analysis recognises comments, keywords (including punctuation strings and separator characters), constants, identifers, numbers and strings, which it wraps up as Tokens with appropriate types. All white-space is discarded.


Field Summary
 int numTokens
          The number of lexographic Tokens found in 'sentence'.
 Sentence sentence
          The Sentence of which this is the lexical analysis.
 
Constructor Summary
Lex(Sentence sentence)
          Constructs a Lex representing the lexical structure of 'sentence'.
 
Method Summary
 Token getToken(int index)
          Returns one of the lexographic Tokens.
static void main(java.lang.String[] args)
          Takes one argument: a filename.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

sentence

public final Sentence sentence
The Sentence of which this is the lexical analysis.


numTokens

public final int numTokens
The number of lexographic Tokens found in 'sentence'.

Constructor Detail

Lex

public Lex(Sentence sentence)
Constructs a Lex representing the lexical structure of 'sentence'. Attaches error messages to 'sentence' if appropriate.

Method Detail

getToken

public Token getToken(int index)
Returns one of the lexographic Tokens.

Parameters:
index - the index of the Token, from '0' to 'numTokens-1'.

main

public static void main(java.lang.String[] args)
                 throws java.io.IOException
Takes one argument: a filename. Reads the file and lexes it. If there are errors, prints an error report. Otherwise lists the Tokens.

Throws:
java.io.IOException