Compare commits
1 Commits
comment-le
...
2025-predr
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
352085b499 |
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 | .
|
||||||
@@ -1,2 +1,5 @@
|
|||||||
//1234567890
|
// line1 --
|
||||||
//12345678901
|
line2 -----x
|
||||||
|
line3
|
||||||
|
|
||||||
|
fun main() = 0
|
||||||
@@ -246,14 +246,14 @@ 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;
|
StringBuilder builder = new StringBuilder();
|
||||||
while (buffChar != '\n' && buffChar != -1) {
|
|
||||||
length++;
|
while (buffChar != -1) {
|
||||||
if (length > 10) {
|
if (buffChar == '\n' && !builder.toString().endsWith("--")) {
|
||||||
throw new Report.Error(currentLocation(), "Comments can only be 10 characters long");
|
break;
|
||||||
}
|
}
|
||||||
|
builder.append((char) buffChar);
|
||||||
nextChar();
|
nextChar();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user