allow comment lines inside array initializer value

This commit is contained in:
Irmen de Jong 2023-06-27 23:30:37 +02:00
parent a9f5dc036c
commit e7b631b087
4 changed files with 17 additions and 8 deletions

View File

@ -102,6 +102,8 @@ class AstToSourceTextConverter(val output: (text: String) -> Unit, val program:
DataType.ARRAY_W -> "word["
DataType.ARRAY_F -> "float["
DataType.ARRAY_BOOL -> "bool["
DataType.ARRAY_UW_SPLIT -> "@split uword["
DataType.ARRAY_W_SPLIT -> "@split word["
else -> throw IllegalArgumentException("weird dt: $dt")
}
}

View File

@ -1,6 +1,7 @@
TODO
====
- fix array expression assignment bug from Mark in the discord.
- fix double code gen with tryInplaceModifyWithRemovedRedundantCast() ? word birdX[j] += testbyte
...

View File

@ -1,13 +1,19 @@
%import textio
%zeropage basicsafe
main {
sub start() {
word[4] birdX
byte testbyte = 0
ubyte j = 0
repeat {
birdX[j] += testbyte
byte[] foo = [ 1, 2, ; this comment is ok
; but after this comment there's a syntax error
3 ]
byte bb
for bb in foo {
txt.print_b(bb)
txt.nl()
}
}
}

View File

@ -16,9 +16,9 @@ grammar Prog8ANTLR;
package prog8.parser;
}
LINECOMMENT : ('\r'? '\n' | '\r') [ \t]* COMMENT -> channel(HIDDEN);
EOL : ('\r'? '\n' | '\r' | '\n')+ ;
LINECOMMENT : EOL [ \t]* COMMENT -> channel(HIDDEN);
COMMENT : ';' ~[\r\n]* -> channel(HIDDEN) ;
EOL : ('\r'? '\n' | '\r')+ ;
WS : [ \t] -> skip ;
// WS2 : '\\' EOL -> skip;