|
In C, literal integers default to a 32-bit size for arithmetic
operations. Unfortunately, this was causing incorrect values to be
assigned to our uint64_t variables, leading to unexpected behavior.
To resolve this issue, we have updated our code to explicitly set the
literal size using the "ULL" suffix (unsigned long long).
It's important to note that this implementation has a limitation of 64
levels of indentation. Beyond this point, we may encounter a 64-bit
overflow. However, at present, we don't anticipate the need to visualize
trees that exceed this depth. If this requirement arises in the future,
we can explore solutions like dynamically creating new numbers to
accommodate larger tree sizes.
Overall, this change ensures that our code is functioning correctly and
improves the reliability of our codebase.
Signed-off-by: Johnny Richard <johnny@johnnyrichard.com>
|
|
Parsing can be a complex process, and it's not always easy to get a
clear picture of what's happening with the AST. This commit adds a new
feature to the CLI that allows us to pretty-print the AST (outputs to
stdout), making it easier to visualize the tree structure and understand
how the parser is working.
The new --ast-dump option generates a human-readable representation of
the AST, including node types, values, and child relationships. This
information can be invaluable for debugging and understanding the
parser's behavior.
Signed-off-by: Johnny Richard <johnny@johnnyrichard.com>
Reviewed-by: Carlos Maniero <carlos@maniero.me>
|