|
|||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
SUMMARY: INNER | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Object | +--Interpreter.Sexp.Utils.Lexer.StreamTokenizerWithAtom | +--Interpreter.Sexp.Utils.Lexer.LexerMask | +--Interpreter.Sexp.Utils.Lexer.Lexer
La classe Lexer definisce un lexer generico.
Per utilizzarlo si deve creare una classe derivata in cui si specializzano le funzioni.
Tramite la LoadKey() si definiscono tutte le parole chiavi e i caratteri speciali che
devono essere riconosciute.
Con BuildSpecial() si definisce il comportamento nei casi particolari.
Con next() si ottengono i Token.
Field Summary | |
protected java.util.HashSet |
OperationalSet
Set contenente le stringhe corrispondenti ad operatori predefiniti preesistenti. |
protected java.util.HashSet |
PrimitiveSet
Set contenente le stringhe corrispondenti ad operatori predefiniti preesistenti. |
protected java.util.HashSet |
RelationalSet
Set contenente le stringhe corrispondenti ad operatori predefiniti preesistenti. |
protected java.util.HashSet |
SpecialSet
Set contenente le stringhe corrispondenti ad operatori predefiniti preesistenti. |
Fields inherited from class Interpreter.Sexp.Utils.Lexer.StreamTokenizerWithAtom |
nospaces,
nval,
sval,
TT_ATOM,
TT_EOF,
TT_EOL,
TT_NUMBER,
TT_WORD,
ttype |
Constructor Summary | |
Lexer(java.io.Reader I)
Costruisce un Lexer che accetta come parametro un oggetto Reader. |
|
Lexer(java.lang.String s)
Costruisce un Lexer che accetta come parametro una stringa. |
Method Summary | |
protected Sexp |
BuildSpecial(java.lang.String tok)
Funzione che deve essere specializzata dalle classi derivate per trattare tutti i casi particolari definiti in SpecialSet. Se non ridefinito, il metodo BuildSpecial genera n'eccezione. |
protected Sexp |
getToken(java.lang.String s,
boolean isWord)
Analizza le parole ed i caratteri ordinari trovati nella next(). |
void |
LoadKeys(java.util.HashSet PSet,
java.util.HashSet OpSet,
java.util.HashSet RelSet,
java.util.HashSet SpSet)
Funzione di inizializzazione dei Set di parole chiave riconosciute e caratteri speciali. |
Sexp |
next()
Analizza il token corrente della stringa ed avanza il puntatore all'interno della stringa, di modo che la prossima chiamata alla next() analizzi il token successivo. |
Methods inherited from class Interpreter.Sexp.Utils.Lexer.StreamTokenizerWithAtom |
atom,
commentChar,
eolIsSignificant,
lineno,
lowerCaseMode,
nextToken,
ordinaryChar,
ordinaryChars,
parseNumbers,
pushBack,
quoteChar,
resetSyntax,
slashSlashComments,
slashStarComments,
toString,
whitespaceChars,
wordChars |
Methods inherited from class java.lang.Object |
clone,
equals,
finalize,
getClass,
hashCode,
notify,
notifyAll,
wait,
wait,
wait |
Field Detail |
protected java.util.HashSet PrimitiveSet
protected java.util.HashSet OperationalSet
protected java.util.HashSet RelationalSet
protected java.util.HashSet SpecialSet
Constructor Detail |
public Lexer(java.io.Reader I)
I
- oggetto Reader contenente la stringa da analizzare.public Lexer(java.lang.String s)
s
- è la stringa da essere analizzata.Method Detail |
public void LoadKeys(java.util.HashSet PSet, java.util.HashSet OpSet, java.util.HashSet RelSet, java.util.HashSet SpSet)
Pset
- è l'insieme delle primitiveOpSet
- è l'insieme degli operatori aritmeticiRelSet
- è l'insieme degli operatori relazionaliSpSet
- è l'insieme di tutti i caratteri e le stringhe specialiprotected Sexp getToken(java.lang.String s, boolean isWord) throws InterpreterException
s
- parola o carattere da analizzare.protected Sexp BuildSpecial(java.lang.String tok) throws InterpreterException
tok
- la stringa che deve essere riconosciutapublic Sexp next() throws InterpreterException
|
|||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
SUMMARY: INNER | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |