Added some initial directive code. Don't quite like the way it's done

This commit is contained in:
2025-09-03 21:05:00 +02:00
parent 603b625e21
commit 4924b01eac
4 changed files with 50 additions and 29 deletions

View File

@@ -19,15 +19,6 @@ Parse_State :: struct {
////////////////////////////
//@nb - Result and error handling
// Parse_Result :: struct {
// root : *AST_Node;
// nodes : [..]AST_Node;
// had_error : bool;
// messages : [..]Compiler_Message;
// }
Parse_Error_Kind :: enum {
Parse_Error_Type_Missing;
Parse_Error_Expected_Expression;
@@ -616,6 +607,23 @@ directive :: (state : *Parse_State) -> *AST_Node {
func := function_declaration(state, identifier_token, .None, false, false);
func.foreign_declaration = true;
return func;
} else if state.current.ident_value == "if" {
if_directive := make_node(state, .If_Directive);
source_location : Source_Range;
// source_location.begin = state.previous;
advance(state);
cond := expression(state);
add_child(if_directive, cond);
if_body := block(state);
add_child(if_directive, if_body);
if_directive.source_location = source_location;
return if_directive;
}
return null;