This commit is contained in:
Gašper Dobrovoljc 2025-03-23 14:00:35 +01:00
parent b8545a143b
commit ffcb50c707
No known key found for this signature in database
GPG Key ID: 0E7E037018CFA5A5
5 changed files with 27 additions and 28 deletions

View File

@ -1 +1,2 @@
var
fun a() =
1 +

View File

@ -1,7 +1,5 @@
package pins25.common;
import java.util.HashMap;
/**
* Leksikalni simbol.
*
@ -152,7 +150,8 @@ public record Token(Report.Location location, Symbol symbol, String lexeme) impl
*/
RPAREN;
public String prettyPrint() {
@Override
public String toString() {
return switch (this) {
case INTCONST -> "integer constant";
case CHARCONST -> "character constant";
@ -192,7 +191,6 @@ public record Token(Report.Location location, Symbol symbol, String lexeme) impl
}
}
@Override
public String toString() {
String lexeme = switch (symbol) {

View File

@ -130,7 +130,7 @@ public class LexAn implements AutoCloseable {
Report.Location start = currentLocation();
switch (buffChar) {
case -1: // EOF
buffToken = new Token(start, Token.Symbol.EOF, null);
buffToken = new Token(start, Token.Symbol.EOF, "EOF");
return;
case '\'':

View File

@ -38,7 +38,7 @@ public class SynAn implements AutoCloseable {
private Token check(Token.Symbol symbol) {
final Token token = lexAn.takeToken();
if (token.symbol() != symbol)
throw new Report.Error(token, "Unexpected symbol '" + token.lexeme() + "', expected " + symbol.prettyPrint() + ".");
throw new Report.Error(token, "Unexpected symbol '" + token.lexeme() + "', expected " + symbol + ".");
return token;
}