refactor!(argus): combine co-dependent crates
- argus-core, argus-parser, argus-semantics are highly co-dependent, and hence should be in the same create.
This commit is contained in:
parent
dc71a51df3
commit
7ce056b471
43 changed files with 281 additions and 399 deletions
|
|
@ -3,12 +3,12 @@ use proc_macro2::{Ident, Span};
|
|||
use quote::{quote, ToTokens};
|
||||
use syn::DeriveInput;
|
||||
|
||||
/// Implement [`IsBoolExpr`](argus_core::expr::traits::IsBoolExpr) and other Boolean
|
||||
/// Implement [`IsBoolExpr`](argus::expr::IsBoolExpr) and other Boolean
|
||||
/// operations (`Not`, `BitOr`, and `BitAnd`) for the input identifier.
|
||||
pub fn bool_expr_impl(input: DeriveInput) -> TokenStream {
|
||||
let ident = &input.ident;
|
||||
let marker_impl = quote! {
|
||||
impl ::argus_core::expr::traits::IsBoolExpr for #ident {}
|
||||
impl ::argus::expr::IsBoolExpr for #ident {}
|
||||
};
|
||||
|
||||
let not_impl = impl_bool_not(&input);
|
||||
|
|
@ -29,11 +29,11 @@ fn impl_bool_not(input: &DeriveInput) -> impl ToTokens {
|
|||
let ident = &input.ident;
|
||||
quote! {
|
||||
impl ::core::ops::Not for #ident {
|
||||
type Output = ::argus_core::expr::BoolExpr;
|
||||
type Output = ::argus::expr::BoolExpr;
|
||||
|
||||
#[inline]
|
||||
fn not(self) -> Self::Output {
|
||||
(::argus_core::expr::Not { arg: Box::new(self.into()) }).into()
|
||||
(::argus::expr::Not { arg: Box::new(self.into()) }).into()
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
@ -62,12 +62,12 @@ fn impl_bool_and_or(input: &DeriveInput, op: BoolOp) -> impl ToTokens {
|
|||
};
|
||||
quote! {
|
||||
impl ::core::ops::#trait_name for #ident {
|
||||
type Output = ::argus_core::expr::BoolExpr;
|
||||
type Output = ::argus::expr::BoolExpr;
|
||||
|
||||
#[inline]
|
||||
fn #trait_fn(self, other: Self) -> Self::Output {
|
||||
use ::argus_core::expr::BoolExpr;
|
||||
use ::argus_core::expr::#enum_id;
|
||||
use ::argus::expr::BoolExpr;
|
||||
use ::argus::expr::#enum_id;
|
||||
let lhs: BoolExpr = self.into();
|
||||
let rhs: BoolExpr = other.into();
|
||||
|
||||
|
|
|
|||
|
|
@ -3,12 +3,12 @@ use proc_macro2::{Ident, Span};
|
|||
use quote::{quote, ToTokens};
|
||||
use syn::DeriveInput;
|
||||
|
||||
/// Implement [`IsNumExpr`](argus_core::expr::traits::IsNumExpr) and other Numean
|
||||
/// Implement [`IsNumExpr`](argus::expr::IsNumExpr) and other Numean
|
||||
/// operations (`Neg`, `Add`, `Mul`, `Sub`, and `Div`) for the input identifier.
|
||||
pub fn num_expr_impl(input: DeriveInput) -> TokenStream {
|
||||
let ident = &input.ident;
|
||||
let marker_impl = quote! {
|
||||
impl ::argus_core::expr::traits::IsNumExpr for #ident {}
|
||||
impl ::argus::expr::IsNumExpr for #ident {}
|
||||
};
|
||||
|
||||
let neg_impl = impl_num_neg(&input);
|
||||
|
|
@ -33,11 +33,11 @@ fn impl_num_neg(input: &DeriveInput) -> impl ToTokens {
|
|||
let ident = &input.ident;
|
||||
quote! {
|
||||
impl ::core::ops::Neg for #ident {
|
||||
type Output = ::argus_core::expr::NumExpr;
|
||||
type Output = ::argus::expr::NumExpr;
|
||||
|
||||
#[inline]
|
||||
fn neg(self) -> Self::Output {
|
||||
(::argus_core::expr::Neg { arg: Box::new(self.into()) }).into()
|
||||
(::argus::expr::Neg { arg: Box::new(self.into()) }).into()
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
@ -79,14 +79,14 @@ fn impl_nary_op(input: &DeriveInput, op: NumOp) -> impl ToTokens {
|
|||
quote! {
|
||||
impl<T> ::core::ops::#trait_name<T> for #ident
|
||||
where
|
||||
T: ::core::convert::Into<::argus_core::expr::NumExpr>
|
||||
T: ::core::convert::Into<::argus::expr::NumExpr>
|
||||
{
|
||||
type Output = ::argus_core::expr::NumExpr;
|
||||
type Output = ::argus::expr::NumExpr;
|
||||
|
||||
#[inline]
|
||||
fn #trait_fn(self, other: T) -> Self::Output {
|
||||
use ::argus_core::expr::NumExpr;
|
||||
use ::argus_core::expr::#node_name;
|
||||
use ::argus::expr::NumExpr;
|
||||
use ::argus::expr::#node_name;
|
||||
let lhs: NumExpr = self.into();
|
||||
let rhs: NumExpr = other.into();
|
||||
|
||||
|
|
@ -115,13 +115,13 @@ fn impl_sub(input: &DeriveInput) -> impl ToTokens {
|
|||
quote! {
|
||||
impl<T> ::core::ops::Sub<T> for #ident
|
||||
where
|
||||
T: ::core::convert::Into<::argus_core::expr::NumExpr>
|
||||
T: ::core::convert::Into<::argus::expr::NumExpr>
|
||||
{
|
||||
type Output = ::argus_core::expr::NumExpr;
|
||||
type Output = ::argus::expr::NumExpr;
|
||||
|
||||
#[inline]
|
||||
fn sub(self, other: T) -> Self::Output {
|
||||
use ::argus_core::expr::Sub;
|
||||
use ::argus::expr::Sub;
|
||||
let expr = Sub {
|
||||
lhs: Box::new(self.into()),
|
||||
rhs: Box::new(other.into())
|
||||
|
|
@ -137,13 +137,13 @@ fn impl_div(input: &DeriveInput) -> impl ToTokens {
|
|||
quote! {
|
||||
impl<T> ::core::ops::Div<T> for #ident
|
||||
where
|
||||
T: ::core::convert::Into<::argus_core::expr::NumExpr>
|
||||
T: ::core::convert::Into<::argus::expr::NumExpr>
|
||||
{
|
||||
type Output = ::argus_core::expr::NumExpr;
|
||||
type Output = ::argus::expr::NumExpr;
|
||||
|
||||
#[inline]
|
||||
fn div(self, other: T) -> Self::Output {
|
||||
use ::argus_core::expr::Div;
|
||||
use ::argus::expr::Div;
|
||||
let expr = Div {
|
||||
dividend: Box::new(self.into()),
|
||||
divisor: Box::new(other.into())
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue