Skip to content

Commit

Permalink
fixed error caused by negative number for St instruction
Browse files Browse the repository at this point in the history
  • Loading branch information
aspwil committed Apr 4, 2021
1 parent c0ebfef commit ad8a07c
Showing 1 changed file with 3 additions and 0 deletions.
3 changes: 3 additions & 0 deletions src/ndballsim/Parser.java
Original file line number Diff line number Diff line change
Expand Up @@ -414,6 +414,9 @@ public static Instr[] parse(String file, boolean unlimit) {
error(lineNum, "String instruction requires a ending \"]\" ex. St[num]");
}
try {
if( Integer.parseInt(line.substring(3, line.length() - 1)) < 0){
error(lineNum, "String instruction only accepts non-negative numbers");
}
list.add(new Instr(pos, "St", Integer.parseInt(line.substring(3, line.length() - 1))));
} catch (NumberFormatException e) {
//was not a number
Expand Down

0 comments on commit ad8a07c

Please sign in to comment.