Skip to main content

AdamParser

Struct AdamParser 

Source
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

Source

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.

Source

pub fn op_lookup_mut(&mut self) -> &mut OpLookup

Returns a mutable reference to the embedded CEL operation lookup.

Source

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.

Auto Trait Implementations§

Blanket Implementations§

Source§

impl<T> Any for T
where T: 'static + ?Sized,

Source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
Source§

impl<T> Borrow<T> for T
where T: ?Sized,

Source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
Source§

impl<T> BorrowMut<T> for T
where T: ?Sized,

Source§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
Source§

impl<T> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

Source§

impl<T, U> Into<U> for T
where U: From<T>,

Source§

fn into(self) -> U

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

Source§

impl<T> Same for T

Source§

type Output = T

Should always be Self
Source§

impl<T, U> TryFrom<U> for T
where U: Into<T>,

Source§

type Error = Infallible

The type returned in the event of a conversion error.
Source§

fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>

Performs the conversion.
Source§

impl<T, U> TryInto<U> for T
where U: TryFrom<T>,

Source§

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.
Source§

fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

Performs the conversion.