|
|||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Objectmars.assembler.Tokenizer
public class 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. |
|
Tokenizer(MIPSprogram program)
Constructor for use with existing MIPSprogram. |
Method Summary | |
---|---|
ErrorList |
getErrors()
Fetch this Tokenizer's error list. |
ArrayList |
tokenize(MIPSprogram p)
Will tokenize a complete MIPS program. |
TokenList |
tokenizeExampleInstruction(String example)
Used only to create a token list for the example provided with each instruction specification. |
TokenList |
tokenizeLine(int lineNum,
String theLine)
Will tokenize one line of source code. |
TokenList |
tokenizeLine(int lineNum,
String theLine,
ErrorList callerErrorList)
Will tokenize one line of source code. |
TokenList |
tokenizeLine(int lineNum,
String theLine,
ErrorList callerErrorList,
boolean doEqvSubstitutes)
Will tokenize one line of source code. |
TokenList |
tokenizeLine(MIPSprogram program,
int lineNum,
String theLine,
boolean doEqvSubstitutes)
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()
public Tokenizer(MIPSprogram program)
program
- A previously-existing MIPSprogram object or null if none.Method Detail |
---|
public ArrayList tokenize(MIPSprogram p) throws ProcessingException
p
- The MIPSprogram to be tokenized.
ProcessingException
public TokenList tokenizeExampleInstruction(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, String theLine)
lineNum
- line number from source code (used in error message)theLine
- String containing source code
public TokenList tokenizeLine(int lineNum, 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 TokenList tokenizeLine(int lineNum, String theLine, ErrorList callerErrorList, boolean doEqvSubstitutes)
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.doEqvSubstitutse
- boolean param set true to perform .eqv substitutions, else false
public TokenList tokenizeLine(MIPSprogram program, int lineNum, String theLine, boolean doEqvSubstitutes)
program
- MIPSprogram containing this line of sourcelineNum
- line number from source code (used in error message)theLine
- String containing source codedoEqvSubstitutes
- boolean param set true to perform .eqv substitutions, else false
public ErrorList getErrors()
|
|||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |