From ee724c95ef52bbd11d3bc89bbd1e372b0c936bae Mon Sep 17 00:00:00 2001 From: Philippe Proulx Date: Wed, 11 Oct 2023 12:39:07 -0400 Subject: [PATCH] Use only naked `{` and `}` for variable assignment This patch: * Makes a fixed-length number, an LEB128, or a string item use `[` and `]` instead of `{` and `}`. * Changes `{be}` and `{le}` to `!be` and `!le`. * Removes the `[` and `]` symbols from the insignificant symbol set (I knew this day would come). This means anything between `{` and `}` is now a valid Python 3 expression. A side effect of this patch is to also simplify the parser because when expecting an item, `{` already means a variable assignment. `README.adoc` and tests are changed accordingly. Change-Id: I071978b0eae9349b779be44843e5f8dd0a162461 Signed-off-by: Philippe Proulx Reviewed-on: https://review.lttng.org/c/normand/+/11036 Tested-by: jenkins --- README.adoc | 148 ++++++------ normand/normand.py | 250 ++++++++------------ pyproject.toml | 2 +- tests/conftest.py | 2 +- tests/fail-fl-float-inval-len.nt | 4 +- tests/fail-fl-int-32b-out-of-range-neg.nt | 4 +- tests/fail-fl-int-32b-out-of-range-pos.nt | 4 +- tests/fail-fl-int-8b-out-of-range-neg.nt | 2 +- tests/fail-fl-int-8b-out-of-range-pos.nt | 2 +- tests/fail-fl-num-empty-expr.nt | 4 +- tests/fail-fl-num-eval-type.nt | 2 +- tests/fail-fl-num-eval.nt | 2 +- tests/fail-fl-num-inval-len.nt | 2 +- tests/fail-fl-num-inval-syntax.nt | 2 +- tests/fail-fl-num-missing-bo.nt | 2 +- tests/fail-fl-num-missing-len.nt | 2 +- tests/fail-fl-num-unknown-name-1.nt | 2 +- tests/fail-fl-num-unknown-name-2.nt | 2 +- tests/fail-macro-exp-nested-1.nt | 2 +- tests/fail-macro-exp-nested-2.nt | 2 +- tests/fail-sleb128-empty-expr.nt | 4 +- tests/fail-str-post-empty-expr.nt | 4 +- tests/fail-str-post-inval-latin-enc.nt | 2 +- tests/fail-str-post-inval-utf-spec.nt | 2 +- tests/fail-str-post-missing-enc-colon.nt | 2 +- tests/fail-str-post-missing-enc.nt | 2 +- tests/fail-str-post-missing-gen-prefix.nt | 2 +- tests/fail-str-post-missing-utf-spec.nt | 2 +- tests/fail-str-pre-missing-enc.nt | 2 +- tests/fail-trans-unknown-label.nt | 2 +- tests/fail-uleb128-empty-expr.nt | 4 +- tests/fail-uleb128-eval-type-1.nt | 2 +- tests/fail-uleb128-eval-type-2.nt | 2 +- tests/fail-uleb128-eval.nt | 2 +- tests/fail-uleb128-inval-syntax.nt | 2 +- tests/fail-uleb128-unknown-name-1.nt | 2 +- tests/fail-uleb128-unknown-name-2.nt | 2 +- tests/fail-uleb128-unreachable-label-1.nt | 2 +- tests/fail-uleb128-unreachable-label-2.nt | 2 +- tests/fail-var-label-bo-none.nt | 2 +- tests/pass-bmp.nt | 18 +- tests/pass-bo.nt | 8 +- tests/pass-comment-all.nt | 18 +- tests/pass-comment-sym-bin-const.nt | 4 +- tests/pass-comment-sym-group.nt | 2 +- tests/pass-comment-sym-hex-const.nt | 6 +- tests/pass-const-int-bin.nt | 2 +- tests/pass-const-int-dec.nt | 2 +- tests/pass-const-int-hex.nt | 2 +- tests/pass-const-int-oct.nt | 2 +- tests/pass-fill-cur-offset.nt | 2 +- tests/pass-fill-name.nt | 2 +- tests/pass-fill-pad-val.nt | 4 +- tests/pass-fill.nt | 2 +- tests/pass-fl-float-32b-be.nt | 6 +- tests/pass-fl-float-32b-le.nt | 6 +- tests/pass-fl-float-64b-be.nt | 6 +- tests/pass-fl-float-64b-le.nt | 6 +- tests/pass-fl-int-16b-be.nt | 14 +- tests/pass-fl-int-16b-le.nt | 14 +- tests/pass-fl-int-24b-be.nt | 14 +- tests/pass-fl-int-24b-le.nt | 14 +- tests/pass-fl-int-32b-be.nt | 14 +- tests/pass-fl-int-32b-le.nt | 14 +- tests/pass-fl-int-40b-be.nt | 14 +- tests/pass-fl-int-40b-le.nt | 14 +- tests/pass-fl-int-48b-be.nt | 14 +- tests/pass-fl-int-48b-le.nt | 14 +- tests/pass-fl-int-56b-be.nt | 14 +- tests/pass-fl-int-56b-le.nt | 14 +- tests/pass-fl-int-64b-be.nt | 14 +- tests/pass-fl-int-64b-le.nt | 14 +- tests/pass-fl-int-8b.nt | 10 +- tests/pass-fl-int-icitte.nt | 10 +- tests/pass-group-blk-label-1.nt | 2 +- tests/pass-group-blk-label-2.nt | 4 +- tests/pass-group-blk-label-3.nt | 2 +- tests/pass-group-paren-label-1.nt | 2 +- tests/pass-group-paren-label-2.nt | 2 +- tests/pass-group-paren-label-3.nt | 2 +- tests/pass-label.nt | 6 +- tests/pass-macro-exp-final-state-bo.nt | 4 +- tests/pass-macro-exp-final-state-labels.nt | 4 +- tests/pass-macro-exp-final-state-offset.nt | 2 +- tests/pass-macro-exp-final-state-vars.nt | 4 +- tests/pass-macro-exp-fl-num.nt | 2 +- tests/pass-macro-exp-init-state-bo.nt | 6 +- tests/pass-macro-exp-init-state-offset.nt | 2 +- tests/pass-macro-exp-param-float.nt | 4 +- tests/pass-macro-exp-param-str.nt | 4 +- tests/pass-macro-exp-three-params.nt | 2 +- tests/pass-macro-exp-var.nt | 2 +- tests/pass-offset.nt | 6 +- tests/pass-readme-intro-align.nt | 10 +- tests/pass-readme-intro-fill.nt | 12 +- tests/pass-readme-intro-fl-num.nt | 6 +- tests/pass-readme-intro-leb128.nt | 4 +- tests/pass-readme-learn-align-2.nt | 4 +- tests/pass-readme-learn-const-1.nt | 2 +- tests/pass-readme-learn-fill-2.nt | 2 +- tests/pass-readme-learn-fl-num-1.nt | 4 +- tests/pass-readme-learn-fl-num-2.nt | 4 +- tests/pass-readme-learn-fl-num-3.nt | 2 +- tests/pass-readme-learn-fl-num-4.nt | 4 +- tests/pass-readme-learn-group-3.nt | 6 +- tests/pass-readme-learn-leb128-1.nt | 2 +- tests/pass-readme-learn-leb128-2.nt | 2 +- tests/pass-readme-learn-macro-def-1.nt | 2 +- tests/pass-readme-learn-macro-def-2.nt | 4 +- tests/pass-readme-learn-macro-exp-1.nt | 2 +- tests/pass-readme-learn-macro-exp-2.nt | 6 +- tests/pass-readme-learn-macro-exp-3.nt | 2 +- tests/pass-readme-learn-offset-1.nt | 4 +- tests/pass-readme-learn-offset-2.nt | 2 +- tests/pass-readme-learn-rep-blk-1.nt | 2 +- tests/pass-readme-learn-rep-blk-3-cond-0.nt | 2 +- tests/pass-readme-learn-rep-blk-3-cond-1.nt | 2 +- tests/pass-readme-learn-rep-post-1.nt | 2 +- tests/pass-readme-learn-str-1.nt | 2 +- tests/pass-readme-learn-str-2.nt | 2 +- tests/pass-readme-learn-trans.nt | 2 +- tests/pass-readme-learn-var.nt | 6 +- tests/pass-rep-blk-all-bytes.nt | 2 +- tests/pass-rep-post-all-bytes.nt | 2 +- tests/pass-sleb128-1-byte.nt | 2 +- tests/pass-sleb128-10-bytes.nt | 2 +- tests/pass-sleb128-2-bytes.nt | 2 +- tests/pass-sleb128-3-bytes.nt | 2 +- tests/pass-sleb128-4-bytes.nt | 2 +- tests/pass-sleb128-5-bytes.nt | 2 +- tests/pass-sleb128-6-bytes.nt | 2 +- tests/pass-sleb128-7-bytes.nt | 2 +- tests/pass-sleb128-8-bytes.nt | 2 +- tests/pass-sleb128-9-bytes.nt | 2 +- tests/pass-sleb128-limits.nt | 8 +- tests/pass-sleb128-minus-one.nt | 2 +- tests/pass-sleb128-zero.nt | 2 +- tests/pass-str-post-bool.nt | 4 +- tests/pass-str-post-expr-lower.nt | 4 +- tests/pass-str-post-latin.nt | 20 +- tests/pass-str-post-utf.nt | 10 +- tests/pass-str-pre-float.nt | 2 +- tests/pass-str-pre-int.nt | 2 +- tests/pass-trans-a85.nt | 4 +- tests/pass-trans-a85p.nt | 4 +- tests/pass-trans-b16.nt | 4 +- tests/pass-trans-b32.nt | 4 +- tests/pass-trans-b64.nt | 4 +- tests/pass-trans-b64u.nt | 4 +- tests/pass-trans-b85.nt | 4 +- tests/pass-trans-b85p.nt | 4 +- tests/pass-trans-qp.nt | 4 +- tests/pass-trans-qpt.nt | 4 +- tests/pass-uleb128-1-byte.nt | 2 +- tests/pass-uleb128-10-bytes.nt | 2 +- tests/pass-uleb128-2-bytes.nt | 2 +- tests/pass-uleb128-3-bytes.nt | 2 +- tests/pass-uleb128-4-bytes.nt | 2 +- tests/pass-uleb128-5-bytes.nt | 2 +- tests/pass-uleb128-6-bytes.nt | 2 +- tests/pass-uleb128-7-bytes.nt | 2 +- tests/pass-uleb128-8-bytes.nt | 2 +- tests/pass-uleb128-9-bytes.nt | 2 +- tests/pass-uleb128-expr-label-inner.nt | 2 +- tests/pass-uleb128-expr-label.nt | 2 +- tests/pass-uleb128-expr-var.nt | 2 +- tests/pass-uleb128-limits.nt | 4 +- tests/pass-uleb128-zero.nt | 2 +- tests/pass-var-float.nt | 2 +- tests/pass-var-icitte.nt | 2 +- tests/pass-var-label.nt | 4 +- tests/pass-var.nt | 6 +- tests/test_api.py | 14 +- 173 files changed, 545 insertions(+), 603 deletions(-) diff --git a/README.adoc b/README.adoc index 7469654..8558237 100644 --- a/README.adoc +++ b/README.adoc @@ -29,7 +29,7 @@ _**Normand**_ is a text-to-binary processor with its own language. This package offers both a portable {py3} module and a command-line tool. -WARNING: This version of Normand is 0.21, meaning both the Normand +WARNING: This version of Normand is 0.22, meaning both the Normand language and the module/CLI interface aren't stable. ifdef::env-github[] @@ -141,9 +141,9 @@ Input: + ---- {strength = 4} -{be} 67 44 $178 {(end - lbl) * 8 + strength : 16} $99 -{le} {-1993 : 32} -{-3.141593 : 64} +!be 67 44 $178 [(end - lbl) * 8 + strength : 16] $99 +!le [-1993 : 32] +[-3.141593 : 64] ---- + Output: @@ -161,8 +161,8 @@ https://en.wikipedia.org/wiki/LEB128[LEB128] integer:: Input: + ---- -aa bb cc {-1993 : sleb128} dd ee ff -{meow * 199 : uleb128} +aa bb cc [-1993 : sleb128] dd ee ff +[meow * 199 : uleb128] ---- + Output: @@ -230,12 +230,12 @@ Alignment:: Input: + ---- -{be} +!be - {199:32} -@64 {43:64} -@16 {-123:16} -@32~255 {5584:32} + [199:32] +@64 [43:64] +@16 [-123:16] +@32~255 [5584:32] ---- + Output: @@ -250,15 +250,15 @@ Filling:: Input: + ---- -{le} -{0xdeadbeef:32} -{-1993:16} -{9:16} +!le +[0xdeadbeef:32] +[-1993:16] +[9:16] +0x40 -{ICITTE:8} +[ICITTE:8] "meow mix" +200~FFh -{ICITTE:8} +[ICITTE:8] ---- + Output: @@ -284,7 +284,7 @@ Transformation:: Input: + ---- -"end of file @ " {end:8} +"end of file @ " [end:8] !transform gzip "this part will be gzipped" @@ -436,14 +436,14 @@ equivalent, for example: ---- ff dd 01 ab $192 $-128 %1101:0011 -{end:8} +[end:8] {iter = 1} !if {not something} # five times because xyz !repeat 5 - "hello world " {iter:8} + "hello world " [iter:8] {iter = iter + 1} !end !end @@ -591,7 +591,7 @@ comments around and between items, as well as between hexadecimal nibbles and binary bits of <>: ---- -/ \ ? & : ; . , [ ] _ = | - +& , - . / : ; = ? \ _ | ---- The latter serve to improve readability so that you may write, for @@ -625,6 +625,8 @@ Binary:: * The `0b` or `0B` prefix followed with one or more bits (`0` or `1`). * One or more bits followed with the `b` or `B` suffix. +In general, anything between `pass:[{]` and `}` is a {py3} expression. + You can test the examples of this section with the `normand` <> as such: @@ -660,7 +662,7 @@ The number of `%` characters is the number of subsequent expected bytes. Input: ---- -ab cd [3d 8F] CC +ab cd (3d 8F) CC ---- Output: @@ -884,8 +886,8 @@ This special item sets the <>. The two accepted forms are: [horizontal] -``pass:[{be}]``:: Set the current byte order to big endian. -``pass:[{le}]``:: Set the current byte order to little endian. +`!be`:: Set the current byte order to big endian. +`!le`:: Set the current byte order to little endian. === Fixed-length number @@ -906,7 +908,7 @@ The value is the result of evaluating a {py3} expression using the A fixed-length number is: -. The ``pass:[{]`` prefix. +. The `[` prefix. . A valid {py3} expression. + @@ -934,14 +936,14 @@ The expression evaluates to a `float` value:: `32` and `64`. -- -. The `}` suffix. +. The `]` suffix. ==== Input: ---- -{le} {345:16} -{be} {-0xabcd:32} +!le [345:16] +!be [-0xabcd:32] ---- Output: @@ -955,10 +957,10 @@ Output: Input: ---- -{be} +!be # String length in bits -{8 * (str_end - str_beg) : 16} +[8 * (str_end - str_beg) : 16] # String @@ -977,7 +979,7 @@ Output: Input: ---- -{20 - ICITTE : 8} * 10 +[20 - ICITTE : 8] * 10 ---- Output: @@ -991,8 +993,8 @@ Output: Input: ---- -{le} -{2 * 0.0529 : 32} +!le +[2 * 0.0529 : 32] ---- Output: @@ -1011,7 +1013,7 @@ format. An LEB128 integer is: -. The ``pass:[{]`` prefix. +. The `[` prefix. . A valid {py3} expression of which the evaluation result type is `int` or `bool` (automatically converted to `int`). @@ -1039,13 +1041,13 @@ is the <> (before encoding the integer). `sleb128`:: Use the signed LEB128 format. -- -. The `}` suffix. +. The `]` suffix. ==== Input: ---- -{624485 : uleb128} +[624485 : uleb128] ---- Output: @@ -1062,7 +1064,7 @@ Input: aa bb cc dd ee ff -{-981238311 + (meow * -23) : sleb128} +[-981238311 + (meow * -23) : sleb128] "hello" ---- @@ -1161,7 +1163,7 @@ is the <> (before encoding the string). Encoding suffix form:: {empty} + -. The ``pass:[{]`` prefix. +. The `[` prefix. . A valid {py3} expression of which the evaluation result type is `bool`, `int`, `float`, or `str` (the first three automatically @@ -1232,7 +1234,7 @@ is the <> (before encoding the string). ISO/IEC 8859-16. -- -. The `}` suffix. +. The `]` suffix. ==== Input: @@ -1241,7 +1243,7 @@ Input: {iter = 1} !repeat 10 - {iter : s:u8} " " + u8{iter} " " {iter = iter + 1} !end ---- @@ -1259,7 +1261,7 @@ Input: ---- {meow = 'salut jérémie'} -{meow.upper() : s:latin1} +[meow.upper() : s:latin1] ---- Output: @@ -1286,8 +1288,8 @@ A current offset setting is: Input: ---- - {ICITTE : 8} * 8 -<0x61> {ICITTE : 8} * 8 + [ICITTE : 8] * 8 +<0x61> [ICITTE : 8] * 8 ---- Output: @@ -1303,7 +1305,7 @@ Input: ---- aa bb cc dd ee ff <12> 11 22 33 44 55 -{meow : 8} {mix : 8} +[meow : 8] [mix : 8] ---- Output: @@ -1360,9 +1362,9 @@ Output: Input: ---- -{le} +!le 77 88 -@32~0xcc {-893.5:32} +@32~0xcc [-893.5:32] @128~0x55 "meow" ---- @@ -1404,7 +1406,7 @@ A filling is: ** The ``pass:[{]`` prefix, a valid {py3} expression of which the evaluation result type is `int` or `bool` (automatically converted to - `int`), and the ``pass:[}]`` suffix. + `int`), and the `}` suffix. + For a filling at some source location{nbsp}__**L**__, this expression may contain: @@ -1423,7 +1425,7 @@ repeat). ** A valid {py3} name. + For the name `__NAME__`, this is equivalent to the -`pass:[{]__NAME__pass:[}]` form above. +`pass:[{]__NAME__}` form above. + This value must be greater than or equal to the current offset where @@ -1464,7 +1466,7 @@ Input: ---- !macro part(iter, fill) - <0> "particular security " {ord('0') + iter : 8} +fill~0x80 + <0> "particular security " [ord('0') + iter : 8] +fill~0x80 !end {iter = 1} @@ -1547,9 +1549,9 @@ is the <>. Input: ---- -{mix = 101} {le} -{meow = 42} 11 22 {meow:8} 33 {meow = ICITTE + 17} -"yooo" {meow + mix : 16} +{mix = 101} !le +{meow = 42} 11 22 [meow:8] 33 {meow = ICITTE + 17} +"yooo" [meow + mix : 16] ---- Output: @@ -1622,11 +1624,11 @@ bb cc aa bb cc dd ee Input: ---- -{be} +!be ( u16le"sébastien diaz" - {ICITTE - str_beg : 8} - {(end - str_beg) * 5 : 24} + [ICITTE - str_beg : 8] + [(end - str_beg) * 5 : 24] ) * 3 ---- @@ -1657,7 +1659,7 @@ A conditional block is: ** The ``pass:[{]`` prefix, a valid {py3} expression of which the evaluation result type is `int` or `bool` (automatically converted to - `int`), and the ``pass:[}]`` suffix. + `int`), and the `}` suffix. + For a conditional block at some source location{nbsp}__**L**__, this expression may contain: @@ -1676,7 +1678,7 @@ items). ** A valid {py3} name. + For the name `__NAME__`, this is equivalent to the -`pass:[{]__NAME__pass:[}]` form above. +`pass:[{]__NAME__}` form above. . Zero or more items to be handled when the condition is true except, recursively, a macro definition block. @@ -1760,7 +1762,7 @@ A repetition block is: ** The ``pass:[{]`` prefix, a valid {py3} expression of which the evaluation result type is `int` or `bool` (automatically converted to - `int`), and the ``pass:[}]`` suffix. + `int`), and the `}` suffix. + For a repetition block at some source location{nbsp}__**L**__, this expression may contain: @@ -1779,7 +1781,7 @@ repeat). ** A valid {py3} name. + For the name `__NAME__`, this is equivalent to the -`pass:[{]__NAME__pass:[}]` form above. +`pass:[{]__NAME__}` form above. . Zero or more items except, recursively, a macro definition block. @@ -1794,7 +1796,7 @@ Input: ---- !repeat 0o400 - {end - ICITTE - 1 : 8} + [end - ICITTE - 1 : 8] !end @@ -1958,7 +1960,7 @@ Input: ---- aa bb cc dd -"size of compressed section: " {end - start : 8} +"size of compressed section: " [end - start : 8] @@ -2001,7 +2003,7 @@ Input: @128~99h -!t qp {ICITTE - beg : 8} * 50 !end +!t qp [ICITTE - beg : 8] * 50 !end ---- Output: @@ -2070,7 +2072,7 @@ A macro definition is: ==== ---- !macro bake() - {le} {ICITTE * 8 : 16} + !le [ICITTE * 8 : 16] u16le"predict explode" !end ---- @@ -2082,8 +2084,8 @@ A macro definition is: {iter = 1} !repeat rep - {val + iter : uleb128} - {0xdeadbeef : 32} + [val + iter : uleb128] + [0xdeadbeef : 32] {iter = iter + 1} !end @@ -2156,7 +2158,7 @@ A parameter value is one of: * The ``pass:[{]`` prefix, a valid {py3} expression of which the evaluation result type is `int` or `bool` (automatically converted to - `int`), and the ``pass:[}]`` suffix. + `int`), and the `}` suffix. + For a macro expansion at some source location{nbsp}__**L**__, this expression may contain: @@ -2184,7 +2186,7 @@ Input: ---- !macro bake() - {le} {ICITTE * 8 : 16} + !le [ICITTE * 8 : 16] u16le"predict explode" !end @@ -2217,13 +2219,13 @@ Input: ---- !macro A(val, is_be) - {le} + !le !if is_be - {be} + !be !end - {val : 16} + [val : 16] !end !macro B(rep, is_be) @@ -2250,7 +2252,7 @@ Output: Input: ---- -!macro flt32be(val) {be} {val : 32} !end +!macro flt32be(val) !be [val : 32] !end "CHEETOS" m:flt32be(-42.17) @@ -2291,7 +2293,7 @@ A post-item repetition is: ** The ``pass:[{]`` prefix, a valid {py3} expression of which the evaluation result type is `int` or `bool` (automatically converted to - `int`), and the ``pass:[}]`` suffix. + `int`), and the `}` suffix. + For a post-item repetition at some source location{nbsp}__**L**__, this expression may contain: @@ -2322,7 +2324,7 @@ You may also use a <>. The form Input: ---- -{end - ICITTE - 1 : 8} * 0x100 +[end - ICITTE - 1 : 8] * 0x100 ---- Output: diff --git a/normand/normand.py b/normand/normand.py index 8e1acf2..49188b4 100644 --- a/normand/normand.py +++ b/normand/normand.py @@ -30,7 +30,7 @@ # Upstream repository: . __author__ = "Philippe Proulx" -__version__ = "0.21.0" +__version__ = "0.22.0" __all__ = [ "__author__", "__version__", @@ -716,6 +716,21 @@ class _Parser: self._label_names = set(labels.keys()) self._var_names = set(variables.keys()) self._macro_defs = {} # type: _MacroDefsT + self._base_item_parse_funcs = [ + self._try_parse_byte, + self._try_parse_str, + self._try_parse_val, + self._try_parse_var_assign, + self._try_parse_set_bo, + self._try_parse_label_or_set_offset, + self._try_parse_align_offset, + self._try_parse_fill_until, + self._try_parse_group, + self._try_parse_rep_block, + self._try_parse_cond_block, + self._try_parse_macro_exp, + self._try_parse_trans_block, + ] self._parse() # Result (main group). @@ -795,7 +810,7 @@ class _Parser: _comment_pat = re.compile(r"#[^#]*?(?:$|#)", re.M) _ws_or_comments_pat = re.compile(r"(?:\s|{})*".format(_comment_pat.pattern), re.M) _ws_or_syms_or_comments_pat = re.compile( - r"(?:[\s/\\?&:;.,[\]_=|-]|{})*".format(_comment_pat.pattern), re.M + r"(?:[\s/\\?&:;.,_=|-]|{})*".format(_comment_pat.pattern), re.M ) # Skips as many whitespaces and comments as possible, but not @@ -1141,94 +1156,113 @@ class _Parser: return expr_str, expr # Patterns for _try_parse_val() - _val_expr_pat = re.compile(r"([^}:]+):\s*") + _val_prefix_pat = re.compile(r"\[") + _val_expr_pat = re.compile(r"([^\]:]+):") _fl_num_len_fmt_pat = re.compile(r"8|16|24|32|40|48|56|64") _leb128_int_fmt_pat = re.compile(r"(u|s)leb128") + _val_suffix_pat = re.compile(r"]") # Tries to parse a value (number or string) and format (fixed length # in bits, `uleb128`, `sleb128`, or `s:` followed with an encoding # name), returning an item on success. def _try_parse_val(self): - begin_text_loc = self._text_loc - - # Match - m_expr = self._try_parse_pat(self._val_expr_pat) - - if m_expr is None: + # Match prefix + if self._try_parse_pat(self._val_prefix_pat) is None: # No match return + # Expect expression and `:` + self._skip_ws_and_comments() + expr_text_loc = self._text_loc + m = self._expect_pat(self._val_expr_pat, "Expecting an expression") + # Create an expression node from the expression string - expr_str, expr = self._ast_expr_from_str(m_expr.group(1), begin_text_loc) + expr_str, expr = self._ast_expr_from_str(m.group(1), expr_text_loc) # Fixed length? self._skip_ws_and_comments() m_fmt = self._try_parse_pat(self._fl_num_len_fmt_pat) - if m_fmt is None: + if m_fmt is not None: + # Create fixed-length number item + item = _FlNum( + expr_str, + expr, + int(m_fmt.group(0)), + expr_text_loc, + ) + else: # LEB128? m_fmt = self._try_parse_pat(self._leb128_int_fmt_pat) - if m_fmt is None: + if m_fmt is not None: + # Create LEB128 integer item + cls = _ULeb128Int if m_fmt.group(1) == "u" else _SLeb128Int + item = cls(expr_str, expr, expr_text_loc) + else: # String encoding? codec = self._try_parse_str_encoding(True) - if codec is None: + if codec is not None: + # Create string item + item = _Str(expr_str, expr, codec, expr_text_loc) + else: # At this point it's invalid self._raise_error( "Expecting a fixed length (multiple of eight bits), `uleb128`, `sleb128`, or `s:` followed with a valid encoding (`u8`, `u16be`, `u16le`, `u32be`, `u32le`, or `latin1` to `latin10`)" ) - else: - # Return string item - return _Str(expr_str, expr, codec, begin_text_loc) - # Return LEB128 integer item - cls = _ULeb128Int if m_fmt.group(1) == "u" else _SLeb128Int - return cls(expr_str, expr, begin_text_loc) - else: - # Return fixed-length number item - return _FlNum( - expr_str, - expr, - int(m_fmt.group(0)), - begin_text_loc, - ) + # Expect `]` + self._skip_ws_and_comments() + m = self._expect_pat(self._val_suffix_pat, "Expecting `]`") + + # Return item + return item # Patterns for _try_parse_var_assign() - _var_assign_name_equal_pat = re.compile( - r"({})\s*=(?!=)".format(_py_name_pat.pattern) - ) + _var_assign_prefix_pat = re.compile(r"\{") + _var_assign_equal_pat = re.compile(r"=") _var_assign_expr_pat = re.compile(r"[^}]+") + _var_assign_suffix_pat = re.compile(r"\}") # Tries to parse a variable assignment, returning a variable # assignment item on success. def _try_parse_var_assign(self): - begin_text_loc = self._text_loc - - # Match - m = self._try_parse_pat(self._var_assign_name_equal_pat) - - if m is None: + # Match prefix + if self._try_parse_pat(self._var_assign_prefix_pat) is None: # No match return - # Validate name - name = m.group(1) + # Expect a name + self._skip_ws_and_comments() + name_text_loc = self._text_loc + m = self._expect_pat(_py_name_pat, "Expecting a valid Python name") + name = m.group(0) + # Expect `=` + self._skip_ws_and_comments() + self._expect_pat(self._var_assign_equal_pat, "Expecting `=`") + + # Expect expression + self._skip_ws_and_comments() + expr_text_loc = self._text_loc + m_expr = self._expect_pat(self._var_assign_expr_pat, "Expecting an expression") + + # Expect `}` + self._skip_ws_and_comments() + self._expect_pat(self._var_assign_suffix_pat, "Expecting `}`") + + # Validate name if name == _icitte_name: _raise_error( - "`{}` is a reserved variable name".format(_icitte_name), begin_text_loc + "`{}` is a reserved variable name".format(_icitte_name), name_text_loc ) if name in self._label_names: - _raise_error("Existing label named `{}`".format(name), begin_text_loc) - - # Expect an expression - self._skip_ws_and_comments() - m = self._expect_pat(self._var_assign_expr_pat, "Expecting an expression") + _raise_error("Existing label named `{}`".format(name), name_text_loc) # Create an expression node from the expression string - expr_str, expr = self._ast_expr_from_str(m.group(0), begin_text_loc) + expr_str, expr = self._ast_expr_from_str(m_expr.group(0), expr_text_loc) # Add to known variable names self._var_names.add(name) @@ -1238,66 +1272,32 @@ class _Parser: name, expr_str, expr, - begin_text_loc, + name_text_loc, ) # Pattern for _try_parse_set_bo() - _bo_pat = re.compile(r"[bl]e") + _set_bo_pat = re.compile(r"!([bl]e)\b") - # Tries to parse a byte order name, returning a byte order setting - # item on success. + # Tries to parse a byte order setting, returning a byte order + # setting item on success. def _try_parse_set_bo(self): begin_text_loc = self._text_loc # Match - m = self._try_parse_pat(self._bo_pat) + m = self._try_parse_pat(self._set_bo_pat) if m is None: # No match return # Return corresponding item - if m.group(0) == "be": - return _SetBo(ByteOrder.BE, begin_text_loc) + if m.group(1) == "be": + bo = ByteOrder.BE else: - assert m.group(0) == "le" - return _SetBo(ByteOrder.LE, begin_text_loc) - - # Patterns for _try_parse_val_or_bo() - _val_var_assign_set_bo_prefix_pat = re.compile(r"\{") - _val_var_assign_set_bo_suffix_pat = re.compile(r"\}") - - # Tries to parse a value, a variable assignment, or a byte order - # setting, returning an item on success. - def _try_parse_val_or_var_assign_or_set_bo(self): - # Match prefix - if self._try_parse_pat(self._val_var_assign_set_bo_prefix_pat) is None: - # No match - return - - self._skip_ws_and_comments() - - # Variable assignment item? - item = self._try_parse_var_assign() - - if item is None: - # Value item? - item = self._try_parse_val() - - if item is None: - # Byte order setting item? - item = self._try_parse_set_bo() - - if item is None: - # At this point it's invalid - self._raise_error( - "Expecting a fixed-length number, a string, a variable assignment, or a byte order setting" - ) + assert m.group(1) == "le" + bo = ByteOrder.LE - # Expect suffix - self._skip_ws_and_comments() - self._expect_pat(self._val_var_assign_set_bo_suffix_pat, "Expecting `}`") - return item + return _SetBo(bo, begin_text_loc) # Tries to parse an offset setting value (after the initial `<`), # returning an offset item on success. @@ -1894,74 +1894,14 @@ class _Parser: # Return item return _MacroExp(name, params, begin_text_loc) - # Tries to parse a base item (anything except a repetition), - # returning it on success. + # Tries to parse a base item (anything except a post-item + # repetition), returning it on success. def _try_parse_base_item(self): - # Byte item? - item = self._try_parse_byte() + for func in self._base_item_parse_funcs: + item = func() - if item is not None: - return item - - # String item? - item = self._try_parse_str() - - if item is not None: - return item - - # Value, variable assignment, or byte order setting item? - item = self._try_parse_val_or_var_assign_or_set_bo() - - if item is not None: - return item - - # Label or offset setting item? - item = self._try_parse_label_or_set_offset() - - if item is not None: - return item - - # Offset alignment item? - item = self._try_parse_align_offset() - - if item is not None: - return item - - # Filling item? - item = self._try_parse_fill_until() - - if item is not None: - return item - - # Group item? - item = self._try_parse_group() - - if item is not None: - return item - - # Repetition block item? - item = self._try_parse_rep_block() - - if item is not None: - return item - - # Conditional block item? - item = self._try_parse_cond_block() - - if item is not None: - return item - - # Macro expansion item? - item = self._try_parse_macro_exp() - - if item is not None: - return item - - # Transformation block item? - item = self._try_parse_trans_block() - - if item is not None: - return item + if item is not None: + return item # Pattern for _try_parse_rep_post() _rep_post_prefix_pat = re.compile(r"\*") diff --git a/pyproject.toml b/pyproject.toml index 1b76630..15bbed3 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -23,7 +23,7 @@ [tool.poetry] name = 'normand' -version = '0.21.0' +version = '0.22.0' description = 'Text-to-binary processor with its own language' license = 'MIT' authors = ['Philippe Proulx '] diff --git a/tests/conftest.py b/tests/conftest.py index 0c90e2a..3368d33 100644 --- a/tests/conftest.py +++ b/tests/conftest.py @@ -77,7 +77,7 @@ class _NormandTestItemFail(_NormandTestItem): normand.parse(normand_text) exc = exc_info.value - expected_msg = '' + expected_msg = "" for msg in reversed(exc.messages): expected_msg += "{}:{} - {}\n".format( diff --git a/tests/fail-fl-float-inval-len.nt b/tests/fail-fl-float-inval-len.nt index bc02979..224d443 100644 --- a/tests/fail-fl-float-inval-len.nt +++ b/tests/fail-fl-float-inval-len.nt @@ -1,4 +1,4 @@ -{be} -{ 18.49 : 16 } +!be +[ 18.49 : 16 ] --- 2:3 - Invalid 16-bit length for a fixed-length floating point number (value 18.49) diff --git a/tests/fail-fl-int-32b-out-of-range-neg.nt b/tests/fail-fl-int-32b-out-of-range-neg.nt index 4e8cb1b..69a0cb8 100644 --- a/tests/fail-fl-int-32b-out-of-range-neg.nt +++ b/tests/fail-fl-int-32b-out-of-range-neg.nt @@ -1,5 +1,5 @@ aa bb -{be} -{ -(2**31) - 1 : 32 } +!be +[ -(2**31) - 1 : 32 ] --- 3:3 - Value -2,147,483,649 is outside the 32-bit range when evaluating expression `-(2**31) - 1` diff --git a/tests/fail-fl-int-32b-out-of-range-pos.nt b/tests/fail-fl-int-32b-out-of-range-pos.nt index c00b600..eb0c267 100644 --- a/tests/fail-fl-int-32b-out-of-range-pos.nt +++ b/tests/fail-fl-int-32b-out-of-range-pos.nt @@ -1,5 +1,5 @@ -{be} +!be "yoyo" -{ 2**32 : 32 } +[ 2**32 : 32 ] --- 3:3 - Value 4,294,967,296 is outside the 32-bit range when evaluating expression `2**32` diff --git a/tests/fail-fl-int-8b-out-of-range-neg.nt b/tests/fail-fl-int-8b-out-of-range-neg.nt index 91f32f8..6d2f52d 100644 --- a/tests/fail-fl-int-8b-out-of-range-neg.nt +++ b/tests/fail-fl-int-8b-out-of-range-neg.nt @@ -1,3 +1,3 @@ -{ -129 : 8 } +[ -129 : 8 ] --- 1:3 - Value -129 is outside the 8-bit range when evaluating expression `-129` diff --git a/tests/fail-fl-int-8b-out-of-range-pos.nt b/tests/fail-fl-int-8b-out-of-range-pos.nt index fe946af..518164e 100644 --- a/tests/fail-fl-int-8b-out-of-range-pos.nt +++ b/tests/fail-fl-int-8b-out-of-range-pos.nt @@ -1,3 +1,3 @@ -{ 256 : 8 } +[ 256 : 8 ] --- 1:3 - Value 256 is outside the 8-bit range when evaluating expression `256` diff --git a/tests/fail-fl-num-empty-expr.nt b/tests/fail-fl-num-empty-expr.nt index 378a896..7177e25 100644 --- a/tests/fail-fl-num-empty-expr.nt +++ b/tests/fail-fl-num-empty-expr.nt @@ -1,3 +1,3 @@ -{ : 8 } +[ : 8 ] --- -1:3 - Expecting a fixed-length number, a string, a variable assignment, or a byte order setting +1:3 - Expecting an expression diff --git a/tests/fail-fl-num-eval-type.nt b/tests/fail-fl-num-eval-type.nt index 96b6aa2..ab4595a 100644 --- a/tests/fail-fl-num-eval-type.nt +++ b/tests/fail-fl-num-eval-type.nt @@ -1,3 +1,3 @@ -{ 'salut' : 8 } +[ 'salut' : 8 ] --- 1:3 - Invalid expression `'salut'`: expecting result type `float` or `int`, not `str` diff --git a/tests/fail-fl-num-eval.nt b/tests/fail-fl-num-eval.nt index 8f503e3..cb41201 100644 --- a/tests/fail-fl-num-eval.nt +++ b/tests/fail-fl-num-eval.nt @@ -1,3 +1,3 @@ -{ 23 + zoom(14) : 8 } +[ 23 + zoom(14) : 8 ] --- 1:3 - Failed to evaluate expression `23 + zoom(14)`: name 'zoom' is not defined diff --git a/tests/fail-fl-num-inval-len.nt b/tests/fail-fl-num-inval-len.nt index 79d465b..0b42cda 100644 --- a/tests/fail-fl-num-inval-len.nt +++ b/tests/fail-fl-num-inval-len.nt @@ -1,3 +1,3 @@ -{ 23 : 17 } +[ 23 : 17 ] --- 1:8 - Expecting a fixed length (multiple of eight bits), `uleb128`, `sleb128`, or `s:` followed with a valid encoding (`u8`, `u16be`, `u16le`, `u32be`, `u32le`, or `latin1` to `latin10`) diff --git a/tests/fail-fl-num-inval-syntax.nt b/tests/fail-fl-num-inval-syntax.nt index a4d8af2..6c77df6 100644 --- a/tests/fail-fl-num-inval-syntax.nt +++ b/tests/fail-fl-num-inval-syntax.nt @@ -1,3 +1,3 @@ -{ 19 + / 23 : 8 } +[ 19 + / 23 : 8 ] --- 1:3 - Invalid expression `19 + / 23`: invalid syntax diff --git a/tests/fail-fl-num-missing-bo.nt b/tests/fail-fl-num-missing-bo.nt index 3721baf..865843d 100644 --- a/tests/fail-fl-num-missing-bo.nt +++ b/tests/fail-fl-num-missing-bo.nt @@ -1,3 +1,3 @@ -{ 34 : 16 } +[ 34 : 16 ] --- 1:3 - Current byte order isn't defined at first fixed-length number (`34`) to encode on more than 8 bits diff --git a/tests/fail-fl-num-missing-len.nt b/tests/fail-fl-num-missing-len.nt index 000e873..e70f99e 100644 --- a/tests/fail-fl-num-missing-len.nt +++ b/tests/fail-fl-num-missing-len.nt @@ -1,3 +1,3 @@ -{ 23 : } +[ 23 : ] --- 1:9 - Expecting a fixed length (multiple of eight bits), `uleb128`, `sleb128`, or `s:` followed with a valid encoding (`u8`, `u16be`, `u16le`, `u32be`, `u32le`, or `latin1` to `latin10`) diff --git a/tests/fail-fl-num-unknown-name-1.nt b/tests/fail-fl-num-unknown-name-1.nt index 2663bf0..692b5b4 100644 --- a/tests/fail-fl-num-unknown-name-1.nt +++ b/tests/fail-fl-num-unknown-name-1.nt @@ -1,3 +1,3 @@ -{ meow : 8 } +[ meow : 8 ] --- 1:3 - Illegal (unknown or unreachable) variable/label name `meow` in expression `meow`; the legal names are {`ICITTE`} diff --git a/tests/fail-fl-num-unknown-name-2.nt b/tests/fail-fl-num-unknown-name-2.nt index c2c2547..789e3c5 100644 --- a/tests/fail-fl-num-unknown-name-2.nt +++ b/tests/fail-fl-num-unknown-name-2.nt @@ -1,4 +1,4 @@ -{ meow : 8 } +[ meow : 8 ] { meow = 34 } --- 1:3 - Illegal (unknown or unreachable) variable/label name `meow` in expression `meow`; the legal names are {`ICITTE`} diff --git a/tests/fail-macro-exp-nested-1.nt b/tests/fail-macro-exp-nested-1.nt index f6e5f49..9e38a98 100644 --- a/tests/fail-macro-exp-nested-1.nt +++ b/tests/fail-macro-exp-nested-1.nt @@ -1,5 +1,5 @@ !macro meow(yeah) - {yeah:8} + [yeah:8] !end !macro mix(yeah) diff --git a/tests/fail-macro-exp-nested-2.nt b/tests/fail-macro-exp-nested-2.nt index 1a3aa9e..e25336c 100644 --- a/tests/fail-macro-exp-nested-2.nt +++ b/tests/fail-macro-exp-nested-2.nt @@ -1,5 +1,5 @@ !macro meow() - {1993:8} + [1993:8] !end !macro mix() diff --git a/tests/fail-sleb128-empty-expr.nt b/tests/fail-sleb128-empty-expr.nt index f08bb47..70335f5 100644 --- a/tests/fail-sleb128-empty-expr.nt +++ b/tests/fail-sleb128-empty-expr.nt @@ -1,3 +1,3 @@ -{ : sleb128 } +[ : sleb128 ] --- -1:3 - Expecting a fixed-length number, a string, a variable assignment, or a byte order setting +1:3 - Expecting an expression diff --git a/tests/fail-str-post-empty-expr.nt b/tests/fail-str-post-empty-expr.nt index de98769..121c472 100644 --- a/tests/fail-str-post-empty-expr.nt +++ b/tests/fail-str-post-empty-expr.nt @@ -1,3 +1,3 @@ -{ : s:u8} +[ : s:u8] --- -1:3 - Expecting a fixed-length number, a string, a variable assignment, or a byte order setting +1:3 - Expecting an expression diff --git a/tests/fail-str-post-inval-latin-enc.nt b/tests/fail-str-post-inval-latin-enc.nt index c8e2686..a98d43b 100644 --- a/tests/fail-str-post-inval-latin-enc.nt +++ b/tests/fail-str-post-inval-latin-enc.nt @@ -1,3 +1,3 @@ -{"a string" : s:latin11} +["a string" : s:latin11] --- 1:17 - Expecting `u8`, `u16be`, `u16le`, `u32be`, `u32le`, or `latin1` to `latin10` diff --git a/tests/fail-str-post-inval-utf-spec.nt b/tests/fail-str-post-inval-utf-spec.nt index f1033d3..3950ae8 100644 --- a/tests/fail-str-post-inval-utf-spec.nt +++ b/tests/fail-str-post-inval-utf-spec.nt @@ -1,3 +1,3 @@ -{"a string" : s:u24be} +["a string" : s:u24be] --- 1:18 - Expecting `8`, `16be`, `16le`, `32be` or `32le` diff --git a/tests/fail-str-post-missing-enc-colon.nt b/tests/fail-str-post-missing-enc-colon.nt index f2b89f0..f4ce015 100644 --- a/tests/fail-str-post-missing-enc-colon.nt +++ b/tests/fail-str-post-missing-enc-colon.nt @@ -1,3 +1,3 @@ -{"a string" : slatin1} +["a string" : slatin1] --- 1:16 - Expecting `:` diff --git a/tests/fail-str-post-missing-enc.nt b/tests/fail-str-post-missing-enc.nt index ef0e407..c850818 100644 --- a/tests/fail-str-post-missing-enc.nt +++ b/tests/fail-str-post-missing-enc.nt @@ -1,3 +1,3 @@ -{"a string" : } +["a string" : ] --- 1:15 - Expecting a fixed length (multiple of eight bits), `uleb128`, `sleb128`, or `s:` followed with a valid encoding (`u8`, `u16be`, `u16le`, `u32be`, `u32le`, or `latin1` to `latin10`) diff --git a/tests/fail-str-post-missing-gen-prefix.nt b/tests/fail-str-post-missing-gen-prefix.nt index 5273052..c11dd51 100644 --- a/tests/fail-str-post-missing-gen-prefix.nt +++ b/tests/fail-str-post-missing-gen-prefix.nt @@ -1,3 +1,3 @@ -{"a string" : latin1} +["a string" : latin1] --- 1:15 - Expecting a fixed length (multiple of eight bits), `uleb128`, `sleb128`, or `s:` followed with a valid encoding (`u8`, `u16be`, `u16le`, `u32be`, `u32le`, or `latin1` to `latin10`) diff --git a/tests/fail-str-post-missing-utf-spec.nt b/tests/fail-str-post-missing-utf-spec.nt index 30c5472..c870560 100644 --- a/tests/fail-str-post-missing-utf-spec.nt +++ b/tests/fail-str-post-missing-utf-spec.nt @@ -1,3 +1,3 @@ -{"a string" : s:u} +["a string" : s:u] --- 1:18 - Expecting `8`, `16be`, `16le`, `32be` or `32le` diff --git a/tests/fail-str-pre-missing-enc.nt b/tests/fail-str-pre-missing-enc.nt index 415005f..e67b1c5 100644 --- a/tests/fail-str-pre-missing-enc.nt +++ b/tests/fail-str-pre-missing-enc.nt @@ -1,3 +1,3 @@ {"a string"} --- -1:2 - Expecting a fixed-length number, a string, a variable assignment, or a byte order setting +1:2 - Expecting a valid Python name diff --git a/tests/fail-trans-unknown-label.nt b/tests/fail-trans-unknown-label.nt index d28ce29..599d6be 100644 --- a/tests/fail-trans-unknown-label.nt +++ b/tests/fail-trans-unknown-label.nt @@ -1,6 +1,6 @@ !transform base64 "meow" - {far:8} + [far:8] "mix" !end diff --git a/tests/fail-uleb128-empty-expr.nt b/tests/fail-uleb128-empty-expr.nt index daa73c9..8b04ef7 100644 --- a/tests/fail-uleb128-empty-expr.nt +++ b/tests/fail-uleb128-empty-expr.nt @@ -1,3 +1,3 @@ -{ : uleb128 } +[ : uleb128 ] --- -1:3 - Expecting a fixed-length number, a string, a variable assignment, or a byte order setting +1:3 - Expecting an expression diff --git a/tests/fail-uleb128-eval-type-1.nt b/tests/fail-uleb128-eval-type-1.nt index 4bf01c1..ef9cd29 100644 --- a/tests/fail-uleb128-eval-type-1.nt +++ b/tests/fail-uleb128-eval-type-1.nt @@ -1,3 +1,3 @@ -{ 'salut' : uleb128 } +[ 'salut' : uleb128 ] --- 1:3 - Invalid expression `'salut'`: expecting result type `int`, not `str` diff --git a/tests/fail-uleb128-eval-type-2.nt b/tests/fail-uleb128-eval-type-2.nt index 7096660..bab56cd 100644 --- a/tests/fail-uleb128-eval-type-2.nt +++ b/tests/fail-uleb128-eval-type-2.nt @@ -1,3 +1,3 @@ -{ 45.2 : uleb128 } +[ 45.2 : uleb128 ] --- 1:3 - Invalid expression `45.2`: expecting result type `int`, not `float` diff --git a/tests/fail-uleb128-eval.nt b/tests/fail-uleb128-eval.nt index aba6ca8..5ee6ef4 100644 --- a/tests/fail-uleb128-eval.nt +++ b/tests/fail-uleb128-eval.nt @@ -1,3 +1,3 @@ -{ 23 + zoom(14) : uleb128 } +[ 23 + zoom(14) : uleb128 ] --- 1:3 - Failed to evaluate expression `23 + zoom(14)`: name 'zoom' is not defined diff --git a/tests/fail-uleb128-inval-syntax.nt b/tests/fail-uleb128-inval-syntax.nt index c8d5064..f253c3f 100644 --- a/tests/fail-uleb128-inval-syntax.nt +++ b/tests/fail-uleb128-inval-syntax.nt @@ -1,3 +1,3 @@ -{ 19 + / 23 : uleb128 } +[ 19 + / 23 : uleb128 ] --- 1:3 - Invalid expression `19 + / 23`: invalid syntax diff --git a/tests/fail-uleb128-unknown-name-1.nt b/tests/fail-uleb128-unknown-name-1.nt index 2663bf0..692b5b4 100644 --- a/tests/fail-uleb128-unknown-name-1.nt +++ b/tests/fail-uleb128-unknown-name-1.nt @@ -1,3 +1,3 @@ -{ meow : 8 } +[ meow : 8 ] --- 1:3 - Illegal (unknown or unreachable) variable/label name `meow` in expression `meow`; the legal names are {`ICITTE`} diff --git a/tests/fail-uleb128-unknown-name-2.nt b/tests/fail-uleb128-unknown-name-2.nt index 0e1700f..872d48b 100644 --- a/tests/fail-uleb128-unknown-name-2.nt +++ b/tests/fail-uleb128-unknown-name-2.nt @@ -1,4 +1,4 @@ -{ meow : uleb128 } +[ meow : uleb128 ] { meow = 34 } --- 1:3 - Illegal (unknown or unreachable) variable/label name `meow` in expression `meow`; the legal names are {`ICITTE`} diff --git a/tests/fail-uleb128-unreachable-label-1.nt b/tests/fail-uleb128-unreachable-label-1.nt index 0d5fb4e..b0f93ef 100644 --- a/tests/fail-uleb128-unreachable-label-1.nt +++ b/tests/fail-uleb128-unreachable-label-1.nt @@ -1,6 +1,6 @@ aa bb {kilo = 23} cc -{mix : uleb128} +[mix : uleb128] ee --- 3:2 - Illegal (unknown or unreachable) variable/label name `mix` in expression `mix`; the legal names are {`ICITTE`, `kilo`, `meow`} diff --git a/tests/fail-uleb128-unreachable-label-2.nt b/tests/fail-uleb128-unreachable-label-2.nt index ed3782f..cf88d7c 100644 --- a/tests/fail-uleb128-unreachable-label-2.nt +++ b/tests/fail-uleb128-unreachable-label-2.nt @@ -1,6 +1,6 @@ aa {mix = 23} bb cc ( - dd {meow : uleb128} + dd [meow : uleb128] ff ) diff --git a/tests/fail-var-label-bo-none.nt b/tests/fail-var-label-bo-none.nt index 0f7314d..4dc4db3 100644 --- a/tests/fail-var-label-bo-none.nt +++ b/tests/fail-var-label-bo-none.nt @@ -1,3 +1,3 @@ { hello } --- -1:3 - Expecting a fixed-length number, a string, a variable assignment, or a byte order setting +1:9 - Expecting `=` diff --git a/tests/pass-bmp.nt b/tests/pass-bmp.nt index fb96be9..bc6fa3c 100644 --- a/tests/pass-bmp.nt +++ b/tests/pass-bmp.nt @@ -1,9 +1,9 @@ {dim = 128} -{le} +!le # Single pixel macro !macro px(r, g, b) - {r:8} {g:8} {b:8} + [r:8] [g:8] [b:8] !end # Header @@ -11,31 +11,31 @@ "BM" # File size - {end : 32} + [end : 32] # Reserved 00 00 00 00 # Bitmap data offset - {data : 32} + [data : 32] # DIB header # DIB header size - {dib_end - dib_start : 32} + [dib_end - dib_start : 32] # Bitmap width - {dim : 16} + [dim : 16] # Bitmap height - {dim : 16} + [dim : 16] # Planes - {1 : 16} + [1 : 16] # Bits/pixel - {24 : 16} + [24 : 16] diff --git a/tests/pass-bo.nt b/tests/pass-bo.nt index 1100c5e..bd29c02 100644 --- a/tests/pass-bo.nt +++ b/tests/pass-bo.nt @@ -1,7 +1,7 @@ -{0xff:8} -{be} {0x17:16} {0x17:16} -{le} {0x23:16} {0x23:16} -{be} {0x42:16} {0x42:16} +[0xff:8] +!be [0x17:16] [0x17:16] +!le [0x23:16] [0x23:16] +!be [0x42:16] [0x42:16] --- ff 00 17 00 17 diff --git a/tests/pass-comment-all.nt b/tests/pass-comment-all.nt index 8b37fdc..740ca22 100644 --- a/tests/pass-comment-all.nt +++ b/tests/pass-comment-all.nt @@ -13,26 +13,26 @@ a#bonjour tout le monde#a#bonjour tout le monde#bb#bonjour tout le monde# #bonjour tout le monde#s#bonjour tout le monde#:#bonjour tout le monde#u16be#bonjour tout le monde#"coucou"#bonjour tout le monde# # byte order setting -#bonjour tout le monde#{#bonjour tout le monde#be#bonjour tout le monde#}#bonjour tout le monde#{0xaabb:16} -#bonjour tout le monde#{#bonjour tout le monde#le#bonjour tout le monde#}#bonjour tout le monde#{0xaabb:16} +#bonjour tout le monde#!be#bonjour tout le monde#[0xaabb:16] +#bonjour tout le monde#!le#bonjour tout le monde#[0xaabb:16] # fixed-length number -#bonjour tout le monde#{ 0xbeef :#bonjour tout le monde#16#bonjour tout le monde#}#bonjour tout le monde# +#bonjour tout le monde#[#bonjour tout le monde#0xbeef :#bonjour tout le monde#16#bonjour tout le monde#]#bonjour tout le monde# # LEB128 integer: unsigned -#bonjour tout le monde#{ 12345678 :#bonjour tout le monde#uleb128#bonjour tout le monde#}#bonjour tout le monde# +#bonjour tout le monde#[#bonjour tout le monde#12345678 :#bonjour tout le monde#uleb128#bonjour tout le monde#]#bonjour tout le monde# # LEB128 integer: signed -#bonjour tout le monde#{ -12345678 :#bonjour tout le monde#sleb128#bonjour tout le monde#}#bonjour tout le monde# +#bonjour tout le monde#[#bonjour tout le monde#-12345678 :#bonjour tout le monde#sleb128#bonjour tout le monde#]#bonjour tout le monde# # string: encoding before #bonjour tout le monde#s#bonjour tout le monde#:#bonjour tout le monde#latin1#bonjour tout le monde#{ "allo" }#bonjour tout le monde# # string: encoding after -#bonjour tout le monde#{ 'meow mix' :#bonjour tout le monde#s#bonjour tout le monde#:#bonjour tout le monde#latin3#bonjour tout le monde#}#bonjour tout le monde# +#bonjour tout le monde#[#bonjour tout le monde#'meow mix' :#bonjour tout le monde#s#bonjour tout le monde#:#bonjour tout le monde#latin3#bonjour tout le monde#]#bonjour tout le monde# # current offset setting -#bonjour tout le monde#<#bonjour tout le monde#18#bonjour tout le monde#>#bonjour tout le monde#{ICITTE-18:8} +#bonjour tout le monde#<#bonjour tout le monde#18#bonjour tout le monde#>#bonjour tout le monde#[ICITTE-18:8] # current offset alignment #bonjour tout le monde#@#bonjour tout le monde#64#bonjour tout le monde#~#bonjour tout le monde#ffh#bonjour tout le monde# @@ -41,7 +41,7 @@ a#bonjour tout le monde#a#bonjour tout le monde#bb#bonjour tout le monde# #bonjour tout le monde#+#bonjour tout le monde#{ ICITTE+8+4+2+1+1 }#bonjour tout le monde#~#bonjour tout le monde#0xcc#bonjour tout le monde# # label -#bonjour tout le monde#<#bonjour tout le monde#salut#bonjour tout le monde#>#bonjour tout le monde#{salut-ICITTE:8} +#bonjour tout le monde#<#bonjour tout le monde#salut#bonjour tout le monde#>#bonjour tout le monde#[salut-ICITTE:8] # group #bonjour tout le monde#(#bonjour tout le monde#aa#bonjour tout le monde#)#bonjour tout le monde# @@ -57,7 +57,7 @@ a#bonjour tout le monde#a#bonjour tout le monde#bb#bonjour tout le monde# # macro definition block #bonjour tout le monde#!macro#bonjour tout le monde#gang#bonjour tout le monde#(#bonjour tout le monde#meow#bonjour tout le monde#,#bonjour tout le monde#mix#bonjour tout le monde#)#bonjour tout le monde# - aa {meow:8} bb {mix:8} + aa [meow:8] bb [mix:8] #bonjour tout le monde#!end#bonjour tout le monde# # macro expansion diff --git a/tests/pass-comment-sym-bin-const.nt b/tests/pass-comment-sym-bin-const.nt index ff49023..038f20b 100644 --- a/tests/pass-comment-sym-bin-const.nt +++ b/tests/pass-comment-sym-bin-const.nt @@ -1,6 +1,6 @@ -%1/01\0?1&0:1;0 %.0,10[1]0_1=0|1 %1111-0000 +%1/01\0?1&0:1;0 %.0,1010_1=0|1 %1111-0000 % 1 0 / 1 \ 0 ? 1 & 0 : 1 ; 0 -% . 0 , 1 0 [ 1 ] 0 _ 1 = 0 | 1 +% . 0 , 1 0 1 0 _ 1 = 0 | 1 % 1111 - 0000 --- aa 55 f0 diff --git a/tests/pass-comment-sym-group.nt b/tests/pass-comment-sym-group.nt index bcc7db9..afb55d4 100644 --- a/tests/pass-comment-sym-group.nt +++ b/tests/pass-comment-sym-group.nt @@ -1,3 +1,3 @@ -(012/3\4?5&6:7;8.9,ab[c]d_e=f|0-1(/\?&:;.,[]_=|-)) +(012/3\4?5&6:7;8.9,abcd_e=f|0-1(/\?&:;.,_=|-)) --- 01 23 45 67 89 ab cd ef 01 diff --git a/tests/pass-comment-sym-hex-const.nt b/tests/pass-comment-sym-hex-const.nt index c770691..6102382 100644 --- a/tests/pass-comment-sym-hex-const.nt +++ b/tests/pass-comment-sym-hex-const.nt @@ -1,6 +1,6 @@ -/ \ ? & : ; . , [ ] _ = | - -012/3\4?5&6:7;8.9,ab[c]d_e=f|0-1 -0 1 2 / 3 \ 4 ? 5 & 6 : 7 ; 8 . 9 , a b [ c ] d_e = f | 0 - 1 +/ \ ? & : ; . , _ = | - +012/3\4?5&6:7;8.9,abcd_e=f|0-1 +0 1 2 / 3 \ 4 ? 5 & 6 : 7 ; 8 . 9 , a b c d_e = f | 0 - 1 --- 01 23 45 67 89 ab cd ef 01 01 23 45 67 89 ab cd ef 01 diff --git a/tests/pass-const-int-bin.nt b/tests/pass-const-int-bin.nt index 97f6de8..24c2f85 100644 --- a/tests/pass-const-int-bin.nt +++ b/tests/pass-const-int-bin.nt @@ -1,5 +1,5 @@ !m ci(val) - {val:8} + [val:8] !end m:ci(0b11001010) diff --git a/tests/pass-const-int-dec.nt b/tests/pass-const-int-dec.nt index 10b04cb..f357143 100644 --- a/tests/pass-const-int-dec.nt +++ b/tests/pass-const-int-dec.nt @@ -1,5 +1,5 @@ !m ci(val) - {val:8} + [val:8] !end m:ci(42) diff --git a/tests/pass-const-int-hex.nt b/tests/pass-const-int-hex.nt index 868c62a..1954eaf 100644 --- a/tests/pass-const-int-hex.nt +++ b/tests/pass-const-int-hex.nt @@ -1,5 +1,5 @@ !m ci(val) - {val:8} + [val:8] !end m:ci(0x01) diff --git a/tests/pass-const-int-oct.nt b/tests/pass-const-int-oct.nt index 760585d..d5fd33f 100644 --- a/tests/pass-const-int-oct.nt +++ b/tests/pass-const-int-oct.nt @@ -1,5 +1,5 @@ !m ci(val) - {val:8} + [val:8] !end m:ci(0o01) diff --git a/tests/pass-fill-cur-offset.nt b/tests/pass-fill-cur-offset.nt index c0f9a96..1c77742 100644 --- a/tests/pass-fill-cur-offset.nt +++ b/tests/pass-fill-cur-offset.nt @@ -1,3 +1,3 @@ -aa bb cc +{ICITTE} {ICITTE:8} +aa bb cc +{ICITTE} [ICITTE:8] --- aa bb cc 03 diff --git a/tests/pass-fill-name.nt b/tests/pass-fill-name.nt index aeecbd5..e80263a 100644 --- a/tests/pass-fill-name.nt +++ b/tests/pass-fill-name.nt @@ -1,4 +1,4 @@ -aa {zoom = 10} bb cc +zoom {ICITTE:8} +aa {zoom = 10} bb cc +zoom [ICITTE:8] --- aa bb cc 00 00 00 00 00 00 00 diff --git a/tests/pass-fill-pad-val.nt b/tests/pass-fill-pad-val.nt index ba43a7f..b5af3e6 100644 --- a/tests/pass-fill-pad-val.nt +++ b/tests/pass-fill-pad-val.nt @@ -1,5 +1,5 @@ -aa {zoom = 10} bb cc +zoom~0xcc {ICITTE:8} -+ 15 ~ 255 {ICITTE:8} +aa {zoom = 10} bb cc +zoom~0xcc [ICITTE:8] ++ 15 ~ 255 [ICITTE:8] --- aa bb cc cc cc cc cc cc cc cc diff --git a/tests/pass-fill.nt b/tests/pass-fill.nt index 15e7a94..50446a3 100644 --- a/tests/pass-fill.nt +++ b/tests/pass-fill.nt @@ -1,4 +1,4 @@ -aa bb cc +10 {ICITTE:8} +aa bb cc +10 [ICITTE:8] --- aa bb cc 00 00 00 00 00 00 00 diff --git a/tests/pass-fl-float-32b-be.nt b/tests/pass-fl-float-32b-be.nt index 76c27ae..fbd8e28 100644 --- a/tests/pass-fl-float-32b-be.nt +++ b/tests/pass-fl-float-32b-be.nt @@ -1,6 +1,6 @@ -{be} -{2.99792458e8:32} -{-1.6021766208:32} +!be +[2.99792458e8:32] +[-1.6021766208:32] --- 4d 8e f3 c2 bf cd 14 20 diff --git a/tests/pass-fl-float-32b-le.nt b/tests/pass-fl-float-32b-le.nt index dab2899..1600e4c 100644 --- a/tests/pass-fl-float-32b-le.nt +++ b/tests/pass-fl-float-32b-le.nt @@ -1,6 +1,6 @@ -{le} -{2.99792458e8:32} -{-1.6021766208:32} +!le +[2.99792458e8:32] +[-1.6021766208:32] --- c2 f3 8e 4d 20 14 cd bf diff --git a/tests/pass-fl-float-64b-be.nt b/tests/pass-fl-float-64b-be.nt index 825e65a..c210ecc 100644 --- a/tests/pass-fl-float-64b-be.nt +++ b/tests/pass-fl-float-64b-be.nt @@ -1,6 +1,6 @@ -{be} -{2.99792458e8:64} -{-1.6021766208:64} +!be +[2.99792458e8:64] +[-1.6021766208:64] --- 41 b1 de 78 4a 00 00 00 bf f9 a2 83 f3 cc 07 58 diff --git a/tests/pass-fl-float-64b-le.nt b/tests/pass-fl-float-64b-le.nt index 1c44ff3..c882f3c 100644 --- a/tests/pass-fl-float-64b-le.nt +++ b/tests/pass-fl-float-64b-le.nt @@ -1,6 +1,6 @@ -{le} -{2.99792458e8:64} -{-1.6021766208:64} +!le +[2.99792458e8:64] +[-1.6021766208:64] --- 00 00 00 4a 78 de b1 41 58 07 cc f3 83 a2 f9 bf diff --git a/tests/pass-fl-int-16b-be.nt b/tests/pass-fl-int-16b-be.nt index f8d5fd6..9b02a37 100644 --- a/tests/pass-fl-int-16b-be.nt +++ b/tests/pass-fl-int-16b-be.nt @@ -1,15 +1,15 @@ -{be} +!be {var = 5} aa bb cc dd ee ff 33 44 55 -{1966:16} -{-1966:16} -{1966 + var : 16} -{1966 + lbl : 16} -{1966 + var + lbl : 16} -{-1:16} +[1966:16] +[-1966:16] +[1966 + var : 16] +[1966 + lbl : 16] +[1966 + var + lbl : 16] +[-1:16] 33 diff --git a/tests/pass-fl-int-16b-le.nt b/tests/pass-fl-int-16b-le.nt index c417dcf..205275b 100644 --- a/tests/pass-fl-int-16b-le.nt +++ b/tests/pass-fl-int-16b-le.nt @@ -1,15 +1,15 @@ -{le} +!le {var = 5} aa bb cc dd ee ff 33 44 55 -{1966:16} -{-1966:16} -{1966 + var : 16} -{1966 + lbl : 16} -{1966 + var + lbl : 16} -{-1:16} +[1966:16] +[-1966:16] +[1966 + var : 16] +[1966 + lbl : 16] +[1966 + var + lbl : 16] +[-1:16] 33 diff --git a/tests/pass-fl-int-24b-be.nt b/tests/pass-fl-int-24b-be.nt index 13c4d74..f0e1e7d 100644 --- a/tests/pass-fl-int-24b-be.nt +++ b/tests/pass-fl-int-24b-be.nt @@ -1,15 +1,15 @@ -{be} +!be {var = 5} aa bb cc dd ee ff 33 44 55 -{4192322:24} -{-4192322:24} -{4192322 + var : 24} -{4192322 + lbl : 24} -{4192322 + var + lbl : 24} -{-1:24} +[4192322:24] +[-4192322:24] +[4192322 + var : 24] +[4192322 + lbl : 24] +[4192322 + var + lbl : 24] +[-1:24] 33 diff --git a/tests/pass-fl-int-24b-le.nt b/tests/pass-fl-int-24b-le.nt index d1f18a2..c917e10 100644 --- a/tests/pass-fl-int-24b-le.nt +++ b/tests/pass-fl-int-24b-le.nt @@ -1,15 +1,15 @@ -{le} +!le {var = 5} aa bb cc dd ee ff 33 44 55 -{4192322:24} -{-4192322:24} -{4192322 + var : 24} -{4192322 + lbl : 24} -{4192322 + var + lbl : 24} -{-1:24} +[4192322:24] +[-4192322:24] +[4192322 + var : 24] +[4192322 + lbl : 24] +[4192322 + var + lbl : 24] +[-1:24] 33 diff --git a/tests/pass-fl-int-32b-be.nt b/tests/pass-fl-int-32b-be.nt index c7415e6..3c7eea1 100644 --- a/tests/pass-fl-int-32b-be.nt +++ b/tests/pass-fl-int-32b-be.nt @@ -1,15 +1,15 @@ -{be} +!be {var = 5} aa bb cc dd ee ff 33 44 55 -{536890750:32} -{-536890750:32} -{536890750 + var : 32} -{536890750 + lbl : 32} -{536890750 + var + lbl : 32} -{-1:32} +[536890750:32] +[-536890750:32] +[536890750 + var : 32] +[536890750 + lbl : 32] +[536890750 + var + lbl : 32] +[-1:32] 33 diff --git a/tests/pass-fl-int-32b-le.nt b/tests/pass-fl-int-32b-le.nt index 5865d25..7efd093 100644 --- a/tests/pass-fl-int-32b-le.nt +++ b/tests/pass-fl-int-32b-le.nt @@ -1,15 +1,15 @@ -{le} +!le {var = 5} aa bb cc dd ee ff 33 44 55 -{536890750:32} -{-536890750:32} -{536890750 + var : 32} -{536890750 + lbl : 32} -{536890750 + var + lbl : 32} -{-1:32} +[536890750:32] +[-536890750:32] +[536890750 + var : 32] +[536890750 + lbl : 32] +[536890750 + var + lbl : 32] +[-1:32] 33 diff --git a/tests/pass-fl-int-40b-be.nt b/tests/pass-fl-int-40b-be.nt index 9b09c35..3106e62 100644 --- a/tests/pass-fl-int-40b-be.nt +++ b/tests/pass-fl-int-40b-be.nt @@ -1,15 +1,15 @@ -{be} +!be {var = 5} aa bb cc dd ee ff 33 44 55 -{34359758191:40} -{-34359758191:40} -{34359758191 + var : 40} -{34359758191 + lbl : 40} -{34359758191 + var + lbl : 40} -{-1:40} +[34359758191:40] +[-34359758191:40] +[34359758191 + var : 40] +[34359758191 + lbl : 40] +[34359758191 + var + lbl : 40] +[-1:40] 33 diff --git a/tests/pass-fl-int-40b-le.nt b/tests/pass-fl-int-40b-le.nt index 22713c4..777a201 100644 --- a/tests/pass-fl-int-40b-le.nt +++ b/tests/pass-fl-int-40b-le.nt @@ -1,15 +1,15 @@ -{le} +!le {var = 5} aa bb cc dd ee ff 33 44 55 -{34359758191:40} -{-34359758191:40} -{34359758191 + var : 40} -{34359758191 + lbl : 40} -{34359758191 + var + lbl : 40} -{-1:40} +[34359758191:40] +[-34359758191:40] +[34359758191 + var : 40] +[34359758191 + lbl : 40] +[34359758191 + var + lbl : 40] +[-1:40] 33 diff --git a/tests/pass-fl-int-48b-be.nt b/tests/pass-fl-int-48b-be.nt index 4b3fe0b..89d3519 100644 --- a/tests/pass-fl-int-48b-be.nt +++ b/tests/pass-fl-int-48b-be.nt @@ -1,15 +1,15 @@ -{be} +!be {var = 5} aa bb cc dd ee ff 33 44 55 -{35184372059993:48} -{-35184372059993:48} -{35184372059993 + var : 48} -{35184372059993 + lbl : 48} -{35184372059993 + var + lbl : 48} -{-1:48} +[35184372059993:48] +[-35184372059993:48] +[35184372059993 + var : 48] +[35184372059993 + lbl : 48] +[35184372059993 + var + lbl : 48] +[-1:48] 33 diff --git a/tests/pass-fl-int-48b-le.nt b/tests/pass-fl-int-48b-le.nt index c6b4db4..3ddea44 100644 --- a/tests/pass-fl-int-48b-le.nt +++ b/tests/pass-fl-int-48b-le.nt @@ -1,15 +1,15 @@ -{le} +!le {var = 5} aa bb cc dd ee ff 33 44 55 -{35184372059993:48} -{-35184372059993:48} -{35184372059993 + var : 48} -{35184372059993 + lbl : 48} -{35184372059993 + var + lbl : 48} -{-1:48} +[35184372059993:48] +[-35184372059993:48] +[35184372059993 + var : 48] +[35184372059993 + lbl : 48] +[35184372059993 + var + lbl : 48] +[-1:48] 33 diff --git a/tests/pass-fl-int-56b-be.nt b/tests/pass-fl-int-56b-be.nt index 5d3a9c5..382d4f6 100644 --- a/tests/pass-fl-int-56b-be.nt +++ b/tests/pass-fl-int-56b-be.nt @@ -1,15 +1,15 @@ -{be} +!be {var = 5} aa bb cc dd ee ff 33 44 55 -{1125899906844617:56} -{-1125899906844617:56} -{1125899906844617 + var : 56} -{1125899906844617 + lbl : 56} -{1125899906844617 + var + lbl : 56} -{-1:56} +[1125899906844617:56] +[-1125899906844617:56] +[1125899906844617 + var : 56] +[1125899906844617 + lbl : 56] +[1125899906844617 + var + lbl : 56] +[-1:56] 33 diff --git a/tests/pass-fl-int-56b-le.nt b/tests/pass-fl-int-56b-le.nt index 523689c..70e7a15 100644 --- a/tests/pass-fl-int-56b-le.nt +++ b/tests/pass-fl-int-56b-le.nt @@ -1,15 +1,15 @@ -{le} +!le {var = 5} aa bb cc dd ee ff 33 44 55 -{1125899906844617:56} -{-1125899906844617:56} -{1125899906844617 + var : 56} -{1125899906844617 + lbl : 56} -{1125899906844617 + var + lbl : 56} -{-1:56} +[1125899906844617:56] +[-1125899906844617:56] +[1125899906844617 + var : 56] +[1125899906844617 + lbl : 56] +[1125899906844617 + var + lbl : 56] +[-1:56] 33 diff --git a/tests/pass-fl-int-64b-be.nt b/tests/pass-fl-int-64b-be.nt index a959080..a8e0fd6 100644 --- a/tests/pass-fl-int-64b-be.nt +++ b/tests/pass-fl-int-64b-be.nt @@ -1,15 +1,15 @@ -{be} +!be {var = 5} aa bb cc dd ee ff 33 44 55 -{4611686018427387158:64} -{-4611686018427387158:64} -{4611686018427387158 + var : 64} -{4611686018427387158 + lbl : 64} -{4611686018427387158 + var + lbl : 64} -{-1:64} +[4611686018427387158:64] +[-4611686018427387158:64] +[4611686018427387158 + var : 64] +[4611686018427387158 + lbl : 64] +[4611686018427387158 + var + lbl : 64] +[-1:64] 33 diff --git a/tests/pass-fl-int-64b-le.nt b/tests/pass-fl-int-64b-le.nt index b1d6b9c..bf96205 100644 --- a/tests/pass-fl-int-64b-le.nt +++ b/tests/pass-fl-int-64b-le.nt @@ -1,15 +1,15 @@ -{le} +!le {var = 5} aa bb cc dd ee ff 33 44 55 -{4611686018427387158:64} -{-4611686018427387158:64} -{4611686018427387158 + var : 64} -{4611686018427387158 + lbl : 64} -{4611686018427387158 + var + lbl : 64} -{-1:64} +[4611686018427387158:64] +[-4611686018427387158:64] +[4611686018427387158 + var : 64] +[4611686018427387158 + lbl : 64] +[4611686018427387158 + var + lbl : 64] +[-1:64] 33 diff --git a/tests/pass-fl-int-8b.nt b/tests/pass-fl-int-8b.nt index 15fea63..8c55e6e 100644 --- a/tests/pass-fl-int-8b.nt +++ b/tests/pass-fl-int-8b.nt @@ -3,11 +3,11 @@ aa bb cc dd ee ff 33 44 55 -{66:8} -{-66:8} -{66 + var : 8} -{66 + lbl : 8} -{66 + var + lbl : 8} +[66:8] +[-66:8] +[66 + var : 8] +[66 + lbl : 8] +[66 + var + lbl : 8] 33 diff --git a/tests/pass-fl-int-icitte.nt b/tests/pass-fl-int-icitte.nt index a6a5e7f..55d6281 100644 --- a/tests/pass-fl-int-icitte.nt +++ b/tests/pass-fl-int-icitte.nt @@ -1,9 +1,9 @@ aa bb cc dd ee ff -{ICITTE + 23 : 8} -{be} -{ICITTE + 23 : 16} -{ICITTE + 23 : 32} -{ICITTE + 23 : 64} +[ICITTE + 23 : 8] +!be +[ICITTE + 23 : 16] +[ICITTE + 23 : 32] +[ICITTE + 23 : 64] --- aa bb cc dd ee ff 1d diff --git a/tests/pass-group-blk-label-1.nt b/tests/pass-group-blk-label-1.nt index 1d83d60..b1f2407 100644 --- a/tests/pass-group-blk-label-1.nt +++ b/tests/pass-group-blk-label-1.nt @@ -1,4 +1,4 @@ -00 !group 11 22 {mix-meow:8} 33 44 !end * 2 55 +00 !group 11 22 [mix-meow:8] 33 44 !end * 2 55 --- 00 11 22 03 33 44 diff --git a/tests/pass-group-blk-label-2.nt b/tests/pass-group-blk-label-2.nt index 2285e9d..9961461 100644 --- a/tests/pass-group-blk-label-2.nt +++ b/tests/pass-group-blk-label-2.nt @@ -1,8 +1,8 @@ 00 !group - 11 {mix:8} 22 + 11 [mix:8] 22 !group - {meow + mix : 8} + [meow + mix : 8] !end * 3 33 !end * 2 diff --git a/tests/pass-group-blk-label-3.nt b/tests/pass-group-blk-label-3.nt index 1f8b421..8bd278b 100644 --- a/tests/pass-group-blk-label-3.nt +++ b/tests/pass-group-blk-label-3.nt @@ -1,6 +1,6 @@ 00 !group - 11 22 {outer:8} {inner:8} {end:8} + 11 22 [outer:8] [inner:8] [end:8] !end * 3 ff --- diff --git a/tests/pass-group-paren-label-1.nt b/tests/pass-group-paren-label-1.nt index dbfa2d8..5cba064 100644 --- a/tests/pass-group-paren-label-1.nt +++ b/tests/pass-group-paren-label-1.nt @@ -1,4 +1,4 @@ -00 (11 22 {mix-meow:8} 33 44) * 2 55 +00 (11 22 [mix-meow:8] 33 44) * 2 55 --- 00 11 22 03 33 44 diff --git a/tests/pass-group-paren-label-2.nt b/tests/pass-group-paren-label-2.nt index 7eff18e..c85f936 100644 --- a/tests/pass-group-paren-label-2.nt +++ b/tests/pass-group-paren-label-2.nt @@ -1,4 +1,4 @@ -00 (11 {mix:8} 22 ( {meow + mix : 8}) * 3 33) * 2 44 +00 (11 [mix:8] 22 ( [meow + mix : 8]) * 3 33) * 2 44 --- 00 diff --git a/tests/pass-group-paren-label-3.nt b/tests/pass-group-paren-label-3.nt index 57928b1..e5c6119 100644 --- a/tests/pass-group-paren-label-3.nt +++ b/tests/pass-group-paren-label-3.nt @@ -1,4 +1,4 @@ -00 (11 22 {outer:8} {inner:8} {end:8}) * 3 ff +00 (11 22 [outer:8] [inner:8] [end:8]) * 3 ff --- 00 11 22 01 02 10 diff --git a/tests/pass-label.nt b/tests/pass-label.nt index 67f3401..7fcbe97 100644 --- a/tests/pass-label.nt +++ b/tests/pass-label.nt @@ -1,13 +1,13 @@ 00 11 22 33 -{meow:8} +[meow:8] 44 55 -{mix:8} +[mix:8] 66 77 < mix > 88 99 -{meow + mix : 8} +[meow + mix : 8] --- 00 11 22 33 diff --git a/tests/pass-macro-exp-final-state-bo.nt b/tests/pass-macro-exp-final-state-bo.nt index 79c5b33..845b58b 100644 --- a/tests/pass-macro-exp-final-state-bo.nt +++ b/tests/pass-macro-exp-final-state-bo.nt @@ -1,8 +1,8 @@ !m s() - {le} {0xabcd:16} + !le [0xabcd:16] !end -{be} m:s() {0xabcd:16} +!be m:s() [0xabcd:16] --- cd ab ab cd diff --git a/tests/pass-macro-exp-final-state-labels.nt b/tests/pass-macro-exp-final-state-labels.nt index c6b1134..519db38 100644 --- a/tests/pass-macro-exp-final-state-labels.nt +++ b/tests/pass-macro-exp-final-state-labels.nt @@ -1,9 +1,9 @@ !m s() 33 44 - {zoom:8} + [zoom:8] !end -11 22 m:s() ff {zoom:8} +11 22 m:s() ff [zoom:8] --- 11 22 33 44 03 diff --git a/tests/pass-macro-exp-final-state-offset.nt b/tests/pass-macro-exp-final-state-offset.nt index 4af387f..65f8cf1 100644 --- a/tests/pass-macro-exp-final-state-offset.nt +++ b/tests/pass-macro-exp-final-state-offset.nt @@ -2,7 +2,7 @@ aa bb cc <0x100> dd !end -11 m:s() {ICITTE:8} +11 m:s() [ICITTE:8] --- 11 aa bb cc dd diff --git a/tests/pass-macro-exp-final-state-vars.nt b/tests/pass-macro-exp-final-state-vars.nt index 028b097..740aeb2 100644 --- a/tests/pass-macro-exp-final-state-vars.nt +++ b/tests/pass-macro-exp-final-state-vars.nt @@ -1,8 +1,8 @@ !m s() {meow = 0x42} - {meow:8} + [meow:8] !end -{meow = 0x23} m:s() {meow:8} +{meow = 0x23} m:s() [meow:8] --- 42 23 diff --git a/tests/pass-macro-exp-fl-num.nt b/tests/pass-macro-exp-fl-num.nt index 7e50d75..45171d1 100644 --- a/tests/pass-macro-exp-fl-num.nt +++ b/tests/pass-macro-exp-fl-num.nt @@ -1,5 +1,5 @@ !m butter(val) - {val : 8} + [val : 8] !end m:butter(0x23) m:butter(0x42) diff --git a/tests/pass-macro-exp-init-state-bo.nt b/tests/pass-macro-exp-init-state-bo.nt index aad121a..a3ffdfd 100644 --- a/tests/pass-macro-exp-init-state-bo.nt +++ b/tests/pass-macro-exp-init-state-bo.nt @@ -1,9 +1,9 @@ !m s() - {0xabcd : 16} + [0xabcd : 16] !end -{be} m:s() -{le} m:s() +!be m:s() +!le m:s() --- ab cd cd ab diff --git a/tests/pass-macro-exp-init-state-offset.nt b/tests/pass-macro-exp-init-state-offset.nt index 09f3e41..f172eff 100644 --- a/tests/pass-macro-exp-init-state-offset.nt +++ b/tests/pass-macro-exp-init-state-offset.nt @@ -1,5 +1,5 @@ !m s() - {ICITTE : 8} + [ICITTE : 8] !end aa bb cc dd m:s() ee ff diff --git a/tests/pass-macro-exp-param-float.nt b/tests/pass-macro-exp-param-float.nt index f06de84..d432dd5 100644 --- a/tests/pass-macro-exp-param-float.nt +++ b/tests/pass-macro-exp-param-float.nt @@ -1,8 +1,8 @@ !macro salut(a, b, c) - "meow" {b : 32} + "meow" [b : 32] !end -{be} +!be aa bb m:salut(42, 45.12, 12) m:salut(42, -12.34e9, 12) diff --git a/tests/pass-macro-exp-param-str.nt b/tests/pass-macro-exp-param-str.nt index 5b8ab83..462d4ee 100644 --- a/tests/pass-macro-exp-param-str.nt +++ b/tests/pass-macro-exp-param-str.nt @@ -1,8 +1,8 @@ !macro salut(zoom) - "meow " {zoom : s:latin1} + "meow " [zoom : s:latin1] !end -{be} +!be aa bb m:salut("mix\n") m:salut("meow") diff --git a/tests/pass-macro-exp-three-params.nt b/tests/pass-macro-exp-three-params.nt index 8e990c6..389920d 100644 --- a/tests/pass-macro-exp-three-params.nt +++ b/tests/pass-macro-exp-three-params.nt @@ -3,7 +3,7 @@ aa bb cc dd !if cond - "hello" {val * 2 : 8} + "hello" [val * 2 : 8] !end !end !end diff --git a/tests/pass-macro-exp-var.nt b/tests/pass-macro-exp-var.nt index 012a645..da08423 100644 --- a/tests/pass-macro-exp-var.nt +++ b/tests/pass-macro-exp-var.nt @@ -1,6 +1,6 @@ !m butter(val) {milk = val * 2} - {be} {milk : 8} + !be [milk : 8] !end m:butter(0x23) m:butter(0x42) diff --git a/tests/pass-offset.nt b/tests/pass-offset.nt index 47ecc7a..d482e62 100644 --- a/tests/pass-offset.nt +++ b/tests/pass-offset.nt @@ -4,9 +4,9 @@ 66 77 <0x3f> 88 99 -{meow:8} -{mix:8} -{zoom:8} +[meow:8] +[mix:8] +[zoom:8] --- 00 11 22 33 44 55 diff --git a/tests/pass-readme-intro-align.nt b/tests/pass-readme-intro-align.nt index 4ebc94d..3c83aac 100644 --- a/tests/pass-readme-intro-align.nt +++ b/tests/pass-readme-intro-align.nt @@ -1,9 +1,9 @@ -{be} +!be - {199:32} -@64 {43:64} -@16 {-123:16} -@32~255 {5584:32} + [199:32] +@64 [43:64] +@16 [-123:16] +@32~255 [5584:32] --- 00 00 00 c7 00 00 00 00 00 00 00 00 00 00 00 2b ff 85 ff ff 00 00 15 d0 diff --git a/tests/pass-readme-intro-fill.nt b/tests/pass-readme-intro-fill.nt index c36f731..386fa5c 100644 --- a/tests/pass-readme-intro-fill.nt +++ b/tests/pass-readme-intro-fill.nt @@ -1,12 +1,12 @@ -{le} -{0xdeadbeef:32} -{-1993:16} -{9:16} +!le +[0xdeadbeef:32] +[-1993:16] +[9:16] +0x40 -{ICITTE:8} +[ICITTE:8] "meow mix" +200~FFh -{ICITTE:8} +[ICITTE:8] --- ef be ad de 37 f8 09 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 diff --git a/tests/pass-readme-intro-fl-num.nt b/tests/pass-readme-intro-fl-num.nt index da03aa9..d0a6b10 100644 --- a/tests/pass-readme-intro-fl-num.nt +++ b/tests/pass-readme-intro-fl-num.nt @@ -1,7 +1,7 @@ {strength = 4} -{be} 67 44 $178 {(end - lbl) * 8 + strength : 16} $99 -{le} {-1993 : 32} -{-3.141593 : 64} +!be 67 44 $178 [(end - lbl) * 8 + strength : 16] $99 +!le [-1993 : 32] +[-3.141593 : 64] --- 67 44 b2 00 2c 63 37 f8 ff ff 7f bd c2 82 fb 21 09 c0 diff --git a/tests/pass-readme-intro-leb128.nt b/tests/pass-readme-intro-leb128.nt index eb8d47b..c9891b0 100644 --- a/tests/pass-readme-intro-leb128.nt +++ b/tests/pass-readme-intro-leb128.nt @@ -1,4 +1,4 @@ -aa bb cc {-1993 : sleb128} dd ee ff -{meow * 199 : uleb128} +aa bb cc [-1993 : sleb128] dd ee ff +[meow * 199 : uleb128] --- aa bb cc b7 70 dd ee ff e3 07 diff --git a/tests/pass-readme-learn-align-2.nt b/tests/pass-readme-learn-align-2.nt index 6af3b7f..a660c87 100644 --- a/tests/pass-readme-learn-align-2.nt +++ b/tests/pass-readme-learn-align-2.nt @@ -1,6 +1,6 @@ -{le} +!le 77 88 -@32~0xcc {-893.5:32} +@32~0xcc [-893.5:32] @128~0x55 "meow" --- 77 88 cc cc 00 60 5f c4 55 55 55 55 55 55 55 55 diff --git a/tests/pass-readme-learn-const-1.nt b/tests/pass-readme-learn-const-1.nt index ea2db9c..613562e 100644 --- a/tests/pass-readme-learn-const-1.nt +++ b/tests/pass-readme-learn-const-1.nt @@ -1,3 +1,3 @@ -ab cd [3d 8F] CC +ab cd (3d 8F) CC --- ab cd 3d 8f cc diff --git a/tests/pass-readme-learn-fill-2.nt b/tests/pass-readme-learn-fill-2.nt index fed70e9..2e818ef 100644 --- a/tests/pass-readme-learn-fill-2.nt +++ b/tests/pass-readme-learn-fill-2.nt @@ -1,5 +1,5 @@ !macro part(iter, fill) - <0> "particular security " {ord('0') + iter : 8} +fill~0x80 + <0> "particular security " [ord('0') + iter : 8] +fill~0x80 !end {iter = 1} diff --git a/tests/pass-readme-learn-fl-num-1.nt b/tests/pass-readme-learn-fl-num-1.nt index 63af0d7..48965e6 100644 --- a/tests/pass-readme-learn-fl-num-1.nt +++ b/tests/pass-readme-learn-fl-num-1.nt @@ -1,4 +1,4 @@ -{le} {345:16} -{be} {-0xabcd:32} +!le [345:16] +!be [-0xabcd:32] --- 59 01 ff ff 54 33 diff --git a/tests/pass-readme-learn-fl-num-2.nt b/tests/pass-readme-learn-fl-num-2.nt index 472c545..26d31fe 100644 --- a/tests/pass-readme-learn-fl-num-2.nt +++ b/tests/pass-readme-learn-fl-num-2.nt @@ -1,7 +1,7 @@ -{be} +!be # String length in bits -{8 * (str_end - str_beg) : 16} +[8 * (str_end - str_beg) : 16] # String diff --git a/tests/pass-readme-learn-fl-num-3.nt b/tests/pass-readme-learn-fl-num-3.nt index 9426048..a35d1bd 100644 --- a/tests/pass-readme-learn-fl-num-3.nt +++ b/tests/pass-readme-learn-fl-num-3.nt @@ -1,3 +1,3 @@ -{20 - ICITTE : 8} * 10 +[20 - ICITTE : 8] * 10 --- 14 13 12 11 10 0f 0e 0d 0c 0b diff --git a/tests/pass-readme-learn-fl-num-4.nt b/tests/pass-readme-learn-fl-num-4.nt index 6998c8f..c31ac6b 100644 --- a/tests/pass-readme-learn-fl-num-4.nt +++ b/tests/pass-readme-learn-fl-num-4.nt @@ -1,4 +1,4 @@ -{le} -{2 * 0.0529 : 32} +!le +[2 * 0.0529 : 32] --- ac ad d8 3d diff --git a/tests/pass-readme-learn-group-3.nt b/tests/pass-readme-learn-group-3.nt index 24b6943..fdb51a1 100644 --- a/tests/pass-readme-learn-group-3.nt +++ b/tests/pass-readme-learn-group-3.nt @@ -1,8 +1,8 @@ -{be} +!be ( u16le"sébastien diaz" - {ICITTE - str_beg : 8} - {(end - str_beg) * 5 : 24} + [ICITTE - str_beg : 8] + [(end - str_beg) * 5 : 24] ) * 3 --- diff --git a/tests/pass-readme-learn-leb128-1.nt b/tests/pass-readme-learn-leb128-1.nt index 189854a..f1af6eb 100644 --- a/tests/pass-readme-learn-leb128-1.nt +++ b/tests/pass-readme-learn-leb128-1.nt @@ -1,3 +1,3 @@ -{624485 : uleb128} +[624485 : uleb128] --- e5 8e 26 diff --git a/tests/pass-readme-learn-leb128-2.nt b/tests/pass-readme-learn-leb128-2.nt index 844c13e..8b2bb1b 100644 --- a/tests/pass-readme-learn-leb128-2.nt +++ b/tests/pass-readme-learn-leb128-2.nt @@ -1,7 +1,7 @@ aa bb cc dd ee ff -{-981238311 + (meow * -23) : sleb128} +[-981238311 + (meow * -23) : sleb128] "hello" --- aa bb cc dd ee ff fd fa 8d ac 7c 68 65 6c 6c 6f diff --git a/tests/pass-readme-learn-macro-def-1.nt b/tests/pass-readme-learn-macro-def-1.nt index a73d9f4..c3f9f98 100644 --- a/tests/pass-readme-learn-macro-def-1.nt +++ b/tests/pass-readme-learn-macro-def-1.nt @@ -1,5 +1,5 @@ !macro bake() - {le} {ICITTE * 8 : 16} + !le [ICITTE * 8 : 16] u16le"predict explode" !end diff --git a/tests/pass-readme-learn-macro-def-2.nt b/tests/pass-readme-learn-macro-def-2.nt index 10833da..c9ffede 100644 --- a/tests/pass-readme-learn-macro-def-2.nt +++ b/tests/pass-readme-learn-macro-def-2.nt @@ -2,8 +2,8 @@ {iter = 1} !repeat rep - {val + iter : uleb128} - {0xdeadbeef : 32} + [val + iter : uleb128] + [0xdeadbeef : 32] {iter = iter + 1} !end diff --git a/tests/pass-readme-learn-macro-exp-1.nt b/tests/pass-readme-learn-macro-exp-1.nt index 5d2a2e7..cfc9d5f 100644 --- a/tests/pass-readme-learn-macro-exp-1.nt +++ b/tests/pass-readme-learn-macro-exp-1.nt @@ -1,5 +1,5 @@ !macro bake() - {le} {ICITTE * 8 : 16} + !le [ICITTE * 8 : 16] u16le"predict explode" !end diff --git a/tests/pass-readme-learn-macro-exp-2.nt b/tests/pass-readme-learn-macro-exp-2.nt index 3cce7db..88995cb 100644 --- a/tests/pass-readme-learn-macro-exp-2.nt +++ b/tests/pass-readme-learn-macro-exp-2.nt @@ -1,11 +1,11 @@ !macro A(val, is_be) - {le} + !le !if is_be - {be} + !be !end - {val : 16} + [val : 16] !end !macro B(rep, is_be) diff --git a/tests/pass-readme-learn-macro-exp-3.nt b/tests/pass-readme-learn-macro-exp-3.nt index 865c682..3fe65e3 100644 --- a/tests/pass-readme-learn-macro-exp-3.nt +++ b/tests/pass-readme-learn-macro-exp-3.nt @@ -1,4 +1,4 @@ -!macro flt32be(val) {be} {val : 32} !end +!macro flt32be(val) !be [val : 32] !end "CHEETOS" m:flt32be(-42.17) diff --git a/tests/pass-readme-learn-offset-1.nt b/tests/pass-readme-learn-offset-1.nt index fc00ffd..4a68bfe 100644 --- a/tests/pass-readme-learn-offset-1.nt +++ b/tests/pass-readme-learn-offset-1.nt @@ -1,4 +1,4 @@ - {ICITTE : 8} * 8 -<0x61> {ICITTE : 8} * 8 + [ICITTE : 8] * 8 +<0x61> [ICITTE : 8] * 8 --- 00 01 02 03 04 05 06 07 61 62 63 64 65 66 67 68 diff --git a/tests/pass-readme-learn-offset-2.nt b/tests/pass-readme-learn-offset-2.nt index eb0ff57..1819075 100644 --- a/tests/pass-readme-learn-offset-2.nt +++ b/tests/pass-readme-learn-offset-2.nt @@ -1,5 +1,5 @@ aa bb cc dd ee ff <12> 11 22 33 44 55 -{meow : 8} {mix : 8} +[meow : 8] [mix : 8] --- aa bb cc dd ee ff 11 22 33 44 55 04 0f diff --git a/tests/pass-readme-learn-rep-blk-1.nt b/tests/pass-readme-learn-rep-blk-1.nt index 29f754f..048c2ae 100644 --- a/tests/pass-readme-learn-rep-blk-1.nt +++ b/tests/pass-readme-learn-rep-blk-1.nt @@ -1,5 +1,5 @@ !repeat 0o400 - {end - ICITTE - 1 : 8} + [end - ICITTE - 1 : 8] !end diff --git a/tests/pass-readme-learn-rep-blk-3-cond-0.nt b/tests/pass-readme-learn-rep-blk-3-cond-0.nt index 930dc62..3d52b1e 100644 --- a/tests/pass-readme-learn-rep-blk-3-cond-0.nt +++ b/tests/pass-readme-learn-rep-blk-3-cond-0.nt @@ -6,6 +6,6 @@ aa bb cc dd ee ff "meow mix" 00 !end -{be} {-1993:16} +!be [-1993:16] --- aa bb cc dd f8 37 diff --git a/tests/pass-readme-learn-rep-blk-3-cond-1.nt b/tests/pass-readme-learn-rep-blk-3-cond-1.nt index fbc6276..5152dd8 100644 --- a/tests/pass-readme-learn-rep-blk-3-cond-1.nt +++ b/tests/pass-readme-learn-rep-blk-3-cond-1.nt @@ -6,6 +6,6 @@ aa bb cc dd ee ff "meow mix" 00 !end -{be} {-1993:16} +!be [-1993:16] --- aa bb cc dd ee ff 6d 65 6f 77 20 6d 69 78 00 f8 37 diff --git a/tests/pass-readme-learn-rep-post-1.nt b/tests/pass-readme-learn-rep-post-1.nt index 74283c7..6cf6052 100644 --- a/tests/pass-readme-learn-rep-post-1.nt +++ b/tests/pass-readme-learn-rep-post-1.nt @@ -1,4 +1,4 @@ -{end - ICITTE - 1 : 8} * 0x100 +[end - ICITTE - 1 : 8] * 0x100 --- ff fe fd fc fb fa f9 f8 f7 f6 f5 f4 f3 f2 f1 f0 ef ee ed ec eb ea e9 e8 e7 e6 e5 e4 e3 e2 e1 e0 diff --git a/tests/pass-readme-learn-str-1.nt b/tests/pass-readme-learn-str-1.nt index 89d3962..8b0db96 100644 --- a/tests/pass-readme-learn-str-1.nt +++ b/tests/pass-readme-learn-str-1.nt @@ -1,7 +1,7 @@ {iter = 1} !repeat 10 - {iter : s:u8} " " + u8{iter} " " {iter = iter + 1} !end --- diff --git a/tests/pass-readme-learn-str-2.nt b/tests/pass-readme-learn-str-2.nt index 99d9240..76c876a 100644 --- a/tests/pass-readme-learn-str-2.nt +++ b/tests/pass-readme-learn-str-2.nt @@ -1,4 +1,4 @@ {meow = 'salut jérémie'} -{meow.upper() : s:latin1} +[meow.upper() : s:latin1] --- 53 41 4c 55 54 20 4a c9 52 c9 4d 49 45 diff --git a/tests/pass-readme-learn-trans.nt b/tests/pass-readme-learn-trans.nt index 88c0c90..90b25e5 100644 --- a/tests/pass-readme-learn-trans.nt +++ b/tests/pass-readme-learn-trans.nt @@ -9,7 +9,7 @@ @128~99h -!t qp {ICITTE - beg : 8} * 50 !end +!t qp [ICITTE - beg : 8] * 50 !end --- 88 88 88 88 88 88 88 88 88 88 88 88 88 88 88 88 38 4b 5f 47 59 2b 43 6f 26 2a 41 54 44 58 25 44 diff --git a/tests/pass-readme-learn-var.nt b/tests/pass-readme-learn-var.nt index f4aec02..f61cd6d 100644 --- a/tests/pass-readme-learn-var.nt +++ b/tests/pass-readme-learn-var.nt @@ -1,5 +1,5 @@ -{mix = 101} {le} -{meow = 42} 11 22 {meow:8} 33 {meow = ICITTE + 17} -"yooo" {meow + mix : 16} +{mix = 101} !le +{meow = 42} 11 22 [meow:8] 33 {meow = ICITTE + 17} +"yooo" [meow + mix : 16] --- 11 22 2a 33 79 6f 6f 6f 7a 00 diff --git a/tests/pass-rep-blk-all-bytes.nt b/tests/pass-rep-blk-all-bytes.nt index f875059..6357708 100644 --- a/tests/pass-rep-blk-all-bytes.nt +++ b/tests/pass-rep-blk-all-bytes.nt @@ -1,4 +1,4 @@ -!repeat 256 {ICITTE:8} !end +!repeat 256 [ICITTE:8] !end --- 00 01 02 03 04 05 06 07 08 09 0a 0b 0c 0d 0e 0f 10 11 12 13 14 15 16 17 18 19 1a 1b 1c 1d 1e 1f diff --git a/tests/pass-rep-post-all-bytes.nt b/tests/pass-rep-post-all-bytes.nt index 494f343..3343c1e 100644 --- a/tests/pass-rep-post-all-bytes.nt +++ b/tests/pass-rep-post-all-bytes.nt @@ -1,4 +1,4 @@ -{ICITTE:8} * 256 +[ICITTE:8] * 256 --- 00 01 02 03 04 05 06 07 08 09 0a 0b 0c 0d 0e 0f 10 11 12 13 14 15 16 17 18 19 1a 1b 1c 1d 1e 1f diff --git a/tests/pass-sleb128-1-byte.nt b/tests/pass-sleb128-1-byte.nt index 2357d11..9e76b51 100644 --- a/tests/pass-sleb128-1-byte.nt +++ b/tests/pass-sleb128-1-byte.nt @@ -1,3 +1,3 @@ -{-1 : sleb128} +[-1 : sleb128] --- 7f diff --git a/tests/pass-sleb128-10-bytes.nt b/tests/pass-sleb128-10-bytes.nt index 82df5a8..2428232 100644 --- a/tests/pass-sleb128-10-bytes.nt +++ b/tests/pass-sleb128-10-bytes.nt @@ -1,3 +1,3 @@ -{-6922985746849737371 : sleb128} +[-6922985746849737371 : sleb128] --- e5 aa b7 ef c8 a4 a7 f6 9f 7f diff --git a/tests/pass-sleb128-2-bytes.nt b/tests/pass-sleb128-2-bytes.nt index ad98ec9..37e127c 100644 --- a/tests/pass-sleb128-2-bytes.nt +++ b/tests/pass-sleb128-2-bytes.nt @@ -1,3 +1,3 @@ -{-116 : sleb128} +[-116 : sleb128] --- 8c 7f diff --git a/tests/pass-sleb128-3-bytes.nt b/tests/pass-sleb128-3-bytes.nt index fb7692d..49cbd44 100644 --- a/tests/pass-sleb128-3-bytes.nt +++ b/tests/pass-sleb128-3-bytes.nt @@ -1,3 +1,3 @@ -{-8680 : sleb128} +[-8680 : sleb128] --- 98 bc 7f diff --git a/tests/pass-sleb128-4-bytes.nt b/tests/pass-sleb128-4-bytes.nt index 6a51191..3c58d53 100644 --- a/tests/pass-sleb128-4-bytes.nt +++ b/tests/pass-sleb128-4-bytes.nt @@ -1,3 +1,3 @@ -{-2078359 : sleb128} +[-2078359 : sleb128] --- e9 92 81 7f diff --git a/tests/pass-sleb128-5-bytes.nt b/tests/pass-sleb128-5-bytes.nt index 3ae6c34..11a1968 100644 --- a/tests/pass-sleb128-5-bytes.nt +++ b/tests/pass-sleb128-5-bytes.nt @@ -1,3 +1,3 @@ -{-238633602 : sleb128} +[-238633602 : sleb128] --- fe fa 9a 8e 7f diff --git a/tests/pass-sleb128-6-bytes.nt b/tests/pass-sleb128-6-bytes.nt index 87c3855..c78256f 100644 --- a/tests/pass-sleb128-6-bytes.nt +++ b/tests/pass-sleb128-6-bytes.nt @@ -1,3 +1,3 @@ -{-23700055062 : sleb128} +[-23700055062 : sleb128] --- ea b7 f7 da a7 7f diff --git a/tests/pass-sleb128-7-bytes.nt b/tests/pass-sleb128-7-bytes.nt index a06be7f..d728fac 100644 --- a/tests/pass-sleb128-7-bytes.nt +++ b/tests/pass-sleb128-7-bytes.nt @@ -1,3 +1,3 @@ -{-3724280114436 : sleb128} +[-3724280114436 : sleb128] --- fc a5 ed fc cd 93 7f diff --git a/tests/pass-sleb128-8-bytes.nt b/tests/pass-sleb128-8-bytes.nt index 106b424..50ee283 100644 --- a/tests/pass-sleb128-8-bytes.nt +++ b/tests/pass-sleb128-8-bytes.nt @@ -1,3 +1,3 @@ -{-547712888934486 : sleb128} +[-547712888934486 : sleb128] --- aa df c3 be ba bb 83 7f diff --git a/tests/pass-sleb128-9-bytes.nt b/tests/pass-sleb128-9-bytes.nt index e2300a4..322f862 100644 --- a/tests/pass-sleb128-9-bytes.nt +++ b/tests/pass-sleb128-9-bytes.nt @@ -1,3 +1,3 @@ -{-56890538594315647 : sleb128} +[-56890538594315647 : sleb128] --- 81 a5 85 c0 b4 cb f8 9a 7f diff --git a/tests/pass-sleb128-limits.nt b/tests/pass-sleb128-limits.nt index f6b1f87..701b029 100644 --- a/tests/pass-sleb128-limits.nt +++ b/tests/pass-sleb128-limits.nt @@ -1,7 +1,7 @@ -{-65:sleb128} -{-64:sleb128} -{63:sleb128} -{64:sleb128} +[-65:sleb128] +[-64:sleb128] +[63:sleb128] +[64:sleb128] --- bf 7f 40 diff --git a/tests/pass-sleb128-minus-one.nt b/tests/pass-sleb128-minus-one.nt index 777a071..3a76037 100644 --- a/tests/pass-sleb128-minus-one.nt +++ b/tests/pass-sleb128-minus-one.nt @@ -1,3 +1,3 @@ -{-1:sleb128} +[-1:sleb128] --- 7f diff --git a/tests/pass-sleb128-zero.nt b/tests/pass-sleb128-zero.nt index 4e481af..d2cae9c 100644 --- a/tests/pass-sleb128-zero.nt +++ b/tests/pass-sleb128-zero.nt @@ -1,3 +1,3 @@ -{0:sleb128} +[0:sleb128] --- 00 diff --git a/tests/pass-str-post-bool.nt b/tests/pass-str-post-bool.nt index df32e1a..f642c53 100644 --- a/tests/pass-str-post-bool.nt +++ b/tests/pass-str-post-bool.nt @@ -1,5 +1,5 @@ -{False : s:latin1} -{True : s:latin1} +[False : s:latin1] +[True : s:latin1] --- 30 31 diff --git a/tests/pass-str-post-expr-lower.nt b/tests/pass-str-post-expr-lower.nt index 89313fb..56272c1 100644 --- a/tests/pass-str-post-expr-lower.nt +++ b/tests/pass-str-post-expr-lower.nt @@ -1,7 +1,7 @@ {meow = 'LÉGIFÉRER'} -{meow.lower() : s:latin1} -{ICITTE == len(meow) : 8} +[meow.lower() : s:latin1] +[ICITTE == len(meow) : 8] --- 6c e9 67 69 66 e9 72 65 72 01 diff --git a/tests/pass-str-post-latin.nt b/tests/pass-str-post-latin.nt index 70b96ea..3455602 100644 --- a/tests/pass-str-post-latin.nt +++ b/tests/pass-str-post-latin.nt @@ -1,13 +1,13 @@ -{"ãäåæçèéêëìíîïðñò" : s:latin1} -{"ăäĺćçčéęëěíîďđńň" : s:latin2} -{"µĥ·¸ışğĵ½żÀÁÂÄĊĈ" : s:latin3} -{"ãäåæįčéęëėíîīđņō" : s:latin4} -{"ãäåæçèéêëìíîïğñò" : s:latin5} -{"ÃÄÅÆĮČÉĘËĖÍÎÏÐŅŌ" : s:latin6} -{"ÓŌÕÖ×ŲŁŚŪÜŻŽßąįā" : s:latin7} -{"ãäåæçèéêëìíîïŵñò" : s:latin8} -{"ÃÄÅÆÇÈÉÊËÌÍÎÏÐÑÒ" : s:latin9} -{"łŽ”¶·žčș»ŒœŸżÀÁÂ" : s:latin10} +["ãäåæçèéêëìíîïðñò" : s:latin1] +["ăäĺćçčéęëěíîďđńň" : s:latin2] +["µĥ·¸ışğĵ½żÀÁÂÄĊĈ" : s:latin3] +["ãäåæįčéęëėíîīđņō" : s:latin4] +["ãäåæçèéêëìíîïğñò" : s:latin5] +["ÃÄÅÆĮČÉĘËĖÍÎÏÐŅŌ" : s:latin6] +["ÓŌÕÖ×ŲŁŚŪÜŻŽßąįā" : s:latin7] +["ãäåæçèéêëìíîïŵñò" : s:latin8] +["ÃÄÅÆÇÈÉÊËÌÍÎÏÐÑÒ" : s:latin9] +["łŽ”¶·žčș»ŒœŸżÀÁÂ" : s:latin10] --- e3 e4 e5 e6 e7 e8 e9 ea eb ec ed ee ef f0 f1 f2 e3 e4 e5 e6 e7 e8 e9 ea eb ec ed ee ef f0 f1 f2 diff --git a/tests/pass-str-post-utf.nt b/tests/pass-str-post-utf.nt index 4c74156..09c9205 100644 --- a/tests/pass-str-post-utf.nt +++ b/tests/pass-str-post-utf.nt @@ -1,10 +1,10 @@ {zoom = 'hello 🦊'} -{zoom : s:u8} -{zoom : s:u16be} -{zoom : s:u16le} -{zoom : s:u32be} -{zoom : s:u32le} +[zoom : s:u8] +[zoom : s:u16be] +[zoom : s:u16le] +[zoom : s:u32be] +[zoom : s:u32le] --- 68 65 6c 6c 6f 20 f0 9f a6 8a 00 68 00 65 00 6c 00 6c 00 6f 00 20 d8 3e dd 8a 68 00 65 00 6c 00 diff --git a/tests/pass-str-pre-float.nt b/tests/pass-str-pre-float.nt index bbd95af..c5db267 100644 --- a/tests/pass-str-pre-float.nt +++ b/tests/pass-str-pre-float.nt @@ -1,3 +1,3 @@ -{-23.42 : s:latin1} +[-23.42 : s:latin1] --- 2d 32 33 2e 34 32 diff --git a/tests/pass-str-pre-int.nt b/tests/pass-str-pre-int.nt index 4c3cd16..6fd2e1e 100644 --- a/tests/pass-str-pre-int.nt +++ b/tests/pass-str-pre-int.nt @@ -1,3 +1,3 @@ -{-42 : s:latin1} +[-42 : s:latin1] --- 2d 34 32 diff --git a/tests/pass-trans-a85.nt b/tests/pass-trans-a85.nt index 3bac685..3ddad87 100644 --- a/tests/pass-trans-a85.nt +++ b/tests/pass-trans-a85.nt @@ -1,11 +1,11 @@ !transform ascii85 "bonjour tout le monde" - {ICITTE - beg1 : 8} * 15 + [ICITTE - beg1 : 8] * 15 !end !t a85 "bonjour tout le monde" - {ICITTE - beg2 : 8} * 15 + [ICITTE - beg2 : 8] * 15 !end --- 40 57 2d 2e 21 44 66 70 28 43 46 44 6c 3b 44 2b diff --git a/tests/pass-trans-a85p.nt b/tests/pass-trans-a85p.nt index 3530a1f..68e6c1d 100644 --- a/tests/pass-trans-a85p.nt +++ b/tests/pass-trans-a85p.nt @@ -1,11 +1,11 @@ !transform ascii85p "bonjour tout le monde" - {ICITTE - beg1 : 8} * 15 + [ICITTE - beg1 : 8] * 15 !end !t a85p "bonjour tout le monde" - {ICITTE - beg2 : 8} * 15 + [ICITTE - beg2 : 8] * 15 !end --- 40 57 2d 2e 21 44 66 70 28 43 46 44 6c 3b 44 2b diff --git a/tests/pass-trans-b16.nt b/tests/pass-trans-b16.nt index 807e8f6..43eb869 100644 --- a/tests/pass-trans-b16.nt +++ b/tests/pass-trans-b16.nt @@ -1,11 +1,11 @@ !transform base16 "bonjour tout le monde" - {ICITTE - beg1 : 8} * 15 + [ICITTE - beg1 : 8] * 15 !end !t b16 "bonjour tout le monde" - {ICITTE - beg2 : 8} * 15 + [ICITTE - beg2 : 8] * 15 !end --- 36 32 36 46 36 45 36 41 36 46 37 35 37 32 32 30 diff --git a/tests/pass-trans-b32.nt b/tests/pass-trans-b32.nt index b7559bf..1c19c2d 100644 --- a/tests/pass-trans-b32.nt +++ b/tests/pass-trans-b32.nt @@ -1,11 +1,11 @@ !transform base32 "bonjour tout le monde" - {ICITTE - beg1 : 8} * 15 + [ICITTE - beg1 : 8] * 15 !end !t b32 "bonjour tout le monde" - {ICITTE - beg2 : 8} * 15 + [ICITTE - beg2 : 8] * 15 !end --- 4d 4a 58 57 34 32 54 50 4f 56 5a 43 41 35 44 50 diff --git a/tests/pass-trans-b64.nt b/tests/pass-trans-b64.nt index 641fd9b..96393c2 100644 --- a/tests/pass-trans-b64.nt +++ b/tests/pass-trans-b64.nt @@ -1,11 +1,11 @@ !transform base64 "bonjour tout le monde" - {ICITTE - beg1 : 8} * 15 + [ICITTE - beg1 : 8] * 15 !end !t b64 "bonjour tout le monde" - {ICITTE - beg2 : 8} * 15 + [ICITTE - beg2 : 8] * 15 !end --- 59 6d 39 75 61 6d 39 31 63 69 42 30 62 33 56 30 diff --git a/tests/pass-trans-b64u.nt b/tests/pass-trans-b64u.nt index c1398b7..964fcdc 100644 --- a/tests/pass-trans-b64u.nt +++ b/tests/pass-trans-b64u.nt @@ -1,11 +1,11 @@ !transform base64u "bonjour tout le monde" - {ICITTE - beg1 : 8} * 15 + [ICITTE - beg1 : 8] * 15 !end !t b64u "bonjour tout le monde" - {ICITTE - beg2 : 8} * 15 + [ICITTE - beg2 : 8] * 15 !end --- 59 6d 39 75 61 6d 39 31 63 69 42 30 62 33 56 30 diff --git a/tests/pass-trans-b85.nt b/tests/pass-trans-b85.nt index 85d00d5..d404fd2 100644 --- a/tests/pass-trans-b85.nt +++ b/tests/pass-trans-b85.nt @@ -1,11 +1,11 @@ !transform base85 "bonjour tout le monde" - {ICITTE - beg1 : 8} * 15 + [ICITTE - beg1 : 8] * 15 !end !t b85 "bonjour tout le monde" - {ICITTE - beg2 : 8} * 15 + [ICITTE - beg2 : 8] * 15 !end --- 56 73 43 44 30 5a 2a 5f 37 59 62 5a 3e 51 5a 41 diff --git a/tests/pass-trans-b85p.nt b/tests/pass-trans-b85p.nt index 99be8c7..5ced761 100644 --- a/tests/pass-trans-b85p.nt +++ b/tests/pass-trans-b85p.nt @@ -1,11 +1,11 @@ !transform base85p "bonjour tout le monde" - {ICITTE - beg1 : 8} * 15 + [ICITTE - beg1 : 8] * 15 !end !t b85p "bonjour tout le monde" - {ICITTE - beg2 : 8} * 15 + [ICITTE - beg2 : 8] * 15 !end --- 56 73 43 44 30 5a 2a 5f 37 59 62 5a 3e 51 5a 41 diff --git a/tests/pass-trans-qp.nt b/tests/pass-trans-qp.nt index 9341ff8..55faeed 100644 --- a/tests/pass-trans-qp.nt +++ b/tests/pass-trans-qp.nt @@ -1,11 +1,11 @@ !transform quopri "bonjour tout le monde" - {ICITTE - beg1 : 8} * 15 + [ICITTE - beg1 : 8] * 15 !end !t qp "bonjour tout le monde" - {ICITTE - beg2 : 8} * 15 + [ICITTE - beg2 : 8] * 15 !end --- 62 6f 6e 6a 6f 75 72 20 74 6f 75 74 20 6c 65 20 diff --git a/tests/pass-trans-qpt.nt b/tests/pass-trans-qpt.nt index d57af61..40b3d4f 100644 --- a/tests/pass-trans-qpt.nt +++ b/tests/pass-trans-qpt.nt @@ -1,11 +1,11 @@ !transform quoprit "bonjour tout le monde" - {ICITTE - beg1 : 8} * 15 + [ICITTE - beg1 : 8] * 15 !end !t qpt "bonjour tout le monde" - {ICITTE - beg2 : 8} * 15 + [ICITTE - beg2 : 8] * 15 !end --- 62 6f 6e 6a 6f 75 72 3d 32 30 74 6f 75 74 3d 32 diff --git a/tests/pass-uleb128-1-byte.nt b/tests/pass-uleb128-1-byte.nt index 83443d3..7bde458 100644 --- a/tests/pass-uleb128-1-byte.nt +++ b/tests/pass-uleb128-1-byte.nt @@ -1,3 +1,3 @@ -{2 : uleb128} +[2 : uleb128] --- 02 diff --git a/tests/pass-uleb128-10-bytes.nt b/tests/pass-uleb128-10-bytes.nt index 538032d..b65acaa 100644 --- a/tests/pass-uleb128-10-bytes.nt +++ b/tests/pass-uleb128-10-bytes.nt @@ -1,3 +1,3 @@ -{11662943340368564545 : uleb128} +[11662943340368564545 : uleb128] --- c1 a2 b4 b1 cd a5 c6 ed a1 01 diff --git a/tests/pass-uleb128-2-bytes.nt b/tests/pass-uleb128-2-bytes.nt index 36e3e84..6cd1892 100644 --- a/tests/pass-uleb128-2-bytes.nt +++ b/tests/pass-uleb128-2-bytes.nt @@ -1,3 +1,3 @@ -{138 : uleb128} +[138 : uleb128] --- 8a 01 diff --git a/tests/pass-uleb128-3-bytes.nt b/tests/pass-uleb128-3-bytes.nt index 651acd4..eb8847e 100644 --- a/tests/pass-uleb128-3-bytes.nt +++ b/tests/pass-uleb128-3-bytes.nt @@ -1,3 +1,3 @@ -{22454 : uleb128} +[22454 : uleb128] --- b6 af 01 diff --git a/tests/pass-uleb128-4-bytes.nt b/tests/pass-uleb128-4-bytes.nt index d970f5a..64c6afd 100644 --- a/tests/pass-uleb128-4-bytes.nt +++ b/tests/pass-uleb128-4-bytes.nt @@ -1,3 +1,3 @@ -{3003030 : uleb128} +[3003030 : uleb128] --- 96 a5 b7 01 diff --git a/tests/pass-uleb128-5-bytes.nt b/tests/pass-uleb128-5-bytes.nt index 64c0b9f..b5b2ce2 100644 --- a/tests/pass-uleb128-5-bytes.nt +++ b/tests/pass-uleb128-5-bytes.nt @@ -1,3 +1,3 @@ -{480029143 : uleb128} +[480029143 : uleb128] --- d7 d3 f2 e4 01 diff --git a/tests/pass-uleb128-6-bytes.nt b/tests/pass-uleb128-6-bytes.nt index 41187ec..2bbf80d 100644 --- a/tests/pass-uleb128-6-bytes.nt +++ b/tests/pass-uleb128-6-bytes.nt @@ -1,3 +1,3 @@ -{65632604596 : uleb128} +[65632604596 : uleb128] --- b4 a3 88 c0 f4 01 diff --git a/tests/pass-uleb128-7-bytes.nt b/tests/pass-uleb128-7-bytes.nt index 849ad0e..c758048 100644 --- a/tests/pass-uleb128-7-bytes.nt +++ b/tests/pass-uleb128-7-bytes.nt @@ -1,3 +1,3 @@ -{5790353763547 : uleb128} +[5790353763547 : uleb128] --- db d9 ea df c2 a8 01 diff --git a/tests/pass-uleb128-8-bytes.nt b/tests/pass-uleb128-8-bytes.nt index 7f483c5..d321857 100644 --- a/tests/pass-uleb128-8-bytes.nt +++ b/tests/pass-uleb128-8-bytes.nt @@ -1,3 +1,3 @@ -{946008033604205 : uleb128} +[946008033604205 : uleb128] --- ed e4 b0 c6 ba 8c d7 01 diff --git a/tests/pass-uleb128-9-bytes.nt b/tests/pass-uleb128-9-bytes.nt index d7394a4..6b5f948 100644 --- a/tests/pass-uleb128-9-bytes.nt +++ b/tests/pass-uleb128-9-bytes.nt @@ -1,3 +1,3 @@ -{119795752416646235 : uleb128} +[119795752416646235 : uleb128] --- db a8 94 a3 a2 b3 e6 d4 01 diff --git a/tests/pass-uleb128-expr-label-inner.nt b/tests/pass-uleb128-expr-label-inner.nt index a89a8de..f1ecaeb 100644 --- a/tests/pass-uleb128-expr-label-inner.nt +++ b/tests/pass-uleb128-expr-label-inner.nt @@ -3,7 +3,7 @@ aa bb cc dd - {meow * 500 : uleb128} + [meow * 500 : uleb128] ee ff ) * 2 22 diff --git a/tests/pass-uleb128-expr-label.nt b/tests/pass-uleb128-expr-label.nt index c96fb13..244070e 100644 --- a/tests/pass-uleb128-expr-label.nt +++ b/tests/pass-uleb128-expr-label.nt @@ -1,7 +1,7 @@ aa bb 11 22 -{meow * 199 : uleb128} +[meow * 199 : uleb128] ee ff --- aa bb diff --git a/tests/pass-uleb128-expr-var.nt b/tests/pass-uleb128-expr-var.nt index 3f89282..c15e79f 100644 --- a/tests/pass-uleb128-expr-var.nt +++ b/tests/pass-uleb128-expr-var.nt @@ -1,6 +1,6 @@ aa bb {meow = 1111} -cc {meow : uleb128} +cc [meow : uleb128] ee ff --- aa bb diff --git a/tests/pass-uleb128-limits.nt b/tests/pass-uleb128-limits.nt index 993531b..6c89011 100644 --- a/tests/pass-uleb128-limits.nt +++ b/tests/pass-uleb128-limits.nt @@ -1,5 +1,5 @@ -{127:uleb128} -{128:uleb128} +[127:uleb128] +[128:uleb128] --- 7f 80 01 diff --git a/tests/pass-uleb128-zero.nt b/tests/pass-uleb128-zero.nt index d206294..58a20a9 100644 --- a/tests/pass-uleb128-zero.nt +++ b/tests/pass-uleb128-zero.nt @@ -1,3 +1,3 @@ -{0:uleb128} +[0:uleb128] --- 00 diff --git a/tests/pass-var-float.nt b/tests/pass-var-float.nt index c66ac10..5a20dce 100644 --- a/tests/pass-var-float.nt +++ b/tests/pass-var-float.nt @@ -1,3 +1,3 @@ -{be} aa {meow = 32.5} bb {meow : 32} cc +!be aa {meow = 32.5} bb [meow : 32] cc --- aa bb 42 02 00 00 cc diff --git a/tests/pass-var-icitte.nt b/tests/pass-var-icitte.nt index 0567810..f2e7884 100644 --- a/tests/pass-var-icitte.nt +++ b/tests/pass-var-icitte.nt @@ -1,5 +1,5 @@ aa bb cc {meow = ICITTE + 3} dd ee ff -{meow : 8} +[meow : 8] --- aa bb cc dd ee ff 06 diff --git a/tests/pass-var-label.nt b/tests/pass-var-label.nt index a1796c7..7ff95e4 100644 --- a/tests/pass-var-label.nt +++ b/tests/pass-var-label.nt @@ -1,8 +1,8 @@ -<11> {be} aa +<11> !be aa bb cc dd*5 {mix = meow} ee -{mix:8} +[mix:8] ff --- aa diff --git a/tests/pass-var.nt b/tests/pass-var.nt index e0501ff..b861e29 100644 --- a/tests/pass-var.nt +++ b/tests/pass-var.nt @@ -1,12 +1,12 @@ {var = 0x18} aa bb -{var:8} +[var:8] cc dd {var = var - ICITTE} {mix = meow + 23} -{var:8} -{mix:8} +[var:8] +[mix:8] --- aa bb 18 diff --git a/tests/test_api.py b/tests/test_api.py index 77afebf..6a03564 100644 --- a/tests/test_api.py +++ b/tests/test_api.py @@ -26,20 +26,20 @@ import normand def test_init_labels(): labels = {"yo": 0x88, "meow": 123} # type: normand.LabelsT - res = normand.parse("11 22 {yo:8} 33", init_labels=labels.copy()) + res = normand.parse("11 22 [yo:8] 33", init_labels=labels.copy()) assert res.data == bytearray([0x11, 0x22, 0x88, 0x33]) assert res.labels == labels.copy() def test_init_vars(): variables = {"zoom": 0x88, "bateau": -123.45} # type: normand.VariablesT - res = normand.parse("11 22 {zoom:8} 33", init_variables=variables.copy()) + res = normand.parse("11 22 [zoom:8] 33", init_variables=variables.copy()) assert res.data == bytearray([0x11, 0x22, 0x88, 0x33]) assert res.variables == variables.copy() def test_init_offset(): - res = normand.parse("11 22 {ICITTE:8} 33", init_offset=0x23) + res = normand.parse("11 22 [ICITTE:8] 33", init_offset=0x23) assert res.data == bytearray([0x11, 0x22, 0x25, 0x33]) assert res.offset == 0x27 @@ -51,7 +51,7 @@ def _test_init_bo(bo: normand.ByteOrder): if bo == normand.ByteOrder.LE: h_byte, l_byte = l_byte, h_byte - res = normand.parse("11 22 {-1993:16} 33", init_byte_order=bo) + res = normand.parse("11 22 [-1993:16] 33", init_byte_order=bo) assert res.data == bytearray([0x11, 0x22, h_byte, l_byte, 0x33]) assert res.byte_order == bo @@ -91,17 +91,17 @@ def test_final_offset(): def test_final_byte_order_none(): - res = normand.parse("11 22 33 {-19:8} 44 55") + res = normand.parse("11 22 33 [-19:8] 44 55") assert res.byte_order is None def test_final_byte_order_be(): - res = normand.parse("11 22 {le} 33 {-19:8} 44 ( {be} 88 ) * 3 55") + res = normand.parse("11 22 !le 33 [-19:8] 44 ( !be 88 ) * 3 55") assert res.byte_order == normand.ByteOrder.BE def test_final_byte_order_le(): - res = normand.parse("11 22 {be} 33 {-19:8} 44 ( {le} 88 ) * 3 55") + res = normand.parse("11 22 !be 33 [-19:8] 44 ( !le 88 ) * 3 55") assert res.byte_order == normand.ByteOrder.LE -- 2.34.1