2024-08-05 04:54:12 +00:00
|
|
|
//! The Dust programming language.
|
|
|
|
//!
|
2024-08-13 22:27:03 +00:00
|
|
|
//! To get started, you can use the `run` function to run a Dust program.
|
|
|
|
//!
|
|
|
|
//! ```rust
|
|
|
|
//! use dust_lang::{run, Value};
|
|
|
|
//!
|
|
|
|
//! let program = "
|
2024-08-23 21:27:11 +00:00
|
|
|
//! let foo = 21
|
|
|
|
//! let bar = 2
|
2024-08-13 22:27:03 +00:00
|
|
|
//! foo * bar
|
|
|
|
//! ";
|
|
|
|
//!
|
|
|
|
//! let the_answer = run(program).unwrap();
|
|
|
|
//!
|
|
|
|
//! assert_eq!(the_answer, Some(Value::integer(42)));
|
|
|
|
//! ```
|
2024-09-07 10:38:12 +00:00
|
|
|
pub mod chunk;
|
2024-08-20 06:25:22 +00:00
|
|
|
pub mod constructor;
|
2024-09-07 08:34:03 +00:00
|
|
|
pub mod dust_error;
|
2024-03-25 04:16:55 +00:00
|
|
|
pub mod identifier;
|
2024-09-07 03:30:43 +00:00
|
|
|
pub mod lexer;
|
|
|
|
pub mod parser;
|
2024-09-07 16:15:47 +00:00
|
|
|
pub mod run;
|
2024-09-07 03:30:43 +00:00
|
|
|
pub mod token;
|
2024-08-02 20:33:40 +00:00
|
|
|
pub mod r#type;
|
2024-02-26 21:27:01 +00:00
|
|
|
pub mod value;
|
2024-09-07 10:38:12 +00:00
|
|
|
pub mod vm;
|
2024-02-23 12:40:01 +00:00
|
|
|
|
2024-09-07 10:38:12 +00:00
|
|
|
pub use chunk::{Chunk, ChunkError};
|
2024-09-07 03:30:43 +00:00
|
|
|
pub use constructor::{ConstructError, Constructor};
|
2024-09-07 08:34:03 +00:00
|
|
|
pub use dust_error::DustError;
|
2024-09-07 03:30:43 +00:00
|
|
|
pub use identifier::Identifier;
|
|
|
|
pub use lexer::{LexError, Lexer};
|
2024-09-07 16:15:47 +00:00
|
|
|
pub use parser::{parse, ParseError, Parser};
|
2024-09-07 03:30:43 +00:00
|
|
|
pub use r#type::{EnumType, FunctionType, RangeableType, StructType, Type, TypeConflict};
|
2024-09-07 16:15:47 +00:00
|
|
|
pub use run::run;
|
2024-09-07 03:30:43 +00:00
|
|
|
pub use token::{Token, TokenKind, TokenOwned};
|
|
|
|
pub use value::{Struct, Value, ValueError};
|
2024-09-07 10:38:12 +00:00
|
|
|
pub use vm::{Instruction, Vm};
|
2024-09-06 23:27:16 +00:00
|
|
|
|
|
|
|
use std::fmt::{self, Display, Formatter};
|
|
|
|
|
|
|
|
use serde::{Deserialize, Serialize};
|
|
|
|
|
|
|
|
#[derive(Debug, Clone, Copy, Eq, PartialEq, PartialOrd, Ord, Serialize, Deserialize)]
|
|
|
|
pub struct Span(usize, usize);
|
|
|
|
|
|
|
|
impl Display for Span {
|
|
|
|
fn fmt(&self, f: &mut Formatter) -> fmt::Result {
|
|
|
|
write!(f, "({}, {})", self.0, self.1)
|
|
|
|
}
|
|
|
|
}
|