Skip to content

Commit

Permalink
expose more AST internals in grass_compiler
Browse files Browse the repository at this point in the history
  • Loading branch information
connorskees committed Jun 30, 2023
1 parent 8363ca1 commit 8b34d0e
Show file tree
Hide file tree
Showing 15 changed files with 161 additions and 106 deletions.
3 changes: 3 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,9 @@

# 0.13.0

- fix various module system bugs when combined with `@import`
- expose more AST internals in `grass_compiler`

# 0.12.4

- implement builtin map-module functions `map.deep-merge(..)` and `map.deep-remove(..)`
Expand Down
6 changes: 3 additions & 3 deletions crates/compiler/src/ast/args.rs
Original file line number Diff line number Diff line change
Expand Up @@ -16,13 +16,13 @@ use crate::{
use super::AstExpr;

#[derive(Debug, Clone)]
pub(crate) struct Argument {
pub struct Argument {
pub name: Identifier,
pub default: Option<AstExpr>,
}

#[derive(Debug, Clone)]
pub(crate) struct ArgumentDeclaration {
pub struct ArgumentDeclaration {
pub args: Vec<Argument>,
pub rest: Option<Identifier>,
}
Expand Down Expand Up @@ -130,7 +130,7 @@ impl ArgumentDeclaration {
}

#[derive(Debug, Clone)]
pub(crate) struct ArgumentInvocation {
pub struct ArgumentInvocation {
pub(crate) positional: Vec<AstExpr>,
pub(crate) named: BTreeMap<Identifier, AstExpr>,
pub(crate) rest: Option<AstExpr>,
Expand Down
16 changes: 8 additions & 8 deletions crates/compiler/src/ast/expr.rs
Original file line number Diff line number Diff line change
Expand Up @@ -13,35 +13,35 @@ use super::{ArgumentInvocation, AstSupportsCondition, Interpolation, Interpolati

/// Represented by the `if` function
#[derive(Debug, Clone)]
pub(crate) struct Ternary(pub ArgumentInvocation);
pub struct Ternary(pub ArgumentInvocation);

#[derive(Debug, Clone)]
pub(crate) struct ListExpr {
pub struct ListExpr {
pub elems: Vec<Spanned<AstExpr>>,
pub separator: ListSeparator,
pub brackets: Brackets,
}

#[derive(Debug, Clone)]
pub(crate) struct FunctionCallExpr {
pub struct FunctionCallExpr {
pub namespace: Option<Spanned<Identifier>>,
pub name: Identifier,
pub arguments: Arc<ArgumentInvocation>,
pub span: Span,
}

#[derive(Debug, Clone)]
pub(crate) struct InterpolatedFunction {
pub struct InterpolatedFunction {
pub name: Interpolation,
pub arguments: ArgumentInvocation,
pub span: Span,
}

#[derive(Debug, Clone, Default)]
pub(crate) struct AstSassMap(pub Vec<(Spanned<AstExpr>, AstExpr)>);
pub struct AstSassMap(pub Vec<(Spanned<AstExpr>, AstExpr)>);

#[derive(Debug, Clone)]
pub(crate) struct BinaryOpExpr {
pub struct BinaryOpExpr {
pub lhs: AstExpr,
pub op: BinaryOp,
pub rhs: AstExpr,
Expand All @@ -50,7 +50,7 @@ pub(crate) struct BinaryOpExpr {
}

#[derive(Debug, Clone)]
pub(crate) enum AstExpr {
pub enum AstExpr {
BinaryOp(Arc<BinaryOpExpr>),
True,
False,
Expand Down Expand Up @@ -83,7 +83,7 @@ pub(crate) enum AstExpr {
// todo: make quotes bool
// todo: track span inside
#[derive(Debug, Clone)]
pub(crate) struct StringExpr(pub Interpolation, pub QuoteKind);
pub struct StringExpr(pub Interpolation, pub QuoteKind);

impl StringExpr {
fn quote_inner_text(
Expand Down
4 changes: 2 additions & 2 deletions crates/compiler/src/ast/interpolation.rs
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ use codemap::Spanned;
use super::AstExpr;

#[derive(Debug, Clone)]
pub(crate) struct Interpolation {
pub struct Interpolation {
pub contents: Vec<InterpolationPart>,
}

Expand Down Expand Up @@ -81,7 +81,7 @@ impl Interpolation {
}

#[derive(Debug, Clone)]
pub(crate) enum InterpolationPart {
pub enum InterpolationPart {
String(String),
Expr(Spanned<AstExpr>),
}
4 changes: 2 additions & 2 deletions crates/compiler/src/ast/media.rs
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ pub(crate) struct MediaRule {
}

#[derive(Clone, Debug, Eq, PartialEq, Hash)]
pub(crate) struct MediaQuery {
pub struct MediaQuery {
pub modifier: Option<String>,
pub media_type: Option<String>,
pub conditions: Vec<String>,
Expand Down Expand Up @@ -60,7 +60,7 @@ impl MediaQuery {
}

#[allow(clippy::if_not_else)]
pub fn merge(&self, other: &Self) -> MediaQueryMergeResult {
pub(crate) fn merge(&self, other: &Self) -> MediaQueryMergeResult {
if !self.conjunction || !other.conjunction {
return MediaQueryMergeResult::Unrepresentable;
}
Expand Down
8 changes: 4 additions & 4 deletions crates/compiler/src/ast/mod.rs
Original file line number Diff line number Diff line change
@@ -1,10 +1,10 @@
pub(crate) use args::*;
pub use args::*;
pub(crate) use css::*;
pub(crate) use expr::*;
pub(crate) use interpolation::*;
pub use expr::*;
pub use interpolation::*;
pub(crate) use media::*;
pub(crate) use mixin::*;
pub(crate) use stmt::*;
pub use stmt::*;
pub(crate) use style::*;
pub(crate) use unknown::*;

Expand Down

0 comments on commit 8b34d0e

Please sign in to comment.