From 3820b26a9325b26acd614bcad57d410e7286226e Mon Sep 17 00:00:00 2001 From: Aleksey Kladov Date: Fri, 6 Nov 2020 18:19:24 +0100 Subject: Generate token for ints and floats --- crates/syntax/src/ast/generated/tokens.rs | 42 +++++++++++++++++++++++++++++++ 1 file changed, 42 insertions(+) (limited to 'crates/syntax') diff --git a/crates/syntax/src/ast/generated/tokens.rs b/crates/syntax/src/ast/generated/tokens.rs index abadd0b61..1b8449221 100644 --- a/crates/syntax/src/ast/generated/tokens.rs +++ b/crates/syntax/src/ast/generated/tokens.rs @@ -89,3 +89,45 @@ impl AstToken for RawString { } fn syntax(&self) -> &SyntaxToken { &self.syntax } } + +#[derive(Debug, Clone, PartialEq, Eq, Hash)] +pub struct IntNumber { + pub(crate) syntax: SyntaxToken, +} +impl std::fmt::Display for IntNumber { + fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result { + std::fmt::Display::fmt(&self.syntax, f) + } +} +impl AstToken for IntNumber { + fn can_cast(kind: SyntaxKind) -> bool { kind == INT_NUMBER } + fn cast(syntax: SyntaxToken) -> Option { + if Self::can_cast(syntax.kind()) { + Some(Self { syntax }) + } else { + None + } + } + fn syntax(&self) -> &SyntaxToken { &self.syntax } +} + +#[derive(Debug, Clone, PartialEq, Eq, Hash)] +pub struct FloatNumber { + pub(crate) syntax: SyntaxToken, +} +impl std::fmt::Display for FloatNumber { + fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result { + std::fmt::Display::fmt(&self.syntax, f) + } +} +impl AstToken for FloatNumber { + fn can_cast(kind: SyntaxKind) -> bool { kind == FLOAT_NUMBER } + fn cast(syntax: SyntaxToken) -> Option { + if Self::can_cast(syntax.kind()) { + Some(Self { syntax }) + } else { + None + } + } + fn syntax(&self) -> &SyntaxToken { &self.syntax } +} -- cgit v1.2.3