Add variable repetition count support v0.3.0
authorPhilippe Proulx <eeppeliteloop@gmail.com>
Thu, 28 Sep 2023 20:34:38 +0000 (16:34 -0400)
committerPhilippe Proulx <eeppeliteloop@gmail.com>
Fri, 29 Sep 2023 05:06:28 +0000 (01:06 -0400)
commit2adf43367080d327e2d30ed4120bca3098eaa156
treeec4b64433b2dd287014967b56975df937dd24cd3
parent2e1c1acd2530ee6a6989e8addc28691c92c766f8
Add variable repetition count support

This patch makes it possible to do this:

    {meow = 23}
    aa <lbl> bb (cc dd) * {9 * meow + lbl} ff

The repetition count expression cannot refer to a "future" label name,
to an inner label name, or to any variable of which the value was
computed using, directly or indirectly, one of those labels.

For example, this is invalid:

    aa
    {meow = mix}
    {zoom = meow}
    bb * {zoom}
    <mix>

However this is valid:

    aa
    {meow = mix}
    {zoom = meow}
    {meow = 23}
    bb * {meow}
    <mix>

An interesting side effect of this feature is to make Normand support
conditional sections by using zero vs. one repetition:

    (
      <beg>
      aa bb cc dd
      <end>
      {include = int(beg >= 4 * (end - beg))}
      (11 22 33 44) * {include}
    ) * 10

Result:

    aa bb cc dd aa bb cc dd  aa bb cc dd aa bb cc dd  ┆ ••••••••••••••••
    aa bb cc dd 11 22 33 44  aa bb cc dd 11 22 33 44  ┆ •••••"3D•••••"3D
    aa bb cc dd 11 22 33 44  aa bb cc dd 11 22 33 44  ┆ •••••"3D•••••"3D
    aa bb cc dd 11 22 33 44  aa bb cc dd 11 22 33 44  ┆ •••••"3D•••••"3D

This becomes interesting with externally-provided variables, for
example:

    aa bb cc dd
    (beef) * {has_beef}
    "salut"

You may include or exclude the `be ef` bytes with `--var=has_beef=1` and
`--var=has_beef=0` (or the equivalent API way).

Also update the `README.adoc` usage and examples.

Change-Id: I8cd8aa7078cbe48038b00c541aa40a067c9f79bf
Signed-off-by: Philippe Proulx <eeppeliteloop@gmail.com>
README.adoc
normand/normand.py
pyproject.toml
This page took 0.02404 seconds and 4 git commands to generate.