fic/parser/mod.rs
1//! Parser module for the Fiducia language
2//!
3//! This module provides parsers for Fiducia language files:
4//! - `.fis` files: System description (memory regions, protection domains, channels)
5//! - `.fi` files: Program implementation (imports, mappings, IRQs)
6//!
7//! # Module Organization
8//!
9//! - [`allocator`]: Virtual address and channel ID allocation
10//! - `data`: Data-layer grammar (struct/const declarations), shared by the
11//! `.fis` and `.fi` surfaces
12//! - [`expr`]: Expression grammar
13//! - [`lexer`]: Shared lexer primitives (keywords, tokens, identifiers, comments)
14//! - [`program`]: Grammar rules for `.fi` files
15//! - [`statement`]: Statement grammar (variable declarations, assignments, calls)
16//! - [`system`]: Grammar rules for `.fis` files, including channel and data-layer
17//! (struct/const) declarations — all top-level `.fis` items
18//! - [`types`]: Type expression grammar and information flow security label keywords
19//! - [`crate::ast`]: AST node type definitions
20//! - [`crate::error`]: Compiler diagnostics with source-annotated rendering
21//!
22//! # Examples
23//!
24//! Parse a system description (`.fis`):
25//!
26//! ```
27//! let system = fic::parser::parse_system("ProtectionDomain pd1(100);").unwrap();
28//! assert_eq!(system.protection_domains.len(), 1);
29//! ```
30//!
31//! Parse a program implementation (`.fi`):
32//!
33//! ```
34//! let program = fic::parser::parse_program(r#"import "eth.c" as eth;"#).unwrap();
35//! assert_eq!(program.imports.len(), 1);
36//! ```
37
38pub mod lexer;
39
40pub mod expr;
41pub mod statement;
42pub mod types;
43
44mod data;
45mod recovery;
46
47pub mod event;
48pub mod process;
49pub mod program;
50pub mod system;
51
52pub use crate::error::{format_errors, Diagnostic, Diagnostics};
53pub use crate::foreign::parse as parse_foreign;
54pub use lexer::{identifier, keyword, reserved, symbol, ws, Input, PResult};
55
56pub use expr::parse as parse_expr;
57pub use statement::parse as parse_statement;
58pub use types::parse as parse_types;
59pub use types::security_label;
60pub use types::typed_param;
61
62pub use event::parse as parse_event;
63pub use event::parse_evt_decl;
64pub use process::parse as parse_process;
65pub use program::parse as parse_program;
66pub use system::parse as parse_system;