Add conditional block support v0.9.0
authorPhilippe Proulx <eeppeliteloop@gmail.com>
Mon, 2 Oct 2023 04:28:01 +0000 (00:28 -0400)
committerPhilippe Proulx <eeppeliteloop@gmail.com>
Mon, 2 Oct 2023 15:38:29 +0000 (11:38 -0400)
commit27d52a19c5248aff0194e22c86e66e526aa9e4f1
tree9e62a4218d1d543badf450643f2d2c6a8ea5958f
parente57a18e1620dc01979402c7dda30c2a44c64792f
Add conditional block support

This patch adds the `!if` directive to support conditional blocks.

A conditional block is functionally equivalent to a repetition block
when casting the expression to `bool`:

    !if {meow + mix > 32}
      # ...
    !end

    !repeat {meow + mix > 32}
      # ...
    !end

In other words, a conditional block is a repetition of its contained
items zero or one time.

The expression of a fixed-length number, an LEB128 integer, a variable
assignment, and a repetition may now evaluate to a `bool` value: Normand
converts it to `int` (0 or 1) automatically.

Change-Id: I3b686a3196d1ea8daa5741e78320c031b40abc00
Signed-off-by: Philippe Proulx <eeppeliteloop@gmail.com>
14 files changed:
README.adoc
normand/normand.py
pyproject.toml
tests/fail-rep-post-inval-count.nt
tests/pass-cond-blk-expr-label-inner.nt [new file with mode: 0644]
tests/pass-cond-blk-expr-label.nt [new file with mode: 0644]
tests/pass-cond-blk-expr-var-1.nt [new file with mode: 0644]
tests/pass-cond-blk-expr-var-2.nt [new file with mode: 0644]
tests/pass-cond-blk-icitte.nt [new file with mode: 0644]
tests/pass-cond-blk-label.nt [new file with mode: 0644]
tests/pass-cond-blk-var.nt [new file with mode: 0644]
tests/pass-readme-intro-cond.nt [new file with mode: 0644]
tests/pass-readme-learn-cond-1.nt [new file with mode: 0644]
tests/pass-readme-learn-cond-2.nt [new file with mode: 0644]
This page took 0.024454 seconds and 4 git commands to generate.