Compare commits
1 Commits
line-symbo
...
times-init
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
d64e597414 |
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__)
|
|
||||||
@@ -69,6 +69,10 @@ public record Token(Report.Location location, Symbol symbol, String lexeme) impl
|
|||||||
* Kljucna beseda {@code in}.
|
* Kljucna beseda {@code in}.
|
||||||
*/
|
*/
|
||||||
IN,
|
IN,
|
||||||
|
/**
|
||||||
|
* Kljucna beseda {@code times}.
|
||||||
|
*/
|
||||||
|
TIMES,
|
||||||
/**
|
/**
|
||||||
* Kljucna beseda {@code end}.
|
* Kljucna beseda {@code end}.
|
||||||
*/
|
*/
|
||||||
@@ -148,11 +152,7 @@ public record Token(Report.Location location, Symbol symbol, String lexeme) impl
|
|||||||
/**
|
/**
|
||||||
* Simbol {@code )}.
|
* Simbol {@code )}.
|
||||||
*/
|
*/
|
||||||
RPAREN,
|
RPAREN;
|
||||||
/**
|
|
||||||
* Simbol {@code __LINE__}.
|
|
||||||
*/
|
|
||||||
LINE
|
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
|
|||||||
@@ -319,7 +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;
|
case "times" -> Token.Symbol.TIMES;
|
||||||
default -> null;
|
default -> null;
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
@@ -452,15 +452,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,
|
||||||
|
|||||||
@@ -360,9 +360,9 @@ public class SynAn implements AutoCloseable {
|
|||||||
|
|
||||||
private AST.AtomExpr parseIntegerConstantMultiplier() {
|
private AST.AtomExpr parseIntegerConstantMultiplier() {
|
||||||
Token token = lexAn.peekToken();
|
Token token = lexAn.peekToken();
|
||||||
if (token.symbol() == Token.Symbol.MUL) {
|
if (token.symbol() == Token.Symbol.TIMES) {
|
||||||
// intconstmult -> MUL const
|
// intconstmult -> TIMES const
|
||||||
check(Token.Symbol.MUL);
|
check(Token.Symbol.TIMES);
|
||||||
return parseConstant();
|
return parseConstant();
|
||||||
}
|
}
|
||||||
// intconstmult -> ε
|
// intconstmult -> ε
|
||||||
|
|||||||
Reference in New Issue
Block a user