Add bool values to parser, and bool nodes to ast

This commit is contained in:
Krzosa Karol
2022-06-02 23:48:03 +02:00
parent 2909214ee0
commit e2e684294e
5 changed files with 38 additions and 46 deletions

View File

@@ -10,6 +10,8 @@ Intern_String keyword_union;
Intern_String keyword_return;
Intern_String keyword_if;
Intern_String keyword_else;
Intern_String keyword_true;
Intern_String keyword_false;
Intern_String keyword_for;
Intern_String keyword_pass;
Intern_String keyword_cast;
@@ -58,6 +60,8 @@ struct Parse_Ctx:Lexer{
keyword_struct= intern("struct"_s);
keyword_union = intern("union"_s);
keyword_cast = intern("cast"_s);
keyword_true = intern("true"_s);
keyword_false = intern("false"_s);
keyword_return = intern("return"_s);
keyword_if = intern("if"_s);
keyword_pass = intern("pass"_s);
@@ -283,7 +287,7 @@ struct Ast_Package:Ast{
function Ast_Atom *
ast_str(Token *pos, Intern_String string){
AST_NEW(Atom, VALUE, pos, AST_EXPR | AST_ATOM);
result->type = type_string; // @todo untyped
result->type = type_string;
result->intern_val = string;
return result;
}
@@ -295,10 +299,18 @@ ast_ident(Token *pos, Intern_String string){
return result;
}
function Ast_Atom *
ast_bool(Token *pos, B32 bool_val){
AST_NEW(Atom, VALUE, pos, AST_EXPR | AST_ATOM);
result->bool_val = bool_val;
result->type = type_bool;
return result;
}
function Ast_Atom *
ast_float(Token *pos, F64 value){
AST_NEW(Atom, VALUE, pos, AST_EXPR | AST_ATOM);
result->type = type_f64; // @todo untyped
result->type = type_f64;
result->f64_val = value;
return result;
}
@@ -306,7 +318,7 @@ ast_float(Token *pos, F64 value){
function Ast_Atom *
ast_int(Token *pos, S64 integer){
AST_NEW(Atom, VALUE, pos, AST_EXPR | AST_ATOM);
result->type = type_int; // @todo untyped
result->type = type_int;
result->int_val = integer;
return result;
}