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 voidaddAssembly(java.lang.String label, java.lang.String mnemonic, java.lang.String parameter)protected voidaddCopyFac(Variable variable)protected voidaddLoadAddress(Variable variable, char registerHi, char registerLo)protected voidaddLoadByteValue(Variable variable, char register)protected voidaddLoadFac(Variable variable)protected voidaddLoadWordValue(Variable variable, char registerHi, char registerLo)protected java.lang.StringBufferbuildUsedAddresses()Build a list of ROM and Zero-page addresses that are used within this specific program.protected java.lang.StringBufferbuildVariableSection()Build the variable section that is placed at the end of the assembly listing.protected voidcheckSyntax(byte tokenValue, java.lang.String expectedToken)protected voidcheckSyntax(java.lang.String stringValue, java.lang.String expectedToken)byte[]compile()Compile the given FileEntry and return the assembly code.protected voidevaluateCommand()voidevaluateEND()protected VariableevaluateExpression()voidevaluateFLASH()voidevaluateFOR()voidevaluateGOTO()voidevaluateGR()voidevaluateHCOLOR()voidevaluateHGR()voidevaluateHGR2()voidevaluateHOME()voidevaluateHPLOT()voidevaluateHTAB()voidevaluateINVERSE()voidevaluateNEXT()voidevaluateNORMAL()protected VariableevaluateNumber()voidevaluatePRINT()voidevaluateRETURN()voidevaluateTEXT()voidevaluateVTAB()protected java.lang.StringgetLineNumberLabel()Answer with the line number label.protected java.lang.reflect.MethodgetMethod(ApplesoftToken token)protected booleanhasMoreTokens()Answers true if there are more tokens to process.protected voidinitializeKnownAddresses()Load known memory addresses from AppleMemoryAddresses.properties.protected booleanisIntegerNumber(java.lang.String value)Indicates if this string is a number.booleanisIntegerOnlyMath()Indicates integer math only.protected ApplesoftTokennextToken()Get the next token.protected ApplesoftTokenpeekToken()Take a peek at the next token.voidsetIntegerOnlyMath(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 CompileExceptionCompile 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 CompileExceptionAnswer 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.
-
-