summaryrefslogtreecommitdiff
path: root/src/main.c
AgeCommit message (Collapse)Author
2023-05-10namespaces: Add a namespace structure that represents a fileCarlos Maniero
We have been always parsing a single function. Since we want to have multiple functions in a near future, this patch introduces an namespace that represents an entire file. To ensure a function is defined inside a namespace, a helper function was created. Today our ast_node structure is highly exposed, and this is something that Johnny and I have been discussed. So then, this is a first step to try to protected the code generation from our ast tree. Signed-off-by: Carlos Maniero <carlos@maniero.me>
2023-05-10gas: Removes Linux entrypoint logic from function declarationCarlos Maniero
Before this commit, function declarations were making syscalls to interrupt the flow. This is a fair approach considering all our examples just have a main function. But won't work if the namespace has more then a single function. The return now always sets the return value on RAX and jumps to the function return label. The function return label, will restore RBP and jump back to callee's next instruction using RET instruction. Function labels are kept, which means that a function called my_fn will have the assembly label my_fn, so then, they can have INTEROP with other languages. Signed-off-by: Carlos Maniero <carlos@maniero.me>
2023-05-05cli: Add AST pretty-printing option (--ast-dump)Johnny Richard
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>
2023-05-03cli: Rename src/pipac.c to src/main.cJohnny Richard
I found easier to understand the application entrypoint by calling it main.c. Signed-off-by: Johnny Richard <johnny@johnnyrichard.com>