|
|||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
SUMMARY: INNER | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Object | +--Interpreter.LispInterpreter.Parser
Analizzatore sintattico (AS) per linguaggio Lisp (e Scheme).
Un AS è un riconoscitore delle frasi del linguaggio. Oltre a riconoscere
le frasi del linguaggio, il Parser costruisce una rappresentazione interna
delle frasi stesse.
L'utilizzo normale prevede di utilizzare il comando feed per indicare al lexer da dove prendere l'input.
Dopo una feed si utilizza il metodo read() per farsi restituire la forma interna della prima frase.
Si richiama la read() per la frase successiva.
Il lexer è gestito direttamente dal parser.
Si può anche interrompere il parsing di una frase per iniziarne una nuova, poi successivamente ripristinare il parsing interrotto. Questo si può ottenere grazie ai metodi feed e reload.
Grammatica Scheme:
Program ::= Sexp | Sexp Program |
Sexp ::= ConsSexp | Ident |
ConsSexp ::= () | ( Sexp PairOrList |
PairOrList ::= ) | . Sexp ) | Sexp PairOrList |
Ident ::= <identificatore> | <numero> |
read()
,
feed(Reader)
,
feed(String)
,
reload(LispLexer)
Constructor Summary | |
Parser(OutputBuffer Out)
Costruisce un nuovo Parser. |
Method Summary | |
LispLexer |
feed(java.io.Reader I)
Crea un nuovo oggetto LispLexer inizializzato con l'oggetto Reader specificato. |
LispLexer |
feed(java.lang.String s)
Crea un nuovo oggetto LispLexer inizializzato con l'oggetto String specificato. |
static void |
main(java.lang.String[] args)
Metodo main utilizzato per il debugging. |
Sexp |
read()
Consuma un'istruzione del Programma Lisp. |
void |
reload(LispLexer lexer)
Il lexer passato come parametro diventa il lexer corrente. |
void |
setPrimitive(java.lang.String prim)
Aggiunge una primitiva al set di primitive predefinite. |
Methods inherited from class java.lang.Object |
clone,
equals,
finalize,
getClass,
hashCode,
notify,
notifyAll,
toString,
wait,
wait,
wait |
Constructor Detail |
public Parser(OutputBuffer Out)
Out
- un oggetto OutputBuffer che costituirà lo standard output.Method Detail |
public void setPrimitive(java.lang.String prim)
prim
- nome della primitiva da aggiungere al set di primitive
predefinite.public LispLexer feed(java.io.Reader I)
I
- oggetto Reader con cui inizializzare il nuovo lexer.reload(LispLexer)
public LispLexer feed(java.lang.String s)
s
- oggetto String con cui inizializzare il nuovo lexer.reload(LispLexer)
public void reload(LispLexer lexer)
Lexer
- oggetto LispLexer che diventerà il lexer attuale.feed(Reader)
,
feed(String)
public Sexp read() throws InterpreterException
public static void main(java.lang.String[] args)
|
|||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
SUMMARY: INNER | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |