Expand description
Parser for Fiducia Program Implementation (.fi) files.
Implements grammar rules for parsing .fi files, which define per-protection-domain
implementations: imports of external C/Pancake files, memory mappings, flat event
declarations (evt), and flat process definitions (proc).
§Grammar summary
program ::= item*
item ::= import_decl | mapping_decl | local_var | evt_decl | proc_decl
import_decl ::= 'import' '"' path '"' 'as' ident ';'
mapping_decl ::= label? 'Mapping' ident '(' ident (',' hex)? ',' string (',' bool)? ')' ';'
local_var ::= ident ':' Type ';' -- a local variable: the program's, its PD's state
evt_decl ::= 'evt' ident carriers? ':' stmt*
proc_decl ::= bind? 'proc' UIdent '(' params? ')' '{' process_body '}'
bind ::= '@bind' '(' ident '.' ident (',' ident '.' ident)* ')'evt and proc declarations may appear in any order; forward references
are resolved during name resolution.
§Example
let input = r#"
import "eth.c" as eth;
Mapping ring_buffer(ring_buffer_outer, "rw", false);
Mapping packet_buffer(packet_buffer_outer, "rw");
"#;
let program = fic::parser::parse_program(input).unwrap();
assert_eq!(program.imports.len(), 1);
assert_eq!(program.mappings.len(), 2);Functions§
- parse
- Parse a
.fiprogram implementation with error recovery.