Compare commits
1 Commits
line-symbo
...
multiline-
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
30fbde8c31 |
1
.gitignore
vendored
1
.gitignore
vendored
@@ -3,3 +3,4 @@ out/
|
|||||||
*.zip
|
*.zip
|
||||||
prg/**/*.ast
|
prg/**/*.ast
|
||||||
prg/**/*.out
|
prg/**/*.out
|
||||||
|
prg/**/*.pins25
|
||||||
@@ -1,4 +0,0 @@
|
|||||||
fun putint(n)
|
|
||||||
|
|
||||||
fun main() =
|
|
||||||
putint(__LINE__)
|
|
||||||
@@ -148,11 +148,7 @@ public record Token(Report.Location location, Symbol symbol, String lexeme) impl
|
|||||||
/**
|
/**
|
||||||
* Simbol {@code )}.
|
* Simbol {@code )}.
|
||||||
*/
|
*/
|
||||||
RPAREN,
|
RPAREN;
|
||||||
/**
|
|
||||||
* Simbol {@code __LINE__}.
|
|
||||||
*/
|
|
||||||
LINE
|
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
|
|||||||
@@ -247,9 +247,38 @@ public class LexAn implements AutoCloseable {
|
|||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
nextChar();
|
||||||
|
if (buffChar == '{') {
|
||||||
|
int depth = 1;
|
||||||
|
|
||||||
|
nextChar();
|
||||||
|
while (depth > 0) {
|
||||||
|
switch (buffChar) {
|
||||||
|
case '}':
|
||||||
|
nextChar();
|
||||||
|
if (buffChar != '/') continue;
|
||||||
|
nextChar();
|
||||||
|
if (buffChar != '/') continue;
|
||||||
|
depth--;
|
||||||
|
break;
|
||||||
|
case '/':
|
||||||
|
nextChar();
|
||||||
|
if (buffChar != '/') continue;
|
||||||
|
nextChar();
|
||||||
|
if (buffChar != '{') continue;
|
||||||
|
depth++;
|
||||||
|
break;
|
||||||
|
case -1:
|
||||||
|
throw new Report.Error(currentLocation(), "Unterminated multiline comment");
|
||||||
|
default:
|
||||||
|
nextChar();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
} else {
|
||||||
while (buffChar != '\n' && buffChar != -1) {
|
while (buffChar != '\n' && buffChar != -1) {
|
||||||
nextChar();
|
nextChar();
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
nextToken();
|
nextToken();
|
||||||
return;
|
return;
|
||||||
@@ -319,7 +348,6 @@ public class LexAn implements AutoCloseable {
|
|||||||
case "let" -> Token.Symbol.LET;
|
case "let" -> Token.Symbol.LET;
|
||||||
case "in" -> Token.Symbol.IN;
|
case "in" -> Token.Symbol.IN;
|
||||||
case "end" -> Token.Symbol.END;
|
case "end" -> Token.Symbol.END;
|
||||||
case "__LINE__" -> Token.Symbol.LINE;
|
|
||||||
default -> null;
|
default -> null;
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
@@ -452,15 +480,6 @@ public class LexAn implements AutoCloseable {
|
|||||||
symbol = Token.Symbol.IDENTIFIER;
|
symbol = Token.Symbol.IDENTIFIER;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (symbol == Token.Symbol.LINE) {
|
|
||||||
buffToken = new Token(
|
|
||||||
new Report.Location(startLocation, endLocation),
|
|
||||||
Token.Symbol.INTCONST,
|
|
||||||
Integer.toString(startLocation.begLine())
|
|
||||||
);
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
|
|
||||||
buffToken = new Token(
|
buffToken = new Token(
|
||||||
new Report.Location(startLocation, endLocation),
|
new Report.Location(startLocation, endLocation),
|
||||||
symbol,
|
symbol,
|
||||||
|
|||||||
Reference in New Issue
Block a user