diff --git a/rust/Cargo.toml b/rust/Cargo.toml index b513df66..683f708b 100644 --- a/rust/Cargo.toml +++ b/rust/Cargo.toml @@ -2,13 +2,16 @@ # Generated by TypeDB Cargo sync tool. # Do not modify this file. -features = {} - [package] name = "typeql" edition = "2021" version = "0.0.0" +[features] + default = ["quine"] + quine = ["dep:polyquine", "dep:proc-macro2", "dep:quote"] + + [lib] path = "typeql.rs" @@ -35,6 +38,15 @@ features = {} default-features = false [dependencies] +quote = { version = "1.0.40", default-features = false, optional = true } + [dependencies.proc-macro2] + version = "1.0.94" + default-features = false + optional = true + + [dependencies.polyquine] + version = "0.0.3" + optional = true [dependencies.pest] features = ["default", "memchr", "std"] @@ -68,4 +80,3 @@ features = {} [[test]] path = "tests/behaviour/test_debug.rs" name = "test_debug" - diff --git a/rust/annotation.rs b/rust/annotation.rs index 05491817..a9d1c99b 100644 --- a/rust/annotation.rs +++ b/rust/annotation.rs @@ -6,6 +6,9 @@ use std::fmt::{self, Write}; +#[cfg(feature = "quine")] +use {polyquine::Quine, proc_macro2::TokenStream}; + use crate::{ common::{identifier::Identifier, token, Span, Spanned}, util::write_joined, @@ -13,6 +16,7 @@ use crate::{ }; #[derive(Debug, Clone, Eq, PartialEq)] +#[cfg_attr(feature = "quine", derive(Quine))] pub enum Annotation { Abstract(Abstract), Cardinality(Cardinality), @@ -64,6 +68,7 @@ impl fmt::Display for Annotation { } #[derive(Debug, Clone, Eq, PartialEq)] +#[cfg_attr(feature = "quine", derive(Quine))] pub struct Abstract { pub span: Option, } @@ -87,6 +92,7 @@ impl fmt::Display for Abstract { } #[derive(Debug, Clone, Eq, PartialEq)] +#[cfg_attr(feature = "quine", derive(Quine))] pub struct Cardinality { pub span: Option, pub range: CardinalityRange, @@ -111,6 +117,7 @@ impl fmt::Display for Cardinality { } #[derive(Debug, Clone, Eq, PartialEq)] +#[cfg_attr(feature = "quine", derive(Quine))] pub enum CardinalityRange { Exact(IntegerLiteral), Range(IntegerLiteral, Option), @@ -127,6 +134,7 @@ impl fmt::Display for CardinalityRange { } #[derive(Debug, Clone, Eq, PartialEq)] +#[cfg_attr(feature = "quine", derive(Quine))] pub struct Cascade { pub span: Option, } @@ -150,6 +158,7 @@ impl fmt::Display for Cascade { } #[derive(Debug, Clone, Eq, PartialEq)] +#[cfg_attr(feature = "quine", derive(Quine))] pub struct Distinct { pub span: Option, } @@ -173,6 +182,7 @@ impl fmt::Display for Distinct { } #[derive(Debug, Clone, Eq, PartialEq)] +#[cfg_attr(feature = "quine", derive(Quine))] pub struct Independent { pub span: Option, } @@ -196,6 +206,7 @@ impl fmt::Display for Independent { } #[derive(Debug, Clone, Eq, PartialEq)] +#[cfg_attr(feature = "quine", derive(Quine))] pub struct Key { pub span: Option, } @@ -219,6 +230,7 @@ impl fmt::Display for Key { } #[derive(Debug, Clone, Eq, PartialEq)] +#[cfg_attr(feature = "quine", derive(Quine))] pub struct Range { pub span: Option, pub min: Option, @@ -253,6 +265,7 @@ impl fmt::Display for Range { } #[derive(Debug, Clone, Eq, PartialEq)] +#[cfg_attr(feature = "quine", derive(Quine))] pub struct Regex { pub span: Option, pub regex: StringLiteral, @@ -277,6 +290,7 @@ impl fmt::Display for Regex { } #[derive(Debug, Clone, Eq, PartialEq)] +#[cfg_attr(feature = "quine", derive(Quine))] pub struct Subkey { pub span: Option, pub ident: Identifier, @@ -301,6 +315,7 @@ impl fmt::Display for Subkey { } #[derive(Debug, Clone, Eq, PartialEq)] +#[cfg_attr(feature = "quine", derive(Quine))] pub struct Unique { pub span: Option, } @@ -324,6 +339,7 @@ impl fmt::Display for Unique { } #[derive(Debug, Clone, Eq, PartialEq)] +#[cfg_attr(feature = "quine", derive(Quine))] pub struct Values { pub span: Option, pub values: Vec, diff --git a/rust/common/date_time.rs b/rust/common/date_time.rs index 8d56f654..3e503642 100644 --- a/rust/common/date_time.rs +++ b/rust/common/date_time.rs @@ -6,6 +6,7 @@ use chrono::{NaiveDateTime, Timelike}; +#[allow(dead_code)] pub(crate) fn parse(date_time_text: &str) -> Option { let has_seconds = date_time_text.matches(':').count() == 2; if has_seconds { @@ -23,7 +24,7 @@ pub(crate) fn parse(date_time_text: &str) -> Option { NaiveDateTime::parse_from_str(date_time_text, "%Y-%m-%dT%H:%M").ok() } } - +#[allow(dead_code)] pub(crate) fn format(date_time: &NaiveDateTime) -> String { if date_time.time().nanosecond() > 0 { date_time.format("%Y-%m-%dT%H:%M:%S.%3f").to_string() diff --git a/rust/common/identifier.rs b/rust/common/identifier.rs index d4a44930..44f2d9b7 100644 --- a/rust/common/identifier.rs +++ b/rust/common/identifier.rs @@ -8,6 +8,9 @@ use std::{fmt, sync::OnceLock}; use regex::{Regex, RegexBuilder}; +#[cfg(feature = "quine")] +use {polyquine::Quine, proc_macro2::TokenStream}; + use crate::{ common::{error::TypeQLError, Span, Spanned}, is_reserved_keyword, @@ -15,6 +18,7 @@ use crate::{ }; #[derive(Debug, Clone, Eq, PartialEq, Hash)] +#[cfg_attr(feature = "quine", derive(Quine))] pub struct Identifier { pub span: Option, ident: String, diff --git a/rust/common/mod.rs b/rust/common/mod.rs index 90f34d21..66ce31f8 100644 --- a/rust/common/mod.rs +++ b/rust/common/mod.rs @@ -21,6 +21,9 @@ pub mod token; pub type Result = std::result::Result; +#[cfg(feature = "quine")] +use {polyquine::Quine, proc_macro2::TokenStream}; + #[derive(Debug, Copy, Clone, Eq, PartialEq, Hash)] pub struct LineColumn { pub line: u32, @@ -28,6 +31,7 @@ pub struct LineColumn { } #[derive(Debug, Copy, Clone, Eq, PartialEq, Hash)] +#[cfg_attr(feature = "quine", derive(Quine))] pub struct Span { pub begin_offset: usize, pub end_offset: usize, diff --git a/rust/common/token.rs b/rust/common/token.rs index 2aab37f3..65bfd937 100644 --- a/rust/common/token.rs +++ b/rust/common/token.rs @@ -6,9 +6,13 @@ use std::fmt; +#[cfg(feature = "quine")] +use {polyquine::Quine, proc_macro2::TokenStream}; + macro_rules! string_enum { {$name:ident $($item:ident = $value:tt),* $(,)?} => { #[derive(Debug, Clone, Copy, Eq, PartialEq, Hash)] + #[cfg_attr(feature = "quine", derive(Quine))] pub enum $name { $($item),* } diff --git a/rust/expression/mod.rs b/rust/expression/mod.rs index 5009262b..389c38b3 100644 --- a/rust/expression/mod.rs +++ b/rust/expression/mod.rs @@ -6,6 +6,9 @@ use std::fmt::{self, Write}; +#[cfg(feature = "quine")] +use {polyquine::Quine, proc_macro2::TokenStream}; + use crate::{ common::{ identifier::Identifier, @@ -19,6 +22,7 @@ use crate::{ }; #[derive(Debug, Clone, Eq, PartialEq)] +#[cfg_attr(feature = "quine", derive(Quine))] pub struct BuiltinFunctionName { pub span: Option, pub token: token::Function, @@ -45,6 +49,7 @@ impl fmt::Display for BuiltinFunctionName { } #[derive(Debug, Clone, Eq, PartialEq)] +#[cfg_attr(feature = "quine", derive(Quine))] pub enum FunctionName { Builtin(BuiltinFunctionName), Identifier(Identifier), @@ -71,6 +76,7 @@ impl fmt::Display for FunctionName { } #[derive(Debug, Clone, Eq, PartialEq)] +#[cfg_attr(feature = "quine", derive(Quine))] pub struct FunctionCall { pub span: Option, pub name: FunctionName, @@ -101,6 +107,7 @@ impl fmt::Display for FunctionCall { } #[derive(Debug, Clone, Eq, PartialEq)] +#[cfg_attr(feature = "quine", derive(Quine))] pub struct Operation { pub op: ArithmeticOperator, pub left: Expression, @@ -132,6 +139,7 @@ impl fmt::Display for Operation { } #[derive(Debug, Clone, Eq, PartialEq)] +#[cfg_attr(feature = "quine", derive(Quine))] pub struct Paren { pub span: Option, pub inner: Expression, @@ -158,6 +166,7 @@ impl fmt::Display for Paren { } #[derive(Debug, Clone, Eq, PartialEq)] +#[cfg_attr(feature = "quine", derive(Quine))] pub struct ListIndex { pub span: Option, pub variable: Variable, @@ -185,6 +194,7 @@ impl fmt::Display for ListIndex { } #[derive(Debug, Clone, Eq, PartialEq)] +#[cfg_attr(feature = "quine", derive(Quine))] pub struct List { pub span: Option, pub items: Vec, @@ -214,6 +224,7 @@ impl fmt::Display for List { } #[derive(Debug, Clone, Eq, PartialEq)] +#[cfg_attr(feature = "quine", derive(Quine))] pub struct ListIndexRange { pub span: Option, pub var: Variable, @@ -242,6 +253,7 @@ impl fmt::Display for ListIndexRange { } #[derive(Debug, Clone, Eq, PartialEq)] +#[cfg_attr(feature = "quine", derive(Quine))] pub enum Expression { Variable(Variable), ListIndex(Box), diff --git a/rust/pattern/mod.rs b/rust/pattern/mod.rs index ed22d8a8..90224ff9 100644 --- a/rust/pattern/mod.rs +++ b/rust/pattern/mod.rs @@ -6,6 +6,9 @@ use std::fmt::{self, Write}; +#[cfg(feature = "quine")] +use {polyquine::Quine, proc_macro2::TokenStream}; + use crate::{ common::{token, Span}, pretty::{indent, Pretty}, @@ -13,6 +16,7 @@ use crate::{ }; #[derive(Debug, Clone, Eq, PartialEq)] +#[cfg_attr(feature = "quine", derive(Quine))] pub struct Conjunction { pub span: Option, pub patterns: Vec, @@ -42,6 +46,7 @@ impl fmt::Display for Conjunction { } #[derive(Debug, Clone, Eq, PartialEq)] +#[cfg_attr(feature = "quine", derive(Quine))] pub struct Negation { pub span: Option, pub patterns: Vec, @@ -73,6 +78,7 @@ impl fmt::Display for Negation { } #[derive(Debug, Clone, Eq, PartialEq)] +#[cfg_attr(feature = "quine", derive(Quine))] pub struct Optional { pub span: Option, pub patterns: Vec, @@ -104,6 +110,7 @@ impl fmt::Display for Optional { } #[derive(Debug, Clone, Eq, PartialEq)] +#[cfg_attr(feature = "quine", derive(Quine))] pub struct Disjunction { pub span: Option, pub branches: Vec>, @@ -164,6 +171,7 @@ impl fmt::Display for Disjunction { } #[derive(Debug, Clone, Eq, PartialEq)] +#[cfg_attr(feature = "quine", derive(Quine))] pub enum Pattern { Conjunction(Conjunction), Disjunction(Disjunction), diff --git a/rust/query/mod.rs b/rust/query/mod.rs index 1c42b429..37d05040 100644 --- a/rust/query/mod.rs +++ b/rust/query/mod.rs @@ -6,6 +6,9 @@ use std::fmt; +#[cfg(feature = "quine")] +use {polyquine::Quine, proc_macro2::TokenStream}; + use self::pipeline::stage::{Match, Stage}; pub use self::{ pipeline::{stage, Pipeline}, @@ -20,6 +23,7 @@ pub mod pipeline; pub mod schema; #[derive(Debug, Eq, PartialEq)] +#[cfg_attr(feature = "quine", derive(Quine))] pub struct Query { pub span: Option, pub structure: QueryStructure, @@ -56,6 +60,7 @@ impl fmt::Display for Query { } #[derive(Debug, Eq, PartialEq)] +#[cfg_attr(feature = "quine", derive(Quine))] pub enum QueryStructure { Schema(SchemaQuery), Pipeline(Pipeline), diff --git a/rust/query/pipeline/mod.rs b/rust/query/pipeline/mod.rs index 7a11d5ae..c106f85d 100644 --- a/rust/query/pipeline/mod.rs +++ b/rust/query/pipeline/mod.rs @@ -6,6 +6,9 @@ use std::fmt; +#[cfg(feature = "quine")] +use {polyquine::Quine, proc_macro2::TokenStream}; + use self::stage::Stage; use crate::{ common::{Span, Spanned}, @@ -17,6 +20,7 @@ use crate::{ pub mod stage; #[derive(Debug, Clone, Eq, PartialEq)] +#[cfg_attr(feature = "quine", derive(Quine))] pub struct Preamble { pub span: Option, pub function: definable::Function, @@ -44,6 +48,7 @@ impl fmt::Display for Preamble { } #[derive(Debug, Clone, Eq, PartialEq)] +#[cfg_attr(feature = "quine", derive(Quine))] pub struct Pipeline { pub span: Option, pub preambles: Vec, diff --git a/rust/query/pipeline/stage/delete.rs b/rust/query/pipeline/stage/delete.rs index 9c064b53..22bc4c60 100644 --- a/rust/query/pipeline/stage/delete.rs +++ b/rust/query/pipeline/stage/delete.rs @@ -6,6 +6,9 @@ use std::fmt::{self, Write}; +#[cfg(feature = "quine")] +use {polyquine::Quine, proc_macro2::TokenStream}; + use crate::{ common::{token, Span, Spanned}, pretty::{indent, Pretty}, @@ -14,6 +17,7 @@ use crate::{ }; #[derive(Debug, Clone, Eq, PartialEq)] +#[cfg_attr(feature = "quine", derive(Quine))] pub struct Delete { pub span: Option, pub deletables: Vec, @@ -59,6 +63,7 @@ impl fmt::Display for Delete { } #[derive(Debug, Clone, Eq, PartialEq)] +#[cfg_attr(feature = "quine", derive(Quine))] pub struct Deletable { pub span: Option, pub kind: DeletableKind, @@ -89,6 +94,7 @@ impl fmt::Display for Deletable { } #[derive(Debug, Clone, Eq, PartialEq)] +#[cfg_attr(feature = "quine", derive(Quine))] pub enum DeletableKind { Has { attribute: Variable, owner: Variable }, Links { players: Relation, relation: Variable }, diff --git a/rust/query/pipeline/stage/fetch.rs b/rust/query/pipeline/stage/fetch.rs index 2ac0f996..d1ebf7a5 100644 --- a/rust/query/pipeline/stage/fetch.rs +++ b/rust/query/pipeline/stage/fetch.rs @@ -6,6 +6,9 @@ use std::{fmt, fmt::Formatter}; +#[cfg(feature = "quine")] +use {polyquine::Quine, proc_macro2::TokenStream}; + use crate::{ common::{token, Span, Spanned}, expression::{Expression, FunctionCall}, @@ -17,6 +20,7 @@ use crate::{ }; #[derive(Debug, Clone, Eq, PartialEq)] +#[cfg_attr(feature = "quine", derive(Quine))] pub struct Fetch { pub span: Option, pub object: FetchObject, @@ -52,6 +56,7 @@ impl fmt::Display for Fetch { } #[derive(Debug, Clone, Eq, PartialEq)] +#[cfg_attr(feature = "quine", derive(Quine))] pub enum FetchSome { Object(FetchObject), List(FetchList), @@ -85,6 +90,7 @@ impl fmt::Display for FetchSome { } #[derive(Debug, Clone, Eq, PartialEq)] +#[cfg_attr(feature = "quine", derive(Quine))] pub struct FetchObject { pub span: Option, pub body: FetchObjectBody, @@ -115,6 +121,7 @@ impl fmt::Display for FetchObject { } #[derive(Debug, Clone, Eq, PartialEq)] +#[cfg_attr(feature = "quine", derive(Quine))] pub enum FetchObjectBody { Entries(Vec), AttributesAll(Variable), @@ -166,6 +173,7 @@ impl fmt::Display for FetchObjectBody { } #[derive(Debug, Clone, Eq, PartialEq)] +#[cfg_attr(feature = "quine", derive(Quine))] pub struct FetchObjectEntry { pub span: Option, pub key: StringLiteral, @@ -199,6 +207,7 @@ impl fmt::Display for FetchObjectEntry { } #[derive(Debug, Clone, Eq, PartialEq)] +#[cfg_attr(feature = "quine", derive(Quine))] pub struct FetchList { pub span: Option, pub stream: FetchStream, @@ -229,6 +238,7 @@ impl fmt::Display for FetchList { } #[derive(Debug, Clone, Eq, PartialEq)] +#[cfg_attr(feature = "quine", derive(Quine))] pub enum FetchSingle { Attribute(FetchAttribute), Expression(Expression), @@ -272,6 +282,7 @@ impl fmt::Display for FetchSingle { } #[derive(Debug, Clone, Eq, PartialEq)] +#[cfg_attr(feature = "quine", derive(Quine))] pub enum FetchStream { Attribute(FetchAttribute), Function(FunctionCall), @@ -335,6 +346,7 @@ impl fmt::Display for FetchStream { } #[derive(Debug, Clone, Eq, PartialEq)] +#[cfg_attr(feature = "quine", derive(Quine))] pub struct FetchAttribute { pub span: Option, pub owner: Variable, diff --git a/rust/query/pipeline/stage/insert.rs b/rust/query/pipeline/stage/insert.rs index e07f9549..5a3f36cb 100644 --- a/rust/query/pipeline/stage/insert.rs +++ b/rust/query/pipeline/stage/insert.rs @@ -6,6 +6,9 @@ use std::fmt::{self, Write}; +#[cfg(feature = "quine")] +use {polyquine::Quine, proc_macro2::TokenStream}; + use crate::{ common::{token, Span, Spanned}, pretty::{indent, Pretty}, @@ -13,6 +16,7 @@ use crate::{ }; #[derive(Debug, Clone, Eq, PartialEq)] +#[cfg_attr(feature = "quine", derive(Quine))] pub struct Insert { pub span: Option, pub statements: Vec, diff --git a/rust/query/pipeline/stage/match_.rs b/rust/query/pipeline/stage/match_.rs index 7de94b79..84a73b62 100644 --- a/rust/query/pipeline/stage/match_.rs +++ b/rust/query/pipeline/stage/match_.rs @@ -6,6 +6,9 @@ use std::fmt::{self, Write}; +#[cfg(feature = "quine")] +use {polyquine::Quine, proc_macro2::TokenStream}; + use crate::{ common::{token, Span, Spanned}, pattern::Pattern, @@ -13,6 +16,7 @@ use crate::{ }; #[derive(Debug, Clone, Eq, PartialEq)] +#[cfg_attr(feature = "quine", derive(Quine))] pub struct Match { pub span: Option, pub patterns: Vec, diff --git a/rust/query/pipeline/stage/mod.rs b/rust/query/pipeline/stage/mod.rs index 0543e97e..918a5a4e 100644 --- a/rust/query/pipeline/stage/mod.rs +++ b/rust/query/pipeline/stage/mod.rs @@ -6,6 +6,9 @@ use std::fmt; +#[cfg(feature = "quine")] +use {polyquine::Quine, proc_macro2::TokenStream}; + pub use self::{ delete::Delete, fetch::Fetch, insert::Insert, match_::Match, modifier::Operator, put::Put, reduce::Reduce, update::Update, @@ -26,6 +29,7 @@ pub mod reduce; mod update; #[derive(Debug, Clone, Eq, PartialEq)] +#[cfg_attr(feature = "quine", derive(Quine))] pub enum Stage { Match(Match), Insert(Insert), diff --git a/rust/query/pipeline/stage/modifier.rs b/rust/query/pipeline/stage/modifier.rs index 8beca1c5..4af69917 100644 --- a/rust/query/pipeline/stage/modifier.rs +++ b/rust/query/pipeline/stage/modifier.rs @@ -6,6 +6,9 @@ use std::fmt::{self, Write}; +#[cfg(feature = "quine")] +use {polyquine::Quine, proc_macro2::TokenStream}; + use crate::{ common::{ token::{self, Order}, @@ -19,6 +22,7 @@ use crate::{ }; #[derive(Debug, Clone, Eq, PartialEq)] +#[cfg_attr(feature = "quine", derive(Quine))] pub struct OrderedVariable { pub span: Option, pub variable: Variable, @@ -50,6 +54,7 @@ impl fmt::Display for OrderedVariable { } #[derive(Debug, Clone, Eq, PartialEq)] +#[cfg_attr(feature = "quine", derive(Quine))] pub struct Sort { pub span: Option, pub ordered_variables: Vec, @@ -79,6 +84,7 @@ impl fmt::Display for Sort { } #[derive(Debug, Clone, Eq, PartialEq)] +#[cfg_attr(feature = "quine", derive(Quine))] pub struct Select { pub span: Option, pub variables: Vec, @@ -108,6 +114,7 @@ impl fmt::Display for Select { } #[derive(Debug, Clone, Eq, PartialEq)] +#[cfg_attr(feature = "quine", derive(Quine))] pub struct Offset { pub span: Option, pub offset: IntegerLiteral, @@ -134,6 +141,7 @@ impl fmt::Display for Offset { } #[derive(Debug, Clone, Eq, PartialEq)] +#[cfg_attr(feature = "quine", derive(Quine))] pub struct Limit { pub span: Option, pub limit: IntegerLiteral, @@ -160,6 +168,7 @@ impl fmt::Display for Limit { } #[derive(Debug, Clone, Eq, PartialEq)] +#[cfg_attr(feature = "quine", derive(Quine))] pub struct Require { pub span: Option, pub variables: Vec, @@ -189,6 +198,7 @@ impl fmt::Display for Require { } #[derive(Debug, Clone, Eq, PartialEq)] +#[cfg_attr(feature = "quine", derive(Quine))] pub struct Distinct { span: Option, } @@ -214,6 +224,7 @@ impl fmt::Display for Distinct { } #[derive(Debug, Clone, Eq, PartialEq)] +#[cfg_attr(feature = "quine", derive(Quine))] pub enum Operator { Select(Select), Sort(Sort), diff --git a/rust/query/pipeline/stage/put.rs b/rust/query/pipeline/stage/put.rs index ca384316..57934f58 100644 --- a/rust/query/pipeline/stage/put.rs +++ b/rust/query/pipeline/stage/put.rs @@ -6,6 +6,9 @@ use std::fmt::{self, Write}; +#[cfg(feature = "quine")] +use {polyquine::Quine, proc_macro2::TokenStream}; + use crate::{ common::{token, Span, Spanned}, pretty::{indent, Pretty}, @@ -13,6 +16,7 @@ use crate::{ }; #[derive(Debug, Clone, Eq, PartialEq)] +#[cfg_attr(feature = "quine", derive(Quine))] pub struct Put { pub span: Option, pub statements: Vec, diff --git a/rust/query/pipeline/stage/reduce.rs b/rust/query/pipeline/stage/reduce.rs index 085a4823..bf565581 100644 --- a/rust/query/pipeline/stage/reduce.rs +++ b/rust/query/pipeline/stage/reduce.rs @@ -6,6 +6,9 @@ use std::fmt; +#[cfg(feature = "quine")] +use {polyquine::Quine, proc_macro2::TokenStream}; + use crate::{ common::{token, Span, Spanned}, pretty::{indent, Pretty}, @@ -14,6 +17,7 @@ use crate::{ }; #[derive(Debug, Clone, Eq, PartialEq)] +#[cfg_attr(feature = "quine", derive(Quine))] pub struct Reduce { pub span: Option, pub reduce_assignments: Vec, @@ -61,6 +65,7 @@ impl fmt::Display for Reduce { } #[derive(Debug, Clone, Eq, PartialEq)] +#[cfg_attr(feature = "quine", derive(Quine))] pub struct ReduceAssign { pub variable: Variable, pub reducer: Reducer, @@ -80,6 +85,7 @@ impl fmt::Display for ReduceAssign { } #[derive(Debug, Clone, Eq, PartialEq)] +#[cfg_attr(feature = "quine", derive(Quine))] pub enum Reducer { Count(Count), Stat(Stat), @@ -104,6 +110,7 @@ impl fmt::Display for Reducer { } #[derive(Debug, Clone, Eq, PartialEq)] +#[cfg_attr(feature = "quine", derive(Quine))] pub struct Count { pub span: Option, pub variable: Option, @@ -134,6 +141,7 @@ impl fmt::Display for Count { } #[derive(Debug, Clone, Eq, PartialEq)] +#[cfg_attr(feature = "quine", derive(Quine))] pub struct Stat { pub span: Option, pub reduce_operator: token::ReduceOperator, diff --git a/rust/query/pipeline/stage/update.rs b/rust/query/pipeline/stage/update.rs index faf119fe..1ab498c7 100644 --- a/rust/query/pipeline/stage/update.rs +++ b/rust/query/pipeline/stage/update.rs @@ -6,6 +6,9 @@ use std::fmt::{self, Write}; +#[cfg(feature = "quine")] +use {polyquine::Quine, proc_macro2::TokenStream}; + use crate::{ common::{token, Span, Spanned}, pretty::{indent, Pretty}, @@ -13,6 +16,7 @@ use crate::{ }; #[derive(Debug, Clone, Eq, PartialEq)] +#[cfg_attr(feature = "quine", derive(Quine))] pub struct Update { pub span: Option, pub statements: Vec, diff --git a/rust/query/schema/define.rs b/rust/query/schema/define.rs index cf0289ad..b9544693 100644 --- a/rust/query/schema/define.rs +++ b/rust/query/schema/define.rs @@ -6,6 +6,9 @@ use std::fmt; +#[cfg(feature = "quine")] +use {polyquine::Quine, proc_macro2::TokenStream}; + use crate::{ common::{token, Span, Spanned}, pretty::{indent, Pretty}, @@ -13,6 +16,7 @@ use crate::{ }; #[derive(Debug, Eq, PartialEq)] +#[cfg_attr(feature = "quine", derive(Quine))] pub struct Define { pub span: Option, pub definables: Vec, diff --git a/rust/query/schema/mod.rs b/rust/query/schema/mod.rs index e2b42209..826e1068 100644 --- a/rust/query/schema/mod.rs +++ b/rust/query/schema/mod.rs @@ -6,6 +6,9 @@ use std::fmt; +#[cfg(feature = "quine")] +use {polyquine::Quine, proc_macro2::TokenStream}; + pub use self::{define::Define, redefine::Redefine, undefine::Undefine}; use crate::common::{Span, Spanned}; @@ -14,6 +17,7 @@ mod redefine; mod undefine; #[derive(Debug, Eq, PartialEq)] +#[cfg_attr(feature = "quine", derive(Quine))] pub enum SchemaQuery { Define(Define), Redefine(Redefine), diff --git a/rust/query/schema/redefine.rs b/rust/query/schema/redefine.rs index 3a5e6ca6..ff00e4aa 100644 --- a/rust/query/schema/redefine.rs +++ b/rust/query/schema/redefine.rs @@ -6,6 +6,9 @@ use std::fmt::{self, Write}; +#[cfg(feature = "quine")] +use {polyquine::Quine, proc_macro2::TokenStream}; + use crate::{ common::{token, Span, Spanned}, schema::definable::Definable, @@ -13,6 +16,7 @@ use crate::{ }; #[derive(Debug, Eq, PartialEq)] +#[cfg_attr(feature = "quine", derive(Quine))] pub struct Redefine { pub span: Option, pub definables: Vec, diff --git a/rust/query/schema/undefine.rs b/rust/query/schema/undefine.rs index c010ac12..570be2bb 100644 --- a/rust/query/schema/undefine.rs +++ b/rust/query/schema/undefine.rs @@ -6,6 +6,9 @@ use std::fmt::{self, Write}; +#[cfg(feature = "quine")] +use {polyquine::Quine, proc_macro2::TokenStream}; + use crate::{ common::{token, Span, Spanned}, pretty::{indent, Pretty}, @@ -13,6 +16,7 @@ use crate::{ }; #[derive(Debug, Eq, PartialEq)] +#[cfg_attr(feature = "quine", derive(Quine))] pub struct Undefine { pub span: Option, pub undefinables: Vec, diff --git a/rust/schema/definable/function.rs b/rust/schema/definable/function.rs index d13957e3..9056a4dd 100644 --- a/rust/schema/definable/function.rs +++ b/rust/schema/definable/function.rs @@ -6,6 +6,9 @@ use std::fmt::{self, Debug, Formatter, Write}; +#[cfg(feature = "quine")] +use {polyquine::Quine, proc_macro2::TokenStream}; + use crate::{ common::{identifier::Identifier, token, Span, Spanned}, pretty::{indent, Pretty}, @@ -16,6 +19,7 @@ use crate::{ }; #[derive(Debug, Clone, PartialEq, Eq)] +#[cfg_attr(feature = "quine", derive(Quine))] pub struct Function { pub span: Option, pub signature: Signature, @@ -59,6 +63,7 @@ impl fmt::Display for Function { } #[derive(Debug, Clone, PartialEq, Eq)] +#[cfg_attr(feature = "quine", derive(Quine))] pub struct Signature { pub span: Option, pub ident: Identifier, @@ -105,6 +110,7 @@ impl fmt::Display for Signature { } #[derive(Debug, Clone, PartialEq, Eq)] +#[cfg_attr(feature = "quine", derive(Quine))] pub struct Argument { pub span: Option, pub var: Variable, @@ -125,6 +131,7 @@ impl fmt::Display for Argument { } #[derive(Debug, Clone, PartialEq, Eq)] +#[cfg_attr(feature = "quine", derive(Quine))] pub enum Output { Stream(Stream), Single(Single), @@ -158,6 +165,7 @@ impl fmt::Display for Output { } #[derive(Debug, Clone, PartialEq, Eq)] +#[cfg_attr(feature = "quine", derive(Quine))] pub struct Stream { pub span: Option, pub types: Vec, @@ -186,6 +194,7 @@ impl fmt::Display for Stream { } #[derive(Debug, Clone, PartialEq, Eq)] +#[cfg_attr(feature = "quine", derive(Quine))] pub struct Single { pub span: Option, pub types: Vec, @@ -212,6 +221,7 @@ impl fmt::Display for Single { } #[derive(Debug, Clone, PartialEq, Eq)] +#[cfg_attr(feature = "quine", derive(Quine))] pub struct FunctionBlock { pub span: Option, pub stages: Vec, @@ -244,6 +254,7 @@ impl fmt::Display for FunctionBlock { } #[derive(Debug, Clone, PartialEq, Eq)] +#[cfg_attr(feature = "quine", derive(Quine))] pub enum ReturnStatement { Stream(ReturnStream), Single(ReturnSingle), @@ -274,6 +285,7 @@ impl fmt::Display for ReturnStatement { } #[derive(Debug, Clone, PartialEq, Eq)] +#[cfg_attr(feature = "quine", derive(Quine))] pub struct ReturnStream { pub span: Option, pub vars: Vec, @@ -305,6 +317,7 @@ impl fmt::Display for ReturnStream { } #[derive(Debug, Clone, PartialEq, Eq)] +#[cfg_attr(feature = "quine", derive(Quine))] pub struct ReturnSingle { pub span: Option, pub selector: SingleSelector, @@ -338,6 +351,7 @@ impl fmt::Display for ReturnSingle { } #[derive(Debug, Clone, PartialEq, Eq)] +#[cfg_attr(feature = "quine", derive(Quine))] pub enum SingleSelector { First, Last, @@ -353,6 +367,7 @@ impl fmt::Display for SingleSelector { } #[derive(Debug, Clone, Eq, PartialEq)] +#[cfg_attr(feature = "quine", derive(Quine))] pub enum ReturnReduction { Check(Check), Value(Vec, Option), @@ -386,6 +401,7 @@ impl fmt::Display for ReturnReduction { } #[derive(Debug, Clone, Eq, PartialEq)] +#[cfg_attr(feature = "quine", derive(Quine))] pub struct Check { pub span: Option, } diff --git a/rust/schema/definable/mod.rs b/rust/schema/definable/mod.rs index cde14f4a..c13ab755 100644 --- a/rust/schema/definable/mod.rs +++ b/rust/schema/definable/mod.rs @@ -6,6 +6,9 @@ use std::fmt; +#[cfg(feature = "quine")] +use {polyquine::Quine, proc_macro2::TokenStream}; + pub use self::{function::Function, struct_::Struct, type_::Type}; use crate::pretty::Pretty; @@ -14,6 +17,7 @@ pub mod struct_; pub mod type_; #[derive(Debug, Eq, PartialEq)] +#[cfg_attr(feature = "quine", derive(Quine))] pub enum Definable { TypeDeclaration(Type), Function(Function), diff --git a/rust/schema/definable/struct_.rs b/rust/schema/definable/struct_.rs index 39cff9c8..bdb8f994 100644 --- a/rust/schema/definable/struct_.rs +++ b/rust/schema/definable/struct_.rs @@ -6,6 +6,9 @@ use std::{fmt, fmt::Formatter}; +#[cfg(feature = "quine")] +use {polyquine::Quine, proc_macro2::TokenStream}; + use crate::{ common::{identifier::Identifier, Span, Spanned}, pretty::{indent, Pretty}, @@ -14,6 +17,7 @@ use crate::{ }; #[derive(Debug, Clone, PartialEq, Eq)] +#[cfg_attr(feature = "quine", derive(Quine))] pub struct Struct { pub span: Option, pub ident: Identifier, @@ -61,6 +65,7 @@ impl fmt::Display for Struct { } #[derive(Debug, Clone, PartialEq, Eq)] +#[cfg_attr(feature = "quine", derive(Quine))] pub struct Field { pub span: Option, pub key: Identifier, diff --git a/rust/schema/definable/type_/capability.rs b/rust/schema/definable/type_/capability.rs index d3569ec6..db001073 100644 --- a/rust/schema/definable/type_/capability.rs +++ b/rust/schema/definable/type_/capability.rs @@ -6,6 +6,9 @@ use std::fmt; +#[cfg(feature = "quine")] +use {polyquine::Quine, proc_macro2::TokenStream}; + use crate::{ common::{identifier::Identifier, token, Span, Spanned}, pretty::Pretty, @@ -14,6 +17,7 @@ use crate::{ }; #[derive(Debug, Clone, Eq, PartialEq)] +#[cfg_attr(feature = "quine", derive(Quine))] pub struct Alias { pub span: Option, pub aliases: Vec