Use Self:: for matching
This commit is contained in:
parent
622ca8ceef
commit
99dfcb6756
296
src/color.rs
296
src/color.rs
@ -325,154 +325,154 @@ impl TryFrom<&str> for Color {
|
||||
|
||||
fn try_from(string: &str) -> Result<Self, Self::Error> {
|
||||
match string {
|
||||
"aliceblue" => Ok(Color::AliceBlue),
|
||||
"antiquewhite" => Ok(Color::AntiqueWhite),
|
||||
"aqua" => Ok(Color::Aqua),
|
||||
"aquamarine" => Ok(Color::Aquamarine),
|
||||
"azure" => Ok(Color::Azure),
|
||||
"beige" => Ok(Color::Beige),
|
||||
"bisque" => Ok(Color::Bisque),
|
||||
"black" => Ok(Color::Black),
|
||||
"blanchedalmond" => Ok(Color::BlanchedAlmond),
|
||||
"blue" => Ok(Color::Blue),
|
||||
"blueviolet" => Ok(Color::BlueViolet),
|
||||
"brown" => Ok(Color::Brown),
|
||||
"burlywood" => Ok(Color::BurlyWood),
|
||||
"cadetblue" => Ok(Color::CadetBlue),
|
||||
"chartreuse" => Ok(Color::Chartreuse),
|
||||
"chocolate" => Ok(Color::Chocolate),
|
||||
"coral" => Ok(Color::Coral),
|
||||
"cornflowerblue" => Ok(Color::CornflowerBlue),
|
||||
"cornsilk" => Ok(Color::Cornsilk),
|
||||
"crimson" => Ok(Color::Crimson),
|
||||
"cyan" => Ok(Color::Cyan),
|
||||
"darkblue" => Ok(Color::DarkBlue),
|
||||
"darkcyan" => Ok(Color::DarkCyan),
|
||||
"darkgoldenrod" => Ok(Color::DarkGoldenRod),
|
||||
"darkgray" => Ok(Color::DarkGray),
|
||||
"darkgrey" => Ok(Color::DarkGrey),
|
||||
"darkgreen" => Ok(Color::DarkGreen),
|
||||
"darkkhaki" => Ok(Color::DarkKhaki),
|
||||
"darkmagenta" => Ok(Color::DarkMagenta),
|
||||
"darkolivegreen" => Ok(Color::DarkOliveGreen),
|
||||
"darkorange" => Ok(Color::DarkOrange),
|
||||
"darkorchid" => Ok(Color::DarkOrchid),
|
||||
"darkred" => Ok(Color::DarkRed),
|
||||
"darksalmon" => Ok(Color::DarkSalmon),
|
||||
"darkseagreen" => Ok(Color::DarkSeaGreen),
|
||||
"darkslateblue" => Ok(Color::DarkSlateBlue),
|
||||
"darkslategray" => Ok(Color::DarkSlateGray),
|
||||
"darkslategrey" => Ok(Color::DarkSlateGrey),
|
||||
"darkturquoise" => Ok(Color::DarkTurquoise),
|
||||
"darkviolet" => Ok(Color::DarkViolet),
|
||||
"deeppink" => Ok(Color::DeepPink),
|
||||
"deepskyblue" => Ok(Color::DeepSkyBlue),
|
||||
"dimgray" => Ok(Color::DimGray),
|
||||
"dimgrey" => Ok(Color::DimGrey),
|
||||
"dodgerblue" => Ok(Color::DodgerBlue),
|
||||
"firebrick" => Ok(Color::FireBrick),
|
||||
"floralwhite" => Ok(Color::FloralWhite),
|
||||
"forestgreen" => Ok(Color::ForestGreen),
|
||||
"fuchsia" => Ok(Color::Fuchsia),
|
||||
"gainsboro" => Ok(Color::Gainsboro),
|
||||
"ghostwhite" => Ok(Color::GhostWhite),
|
||||
"gold" => Ok(Color::Gold),
|
||||
"goldenrod" => Ok(Color::GoldenRod),
|
||||
"gray" => Ok(Color::Gray),
|
||||
"grey" => Ok(Color::Grey),
|
||||
"green" => Ok(Color::Green),
|
||||
"greenyellow" => Ok(Color::GreenYellow),
|
||||
"honeydew" => Ok(Color::HoneyDew),
|
||||
"hotpink" => Ok(Color::HotPink),
|
||||
"indianred" => Ok(Color::IndianRed),
|
||||
"indigo" => Ok(Color::Indigo),
|
||||
"ivory" => Ok(Color::Ivory),
|
||||
"khaki" => Ok(Color::Khaki),
|
||||
"lavender" => Ok(Color::Lavender),
|
||||
"lavenderblush" => Ok(Color::LavenderBlush),
|
||||
"lawngreen" => Ok(Color::LawnGreen),
|
||||
"lemonchiffon" => Ok(Color::LemonChiffon),
|
||||
"lightblue" => Ok(Color::LightBlue),
|
||||
"lightcoral" => Ok(Color::LightCoral),
|
||||
"lightcyan" => Ok(Color::LightCyan),
|
||||
"lightgoldenrodyellow" => Ok(Color::LightGoldenRodYellow),
|
||||
"lightgray" => Ok(Color::LightGray),
|
||||
"lightgrey" => Ok(Color::LightGrey),
|
||||
"lightgreen" => Ok(Color::LightGreen),
|
||||
"lightpink" => Ok(Color::LightPink),
|
||||
"lightsalmon" => Ok(Color::LightSalmon),
|
||||
"lightseagreen" => Ok(Color::LightSeaGreen),
|
||||
"lightskyblue" => Ok(Color::LightSkyBlue),
|
||||
"lightslategray" => Ok(Color::LightSlateGray),
|
||||
"lightslategrey" => Ok(Color::LightSlateGrey),
|
||||
"lightsteelblue" => Ok(Color::LightSteelBlue),
|
||||
"lightyellow" => Ok(Color::LightYellow),
|
||||
"lime" => Ok(Color::Lime),
|
||||
"limegreen" => Ok(Color::LimeGreen),
|
||||
"linen" => Ok(Color::Linen),
|
||||
"magenta" => Ok(Color::Magenta),
|
||||
"maroon" => Ok(Color::Maroon),
|
||||
"mediumaquamarine" => Ok(Color::MediumAquaMarine),
|
||||
"mediumblue" => Ok(Color::MediumBlue),
|
||||
"mediumorchid" => Ok(Color::MediumOrchid),
|
||||
"mediumpurple" => Ok(Color::MediumPurple),
|
||||
"mediumseagreen" => Ok(Color::MediumSeaGreen),
|
||||
"mediumslateblue" => Ok(Color::MediumSlateBlue),
|
||||
"mediumspringgreen" => Ok(Color::MediumSpringGreen),
|
||||
"mediumturquoise" => Ok(Color::MediumTurquoise),
|
||||
"mediumvioletred" => Ok(Color::MediumVioletRed),
|
||||
"midnightblue" => Ok(Color::MidnightBlue),
|
||||
"mintcream" => Ok(Color::MintCream),
|
||||
"mistyrose" => Ok(Color::MistyRose),
|
||||
"moccasin" => Ok(Color::Moccasin),
|
||||
"navajowhite" => Ok(Color::NavajoWhite),
|
||||
"navy" => Ok(Color::Navy),
|
||||
"oldlace" => Ok(Color::OldLace),
|
||||
"olive" => Ok(Color::Olive),
|
||||
"olivedrab" => Ok(Color::OliveDrab),
|
||||
"orange" => Ok(Color::Orange),
|
||||
"orangered" => Ok(Color::OrangeRed),
|
||||
"orchid" => Ok(Color::Orchid),
|
||||
"palegoldenrod" => Ok(Color::PaleGoldenRod),
|
||||
"palegreen" => Ok(Color::PaleGreen),
|
||||
"paleturquoise" => Ok(Color::PaleTurquoise),
|
||||
"palevioletred" => Ok(Color::PaleVioletRed),
|
||||
"papayawhip" => Ok(Color::PapayaWhip),
|
||||
"peachpuff" => Ok(Color::PeachPuff),
|
||||
"peru" => Ok(Color::Peru),
|
||||
"pink" => Ok(Color::Pink),
|
||||
"plum" => Ok(Color::Plum),
|
||||
"powderblue" => Ok(Color::PowderBlue),
|
||||
"purple" => Ok(Color::Purple),
|
||||
"rebeccapurple" => Ok(Color::RebeccaPurple),
|
||||
"red" => Ok(Color::Red),
|
||||
"rosybrown" => Ok(Color::RosyBrown),
|
||||
"royalblue" => Ok(Color::RoyalBlue),
|
||||
"saddlebrown" => Ok(Color::SaddleBrown),
|
||||
"salmon" => Ok(Color::Salmon),
|
||||
"sandybrown" => Ok(Color::SandyBrown),
|
||||
"seagreen" => Ok(Color::SeaGreen),
|
||||
"seashell" => Ok(Color::SeaShell),
|
||||
"sienna" => Ok(Color::Sienna),
|
||||
"silver" => Ok(Color::Silver),
|
||||
"skyblue" => Ok(Color::SkyBlue),
|
||||
"slateblue" => Ok(Color::SlateBlue),
|
||||
"slategray" => Ok(Color::SlateGray),
|
||||
"slategrey" => Ok(Color::SlateGrey),
|
||||
"snow" => Ok(Color::Snow),
|
||||
"springgreen" => Ok(Color::SpringGreen),
|
||||
"steelblue" => Ok(Color::SteelBlue),
|
||||
"tan" => Ok(Color::Tan),
|
||||
"teal" => Ok(Color::Teal),
|
||||
"thistle" => Ok(Color::Thistle),
|
||||
"tomato" => Ok(Color::Tomato),
|
||||
"turquoise" => Ok(Color::Turquoise),
|
||||
"violet" => Ok(Color::Violet),
|
||||
"wheat" => Ok(Color::Wheat),
|
||||
"white" => Ok(Color::White),
|
||||
"whitesmoke" => Ok(Color::WhiteSmoke),
|
||||
"yellow" => Ok(Color::Yellow),
|
||||
"yellowgreen" => Ok(Color::YellowGreen),
|
||||
"aliceblue" => Ok(Self::AliceBlue),
|
||||
"antiquewhite" => Ok(Self::AntiqueWhite),
|
||||
"aqua" => Ok(Self::Aqua),
|
||||
"aquamarine" => Ok(Self::Aquamarine),
|
||||
"azure" => Ok(Self::Azure),
|
||||
"beige" => Ok(Self::Beige),
|
||||
"bisque" => Ok(Self::Bisque),
|
||||
"black" => Ok(Self::Black),
|
||||
"blanchedalmond" => Ok(Self::BlanchedAlmond),
|
||||
"blue" => Ok(Self::Blue),
|
||||
"blueviolet" => Ok(Self::BlueViolet),
|
||||
"brown" => Ok(Self::Brown),
|
||||
"burlywood" => Ok(Self::BurlyWood),
|
||||
"cadetblue" => Ok(Self::CadetBlue),
|
||||
"chartreuse" => Ok(Self::Chartreuse),
|
||||
"chocolate" => Ok(Self::Chocolate),
|
||||
"coral" => Ok(Self::Coral),
|
||||
"cornflowerblue" => Ok(Self::CornflowerBlue),
|
||||
"cornsilk" => Ok(Self::Cornsilk),
|
||||
"crimson" => Ok(Self::Crimson),
|
||||
"cyan" => Ok(Self::Cyan),
|
||||
"darkblue" => Ok(Self::DarkBlue),
|
||||
"darkcyan" => Ok(Self::DarkCyan),
|
||||
"darkgoldenrod" => Ok(Self::DarkGoldenRod),
|
||||
"darkgray" => Ok(Self::DarkGray),
|
||||
"darkgrey" => Ok(Self::DarkGrey),
|
||||
"darkgreen" => Ok(Self::DarkGreen),
|
||||
"darkkhaki" => Ok(Self::DarkKhaki),
|
||||
"darkmagenta" => Ok(Self::DarkMagenta),
|
||||
"darkolivegreen" => Ok(Self::DarkOliveGreen),
|
||||
"darkorange" => Ok(Self::DarkOrange),
|
||||
"darkorchid" => Ok(Self::DarkOrchid),
|
||||
"darkred" => Ok(Self::DarkRed),
|
||||
"darksalmon" => Ok(Self::DarkSalmon),
|
||||
"darkseagreen" => Ok(Self::DarkSeaGreen),
|
||||
"darkslateblue" => Ok(Self::DarkSlateBlue),
|
||||
"darkslategray" => Ok(Self::DarkSlateGray),
|
||||
"darkslategrey" => Ok(Self::DarkSlateGrey),
|
||||
"darkturquoise" => Ok(Self::DarkTurquoise),
|
||||
"darkviolet" => Ok(Self::DarkViolet),
|
||||
"deeppink" => Ok(Self::DeepPink),
|
||||
"deepskyblue" => Ok(Self::DeepSkyBlue),
|
||||
"dimgray" => Ok(Self::DimGray),
|
||||
"dimgrey" => Ok(Self::DimGrey),
|
||||
"dodgerblue" => Ok(Self::DodgerBlue),
|
||||
"firebrick" => Ok(Self::FireBrick),
|
||||
"floralwhite" => Ok(Self::FloralWhite),
|
||||
"forestgreen" => Ok(Self::ForestGreen),
|
||||
"fuchsia" => Ok(Self::Fuchsia),
|
||||
"gainsboro" => Ok(Self::Gainsboro),
|
||||
"ghostwhite" => Ok(Self::GhostWhite),
|
||||
"gold" => Ok(Self::Gold),
|
||||
"goldenrod" => Ok(Self::GoldenRod),
|
||||
"gray" => Ok(Self::Gray),
|
||||
"grey" => Ok(Self::Grey),
|
||||
"green" => Ok(Self::Green),
|
||||
"greenyellow" => Ok(Self::GreenYellow),
|
||||
"honeydew" => Ok(Self::HoneyDew),
|
||||
"hotpink" => Ok(Self::HotPink),
|
||||
"indianred" => Ok(Self::IndianRed),
|
||||
"indigo" => Ok(Self::Indigo),
|
||||
"ivory" => Ok(Self::Ivory),
|
||||
"khaki" => Ok(Self::Khaki),
|
||||
"lavender" => Ok(Self::Lavender),
|
||||
"lavenderblush" => Ok(Self::LavenderBlush),
|
||||
"lawngreen" => Ok(Self::LawnGreen),
|
||||
"lemonchiffon" => Ok(Self::LemonChiffon),
|
||||
"lightblue" => Ok(Self::LightBlue),
|
||||
"lightcoral" => Ok(Self::LightCoral),
|
||||
"lightcyan" => Ok(Self::LightCyan),
|
||||
"lightgoldenrodyellow" => Ok(Self::LightGoldenRodYellow),
|
||||
"lightgray" => Ok(Self::LightGray),
|
||||
"lightgrey" => Ok(Self::LightGrey),
|
||||
"lightgreen" => Ok(Self::LightGreen),
|
||||
"lightpink" => Ok(Self::LightPink),
|
||||
"lightsalmon" => Ok(Self::LightSalmon),
|
||||
"lightseagreen" => Ok(Self::LightSeaGreen),
|
||||
"lightskyblue" => Ok(Self::LightSkyBlue),
|
||||
"lightslategray" => Ok(Self::LightSlateGray),
|
||||
"lightslategrey" => Ok(Self::LightSlateGrey),
|
||||
"lightsteelblue" => Ok(Self::LightSteelBlue),
|
||||
"lightyellow" => Ok(Self::LightYellow),
|
||||
"lime" => Ok(Self::Lime),
|
||||
"limegreen" => Ok(Self::LimeGreen),
|
||||
"linen" => Ok(Self::Linen),
|
||||
"magenta" => Ok(Self::Magenta),
|
||||
"maroon" => Ok(Self::Maroon),
|
||||
"mediumaquamarine" => Ok(Self::MediumAquaMarine),
|
||||
"mediumblue" => Ok(Self::MediumBlue),
|
||||
"mediumorchid" => Ok(Self::MediumOrchid),
|
||||
"mediumpurple" => Ok(Self::MediumPurple),
|
||||
"mediumseagreen" => Ok(Self::MediumSeaGreen),
|
||||
"mediumslateblue" => Ok(Self::MediumSlateBlue),
|
||||
"mediumspringgreen" => Ok(Self::MediumSpringGreen),
|
||||
"mediumturquoise" => Ok(Self::MediumTurquoise),
|
||||
"mediumvioletred" => Ok(Self::MediumVioletRed),
|
||||
"midnightblue" => Ok(Self::MidnightBlue),
|
||||
"mintcream" => Ok(Self::MintCream),
|
||||
"mistyrose" => Ok(Self::MistyRose),
|
||||
"moccasin" => Ok(Self::Moccasin),
|
||||
"navajowhite" => Ok(Self::NavajoWhite),
|
||||
"navy" => Ok(Self::Navy),
|
||||
"oldlace" => Ok(Self::OldLace),
|
||||
"olive" => Ok(Self::Olive),
|
||||
"olivedrab" => Ok(Self::OliveDrab),
|
||||
"orange" => Ok(Self::Orange),
|
||||
"orangered" => Ok(Self::OrangeRed),
|
||||
"orchid" => Ok(Self::Orchid),
|
||||
"palegoldenrod" => Ok(Self::PaleGoldenRod),
|
||||
"palegreen" => Ok(Self::PaleGreen),
|
||||
"paleturquoise" => Ok(Self::PaleTurquoise),
|
||||
"palevioletred" => Ok(Self::PaleVioletRed),
|
||||
"papayawhip" => Ok(Self::PapayaWhip),
|
||||
"peachpuff" => Ok(Self::PeachPuff),
|
||||
"peru" => Ok(Self::Peru),
|
||||
"pink" => Ok(Self::Pink),
|
||||
"plum" => Ok(Self::Plum),
|
||||
"powderblue" => Ok(Self::PowderBlue),
|
||||
"purple" => Ok(Self::Purple),
|
||||
"rebeccapurple" => Ok(Self::RebeccaPurple),
|
||||
"red" => Ok(Self::Red),
|
||||
"rosybrown" => Ok(Self::RosyBrown),
|
||||
"royalblue" => Ok(Self::RoyalBlue),
|
||||
"saddlebrown" => Ok(Self::SaddleBrown),
|
||||
"salmon" => Ok(Self::Salmon),
|
||||
"sandybrown" => Ok(Self::SandyBrown),
|
||||
"seagreen" => Ok(Self::SeaGreen),
|
||||
"seashell" => Ok(Self::SeaShell),
|
||||
"sienna" => Ok(Self::Sienna),
|
||||
"silver" => Ok(Self::Silver),
|
||||
"skyblue" => Ok(Self::SkyBlue),
|
||||
"slateblue" => Ok(Self::SlateBlue),
|
||||
"slategray" => Ok(Self::SlateGray),
|
||||
"slategrey" => Ok(Self::SlateGrey),
|
||||
"snow" => Ok(Self::Snow),
|
||||
"springgreen" => Ok(Self::SpringGreen),
|
||||
"steelblue" => Ok(Self::SteelBlue),
|
||||
"tan" => Ok(Self::Tan),
|
||||
"teal" => Ok(Self::Teal),
|
||||
"thistle" => Ok(Self::Thistle),
|
||||
"tomato" => Ok(Self::Tomato),
|
||||
"turquoise" => Ok(Self::Turquoise),
|
||||
"violet" => Ok(Self::Violet),
|
||||
"wheat" => Ok(Self::Wheat),
|
||||
"white" => Ok(Self::White),
|
||||
"whitesmoke" => Ok(Self::WhiteSmoke),
|
||||
"yellow" => Ok(Self::Yellow),
|
||||
"yellowgreen" => Ok(Self::YellowGreen),
|
||||
_ => Err("invalid color"),
|
||||
}
|
||||
}
|
||||
|
348
src/common.rs
348
src/common.rs
@ -67,33 +67,33 @@ pub enum Symbol {
|
||||
impl Display for Symbol {
|
||||
fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result {
|
||||
match self {
|
||||
Symbol::Period => write!(f, "."),
|
||||
Symbol::Hash => write!(f, "#"),
|
||||
Symbol::At => write!(f, "@"),
|
||||
Symbol::Dollar => write!(f, "$"),
|
||||
Symbol::OpenParen => write!(f, "("),
|
||||
Symbol::CloseParen => write!(f, "),"),
|
||||
Symbol::OpenCurlyBrace => write!(f, "{{"),
|
||||
Symbol::CloseCurlyBrace => write!(f, "}}"),
|
||||
Symbol::OpenSquareBrace => write!(f, "["),
|
||||
Symbol::CloseSquareBrace => write!(f, "]"),
|
||||
Symbol::Comma => write!(f, ","),
|
||||
Symbol::Plus => write!(f, "+"),
|
||||
Symbol::Minus => write!(f, "-"),
|
||||
Symbol::Mul => write!(f, "*"),
|
||||
Symbol::Div => write!(f, "/"),
|
||||
Symbol::Colon => write!(f, ":"),
|
||||
Symbol::SemiColon => write!(f, ";"),
|
||||
Symbol::Tilde => write!(f, "~"),
|
||||
Symbol::Gt => write!(f, ">"),
|
||||
Symbol::Lt => write!(f, "<"),
|
||||
Symbol::Xor => write!(f, "^"),
|
||||
Symbol::Equal => write!(f, "="),
|
||||
Symbol::BitOr => write!(f, "|"),
|
||||
Symbol::BitAnd => write!(f, "&"),
|
||||
Symbol::Percent => write!(f, "%"),
|
||||
Symbol::DoubleQuote => write!(f, "\""),
|
||||
Symbol::SingleQuote => write!(f, "'"),
|
||||
Self::Period => write!(f, "."),
|
||||
Self::Hash => write!(f, "#"),
|
||||
Self::At => write!(f, "@"),
|
||||
Self::Dollar => write!(f, "$"),
|
||||
Self::OpenParen => write!(f, "("),
|
||||
Self::CloseParen => write!(f, "),"),
|
||||
Self::OpenCurlyBrace => write!(f, "{{"),
|
||||
Self::CloseCurlyBrace => write!(f, "}}"),
|
||||
Self::OpenSquareBrace => write!(f, "["),
|
||||
Self::CloseSquareBrace => write!(f, "]"),
|
||||
Self::Comma => write!(f, ","),
|
||||
Self::Plus => write!(f, "+"),
|
||||
Self::Minus => write!(f, "-"),
|
||||
Self::Mul => write!(f, "*"),
|
||||
Self::Div => write!(f, "/"),
|
||||
Self::Colon => write!(f, ":"),
|
||||
Self::SemiColon => write!(f, ";"),
|
||||
Self::Tilde => write!(f, "~"),
|
||||
Self::Gt => write!(f, ">"),
|
||||
Self::Lt => write!(f, "<"),
|
||||
Self::Xor => write!(f, "^"),
|
||||
Self::Equal => write!(f, "="),
|
||||
Self::BitOr => write!(f, "|"),
|
||||
Self::BitAnd => write!(f, "&"),
|
||||
Self::Percent => write!(f, "%"),
|
||||
Self::DoubleQuote => write!(f, "\""),
|
||||
Self::SingleQuote => write!(f, "'"),
|
||||
}
|
||||
}
|
||||
}
|
||||
@ -103,33 +103,33 @@ impl TryFrom<char> for Symbol {
|
||||
|
||||
fn try_from(c: char) -> Result<Self, Self::Error> {
|
||||
match c {
|
||||
'.' => Ok(Symbol::Period),
|
||||
'#' => Ok(Symbol::Hash),
|
||||
'@' => Ok(Symbol::At),
|
||||
'$' => Ok(Symbol::Dollar),
|
||||
'(' => Ok(Symbol::OpenParen),
|
||||
')' => Ok(Symbol::CloseParen),
|
||||
'{' => Ok(Symbol::OpenCurlyBrace),
|
||||
'}' => Ok(Symbol::CloseCurlyBrace),
|
||||
'[' => Ok(Symbol::OpenSquareBrace),
|
||||
']' => Ok(Symbol::CloseSquareBrace),
|
||||
',' => Ok(Symbol::Comma),
|
||||
'+' => Ok(Symbol::Plus),
|
||||
'-' => Ok(Symbol::Minus),
|
||||
'*' => Ok(Symbol::Mul),
|
||||
'/' => Ok(Symbol::Div),
|
||||
':' => Ok(Symbol::Colon),
|
||||
';' => Ok(Symbol::SemiColon),
|
||||
'~' => Ok(Symbol::Tilde),
|
||||
'>' => Ok(Symbol::Gt),
|
||||
'<' => Ok(Symbol::Lt),
|
||||
'^' => Ok(Symbol::Xor),
|
||||
'=' => Ok(Symbol::Equal),
|
||||
'|' => Ok(Symbol::BitOr),
|
||||
'&' => Ok(Symbol::BitAnd),
|
||||
'%' => Ok(Symbol::Percent),
|
||||
'"' => Ok(Symbol::DoubleQuote),
|
||||
'\'' => Ok(Symbol::SingleQuote),
|
||||
'.' => Ok(Self::Period),
|
||||
'#' => Ok(Self::Hash),
|
||||
'@' => Ok(Self::At),
|
||||
'$' => Ok(Self::Dollar),
|
||||
'(' => Ok(Self::OpenParen),
|
||||
')' => Ok(Self::CloseParen),
|
||||
'{' => Ok(Self::OpenCurlyBrace),
|
||||
'}' => Ok(Self::CloseCurlyBrace),
|
||||
'[' => Ok(Self::OpenSquareBrace),
|
||||
']' => Ok(Self::CloseSquareBrace),
|
||||
',' => Ok(Self::Comma),
|
||||
'+' => Ok(Self::Plus),
|
||||
'-' => Ok(Self::Minus),
|
||||
'*' => Ok(Self::Mul),
|
||||
'/' => Ok(Self::Div),
|
||||
':' => Ok(Self::Colon),
|
||||
';' => Ok(Self::SemiColon),
|
||||
'~' => Ok(Self::Tilde),
|
||||
'>' => Ok(Self::Gt),
|
||||
'<' => Ok(Self::Lt),
|
||||
'^' => Ok(Self::Xor),
|
||||
'=' => Ok(Self::Equal),
|
||||
'|' => Ok(Self::BitOr),
|
||||
'&' => Ok(Self::BitAnd),
|
||||
'%' => Ok(Self::Percent),
|
||||
'"' => Ok(Self::DoubleQuote),
|
||||
'\'' => Ok(Self::SingleQuote),
|
||||
_ => Err("invalid symbol"),
|
||||
}
|
||||
}
|
||||
@ -211,38 +211,38 @@ impl TryFrom<&str> for AtRule {
|
||||
|
||||
fn try_from(c: &str) -> Result<Self, &'static str> {
|
||||
match c {
|
||||
"use" => Ok(AtRule::Use),
|
||||
"forward" => Ok(AtRule::Forward),
|
||||
"import" => Ok(AtRule::Import),
|
||||
"mixin" => Ok(AtRule::Mixin),
|
||||
"include" => Ok(AtRule::Include),
|
||||
"function" => Ok(AtRule::Function),
|
||||
"extend" => Ok(AtRule::Extend),
|
||||
"atroot" => Ok(AtRule::AtRoot),
|
||||
"error" => Ok(AtRule::Error),
|
||||
"warn" => Ok(AtRule::Warn),
|
||||
"debug" => Ok(AtRule::Debug),
|
||||
"if" => Ok(AtRule::If),
|
||||
"each" => Ok(AtRule::Each),
|
||||
"for" => Ok(AtRule::For),
|
||||
"while" => Ok(AtRule::While),
|
||||
"charset" => Ok(AtRule::Charset),
|
||||
"namespace" => Ok(AtRule::Namespace),
|
||||
"media" => Ok(AtRule::Media),
|
||||
"supports" => Ok(AtRule::Supports),
|
||||
"page" => Ok(AtRule::Page),
|
||||
"fontface" => Ok(AtRule::FontFace),
|
||||
"keyframes" => Ok(AtRule::Keyframes),
|
||||
"fontfeaturevalues" => Ok(AtRule::FontFeatureValues),
|
||||
"swash" => Ok(AtRule::Swash),
|
||||
"ornaments" => Ok(AtRule::Ornaments),
|
||||
"annotation" => Ok(AtRule::Annotation),
|
||||
"stylistic" => Ok(AtRule::Stylistic),
|
||||
"styleset" => Ok(AtRule::Styleset),
|
||||
"charactervariant" => Ok(AtRule::CharacterVariant),
|
||||
"viewport" => Ok(AtRule::Viewport),
|
||||
"document" => Ok(AtRule::Document),
|
||||
"counterstyle" => Ok(AtRule::CounterStyle),
|
||||
"use" => Ok(Self::Use),
|
||||
"forward" => Ok(Self::Forward),
|
||||
"import" => Ok(Self::Import),
|
||||
"mixin" => Ok(Self::Mixin),
|
||||
"include" => Ok(Self::Include),
|
||||
"function" => Ok(Self::Function),
|
||||
"extend" => Ok(Self::Extend),
|
||||
"atroot" => Ok(Self::AtRoot),
|
||||
"error" => Ok(Self::Error),
|
||||
"warn" => Ok(Self::Warn),
|
||||
"debug" => Ok(Self::Debug),
|
||||
"if" => Ok(Self::If),
|
||||
"each" => Ok(Self::Each),
|
||||
"for" => Ok(Self::For),
|
||||
"while" => Ok(Self::While),
|
||||
"charset" => Ok(Self::Charset),
|
||||
"namespace" => Ok(Self::Namespace),
|
||||
"media" => Ok(Self::Media),
|
||||
"supports" => Ok(Self::Supports),
|
||||
"page" => Ok(Self::Page),
|
||||
"fontface" => Ok(Self::FontFace),
|
||||
"keyframes" => Ok(Self::Keyframes),
|
||||
"fontfeaturevalues" => Ok(Self::FontFeatureValues),
|
||||
"swash" => Ok(Self::Swash),
|
||||
"ornaments" => Ok(Self::Ornaments),
|
||||
"annotation" => Ok(Self::Annotation),
|
||||
"stylistic" => Ok(Self::Stylistic),
|
||||
"styleset" => Ok(Self::Styleset),
|
||||
"charactervariant" => Ok(Self::CharacterVariant),
|
||||
"viewport" => Ok(Self::Viewport),
|
||||
"document" => Ok(Self::Document),
|
||||
"counterstyle" => Ok(Self::CounterStyle),
|
||||
_ => Err("invalid at rule"),
|
||||
}
|
||||
}
|
||||
@ -251,38 +251,38 @@ impl TryFrom<&str> for AtRule {
|
||||
impl Display for AtRule {
|
||||
fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result {
|
||||
match self {
|
||||
AtRule::Use => write!(f, "@use"),
|
||||
AtRule::Forward => write!(f, "@forward"),
|
||||
AtRule::Import => write!(f, "@import"),
|
||||
AtRule::Mixin => write!(f, "@mixin"),
|
||||
AtRule::Include => write!(f, "@include"),
|
||||
AtRule::Function => write!(f, "@function"),
|
||||
AtRule::Extend => write!(f, "@extend"),
|
||||
AtRule::AtRoot => write!(f, "@atroot"),
|
||||
AtRule::Error => write!(f, "@error"),
|
||||
AtRule::Warn => write!(f, "@warn"),
|
||||
AtRule::Debug => write!(f, "@debug"),
|
||||
AtRule::If => write!(f, "@if"),
|
||||
AtRule::Each => write!(f, "@each"),
|
||||
AtRule::For => write!(f, "@for"),
|
||||
AtRule::While => write!(f, "@while"),
|
||||
AtRule::Charset => write!(f, "@charset"),
|
||||
AtRule::Namespace => write!(f, "@namespace"),
|
||||
AtRule::Media => write!(f, "@media"),
|
||||
AtRule::Supports => write!(f, "@supports"),
|
||||
AtRule::Page => write!(f, "@page"),
|
||||
AtRule::FontFace => write!(f, "@fontface"),
|
||||
AtRule::Keyframes => write!(f, "@keyframes"),
|
||||
AtRule::FontFeatureValues => write!(f, "@fontfeaturevalues"),
|
||||
AtRule::Swash => write!(f, "@swash"),
|
||||
AtRule::Ornaments => write!(f, "@ornaments"),
|
||||
AtRule::Annotation => write!(f, "@annotation"),
|
||||
AtRule::Stylistic => write!(f, "@stylistic"),
|
||||
AtRule::Styleset => write!(f, "@styleset"),
|
||||
AtRule::CharacterVariant => write!(f, "@charactervariant"),
|
||||
AtRule::Viewport => write!(f, "@viewport"),
|
||||
AtRule::Document => write!(f, "@document"),
|
||||
AtRule::CounterStyle => write!(f, "@counterstyle"),
|
||||
Self::Use => write!(f, "@use"),
|
||||
Self::Forward => write!(f, "@forward"),
|
||||
Self::Import => write!(f, "@import"),
|
||||
Self::Mixin => write!(f, "@mixin"),
|
||||
Self::Include => write!(f, "@include"),
|
||||
Self::Function => write!(f, "@function"),
|
||||
Self::Extend => write!(f, "@extend"),
|
||||
Self::AtRoot => write!(f, "@atroot"),
|
||||
Self::Error => write!(f, "@error"),
|
||||
Self::Warn => write!(f, "@warn"),
|
||||
Self::Debug => write!(f, "@debug"),
|
||||
Self::If => write!(f, "@if"),
|
||||
Self::Each => write!(f, "@each"),
|
||||
Self::For => write!(f, "@for"),
|
||||
Self::While => write!(f, "@while"),
|
||||
Self::Charset => write!(f, "@charset"),
|
||||
Self::Namespace => write!(f, "@namespace"),
|
||||
Self::Media => write!(f, "@media"),
|
||||
Self::Supports => write!(f, "@supports"),
|
||||
Self::Page => write!(f, "@page"),
|
||||
Self::FontFace => write!(f, "@fontface"),
|
||||
Self::Keyframes => write!(f, "@keyframes"),
|
||||
Self::FontFeatureValues => write!(f, "@fontfeaturevalues"),
|
||||
Self::Swash => write!(f, "@swash"),
|
||||
Self::Ornaments => write!(f, "@ornaments"),
|
||||
Self::Annotation => write!(f, "@annotation"),
|
||||
Self::Stylistic => write!(f, "@stylistic"),
|
||||
Self::Styleset => write!(f, "@styleset"),
|
||||
Self::CharacterVariant => write!(f, "@charactervariant"),
|
||||
Self::Viewport => write!(f, "@viewport"),
|
||||
Self::Document => write!(f, "@document"),
|
||||
Self::CounterStyle => write!(f, "@counterstyle"),
|
||||
}
|
||||
}
|
||||
}
|
||||
@ -298,10 +298,10 @@ pub enum Whitespace {
|
||||
impl Display for Whitespace {
|
||||
fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result {
|
||||
match self {
|
||||
Whitespace::Space => write!(f, " "),
|
||||
Whitespace::Tab => write!(f, "\t"),
|
||||
Whitespace::Newline => writeln!(f),
|
||||
Whitespace::CarriageReturn => write!(f, "\r"),
|
||||
Self::Space => write!(f, " "),
|
||||
Self::Tab => write!(f, "\t"),
|
||||
Self::Newline => writeln!(f),
|
||||
Self::CarriageReturn => write!(f, "\r"),
|
||||
}
|
||||
}
|
||||
}
|
||||
@ -311,10 +311,10 @@ impl TryFrom<char> for Whitespace {
|
||||
|
||||
fn try_from(c: char) -> Result<Self, Self::Error> {
|
||||
match c {
|
||||
' ' => Ok(Whitespace::Space),
|
||||
'\t' => Ok(Whitespace::Tab),
|
||||
'\n' => Ok(Whitespace::Newline),
|
||||
'\r' => Ok(Whitespace::CarriageReturn),
|
||||
' ' => Ok(Self::Space),
|
||||
'\t' => Ok(Self::Tab),
|
||||
'\n' => Ok(Self::Newline),
|
||||
'\r' => Ok(Self::CarriageReturn),
|
||||
_ => Err("invalid whitespace"),
|
||||
}
|
||||
}
|
||||
@ -333,12 +333,12 @@ pub enum Op {
|
||||
impl Display for Op {
|
||||
fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result {
|
||||
match self {
|
||||
Op::Equal => write!(f, "=="),
|
||||
Op::NotEqual => write!(f, "!="),
|
||||
Op::GreaterThanEqual => write!(f, ">="),
|
||||
Op::LessThanEqual => write!(f, "<="),
|
||||
Op::GreaterThan => write!(f, ">"),
|
||||
Op::LessThan => write!(f, "<"),
|
||||
Self::Equal => write!(f, "=="),
|
||||
Self::NotEqual => write!(f, "!="),
|
||||
Self::GreaterThanEqual => write!(f, ">="),
|
||||
Self::LessThanEqual => write!(f, "<="),
|
||||
Self::GreaterThan => write!(f, ">"),
|
||||
Self::LessThan => write!(f, "<"),
|
||||
}
|
||||
}
|
||||
}
|
||||
@ -364,20 +364,20 @@ pub enum Keyword {
|
||||
impl Display for Keyword {
|
||||
fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result {
|
||||
match self {
|
||||
Keyword::Important => write!(f, "!important"),
|
||||
Keyword::Infinity => write!(f, "Infinity"),
|
||||
Keyword::NaN => write!(f, "NaN"),
|
||||
Keyword::Auto => write!(f, "auto"),
|
||||
Keyword::Inherit => write!(f, "inherit"),
|
||||
Keyword::Initial => write!(f, "initial"),
|
||||
Keyword::Unset => write!(f, "unset"),
|
||||
Keyword::True => write!(f, "true"),
|
||||
Keyword::False => write!(f, "false"),
|
||||
Keyword::Not => write!(f, "not"),
|
||||
Keyword::And => write!(f, "and"),
|
||||
Keyword::Or => write!(f, "or"),
|
||||
Keyword::Null => write!(f, "null"),
|
||||
Keyword::In => write!(f, "in"),
|
||||
Self::Important => write!(f, "!important"),
|
||||
Self::Infinity => write!(f, "Infinity"),
|
||||
Self::NaN => write!(f, "NaN"),
|
||||
Self::Auto => write!(f, "auto"),
|
||||
Self::Inherit => write!(f, "inherit"),
|
||||
Self::Initial => write!(f, "initial"),
|
||||
Self::Unset => write!(f, "unset"),
|
||||
Self::True => write!(f, "true"),
|
||||
Self::False => write!(f, "false"),
|
||||
Self::Not => write!(f, "not"),
|
||||
Self::And => write!(f, "and"),
|
||||
Self::Or => write!(f, "or"),
|
||||
Self::Null => write!(f, "null"),
|
||||
Self::In => write!(f, "in"),
|
||||
}
|
||||
}
|
||||
}
|
||||
@ -385,20 +385,20 @@ impl Display for Keyword {
|
||||
impl Into<&'static str> for Keyword {
|
||||
fn into(self) -> &'static str {
|
||||
match self {
|
||||
Keyword::Important => "!important",
|
||||
Keyword::Infinity => "Infinity",
|
||||
Keyword::NaN => "NaN",
|
||||
Keyword::Auto => "auto",
|
||||
Keyword::Inherit => "inherit",
|
||||
Keyword::Initial => "initial",
|
||||
Keyword::Unset => "unset",
|
||||
Keyword::True => "true",
|
||||
Keyword::False => "false",
|
||||
Keyword::Not => "not",
|
||||
Keyword::And => "and",
|
||||
Keyword::Or => "or",
|
||||
Keyword::Null => "null",
|
||||
Keyword::In => "in",
|
||||
Self::Important => "!important",
|
||||
Self::Infinity => "Infinity",
|
||||
Self::NaN => "NaN",
|
||||
Self::Auto => "auto",
|
||||
Self::Inherit => "inherit",
|
||||
Self::Initial => "initial",
|
||||
Self::Unset => "unset",
|
||||
Self::True => "true",
|
||||
Self::False => "false",
|
||||
Self::Not => "not",
|
||||
Self::And => "and",
|
||||
Self::Or => "or",
|
||||
Self::Null => "null",
|
||||
Self::In => "in",
|
||||
}
|
||||
}
|
||||
}
|
||||
@ -409,20 +409,20 @@ impl TryFrom<&str> for Keyword {
|
||||
fn try_from(kw: &str) -> Result<Self, Self::Error> {
|
||||
// todo: case insensitive?
|
||||
match kw {
|
||||
"important" => Ok(Keyword::Important),
|
||||
"infinity" => Ok(Keyword::Infinity),
|
||||
"nan" => Ok(Keyword::NaN),
|
||||
"auto" => Ok(Keyword::Auto),
|
||||
"inherit" => Ok(Keyword::Inherit),
|
||||
"initial" => Ok(Keyword::Initial),
|
||||
"unset" => Ok(Keyword::Unset),
|
||||
"true" => Ok(Keyword::True),
|
||||
"false" => Ok(Keyword::False),
|
||||
"not" => Ok(Keyword::Not),
|
||||
"and" => Ok(Keyword::And),
|
||||
"or" => Ok(Keyword::Or),
|
||||
"null" => Ok(Keyword::Null),
|
||||
"in" => Ok(Keyword::In),
|
||||
"important" => Ok(Self::Important),
|
||||
"infinity" => Ok(Self::Infinity),
|
||||
"nan" => Ok(Self::NaN),
|
||||
"auto" => Ok(Self::Auto),
|
||||
"inherit" => Ok(Self::Inherit),
|
||||
"initial" => Ok(Self::Initial),
|
||||
"unset" => Ok(Self::Unset),
|
||||
"true" => Ok(Self::True),
|
||||
"false" => Ok(Self::False),
|
||||
"not" => Ok(Self::Not),
|
||||
"and" => Ok(Self::And),
|
||||
"or" => Ok(Self::Or),
|
||||
"null" => Ok(Self::Null),
|
||||
"in" => Ok(Self::In),
|
||||
_ => Err("invalid keyword"),
|
||||
}
|
||||
}
|
||||
|
Loading…
x
Reference in New Issue
Block a user