palfrey/maiden

while/until display as block

Closed this issue · 0 comments

Test program

validate takes code
let hasDouble be no
let char be 1
let max be 6
while char is weaker than max
let thisvalue be code at char
let thatvalue be code at char without 1
if thisvalue is weaker than thatvalue (can't use array refs here)
give back no
else
if thisvalue is thatvalue
hasDouble is yes

currently comes out as

1: FunctionDeclaration { name: "validate", args: ["code"], block: Block {
2:   Assignment { target: Variable("hasDouble"), value: False }
3:   Assignment { target: Variable("char"), value: Floating(1.0) }
4:   Assignment { target: Variable("max"), value: Floating(6.0) }
5:   While { expression: LessThan(Variable("char"), Variable("max")), block: Block { commands: [CommandLine { cmd: Assignment { target: Variable("thisvalue"), value: ArrayRef { name: Variable("code"), index: Variable("char") } }, line: 6 }, CommandLine { cmd: Assignment { target: Variable("thatvalue"), value: ArrayRef { name: Variable("code"), index: Subtract(Variable("char"), Floating(1.0)) } }, line: 7 }, CommandLine { cmd: If { expression: LessThan(Variable("thisvalue"), Variable("thatvalue")), then: Some(Block { commands: [CommandLine { cmd: Return { return_value: False }, line: 9 }] }), otherwise: Some(Block { commands: [CommandLine { cmd: If { expression: Is(Variable("thisvalue"), Variable("thatvalue")), then: Some(Block { commands: [CommandLine { cmd: Assignment { target: Variable("hasDouble"), value: True }, line: 12 }] }), otherwise: None }, line: 11 }] }) }, line: 8 }] } }
   }}