1
0

Pass all tests

This commit is contained in:
Jeff 2024-08-23 17:27:11 -04:00
parent e45ac042b9
commit 511cc10e98
3 changed files with 9 additions and 9 deletions

View File

@ -54,11 +54,11 @@ pub fn analyze(source: &str) -> Result<(), DustError> {
/// # use dust_lang::*; /// # use dust_lang::*;
/// let input = "x = 1 + false"; /// let input = "x = 1 + false";
/// let abstract_tree = parse(input).unwrap(); /// let abstract_tree = parse(input).unwrap();
/// let mut context = Context::new(); /// let context = Context::new();
/// let mut analyzer = Analyzer::new(&abstract_tree, &mut context); /// let mut analyzer = Analyzer::new(&abstract_tree, context);
/// let result = analyzer.analyze(); /// let result = analyzer.analyze();
/// ///
/// assert!(result.is_err()); /// assert!(!analyzer.errors.is_empty());
pub struct Analyzer<'a> { pub struct Analyzer<'a> {
abstract_tree: &'a AbstractSyntaxTree, abstract_tree: &'a AbstractSyntaxTree,
context: Context, context: Context,

View File

@ -6,8 +6,8 @@
//! use dust_lang::{run, Value}; //! use dust_lang::{run, Value};
//! //!
//! let program = " //! let program = "
//! foo = 21 //! let foo = 21
//! bar = 2 //! let bar = 2
//! foo * bar //! foo * bar
//! "; //! ";
//! //!

View File

@ -34,7 +34,7 @@ use crate::{
/// # use dust_lang::value::Value; /// # use dust_lang::value::Value;
/// let result = run("40 + 2"); /// let result = run("40 + 2");
/// ///
/// assert_eq!(result, Ok(Some(Value::Integer(42)))); /// assert_eq!(result, Ok(Some(Value::integer(42))));
/// ``` /// ```
pub fn run(source: &str) -> Result<Option<Value>, DustError> { pub fn run(source: &str) -> Result<Option<Value>, DustError> {
let context = core_library().create_child(); let context = core_library().create_child();
@ -46,15 +46,15 @@ pub fn run(source: &str) -> Result<Option<Value>, DustError> {
/// ///
/// # Example /// # Example
/// ``` /// ```
/// # use dust_lang::{Context, Identifier, Value, run_with_context}; /// # use dust_lang::*;
/// let context = Context::new(); /// let context = Context::new();
/// ///
/// context.set_value(Identifier::new("foo"), Value::Integer(40)); /// context.set_variable_value(Identifier::new("foo"), Value::integer(40));
/// context.update_last_position(&Identifier::new("foo"), (100, 100)); /// context.update_last_position(&Identifier::new("foo"), (100, 100));
/// ///
/// let result = run_with_context("foo + 2", context); /// let result = run_with_context("foo + 2", context);
/// ///
/// assert_eq!(result, Ok(Some(Value::Integer(42)))); /// assert_eq!(result, Ok(Some(Value::integer(42))));
/// ``` /// ```
pub fn run_with_context(source: &str, context: Context) -> Result<Option<Value>, DustError> { pub fn run_with_context(source: &str, context: Context) -> Result<Option<Value>, DustError> {
let abstract_syntax_tree = parse(source)?; let abstract_syntax_tree = parse(source)?;