From 9349724bac8efc4fb4620693bad96c90786fb725 Mon Sep 17 00:00:00 2001 From: Jeff Date: Thu, 5 Sep 2024 13:16:26 -0400 Subject: [PATCH] Fix doc tests; Clean up --- dust-lang/src/analyzer.rs | 4 +--- dust-lang/src/parser.rs | 9 +++------ 2 files changed, 4 insertions(+), 9 deletions(-) diff --git a/dust-lang/src/analyzer.rs b/dust-lang/src/analyzer.rs index 0a51d10..e2c4f29 100644 --- a/dust-lang/src/analyzer.rs +++ b/dust-lang/src/analyzer.rs @@ -54,7 +54,7 @@ pub fn analyze(source: &str) -> Result<(), DustError> { /// let input = "x = 1 + false"; /// let abstract_tree = parse(input).unwrap(); /// let context = Context::new(); -/// let mut analyzer = Analyzer::new(&abstract_tree, context); +/// let mut analyzer = Analyzer::new(&abstract_tree); /// let result = analyzer.analyze(); /// /// assert!(!analyzer.errors.is_empty()); @@ -353,8 +353,6 @@ impl<'a> Analyzer<'a> { Expression::Identifier(identifier) => { let context_data = context.get_data(&identifier.inner)?; - println!("{:?}", context_data); - if let Some(ContextData::Reserved) | None = context_data { self.errors.push(AnalysisError::UndefinedVariable { identifier: identifier.clone(), diff --git a/dust-lang/src/parser.rs b/dust-lang/src/parser.rs index 010487f..37338c2 100644 --- a/dust-lang/src/parser.rs +++ b/dust-lang/src/parser.rs @@ -70,20 +70,17 @@ pub fn parse(source: &str) -> Result { /// let source = "x = 42"; /// let lexer = Lexer::new(source); /// let mut parser = Parser::new(lexer); -/// let mut statements = VecDeque::new(); +/// let mut ast = AbstractSyntaxTree::new(); /// /// loop { -/// let statement = parser.parse_statement().unwrap(); +/// let statement = parser.parse_statement(&ast.context).unwrap(); /// -/// statements.push_back(statement); +/// ast.statements.push_back(statement); /// /// if parser.is_eof() { /// break; /// } /// } -/// -/// let tree = AbstractSyntaxTree { statements }; -/// /// ``` pub struct Parser<'src> { lexer: Lexer<'src>,