Skip to content

Commit

Permalink
WIP
Browse files Browse the repository at this point in the history
  • Loading branch information
arthurpaulino committed Aug 9, 2023
1 parent 4b23a1b commit 985efe9
Show file tree
Hide file tree
Showing 8 changed files with 236 additions and 202 deletions.
7 changes: 6 additions & 1 deletion src/cli/repl.rs
Original file line number Diff line number Diff line change
Expand Up @@ -780,7 +780,12 @@ impl Repl<F> {
}

loop {
match editor.readline("> ") {
match editor.readline(&format!(
"{}> ",
self.state
.borrow()
.fmt_to_string(self.state.borrow().get_current_package_name())
)) {
Ok(line) => {
#[cfg(not(target_arch = "wasm32"))]
editor.save_history(history_path)?;
Expand Down
2 changes: 1 addition & 1 deletion src/lem/store.rs
Original file line number Diff line number Diff line change
Expand Up @@ -236,7 +236,7 @@ impl<F: LurkField> Store<F> {
Syntax::Symbol(_, symbol) => Ok(self.intern_symbol(&symbol)),
Syntax::String(_, x) => Ok(self.intern_string(&x)),
Syntax::Quote(pos, x) => {
let xs = vec![Syntax::Symbol(pos, lurk_sym("quote")), *x];
let xs = vec![Syntax::Symbol(pos, lurk_sym("quote").into()), *x];
self.intern_syntax(Syntax::List(pos, xs))
}
Syntax::List(_, xs) => {
Expand Down
17 changes: 3 additions & 14 deletions src/parser.rs
Original file line number Diff line number Diff line change
Expand Up @@ -32,8 +32,6 @@ pub enum Error {
NoInput,
#[error("Syntax error: {0}")]
Syntax(String),
#[error("Interning error: {0}")]
Interning(String),
}

impl<F: LurkField> Store<F> {
Expand All @@ -42,10 +40,7 @@ impl<F: LurkField> Store<F> {
match preceded(syntax::parse_space, syntax::parse_syntax(state, false))
.parse(Span::new(input))
{
Ok((_i, x)) => match self.intern_syntax(x) {
Ok(ptr) => Ok(ptr),
Err(e) => Err(Error::Interning(format!("{}", e))),
},
Ok((_i, x)) => Ok(self.intern_syntax(x)),
Err(e) => Err(Error::Syntax(format!("{}", e))),
}
}
Expand All @@ -58,10 +53,7 @@ impl<F: LurkField> Store<F> {
match preceded(syntax::parse_space, syntax::parse_syntax(state, false))
.parse(Span::new(input))
{
Ok((_i, x)) => match self.intern_syntax(x) {
Ok(ptr) => Ok(ptr),
Err(e) => Err(Error::Interning(format!("{}", e))),
},
Ok((_i, x)) => Ok(self.intern_syntax(x)),
Err(e) => Err(Error::Syntax(format!("{}", e))),
}
}
Expand All @@ -73,10 +65,7 @@ impl<F: LurkField> Store<F> {
) -> Result<(Span<'a>, Ptr<F>, bool), Error> {
use syntax::*;
match preceded(parse_space, parse_maybe_meta(state)).parse(input) {
Ok((i, Some((is_meta, x)))) => match self.intern_syntax(x) {
Ok(ptr) => Ok((i, ptr, is_meta)),
Err(e) => Err(Error::Interning(format!("{}", e))),
},
Ok((i, Some((is_meta, x)))) => Ok((i, self.intern_syntax(x), is_meta)),
Ok((_, None)) => Err(Error::NoInput),
Err(e) => Err(Error::Syntax(format!("{}", e))),
}
Expand Down
Loading

0 comments on commit 985efe9

Please sign in to comment.