aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--crates/syntax/src/ast/generated/tokens.rs42
-rw-r--r--xtask/src/codegen/gen_syntax.rs6
2 files changed, 47 insertions, 1 deletions
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 {
89 } 89 }
90 fn syntax(&self) -> &SyntaxToken { &self.syntax } 90 fn syntax(&self) -> &SyntaxToken { &self.syntax }
91} 91}
92
93#[derive(Debug, Clone, PartialEq, Eq, Hash)]
94pub struct IntNumber {
95 pub(crate) syntax: SyntaxToken,
96}
97impl std::fmt::Display for IntNumber {
98 fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result {
99 std::fmt::Display::fmt(&self.syntax, f)
100 }
101}
102impl AstToken for IntNumber {
103 fn can_cast(kind: SyntaxKind) -> bool { kind == INT_NUMBER }
104 fn cast(syntax: SyntaxToken) -> Option<Self> {
105 if Self::can_cast(syntax.kind()) {
106 Some(Self { syntax })
107 } else {
108 None
109 }
110 }
111 fn syntax(&self) -> &SyntaxToken { &self.syntax }
112}
113
114#[derive(Debug, Clone, PartialEq, Eq, Hash)]
115pub struct FloatNumber {
116 pub(crate) syntax: SyntaxToken,
117}
118impl std::fmt::Display for FloatNumber {
119 fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result {
120 std::fmt::Display::fmt(&self.syntax, f)
121 }
122}
123impl AstToken for FloatNumber {
124 fn can_cast(kind: SyntaxKind) -> bool { kind == FLOAT_NUMBER }
125 fn cast(syntax: SyntaxToken) -> Option<Self> {
126 if Self::can_cast(syntax.kind()) {
127 Some(Self { syntax })
128 } else {
129 None
130 }
131 }
132 fn syntax(&self) -> &SyntaxToken { &self.syntax }
133}
diff --git a/xtask/src/codegen/gen_syntax.rs b/xtask/src/codegen/gen_syntax.rs
index 02f4095ce..87c934e66 100644
--- a/xtask/src/codegen/gen_syntax.rs
+++ b/xtask/src/codegen/gen_syntax.rs
@@ -504,7 +504,11 @@ impl Field {
504 504
505fn lower(grammar: &Grammar) -> AstSrc { 505fn lower(grammar: &Grammar) -> AstSrc {
506 let mut res = AstSrc::default(); 506 let mut res = AstSrc::default();
507 res.tokens = vec!["Whitespace".into(), "Comment".into(), "String".into(), "RawString".into()]; 507
508 res.tokens = "Whitespace Comment String RawString IntNumber FloatNumber"
509 .split_ascii_whitespace()
510 .map(|it| it.to_string())
511 .collect::<Vec<_>>();
508 512
509 let nodes = grammar.iter().collect::<Vec<_>>(); 513 let nodes = grammar.iter().collect::<Vec<_>>();
510 514