os

An operating system
git clone https://erai.gay/code/os/
Log | Files | Refs | README | LICENSE

commit 47f0f9e3dbc1c93b48c5b64434c4be0543aa25b2
parent a562fa2ea0f45650cbd9656ed4e9b22f7e666736
Author: erai <erai@omiltem.net>
Date:   Wed, 20 Nov 2024 22:54:35 -0500

allow func to define a function

Diffstat:
Mcc0.c | 20+++++++++++++-------
Mcc3.peg | 4++--
2 files changed, 15 insertions(+), 9 deletions(-)

diff --git a/cc0.c b/cc0.c @@ -6732,7 +6732,19 @@ unsigned long( my_peg_P_func)(struct my_peg* my_c){ unsigned long( my_peg_P_func_decl)(struct my_peg* my_c){ unsigned long my_ok = 0; (my_enter)((my_c),(my_P_func_decl)); + (my_choice)((my_c)); + (my_ok)=((my_literal)((my_c),((unsigned char *)"func"))); + if (my_ok) { + (my_commit)((my_c)); + } else { + (my_ok)=(1UL); + } + if (my_ok) { + (my_ok)=((my_peg_P_sp)((my_c))); + } + if (my_ok) { (my_ok)=((my_peg_P_ident)((my_c))); + } if (my_ok) { (my_ok)=((my_peg_P_sp)((my_c))); } @@ -7146,18 +7158,12 @@ unsigned long( my_peg_P_int)(struct my_peg* my_c){ unsigned long( my_peg_P_label_stmt)(struct my_peg* my_c){ unsigned long my_ok = 0; (my_enter)((my_c),(my_P_label_stmt)); - (my_ok)=((my_literal)((my_c),((unsigned char *)":"))); - if (my_ok) { - (my_ok)=((my_peg_P_sp)((my_c))); - } - if (my_ok) { (my_ok)=((my_peg_P_ident)((my_c))); - } if (my_ok) { (my_ok)=((my_peg_P_sp)((my_c))); } if (my_ok) { - (my_ok)=((my_literal)((my_c),((unsigned char *)";"))); + (my_ok)=((my_literal)((my_c),((unsigned char *)":"))); } if (my_ok) { (my_ok)=((my_peg_P_sp)((my_c))); diff --git a/cc3.peg b/cc3.peg @@ -7,7 +7,7 @@ member_decl <- ident sp ':' sp type ';' sp struct_decl <- struct sp ident sp '{' sp member_decl* '}' sp union_decl <- union sp ident sp '{' sp member_decl* '}' sp -func_decl <- ident sp func_type (';' sp / compound_stmt) +func_decl <- 'func'? sp ident sp func_type (';' sp / compound_stmt) type <- ident sp / byte sp / int sp / void sp / func sp func_type / ptr_type / '(' sp type ')' sp @@ -36,7 +36,7 @@ return_stmt <- return sp expr? sp ';' sp var_stmt <- var sp ident sp ':' sp type ';' sp -label_stmt <- ':' sp ident sp ';' sp +label_stmt <- ident sp ':' sp goto_stmt <- goto sp ident sp ';' sp