Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions crates/val-wasm/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -7,8 +7,8 @@ use {
serde::Serialize,
serde_wasm_bindgen::to_value,
val::{
AssignmentTarget, Environment, Evaluator, Expression, Program,
RoundingMode, Span, Statement,
Environment, Evaluator, RoundingMode, Span,
ast::{AssignmentTarget, Expression, Program, Statement},
},
wasm_bindgen::prelude::*,
};
Expand Down
6 changes: 3 additions & 3 deletions src/arguments.rs
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
use super::*;

#[derive(Clap, Debug)]
#[derive(Debug, Parser)]
#[clap(
about,
author,
Expand All @@ -15,7 +15,7 @@ use super::*;
{all-args}{after-help}
"
)]
pub struct Arguments {
pub(crate) struct Arguments {
#[clap(
short,
long,
Expand Down Expand Up @@ -212,7 +212,7 @@ impl Arguments {
}
}

pub fn run(self) -> Result {
pub(crate) fn run(self) -> Result {
match (&self.filename, &self.expression) {
(Some(filename), _) => self.eval(filename),
(_, Some(expression)) => self.evaluate_expression(expression.clone()),
Expand Down
6 changes: 2 additions & 4 deletions src/error.rs
Original file line number Diff line number Diff line change
Expand Up @@ -14,10 +14,8 @@ impl Error {
}
}

pub(crate) fn report<'a>(
&self,
id: &'a str,
) -> Report<'a, (&'a str, Range<usize>)> {
#[must_use]
pub fn report<'a>(&self, id: &'a str) -> Report<'a, (&'a str, Range<usize>)> {
let span_range = self.span.into_range();

let mut report = Report::build(
Expand Down
69 changes: 22 additions & 47 deletions src/lib.rs
Original file line number Diff line number Diff line change
@@ -1,41 +1,40 @@
pub(crate) use {
crate::{builtins::BUILTINS, consts::with_consts},
ariadne::{Color, Label, Report, ReportKind, Source},
use {
ariadne::{Color, Label, Report, ReportKind},
ast::{AssignmentTarget, BinaryOp, Expression, Program, Statement, UnaryOp},
astro_float::{BigFloat as Float, Consts, Radix, Sign},
builtins::BUILTINS,
chumsky::prelude::*,
clap::Parser as Clap,
consts::with_consts,
std::{
cell::RefCell,
collections::HashMap,
fmt::{self, Display, Formatter},
fs,
ops::Range,
path::PathBuf,
process,
str::FromStr,
},
};

#[cfg(not(target_family = "wasm"))]
pub(crate) use {
crate::highlighter::Highlighter,
regex::Regex,
rustyline::{
Context, Editor, Helper,
completion::{Completer, FilenameCompleter, Pair},
config::{Builder, ColorMode, CompletionType, EditMode},
error::ReadlineError,
highlight::{CmdKind, Highlighter as RustylineHighlighter},
hint::{Hinter, HistoryHinter},
history::DefaultHistory,
validate::Validator,
},
std::borrow::Cow::{self, Owned},
pub use crate::{
builtin::{Builtin, BuiltinFunction, BuiltinFunctionPayload},
completion::Completion,
config::Config,
environment::Environment,
error::Error,
evaluator::Evaluator,
float_ext::FloatExt,
function::Function,
parser::parse,
rounding_mode::RoundingMode,
value::Value,
};

pub type Span = SimpleSpan<usize>;
pub type Spanned<T> = (T, Span);

type Result<T = (), E = anyhow::Error> = std::result::Result<T, E>;
type Spanned<T> = (T, Span);

mod ast;
pub mod ast;
mod builtin;
mod builtins;
mod completion;
Expand All @@ -50,27 +49,3 @@ mod function;
mod parser;
mod rounding_mode;
mod value;

#[doc(hidden)]
pub mod arguments;

#[cfg(not(target_family = "wasm"))]
mod highlighter;

pub use crate::{
arguments::Arguments,
ast::{AssignmentTarget, BinaryOp, Expression, Program, Statement, UnaryOp},
builtin::{Builtin, BuiltinFunction, BuiltinFunctionPayload},
completion::Completion,
config::Config,
environment::Environment,
error::Error,
evaluator::Evaluator,
float_ext::FloatExt,
function::Function,
parser::parse,
rounding_mode::RoundingMode,
value::Value,
};

pub type Span = SimpleSpan<usize>;
39 changes: 36 additions & 3 deletions src/main.rs
Original file line number Diff line number Diff line change
@@ -1,10 +1,43 @@
use {
arguments::Arguments,
ariadne::Source,
clap::Parser,
rustyline::error::ReadlineError,
std::{backtrace::BacktraceStatus, process, thread},
val::arguments::Arguments,
highlighter::Highlighter,
regex::Regex,
rounding_mode::RoundingMode,
rustyline::{
Context, Editor, Helper,
completion::{Completer, FilenameCompleter, Pair},
config::{Builder, ColorMode, CompletionType, EditMode},
error::ReadlineError,
highlight::{CmdKind, Highlighter as RustylineHighlighter},
hint::{Hinter, HistoryHinter},
history::DefaultHistory,
validate::Validator,
},
std::{
backtrace::BacktraceStatus,
borrow::{Cow, Cow::Owned},
fmt::{self, Display, Formatter},
fs,
path::PathBuf,
process,
str::FromStr,
thread,
},
val::{
Config, Environment, Evaluator, Spanned, Value,
ast::{AssignmentTarget, Expression, Program, Statement},
parse,
},
};

mod arguments;
mod highlighter;
mod rounding_mode;

type Result<T = (), E = anyhow::Error> = std::result::Result<T, E>;

fn main() {
let arguments = Arguments::parse();

Expand Down
6 changes: 3 additions & 3 deletions src/rounding_mode.rs
Original file line number Diff line number Diff line change
Expand Up @@ -11,8 +11,8 @@ pub enum RoundingMode {
Up = 2,
}

impl std::fmt::Display for RoundingMode {
fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result {
impl Display for RoundingMode {
fn fmt(&self, f: &mut Formatter<'_>) -> fmt::Result {
let s = match self {
RoundingMode::Down => "down",
RoundingMode::FromZero => "from-zero",
Expand All @@ -26,7 +26,7 @@ impl std::fmt::Display for RoundingMode {
}
}

impl std::str::FromStr for RoundingMode {
impl FromStr for RoundingMode {
type Err = String;

fn from_str(s: &str) -> Result<Self, Self::Err> {
Expand Down
Loading