|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Object | +--mars.assembler.Tokenizer
A tokenizer is capable of tokenizing a complete MIPS program, or a given line from
a MIPS program. Since MIPS is line-oriented, each line defines a complete statement.
Tokenizing is the process of analyzing the input MIPS program for the purpose of
recognizing each MIPS language element. The types of language elements are known as "tokens".
MIPS tokens are defined in the TokenTypes class.
Example:
The MIPS statement here: lw $t3, 8($t4) #load third member of array
generates the following token list
IDENTIFIER, COLON, OPERATOR, REGISTER_NAME, COMMA, INTEGER_5, LEFT_PAREN,
REGISTER_NAME, RIGHT_PAREN, COMMENT
Constructor Summary | |
Tokenizer()
Simple constructor. |
Method Summary | |
ErrorList |
getErrors()
Fetch this Tokenizer's error list. |
java.util.ArrayList |
tokenize(MIPSprogram p)
Will tokenize a complete MIPS program. |
TokenList |
tokenizeExampleInstruction(java.lang.String example)
Used only to create a token list for the example provided with each instruction specification. |
TokenList |
tokenizeLine(int lineNum,
java.lang.String theLine)
Will tokenize one line of source code. |
TokenList |
tokenizeLine(int lineNum,
java.lang.String theLine,
ErrorList callerErrorList)
Will tokenize one line of source code. |
Methods inherited from class java.lang.Object |
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
Constructor Detail |
public Tokenizer()
Method Detail |
public java.util.ArrayList tokenize(MIPSprogram p) throws ProcessingException
p
- The MIPSprogram to be tokenized.
ProcessingException
public TokenList tokenizeExampleInstruction(java.lang.String example) throws ProcessingException
example
- The example MIPS instruction to be tokenized.
ProcessingException
- This occurs only if the instruction specification itself
contains one or more lexical (i.e. token) errors.public TokenList tokenizeLine(int lineNum, java.lang.String theLine)
lineNum
- line number from source code (used in error message)theLine
- String containing source code
public TokenList tokenizeLine(int lineNum, java.lang.String theLine, ErrorList callerErrorList)
lineNum
- line number from source code (used in error message)theLine
- String containing source codecallerErrorList
- errors will go into this list instead of tokenizer's list.
public ErrorList getErrors()
|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |