Fix doc tests; Clean up
This commit is contained in:
parent
c42fca496b
commit
9349724bac
@ -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(),
|
||||||
|
@ -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>,
|
||||||
|
Loading…
Reference in New Issue
Block a user