Compare commits
1 Commits
add-right-
...
multiline-
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
30fbde8c31 |
1
.gitignore
vendored
1
.gitignore
vendored
@@ -3,3 +3,4 @@ out/
|
||||
*.zip
|
||||
prg/**/*.ast
|
||||
prg/**/*.out
|
||||
prg/**/*.pins25
|
||||
@@ -39,9 +39,8 @@ restcmp -> EQU addexpr
|
||||
| .
|
||||
|
||||
addexpr -> multexpr restadd .
|
||||
restadd -> ADD addexpr
|
||||
| SUB addexpr
|
||||
| .
|
||||
restadd -> ADD multexpr restadd
|
||||
| SUB multexpr restadd | .
|
||||
|
||||
multexpr -> 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;
|
||||
}
|
||||
|
||||
while (buffChar != '\n' && buffChar != -1) {
|
||||
nextChar();
|
||||
if (buffChar == '{') {
|
||||
int depth = 1;
|
||||
|
||||
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();
|
||||
|
||||
@@ -540,20 +540,20 @@ public class SynAn implements AutoCloseable {
|
||||
Token token = lexAn.peekToken();
|
||||
switch (token.symbol()) {
|
||||
case ADD: {
|
||||
// restadd -> ADD addexpr
|
||||
// restadd -> ADD multexpr restadd
|
||||
check(Token.Symbol.ADD);
|
||||
AST.Expr right = parseAdditionExpression();
|
||||
AST.Expr right = parseMultiplicationExpression();
|
||||
AST.Expr binExpr = new AST.BinExpr(AST.BinExpr.Oper.ADD, left, right);
|
||||
attrLoc.put(binExpr, new Report.Location(attrLoc.get(left), attrLoc.get(right)));
|
||||
return binExpr;
|
||||
return parseRestAdditionExpressions(binExpr);
|
||||
}
|
||||
case SUB: {
|
||||
// restadd -> ADD addexpr
|
||||
// restadd -> SUB multexpr restadd
|
||||
check(Token.Symbol.SUB);
|
||||
AST.Expr right = parseAdditionExpression();
|
||||
AST.Expr right = parseMultiplicationExpression();
|
||||
AST.Expr binExpr = new AST.BinExpr(AST.BinExpr.Oper.SUB, left, right);
|
||||
attrLoc.put(binExpr, new Report.Location(attrLoc.get(left), attrLoc.get(right)));
|
||||
return binExpr;
|
||||
return parseRestAdditionExpressions(binExpr);
|
||||
}
|
||||
|
||||
default:
|
||||
|
||||
Reference in New Issue
Block a user