Added some comments to scanner

java11
Sandy Brownlee 2 years ago
parent 71e2202512
commit 0233c814ac
  1. 4
      Triangle.Compiler/src/main/java/triangle/syntacticAnalyzer/Scanner.java

@ -63,6 +63,8 @@ public final class Scanner {
private void scanSeparator() { private void scanSeparator() {
switch (currentChar) { switch (currentChar) {
// comment
case '!': { case '!': {
takeIt(); takeIt();
while ((currentChar != SourceFile.EOL) && (currentChar != SourceFile.EOT)) while ((currentChar != SourceFile.EOL) && (currentChar != SourceFile.EOT))
@ -72,6 +74,7 @@ public final class Scanner {
} }
break; break;
// whitespace
case ' ': case ' ':
case '\n': case '\n':
case '\r': case '\r':
@ -247,6 +250,7 @@ public final class Scanner {
int kind; int kind;
currentlyScanningToken = false; currentlyScanningToken = false;
// skip any whitespace or comments
while (currentChar == '!' || currentChar == ' ' || currentChar == '\n' || currentChar == '\r' while (currentChar == '!' || currentChar == ' ' || currentChar == '\n' || currentChar == '\r'
|| currentChar == '\t') || currentChar == '\t')
scanSeparator(); scanSeparator();