Compare commits
1 Commits
times-init
...
2025-predr
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
352085b499 |
1
.gitignore
vendored
1
.gitignore
vendored
@@ -3,4 +3,3 @@ out/
|
|||||||
*.zip
|
*.zip
|
||||||
prg/**/*.ast
|
prg/**/*.ast
|
||||||
prg/**/*.out
|
prg/**/*.out
|
||||||
prg/**/*.pins25
|
|
||||||
26
grammar.txt
26
grammar.txt
@@ -69,4 +69,28 @@ restinits -> COMMA initializer restinits | .
|
|||||||
initializer -> INTCONST intconstmult | CHARCONST | STRINGCONST .
|
initializer -> INTCONST intconstmult | CHARCONST | STRINGCONST .
|
||||||
intconstmult -> MUL const | .
|
intconstmult -> MUL const | .
|
||||||
|
|
||||||
const -> INTCONST | CHARCONST | STRINGCONST .
|
const -> INTCONST | CHARCONST | STRINGCONST .
|
||||||
|
|
||||||
|
|
||||||
|
--------------------------------------------------------------------
|
||||||
|
|
||||||
|
//LEFT ASOC.
|
||||||
|
exp0 = exp0 op other | other
|
||||||
|
|
||||||
|
|
|
||||||
|
v
|
||||||
|
|
||||||
|
exp0 = other exp0'
|
||||||
|
exp0' = op other exp0' | .
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
//RIGHT ASOC.
|
||||||
|
exp0 = other op exp0 | other
|
||||||
|
|
||||||
|
|
|
||||||
|
v
|
||||||
|
|
||||||
|
exp0 = other exp0'
|
||||||
|
exp0' = op exp0 | .
|
||||||
5
prg/test.pins25
Normal file
5
prg/test.pins25
Normal file
@@ -0,0 +1,5 @@
|
|||||||
|
// line1 --
|
||||||
|
line2 -----x
|
||||||
|
line3
|
||||||
|
|
||||||
|
fun main() = 0
|
||||||
@@ -69,10 +69,6 @@ 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}.
|
||||||
*/
|
*/
|
||||||
|
|||||||
@@ -247,7 +247,13 @@ public class LexAn implements AutoCloseable {
|
|||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
while (buffChar != '\n' && buffChar != -1) {
|
StringBuilder builder = new StringBuilder();
|
||||||
|
|
||||||
|
while (buffChar != -1) {
|
||||||
|
if (buffChar == '\n' && !builder.toString().endsWith("--")) {
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
builder.append((char) buffChar);
|
||||||
nextChar();
|
nextChar();
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -319,7 +325,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 "times" -> Token.Symbol.TIMES;
|
|
||||||
default -> null;
|
default -> null;
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -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.TIMES) {
|
if (token.symbol() == Token.Symbol.MUL) {
|
||||||
// intconstmult -> TIMES const
|
// intconstmult -> MUL const
|
||||||
check(Token.Symbol.TIMES);
|
check(Token.Symbol.MUL);
|
||||||
return parseConstant();
|
return parseConstant();
|
||||||
}
|
}
|
||||||
// intconstmult -> ε
|
// intconstmult -> ε
|
||||||
|
|||||||
Reference in New Issue
Block a user