- typescript-state-machine.ts: replace TODO stub at L557-559 with real
if/else TypeScript codegen from SpeckDL ifblock AST nodes
- parser.ts: fix require-continuation loop at L1213 that was consuming
'if (...)' lines as require args; added nextLine.startsWith('if ')
to the stop conditions so ifblocks parse correctly
- examples/ConditionalToggle.speck: new test fixture exercising if/else
- compiler.test.ts: new describe block for ifblock code generation
(asserts real 'if (' + brace block + 'else', no TODO stub)
Tests: 71/71 green (53 parser + 18 compiler incl. new ifblock test).
29 lines
No EOL
424 B
Text
29 lines
No EOL
424 B
Text
speck ConditionalToggle {
|
|
|
|
state {
|
|
isOn: Bool
|
|
count: Nat
|
|
}
|
|
|
|
init {
|
|
isOn == false
|
|
count == 0
|
|
}
|
|
|
|
invariant SwitchConsistent {
|
|
isOn in {true, false}
|
|
}
|
|
|
|
action Toggle {
|
|
require true
|
|
if (isOn) {
|
|
isOn := false
|
|
} else {
|
|
isOn := true
|
|
}
|
|
count := count + 1
|
|
return isOn
|
|
}
|
|
|
|
next: Toggle
|
|
} |