1
0

Fix doc tests; Clean up

This commit is contained in:
Jeff 2024-09-05 13:16:26 -04:00
parent c42fca496b
commit 9349724bac
2 changed files with 4 additions and 9 deletions

View File

@ -54,7 +54,7 @@ pub fn analyze(source: &str) -> Result<(), DustError> {
/// let input = "x = 1 + false"; /// let input = "x = 1 + false";
/// let abstract_tree = parse(input).unwrap(); /// let abstract_tree = parse(input).unwrap();
/// let context = Context::new(); /// let context = Context::new();
/// let mut analyzer = Analyzer::new(&abstract_tree, context); /// let mut analyzer = Analyzer::new(&abstract_tree);
/// let result = analyzer.analyze(); /// let result = analyzer.analyze();
/// ///
/// assert!(!analyzer.errors.is_empty()); /// assert!(!analyzer.errors.is_empty());
@ -353,8 +353,6 @@ impl<'a> Analyzer<'a> {
Expression::Identifier(identifier) => { Expression::Identifier(identifier) => {
let context_data = context.get_data(&identifier.inner)?; let context_data = context.get_data(&identifier.inner)?;
println!("{:?}", context_data);
if let Some(ContextData::Reserved) | None = context_data { if let Some(ContextData::Reserved) | None = context_data {
self.errors.push(AnalysisError::UndefinedVariable { self.errors.push(AnalysisError::UndefinedVariable {
identifier: identifier.clone(), identifier: identifier.clone(),

View File

@ -70,20 +70,17 @@ pub fn parse(source: &str) -> Result<AbstractSyntaxTree, DustError> {
/// let source = "x = 42"; /// let source = "x = 42";
/// let lexer = Lexer::new(source); /// let lexer = Lexer::new(source);
/// let mut parser = Parser::new(lexer); /// let mut parser = Parser::new(lexer);
/// let mut statements = VecDeque::new(); /// let mut ast = AbstractSyntaxTree::new();
/// ///
/// loop { /// 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() { /// if parser.is_eof() {
/// break; /// break;
/// } /// }
/// } /// }
///
/// let tree = AbstractSyntaxTree { statements };
///
/// ``` /// ```
pub struct Parser<'src> { pub struct Parser<'src> {
lexer: Lexer<'src>, lexer: Lexer<'src>,