remove requirement to end subroutine with an EOL, so oneliners are now possible

main { sub start() { cx16.r0++ cx16.r1++ } }
This commit is contained in:
Irmen de Jong 2024-08-26 21:25:23 +02:00
parent bdeac74cfc
commit 2da35fec17
3 changed files with 13 additions and 3 deletions

View File

@ -1046,4 +1046,14 @@ main {
(assigns[3].value as NumericLiteral).number shouldBe 3000001.141592654
}
test("oneliner") {
val src="""
main { sub start() { cx16.r0++ cx16.r1++ } }
other { asmsub thing() { %asm {{ inx }} } }
""";
val result = compileText(VMTarget(), false, src, writeAssembly = false)!!
val st = result.compilerAst.entrypoint.statements
st.size shouldBe 2
}
})

View File

@ -11,7 +11,6 @@ Future Things and Ideas
^^^^^^^^^^^^^^^^^^^^^^^
Compiler:
- Relax newline / bracket in parser so that you can put open and close brackets on the same line or on the next line if you so wish. For example be able to write a true one liner?
- Can we support signed % (remainder) somehow?
- IR: implement missing operators in AssignmentGen (array shifts etc)
- expand the kata encoding to somehow translate normal katana to half-widths? (see comment in KatakanaEncoding)
@ -72,6 +71,7 @@ Optimizations:
STRUCTS?
--------
- declare struct *type*, or directly declare the variable itself? Problem with the latter is: you cannot easily define multiple variables of the same struct type.
- can contain only numeric types (byte,word,float) - no nested structs, no reference types (strings, arrays) inside structs
- only as a reference type (uword pointer). This removes a lot of the problems related to introducing a variable length value type.
- arrays of struct is just an array of uword pointers. Can even be @split?

View File

@ -256,7 +256,7 @@ inlineir: '%ir' EOL? INLINEASMBLOCK;
inline: 'inline';
subroutine :
'sub' identifier '(' sub_params? ')' sub_return_part? EOL? (statement_block EOL)
'sub' identifier '(' sub_params? ')' sub_return_part? EOL? (statement_block EOL?)
;
sub_return_part : '->' datatype ;
@ -271,7 +271,7 @@ statement_block :
sub_params : vardecl (',' EOL? vardecl)* ;
asmsubroutine :
inline? 'asmsub' asmsub_decl EOL? (statement_block EOL)
inline? 'asmsub' asmsub_decl EOL? (statement_block EOL?)
;
romsubroutine :