Compare commits
1 Commits
comment-le
...
line-symbo
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
de2522c28c |
@@ -1,2 +1,4 @@
|
|||||||
//1234567890
|
fun putint(n)
|
||||||
//12345678901
|
|
||||||
|
fun main() =
|
||||||
|
putint(__LINE__)
|
||||||
@@ -148,7 +148,11 @@ public record Token(Report.Location location, Symbol symbol, String lexeme) impl
|
|||||||
/**
|
/**
|
||||||
* Simbol {@code )}.
|
* Simbol {@code )}.
|
||||||
*/
|
*/
|
||||||
RPAREN;
|
RPAREN,
|
||||||
|
/**
|
||||||
|
* Simbol {@code __LINE__}.
|
||||||
|
*/
|
||||||
|
LINE
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
|
|||||||
@@ -246,14 +246,8 @@ public class LexAn implements AutoCloseable {
|
|||||||
buffToken = new Token(start, Token.Symbol.DIV, "/");
|
buffToken = new Token(start, Token.Symbol.DIV, "/");
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
nextChar();
|
|
||||||
|
|
||||||
int length = 0;
|
|
||||||
while (buffChar != '\n' && buffChar != -1) {
|
while (buffChar != '\n' && buffChar != -1) {
|
||||||
length++;
|
|
||||||
if (length > 10) {
|
|
||||||
throw new Report.Error(currentLocation(), "Comments can only be 10 characters long");
|
|
||||||
}
|
|
||||||
nextChar();
|
nextChar();
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -325,6 +319,7 @@ 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;
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
@@ -457,6 +452,15 @@ 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