Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- class IfStatement
- {
- String condition;
- String gotoLabel;
- }
- public void parseLine(String line)
- {
- line = line.trim();
- String[] parts = line.split("\\s+");
- String command = parts[0];
- if(command.equals("IF"))
- {
- String condition = parts[1];
- boolean result = evaluate(conditon);
- if(parts[2].equals("GOTO"))
- {
- String gotoLabel = parts[3];
- if(!gotoLabel.startsWith("#"))
- throw new CompileError();
- instructions.add(new IfStatement(condition, gotoLabel));
- }
- }
- else if(command.equals("GOTO"))
- {
- line = line.substring(5);
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement