asdlGen
Reference Manual
: Input Syntax
: Type Definitions
: Field LabelsField declarations can be as simple as a single type identifier, or they can
be followed with an optional label. Labels aid in the readability of
descriptions and are used by asdlGen
to name the fields of records
and classes for languages. For example the declarations
module Tree {
tree = Node(int, tree, tree)
| EmptyTree
}
can also be written as
module Tree {
tree = Node(int value, tree left, tree right)
| EmptyTree
}
When translating the first definition without labels into C one would normally get
...
struct Tree_tree_s {
union {
struct { int_ty int1; Tree_tree_ty tree1; Tree_tree_ty tree2; } ...
} v
}
...
with labels one would get
...
struct Tree_tree_s {
union {
struct { int_ty value; Tree_tree_ty left; Tree_tree_ty right; } ...
} v
}
...
asdlGen
Reference Manual
: Input Syntax
: Type Definitions
: Field Labels