diff --git a/.classpath b/.classpath
new file mode 100644
index 0000000..07ca123
--- /dev/null
+++ b/.classpath
@@ -0,0 +1,6 @@
+
+
+
+
+
+
diff --git a/.project b/.project
new file mode 100644
index 0000000..328a6bd
--- /dev/null
+++ b/.project
@@ -0,0 +1,17 @@
+
+
+ RobotWarsSVN
+
+
+
+
+
+ org.eclipse.jdt.core.javabuilder
+
+
+
+
+
+ org.eclipse.jdt.core.javanature
+
+
diff --git a/.settings/org.eclipse.jdt.core.prefs b/.settings/org.eclipse.jdt.core.prefs
new file mode 100644
index 0000000..9f8758e
--- /dev/null
+++ b/.settings/org.eclipse.jdt.core.prefs
@@ -0,0 +1,12 @@
+#Wed Nov 04 12:00:17 GMT-05:00 2009
+eclipse.preferences.version=1
+org.eclipse.jdt.core.compiler.codegen.inlineJsrBytecode=enabled
+org.eclipse.jdt.core.compiler.codegen.targetPlatform=1.6
+org.eclipse.jdt.core.compiler.codegen.unusedLocal=preserve
+org.eclipse.jdt.core.compiler.compliance=1.6
+org.eclipse.jdt.core.compiler.debug.lineNumber=generate
+org.eclipse.jdt.core.compiler.debug.localVariable=generate
+org.eclipse.jdt.core.compiler.debug.sourceFile=generate
+org.eclipse.jdt.core.compiler.problem.assertIdentifier=error
+org.eclipse.jdt.core.compiler.problem.enumIdentifier=error
+org.eclipse.jdt.core.compiler.source=1.6
diff --git a/src/lexer/Block.java b/src/lexer/Block.java
new file mode 100644
index 0000000..e138288
--- /dev/null
+++ b/src/lexer/Block.java
@@ -0,0 +1,91 @@
+package lexer;
+
+import java.util.ArrayList;
+
+import lexer.Token.TokenType;
+
+public class Block {
+
+ ArrayList block = new ArrayList();
+
+ Block(Token current, Token lookAhead, TextFile body)
+ {
+ while(current != null && lookAhead != null && (current.getType() == TokenType.KEYWORD | current.getType() == TokenType.GAMEORDER) && !current.getText().equals("RETURN"))
+ {
+ if(current.equals("IF"))
+ {
+ if (lookAhead.equals("("))
+ {
+ current = body.getNonWSToken();
+ lookAhead = body.getNonWSToken();
+ IfOnly ifOnlyBlockToBeAdded = new IfOnly(current, lookAhead, body);
+ block.add(ifOnlyBlockToBeAdded);
+ }
+ else
+ {
+ System.out.println("ERROR: ( expected after IF on line" + body.getLine());
+ }
+ }
+ else if(current.equals("IFELSE"))
+ {
+ if (lookAhead.equals("("))
+ {
+ current = body.getNonWSToken();
+ lookAhead = body.getNonWSToken();
+ IfElse ifElseBlockToBeAdded = new IfElse(current, lookAhead, body);
+ block.add(ifElseBlockToBeAdded);
+ }
+ else
+ {
+ System.out.println("ERROR: ( expected after IFELSE on line" + body.getLine());
+ }
+ }
+ else if(current.equals("WHILE"))
+ {
+ if (lookAhead.equals("("))
+ {
+ current = body.getNonWSToken();
+ lookAhead = body.getNonWSToken();
+ While whileBlockToBeAdded = new While(current, lookAhead, body);
+ block.add(whileBlockToBeAdded);
+ }
+ else
+ {
+ System.out.println("ERROR: ( expected after WHILE on line" + body.getLine());
+ }
+ }
+ else if(current.equals("VAR"))
+ {
+ if (lookAhead.getType() == TokenType.IDENTIFIER)
+ {
+ current = body.getNonWSToken();
+ lookAhead = body.getNonWSToken();
+ VariableAssignment variableAssignmentStatementToBeAdded = new VariableAssignment(current, lookAhead, body);
+ block.add(variableAssignmentStatementToBeAdded);
+ }
+ else
+ {
+ System.out.println("ERROR: IDENTIFIER expected after VAR on line" + body.getLine());
+ }
+ }
+ else if(current.getType() == TokenType.GAMEORDER)
+ {
+ if (lookAhead.equals("("))
+ {
+ current = body.getNonWSToken();
+ lookAhead = body.getNonWSToken();
+ GameCommand gameCommandStatementToBeAdded = new GameCommand(current, lookAhead, body);
+ block.add(gameCommandStatementToBeAdded);
+ }
+ else
+ {
+ System.out.println("ERROR: ( expected after GAMEORDER on line" + body.getLine());
+ }
+ }
+ else
+ {
+ System.out.println("ERROR: IF, IFELSE, WHILE, VAR, or GAMEORDER command expected while parsing line "+ body.getLine());
+ }
+ }
+ }
+}
diff --git a/src/lexer/Expression.java b/src/lexer/Expression.java
new file mode 100644
index 0000000..6691aa6
--- /dev/null
+++ b/src/lexer/Expression.java
@@ -0,0 +1,27 @@
+package lexer;
+
+import java.util.ArrayList;
+
+import lexer.Token.TokenType;
+
+public class Expression {
+
+
+
+ public Expression(Token current, Token lookAhead, TextFile body) {
+
+
+ ArrayList terms;
+ ArrayList addops;
+
+ Term first = new Term(current, lookAhead, body);
+
+ while(!(current.getType() == TokenType.CONDITION))
+ {
+
+ Term tempT = new Term(current, lookAhead, body);
+ }
+
+ }
+
+}
diff --git a/src/lexer/GameCommand.java b/src/lexer/GameCommand.java
index 954d979..d4f619a 100644
--- a/src/lexer/GameCommand.java
+++ b/src/lexer/GameCommand.java
@@ -4,6 +4,10 @@
public class GameCommand implements Statement {
+ public GameCommand(Token current, Token lookAhead, TextFile body) {
+ // TODO Auto-generated constructor stub
+ }
+
@Override
public ArrayList evaluate() {
// TODO Auto-generated method stub
diff --git a/src/lexer/IfElse.java b/src/lexer/IfElse.java
index d2be8df..75f8af6 100644
--- a/src/lexer/IfElse.java
+++ b/src/lexer/IfElse.java
@@ -4,6 +4,10 @@
public class IfElse implements Statement {
+ public IfElse(Token current, Token lookAhead, TextFile body) {
+ // TODO Auto-generated constructor stub
+ }
+
@Override
public ArrayList evaluate() {
// TODO Auto-generated method stub
diff --git a/src/lexer/IfOnly.java b/src/lexer/IfOnly.java
index 2ab12b1..2d1746b 100644
--- a/src/lexer/IfOnly.java
+++ b/src/lexer/IfOnly.java
@@ -4,6 +4,16 @@
public class IfOnly implements Statement {
+ Expression leftExp, rightExp;
+ String Condition;
+
+ public IfOnly(Token current, Token lookAhead, TextFile body)
+ {
+ leftExp = new Expression(current, lookAhead, body);
+ Condition = current.getText();
+ rightExp = new Expression(current, lookAhead, body);
+ }
+
@Override
public ArrayList evaluate() {
// TODO Auto-generated method stub
diff --git a/src/lexer/MainProgram.java b/src/lexer/MainProgram.java
new file mode 100644
index 0000000..d6b0fe8
--- /dev/null
+++ b/src/lexer/MainProgram.java
@@ -0,0 +1,9 @@
+package lexer;
+
+public class MainProgram {
+
+ public MainProgram(Token current, Token lookAhead, TextFile body) {
+ // TODO Auto-generated constructor stub
+ }
+
+}
diff --git a/src/lexer/Routine.java b/src/lexer/Routine.java
new file mode 100644
index 0000000..c0129bf
--- /dev/null
+++ b/src/lexer/Routine.java
@@ -0,0 +1,32 @@
+package lexer;
+
+import java.util.TreeSet;
+
+public class Routine {
+
+ MainProgram main;
+ TreeSet subroutines = new TreeSet();
+
+ Routine(TextFile body)
+ {
+ Token current = body.getNonWSToken();
+ Token lookAhead = body.getNonWSToken();
+
+ if(current != null && lookAhead != null)
+ {
+ if(current.getText().equals("MAIN"))
+ {
+ main = new MainProgram(current, lookAhead, body);
+ }
+ else if(current.getText().equals("ROUTINE"))
+ {
+ RoutineProgram temp = new RoutineProgram(current, lookAhead, body);
+ subroutines.add(temp);
+ }
+ else
+ {
+ System.out.println("ERROR: MAIN or SUBROUTINE keyword expected while parsing line "+ body.getLine());
+ }
+ }
+ }
+}
diff --git a/src/lexer/RoutineProgram.java b/src/lexer/RoutineProgram.java
new file mode 100644
index 0000000..05ebe6e
--- /dev/null
+++ b/src/lexer/RoutineProgram.java
@@ -0,0 +1,9 @@
+package lexer;
+
+public class RoutineProgram {
+
+ public RoutineProgram(Token current, Token lookAhead, TextFile body) {
+ // TODO Auto-generated constructor stub
+ }
+
+}
diff --git a/src/lexer/Start.java b/src/lexer/Start.java
index 38190e3..b554e6b 100644
--- a/src/lexer/Start.java
+++ b/src/lexer/Start.java
@@ -25,7 +25,7 @@ public static void main(String[] args) {
while(!sFile.isEndOfFile())
{
- Token temp = sFile.getToken();
+ Token temp = sFile.getNonWSToken();
System.out.print(temp.getText() +" IS A:");
System.out.println(temp.getType());
}
diff --git a/src/lexer/Term.java b/src/lexer/Term.java
new file mode 100644
index 0000000..121de94
--- /dev/null
+++ b/src/lexer/Term.java
@@ -0,0 +1,10 @@
+package lexer;
+
+public class Term {
+
+ public Term(Token current, Token lookAhead, TextFile body)
+ {
+
+ }
+
+}
diff --git a/src/lexer/TextFile.java b/src/lexer/TextFile.java
index b80e1d0..3046a1e 100644
--- a/src/lexer/TextFile.java
+++ b/src/lexer/TextFile.java
@@ -134,8 +134,25 @@ public String getCharacter()
return character;
}
+ public Token getNonWSToken()
+ {
+ Token flag = getToken();
+ while (flag.getType() == TokenType.WS && flag != null)
+ {
+ flag = getToken();
+ }
+ return flag;
+ }
+
public Token getToken()
{
+
+ if(isEndOfFile())
+ {
+ System.out.println("Ran out of tokens.");
+ return null;
+ }
+
String rVal = body.get(rowPointer); //Get the string out of the array located at the rowPointer
rVal = rVal.substring(posPointer); //Get the portion of the string to the right of the posPointer
for(int i = rowPointer+1; i < body.size(); i++)
@@ -257,9 +274,8 @@ else if(TokenType.matchesToken(TokenType.IDENTIFIER, temp)) //If it is a properl
{
posPointer -= body.get(rowPointer).length();
rowPointer++;
- }
-// System.out.println("ROW:"+rowPointer);
-// System.out.println("POS:"+posPointer);
+ }
+
return new Token(returnTokType, returnTokText);
}
diff --git a/src/lexer/VariableAssignment.java b/src/lexer/VariableAssignment.java
index 2c6ba82..03a3c6e 100644
--- a/src/lexer/VariableAssignment.java
+++ b/src/lexer/VariableAssignment.java
@@ -4,6 +4,10 @@
public class VariableAssignment implements Statement {
+ public VariableAssignment(Token current, Token lookAhead, TextFile body) {
+ // TODO Auto-generated constructor stub
+ }
+
@Override
public ArrayList evaluate() {
// TODO Auto-generated method stub
diff --git a/src/lexer/While.java b/src/lexer/While.java
index f77b133..4cd962e 100644
--- a/src/lexer/While.java
+++ b/src/lexer/While.java
@@ -4,6 +4,10 @@
public class While implements Statement {
+ public While(Token current, Token lookAhead, TextFile body) {
+ // TODO Auto-generated constructor stub
+ }
+
@Override
public ArrayList evaluate() {
// TODO Auto-generated method stub
diff --git a/test b/test
new file mode 100644
index 0000000..f5cbf27
--- /dev/null
+++ b/test
@@ -0,0 +1,10 @@
+IF IFELSE ELSE VAR MAIN RETURN SUBROUTINE WHILE #Keywords
++-/*% #operators
+{}()=;, #symbols
+0 1 2 3 4 5 6 7 8 9 10 34943 39924 -324933 00-2394 #digits
+!= == <= >= < > #conditions
+ #white space
+isEnemyInRange isHealth directionOfClosestEnemy #game functions
+move turn skip selfDestruct attackWithWeapon useItem #game orders
+AHORSE A_3402aFdko230__ A_ A A439423 AGJFID IFF IFeLse IF4 WHILE9 While WHILE_#identifiers
+_fdishfs 3asdjkj 3943ajsdjajds \ [ ] ~ ` . ? ! #errors
\ No newline at end of file