Browse Source

made some small adjustments to improve readability

master
Github 2 years ago
parent
commit
d5ccabb01e
2 changed files with 5 additions and 5 deletions
  1. +1
    -1
      src/org/rubenruiz/lox/Lox.java
  2. +4
    -4
      src/org/rubenruiz/lox/Scanner.java

+ 1
- 1
src/org/rubenruiz/lox/Lox.java View File

@@ -77,7 +77,7 @@ public class Lox {
public static void main(String[] args) throws IOException {
// Improper use of lox would be if you were to give it more than one argument
if (args.length > 1) {
System.out.println("Usage: loxRun [script]");
System.out.println("Usage: Lox [script]");
System.exit(64);
}
// If you give it one argument, it assumes that it is a file

+ 4
- 4
src/org/rubenruiz/lox/Scanner.java View File

@@ -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 {

Loading…
Cancel
Save