|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Objectslogo.jelan.parser.ElanParser
public class ElanParser
Illustrates the java.io.StreamTokenizer class and how it can be used to parse tokens for a toy 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 | |
---|---|
ElanParser()
|
Method Summary | |
---|---|
void |
error(Token t)
|
Token |
getToken()
returns the current token, doesn't fetch a new one |
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 |
void |
parse(java.io.Reader r)
parses an expression and prints the result of evaluating the expression. |
Methods inherited from class java.lang.Object |
---|
equals, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
Constructor Detail |
---|
public ElanParser()
Method Detail |
---|
public void parse(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 |