Compare commits
1 Commits
add-right-
...
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
|
||||||
@@ -39,9 +39,8 @@ restcmp -> EQU addexpr
|
|||||||
| .
|
| .
|
||||||
|
|
||||||
addexpr -> multexpr restadd .
|
addexpr -> multexpr restadd .
|
||||||
restadd -> ADD addexpr
|
restadd -> ADD multexpr restadd
|
||||||
| SUB addexpr
|
| SUB multexpr restadd | .
|
||||||
| .
|
|
||||||
|
|
||||||
multexpr -> prefixexpr restmult .
|
multexpr -> prefixexpr restmult .
|
||||||
restmult -> MUL prefixexpr restmult
|
restmult -> MUL prefixexpr restmult
|
||||||
|
|||||||
@@ -1,3 +0,0 @@
|
|||||||
|
|
||||||
fun main() =
|
|
||||||
3 - 2 - 1
|
|
||||||
@@ -247,8 +247,37 @@ public class LexAn implements AutoCloseable {
|
|||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
while (buffChar != '\n' && buffChar != -1) {
|
nextChar();
|
||||||
|
if (buffChar == '{') {
|
||||||
|
int depth = 1;
|
||||||
|
|
||||||
nextChar();
|
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) {
|
||||||
|
nextChar();
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
nextToken();
|
nextToken();
|
||||||
|
|||||||
@@ -540,20 +540,20 @@ public class SynAn implements AutoCloseable {
|
|||||||
Token token = lexAn.peekToken();
|
Token token = lexAn.peekToken();
|
||||||
switch (token.symbol()) {
|
switch (token.symbol()) {
|
||||||
case ADD: {
|
case ADD: {
|
||||||
// restadd -> ADD addexpr
|
// restadd -> ADD multexpr restadd
|
||||||
check(Token.Symbol.ADD);
|
check(Token.Symbol.ADD);
|
||||||
AST.Expr right = parseAdditionExpression();
|
AST.Expr right = parseMultiplicationExpression();
|
||||||
AST.Expr binExpr = new AST.BinExpr(AST.BinExpr.Oper.ADD, left, right);
|
AST.Expr binExpr = new AST.BinExpr(AST.BinExpr.Oper.ADD, left, right);
|
||||||
attrLoc.put(binExpr, new Report.Location(attrLoc.get(left), attrLoc.get(right)));
|
attrLoc.put(binExpr, new Report.Location(attrLoc.get(left), attrLoc.get(right)));
|
||||||
return binExpr;
|
return parseRestAdditionExpressions(binExpr);
|
||||||
}
|
}
|
||||||
case SUB: {
|
case SUB: {
|
||||||
// restadd -> ADD addexpr
|
// restadd -> SUB multexpr restadd
|
||||||
check(Token.Symbol.SUB);
|
check(Token.Symbol.SUB);
|
||||||
AST.Expr right = parseAdditionExpression();
|
AST.Expr right = parseMultiplicationExpression();
|
||||||
AST.Expr binExpr = new AST.BinExpr(AST.BinExpr.Oper.SUB, left, right);
|
AST.Expr binExpr = new AST.BinExpr(AST.BinExpr.Oper.SUB, left, right);
|
||||||
attrLoc.put(binExpr, new Report.Location(attrLoc.get(left), attrLoc.get(right)));
|
attrLoc.put(binExpr, new Report.Location(attrLoc.get(left), attrLoc.get(right)));
|
||||||
return binExpr;
|
return parseRestAdditionExpressions(binExpr);
|
||||||
}
|
}
|
||||||
|
|
||||||
default:
|
default:
|
||||||
|
|||||||
Reference in New Issue
Block a user