microcad_lang/parse/mod.rs
1// Copyright © 2024-2025 The µcad authors <info@ucad.xyz>
2// SPDX-License-Identifier: AGPL-3.0-or-later
3
4//! Source code parsing
5//!
6//! A source file on disc is just a bunch of UTF-8 encoded text which must be parsed
7//! before any processing:
8//!
9//! ```no_run
10//! use microcad_lang::{syntax::*, parse::*};
11//!
12//! let source_file = SourceFile::load("my.µcad").expect("parsing success");
13//! ```
14//!
15//! To read a source file from an already loaded string use:
16//!
17//! ```no_run
18//! use microcad_lang::{syntax::*, parse::*};
19//!
20//! let source_file = SourceFile::load_from_str("test", "test.µcad", r#"std::print("hello world!");"#).expect("parsing success");
21//! ```
22//!
23//! To "run" the source file (and get the expected output) it must now be resolved and evaluated (see [`crate::resolve`] and [`crate::eval`]) .
24
25mod attribute;
26mod body;
27mod call;
28mod doc_block;
29mod expression;
30mod format_string;
31mod function;
32mod identifier;
33mod init_definition;
34mod lang_type;
35mod literal;
36mod module;
37mod parameter;
38mod source_file;
39mod statement;
40mod r#type;
41mod r#use;
42mod workbench;
43
44pub(crate) mod find_rule;
45pub(crate) mod parse_error;
46
47pub use find_rule::*;
48pub use parse_error::*;
49
50use crate::{src_ref::*, syntax::*};
51const INTERNAL_PARSE_ERROR: &str = "internal parse error";