Administrator approval is now required for registering new accounts. If you are registering a new account, and are external to the University, please ask the repository owner to contact ServiceLine to request your account be approved. Repository owners must include the newly registered email address, and specific repository in the request for approval.

Commit 73c6fc9b authored by mutantoe's avatar mutantoe
Browse files

Added basic code for running clear instructions.

parent f49360ed
......@@ -70,6 +70,9 @@ public class Interpreter {
return token;
}
public boolean validateStatement(final ArrayList<Token> tokens, int stmt_begin, int stmt_end){
public void exec() {
ArrayList<Token> tokenHistory = new ArrayList<Token>();
Token lookahead;
......@@ -84,15 +87,17 @@ public class Interpreter {
tokenHistory.add(lookahead);
} while(lookahead.getType()!=TokenType.SEMICOLON);
// Run statement
for (int stmt_idx = stmt_begin; stmt_idx < stmt_end; stmt_idx++) {
Token currentToken = tokenHistory.get(stmt_idx);
switch (currentToken.getType()) {
case CLEAR:
default:
throw new IllegalStateException("Illegal token type: "
+ Token.tokenTypeToString(currentToken.getType()));
int stmt_len = stmt_end-stmt_begin;
Token currentToken = tokenHistory.get(stmt_idx);
switch (currentToken.getType()) {
case CLEAR:
if(tokenHistory.get(stmt_begin+1).getType()==TokenType.IDENTIFIER){
ValueToken token = tokenHistory.get(stmt_begin+1);
m_variables.get(token.getName()) = 0;
}
default:
throw new IllegalStateException("Illegal token type: "
+ Token.tokenTypeToString(currentToken.getType()));
}
}
}
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment