Class ApplesoftCompiler
- java.lang.Object
-
- com.webcodepro.applecommander.compiler.ApplesoftCompiler
-
- All Implemented Interfaces:
ApplesoftTokens
public class ApplesoftCompiler extends java.lang.Object implements ApplesoftTokens
Compile the given Applesoft file. The result will be an assembly program (ultimately assembled). This is not intended to be anything sophisticated.Date created: Nov 2, 2002 10:04:10 PM
-
-
Field Summary
-
Fields inherited from interface com.webcodepro.applecommander.util.ApplesoftTokens
ABS, AMPERSAND, AND, ASC, AT, ATN, CALL, CHR$, CLEAR, COLOR, CONT, COS, DATA, DEF, DEL, DIM, DIVIDE, DRAW, END, EQUALS, EXP, FLASH, FN, FOR, FRE, GET, GOSUB, GOTO, GR, GREATERTHAN, HCOLOR, HGR, HGR2, HIMEM, HLIN, HOME, HPLOT, HTAB, IF, INnbr, INPUT, INT, INVERSE, LEFT$, LEN, LESSTHAN, LET, LIST, LOAD, LOG, LOMEM, MID$, MINUS, MULTIPLY, NEW, NEXT, NORMAL, NOT, NOTRACE, ON, ONERR, OR, PDL, PEEK, PLOT, PLUS, POKE, POP, POS, POWER, PRINT, PRnbr, READ, RECALL, REM, RESTORE, RESUME, RETURN, RIGHT$, RND, ROT, RUN, SAVE, SCALE, SCRN, SGN, SHLOAD, SIN, SPC, SPEED, SQR, STEP, STOP, STORE, STR$, TAB, TAN, TEXT, THEN, TO, TRACE, USR, VAL, VLIN, VTAB, WAIT, XDRAW
-
-
Constructor Summary
Constructors Constructor Description ApplesoftCompiler(FileEntry fileEntry)
Constructor for ApplesoftCompiler.
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description protected void
addAssembly(java.lang.String label, java.lang.String mnemonic, java.lang.String parameter)
protected void
addCopyFac(Variable variable)
protected void
addLoadAddress(Variable variable, char registerHi, char registerLo)
protected void
addLoadByteValue(Variable variable, char register)
protected void
addLoadFac(Variable variable)
protected void
addLoadWordValue(Variable variable, char registerHi, char registerLo)
protected java.lang.StringBuffer
buildUsedAddresses()
Build a list of ROM and Zero-page addresses that are used within this specific program.protected java.lang.StringBuffer
buildVariableSection()
Build the variable section that is placed at the end of the assembly listing.protected void
checkSyntax(byte tokenValue, java.lang.String expectedToken)
protected void
checkSyntax(java.lang.String stringValue, java.lang.String expectedToken)
byte[]
compile()
Compile the given FileEntry and return the assembly code.protected void
evaluateCommand()
void
evaluateEND()
protected Variable
evaluateExpression()
void
evaluateFLASH()
void
evaluateFOR()
void
evaluateGOTO()
void
evaluateGR()
void
evaluateHCOLOR()
void
evaluateHGR()
void
evaluateHGR2()
void
evaluateHOME()
void
evaluateHPLOT()
void
evaluateHTAB()
void
evaluateINVERSE()
void
evaluateNEXT()
void
evaluateNORMAL()
protected Variable
evaluateNumber()
void
evaluatePRINT()
void
evaluateRETURN()
void
evaluateTEXT()
void
evaluateVTAB()
protected java.lang.String
getLineNumberLabel()
Answer with the line number label.protected java.lang.reflect.Method
getMethod(ApplesoftToken token)
protected boolean
hasMoreTokens()
Answers true if there are more tokens to process.protected void
initializeKnownAddresses()
Load known memory addresses from AppleMemoryAddresses.properties.protected boolean
isIntegerNumber(java.lang.String value)
Indicates if this string is a number.boolean
isIntegerOnlyMath()
Indicates integer math only.protected ApplesoftToken
nextToken()
Get the next token.protected ApplesoftToken
peekToken()
Take a peek at the next token.void
setIntegerOnlyMath(boolean integerOnlyMath)
Sets integer only math.
-
-
-
Constructor Detail
-
ApplesoftCompiler
public ApplesoftCompiler(FileEntry fileEntry)
Constructor for ApplesoftCompiler.
-
-
Method Detail
-
initializeKnownAddresses
protected void initializeKnownAddresses()
Load known memory addresses from AppleMemoryAddresses.properties.
-
hasMoreTokens
protected boolean hasMoreTokens()
Answers true if there are more tokens to process.
-
nextToken
protected ApplesoftToken nextToken()
Get the next token.
-
peekToken
protected ApplesoftToken peekToken()
Take a peek at the next token.
-
compile
public byte[] compile() throws CompileException
Compile the given FileEntry and return the assembly code.- Throws:
CompileException
-
buildUsedAddresses
protected java.lang.StringBuffer buildUsedAddresses()
Build a list of ROM and Zero-page addresses that are used within this specific program.
-
buildVariableSection
protected java.lang.StringBuffer buildVariableSection()
Build the variable section that is placed at the end of the assembly listing.Warning: This method re-uses the global sourceAssembly variables since the addAssembly method is used to format the code.
-
evaluateCommand
protected void evaluateCommand()
-
getMethod
protected java.lang.reflect.Method getMethod(ApplesoftToken token)
-
addAssembly
protected void addAssembly(java.lang.String label, java.lang.String mnemonic, java.lang.String parameter)
-
evaluateHOME
public void evaluateHOME()
-
evaluateTEXT
public void evaluateTEXT()
-
evaluateRETURN
public void evaluateRETURN()
-
evaluateEND
public void evaluateEND()
-
evaluateHGR
public void evaluateHGR()
-
evaluateHGR2
public void evaluateHGR2()
-
evaluateGR
public void evaluateGR()
-
evaluateINVERSE
public void evaluateINVERSE()
-
evaluateNORMAL
public void evaluateNORMAL()
-
evaluateFLASH
public void evaluateFLASH()
-
evaluateExpression
protected Variable evaluateExpression() throws CompileException
- Throws:
CompileException
-
evaluateNumber
protected Variable evaluateNumber() throws CompileException
- Throws:
CompileException
-
getLineNumberLabel
protected java.lang.String getLineNumberLabel() throws CompileException
Answer with the line number label. Used by GOTO and ON expr GOTO statements.- Throws:
CompileException
-
addLoadByteValue
protected void addLoadByteValue(Variable variable, char register) throws CompileException
- Throws:
CompileException
-
addLoadWordValue
protected void addLoadWordValue(Variable variable, char registerHi, char registerLo) throws CompileException
- Throws:
CompileException
-
addLoadAddress
protected void addLoadAddress(Variable variable, char registerHi, char registerLo)
-
addLoadFac
protected void addLoadFac(Variable variable) throws CompileException
- Throws:
CompileException
-
addCopyFac
protected void addCopyFac(Variable variable) throws CompileException
- Throws:
CompileException
-
evaluateHTAB
public void evaluateHTAB() throws CompileException
- Throws:
CompileException
-
evaluateVTAB
public void evaluateVTAB() throws CompileException
- Throws:
CompileException
-
evaluateHCOLOR
public void evaluateHCOLOR() throws CompileException
- Throws:
CompileException
-
evaluatePRINT
public void evaluatePRINT() throws CompileException
- Throws:
CompileException
-
evaluateGOTO
public void evaluateGOTO() throws CompileException
- Throws:
CompileException
-
checkSyntax
protected void checkSyntax(byte tokenValue, java.lang.String expectedToken) throws CompileException
- Throws:
CompileException
-
checkSyntax
protected void checkSyntax(java.lang.String stringValue, java.lang.String expectedToken) throws CompileException
- Throws:
CompileException
-
evaluateFOR
public void evaluateFOR() throws CompileException
- Throws:
CompileException
-
evaluateHPLOT
public void evaluateHPLOT() throws CompileException
- Throws:
CompileException
-
evaluateNEXT
public void evaluateNEXT() throws CompileException
- Throws:
CompileException
-
isIntegerNumber
protected boolean isIntegerNumber(java.lang.String value)
Indicates if this string is a number.
-
isIntegerOnlyMath
public boolean isIntegerOnlyMath()
Indicates integer math only.
-
setIntegerOnlyMath
public void setIntegerOnlyMath(boolean integerOnlyMath)
Sets integer only math.
-
-