normand.git
7 months agoRename `normand.VarsT` to `normand.SymbolsT` v0.5.0
Philippe Proulx [Fri, 29 Sep 2023 18:06:24 +0000 (14:06 -0400)] 
Rename `normand.VarsT` to `normand.SymbolsT`

This term is more general and applies to both labels and variables.

Change-Id: Iad4d72fa1cf26b934d04ebd014acf51b6881c817
Signed-off-by: Philippe Proulx <eeppeliteloop@gmail.com>
7 months agoAdd LEB128 integer support v0.4.0
Philippe Proulx [Fri, 29 Sep 2023 17:10:59 +0000 (13:10 -0400)] 
Add LEB128 integer support

This patch adds unsigned and signed LEB128 [1] integer support with the
following Normand format:

    {my_val : uleb128}
    {my_val : sleb128}

LEB128 is a popular variable-length integer encoding which has
CTF 2 [2], Android, HP, DWARF, WebAssembly, the xz format, and many more
as its users.

To avoid any confusion, the term "value" in the Normand project is
renamed to "fixed-length integer" (`README.adoc`, test names, and the
code itself).

The challenge for a LEB128 item is similar to a repetition with an
expression: you don't know the final length when parsing because it can
depend on preceding labels and variables. Therefore the repetition item
validation and handling code is reused.

The new test files with names containing `-byte` were randomly generated
using the `leb128` package, therefore Normand agrees with another LEB128
implementation.

[1]: https://en.wikipedia.org/wiki/LEB128
[2]: https://diamon.org/ctf/

Change-Id: Ieac783dcdd093e1b5c70396a12fc2b568c9885bb
Signed-off-by: Philippe Proulx <eeppeliteloop@gmail.com>
7 months agoAdd initial tests
Philippe Proulx [Wed, 27 Sep 2023 19:24:06 +0000 (15:24 -0400)] 
Add initial tests

The tests are meant to be run by pytest (just run `pytest` in the root
or `tests` directory once Normand is installed).

Each `.nt` file is a test, its prefix indicating the expectation:

`pass-`:
    Everything above the `---` line is the valid Normand input
    to test.

    Everything below the `---` line is the expected data
    (whitespace-separated hexadecimal bytes).

`fail-`:
    Everything above the `---` line is the invalid Normand input
    to test.

    Everything below the `---` line is the expected error message
    having this form:

        LINE:COL - MESSAGE

Change-Id: I65c0276f418c252735f75e583023772194b9eb4a
Signed-off-by: Philippe Proulx <eeppeliteloop@gmail.com>
7 months agoAdd variable repetition count support v0.3.0
Philippe Proulx [Thu, 28 Sep 2023 20:34:38 +0000 (16:34 -0400)] 
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>
7 months agoFix: _dict_from_arg(): actually fill the dictionary v0.2.1
Philippe Proulx [Fri, 29 Sep 2023 05:00:22 +0000 (01:00 -0400)] 
Fix: _dict_from_arg(): actually fill the dictionary

Change-Id: Ib86c8df44986eeec5b45908bce2d15c44d053d99
Signed-off-by: Philippe Proulx <eeppeliteloop@gmail.com>
7 months agonormand.py: add comment about the portable module
Philippe Proulx [Thu, 28 Sep 2023 01:02:05 +0000 (21:02 -0400)] 
normand.py: add comment about the portable module

Change-Id: I8e7792f0864bdb0c7786eabcc0a46e00122734b7
Signed-off-by: Philippe Proulx <eeppeliteloop@gmail.com>
7 months agoMake text locations of some items and errors more precise v0.2.0
Philippe Proulx [Wed, 27 Sep 2023 21:36:32 +0000 (17:36 -0400)] 
Make text locations of some items and errors more precise

Using the text location before parsing the item instead of after it
feels more natural.

Change-Id: I0390d3885bf388e1d3ac37e8520ca1894de8474b
Signed-off-by: Philippe Proulx <eeppeliteloop@gmail.com>
7 months agoFix: parse a 0-item repetition v0.1.1
Philippe Proulx [Wed, 27 Sep 2023 17:59:58 +0000 (13:59 -0400)] 
Fix: parse a 0-item repetition

Change-Id: I89d3d01db51a78a0ff543650d95486208eb91d26
Signed-off-by: Philippe Proulx <eeppeliteloop@gmail.com>
7 months agoAdd `.gitreview`
Philippe Proulx [Wed, 27 Sep 2023 16:53:15 +0000 (12:53 -0400)] 
Add `.gitreview`

Change-Id: I4e21512c102ab4d4f150fce2a789da330295f11e
Signed-off-by: Philippe Proulx <eeppeliteloop@gmail.com>
7 months agoREADME.adoc: add logo
Philippe Proulx [Wed, 27 Sep 2023 16:45:38 +0000 (12:45 -0400)] 
README.adoc: add logo

Change-Id: I039e3a475101c79699891687c7843936f2c456ff
Signed-off-by: Philippe Proulx <eeppeliteloop@gmail.com>
7 months agoREADME.adoc: remove redundant internal links
Philippe Proulx [Tue, 26 Sep 2023 22:38:10 +0000 (18:38 -0400)] 
README.adoc: remove redundant internal links

Signed-off-by: Philippe Proulx <eeppeliteloop@gmail.com>
7 months agoREADME.adoc: make it work offline too
Philippe Proulx [Tue, 26 Sep 2023 22:37:54 +0000 (18:37 -0400)] 
README.adoc: make it work offline too

Signed-off-by: Philippe Proulx <eeppeliteloop@gmail.com>
7 months agoThe earliest commit (also Normand 0.1.0) v0.1.0
Philippe Proulx [Mon, 25 Sep 2023 21:16:28 +0000 (17:16 -0400)] 
The earliest commit (also Normand 0.1.0)

Signed-off-by: Philippe Proulx <eeppeliteloop@gmail.com>
This page took 0.026286 seconds and 4 git commands to generate.