cl-parser: Transliterate to a trait-based parsing implementation
Bump version number.
This commit is contained in:
@@ -2,6 +2,7 @@
|
||||
|
||||
use std::{error::Error, path::PathBuf};
|
||||
|
||||
use cl_ast::Expr;
|
||||
use cl_interpret::{convalue::ConValue, env::Environment};
|
||||
use cl_lexer::Lexer;
|
||||
use cl_parser::{inliner::ModuleInliner, Parser};
|
||||
@@ -18,7 +19,7 @@ fn main() -> Result<(), Box<dyn Error>> {
|
||||
let parent = path.parent().unwrap_or("".as_ref());
|
||||
|
||||
let code = std::fs::read_to_string(&path)?;
|
||||
let code = Parser::new(Lexer::new(&code)).file()?;
|
||||
let code = Parser::new(Lexer::new(&code)).parse()?;
|
||||
let code = match ModuleInliner::new(parent).inline(code) {
|
||||
Ok(code) => code,
|
||||
Err((code, ioerrs, perrs)) => {
|
||||
@@ -40,7 +41,7 @@ fn main() -> Result<(), Box<dyn Error>> {
|
||||
let args = args
|
||||
.flat_map(|arg| {
|
||||
Parser::new(Lexer::new(&arg))
|
||||
.expr()
|
||||
.parse::<Expr>()
|
||||
.map(|arg| env.eval(&arg))
|
||||
})
|
||||
.collect::<Result<Vec<_>, _>>()?;
|
||||
|
||||
@@ -48,6 +48,7 @@ mod macros {
|
||||
//! ```
|
||||
#![allow(unused_macros)]
|
||||
use crate::IResult;
|
||||
use cl_parser::parser::Parse;
|
||||
|
||||
use super::*;
|
||||
|
||||
@@ -63,14 +64,14 @@ mod macros {
|
||||
///
|
||||
/// Returns a `Result<`[`File`]`, ParseError>`
|
||||
pub macro file($($t:tt)*) {
|
||||
Parser::new(Lexer::new(stringify!( $($t)* ))).file()
|
||||
File::parse(&mut Parser::new(Lexer::new(stringify!( $($t)* ))))
|
||||
}
|
||||
|
||||
/// Stringifies, lexes, and parses everything you give to it
|
||||
///
|
||||
/// Returns a `Result<`[`Block`]`, ParseError>`
|
||||
pub macro block($($t:tt)*) {
|
||||
Parser::new(Lexer::new(stringify!({ $($t)* }))).block()
|
||||
Block::parse(&mut Parser::new(Lexer::new(stringify!({ $($t)* }))))
|
||||
}
|
||||
|
||||
/// Evaluates a block of code in the given environment
|
||||
|
||||
Reference in New Issue
Block a user