aboutsummaryrefslogtreecommitdiff
path: root/crates/ra_syntax/src/ast
diff options
context:
space:
mode:
Diffstat (limited to 'crates/ra_syntax/src/ast')
-rw-r--r--crates/ra_syntax/src/ast/generated/nodes.rs655
-rw-r--r--crates/ra_syntax/src/ast/generated/tokens.rs651
2 files changed, 653 insertions, 653 deletions
diff --git a/crates/ra_syntax/src/ast/generated/nodes.rs b/crates/ra_syntax/src/ast/generated/nodes.rs
index 7d74c9fc9..18bf30657 100644
--- a/crates/ra_syntax/src/ast/generated/nodes.rs
+++ b/crates/ra_syntax/src/ast/generated/nodes.rs
@@ -2,9 +2,9 @@
2 2
3use super::tokens::*; 3use super::tokens::*;
4use crate::{ 4use crate::{
5 ast::{self, support, AstChildren, AstNode, AstToken}, 5 ast::{self, support, AstChildren, AstNode},
6 SyntaxKind::{self, *}, 6 SyntaxKind::{self, *},
7 SyntaxNode, SyntaxToken, 7 SyntaxNode,
8}; 8};
9#[derive(Debug, Clone, PartialEq, Eq, Hash)] 9#[derive(Debug, Clone, PartialEq, Eq, Hash)]
10pub struct SourceFile { 10pub struct SourceFile {
@@ -5877,657 +5877,6 @@ impl AstNode for Stmt {
5877 } 5877 }
5878} 5878}
5879#[derive(Debug, Clone, PartialEq, Eq, Hash)] 5879#[derive(Debug, Clone, PartialEq, Eq, Hash)]
5880pub enum LeftDelimiter {
5881 LParen(LParen),
5882 LBrack(LBrack),
5883 LCurly(LCurly),
5884}
5885impl From<LParen> for LeftDelimiter {
5886 fn from(node: LParen) -> LeftDelimiter {
5887 LeftDelimiter::LParen(node)
5888 }
5889}
5890impl From<LBrack> for LeftDelimiter {
5891 fn from(node: LBrack) -> LeftDelimiter {
5892 LeftDelimiter::LBrack(node)
5893 }
5894}
5895impl From<LCurly> for LeftDelimiter {
5896 fn from(node: LCurly) -> LeftDelimiter {
5897 LeftDelimiter::LCurly(node)
5898 }
5899}
5900impl std::fmt::Display for LeftDelimiter {
5901 fn fmt(&self, f: &mut std::fmt::Formatter) -> std::fmt::Result {
5902 std::fmt::Display::fmt(self.syntax(), f)
5903 }
5904}
5905impl AstToken for LeftDelimiter {
5906 fn can_cast(kind: SyntaxKind) -> bool {
5907 match kind {
5908 L_PAREN | L_BRACK | L_CURLY => true,
5909 _ => false,
5910 }
5911 }
5912 fn cast(syntax: SyntaxToken) -> Option<Self> {
5913 let res = match syntax.kind() {
5914 L_PAREN => LeftDelimiter::LParen(LParen { syntax }),
5915 L_BRACK => LeftDelimiter::LBrack(LBrack { syntax }),
5916 L_CURLY => LeftDelimiter::LCurly(LCurly { syntax }),
5917 _ => return None,
5918 };
5919 Some(res)
5920 }
5921 fn syntax(&self) -> &SyntaxToken {
5922 match self {
5923 LeftDelimiter::LParen(it) => &it.syntax,
5924 LeftDelimiter::LBrack(it) => &it.syntax,
5925 LeftDelimiter::LCurly(it) => &it.syntax,
5926 }
5927 }
5928}
5929#[derive(Debug, Clone, PartialEq, Eq, Hash)]
5930pub enum RightDelimiter {
5931 RParen(RParen),
5932 RBrack(RBrack),
5933 RCurly(RCurly),
5934}
5935impl From<RParen> for RightDelimiter {
5936 fn from(node: RParen) -> RightDelimiter {
5937 RightDelimiter::RParen(node)
5938 }
5939}
5940impl From<RBrack> for RightDelimiter {
5941 fn from(node: RBrack) -> RightDelimiter {
5942 RightDelimiter::RBrack(node)
5943 }
5944}
5945impl From<RCurly> for RightDelimiter {
5946 fn from(node: RCurly) -> RightDelimiter {
5947 RightDelimiter::RCurly(node)
5948 }
5949}
5950impl std::fmt::Display for RightDelimiter {
5951 fn fmt(&self, f: &mut std::fmt::Formatter) -> std::fmt::Result {
5952 std::fmt::Display::fmt(self.syntax(), f)
5953 }
5954}
5955impl AstToken for RightDelimiter {
5956 fn can_cast(kind: SyntaxKind) -> bool {
5957 match kind {
5958 R_PAREN | R_BRACK | R_CURLY => true,
5959 _ => false,
5960 }
5961 }
5962 fn cast(syntax: SyntaxToken) -> Option<Self> {
5963 let res = match syntax.kind() {
5964 R_PAREN => RightDelimiter::RParen(RParen { syntax }),
5965 R_BRACK => RightDelimiter::RBrack(RBrack { syntax }),
5966 R_CURLY => RightDelimiter::RCurly(RCurly { syntax }),
5967 _ => return None,
5968 };
5969 Some(res)
5970 }
5971 fn syntax(&self) -> &SyntaxToken {
5972 match self {
5973 RightDelimiter::RParen(it) => &it.syntax,
5974 RightDelimiter::RBrack(it) => &it.syntax,
5975 RightDelimiter::RCurly(it) => &it.syntax,
5976 }
5977 }
5978}
5979#[derive(Debug, Clone, PartialEq, Eq, Hash)]
5980pub enum RangeSeparator {
5981 Dotdot(Dotdot),
5982 Dotdotdot(Dotdotdot),
5983 Dotdoteq(Dotdoteq),
5984}
5985impl From<Dotdot> for RangeSeparator {
5986 fn from(node: Dotdot) -> RangeSeparator {
5987 RangeSeparator::Dotdot(node)
5988 }
5989}
5990impl From<Dotdotdot> for RangeSeparator {
5991 fn from(node: Dotdotdot) -> RangeSeparator {
5992 RangeSeparator::Dotdotdot(node)
5993 }
5994}
5995impl From<Dotdoteq> for RangeSeparator {
5996 fn from(node: Dotdoteq) -> RangeSeparator {
5997 RangeSeparator::Dotdoteq(node)
5998 }
5999}
6000impl std::fmt::Display for RangeSeparator {
6001 fn fmt(&self, f: &mut std::fmt::Formatter) -> std::fmt::Result {
6002 std::fmt::Display::fmt(self.syntax(), f)
6003 }
6004}
6005impl AstToken for RangeSeparator {
6006 fn can_cast(kind: SyntaxKind) -> bool {
6007 match kind {
6008 DOTDOT | DOTDOTDOT | DOTDOTEQ => true,
6009 _ => false,
6010 }
6011 }
6012 fn cast(syntax: SyntaxToken) -> Option<Self> {
6013 let res = match syntax.kind() {
6014 DOTDOT => RangeSeparator::Dotdot(Dotdot { syntax }),
6015 DOTDOTDOT => RangeSeparator::Dotdotdot(Dotdotdot { syntax }),
6016 DOTDOTEQ => RangeSeparator::Dotdoteq(Dotdoteq { syntax }),
6017 _ => return None,
6018 };
6019 Some(res)
6020 }
6021 fn syntax(&self) -> &SyntaxToken {
6022 match self {
6023 RangeSeparator::Dotdot(it) => &it.syntax,
6024 RangeSeparator::Dotdotdot(it) => &it.syntax,
6025 RangeSeparator::Dotdoteq(it) => &it.syntax,
6026 }
6027 }
6028}
6029#[derive(Debug, Clone, PartialEq, Eq, Hash)]
6030pub enum BinOp {
6031 Pipepipe(Pipepipe),
6032 Ampamp(Ampamp),
6033 Eqeq(Eqeq),
6034 Neq(Neq),
6035 Lteq(Lteq),
6036 Gteq(Gteq),
6037 LAngle(LAngle),
6038 RAngle(RAngle),
6039 Plus(Plus),
6040 Star(Star),
6041 Minus(Minus),
6042 Slash(Slash),
6043 Percent(Percent),
6044 Shl(Shl),
6045 Shr(Shr),
6046 Caret(Caret),
6047 Pipe(Pipe),
6048 Amp(Amp),
6049 Eq(Eq),
6050 Pluseq(Pluseq),
6051 Slasheq(Slasheq),
6052 Stareq(Stareq),
6053 Percenteq(Percenteq),
6054 Shreq(Shreq),
6055 Shleq(Shleq),
6056 Minuseq(Minuseq),
6057 Pipeeq(Pipeeq),
6058 Ampeq(Ampeq),
6059 Careteq(Careteq),
6060}
6061impl From<Pipepipe> for BinOp {
6062 fn from(node: Pipepipe) -> BinOp {
6063 BinOp::Pipepipe(node)
6064 }
6065}
6066impl From<Ampamp> for BinOp {
6067 fn from(node: Ampamp) -> BinOp {
6068 BinOp::Ampamp(node)
6069 }
6070}
6071impl From<Eqeq> for BinOp {
6072 fn from(node: Eqeq) -> BinOp {
6073 BinOp::Eqeq(node)
6074 }
6075}
6076impl From<Neq> for BinOp {
6077 fn from(node: Neq) -> BinOp {
6078 BinOp::Neq(node)
6079 }
6080}
6081impl From<Lteq> for BinOp {
6082 fn from(node: Lteq) -> BinOp {
6083 BinOp::Lteq(node)
6084 }
6085}
6086impl From<Gteq> for BinOp {
6087 fn from(node: Gteq) -> BinOp {
6088 BinOp::Gteq(node)
6089 }
6090}
6091impl From<LAngle> for BinOp {
6092 fn from(node: LAngle) -> BinOp {
6093 BinOp::LAngle(node)
6094 }
6095}
6096impl From<RAngle> for BinOp {
6097 fn from(node: RAngle) -> BinOp {
6098 BinOp::RAngle(node)
6099 }
6100}
6101impl From<Plus> for BinOp {
6102 fn from(node: Plus) -> BinOp {
6103 BinOp::Plus(node)
6104 }
6105}
6106impl From<Star> for BinOp {
6107 fn from(node: Star) -> BinOp {
6108 BinOp::Star(node)
6109 }
6110}
6111impl From<Minus> for BinOp {
6112 fn from(node: Minus) -> BinOp {
6113 BinOp::Minus(node)
6114 }
6115}
6116impl From<Slash> for BinOp {
6117 fn from(node: Slash) -> BinOp {
6118 BinOp::Slash(node)
6119 }
6120}
6121impl From<Percent> for BinOp {
6122 fn from(node: Percent) -> BinOp {
6123 BinOp::Percent(node)
6124 }
6125}
6126impl From<Shl> for BinOp {
6127 fn from(node: Shl) -> BinOp {
6128 BinOp::Shl(node)
6129 }
6130}
6131impl From<Shr> for BinOp {
6132 fn from(node: Shr) -> BinOp {
6133 BinOp::Shr(node)
6134 }
6135}
6136impl From<Caret> for BinOp {
6137 fn from(node: Caret) -> BinOp {
6138 BinOp::Caret(node)
6139 }
6140}
6141impl From<Pipe> for BinOp {
6142 fn from(node: Pipe) -> BinOp {
6143 BinOp::Pipe(node)
6144 }
6145}
6146impl From<Amp> for BinOp {
6147 fn from(node: Amp) -> BinOp {
6148 BinOp::Amp(node)
6149 }
6150}
6151impl From<Eq> for BinOp {
6152 fn from(node: Eq) -> BinOp {
6153 BinOp::Eq(node)
6154 }
6155}
6156impl From<Pluseq> for BinOp {
6157 fn from(node: Pluseq) -> BinOp {
6158 BinOp::Pluseq(node)
6159 }
6160}
6161impl From<Slasheq> for BinOp {
6162 fn from(node: Slasheq) -> BinOp {
6163 BinOp::Slasheq(node)
6164 }
6165}
6166impl From<Stareq> for BinOp {
6167 fn from(node: Stareq) -> BinOp {
6168 BinOp::Stareq(node)
6169 }
6170}
6171impl From<Percenteq> for BinOp {
6172 fn from(node: Percenteq) -> BinOp {
6173 BinOp::Percenteq(node)
6174 }
6175}
6176impl From<Shreq> for BinOp {
6177 fn from(node: Shreq) -> BinOp {
6178 BinOp::Shreq(node)
6179 }
6180}
6181impl From<Shleq> for BinOp {
6182 fn from(node: Shleq) -> BinOp {
6183 BinOp::Shleq(node)
6184 }
6185}
6186impl From<Minuseq> for BinOp {
6187 fn from(node: Minuseq) -> BinOp {
6188 BinOp::Minuseq(node)
6189 }
6190}
6191impl From<Pipeeq> for BinOp {
6192 fn from(node: Pipeeq) -> BinOp {
6193 BinOp::Pipeeq(node)
6194 }
6195}
6196impl From<Ampeq> for BinOp {
6197 fn from(node: Ampeq) -> BinOp {
6198 BinOp::Ampeq(node)
6199 }
6200}
6201impl From<Careteq> for BinOp {
6202 fn from(node: Careteq) -> BinOp {
6203 BinOp::Careteq(node)
6204 }
6205}
6206impl std::fmt::Display for BinOp {
6207 fn fmt(&self, f: &mut std::fmt::Formatter) -> std::fmt::Result {
6208 std::fmt::Display::fmt(self.syntax(), f)
6209 }
6210}
6211impl AstToken for BinOp {
6212 fn can_cast(kind: SyntaxKind) -> bool {
6213 match kind {
6214 PIPEPIPE | AMPAMP | EQEQ | NEQ | LTEQ | GTEQ | L_ANGLE | R_ANGLE | PLUS | STAR
6215 | MINUS | SLASH | PERCENT | SHL | SHR | CARET | PIPE | AMP | EQ | PLUSEQ | SLASHEQ
6216 | STAREQ | PERCENTEQ | SHREQ | SHLEQ | MINUSEQ | PIPEEQ | AMPEQ | CARETEQ => true,
6217 _ => false,
6218 }
6219 }
6220 fn cast(syntax: SyntaxToken) -> Option<Self> {
6221 let res = match syntax.kind() {
6222 PIPEPIPE => BinOp::Pipepipe(Pipepipe { syntax }),
6223 AMPAMP => BinOp::Ampamp(Ampamp { syntax }),
6224 EQEQ => BinOp::Eqeq(Eqeq { syntax }),
6225 NEQ => BinOp::Neq(Neq { syntax }),
6226 LTEQ => BinOp::Lteq(Lteq { syntax }),
6227 GTEQ => BinOp::Gteq(Gteq { syntax }),
6228 L_ANGLE => BinOp::LAngle(LAngle { syntax }),
6229 R_ANGLE => BinOp::RAngle(RAngle { syntax }),
6230 PLUS => BinOp::Plus(Plus { syntax }),
6231 STAR => BinOp::Star(Star { syntax }),
6232 MINUS => BinOp::Minus(Minus { syntax }),
6233 SLASH => BinOp::Slash(Slash { syntax }),
6234 PERCENT => BinOp::Percent(Percent { syntax }),
6235 SHL => BinOp::Shl(Shl { syntax }),
6236 SHR => BinOp::Shr(Shr { syntax }),
6237 CARET => BinOp::Caret(Caret { syntax }),
6238 PIPE => BinOp::Pipe(Pipe { syntax }),
6239 AMP => BinOp::Amp(Amp { syntax }),
6240 EQ => BinOp::Eq(Eq { syntax }),
6241 PLUSEQ => BinOp::Pluseq(Pluseq { syntax }),
6242 SLASHEQ => BinOp::Slasheq(Slasheq { syntax }),
6243 STAREQ => BinOp::Stareq(Stareq { syntax }),
6244 PERCENTEQ => BinOp::Percenteq(Percenteq { syntax }),
6245 SHREQ => BinOp::Shreq(Shreq { syntax }),
6246 SHLEQ => BinOp::Shleq(Shleq { syntax }),
6247 MINUSEQ => BinOp::Minuseq(Minuseq { syntax }),
6248 PIPEEQ => BinOp::Pipeeq(Pipeeq { syntax }),
6249 AMPEQ => BinOp::Ampeq(Ampeq { syntax }),
6250 CARETEQ => BinOp::Careteq(Careteq { syntax }),
6251 _ => return None,
6252 };
6253 Some(res)
6254 }
6255 fn syntax(&self) -> &SyntaxToken {
6256 match self {
6257 BinOp::Pipepipe(it) => &it.syntax,
6258 BinOp::Ampamp(it) => &it.syntax,
6259 BinOp::Eqeq(it) => &it.syntax,
6260 BinOp::Neq(it) => &it.syntax,
6261 BinOp::Lteq(it) => &it.syntax,
6262 BinOp::Gteq(it) => &it.syntax,
6263 BinOp::LAngle(it) => &it.syntax,
6264 BinOp::RAngle(it) => &it.syntax,
6265 BinOp::Plus(it) => &it.syntax,
6266 BinOp::Star(it) => &it.syntax,
6267 BinOp::Minus(it) => &it.syntax,
6268 BinOp::Slash(it) => &it.syntax,
6269 BinOp::Percent(it) => &it.syntax,
6270 BinOp::Shl(it) => &it.syntax,
6271 BinOp::Shr(it) => &it.syntax,
6272 BinOp::Caret(it) => &it.syntax,
6273 BinOp::Pipe(it) => &it.syntax,
6274 BinOp::Amp(it) => &it.syntax,
6275 BinOp::Eq(it) => &it.syntax,
6276 BinOp::Pluseq(it) => &it.syntax,
6277 BinOp::Slasheq(it) => &it.syntax,
6278 BinOp::Stareq(it) => &it.syntax,
6279 BinOp::Percenteq(it) => &it.syntax,
6280 BinOp::Shreq(it) => &it.syntax,
6281 BinOp::Shleq(it) => &it.syntax,
6282 BinOp::Minuseq(it) => &it.syntax,
6283 BinOp::Pipeeq(it) => &it.syntax,
6284 BinOp::Ampeq(it) => &it.syntax,
6285 BinOp::Careteq(it) => &it.syntax,
6286 }
6287 }
6288}
6289#[derive(Debug, Clone, PartialEq, Eq, Hash)]
6290pub enum PrefixOp {
6291 Minus(Minus),
6292 Excl(Excl),
6293 Star(Star),
6294}
6295impl From<Minus> for PrefixOp {
6296 fn from(node: Minus) -> PrefixOp {
6297 PrefixOp::Minus(node)
6298 }
6299}
6300impl From<Excl> for PrefixOp {
6301 fn from(node: Excl) -> PrefixOp {
6302 PrefixOp::Excl(node)
6303 }
6304}
6305impl From<Star> for PrefixOp {
6306 fn from(node: Star) -> PrefixOp {
6307 PrefixOp::Star(node)
6308 }
6309}
6310impl std::fmt::Display for PrefixOp {
6311 fn fmt(&self, f: &mut std::fmt::Formatter) -> std::fmt::Result {
6312 std::fmt::Display::fmt(self.syntax(), f)
6313 }
6314}
6315impl AstToken for PrefixOp {
6316 fn can_cast(kind: SyntaxKind) -> bool {
6317 match kind {
6318 MINUS | EXCL | STAR => true,
6319 _ => false,
6320 }
6321 }
6322 fn cast(syntax: SyntaxToken) -> Option<Self> {
6323 let res = match syntax.kind() {
6324 MINUS => PrefixOp::Minus(Minus { syntax }),
6325 EXCL => PrefixOp::Excl(Excl { syntax }),
6326 STAR => PrefixOp::Star(Star { syntax }),
6327 _ => return None,
6328 };
6329 Some(res)
6330 }
6331 fn syntax(&self) -> &SyntaxToken {
6332 match self {
6333 PrefixOp::Minus(it) => &it.syntax,
6334 PrefixOp::Excl(it) => &it.syntax,
6335 PrefixOp::Star(it) => &it.syntax,
6336 }
6337 }
6338}
6339#[derive(Debug, Clone, PartialEq, Eq, Hash)]
6340pub enum RangeOp {
6341 Dotdot(Dotdot),
6342 Dotdoteq(Dotdoteq),
6343}
6344impl From<Dotdot> for RangeOp {
6345 fn from(node: Dotdot) -> RangeOp {
6346 RangeOp::Dotdot(node)
6347 }
6348}
6349impl From<Dotdoteq> for RangeOp {
6350 fn from(node: Dotdoteq) -> RangeOp {
6351 RangeOp::Dotdoteq(node)
6352 }
6353}
6354impl std::fmt::Display for RangeOp {
6355 fn fmt(&self, f: &mut std::fmt::Formatter) -> std::fmt::Result {
6356 std::fmt::Display::fmt(self.syntax(), f)
6357 }
6358}
6359impl AstToken for RangeOp {
6360 fn can_cast(kind: SyntaxKind) -> bool {
6361 match kind {
6362 DOTDOT | DOTDOTEQ => true,
6363 _ => false,
6364 }
6365 }
6366 fn cast(syntax: SyntaxToken) -> Option<Self> {
6367 let res = match syntax.kind() {
6368 DOTDOT => RangeOp::Dotdot(Dotdot { syntax }),
6369 DOTDOTEQ => RangeOp::Dotdoteq(Dotdoteq { syntax }),
6370 _ => return None,
6371 };
6372 Some(res)
6373 }
6374 fn syntax(&self) -> &SyntaxToken {
6375 match self {
6376 RangeOp::Dotdot(it) => &it.syntax,
6377 RangeOp::Dotdoteq(it) => &it.syntax,
6378 }
6379 }
6380}
6381#[derive(Debug, Clone, PartialEq, Eq, Hash)]
6382pub enum LiteralToken {
6383 IntNumber(IntNumber),
6384 FloatNumber(FloatNumber),
6385 String(String),
6386 RawString(RawString),
6387 TrueKw(TrueKw),
6388 FalseKw(FalseKw),
6389 ByteString(ByteString),
6390 RawByteString(RawByteString),
6391 Char(Char),
6392 Byte(Byte),
6393}
6394impl From<IntNumber> for LiteralToken {
6395 fn from(node: IntNumber) -> LiteralToken {
6396 LiteralToken::IntNumber(node)
6397 }
6398}
6399impl From<FloatNumber> for LiteralToken {
6400 fn from(node: FloatNumber) -> LiteralToken {
6401 LiteralToken::FloatNumber(node)
6402 }
6403}
6404impl From<String> for LiteralToken {
6405 fn from(node: String) -> LiteralToken {
6406 LiteralToken::String(node)
6407 }
6408}
6409impl From<RawString> for LiteralToken {
6410 fn from(node: RawString) -> LiteralToken {
6411 LiteralToken::RawString(node)
6412 }
6413}
6414impl From<TrueKw> for LiteralToken {
6415 fn from(node: TrueKw) -> LiteralToken {
6416 LiteralToken::TrueKw(node)
6417 }
6418}
6419impl From<FalseKw> for LiteralToken {
6420 fn from(node: FalseKw) -> LiteralToken {
6421 LiteralToken::FalseKw(node)
6422 }
6423}
6424impl From<ByteString> for LiteralToken {
6425 fn from(node: ByteString) -> LiteralToken {
6426 LiteralToken::ByteString(node)
6427 }
6428}
6429impl From<RawByteString> for LiteralToken {
6430 fn from(node: RawByteString) -> LiteralToken {
6431 LiteralToken::RawByteString(node)
6432 }
6433}
6434impl From<Char> for LiteralToken {
6435 fn from(node: Char) -> LiteralToken {
6436 LiteralToken::Char(node)
6437 }
6438}
6439impl From<Byte> for LiteralToken {
6440 fn from(node: Byte) -> LiteralToken {
6441 LiteralToken::Byte(node)
6442 }
6443}
6444impl std::fmt::Display for LiteralToken {
6445 fn fmt(&self, f: &mut std::fmt::Formatter) -> std::fmt::Result {
6446 std::fmt::Display::fmt(self.syntax(), f)
6447 }
6448}
6449impl AstToken for LiteralToken {
6450 fn can_cast(kind: SyntaxKind) -> bool {
6451 match kind {
6452 INT_NUMBER | FLOAT_NUMBER | STRING | RAW_STRING | TRUE_KW | FALSE_KW | BYTE_STRING
6453 | RAW_BYTE_STRING | CHAR | BYTE => true,
6454 _ => false,
6455 }
6456 }
6457 fn cast(syntax: SyntaxToken) -> Option<Self> {
6458 let res = match syntax.kind() {
6459 INT_NUMBER => LiteralToken::IntNumber(IntNumber { syntax }),
6460 FLOAT_NUMBER => LiteralToken::FloatNumber(FloatNumber { syntax }),
6461 STRING => LiteralToken::String(String { syntax }),
6462 RAW_STRING => LiteralToken::RawString(RawString { syntax }),
6463 TRUE_KW => LiteralToken::TrueKw(TrueKw { syntax }),
6464 FALSE_KW => LiteralToken::FalseKw(FalseKw { syntax }),
6465 BYTE_STRING => LiteralToken::ByteString(ByteString { syntax }),
6466 RAW_BYTE_STRING => LiteralToken::RawByteString(RawByteString { syntax }),
6467 CHAR => LiteralToken::Char(Char { syntax }),
6468 BYTE => LiteralToken::Byte(Byte { syntax }),
6469 _ => return None,
6470 };
6471 Some(res)
6472 }
6473 fn syntax(&self) -> &SyntaxToken {
6474 match self {
6475 LiteralToken::IntNumber(it) => &it.syntax,
6476 LiteralToken::FloatNumber(it) => &it.syntax,
6477 LiteralToken::String(it) => &it.syntax,
6478 LiteralToken::RawString(it) => &it.syntax,
6479 LiteralToken::TrueKw(it) => &it.syntax,
6480 LiteralToken::FalseKw(it) => &it.syntax,
6481 LiteralToken::ByteString(it) => &it.syntax,
6482 LiteralToken::RawByteString(it) => &it.syntax,
6483 LiteralToken::Char(it) => &it.syntax,
6484 LiteralToken::Byte(it) => &it.syntax,
6485 }
6486 }
6487}
6488#[derive(Debug, Clone, PartialEq, Eq, Hash)]
6489pub enum NameRefToken {
6490 Ident(Ident),
6491 IntNumber(IntNumber),
6492}
6493impl From<Ident> for NameRefToken {
6494 fn from(node: Ident) -> NameRefToken {
6495 NameRefToken::Ident(node)
6496 }
6497}
6498impl From<IntNumber> for NameRefToken {
6499 fn from(node: IntNumber) -> NameRefToken {
6500 NameRefToken::IntNumber(node)
6501 }
6502}
6503impl std::fmt::Display for NameRefToken {
6504 fn fmt(&self, f: &mut std::fmt::Formatter) -> std::fmt::Result {
6505 std::fmt::Display::fmt(self.syntax(), f)
6506 }
6507}
6508impl AstToken for NameRefToken {
6509 fn can_cast(kind: SyntaxKind) -> bool {
6510 match kind {
6511 IDENT | INT_NUMBER => true,
6512 _ => false,
6513 }
6514 }
6515 fn cast(syntax: SyntaxToken) -> Option<Self> {
6516 let res = match syntax.kind() {
6517 IDENT => NameRefToken::Ident(Ident { syntax }),
6518 INT_NUMBER => NameRefToken::IntNumber(IntNumber { syntax }),
6519 _ => return None,
6520 };
6521 Some(res)
6522 }
6523 fn syntax(&self) -> &SyntaxToken {
6524 match self {
6525 NameRefToken::Ident(it) => &it.syntax,
6526 NameRefToken::IntNumber(it) => &it.syntax,
6527 }
6528 }
6529}
6530#[derive(Debug, Clone, PartialEq, Eq, Hash)]
6531pub enum FieldDefList { 5880pub enum FieldDefList {
6532 RecordFieldDefList(RecordFieldDefList), 5881 RecordFieldDefList(RecordFieldDefList),
6533 TupleFieldDefList(TupleFieldDefList), 5882 TupleFieldDefList(TupleFieldDefList),
diff --git a/crates/ra_syntax/src/ast/generated/tokens.rs b/crates/ra_syntax/src/ast/generated/tokens.rs
index 27b2d2977..3aea5bef1 100644
--- a/crates/ra_syntax/src/ast/generated/tokens.rs
+++ b/crates/ra_syntax/src/ast/generated/tokens.rs
@@ -3056,3 +3056,654 @@ impl AstToken for RDollar {
3056 &self.syntax 3056 &self.syntax
3057 } 3057 }
3058} 3058}
3059#[derive(Debug, Clone, PartialEq, Eq, Hash)]
3060pub enum LeftDelimiter {
3061 LParen(LParen),
3062 LBrack(LBrack),
3063 LCurly(LCurly),
3064}
3065impl From<LParen> for LeftDelimiter {
3066 fn from(node: LParen) -> LeftDelimiter {
3067 LeftDelimiter::LParen(node)
3068 }
3069}
3070impl From<LBrack> for LeftDelimiter {
3071 fn from(node: LBrack) -> LeftDelimiter {
3072 LeftDelimiter::LBrack(node)
3073 }
3074}
3075impl From<LCurly> for LeftDelimiter {
3076 fn from(node: LCurly) -> LeftDelimiter {
3077 LeftDelimiter::LCurly(node)
3078 }
3079}
3080impl std::fmt::Display for LeftDelimiter {
3081 fn fmt(&self, f: &mut std::fmt::Formatter) -> std::fmt::Result {
3082 std::fmt::Display::fmt(self.syntax(), f)
3083 }
3084}
3085impl AstToken for LeftDelimiter {
3086 fn can_cast(kind: SyntaxKind) -> bool {
3087 match kind {
3088 L_PAREN | L_BRACK | L_CURLY => true,
3089 _ => false,
3090 }
3091 }
3092 fn cast(syntax: SyntaxToken) -> Option<Self> {
3093 let res = match syntax.kind() {
3094 L_PAREN => LeftDelimiter::LParen(LParen { syntax }),
3095 L_BRACK => LeftDelimiter::LBrack(LBrack { syntax }),
3096 L_CURLY => LeftDelimiter::LCurly(LCurly { syntax }),
3097 _ => return None,
3098 };
3099 Some(res)
3100 }
3101 fn syntax(&self) -> &SyntaxToken {
3102 match self {
3103 LeftDelimiter::LParen(it) => &it.syntax,
3104 LeftDelimiter::LBrack(it) => &it.syntax,
3105 LeftDelimiter::LCurly(it) => &it.syntax,
3106 }
3107 }
3108}
3109#[derive(Debug, Clone, PartialEq, Eq, Hash)]
3110pub enum RightDelimiter {
3111 RParen(RParen),
3112 RBrack(RBrack),
3113 RCurly(RCurly),
3114}
3115impl From<RParen> for RightDelimiter {
3116 fn from(node: RParen) -> RightDelimiter {
3117 RightDelimiter::RParen(node)
3118 }
3119}
3120impl From<RBrack> for RightDelimiter {
3121 fn from(node: RBrack) -> RightDelimiter {
3122 RightDelimiter::RBrack(node)
3123 }
3124}
3125impl From<RCurly> for RightDelimiter {
3126 fn from(node: RCurly) -> RightDelimiter {
3127 RightDelimiter::RCurly(node)
3128 }
3129}
3130impl std::fmt::Display for RightDelimiter {
3131 fn fmt(&self, f: &mut std::fmt::Formatter) -> std::fmt::Result {
3132 std::fmt::Display::fmt(self.syntax(), f)
3133 }
3134}
3135impl AstToken for RightDelimiter {
3136 fn can_cast(kind: SyntaxKind) -> bool {
3137 match kind {
3138 R_PAREN | R_BRACK | R_CURLY => true,
3139 _ => false,
3140 }
3141 }
3142 fn cast(syntax: SyntaxToken) -> Option<Self> {
3143 let res = match syntax.kind() {
3144 R_PAREN => RightDelimiter::RParen(RParen { syntax }),
3145 R_BRACK => RightDelimiter::RBrack(RBrack { syntax }),
3146 R_CURLY => RightDelimiter::RCurly(RCurly { syntax }),
3147 _ => return None,
3148 };
3149 Some(res)
3150 }
3151 fn syntax(&self) -> &SyntaxToken {
3152 match self {
3153 RightDelimiter::RParen(it) => &it.syntax,
3154 RightDelimiter::RBrack(it) => &it.syntax,
3155 RightDelimiter::RCurly(it) => &it.syntax,
3156 }
3157 }
3158}
3159#[derive(Debug, Clone, PartialEq, Eq, Hash)]
3160pub enum RangeSeparator {
3161 Dotdot(Dotdot),
3162 Dotdotdot(Dotdotdot),
3163 Dotdoteq(Dotdoteq),
3164}
3165impl From<Dotdot> for RangeSeparator {
3166 fn from(node: Dotdot) -> RangeSeparator {
3167 RangeSeparator::Dotdot(node)
3168 }
3169}
3170impl From<Dotdotdot> for RangeSeparator {
3171 fn from(node: Dotdotdot) -> RangeSeparator {
3172 RangeSeparator::Dotdotdot(node)
3173 }
3174}
3175impl From<Dotdoteq> for RangeSeparator {
3176 fn from(node: Dotdoteq) -> RangeSeparator {
3177 RangeSeparator::Dotdoteq(node)
3178 }
3179}
3180impl std::fmt::Display for RangeSeparator {
3181 fn fmt(&self, f: &mut std::fmt::Formatter) -> std::fmt::Result {
3182 std::fmt::Display::fmt(self.syntax(), f)
3183 }
3184}
3185impl AstToken for RangeSeparator {
3186 fn can_cast(kind: SyntaxKind) -> bool {
3187 match kind {
3188 DOTDOT | DOTDOTDOT | DOTDOTEQ => true,
3189 _ => false,
3190 }
3191 }
3192 fn cast(syntax: SyntaxToken) -> Option<Self> {
3193 let res = match syntax.kind() {
3194 DOTDOT => RangeSeparator::Dotdot(Dotdot { syntax }),
3195 DOTDOTDOT => RangeSeparator::Dotdotdot(Dotdotdot { syntax }),
3196 DOTDOTEQ => RangeSeparator::Dotdoteq(Dotdoteq { syntax }),
3197 _ => return None,
3198 };
3199 Some(res)
3200 }
3201 fn syntax(&self) -> &SyntaxToken {
3202 match self {
3203 RangeSeparator::Dotdot(it) => &it.syntax,
3204 RangeSeparator::Dotdotdot(it) => &it.syntax,
3205 RangeSeparator::Dotdoteq(it) => &it.syntax,
3206 }
3207 }
3208}
3209#[derive(Debug, Clone, PartialEq, Eq, Hash)]
3210pub enum BinOp {
3211 Pipepipe(Pipepipe),
3212 Ampamp(Ampamp),
3213 Eqeq(Eqeq),
3214 Neq(Neq),
3215 Lteq(Lteq),
3216 Gteq(Gteq),
3217 LAngle(LAngle),
3218 RAngle(RAngle),
3219 Plus(Plus),
3220 Star(Star),
3221 Minus(Minus),
3222 Slash(Slash),
3223 Percent(Percent),
3224 Shl(Shl),
3225 Shr(Shr),
3226 Caret(Caret),
3227 Pipe(Pipe),
3228 Amp(Amp),
3229 Eq(Eq),
3230 Pluseq(Pluseq),
3231 Slasheq(Slasheq),
3232 Stareq(Stareq),
3233 Percenteq(Percenteq),
3234 Shreq(Shreq),
3235 Shleq(Shleq),
3236 Minuseq(Minuseq),
3237 Pipeeq(Pipeeq),
3238 Ampeq(Ampeq),
3239 Careteq(Careteq),
3240}
3241impl From<Pipepipe> for BinOp {
3242 fn from(node: Pipepipe) -> BinOp {
3243 BinOp::Pipepipe(node)
3244 }
3245}
3246impl From<Ampamp> for BinOp {
3247 fn from(node: Ampamp) -> BinOp {
3248 BinOp::Ampamp(node)
3249 }
3250}
3251impl From<Eqeq> for BinOp {
3252 fn from(node: Eqeq) -> BinOp {
3253 BinOp::Eqeq(node)
3254 }
3255}
3256impl From<Neq> for BinOp {
3257 fn from(node: Neq) -> BinOp {
3258 BinOp::Neq(node)
3259 }
3260}
3261impl From<Lteq> for BinOp {
3262 fn from(node: Lteq) -> BinOp {
3263 BinOp::Lteq(node)
3264 }
3265}
3266impl From<Gteq> for BinOp {
3267 fn from(node: Gteq) -> BinOp {
3268 BinOp::Gteq(node)
3269 }
3270}
3271impl From<LAngle> for BinOp {
3272 fn from(node: LAngle) -> BinOp {
3273 BinOp::LAngle(node)
3274 }
3275}
3276impl From<RAngle> for BinOp {
3277 fn from(node: RAngle) -> BinOp {
3278 BinOp::RAngle(node)
3279 }
3280}
3281impl From<Plus> for BinOp {
3282 fn from(node: Plus) -> BinOp {
3283 BinOp::Plus(node)
3284 }
3285}
3286impl From<Star> for BinOp {
3287 fn from(node: Star) -> BinOp {
3288 BinOp::Star(node)
3289 }
3290}
3291impl From<Minus> for BinOp {
3292 fn from(node: Minus) -> BinOp {
3293 BinOp::Minus(node)
3294 }
3295}
3296impl From<Slash> for BinOp {
3297 fn from(node: Slash) -> BinOp {
3298 BinOp::Slash(node)
3299 }
3300}
3301impl From<Percent> for BinOp {
3302 fn from(node: Percent) -> BinOp {
3303 BinOp::Percent(node)
3304 }
3305}
3306impl From<Shl> for BinOp {
3307 fn from(node: Shl) -> BinOp {
3308 BinOp::Shl(node)
3309 }
3310}
3311impl From<Shr> for BinOp {
3312 fn from(node: Shr) -> BinOp {
3313 BinOp::Shr(node)
3314 }
3315}
3316impl From<Caret> for BinOp {
3317 fn from(node: Caret) -> BinOp {
3318 BinOp::Caret(node)
3319 }
3320}
3321impl From<Pipe> for BinOp {
3322 fn from(node: Pipe) -> BinOp {
3323 BinOp::Pipe(node)
3324 }
3325}
3326impl From<Amp> for BinOp {
3327 fn from(node: Amp) -> BinOp {
3328 BinOp::Amp(node)
3329 }
3330}
3331impl From<Eq> for BinOp {
3332 fn from(node: Eq) -> BinOp {
3333 BinOp::Eq(node)
3334 }
3335}
3336impl From<Pluseq> for BinOp {
3337 fn from(node: Pluseq) -> BinOp {
3338 BinOp::Pluseq(node)
3339 }
3340}
3341impl From<Slasheq> for BinOp {
3342 fn from(node: Slasheq) -> BinOp {
3343 BinOp::Slasheq(node)
3344 }
3345}
3346impl From<Stareq> for BinOp {
3347 fn from(node: Stareq) -> BinOp {
3348 BinOp::Stareq(node)
3349 }
3350}
3351impl From<Percenteq> for BinOp {
3352 fn from(node: Percenteq) -> BinOp {
3353 BinOp::Percenteq(node)
3354 }
3355}
3356impl From<Shreq> for BinOp {
3357 fn from(node: Shreq) -> BinOp {
3358 BinOp::Shreq(node)
3359 }
3360}
3361impl From<Shleq> for BinOp {
3362 fn from(node: Shleq) -> BinOp {
3363 BinOp::Shleq(node)
3364 }
3365}
3366impl From<Minuseq> for BinOp {
3367 fn from(node: Minuseq) -> BinOp {
3368 BinOp::Minuseq(node)
3369 }
3370}
3371impl From<Pipeeq> for BinOp {
3372 fn from(node: Pipeeq) -> BinOp {
3373 BinOp::Pipeeq(node)
3374 }
3375}
3376impl From<Ampeq> for BinOp {
3377 fn from(node: Ampeq) -> BinOp {
3378 BinOp::Ampeq(node)
3379 }
3380}
3381impl From<Careteq> for BinOp {
3382 fn from(node: Careteq) -> BinOp {
3383 BinOp::Careteq(node)
3384 }
3385}
3386impl std::fmt::Display for BinOp {
3387 fn fmt(&self, f: &mut std::fmt::Formatter) -> std::fmt::Result {
3388 std::fmt::Display::fmt(self.syntax(), f)
3389 }
3390}
3391impl AstToken for BinOp {
3392 fn can_cast(kind: SyntaxKind) -> bool {
3393 match kind {
3394 PIPEPIPE | AMPAMP | EQEQ | NEQ | LTEQ | GTEQ | L_ANGLE | R_ANGLE | PLUS | STAR
3395 | MINUS | SLASH | PERCENT | SHL | SHR | CARET | PIPE | AMP | EQ | PLUSEQ | SLASHEQ
3396 | STAREQ | PERCENTEQ | SHREQ | SHLEQ | MINUSEQ | PIPEEQ | AMPEQ | CARETEQ => true,
3397 _ => false,
3398 }
3399 }
3400 fn cast(syntax: SyntaxToken) -> Option<Self> {
3401 let res = match syntax.kind() {
3402 PIPEPIPE => BinOp::Pipepipe(Pipepipe { syntax }),
3403 AMPAMP => BinOp::Ampamp(Ampamp { syntax }),
3404 EQEQ => BinOp::Eqeq(Eqeq { syntax }),
3405 NEQ => BinOp::Neq(Neq { syntax }),
3406 LTEQ => BinOp::Lteq(Lteq { syntax }),
3407 GTEQ => BinOp::Gteq(Gteq { syntax }),
3408 L_ANGLE => BinOp::LAngle(LAngle { syntax }),
3409 R_ANGLE => BinOp::RAngle(RAngle { syntax }),
3410 PLUS => BinOp::Plus(Plus { syntax }),
3411 STAR => BinOp::Star(Star { syntax }),
3412 MINUS => BinOp::Minus(Minus { syntax }),
3413 SLASH => BinOp::Slash(Slash { syntax }),
3414 PERCENT => BinOp::Percent(Percent { syntax }),
3415 SHL => BinOp::Shl(Shl { syntax }),
3416 SHR => BinOp::Shr(Shr { syntax }),
3417 CARET => BinOp::Caret(Caret { syntax }),
3418 PIPE => BinOp::Pipe(Pipe { syntax }),
3419 AMP => BinOp::Amp(Amp { syntax }),
3420 EQ => BinOp::Eq(Eq { syntax }),
3421 PLUSEQ => BinOp::Pluseq(Pluseq { syntax }),
3422 SLASHEQ => BinOp::Slasheq(Slasheq { syntax }),
3423 STAREQ => BinOp::Stareq(Stareq { syntax }),
3424 PERCENTEQ => BinOp::Percenteq(Percenteq { syntax }),
3425 SHREQ => BinOp::Shreq(Shreq { syntax }),
3426 SHLEQ => BinOp::Shleq(Shleq { syntax }),
3427 MINUSEQ => BinOp::Minuseq(Minuseq { syntax }),
3428 PIPEEQ => BinOp::Pipeeq(Pipeeq { syntax }),
3429 AMPEQ => BinOp::Ampeq(Ampeq { syntax }),
3430 CARETEQ => BinOp::Careteq(Careteq { syntax }),
3431 _ => return None,
3432 };
3433 Some(res)
3434 }
3435 fn syntax(&self) -> &SyntaxToken {
3436 match self {
3437 BinOp::Pipepipe(it) => &it.syntax,
3438 BinOp::Ampamp(it) => &it.syntax,
3439 BinOp::Eqeq(it) => &it.syntax,
3440 BinOp::Neq(it) => &it.syntax,
3441 BinOp::Lteq(it) => &it.syntax,
3442 BinOp::Gteq(it) => &it.syntax,
3443 BinOp::LAngle(it) => &it.syntax,
3444 BinOp::RAngle(it) => &it.syntax,
3445 BinOp::Plus(it) => &it.syntax,
3446 BinOp::Star(it) => &it.syntax,
3447 BinOp::Minus(it) => &it.syntax,
3448 BinOp::Slash(it) => &it.syntax,
3449 BinOp::Percent(it) => &it.syntax,
3450 BinOp::Shl(it) => &it.syntax,
3451 BinOp::Shr(it) => &it.syntax,
3452 BinOp::Caret(it) => &it.syntax,
3453 BinOp::Pipe(it) => &it.syntax,
3454 BinOp::Amp(it) => &it.syntax,
3455 BinOp::Eq(it) => &it.syntax,
3456 BinOp::Pluseq(it) => &it.syntax,
3457 BinOp::Slasheq(it) => &it.syntax,
3458 BinOp::Stareq(it) => &it.syntax,
3459 BinOp::Percenteq(it) => &it.syntax,
3460 BinOp::Shreq(it) => &it.syntax,
3461 BinOp::Shleq(it) => &it.syntax,
3462 BinOp::Minuseq(it) => &it.syntax,
3463 BinOp::Pipeeq(it) => &it.syntax,
3464 BinOp::Ampeq(it) => &it.syntax,
3465 BinOp::Careteq(it) => &it.syntax,
3466 }
3467 }
3468}
3469#[derive(Debug, Clone, PartialEq, Eq, Hash)]
3470pub enum PrefixOp {
3471 Minus(Minus),
3472 Excl(Excl),
3473 Star(Star),
3474}
3475impl From<Minus> for PrefixOp {
3476 fn from(node: Minus) -> PrefixOp {
3477 PrefixOp::Minus(node)
3478 }
3479}
3480impl From<Excl> for PrefixOp {
3481 fn from(node: Excl) -> PrefixOp {
3482 PrefixOp::Excl(node)
3483 }
3484}
3485impl From<Star> for PrefixOp {
3486 fn from(node: Star) -> PrefixOp {
3487 PrefixOp::Star(node)
3488 }
3489}
3490impl std::fmt::Display for PrefixOp {
3491 fn fmt(&self, f: &mut std::fmt::Formatter) -> std::fmt::Result {
3492 std::fmt::Display::fmt(self.syntax(), f)
3493 }
3494}
3495impl AstToken for PrefixOp {
3496 fn can_cast(kind: SyntaxKind) -> bool {
3497 match kind {
3498 MINUS | EXCL | STAR => true,
3499 _ => false,
3500 }
3501 }
3502 fn cast(syntax: SyntaxToken) -> Option<Self> {
3503 let res = match syntax.kind() {
3504 MINUS => PrefixOp::Minus(Minus { syntax }),
3505 EXCL => PrefixOp::Excl(Excl { syntax }),
3506 STAR => PrefixOp::Star(Star { syntax }),
3507 _ => return None,
3508 };
3509 Some(res)
3510 }
3511 fn syntax(&self) -> &SyntaxToken {
3512 match self {
3513 PrefixOp::Minus(it) => &it.syntax,
3514 PrefixOp::Excl(it) => &it.syntax,
3515 PrefixOp::Star(it) => &it.syntax,
3516 }
3517 }
3518}
3519#[derive(Debug, Clone, PartialEq, Eq, Hash)]
3520pub enum RangeOp {
3521 Dotdot(Dotdot),
3522 Dotdoteq(Dotdoteq),
3523}
3524impl From<Dotdot> for RangeOp {
3525 fn from(node: Dotdot) -> RangeOp {
3526 RangeOp::Dotdot(node)
3527 }
3528}
3529impl From<Dotdoteq> for RangeOp {
3530 fn from(node: Dotdoteq) -> RangeOp {
3531 RangeOp::Dotdoteq(node)
3532 }
3533}
3534impl std::fmt::Display for RangeOp {
3535 fn fmt(&self, f: &mut std::fmt::Formatter) -> std::fmt::Result {
3536 std::fmt::Display::fmt(self.syntax(), f)
3537 }
3538}
3539impl AstToken for RangeOp {
3540 fn can_cast(kind: SyntaxKind) -> bool {
3541 match kind {
3542 DOTDOT | DOTDOTEQ => true,
3543 _ => false,
3544 }
3545 }
3546 fn cast(syntax: SyntaxToken) -> Option<Self> {
3547 let res = match syntax.kind() {
3548 DOTDOT => RangeOp::Dotdot(Dotdot { syntax }),
3549 DOTDOTEQ => RangeOp::Dotdoteq(Dotdoteq { syntax }),
3550 _ => return None,
3551 };
3552 Some(res)
3553 }
3554 fn syntax(&self) -> &SyntaxToken {
3555 match self {
3556 RangeOp::Dotdot(it) => &it.syntax,
3557 RangeOp::Dotdoteq(it) => &it.syntax,
3558 }
3559 }
3560}
3561#[derive(Debug, Clone, PartialEq, Eq, Hash)]
3562pub enum LiteralToken {
3563 IntNumber(IntNumber),
3564 FloatNumber(FloatNumber),
3565 String(String),
3566 RawString(RawString),
3567 TrueKw(TrueKw),
3568 FalseKw(FalseKw),
3569 ByteString(ByteString),
3570 RawByteString(RawByteString),
3571 Char(Char),
3572 Byte(Byte),
3573}
3574impl From<IntNumber> for LiteralToken {
3575 fn from(node: IntNumber) -> LiteralToken {
3576 LiteralToken::IntNumber(node)
3577 }
3578}
3579impl From<FloatNumber> for LiteralToken {
3580 fn from(node: FloatNumber) -> LiteralToken {
3581 LiteralToken::FloatNumber(node)
3582 }
3583}
3584impl From<String> for LiteralToken {
3585 fn from(node: String) -> LiteralToken {
3586 LiteralToken::String(node)
3587 }
3588}
3589impl From<RawString> for LiteralToken {
3590 fn from(node: RawString) -> LiteralToken {
3591 LiteralToken::RawString(node)
3592 }
3593}
3594impl From<TrueKw> for LiteralToken {
3595 fn from(node: TrueKw) -> LiteralToken {
3596 LiteralToken::TrueKw(node)
3597 }
3598}
3599impl From<FalseKw> for LiteralToken {
3600 fn from(node: FalseKw) -> LiteralToken {
3601 LiteralToken::FalseKw(node)
3602 }
3603}
3604impl From<ByteString> for LiteralToken {
3605 fn from(node: ByteString) -> LiteralToken {
3606 LiteralToken::ByteString(node)
3607 }
3608}
3609impl From<RawByteString> for LiteralToken {
3610 fn from(node: RawByteString) -> LiteralToken {
3611 LiteralToken::RawByteString(node)
3612 }
3613}
3614impl From<Char> for LiteralToken {
3615 fn from(node: Char) -> LiteralToken {
3616 LiteralToken::Char(node)
3617 }
3618}
3619impl From<Byte> for LiteralToken {
3620 fn from(node: Byte) -> LiteralToken {
3621 LiteralToken::Byte(node)
3622 }
3623}
3624impl std::fmt::Display for LiteralToken {
3625 fn fmt(&self, f: &mut std::fmt::Formatter) -> std::fmt::Result {
3626 std::fmt::Display::fmt(self.syntax(), f)
3627 }
3628}
3629impl AstToken for LiteralToken {
3630 fn can_cast(kind: SyntaxKind) -> bool {
3631 match kind {
3632 INT_NUMBER | FLOAT_NUMBER | STRING | RAW_STRING | TRUE_KW | FALSE_KW | BYTE_STRING
3633 | RAW_BYTE_STRING | CHAR | BYTE => true,
3634 _ => false,
3635 }
3636 }
3637 fn cast(syntax: SyntaxToken) -> Option<Self> {
3638 let res = match syntax.kind() {
3639 INT_NUMBER => LiteralToken::IntNumber(IntNumber { syntax }),
3640 FLOAT_NUMBER => LiteralToken::FloatNumber(FloatNumber { syntax }),
3641 STRING => LiteralToken::String(String { syntax }),
3642 RAW_STRING => LiteralToken::RawString(RawString { syntax }),
3643 TRUE_KW => LiteralToken::TrueKw(TrueKw { syntax }),
3644 FALSE_KW => LiteralToken::FalseKw(FalseKw { syntax }),
3645 BYTE_STRING => LiteralToken::ByteString(ByteString { syntax }),
3646 RAW_BYTE_STRING => LiteralToken::RawByteString(RawByteString { syntax }),
3647 CHAR => LiteralToken::Char(Char { syntax }),
3648 BYTE => LiteralToken::Byte(Byte { syntax }),
3649 _ => return None,
3650 };
3651 Some(res)
3652 }
3653 fn syntax(&self) -> &SyntaxToken {
3654 match self {
3655 LiteralToken::IntNumber(it) => &it.syntax,
3656 LiteralToken::FloatNumber(it) => &it.syntax,
3657 LiteralToken::String(it) => &it.syntax,
3658 LiteralToken::RawString(it) => &it.syntax,
3659 LiteralToken::TrueKw(it) => &it.syntax,
3660 LiteralToken::FalseKw(it) => &it.syntax,
3661 LiteralToken::ByteString(it) => &it.syntax,
3662 LiteralToken::RawByteString(it) => &it.syntax,
3663 LiteralToken::Char(it) => &it.syntax,
3664 LiteralToken::Byte(it) => &it.syntax,
3665 }
3666 }
3667}
3668#[derive(Debug, Clone, PartialEq, Eq, Hash)]
3669pub enum NameRefToken {
3670 Ident(Ident),
3671 IntNumber(IntNumber),
3672}
3673impl From<Ident> for NameRefToken {
3674 fn from(node: Ident) -> NameRefToken {
3675 NameRefToken::Ident(node)
3676 }
3677}
3678impl From<IntNumber> for NameRefToken {
3679 fn from(node: IntNumber) -> NameRefToken {
3680 NameRefToken::IntNumber(node)
3681 }
3682}
3683impl std::fmt::Display for NameRefToken {
3684 fn fmt(&self, f: &mut std::fmt::Formatter) -> std::fmt::Result {
3685 std::fmt::Display::fmt(self.syntax(), f)
3686 }
3687}
3688impl AstToken for NameRefToken {
3689 fn can_cast(kind: SyntaxKind) -> bool {
3690 match kind {
3691 IDENT | INT_NUMBER => true,
3692 _ => false,
3693 }
3694 }
3695 fn cast(syntax: SyntaxToken) -> Option<Self> {
3696 let res = match syntax.kind() {
3697 IDENT => NameRefToken::Ident(Ident { syntax }),
3698 INT_NUMBER => NameRefToken::IntNumber(IntNumber { syntax }),
3699 _ => return None,
3700 };
3701 Some(res)
3702 }
3703 fn syntax(&self) -> &SyntaxToken {
3704 match self {
3705 NameRefToken::Ident(it) => &it.syntax,
3706 NameRefToken::IntNumber(it) => &it.syntax,
3707 }
3708 }
3709}