cl-ast: Move AST definition into its own crate

This commit is contained in:
John 2024-02-29 19:49:50 -06:00
parent 6e1d5af134
commit 1afde9ce35
15 changed files with 29 additions and 19 deletions

View File

@ -5,6 +5,7 @@ members = [
"cl-interpret",
"cl-structures",
"cl-token",
"cl-ast",
]
resolver = "2"

11
cl-ast/Cargo.toml Normal file
View File

@ -0,0 +1,11 @@
[package]
name = "cl-ast"
repository.workspace = true
version.workspace = true
authors.workspace = true
edition.workspace = true
license.workspace = true
publish.workspace = true
[dependencies]
cl-structures = { path = "../cl-structures" }

View File

@ -9,6 +9,8 @@
//! - [AssignKind], [BinaryKind], and [UnaryKind] operators
//! - [Ty] and [TyKind]: Type qualifiers
//! - [Path]: Path expressions
#![feature(decl_macro)]
use cl_structures::span::*;
pub mod ast_impl;

View File

@ -9,4 +9,5 @@ publish.workspace = true
[dependencies]
conlang = { path = "../libconlang" }
cl-ast = { path = "../cl-ast" }
cl-structures = { path = "../cl-structures" }

View File

@ -6,7 +6,7 @@
//! one in any situation.
use super::*;
use conlang::ast::*;
use cl_ast::*;
/// A work-in-progress tree walk interpreter for Conlang
pub trait Interpret {
/// Interprets this thing in the given [`Environment`].

View File

@ -297,7 +297,7 @@ pub mod interpret;
pub mod function {
//! Represents a block of code which lives inside the Interpreter
use super::{Callable, ConValue, Environment, Error, IResult, Interpret};
use conlang::ast::{Function as FnDecl, Identifier, Param};
use cl_ast::{Function as FnDecl, Identifier, Param};
/// Represents a block of code which persists inside the Interpreter
#[derive(Clone, Debug)]
pub struct Function {
@ -354,7 +354,7 @@ pub mod env {
temp_type_impl::ConValue,
BuiltIn, Callable, Interpret,
};
use conlang::ast::{Function as FnDecl, Identifier};
use cl_ast::{Function as FnDecl, Identifier};
use std::{
collections::HashMap,
fmt::Display,

View File

@ -1,6 +1,7 @@
#![allow(unused_imports)]
use crate::{env::Environment, temp_type_impl::ConValue, Interpret};
use conlang::{ast::*, lexer::Lexer, parser::Parser};
use cl_ast::*;
use conlang::{lexer::Lexer, parser::Parser};
pub use macros::*;
mod macros {
@ -208,7 +209,7 @@ mod fn_declarations {
}
mod operators {
use conlang::ast::Tuple;
use cl_ast::Tuple;
use super::*;
#[test]

View File

@ -11,6 +11,7 @@ publish.workspace = true
[dependencies]
conlang = { path = "../libconlang" }
cl-ast = { path = "../cl-ast" }
cl-interpret = { path = "../cl-interpret" }
cl-token = { path = "../cl-token" }
crossterm = "0.27.0"

View File

@ -125,7 +125,7 @@ use collectible::Collectible;
pub mod collectible {
use super::Collector;
use conlang::ast::*;
use cl_ast::*;
pub trait Collectible<'code> {
fn collect(&'code self, c: &mut Collector<'code>);
}

View File

@ -72,8 +72,9 @@ pub mod program {
use cl_interpret::{
env::Environment, error::IResult, interpret::Interpret, temp_type_impl::ConValue,
};
use cl_ast::{self as ast, ast_impl::format::Pretty};
use conlang::{
ast::{self, ast_impl::format::Pretty},
// pretty_printer::{PrettyPrintable, Printer},
lexer::Lexer,
parser::{error::PResult, Parser},

View File

@ -13,5 +13,6 @@ repository.workspace = true
[dependencies]
unicode-xid = "0.2.4"
cl-ast = { path = "../cl-ast" }
cl-structures = { path = "../cl-structures" }
cl-token = { path = "../cl-token" }

View File

@ -2,8 +2,6 @@
#![warn(clippy::all)]
#![feature(decl_macro)]
pub mod ast;
pub mod lexer;
pub mod parser;

View File

@ -9,10 +9,8 @@ use self::error::{
ErrorKind::{self, *},
PResult, Parsing,
};
use crate::{
ast::*,
lexer::{error::Error as LexError, Lexer},
};
use crate::lexer::{error::Error as LexError, Lexer};
use cl_ast::*;
use cl_structures::span::*;
use cl_token::*;

View File

@ -853,11 +853,6 @@ mod ast1 {
// }
}
mod ast {
#![allow(unused_imports)]
use crate::ast::*;
}
// heakc yea man, generics
impl<T: Resolve> Resolve for Option<T> {
fn resolve(&mut self, resolver: &mut Resolver) -> TyResult<Type> {