|
||||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | |||||||||
java.lang.Objectorg.extex.ocpware.compiler.parser.CompilerState
public final class CompilerState
This class provides a compiler state to translate an otp file into an ocp.
The processing is done in two phases. In the first phase a parse tree is
build up. This happens within the method
parse(InputStream) or
CompilerState(InputStream) In the second
phase the parse tree is traversed and code is generated. This happens within
the method compile().
| Constructor Summary | |
|---|---|
CompilerState()
Creates a new object. |
|
CompilerState(java.io.InputStream stream)
Creates a new object. |
|
| Method Summary | |
|---|---|
OcpProgram |
compile()
Compile the current compiler state into an ocp program. |
java.util.Map<java.lang.String,Left> |
getAliases()
Getter for aliases. |
State |
getCurrentState()
Getter for current state. |
java.util.List<Expression> |
getExpressions()
Getter for expressions. |
int |
getIn()
Getter for in. |
int |
getOut()
Getter for out. |
java.util.List<State> |
getState()
Getter for state. |
java.util.Map<java.lang.String,java.lang.Integer> |
getStates()
Getter for states. |
java.util.Map<java.lang.String,Table> |
getTables()
Getter for tables. |
void |
incrExpr()
Increment the number of expressions for the current state. |
Left |
lookupAlias(java.lang.String alias)
Find a value for an alias name. |
int |
lookupState(java.lang.String state)
Find a number representation for a state name. |
int |
lookupTable(java.lang.String table)
Get the numeric index of a table from the symbolic name. |
void |
parse(java.io.InputStream stream)
Compile an input stream into an oc program. |
int |
putInstruction(int opCode)
Put an instruction of one op code and no argument into the store. |
int |
putInstruction(int opCode,
int n)
Put an instruction of one op code and one argument into the store. |
int |
putInstruction(int opCode,
int n,
int a)
Put an instruction of one op code and three arguments into the store. |
void |
setAliases(java.util.Map<java.lang.String,Left> aliases)
Setter for aliases. |
void |
setCurrentState(int state)
Setter for current state. |
void |
setCurrentState(java.lang.String state)
Setter for the current state. |
void |
setExpressions(java.util.List<Expression> expressions)
Setter for expressions. |
void |
setIn(int in)
Setter for in. |
void |
setOut(int out)
Setter for out. |
void |
setTables(java.util.Map<java.lang.String,Table> tables)
Setter for tables. |
void |
storeState(java.lang.String name)
Save a new name as name of a state. |
java.lang.String |
toString()
|
| Methods inherited from class java.lang.Object |
|---|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait |
| Constructor Detail |
|---|
public CompilerState()
throws StateDefinedException
StateDefinedException - in case that the INITIAL state is already
known – extremely unlikely
public CompilerState(java.io.InputStream stream)
throws java.io.IOException,
ArgmentTooBigException,
StateDefinedException,
SyntaxException,
TableDefinedException,
AliasDefinedException,
MissingExpressionsException
stream - the input stream
java.io.IOException - in case of an I/O error
ArgmentTooBigException - if the argument of the instruction exceeds
the 16 bit value
StateDefinedException - in case that a state is about to be defined
a second time
TableDefinedException - in case that a table is about to be defined
a second time
SyntaxException - in case of a syntax error
AliasDefinedException - in case that an attempt has been
encountered to define an alias a second time
MissingExpressionsException - in case of a syntax error| Method Detail |
|---|
public OcpProgram compile()
throws AliasNotDefinedException,
ArgmentTooBigException,
java.io.IOException,
StateNotDefinedException,
TableNotDefinedException
AliasNotDefinedException - in case that no matching alias is known
for a symbolic table reference
ArgmentTooBigException - in case that an argument is encountered
which does not fit into two bytes
java.io.IOException - in case of an I/O error
StateNotDefinedException - in case that no matching state is known
for a symbolic table reference
TableNotDefinedException - in case that no matching table is known
for a symbolic table referencepublic java.util.Map<java.lang.String,Left> getAliases()
public State getCurrentState()
public java.util.List<Expression> getExpressions()
public int getIn()
public int getOut()
public java.util.List<State> getState()
public java.util.Map<java.lang.String,java.lang.Integer> getStates()
public java.util.Map<java.lang.String,Table> getTables()
public void incrExpr()
public Left lookupAlias(java.lang.String alias)
throws AliasNotDefinedException
alias - the string representation of the alias
AliasNotDefinedException - in case that the alias is not defined
public int lookupState(java.lang.String state)
throws StateNotDefinedException
state - the string representation of the state
StateNotDefinedException - in case that the state is not defined
public int lookupTable(java.lang.String table)
throws TableNotDefinedException
table - the name of the table
TableNotDefinedException - in case that no matching table is known
public void parse(java.io.InputStream stream)
throws java.io.IOException,
ArgmentTooBigException,
SyntaxException,
StateDefinedException,
TableDefinedException,
AliasDefinedException,
MissingExpressionsException
stream - the input stream
java.io.IOException - in case of an I/O error
ArgmentTooBigException - if the argument of the instruction exceeds
the 16 bit value
SyntaxException - in case of a syntax error
StateDefinedException - in case that a state is about to be defined
a second time
TableDefinedException - in case that a table is about to be defined
a second time
AliasDefinedException - in case that an attempt has been
encountered to define an alias a second time
MissingExpressionsException - in case of a syntax error
public int putInstruction(int opCode)
throws java.io.IOException
opCode - the op code
java.io.IOException - in case of an I/O error
IllegalOpcodeException - in case of an illegal op code
public int putInstruction(int opCode,
int n)
throws java.io.IOException,
ArgmentTooBigException
opCode - the op coden - the first argument
java.io.IOException - in case of an I/O error
ArgmentTooBigException - if the argument of the instruction exceeds
the 16 bit value
IllegalOpcodeException - in case of an illegal op code
public int putInstruction(int opCode,
int n,
int a)
throws java.io.IOException,
ArgmentTooBigException
opCode - the op coden - the first argumenta - the second argument
java.io.IOException - in case of an I/O error
ArgmentTooBigException - if the argument of the instruction exceeds
the 16 bit value
IllegalOpcodeException - in case of an illegal op codepublic void setAliases(java.util.Map<java.lang.String,Left> aliases)
aliases - the aliases to setpublic void setCurrentState(int state)
state - the current state index
public void setCurrentState(java.lang.String state)
throws StateNotDefinedException
state - the new state
StateNotDefinedException - in case that the state is not definedpublic void setExpressions(java.util.List<Expression> expressions)
expressions - the expressions to setpublic void setIn(int in)
in - the in to setpublic void setOut(int out)
out - the out to setpublic void setTables(java.util.Map<java.lang.String,Table> tables)
tables - the tables to set
public void storeState(java.lang.String name)
throws StateDefinedException
name - the name of the state
StateDefinedException - in case that the name is already registered
as statepublic java.lang.String toString()
toString in class java.lang.ObjectObject.toString()
|
||||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | |||||||||