|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Objectslogo.jelan.parser.ElanInterpreter
public class ElanInterpreter
Illustrates the java.io.StreamTokenizer class and how it can be used to parse tokens for an example programming language (elan). For this example simple instructions are parsed, but lots of infrastructure is in place for parsing a more complete language.
slogo.jelan.expressions
,
slogo.jelan.instructions
,
InstructionParser
Constructor Summary | |
---|---|
ElanInterpreter()
|
Method Summary | |
---|---|
void |
error(Token t)
|
Token |
getToken()
returns the current token, doesn't fetch a new one |
void |
interpreter(java.io.Reader r)
parses an expression and prints the result of evaluating the expression. |
static void |
main(java.lang.String[] args)
Basic driver for ElanParser |
Token |
match(Token rhs)
try to match a token, if unsuccessful throw an exception, otherwise match succeeds, and next token is obtained and returned |
Methods inherited from class java.lang.Object |
---|
equals, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
Constructor Detail |
---|
public ElanInterpreter()
Method Detail |
---|
public void interpreter(java.io.Reader r)
r
- the reader that will be tokenizedpublic Token getToken()
public Token match(Token rhs)
rhs
- token being matched
ParseException
- if match failspublic void error(Token t)
t
- token where error occurred
a
- ParseException labeled by tpublic static void main(java.lang.String[] args)
args
-
|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |