|
|
@@ -63,7 +63,7 @@ public class Scanner { |
|
|
|
} |
|
|
|
|
|
|
|
public void scanToken() { |
|
|
|
char c = advance(); |
|
|
|
char currentChar = advance(); |
|
|
|
// This converts the incoming char to a token and adds it to the list |
|
|
|
// We started with the single character tokens as they are the easiest |
|
|
|
// Then, we moved on to the potentially double character ones |
|
|
@@ -75,7 +75,7 @@ public class Scanner { |
|
|
|
// without having to specify every numeral) |
|
|
|
// Finally, a catchall that throws an error if it doesn't recognize |
|
|
|
// the symbol |
|
|
|
switch (c){ |
|
|
|
switch (currentChar){ |
|
|
|
case '(': addToken(LEFT_PAREN); break; |
|
|
|
case ')': addToken(RIGHT_PAREN); break; |
|
|
|
case '{': addToken(LEFT_BRACE); break; |
|
|
@@ -114,10 +114,10 @@ public class Scanner { |
|
|
|
default: |
|
|
|
// Check if it is a numeral first and if not, then throw the error |
|
|
|
// Then check if it is an identifier and if not, then throw the error |
|
|
|
if (isDigit(c)) { |
|
|
|
if (isDigit(currentChar)) { |
|
|
|
number(); |
|
|
|
} |
|
|
|
else if (isAlpha(c)){ |
|
|
|
else if (isAlpha(currentChar)){ |
|
|
|
identifier(); |
|
|
|
} |
|
|
|
else { |