cl-ast: Move AST definition into its own crate
This commit is contained in:
parent
6e1d5af134
commit
1afde9ce35
@ -5,6 +5,7 @@ members = [
|
|||||||
"cl-interpret",
|
"cl-interpret",
|
||||||
"cl-structures",
|
"cl-structures",
|
||||||
"cl-token",
|
"cl-token",
|
||||||
|
"cl-ast",
|
||||||
]
|
]
|
||||||
resolver = "2"
|
resolver = "2"
|
||||||
|
|
||||||
|
11
cl-ast/Cargo.toml
Normal file
11
cl-ast/Cargo.toml
Normal 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" }
|
@ -9,6 +9,8 @@
|
|||||||
//! - [AssignKind], [BinaryKind], and [UnaryKind] operators
|
//! - [AssignKind], [BinaryKind], and [UnaryKind] operators
|
||||||
//! - [Ty] and [TyKind]: Type qualifiers
|
//! - [Ty] and [TyKind]: Type qualifiers
|
||||||
//! - [Path]: Path expressions
|
//! - [Path]: Path expressions
|
||||||
|
#![feature(decl_macro)]
|
||||||
|
|
||||||
use cl_structures::span::*;
|
use cl_structures::span::*;
|
||||||
|
|
||||||
pub mod ast_impl;
|
pub mod ast_impl;
|
@ -9,4 +9,5 @@ publish.workspace = true
|
|||||||
|
|
||||||
[dependencies]
|
[dependencies]
|
||||||
conlang = { path = "../libconlang" }
|
conlang = { path = "../libconlang" }
|
||||||
|
cl-ast = { path = "../cl-ast" }
|
||||||
cl-structures = { path = "../cl-structures" }
|
cl-structures = { path = "../cl-structures" }
|
||||||
|
@ -6,7 +6,7 @@
|
|||||||
//! one in any situation.
|
//! one in any situation.
|
||||||
|
|
||||||
use super::*;
|
use super::*;
|
||||||
use conlang::ast::*;
|
use cl_ast::*;
|
||||||
/// A work-in-progress tree walk interpreter for Conlang
|
/// A work-in-progress tree walk interpreter for Conlang
|
||||||
pub trait Interpret {
|
pub trait Interpret {
|
||||||
/// Interprets this thing in the given [`Environment`].
|
/// Interprets this thing in the given [`Environment`].
|
||||||
|
@ -297,7 +297,7 @@ pub mod interpret;
|
|||||||
pub mod function {
|
pub mod function {
|
||||||
//! Represents a block of code which lives inside the Interpreter
|
//! Represents a block of code which lives inside the Interpreter
|
||||||
use super::{Callable, ConValue, Environment, Error, IResult, Interpret};
|
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
|
/// Represents a block of code which persists inside the Interpreter
|
||||||
#[derive(Clone, Debug)]
|
#[derive(Clone, Debug)]
|
||||||
pub struct Function {
|
pub struct Function {
|
||||||
@ -354,7 +354,7 @@ pub mod env {
|
|||||||
temp_type_impl::ConValue,
|
temp_type_impl::ConValue,
|
||||||
BuiltIn, Callable, Interpret,
|
BuiltIn, Callable, Interpret,
|
||||||
};
|
};
|
||||||
use conlang::ast::{Function as FnDecl, Identifier};
|
use cl_ast::{Function as FnDecl, Identifier};
|
||||||
use std::{
|
use std::{
|
||||||
collections::HashMap,
|
collections::HashMap,
|
||||||
fmt::Display,
|
fmt::Display,
|
||||||
|
@ -1,6 +1,7 @@
|
|||||||
#![allow(unused_imports)]
|
#![allow(unused_imports)]
|
||||||
use crate::{env::Environment, temp_type_impl::ConValue, Interpret};
|
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::*;
|
pub use macros::*;
|
||||||
|
|
||||||
mod macros {
|
mod macros {
|
||||||
@ -208,7 +209,7 @@ mod fn_declarations {
|
|||||||
}
|
}
|
||||||
|
|
||||||
mod operators {
|
mod operators {
|
||||||
use conlang::ast::Tuple;
|
use cl_ast::Tuple;
|
||||||
|
|
||||||
use super::*;
|
use super::*;
|
||||||
#[test]
|
#[test]
|
||||||
|
@ -11,6 +11,7 @@ publish.workspace = true
|
|||||||
|
|
||||||
[dependencies]
|
[dependencies]
|
||||||
conlang = { path = "../libconlang" }
|
conlang = { path = "../libconlang" }
|
||||||
|
cl-ast = { path = "../cl-ast" }
|
||||||
cl-interpret = { path = "../cl-interpret" }
|
cl-interpret = { path = "../cl-interpret" }
|
||||||
cl-token = { path = "../cl-token" }
|
cl-token = { path = "../cl-token" }
|
||||||
crossterm = "0.27.0"
|
crossterm = "0.27.0"
|
||||||
|
@ -125,7 +125,7 @@ use collectible::Collectible;
|
|||||||
pub mod collectible {
|
pub mod collectible {
|
||||||
|
|
||||||
use super::Collector;
|
use super::Collector;
|
||||||
use conlang::ast::*;
|
use cl_ast::*;
|
||||||
pub trait Collectible<'code> {
|
pub trait Collectible<'code> {
|
||||||
fn collect(&'code self, c: &mut Collector<'code>);
|
fn collect(&'code self, c: &mut Collector<'code>);
|
||||||
}
|
}
|
||||||
|
@ -72,8 +72,9 @@ pub mod program {
|
|||||||
use cl_interpret::{
|
use cl_interpret::{
|
||||||
env::Environment, error::IResult, interpret::Interpret, temp_type_impl::ConValue,
|
env::Environment, error::IResult, interpret::Interpret, temp_type_impl::ConValue,
|
||||||
};
|
};
|
||||||
|
|
||||||
|
use cl_ast::{self as ast, ast_impl::format::Pretty};
|
||||||
use conlang::{
|
use conlang::{
|
||||||
ast::{self, ast_impl::format::Pretty},
|
|
||||||
// pretty_printer::{PrettyPrintable, Printer},
|
// pretty_printer::{PrettyPrintable, Printer},
|
||||||
lexer::Lexer,
|
lexer::Lexer,
|
||||||
parser::{error::PResult, Parser},
|
parser::{error::PResult, Parser},
|
||||||
|
@ -13,5 +13,6 @@ repository.workspace = true
|
|||||||
|
|
||||||
[dependencies]
|
[dependencies]
|
||||||
unicode-xid = "0.2.4"
|
unicode-xid = "0.2.4"
|
||||||
|
cl-ast = { path = "../cl-ast" }
|
||||||
cl-structures = { path = "../cl-structures" }
|
cl-structures = { path = "../cl-structures" }
|
||||||
cl-token = { path = "../cl-token" }
|
cl-token = { path = "../cl-token" }
|
||||||
|
@ -2,8 +2,6 @@
|
|||||||
#![warn(clippy::all)]
|
#![warn(clippy::all)]
|
||||||
#![feature(decl_macro)]
|
#![feature(decl_macro)]
|
||||||
|
|
||||||
pub mod ast;
|
|
||||||
|
|
||||||
pub mod lexer;
|
pub mod lexer;
|
||||||
|
|
||||||
pub mod parser;
|
pub mod parser;
|
||||||
|
@ -9,10 +9,8 @@ use self::error::{
|
|||||||
ErrorKind::{self, *},
|
ErrorKind::{self, *},
|
||||||
PResult, Parsing,
|
PResult, Parsing,
|
||||||
};
|
};
|
||||||
use crate::{
|
use crate::lexer::{error::Error as LexError, Lexer};
|
||||||
ast::*,
|
use cl_ast::*;
|
||||||
lexer::{error::Error as LexError, Lexer},
|
|
||||||
};
|
|
||||||
use cl_structures::span::*;
|
use cl_structures::span::*;
|
||||||
use cl_token::*;
|
use cl_token::*;
|
||||||
|
|
||||||
|
@ -853,11 +853,6 @@ mod ast1 {
|
|||||||
// }
|
// }
|
||||||
}
|
}
|
||||||
|
|
||||||
mod ast {
|
|
||||||
#![allow(unused_imports)]
|
|
||||||
use crate::ast::*;
|
|
||||||
}
|
|
||||||
|
|
||||||
// heakc yea man, generics
|
// heakc yea man, generics
|
||||||
impl<T: Resolve> Resolve for Option<T> {
|
impl<T: Resolve> Resolve for Option<T> {
|
||||||
fn resolve(&mut self, resolver: &mut Resolver) -> TyResult<Type> {
|
fn resolve(&mut self, resolver: &mut Resolver) -> TyResult<Type> {
|
||||||
|
Loading…
Reference in New Issue
Block a user