fix ast printing of & array-element

This commit is contained in:
Irmen de Jong 2024-02-08 01:17:19 +01:00
parent 3cc858db12
commit 9d6d98930b
3 changed files with 9 additions and 36 deletions

View File

@ -15,7 +15,12 @@ fun printAst(root: PtNode, skipLibraries: Boolean, output: (text: String) -> Uni
is PtAugmentedAssign -> "<inplace-assign> ${node.operator}"
is PtBreakpoint -> "%breakpoint"
is PtConditionalBranch -> "if_${node.condition.name.lowercase()}"
is PtAddressOf -> "&"
is PtAddressOf -> {
if(node.isFromArrayElement)
"& array-element"
else
"&"
}
is PtArray -> "array len=${node.children.size} ${type(node.type)}"
is PtArrayIndexer -> "<arrayindexer> ${type(node.type)} ${if(node.splitWords) "[splitwords]" else ""}"
is PtBinaryExpression -> "<expr> ${node.operator} ${type(node.type)}"

View File

@ -2,7 +2,6 @@ TODO
====
&pointervar[x] isn't the correct value
&pointervar[x] AST doesn't print correctly
@(s) where s is a str parameter, doesn't work
(after merge in boolean): move all "OperatorXinplace" from expressionGen to AssignmentGen, see if we can get rid of the Result return type.

View File

@ -6,38 +6,7 @@
main {
sub start() {
str name1 = ""
str name2 = "hello"
str name3 = " \n\rhello"
str name4 = " \x02\x02\x02\n\r\xa0\xa0\xff\xffhello"
txt.chrout('[')
txt.print(string.ltrimmed(name1))
txt.print("]\n")
txt.chrout('[')
txt.print(string.ltrimmed(name2))
txt.print("]\n")
txt.chrout('[')
txt.print(string.ltrimmed(name3))
txt.print("]\n")
txt.chrout('[')
txt.print(string.ltrimmed(name4))
txt.print("]\n\n")
txt.chrout('[')
txt.print(string.lstripped(name1))
txt.print("]\n")
txt.chrout('[')
txt.print(string.lstripped(name2))
txt.print("]\n")
txt.chrout('[')
txt.print(string.lstripped(name3))
txt.print("]\n")
txt.chrout('[')
txt.print(string.lstripped(name4))
txt.print("]\n")
; foo(name2)
foo("zzz")
}
sub foo (str s2) {
@ -46,7 +15,7 @@ main {
txt.nl()
txt.print_uwhex(&s, true)
txt.nl()
txt.print_uwhex(&s[2], true) ; TODO doesn't print correctly in the AST!
txt.print_uwhex(&s[2], true)
txt.nl()
txt.nl()
txt.print_uwhex(s2, true)
@ -55,7 +24,7 @@ main {
txt.nl()
txt.print_uwhex(s2+2, true)
txt.nl()
txt.print_uwhex(&s2[2], true) ; TODO should be the same as the previous one! TODO doesn't print correctly in the AST!
txt.print_uwhex(&s2[2], true) ; TODO should be the same as the previous one!
txt.nl()
}
}