a data type parser

FM - This page aimed to present an expr-like language to parse data type.
With it, given this definition :

ParseType {
        {char*}bytes
        x {size}refCount
        x {Tcl_ObjType*}type
        x { {{void*}ptr1 x {void*}ptr2}twoPtr 
            + {{void*}ptr x {size}size}PtrAndSize
        }InternalRep
}

You can produce this tree, defining a very well-know type in Tcl :

                                                              START
                                                                |
                                        ┌────────────────────── x ────────────────────────────┐
                                        |                      (9)                            |  
                        ┌────────────── x ──────────┐                                ┌─────── } ────┐
                        |              (6)          |                                |       (26)  InternalRep
        ┌────────────── x ──────┐             ┌──── } ─────┐                         { (10)
        |              (3)      |             |    (8)    type                       |
┌────── } ─────┐        ┌────── } ─────┐      { (7)                   ┌───────────── + ───────────────┐
|      (2)   bytes      |      (5)  refCount  |                       |          (18)                 |
{ (1)                   { (4)                 |             ┌──────── } ───────┐               ┌───── } ───────┐
|                       |                Tcl_ObjType*       |        (17)   twoPtr             |     (25)   PtrAndSize
char*                  size                                 { (11)                             { (19)             
                                                            |                                  |
                                                  ┌──────── x ──────┐                  ┌────── x ───────────┐
                                                  |        (14)     |                  |      (22)          |
                                          ┌────── } ──────┐   ┌──── } ────┐      ┌──── } ────┐       ┌───── } ─────┐
                                          |      (13)     |   |    (16)   |      |    (21)   |       |     (24)    |
                                          { (12)        ptr1  { (15)     ptr2    { (20)     ptr      { (23)       size
                                          |                   |                  |                   |
                                        void*               void*              void*               size            

It used the same principles explained in the page a better way to do indexation.
The Tree is given as a list of dicts, each dict beeing one NODE, and two list of Operands : TYPES / NAMES.
The tree is made to be explored in the expr way, from left to right, then to parent, picking the operand types in order.
It's just the parsing for now, but an idea could be to produce JIT compilation with it, thanks to tcc4tcl, for instance.

Type definition

I get inspired by OCAML principles. At least, we can distinguish Sum Types (aka C-Unions) and Product Types (aka C-struct).
OCAML use | to denots a Sum (c-Union), I choose to use +. OCAML use * to denots a Product (c-Struct), I choose to use x.

# OCAML
type size = Small | Normal | Big
type garniture = Vegan | Chicken | Beef
type sauce = Cheese | Curry | Harissa | Samurai

type tacos = taille * garniture * sauce

# The way I plan :
type def size Small + Normal + Big
type def garnish Vegan + Chicken + Beef
type def sauce Cheese + Curry + Harissa + Samurai

type def tacos  {size}size x {garnish}garnish x {sauce}sauce

# The goal :
# assignement :
set {tacos}T size Normal garnish Beef sauce Harisso; # generalized prefix and dict like-syntax
# Bad sauce value : "Harisso" , should be : Cheese + Curry + Harissa + Samurai
set {tacos}T size Normal garnish Beef sauce Harissa
# get value :
set {tacos}T(size,garnish) ; # generalized prefix and generalized index !
# -> Normal Beef
puts {tacos}$T(sauce)
# -> Harissa