1
0
dust/dust-lang/src/lib.rs

52 lines
1.3 KiB
Rust
Raw Normal View History

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;
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;
pub mod token;
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};
pub use dust_error::DustError;
2024-09-07 03:30:43 +00:00
pub use identifier::Identifier;
pub use lexer::{LexError, Lexer};
pub use parser::{ParseError, Parser};
pub use r#type::{EnumType, FunctionType, RangeableType, StructType, Type, TypeConflict};
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)
}
}