allow labels also in blocks instead of only in subroutines

This commit is contained in:
Irmen de Jong 2021-04-18 23:03:18 +02:00
parent c70bbdab26
commit a086d6e009
4 changed files with 8 additions and 3 deletions

View File

@ -45,7 +45,8 @@ private fun prog8Parser.BlockContext.toAst(isInLibrary: Boolean, encoding: IStri
it.subroutinedeclaration()!=null -> it.subroutinedeclaration().toAst(encoding)
it.directive()!=null -> it.directive().toAst()
it.inlineasm()!=null -> it.inlineasm().toAst()
else -> throw FatalAstException("weird block statement $it")
it.labeldef()!=null -> it.labeldef().toAst()
else -> throw FatalAstException("weird block node $it")
}
}
return Block(identifier().text, integerliteral()?.toAst()?.number?.toInt(), blockstatements.toMutableList(), isInLibrary, toPosition())

View File

@ -2,8 +2,6 @@
TODO
====
- allow labels in blocks instead of only in subroutines?
- hoist all variable declarations up to the subroutine scope *before* even the constant folding takes place (to avoid undefined symbol errors when referring to a variable from another nested scope in the subroutine)
- c64: make the graphics.BITMAP_ADDRESS configurable (VIC banking)
- get rid of all other TODO's in the code ;-)

View File

@ -3,7 +3,12 @@
%import test_stack
main {
blocklabel:
sub start() {
label1:
ubyte xx=99
if 0==xx {
txt.print("fout")

View File

@ -80,6 +80,7 @@ block_statement:
| variabledeclaration
| subroutinedeclaration
| inlineasm
| labeldef
;