Skip to content

Commit

Permalink
Merge pull request #608 from Sharktheone/css/comma-parsing
Browse files Browse the repository at this point in the history
Css/comma parsing
  • Loading branch information
Sharktheone authored Oct 6, 2024
2 parents 94c9df4 + e91c810 commit 02a4484
Show file tree
Hide file tree
Showing 3 changed files with 10 additions and 1 deletion.
2 changes: 1 addition & 1 deletion crates/gosub_css3/src/parser/value.rs
Original file line number Diff line number Diff line change
Expand Up @@ -50,7 +50,7 @@ impl Css3<'_> {
Ok(Some(node))
}
TokenType::Comma => {
let node = Node::new(NodeType::Operator(",".into()), t.location);
let node = Node::new(NodeType::Comma, t.location);
Ok(Some(node))
}
TokenType::LBracket => Err(CssError::with_location(
Expand Down
7 changes: 7 additions & 0 deletions crates/gosub_css3/src/stylesheet.rs
Original file line number Diff line number Diff line change
Expand Up @@ -474,6 +474,9 @@ impl CssValue {
}
Ok(CssValue::Function(name, list))
}

crate::node::NodeType::Comma => Ok(CssValue::Comma),

_ => Err(CssError::new(
format!("Cannot convert node to CssValue: {:?}", node).as_str(),
)),
Expand Down Expand Up @@ -580,6 +583,10 @@ impl gosub_shared::traits::css3::CssValue for CssValue {
}
}

fn is_comma(&self) -> bool {
matches!(self, CssValue::Comma)
}

fn is_none(&self) -> bool {
matches!(self, CssValue::None)
}
Expand Down
2 changes: 2 additions & 0 deletions crates/gosub_shared/src/traits/css3.rs
Original file line number Diff line number Diff line change
Expand Up @@ -99,5 +99,7 @@ pub trait CssValue: Sized {
fn as_number(&self) -> Option<f32>;
fn as_list(&self) -> Option<Vec<Self>>;

fn is_comma(&self) -> bool;

fn is_none(&self) -> bool;
}

0 comments on commit 02a4484

Please sign in to comment.