ast: Merge Ty into Pat, merge Mod and Fn into Bind

This commit is contained in:
2025-10-20 04:24:21 -04:00
parent 22094f4862
commit b80a3a55c3
4 changed files with 188 additions and 338 deletions

View File

@@ -1,6 +1,6 @@
//! Tests the lexer
use doughlang::{
ast::{Anno, Pat, Ty},
ast::{Anno, Pat},
parser::PPrec,
};
#[allow(unused_imports)]
@@ -45,10 +45,6 @@ fn main() -> Result<(), Box<dyn Error>> {
pats()?;
Ok(Response::Deny)
}
"ty" => {
tys()?;
Ok(Response::Deny)
}
"macro" => {
if let Err(e) = subst() {
println!("\x1b[31m{e}\x1b[0m");
@@ -141,29 +137,6 @@ fn pats() -> Result<(), Box<dyn Error>> {
Ok(())
}
fn tys() -> Result<(), Box<dyn Error>> {
clear();
read_and("\x1b[94m", ".>", " >", |line| {
let mut parser = Parser::new(Lexer::new(line));
if line.trim().is_empty() {
return Ok(Response::Break);
}
loop {
match parser.parse::<Ty>(()) {
Err(ParseError::FromLexer(LexError { res: EOF, .. })) => {
break Ok(Response::Accept);
}
Err(e) => {
println!("\x1b[31m{e}\x1b[0m");
break Ok(Response::Deny);
}
Ok(v) => println!("{v}\n{v:#?}"),
}
}
})?;
Ok(())
}
fn subst() -> Result<(), Box<dyn Error>> {
let mut rl = repline::Repline::new("\x1b[35mexp", " >", "?>");
let exp = rl.read()?;