diff options
Diffstat (limited to 'src/syntax/token.rs')
| -rw-r--r-- | src/syntax/token.rs | 50 |
1 files changed, 25 insertions, 25 deletions
diff --git a/src/syntax/token.rs b/src/syntax/token.rs index a28c35b6..9a7379ca 100644 --- a/src/syntax/token.rs +++ b/src/syntax/token.rs @@ -3,13 +3,13 @@ use crate::geom::Unit; /// A minimal semantic entity of source code. #[derive(Debug, Copy, Clone, PartialEq)] pub enum Token<'s> { + /// A consecutive non-markup string. + Text(&'s str), /// One or more whitespace characters. /// /// The contained `usize` denotes the number of newlines that were contained /// in the whitespace. Space(usize), - /// A consecutive non-markup string. - Text(&'s str), /// A line comment with inner string contents `//<str>\n`. LineComment(&'s str), @@ -20,6 +20,19 @@ pub enum Token<'s> { /// An end of a block comment that was not started. StarSlash, + /// A left bracket: `[`. + LeftBracket, + /// A right bracket: `]`. + RightBracket, + /// A left brace: `{`. + LeftBrace, + /// A right brace: `}`. + RightBrace, + /// A left parenthesis: `(`. + LeftParen, + /// A right parenthesis: `)`. + RightParen, + /// A star: `*`. Star, /// An underscore: `_`. @@ -35,19 +48,6 @@ pub enum Token<'s> { /// A unicode escape sequence: `\u{1F5FA}`. UnicodeEscape(TokenUnicodeEscape<'s>), - /// A left bracket: `[`. - LeftBracket, - /// A right bracket: `]`. - RightBracket, - /// A left brace: `{`. - LeftBrace, - /// A right brace: `}`. - RightBrace, - /// A left parenthesis: `(`. - LeftParen, - /// A right parenthesis: `)`. - RightParen, - /// A colon: `:`. Colon, /// A comma: `,`. @@ -76,7 +76,7 @@ pub enum Token<'s> { /// A percentage: `50%`. /// /// _Note_: `50%` is stored as `50.0` here, as in the corresponding - /// [literal](super::Lit::Percent). + /// [literal](super::Expr::Percent). Percent(f64), /// A hex value: `#20d82a`. Hex(&'s str), @@ -124,13 +124,20 @@ impl<'s> Token<'s> { /// The natural-language name of this token for use in error messages. pub fn name(self) -> &'static str { match self { - Self::Space(_) => "space", Self::Text(_) => "text", + Self::Space(_) => "space", Self::LineComment(_) => "line comment", Self::BlockComment(_) => "block comment", Self::StarSlash => "end of block comment", + Self::LeftBracket => "opening bracket", + Self::RightBracket => "closing bracket", + Self::LeftBrace => "opening brace", + Self::RightBrace => "closing brace", + Self::LeftParen => "opening paren", + Self::RightParen => "closing paren", + Self::Star => "star", Self::Underscore => "underscore", Self::Backslash => "backslash", @@ -139,13 +146,6 @@ impl<'s> Token<'s> { Self::Raw { .. } => "raw block", Self::UnicodeEscape { .. } => "unicode escape sequence", - Self::LeftBracket => "opening bracket", - Self::RightBracket => "closing bracket", - Self::LeftBrace => "opening brace", - Self::RightBrace => "closing brace", - Self::LeftParen => "opening paren", - Self::RightParen => "closing paren", - Self::Colon => "colon", Self::Comma => "comma", Self::Pipe => "pipe", @@ -153,8 +153,8 @@ impl<'s> Token<'s> { Self::Hyphen => "minus sign", Self::Slash => "slash", - Self::Ident(_) => "identifier", Self::None => "none", + Self::Ident(_) => "identifier", Self::Bool(_) => "bool", Self::Int(_) => "integer", Self::Float(_) => "float", |
