pub struct AdamParser { /* private fields */ }Expand description
Parses adam-lang source strings into live ParsedSheets (sheet + cell names).
§Example
use adam_lang::{AdamParser, TypeRegistry};
use cel_parser::OpLookup;
let mut parser = AdamParser::new(TypeRegistry::new(), OpLookup::new());
let parsed = parser.parse_str("sheet s { cell x: i32 = 0; }").unwrap();Implementations§
Source§impl AdamParser
impl AdamParser
Sourcepub fn new(types: TypeRegistry, op_lookup: OpLookup) -> Self
pub fn new(types: TypeRegistry, op_lookup: OpLookup) -> Self
Creates a parser with the given type registry and operation lookup.
op_lookup is forwarded to the embedded [CELParser] when compiling method
body expressions. See
OpLookup::push_library_scope for how to
install a function library (e.g. cel-std) before parsing. The embedded CEL parser also
receives a snapshot of types’ registered scalar leaf names so typed array annotations
such as []: [Custom] resolve custom Adam types during direct parsing.
Sourcepub fn op_lookup_mut(&mut self) -> &mut OpLookup
pub fn op_lookup_mut(&mut self) -> &mut OpLookup
Returns a mutable reference to the embedded CEL operation lookup.
Sourcepub fn parse_str(&mut self, source: &str) -> Result<ParsedSheet, ParseError>
pub fn parse_str(&mut self, source: &str) -> Result<ParsedSheet, ParseError>
Parses an adam-lang source string into a live ParsedSheet.
Resets internal parse state on each call.
§Errors
Returns Err on any syntax error, unknown type name, type mismatch between a
cell annotation and its initializer, undeclared cell name in a relationship binding’s
output list, or a tuple arity/element-type mismatch between the output expression
and its declared outputs.