Function cbork_cddl_parser::parse_cddl

source ·
pub fn parse_cddl<'a>(
    input: &'a mut String,
    extension: &Extension,
) -> Result<AST<'a>, Box<CDDLError>>
Expand description

Parses and checks semantically a CDDL input string.

§Arguments

  • input - A string containing the CDDL input to be parsed.

§Returns

Returns Ok(()) if parsing is successful, otherwise returns an Err containing a boxed CDDLError indicating the parsing error.

§Errors

This function may return an error in the following cases:

  • If there is an issue with parsing the CDDL input.

§Examples

use cbork_cddl_parser::{parse_cddl, Extension};
use std:fs;

let mut input = fs::read_to_string("path/to/your/file.cddl").unwrap();
let result = parse_cddl(&mut input, &Extension::CDDLParser);
assert!(result.is_ok());