1pub mod ast;
21pub mod lexer;
22pub mod parser;
23
24pub use ast::*;
25pub use lexer::{Token, TokenKind};
26pub use parser::{ParseError, ParseResult, Parser};
27
28pub fn parse(input: &str) -> ParseResult<UclDocument> {
30 let mut parser = Parser::new(input);
31 parser.parse_document()
32}
33
34pub fn parse_commands(input: &str) -> ParseResult<Vec<Command>> {
36 let mut parser = Parser::new(input);
37 parser.parse_commands_only()
38}
39
40#[cfg(test)]
41mod tests {
42 use super::*;
43
44 #[test]
45 fn test_parse_simple_document() {
46 let input = r#"
47STRUCTURE
48blk_000000000000: [blk_111111111111]
49
50BLOCKS
51text #blk_111111111111 label="Introduction" :: "Hello, world!"
52
53COMMANDS
54EDIT blk_111111111111 SET content.text = "Updated text"
55"#;
56
57 let doc = parse(input).unwrap();
58 assert!(!doc.structure.is_empty());
59 assert!(!doc.blocks.is_empty());
60 assert!(!doc.commands.is_empty());
61 }
62}