Parsing fn headers

This commit is contained in:
2023-07-03 17:19:19 -05:00
parent 429d57c632
commit b05edb6ed4
2 changed files with 154 additions and 2 deletions
+7 -2
View File
@@ -47,8 +47,13 @@ block = { "{" ~ statement* ~ "}" }
function = { "fn" ~ name ~ annotations? ~ argnames ~ block }
annotations = { "<" ~ (annotation ~ ("," ~ annotation)*) ~ ">" }
annotation = { "inline" | ("org=" ~ number) | ("type=" ~ name) }
argnames = { "(" ~ (name ~ typename? ~ ("," ~ name ~ typename?)*)? ~ ")" }
annotation = { inline_annotation | org_annotation | type_annotation }
inline_annotation = { "inline" }
org_annotation = { "org=" ~ number }
type_annotation = { "type=" ~ name }
argnames = { "(" ~ (argname ~ ("," ~ argname)*)? ~ ")" }
argname = { name ~ typename? }
declaration = { function | global | struct_decl | const_decl }
program = { (COMMENT | WHITESPACE)? ~ declaration* ~ EOI }