Module parse

Module parse 

Source
Expand description

Source code parsing

A source file on disc is just a bunch of UTF-8 encoded text which must be parsed before any processing:

use microcad_lang::{syntax::*, parse::*};

let source_file = SourceFile::load("my.µcad").expect("parsing success");

To read a source file from an already loaded string use:

use microcad_lang::{syntax::*, parse::*};

let source_file = SourceFile::load_from_str("test", "test.µcad", r#"std::print("hello world!");"#).expect("parsing success");

To “run” the source file (and get the expected output) it must now be resolved and evaluated (see crate::resolve and crate::eval) .

Macros§

find_rule
Find rule or use default with proper error handling.
find_rule_exact
Find rule and return definition or ParseError::NotAvailable with proper error handling.
find_rule_opt
Find rule and return optional with proper error handling.

Enums§

ParseError
Parsing errors

Functions§

find_rule
Find rule with proper error handling.

Type Aliases§

ParseResult
Result with parse error