difftreelog
refactor deduplicate operator definitions
in: master
9 files changed
crates/jrsonnet-rowan-parser/jsonnet.ungramdiffbeforeafterboth--- a/crates/jrsonnet-rowan-parser/jsonnet.ungram
+++ b/crates/jrsonnet-rowan-parser/jsonnet.ungram
@@ -136,6 +136,7 @@
| '<<' | '>>'
| '+' | '-'
| '*' | '/' | '%'
+| 'META_OBJECT_APPLY!'
| 'ERROR_NO_OPERATOR!'
UnaryOperator =
crates/jrsonnet-rowan-parser/src/binary.rsdiffbeforeafterboth--- a/crates/jrsonnet-rowan-parser/src/binary.rs
+++ /dev/null
@@ -1,48 +0,0 @@
-#[derive(Clone, Copy, Debug, PartialEq, Eq)]
-pub enum BinaryOperator {
- Mul,
- Div,
- Mod,
- Plus,
- Minus,
- ShiftLeft,
- ShiftRight,
- LessThan,
- GreaterThan,
- LessThanOrEqual,
- GreaterThanOrEqual,
- Equal,
- NotEqual,
- BitAnd,
- BitXor,
- BitOr,
- And,
- Or,
- In,
- ObjectApply,
- #[allow(dead_code)]
- Invalid,
-}
-
-impl BinaryOperator {
- pub fn binding_power(&self) -> (u8, u8) {
- match self {
- Self::ObjectApply => (22, 23),
- Self::Mul | Self::Div | Self::Mod => (20, 21),
- Self::Plus | Self::Minus => (18, 19),
- Self::ShiftLeft | Self::ShiftRight => (16, 17),
- Self::LessThan
- | Self::GreaterThan
- | Self::LessThanOrEqual
- | Self::GreaterThanOrEqual
- | Self::In => (14, 15),
- Self::Equal | Self::NotEqual => (12, 13),
- Self::BitAnd => (10, 11),
- Self::BitXor => (8, 9),
- Self::BitOr => (6, 7),
- Self::And => (4, 5),
- Self::Or => (2, 3),
- Self::Invalid => (0, 1),
- }
- }
-}
crates/jrsonnet-rowan-parser/src/generated/nodes.rsdiffbeforeafterboth1//! This is a generated file, please do not edit manually. Changes can be2//! made in codegeneration that lives in `xtask` top-level dir.34#![allow(non_snake_case, clippy::match_like_matches_macro)]5use crate::{6 ast::{support, AstChildren, AstNode, AstToken},7 SyntaxKind::{self, *},8 SyntaxNode, SyntaxToken, T,9};1011#[derive(Debug, Clone, PartialEq, Eq, Hash)]12pub struct SourceFile {13 pub(crate) syntax: SyntaxNode,14}15impl SourceFile {16 pub fn expr(&self) -> Option<Expr> {17 support::child(&self.syntax)18 }19}2021#[derive(Debug, Clone, PartialEq, Eq, Hash)]22pub struct ExprBinary {23 pub(crate) syntax: SyntaxNode,24}25impl ExprBinary {26 pub fn lhs(&self) -> Option<LhsExpr> {27 support::child(&self.syntax)28 }29 pub fn binary_operator(&self) -> Option<BinaryOperator> {30 support::token_child(&self.syntax)31 }32 pub fn rhs(&self) -> Option<Expr> {33 support::child(&self.syntax)34 }35}3637#[derive(Debug, Clone, PartialEq, Eq, Hash)]38pub struct LhsExpr {39 pub(crate) syntax: SyntaxNode,40}41impl LhsExpr {42 pub fn expr(&self) -> Option<Expr> {43 support::child(&self.syntax)44 }45}4647#[derive(Debug, Clone, PartialEq, Eq, Hash)]48pub struct ExprUnary {49 pub(crate) syntax: SyntaxNode,50}51impl ExprUnary {52 pub fn unary_operator(&self) -> Option<UnaryOperator> {53 support::token_child(&self.syntax)54 }55 pub fn rhs(&self) -> Option<Expr> {56 support::child(&self.syntax)57 }58}5960#[derive(Debug, Clone, PartialEq, Eq, Hash)]61pub struct ExprSlice {62 pub(crate) syntax: SyntaxNode,63}64impl ExprSlice {65 pub fn expr(&self) -> Option<Expr> {66 support::child(&self.syntax)67 }68 pub fn slice_desc(&self) -> Option<SliceDesc> {69 support::child(&self.syntax)70 }71}7273#[derive(Debug, Clone, PartialEq, Eq, Hash)]74pub struct SliceDesc {75 pub(crate) syntax: SyntaxNode,76}77impl SliceDesc {78 pub fn l_brack_token(&self) -> Option<SyntaxToken> {79 support::token(&self.syntax, T!['['])80 }81 pub fn from(&self) -> Option<Expr> {82 support::child(&self.syntax)83 }84 pub fn colon_token(&self) -> Option<SyntaxToken> {85 support::token(&self.syntax, T![:])86 }87 pub fn end(&self) -> Option<SliceDescEnd> {88 support::child(&self.syntax)89 }90 pub fn step(&self) -> Option<SliceDescStep> {91 support::child(&self.syntax)92 }93 pub fn r_brack_token(&self) -> Option<SyntaxToken> {94 support::token(&self.syntax, T![']'])95 }96}9798#[derive(Debug, Clone, PartialEq, Eq, Hash)]99pub struct ExprIndex {100 pub(crate) syntax: SyntaxNode,101}102impl ExprIndex {103 pub fn expr(&self) -> Option<Expr> {104 support::child(&self.syntax)105 }106 pub fn dot_token(&self) -> Option<SyntaxToken> {107 support::token(&self.syntax, T![.])108 }109 pub fn index(&self) -> Option<Name> {110 support::child(&self.syntax)111 }112}113114#[derive(Debug, Clone, PartialEq, Eq, Hash)]115pub struct Name {116 pub(crate) syntax: SyntaxNode,117}118impl Name {119 pub fn ident_lit(&self) -> Option<SyntaxToken> {120 support::token(&self.syntax, IDENT)121 }122}123124#[derive(Debug, Clone, PartialEq, Eq, Hash)]125pub struct ExprIndexExpr {126 pub(crate) syntax: SyntaxNode,127}128impl ExprIndexExpr {129 pub fn base(&self) -> Option<LhsExpr> {130 support::child(&self.syntax)131 }132 pub fn l_brack_token(&self) -> Option<SyntaxToken> {133 support::token(&self.syntax, T!['['])134 }135 pub fn index(&self) -> Option<Expr> {136 support::child(&self.syntax)137 }138 pub fn r_brack_token(&self) -> Option<SyntaxToken> {139 support::token(&self.syntax, T![']'])140 }141}142143#[derive(Debug, Clone, PartialEq, Eq, Hash)]144pub struct ExprApply {145 pub(crate) syntax: SyntaxNode,146}147impl ExprApply {148 pub fn expr(&self) -> Option<Expr> {149 support::child(&self.syntax)150 }151 pub fn args_desc(&self) -> Option<ArgsDesc> {152 support::child(&self.syntax)153 }154 pub fn tailstrict_kw_token(&self) -> Option<SyntaxToken> {155 support::token(&self.syntax, T![tailstrict])156 }157}158159#[derive(Debug, Clone, PartialEq, Eq, Hash)]160pub struct ArgsDesc {161 pub(crate) syntax: SyntaxNode,162}163impl ArgsDesc {164 pub fn l_paren_token(&self) -> Option<SyntaxToken> {165 support::token(&self.syntax, T!['('])166 }167 pub fn args(&self) -> AstChildren<Arg> {168 support::children(&self.syntax)169 }170 pub fn r_paren_token(&self) -> Option<SyntaxToken> {171 support::token(&self.syntax, T![')'])172 }173}174175#[derive(Debug, Clone, PartialEq, Eq, Hash)]176pub struct ExprObjExtend {177 pub(crate) syntax: SyntaxNode,178}179impl ExprObjExtend {180 pub fn lhs_expr(&self) -> Option<LhsExpr> {181 support::child(&self.syntax)182 }183 pub fn expr(&self) -> Option<Expr> {184 support::child(&self.syntax)185 }186}187188#[derive(Debug, Clone, PartialEq, Eq, Hash)]189pub struct ExprParened {190 pub(crate) syntax: SyntaxNode,191}192impl ExprParened {193 pub fn l_paren_token(&self) -> Option<SyntaxToken> {194 support::token(&self.syntax, T!['('])195 }196 pub fn expr(&self) -> Option<Expr> {197 support::child(&self.syntax)198 }199 pub fn r_paren_token(&self) -> Option<SyntaxToken> {200 support::token(&self.syntax, T![')'])201 }202}203204#[derive(Debug, Clone, PartialEq, Eq, Hash)]205pub struct ExprLiteral {206 pub(crate) syntax: SyntaxNode,207}208impl ExprLiteral {209 pub fn literal(&self) -> Option<Literal> {210 support::token_child(&self.syntax)211 }212}213214#[derive(Debug, Clone, PartialEq, Eq, Hash)]215pub struct ExprIntrinsicThisFile {216 pub(crate) syntax: SyntaxNode,217}218impl ExprIntrinsicThisFile {219 pub fn intrinsic_this_file_token(&self) -> Option<SyntaxToken> {220 support::token(&self.syntax, T!["$intrinsicThisFile"])221 }222}223224#[derive(Debug, Clone, PartialEq, Eq, Hash)]225pub struct ExprIntrinsicId {226 pub(crate) syntax: SyntaxNode,227}228impl ExprIntrinsicId {229 pub fn intrinsic_id_token(&self) -> Option<SyntaxToken> {230 support::token(&self.syntax, T!["$intrinsicId"])231 }232}233234#[derive(Debug, Clone, PartialEq, Eq, Hash)]235pub struct ExprIntrinsic {236 pub(crate) syntax: SyntaxNode,237}238impl ExprIntrinsic {239 pub fn intrinsic_token(&self) -> Option<SyntaxToken> {240 support::token(&self.syntax, T!["$intrinsic"])241 }242 pub fn l_paren_token(&self) -> Option<SyntaxToken> {243 support::token(&self.syntax, T!['('])244 }245 pub fn name(&self) -> Option<Name> {246 support::child(&self.syntax)247 }248 pub fn r_paren_token(&self) -> Option<SyntaxToken> {249 support::token(&self.syntax, T![')'])250 }251}252253#[derive(Debug, Clone, PartialEq, Eq, Hash)]254pub struct ExprString {255 pub(crate) syntax: SyntaxNode,256}257impl ExprString {258 pub fn text(&self) -> Option<Text> {259 support::token_child(&self.syntax)260 }261}262263#[derive(Debug, Clone, PartialEq, Eq, Hash)]264pub struct ExprNumber {265 pub(crate) syntax: SyntaxNode,266}267impl ExprNumber {268 pub fn number(&self) -> Option<Number> {269 support::token_child(&self.syntax)270 }271}272273#[derive(Debug, Clone, PartialEq, Eq, Hash)]274pub struct ExprArray {275 pub(crate) syntax: SyntaxNode,276}277impl ExprArray {278 pub fn l_brack_token(&self) -> Option<SyntaxToken> {279 support::token(&self.syntax, T!['['])280 }281 pub fn exprs(&self) -> AstChildren<Expr> {282 support::children(&self.syntax)283 }284 pub fn r_brack_token(&self) -> Option<SyntaxToken> {285 support::token(&self.syntax, T![']'])286 }287}288289#[derive(Debug, Clone, PartialEq, Eq, Hash)]290pub struct ExprObject {291 pub(crate) syntax: SyntaxNode,292}293impl ExprObject {294 pub fn l_brace_token(&self) -> Option<SyntaxToken> {295 support::token(&self.syntax, T!['{'])296 }297 pub fn obj_body(&self) -> Option<ObjBody> {298 support::child(&self.syntax)299 }300 pub fn r_brace_token(&self) -> Option<SyntaxToken> {301 support::token(&self.syntax, T!['}'])302 }303}304305#[derive(Debug, Clone, PartialEq, Eq, Hash)]306pub struct ExprArrayComp {307 pub(crate) syntax: SyntaxNode,308}309impl ExprArrayComp {310 pub fn l_brack_token(&self) -> Option<SyntaxToken> {311 support::token(&self.syntax, T!['['])312 }313 pub fn expr(&self) -> Option<Expr> {314 support::child(&self.syntax)315 }316 pub fn comma_token(&self) -> Option<SyntaxToken> {317 support::token(&self.syntax, T![,])318 }319 pub fn comp_specs(&self) -> AstChildren<CompSpec> {320 support::children(&self.syntax)321 }322 pub fn r_brack_token(&self) -> Option<SyntaxToken> {323 support::token(&self.syntax, T![']'])324 }325}326327#[derive(Debug, Clone, PartialEq, Eq, Hash)]328pub struct ExprImport {329 pub(crate) syntax: SyntaxNode,330}331impl ExprImport {332 pub fn import_kind(&self) -> Option<ImportKind> {333 support::token_child(&self.syntax)334 }335 pub fn text(&self) -> Option<Text> {336 support::token_child(&self.syntax)337 }338}339340#[derive(Debug, Clone, PartialEq, Eq, Hash)]341pub struct ExprVar {342 pub(crate) syntax: SyntaxNode,343}344impl ExprVar {345 pub fn name(&self) -> Option<Name> {346 support::child(&self.syntax)347 }348}349350#[derive(Debug, Clone, PartialEq, Eq, Hash)]351pub struct ExprLocal {352 pub(crate) syntax: SyntaxNode,353}354impl ExprLocal {355 pub fn local_kw_token(&self) -> Option<SyntaxToken> {356 support::token(&self.syntax, T![local])357 }358 pub fn binds(&self) -> AstChildren<Bind> {359 support::children(&self.syntax)360 }361 pub fn semi_token(&self) -> Option<SyntaxToken> {362 support::token(&self.syntax, T![;])363 }364 pub fn expr(&self) -> Option<Expr> {365 support::child(&self.syntax)366 }367}368369#[derive(Debug, Clone, PartialEq, Eq, Hash)]370pub struct ExprIfThenElse {371 pub(crate) syntax: SyntaxNode,372}373impl ExprIfThenElse {374 pub fn if_kw_token(&self) -> Option<SyntaxToken> {375 support::token(&self.syntax, T![if])376 }377 pub fn cond(&self) -> Option<Expr> {378 support::child(&self.syntax)379 }380 pub fn then_kw_token(&self) -> Option<SyntaxToken> {381 support::token(&self.syntax, T![then])382 }383 pub fn then(&self) -> Option<TrueExpr> {384 support::child(&self.syntax)385 }386 pub fn else_kw_token(&self) -> Option<SyntaxToken> {387 support::token(&self.syntax, T![else])388 }389 pub fn else_(&self) -> Option<FalseExpr> {390 support::child(&self.syntax)391 }392}393394#[derive(Debug, Clone, PartialEq, Eq, Hash)]395pub struct TrueExpr {396 pub(crate) syntax: SyntaxNode,397}398impl TrueExpr {399 pub fn expr(&self) -> Option<Expr> {400 support::child(&self.syntax)401 }402}403404#[derive(Debug, Clone, PartialEq, Eq, Hash)]405pub struct FalseExpr {406 pub(crate) syntax: SyntaxNode,407}408impl FalseExpr {409 pub fn expr(&self) -> Option<Expr> {410 support::child(&self.syntax)411 }412}413414#[derive(Debug, Clone, PartialEq, Eq, Hash)]415pub struct ExprFunction {416 pub(crate) syntax: SyntaxNode,417}418impl ExprFunction {419 pub fn function_kw_token(&self) -> Option<SyntaxToken> {420 support::token(&self.syntax, T![function])421 }422 pub fn l_paren_token(&self) -> Option<SyntaxToken> {423 support::token(&self.syntax, T!['('])424 }425 pub fn params_desc(&self) -> Option<ParamsDesc> {426 support::child(&self.syntax)427 }428 pub fn r_paren_token(&self) -> Option<SyntaxToken> {429 support::token(&self.syntax, T![')'])430 }431 pub fn expr(&self) -> Option<Expr> {432 support::child(&self.syntax)433 }434}435436#[derive(Debug, Clone, PartialEq, Eq, Hash)]437pub struct ParamsDesc {438 pub(crate) syntax: SyntaxNode,439}440impl ParamsDesc {441 pub fn l_paren_token(&self) -> Option<SyntaxToken> {442 support::token(&self.syntax, T!['('])443 }444 pub fn params(&self) -> AstChildren<Param> {445 support::children(&self.syntax)446 }447 pub fn r_paren_token(&self) -> Option<SyntaxToken> {448 support::token(&self.syntax, T![')'])449 }450}451452#[derive(Debug, Clone, PartialEq, Eq, Hash)]453pub struct ExprAssert {454 pub(crate) syntax: SyntaxNode,455}456impl ExprAssert {457 pub fn assertion(&self) -> Option<Assertion> {458 support::child(&self.syntax)459 }460 pub fn semi_token(&self) -> Option<SyntaxToken> {461 support::token(&self.syntax, T![;])462 }463 pub fn expr(&self) -> Option<Expr> {464 support::child(&self.syntax)465 }466}467468#[derive(Debug, Clone, PartialEq, Eq, Hash)]469pub struct Assertion {470 pub(crate) syntax: SyntaxNode,471}472impl Assertion {473 pub fn assert_kw_token(&self) -> Option<SyntaxToken> {474 support::token(&self.syntax, T![assert])475 }476 pub fn condition(&self) -> Option<LhsExpr> {477 support::child(&self.syntax)478 }479 pub fn colon_token(&self) -> Option<SyntaxToken> {480 support::token(&self.syntax, T![:])481 }482 pub fn message(&self) -> Option<Expr> {483 support::child(&self.syntax)484 }485}486487#[derive(Debug, Clone, PartialEq, Eq, Hash)]488pub struct ExprError {489 pub(crate) syntax: SyntaxNode,490}491impl ExprError {492 pub fn error_kw_token(&self) -> Option<SyntaxToken> {493 support::token(&self.syntax, T![error])494 }495 pub fn expr(&self) -> Option<Expr> {496 support::child(&self.syntax)497 }498}499500#[derive(Debug, Clone, PartialEq, Eq, Hash)]501pub struct SliceDescEnd {502 pub(crate) syntax: SyntaxNode,503}504impl SliceDescEnd {505 pub fn expr(&self) -> Option<Expr> {506 support::child(&self.syntax)507 }508}509510#[derive(Debug, Clone, PartialEq, Eq, Hash)]511pub struct SliceDescStep {512 pub(crate) syntax: SyntaxNode,513}514impl SliceDescStep {515 pub fn expr(&self) -> Option<Expr> {516 support::child(&self.syntax)517 }518}519520#[derive(Debug, Clone, PartialEq, Eq, Hash)]521pub struct Arg {522 pub(crate) syntax: SyntaxNode,523}524impl Arg {525 pub fn name(&self) -> Option<Name> {526 support::child(&self.syntax)527 }528 pub fn assign_token(&self) -> Option<SyntaxToken> {529 support::token(&self.syntax, T![=])530 }531 pub fn expr(&self) -> Option<Expr> {532 support::child(&self.syntax)533 }534}535536#[derive(Debug, Clone, PartialEq, Eq, Hash)]537pub struct ObjBodyComp {538 pub(crate) syntax: SyntaxNode,539}540impl ObjBodyComp {541 pub fn pre(&self) -> AstChildren<ObjLocalPostComma> {542 support::children(&self.syntax)543 }544 pub fn l_brack_token(&self) -> Option<SyntaxToken> {545 support::token(&self.syntax, T!['['])546 }547 pub fn key(&self) -> Option<LhsExpr> {548 support::child(&self.syntax)549 }550 pub fn r_brack_token(&self) -> Option<SyntaxToken> {551 support::token(&self.syntax, T![']'])552 }553 pub fn plus_token(&self) -> Option<SyntaxToken> {554 support::token(&self.syntax, T![+])555 }556 pub fn colon_token(&self) -> Option<SyntaxToken> {557 support::token(&self.syntax, T![:])558 }559 pub fn value(&self) -> Option<Expr> {560 support::child(&self.syntax)561 }562 pub fn post(&self) -> AstChildren<ObjLocalPreComma> {563 support::children(&self.syntax)564 }565 pub fn comp_specs(&self) -> AstChildren<CompSpec> {566 support::children(&self.syntax)567 }568}569570#[derive(Debug, Clone, PartialEq, Eq, Hash)]571pub struct ObjLocalPostComma {572 pub(crate) syntax: SyntaxNode,573}574impl ObjLocalPostComma {575 pub fn obj_local(&self) -> Option<ObjLocal> {576 support::child(&self.syntax)577 }578 pub fn comma_token(&self) -> Option<SyntaxToken> {579 support::token(&self.syntax, T![,])580 }581}582583#[derive(Debug, Clone, PartialEq, Eq, Hash)]584pub struct ObjLocalPreComma {585 pub(crate) syntax: SyntaxNode,586}587impl ObjLocalPreComma {588 pub fn comma_token(&self) -> Option<SyntaxToken> {589 support::token(&self.syntax, T![,])590 }591 pub fn obj_local(&self) -> Option<ObjLocal> {592 support::child(&self.syntax)593 }594}595596#[derive(Debug, Clone, PartialEq, Eq, Hash)]597pub struct ObjBodyMemberList {598 pub(crate) syntax: SyntaxNode,599}600impl ObjBodyMemberList {601 pub fn members(&self) -> AstChildren<Member> {602 support::children(&self.syntax)603 }604}605606#[derive(Debug, Clone, PartialEq, Eq, Hash)]607pub struct ObjLocal {608 pub(crate) syntax: SyntaxNode,609}610impl ObjLocal {611 pub fn local_kw_token(&self) -> Option<SyntaxToken> {612 support::token(&self.syntax, T![local])613 }614 pub fn bind(&self) -> Option<Bind> {615 support::child(&self.syntax)616 }617}618619#[derive(Debug, Clone, PartialEq, Eq, Hash)]620pub struct MemberBindStmt {621 pub(crate) syntax: SyntaxNode,622}623impl MemberBindStmt {624 pub fn obj_local(&self) -> Option<ObjLocal> {625 support::child(&self.syntax)626 }627}628629#[derive(Debug, Clone, PartialEq, Eq, Hash)]630pub struct MemberAssertStmt {631 pub(crate) syntax: SyntaxNode,632}633impl MemberAssertStmt {634 pub fn assertion(&self) -> Option<Assertion> {635 support::child(&self.syntax)636 }637}638639#[derive(Debug, Clone, PartialEq, Eq, Hash)]640pub struct MemberField {641 pub(crate) syntax: SyntaxNode,642}643impl MemberField {644 pub fn field(&self) -> Option<Field> {645 support::child(&self.syntax)646 }647}648649#[derive(Debug, Clone, PartialEq, Eq, Hash)]650pub struct FieldNormal {651 pub(crate) syntax: SyntaxNode,652}653impl FieldNormal {654 pub fn field_name(&self) -> Option<FieldName> {655 support::child(&self.syntax)656 }657 pub fn plus_token(&self) -> Option<SyntaxToken> {658 support::token(&self.syntax, T![+])659 }660 pub fn visibility(&self) -> Option<Visibility> {661 support::token_child(&self.syntax)662 }663 pub fn expr(&self) -> Option<Expr> {664 support::child(&self.syntax)665 }666}667668#[derive(Debug, Clone, PartialEq, Eq, Hash)]669pub struct FieldMethod {670 pub(crate) syntax: SyntaxNode,671}672impl FieldMethod {673 pub fn field_name(&self) -> Option<FieldName> {674 support::child(&self.syntax)675 }676 pub fn params_desc(&self) -> Option<ParamsDesc> {677 support::child(&self.syntax)678 }679 pub fn visibility(&self) -> Option<Visibility> {680 support::token_child(&self.syntax)681 }682 pub fn expr(&self) -> Option<Expr> {683 support::child(&self.syntax)684 }685}686687#[derive(Debug, Clone, PartialEq, Eq, Hash)]688pub struct FieldNameFixed {689 pub(crate) syntax: SyntaxNode,690}691impl FieldNameFixed {692 pub fn id(&self) -> Option<Name> {693 support::child(&self.syntax)694 }695 pub fn text(&self) -> Option<Text> {696 support::token_child(&self.syntax)697 }698}699700#[derive(Debug, Clone, PartialEq, Eq, Hash)]701pub struct FieldNameDynamic {702 pub(crate) syntax: SyntaxNode,703}704impl FieldNameDynamic {705 pub fn l_brack_token(&self) -> Option<SyntaxToken> {706 support::token(&self.syntax, T!['['])707 }708 pub fn expr(&self) -> Option<Expr> {709 support::child(&self.syntax)710 }711 pub fn r_brack_token(&self) -> Option<SyntaxToken> {712 support::token(&self.syntax, T![']'])713 }714}715716#[derive(Debug, Clone, PartialEq, Eq, Hash)]717pub struct ForSpec {718 pub(crate) syntax: SyntaxNode,719}720impl ForSpec {721 pub fn for_kw_token(&self) -> Option<SyntaxToken> {722 support::token(&self.syntax, T![for])723 }724 pub fn bind(&self) -> Option<Name> {725 support::child(&self.syntax)726 }727 pub fn in_kw_token(&self) -> Option<SyntaxToken> {728 support::token(&self.syntax, T![in])729 }730 pub fn expr(&self) -> Option<Expr> {731 support::child(&self.syntax)732 }733}734735#[derive(Debug, Clone, PartialEq, Eq, Hash)]736pub struct IfSpec {737 pub(crate) syntax: SyntaxNode,738}739impl IfSpec {740 pub fn if_kw_token(&self) -> Option<SyntaxToken> {741 support::token(&self.syntax, T![if])742 }743 pub fn expr(&self) -> Option<Expr> {744 support::child(&self.syntax)745 }746}747748#[derive(Debug, Clone, PartialEq, Eq, Hash)]749pub struct BindDestruct {750 pub(crate) syntax: SyntaxNode,751}752impl BindDestruct {753 pub fn into(&self) -> Option<Destruct> {754 support::child(&self.syntax)755 }756 pub fn assign_token(&self) -> Option<SyntaxToken> {757 support::token(&self.syntax, T![=])758 }759 pub fn value(&self) -> Option<Expr> {760 support::child(&self.syntax)761 }762}763764#[derive(Debug, Clone, PartialEq, Eq, Hash)]765pub struct BindFunction {766 pub(crate) syntax: SyntaxNode,767}768impl BindFunction {769 pub fn name(&self) -> Option<Name> {770 support::child(&self.syntax)771 }772 pub fn params(&self) -> Option<ParamsDesc> {773 support::child(&self.syntax)774 }775 pub fn assign_token(&self) -> Option<SyntaxToken> {776 support::token(&self.syntax, T![=])777 }778 pub fn value(&self) -> Option<Expr> {779 support::child(&self.syntax)780 }781}782783#[derive(Debug, Clone, PartialEq, Eq, Hash)]784pub struct Param {785 pub(crate) syntax: SyntaxNode,786}787impl Param {788 pub fn destruct(&self) -> Option<Destruct> {789 support::child(&self.syntax)790 }791 pub fn assign_token(&self) -> Option<SyntaxToken> {792 support::token(&self.syntax, T![=])793 }794 pub fn expr(&self) -> Option<Expr> {795 support::child(&self.syntax)796 }797}798799#[derive(Debug, Clone, PartialEq, Eq, Hash)]800pub struct DestructFull {801 pub(crate) syntax: SyntaxNode,802}803impl DestructFull {804 pub fn name(&self) -> Option<Name> {805 support::child(&self.syntax)806 }807}808809#[derive(Debug, Clone, PartialEq, Eq, Hash)]810pub struct DestructSkip {811 pub(crate) syntax: SyntaxNode,812}813impl DestructSkip {814 pub fn question_mark_token(&self) -> Option<SyntaxToken> {815 support::token(&self.syntax, T![?])816 }817}818819#[derive(Debug, Clone, PartialEq, Eq, Hash)]820pub struct DestructArray {821 pub(crate) syntax: SyntaxNode,822}823impl DestructArray {824 pub fn l_brack_token(&self) -> Option<SyntaxToken> {825 support::token(&self.syntax, T!['['])826 }827 pub fn destruct_array_parts(&self) -> AstChildren<DestructArrayPart> {828 support::children(&self.syntax)829 }830 pub fn r_brack_token(&self) -> Option<SyntaxToken> {831 support::token(&self.syntax, T![']'])832 }833}834835#[derive(Debug, Clone, PartialEq, Eq, Hash)]836pub struct DestructObject {837 pub(crate) syntax: SyntaxNode,838}839impl DestructObject {840 pub fn l_brace_token(&self) -> Option<SyntaxToken> {841 support::token(&self.syntax, T!['{'])842 }843 pub fn destruct_object_fields(&self) -> AstChildren<DestructObjectField> {844 support::children(&self.syntax)845 }846 pub fn destruct_rest(&self) -> Option<DestructRest> {847 support::child(&self.syntax)848 }849 pub fn comma_token(&self) -> Option<SyntaxToken> {850 support::token(&self.syntax, T![,])851 }852 pub fn r_brace_token(&self) -> Option<SyntaxToken> {853 support::token(&self.syntax, T!['}'])854 }855}856857#[derive(Debug, Clone, PartialEq, Eq, Hash)]858pub struct DestructObjectField {859 pub(crate) syntax: SyntaxNode,860}861impl DestructObjectField {862 pub fn field(&self) -> Option<Name> {863 support::child(&self.syntax)864 }865 pub fn colon_token(&self) -> Option<SyntaxToken> {866 support::token(&self.syntax, T![:])867 }868 pub fn destruct(&self) -> Option<Destruct> {869 support::child(&self.syntax)870 }871 pub fn assign_token(&self) -> Option<SyntaxToken> {872 support::token(&self.syntax, T![=])873 }874 pub fn expr(&self) -> Option<Expr> {875 support::child(&self.syntax)876 }877}878879#[derive(Debug, Clone, PartialEq, Eq, Hash)]880pub struct DestructRest {881 pub(crate) syntax: SyntaxNode,882}883impl DestructRest {884 pub fn dotdotdot_token(&self) -> Option<SyntaxToken> {885 support::token(&self.syntax, T![...])886 }887 pub fn into(&self) -> Option<Name> {888 support::child(&self.syntax)889 }890}891892#[derive(Debug, Clone, PartialEq, Eq, Hash)]893pub struct DestructArrayElement {894 pub(crate) syntax: SyntaxNode,895}896impl DestructArrayElement {897 pub fn destruct(&self) -> Option<Destruct> {898 support::child(&self.syntax)899 }900}901902#[derive(Debug, Clone, PartialEq, Eq, Hash)]903pub enum Expr {904 ExprBinary(ExprBinary),905 ExprUnary(ExprUnary),906 ExprSlice(ExprSlice),907 ExprIndex(ExprIndex),908 ExprIndexExpr(ExprIndexExpr),909 ExprApply(ExprApply),910 ExprObjExtend(ExprObjExtend),911 ExprParened(ExprParened),912 ExprIntrinsicThisFile(ExprIntrinsicThisFile),913 ExprIntrinsicId(ExprIntrinsicId),914 ExprIntrinsic(ExprIntrinsic),915 ExprString(ExprString),916 ExprNumber(ExprNumber),917 ExprLiteral(ExprLiteral),918 ExprArray(ExprArray),919 ExprObject(ExprObject),920 ExprArrayComp(ExprArrayComp),921 ExprImport(ExprImport),922 ExprVar(ExprVar),923 ExprLocal(ExprLocal),924 ExprIfThenElse(ExprIfThenElse),925 ExprFunction(ExprFunction),926 ExprAssert(ExprAssert),927 ExprError(ExprError),928}929930#[derive(Debug, Clone, PartialEq, Eq, Hash)]931pub enum ObjBody {932 ObjBodyComp(ObjBodyComp),933 ObjBodyMemberList(ObjBodyMemberList),934}935936#[derive(Debug, Clone, PartialEq, Eq, Hash)]937pub enum CompSpec {938 ForSpec(ForSpec),939 IfSpec(IfSpec),940}941942#[derive(Debug, Clone, PartialEq, Eq, Hash)]943pub enum Bind {944 BindDestruct(BindDestruct),945 BindFunction(BindFunction),946}947948#[derive(Debug, Clone, PartialEq, Eq, Hash)]949pub enum Member {950 MemberBindStmt(MemberBindStmt),951 MemberAssertStmt(MemberAssertStmt),952 MemberField(MemberField),953}954955#[derive(Debug, Clone, PartialEq, Eq, Hash)]956pub enum Field {957 FieldNormal(FieldNormal),958 FieldMethod(FieldMethod),959}960961#[derive(Debug, Clone, PartialEq, Eq, Hash)]962pub enum FieldName {963 FieldNameFixed(FieldNameFixed),964 FieldNameDynamic(FieldNameDynamic),965}966967#[derive(Debug, Clone, PartialEq, Eq, Hash)]968pub enum Destruct {969 DestructFull(DestructFull),970 DestructSkip(DestructSkip),971 DestructArray(DestructArray),972 DestructObject(DestructObject),973}974975#[derive(Debug, Clone, PartialEq, Eq, Hash)]976pub enum DestructArrayPart {977 DestructArrayElement(DestructArrayElement),978 DestructRest(DestructRest),979}980981#[derive(Debug, Clone, PartialEq, Eq, Hash)]982pub struct BinaryOperator {983 syntax: SyntaxToken,984 kind: BinaryOperatorKind,985}986987#[derive(Debug, Clone, Copy, PartialEq, Eq, Hash)]988pub enum BinaryOperatorKind {989 Or,990 And,991 BitOr,992 BitXor,993 BitAnd,994 Eq,995 Ne,996 Lt,997 Gt,998 Le,999 Ge,1000 InKw,1001 Lhs,1002 Rhs,1003 Plus,1004 Minus,1005 Mul,1006 Div,1007 Modulo,1008 ErrorNoOperator,1009}10101011#[derive(Debug, Clone, PartialEq, Eq, Hash)]1012pub struct UnaryOperator {1013 syntax: SyntaxToken,1014 kind: UnaryOperatorKind,1015}10161017#[derive(Debug, Clone, Copy, PartialEq, Eq, Hash)]1018pub enum UnaryOperatorKind {1019 Minus,1020 Not,1021 BitNot,1022}10231024#[derive(Debug, Clone, PartialEq, Eq, Hash)]1025pub struct Literal {1026 syntax: SyntaxToken,1027 kind: LiteralKind,1028}10291030#[derive(Debug, Clone, Copy, PartialEq, Eq, Hash)]1031pub enum LiteralKind {1032 NullKw,1033 TrueKw,1034 FalseKw,1035 SelfKw,1036 Dollar,1037 SuperKw,1038}10391040#[derive(Debug, Clone, PartialEq, Eq, Hash)]1041pub struct Text {1042 syntax: SyntaxToken,1043 kind: TextKind,1044}10451046#[derive(Debug, Clone, Copy, PartialEq, Eq, Hash)]1047pub enum TextKind {1048 StringDouble,1049 ErrorStringDoubleUnterminated,1050 StringSingle,1051 ErrorStringSingleUnterminated,1052 StringDoubleVerbatim,1053 ErrorStringDoubleVerbatimUnterminated,1054 StringSingleVerbatim,1055 ErrorStringSingleVerbatimUnterminated,1056 ErrorStringVerbatimMissingQuotes,1057 StringBlock,1058 ErrorStringBlockUnexpectedEnd,1059 ErrorStringBlockMissingNewLine,1060 ErrorStringBlockMissingTermination,1061 ErrorStringBlockMissingIndent,1062}10631064#[derive(Debug, Clone, PartialEq, Eq, Hash)]1065pub struct Number {1066 syntax: SyntaxToken,1067 kind: NumberKind,1068}10691070#[derive(Debug, Clone, Copy, PartialEq, Eq, Hash)]1071pub enum NumberKind {1072 Float,1073 ErrorFloatJunkAfterPoint,1074 ErrorFloatJunkAfterExponent,1075 ErrorFloatJunkAfterExponentSign,1076}10771078#[derive(Debug, Clone, PartialEq, Eq, Hash)]1079pub struct ImportKind {1080 syntax: SyntaxToken,1081 kind: ImportKindKind,1082}10831084#[derive(Debug, Clone, Copy, PartialEq, Eq, Hash)]1085pub enum ImportKindKind {1086 ImportstrKw,1087 ImportbinKw,1088 ImportKw,1089}10901091#[derive(Debug, Clone, PartialEq, Eq, Hash)]1092pub struct Visibility {1093 syntax: SyntaxToken,1094 kind: VisibilityKind,1095}10961097#[derive(Debug, Clone, Copy, PartialEq, Eq, Hash)]1098pub enum VisibilityKind {1099 Coloncoloncolon,1100 Coloncolon,1101 Colon,1102}11031104#[derive(Debug, Clone, PartialEq, Eq, Hash)]1105pub struct Trivia {1106 syntax: SyntaxToken,1107 kind: TriviaKind,1108}11091110#[derive(Debug, Clone, Copy, PartialEq, Eq, Hash)]1111pub enum TriviaKind {1112 Whitespace,1113 MultiLineComment,1114 ErrorCommentTooShort,1115 ErrorCommentUnterminated,1116 SingleLineHashComment,1117 SingleLineSlashComment,1118}1119impl AstNode for SourceFile {1120 fn can_cast(kind: SyntaxKind) -> bool {1121 kind == SOURCE_FILE1122 }1123 fn cast(syntax: SyntaxNode) -> Option<Self> {1124 if Self::can_cast(syntax.kind()) {1125 Some(Self { syntax })1126 } else {1127 None1128 }1129 }1130 fn syntax(&self) -> &SyntaxNode {1131 &self.syntax1132 }1133}1134impl AstNode for ExprBinary {1135 fn can_cast(kind: SyntaxKind) -> bool {1136 kind == EXPR_BINARY1137 }1138 fn cast(syntax: SyntaxNode) -> Option<Self> {1139 if Self::can_cast(syntax.kind()) {1140 Some(Self { syntax })1141 } else {1142 None1143 }1144 }1145 fn syntax(&self) -> &SyntaxNode {1146 &self.syntax1147 }1148}1149impl AstNode for LhsExpr {1150 fn can_cast(kind: SyntaxKind) -> bool {1151 kind == LHS_EXPR1152 }1153 fn cast(syntax: SyntaxNode) -> Option<Self> {1154 if Self::can_cast(syntax.kind()) {1155 Some(Self { syntax })1156 } else {1157 None1158 }1159 }1160 fn syntax(&self) -> &SyntaxNode {1161 &self.syntax1162 }1163}1164impl AstNode for ExprUnary {1165 fn can_cast(kind: SyntaxKind) -> bool {1166 kind == EXPR_UNARY1167 }1168 fn cast(syntax: SyntaxNode) -> Option<Self> {1169 if Self::can_cast(syntax.kind()) {1170 Some(Self { syntax })1171 } else {1172 None1173 }1174 }1175 fn syntax(&self) -> &SyntaxNode {1176 &self.syntax1177 }1178}1179impl AstNode for ExprSlice {1180 fn can_cast(kind: SyntaxKind) -> bool {1181 kind == EXPR_SLICE1182 }1183 fn cast(syntax: SyntaxNode) -> Option<Self> {1184 if Self::can_cast(syntax.kind()) {1185 Some(Self { syntax })1186 } else {1187 None1188 }1189 }1190 fn syntax(&self) -> &SyntaxNode {1191 &self.syntax1192 }1193}1194impl AstNode for SliceDesc {1195 fn can_cast(kind: SyntaxKind) -> bool {1196 kind == SLICE_DESC1197 }1198 fn cast(syntax: SyntaxNode) -> Option<Self> {1199 if Self::can_cast(syntax.kind()) {1200 Some(Self { syntax })1201 } else {1202 None1203 }1204 }1205 fn syntax(&self) -> &SyntaxNode {1206 &self.syntax1207 }1208}1209impl AstNode for ExprIndex {1210 fn can_cast(kind: SyntaxKind) -> bool {1211 kind == EXPR_INDEX1212 }1213 fn cast(syntax: SyntaxNode) -> Option<Self> {1214 if Self::can_cast(syntax.kind()) {1215 Some(Self { syntax })1216 } else {1217 None1218 }1219 }1220 fn syntax(&self) -> &SyntaxNode {1221 &self.syntax1222 }1223}1224impl AstNode for Name {1225 fn can_cast(kind: SyntaxKind) -> bool {1226 kind == NAME1227 }1228 fn cast(syntax: SyntaxNode) -> Option<Self> {1229 if Self::can_cast(syntax.kind()) {1230 Some(Self { syntax })1231 } else {1232 None1233 }1234 }1235 fn syntax(&self) -> &SyntaxNode {1236 &self.syntax1237 }1238}1239impl AstNode for ExprIndexExpr {1240 fn can_cast(kind: SyntaxKind) -> bool {1241 kind == EXPR_INDEX_EXPR1242 }1243 fn cast(syntax: SyntaxNode) -> Option<Self> {1244 if Self::can_cast(syntax.kind()) {1245 Some(Self { syntax })1246 } else {1247 None1248 }1249 }1250 fn syntax(&self) -> &SyntaxNode {1251 &self.syntax1252 }1253}1254impl AstNode for ExprApply {1255 fn can_cast(kind: SyntaxKind) -> bool {1256 kind == EXPR_APPLY1257 }1258 fn cast(syntax: SyntaxNode) -> Option<Self> {1259 if Self::can_cast(syntax.kind()) {1260 Some(Self { syntax })1261 } else {1262 None1263 }1264 }1265 fn syntax(&self) -> &SyntaxNode {1266 &self.syntax1267 }1268}1269impl AstNode for ArgsDesc {1270 fn can_cast(kind: SyntaxKind) -> bool {1271 kind == ARGS_DESC1272 }1273 fn cast(syntax: SyntaxNode) -> Option<Self> {1274 if Self::can_cast(syntax.kind()) {1275 Some(Self { syntax })1276 } else {1277 None1278 }1279 }1280 fn syntax(&self) -> &SyntaxNode {1281 &self.syntax1282 }1283}1284impl AstNode for ExprObjExtend {1285 fn can_cast(kind: SyntaxKind) -> bool {1286 kind == EXPR_OBJ_EXTEND1287 }1288 fn cast(syntax: SyntaxNode) -> Option<Self> {1289 if Self::can_cast(syntax.kind()) {1290 Some(Self { syntax })1291 } else {1292 None1293 }1294 }1295 fn syntax(&self) -> &SyntaxNode {1296 &self.syntax1297 }1298}1299impl AstNode for ExprParened {1300 fn can_cast(kind: SyntaxKind) -> bool {1301 kind == EXPR_PARENED1302 }1303 fn cast(syntax: SyntaxNode) -> Option<Self> {1304 if Self::can_cast(syntax.kind()) {1305 Some(Self { syntax })1306 } else {1307 None1308 }1309 }1310 fn syntax(&self) -> &SyntaxNode {1311 &self.syntax1312 }1313}1314impl AstNode for ExprLiteral {1315 fn can_cast(kind: SyntaxKind) -> bool {1316 kind == EXPR_LITERAL1317 }1318 fn cast(syntax: SyntaxNode) -> Option<Self> {1319 if Self::can_cast(syntax.kind()) {1320 Some(Self { syntax })1321 } else {1322 None1323 }1324 }1325 fn syntax(&self) -> &SyntaxNode {1326 &self.syntax1327 }1328}1329impl AstNode for ExprIntrinsicThisFile {1330 fn can_cast(kind: SyntaxKind) -> bool {1331 kind == EXPR_INTRINSIC_THIS_FILE1332 }1333 fn cast(syntax: SyntaxNode) -> Option<Self> {1334 if Self::can_cast(syntax.kind()) {1335 Some(Self { syntax })1336 } else {1337 None1338 }1339 }1340 fn syntax(&self) -> &SyntaxNode {1341 &self.syntax1342 }1343}1344impl AstNode for ExprIntrinsicId {1345 fn can_cast(kind: SyntaxKind) -> bool {1346 kind == EXPR_INTRINSIC_ID1347 }1348 fn cast(syntax: SyntaxNode) -> Option<Self> {1349 if Self::can_cast(syntax.kind()) {1350 Some(Self { syntax })1351 } else {1352 None1353 }1354 }1355 fn syntax(&self) -> &SyntaxNode {1356 &self.syntax1357 }1358}1359impl AstNode for ExprIntrinsic {1360 fn can_cast(kind: SyntaxKind) -> bool {1361 kind == EXPR_INTRINSIC1362 }1363 fn cast(syntax: SyntaxNode) -> Option<Self> {1364 if Self::can_cast(syntax.kind()) {1365 Some(Self { syntax })1366 } else {1367 None1368 }1369 }1370 fn syntax(&self) -> &SyntaxNode {1371 &self.syntax1372 }1373}1374impl AstNode for ExprString {1375 fn can_cast(kind: SyntaxKind) -> bool {1376 kind == EXPR_STRING1377 }1378 fn cast(syntax: SyntaxNode) -> Option<Self> {1379 if Self::can_cast(syntax.kind()) {1380 Some(Self { syntax })1381 } else {1382 None1383 }1384 }1385 fn syntax(&self) -> &SyntaxNode {1386 &self.syntax1387 }1388}1389impl AstNode for ExprNumber {1390 fn can_cast(kind: SyntaxKind) -> bool {1391 kind == EXPR_NUMBER1392 }1393 fn cast(syntax: SyntaxNode) -> Option<Self> {1394 if Self::can_cast(syntax.kind()) {1395 Some(Self { syntax })1396 } else {1397 None1398 }1399 }1400 fn syntax(&self) -> &SyntaxNode {1401 &self.syntax1402 }1403}1404impl AstNode for ExprArray {1405 fn can_cast(kind: SyntaxKind) -> bool {1406 kind == EXPR_ARRAY1407 }1408 fn cast(syntax: SyntaxNode) -> Option<Self> {1409 if Self::can_cast(syntax.kind()) {1410 Some(Self { syntax })1411 } else {1412 None1413 }1414 }1415 fn syntax(&self) -> &SyntaxNode {1416 &self.syntax1417 }1418}1419impl AstNode for ExprObject {1420 fn can_cast(kind: SyntaxKind) -> bool {1421 kind == EXPR_OBJECT1422 }1423 fn cast(syntax: SyntaxNode) -> Option<Self> {1424 if Self::can_cast(syntax.kind()) {1425 Some(Self { syntax })1426 } else {1427 None1428 }1429 }1430 fn syntax(&self) -> &SyntaxNode {1431 &self.syntax1432 }1433}1434impl AstNode for ExprArrayComp {1435 fn can_cast(kind: SyntaxKind) -> bool {1436 kind == EXPR_ARRAY_COMP1437 }1438 fn cast(syntax: SyntaxNode) -> Option<Self> {1439 if Self::can_cast(syntax.kind()) {1440 Some(Self { syntax })1441 } else {1442 None1443 }1444 }1445 fn syntax(&self) -> &SyntaxNode {1446 &self.syntax1447 }1448}1449impl AstNode for ExprImport {1450 fn can_cast(kind: SyntaxKind) -> bool {1451 kind == EXPR_IMPORT1452 }1453 fn cast(syntax: SyntaxNode) -> Option<Self> {1454 if Self::can_cast(syntax.kind()) {1455 Some(Self { syntax })1456 } else {1457 None1458 }1459 }1460 fn syntax(&self) -> &SyntaxNode {1461 &self.syntax1462 }1463}1464impl AstNode for ExprVar {1465 fn can_cast(kind: SyntaxKind) -> bool {1466 kind == EXPR_VAR1467 }1468 fn cast(syntax: SyntaxNode) -> Option<Self> {1469 if Self::can_cast(syntax.kind()) {1470 Some(Self { syntax })1471 } else {1472 None1473 }1474 }1475 fn syntax(&self) -> &SyntaxNode {1476 &self.syntax1477 }1478}1479impl AstNode for ExprLocal {1480 fn can_cast(kind: SyntaxKind) -> bool {1481 kind == EXPR_LOCAL1482 }1483 fn cast(syntax: SyntaxNode) -> Option<Self> {1484 if Self::can_cast(syntax.kind()) {1485 Some(Self { syntax })1486 } else {1487 None1488 }1489 }1490 fn syntax(&self) -> &SyntaxNode {1491 &self.syntax1492 }1493}1494impl AstNode for ExprIfThenElse {1495 fn can_cast(kind: SyntaxKind) -> bool {1496 kind == EXPR_IF_THEN_ELSE1497 }1498 fn cast(syntax: SyntaxNode) -> Option<Self> {1499 if Self::can_cast(syntax.kind()) {1500 Some(Self { syntax })1501 } else {1502 None1503 }1504 }1505 fn syntax(&self) -> &SyntaxNode {1506 &self.syntax1507 }1508}1509impl AstNode for TrueExpr {1510 fn can_cast(kind: SyntaxKind) -> bool {1511 kind == TRUE_EXPR1512 }1513 fn cast(syntax: SyntaxNode) -> Option<Self> {1514 if Self::can_cast(syntax.kind()) {1515 Some(Self { syntax })1516 } else {1517 None1518 }1519 }1520 fn syntax(&self) -> &SyntaxNode {1521 &self.syntax1522 }1523}1524impl AstNode for FalseExpr {1525 fn can_cast(kind: SyntaxKind) -> bool {1526 kind == FALSE_EXPR1527 }1528 fn cast(syntax: SyntaxNode) -> Option<Self> {1529 if Self::can_cast(syntax.kind()) {1530 Some(Self { syntax })1531 } else {1532 None1533 }1534 }1535 fn syntax(&self) -> &SyntaxNode {1536 &self.syntax1537 }1538}1539impl AstNode for ExprFunction {1540 fn can_cast(kind: SyntaxKind) -> bool {1541 kind == EXPR_FUNCTION1542 }1543 fn cast(syntax: SyntaxNode) -> Option<Self> {1544 if Self::can_cast(syntax.kind()) {1545 Some(Self { syntax })1546 } else {1547 None1548 }1549 }1550 fn syntax(&self) -> &SyntaxNode {1551 &self.syntax1552 }1553}1554impl AstNode for ParamsDesc {1555 fn can_cast(kind: SyntaxKind) -> bool {1556 kind == PARAMS_DESC1557 }1558 fn cast(syntax: SyntaxNode) -> Option<Self> {1559 if Self::can_cast(syntax.kind()) {1560 Some(Self { syntax })1561 } else {1562 None1563 }1564 }1565 fn syntax(&self) -> &SyntaxNode {1566 &self.syntax1567 }1568}1569impl AstNode for ExprAssert {1570 fn can_cast(kind: SyntaxKind) -> bool {1571 kind == EXPR_ASSERT1572 }1573 fn cast(syntax: SyntaxNode) -> Option<Self> {1574 if Self::can_cast(syntax.kind()) {1575 Some(Self { syntax })1576 } else {1577 None1578 }1579 }1580 fn syntax(&self) -> &SyntaxNode {1581 &self.syntax1582 }1583}1584impl AstNode for Assertion {1585 fn can_cast(kind: SyntaxKind) -> bool {1586 kind == ASSERTION1587 }1588 fn cast(syntax: SyntaxNode) -> Option<Self> {1589 if Self::can_cast(syntax.kind()) {1590 Some(Self { syntax })1591 } else {1592 None1593 }1594 }1595 fn syntax(&self) -> &SyntaxNode {1596 &self.syntax1597 }1598}1599impl AstNode for ExprError {1600 fn can_cast(kind: SyntaxKind) -> bool {1601 kind == EXPR_ERROR1602 }1603 fn cast(syntax: SyntaxNode) -> Option<Self> {1604 if Self::can_cast(syntax.kind()) {1605 Some(Self { syntax })1606 } else {1607 None1608 }1609 }1610 fn syntax(&self) -> &SyntaxNode {1611 &self.syntax1612 }1613}1614impl AstNode for SliceDescEnd {1615 fn can_cast(kind: SyntaxKind) -> bool {1616 kind == SLICE_DESC_END1617 }1618 fn cast(syntax: SyntaxNode) -> Option<Self> {1619 if Self::can_cast(syntax.kind()) {1620 Some(Self { syntax })1621 } else {1622 None1623 }1624 }1625 fn syntax(&self) -> &SyntaxNode {1626 &self.syntax1627 }1628}1629impl AstNode for SliceDescStep {1630 fn can_cast(kind: SyntaxKind) -> bool {1631 kind == SLICE_DESC_STEP1632 }1633 fn cast(syntax: SyntaxNode) -> Option<Self> {1634 if Self::can_cast(syntax.kind()) {1635 Some(Self { syntax })1636 } else {1637 None1638 }1639 }1640 fn syntax(&self) -> &SyntaxNode {1641 &self.syntax1642 }1643}1644impl AstNode for Arg {1645 fn can_cast(kind: SyntaxKind) -> bool {1646 kind == ARG1647 }1648 fn cast(syntax: SyntaxNode) -> Option<Self> {1649 if Self::can_cast(syntax.kind()) {1650 Some(Self { syntax })1651 } else {1652 None1653 }1654 }1655 fn syntax(&self) -> &SyntaxNode {1656 &self.syntax1657 }1658}1659impl AstNode for ObjBodyComp {1660 fn can_cast(kind: SyntaxKind) -> bool {1661 kind == OBJ_BODY_COMP1662 }1663 fn cast(syntax: SyntaxNode) -> Option<Self> {1664 if Self::can_cast(syntax.kind()) {1665 Some(Self { syntax })1666 } else {1667 None1668 }1669 }1670 fn syntax(&self) -> &SyntaxNode {1671 &self.syntax1672 }1673}1674impl AstNode for ObjLocalPostComma {1675 fn can_cast(kind: SyntaxKind) -> bool {1676 kind == OBJ_LOCAL_POST_COMMA1677 }1678 fn cast(syntax: SyntaxNode) -> Option<Self> {1679 if Self::can_cast(syntax.kind()) {1680 Some(Self { syntax })1681 } else {1682 None1683 }1684 }1685 fn syntax(&self) -> &SyntaxNode {1686 &self.syntax1687 }1688}1689impl AstNode for ObjLocalPreComma {1690 fn can_cast(kind: SyntaxKind) -> bool {1691 kind == OBJ_LOCAL_PRE_COMMA1692 }1693 fn cast(syntax: SyntaxNode) -> Option<Self> {1694 if Self::can_cast(syntax.kind()) {1695 Some(Self { syntax })1696 } else {1697 None1698 }1699 }1700 fn syntax(&self) -> &SyntaxNode {1701 &self.syntax1702 }1703}1704impl AstNode for ObjBodyMemberList {1705 fn can_cast(kind: SyntaxKind) -> bool {1706 kind == OBJ_BODY_MEMBER_LIST1707 }1708 fn cast(syntax: SyntaxNode) -> Option<Self> {1709 if Self::can_cast(syntax.kind()) {1710 Some(Self { syntax })1711 } else {1712 None1713 }1714 }1715 fn syntax(&self) -> &SyntaxNode {1716 &self.syntax1717 }1718}1719impl AstNode for ObjLocal {1720 fn can_cast(kind: SyntaxKind) -> bool {1721 kind == OBJ_LOCAL1722 }1723 fn cast(syntax: SyntaxNode) -> Option<Self> {1724 if Self::can_cast(syntax.kind()) {1725 Some(Self { syntax })1726 } else {1727 None1728 }1729 }1730 fn syntax(&self) -> &SyntaxNode {1731 &self.syntax1732 }1733}1734impl AstNode for MemberBindStmt {1735 fn can_cast(kind: SyntaxKind) -> bool {1736 kind == MEMBER_BIND_STMT1737 }1738 fn cast(syntax: SyntaxNode) -> Option<Self> {1739 if Self::can_cast(syntax.kind()) {1740 Some(Self { syntax })1741 } else {1742 None1743 }1744 }1745 fn syntax(&self) -> &SyntaxNode {1746 &self.syntax1747 }1748}1749impl AstNode for MemberAssertStmt {1750 fn can_cast(kind: SyntaxKind) -> bool {1751 kind == MEMBER_ASSERT_STMT1752 }1753 fn cast(syntax: SyntaxNode) -> Option<Self> {1754 if Self::can_cast(syntax.kind()) {1755 Some(Self { syntax })1756 } else {1757 None1758 }1759 }1760 fn syntax(&self) -> &SyntaxNode {1761 &self.syntax1762 }1763}1764impl AstNode for MemberField {1765 fn can_cast(kind: SyntaxKind) -> bool {1766 kind == MEMBER_FIELD1767 }1768 fn cast(syntax: SyntaxNode) -> Option<Self> {1769 if Self::can_cast(syntax.kind()) {1770 Some(Self { syntax })1771 } else {1772 None1773 }1774 }1775 fn syntax(&self) -> &SyntaxNode {1776 &self.syntax1777 }1778}1779impl AstNode for FieldNormal {1780 fn can_cast(kind: SyntaxKind) -> bool {1781 kind == FIELD_NORMAL1782 }1783 fn cast(syntax: SyntaxNode) -> Option<Self> {1784 if Self::can_cast(syntax.kind()) {1785 Some(Self { syntax })1786 } else {1787 None1788 }1789 }1790 fn syntax(&self) -> &SyntaxNode {1791 &self.syntax1792 }1793}1794impl AstNode for FieldMethod {1795 fn can_cast(kind: SyntaxKind) -> bool {1796 kind == FIELD_METHOD1797 }1798 fn cast(syntax: SyntaxNode) -> Option<Self> {1799 if Self::can_cast(syntax.kind()) {1800 Some(Self { syntax })1801 } else {1802 None1803 }1804 }1805 fn syntax(&self) -> &SyntaxNode {1806 &self.syntax1807 }1808}1809impl AstNode for FieldNameFixed {1810 fn can_cast(kind: SyntaxKind) -> bool {1811 kind == FIELD_NAME_FIXED1812 }1813 fn cast(syntax: SyntaxNode) -> Option<Self> {1814 if Self::can_cast(syntax.kind()) {1815 Some(Self { syntax })1816 } else {1817 None1818 }1819 }1820 fn syntax(&self) -> &SyntaxNode {1821 &self.syntax1822 }1823}1824impl AstNode for FieldNameDynamic {1825 fn can_cast(kind: SyntaxKind) -> bool {1826 kind == FIELD_NAME_DYNAMIC1827 }1828 fn cast(syntax: SyntaxNode) -> Option<Self> {1829 if Self::can_cast(syntax.kind()) {1830 Some(Self { syntax })1831 } else {1832 None1833 }1834 }1835 fn syntax(&self) -> &SyntaxNode {1836 &self.syntax1837 }1838}1839impl AstNode for ForSpec {1840 fn can_cast(kind: SyntaxKind) -> bool {1841 kind == FOR_SPEC1842 }1843 fn cast(syntax: SyntaxNode) -> Option<Self> {1844 if Self::can_cast(syntax.kind()) {1845 Some(Self { syntax })1846 } else {1847 None1848 }1849 }1850 fn syntax(&self) -> &SyntaxNode {1851 &self.syntax1852 }1853}1854impl AstNode for IfSpec {1855 fn can_cast(kind: SyntaxKind) -> bool {1856 kind == IF_SPEC1857 }1858 fn cast(syntax: SyntaxNode) -> Option<Self> {1859 if Self::can_cast(syntax.kind()) {1860 Some(Self { syntax })1861 } else {1862 None1863 }1864 }1865 fn syntax(&self) -> &SyntaxNode {1866 &self.syntax1867 }1868}1869impl AstNode for BindDestruct {1870 fn can_cast(kind: SyntaxKind) -> bool {1871 kind == BIND_DESTRUCT1872 }1873 fn cast(syntax: SyntaxNode) -> Option<Self> {1874 if Self::can_cast(syntax.kind()) {1875 Some(Self { syntax })1876 } else {1877 None1878 }1879 }1880 fn syntax(&self) -> &SyntaxNode {1881 &self.syntax1882 }1883}1884impl AstNode for BindFunction {1885 fn can_cast(kind: SyntaxKind) -> bool {1886 kind == BIND_FUNCTION1887 }1888 fn cast(syntax: SyntaxNode) -> Option<Self> {1889 if Self::can_cast(syntax.kind()) {1890 Some(Self { syntax })1891 } else {1892 None1893 }1894 }1895 fn syntax(&self) -> &SyntaxNode {1896 &self.syntax1897 }1898}1899impl AstNode for Param {1900 fn can_cast(kind: SyntaxKind) -> bool {1901 kind == PARAM1902 }1903 fn cast(syntax: SyntaxNode) -> Option<Self> {1904 if Self::can_cast(syntax.kind()) {1905 Some(Self { syntax })1906 } else {1907 None1908 }1909 }1910 fn syntax(&self) -> &SyntaxNode {1911 &self.syntax1912 }1913}1914impl AstNode for DestructFull {1915 fn can_cast(kind: SyntaxKind) -> bool {1916 kind == DESTRUCT_FULL1917 }1918 fn cast(syntax: SyntaxNode) -> Option<Self> {1919 if Self::can_cast(syntax.kind()) {1920 Some(Self { syntax })1921 } else {1922 None1923 }1924 }1925 fn syntax(&self) -> &SyntaxNode {1926 &self.syntax1927 }1928}1929impl AstNode for DestructSkip {1930 fn can_cast(kind: SyntaxKind) -> bool {1931 kind == DESTRUCT_SKIP1932 }1933 fn cast(syntax: SyntaxNode) -> Option<Self> {1934 if Self::can_cast(syntax.kind()) {1935 Some(Self { syntax })1936 } else {1937 None1938 }1939 }1940 fn syntax(&self) -> &SyntaxNode {1941 &self.syntax1942 }1943}1944impl AstNode for DestructArray {1945 fn can_cast(kind: SyntaxKind) -> bool {1946 kind == DESTRUCT_ARRAY1947 }1948 fn cast(syntax: SyntaxNode) -> Option<Self> {1949 if Self::can_cast(syntax.kind()) {1950 Some(Self { syntax })1951 } else {1952 None1953 }1954 }1955 fn syntax(&self) -> &SyntaxNode {1956 &self.syntax1957 }1958}1959impl AstNode for DestructObject {1960 fn can_cast(kind: SyntaxKind) -> bool {1961 kind == DESTRUCT_OBJECT1962 }1963 fn cast(syntax: SyntaxNode) -> Option<Self> {1964 if Self::can_cast(syntax.kind()) {1965 Some(Self { syntax })1966 } else {1967 None1968 }1969 }1970 fn syntax(&self) -> &SyntaxNode {1971 &self.syntax1972 }1973}1974impl AstNode for DestructObjectField {1975 fn can_cast(kind: SyntaxKind) -> bool {1976 kind == DESTRUCT_OBJECT_FIELD1977 }1978 fn cast(syntax: SyntaxNode) -> Option<Self> {1979 if Self::can_cast(syntax.kind()) {1980 Some(Self { syntax })1981 } else {1982 None1983 }1984 }1985 fn syntax(&self) -> &SyntaxNode {1986 &self.syntax1987 }1988}1989impl AstNode for DestructRest {1990 fn can_cast(kind: SyntaxKind) -> bool {1991 kind == DESTRUCT_REST1992 }1993 fn cast(syntax: SyntaxNode) -> Option<Self> {1994 if Self::can_cast(syntax.kind()) {1995 Some(Self { syntax })1996 } else {1997 None1998 }1999 }2000 fn syntax(&self) -> &SyntaxNode {2001 &self.syntax2002 }2003}2004impl AstNode for DestructArrayElement {2005 fn can_cast(kind: SyntaxKind) -> bool {2006 kind == DESTRUCT_ARRAY_ELEMENT2007 }2008 fn cast(syntax: SyntaxNode) -> Option<Self> {2009 if Self::can_cast(syntax.kind()) {2010 Some(Self { syntax })2011 } else {2012 None2013 }2014 }2015 fn syntax(&self) -> &SyntaxNode {2016 &self.syntax2017 }2018}2019impl From<ExprBinary> for Expr {2020 fn from(node: ExprBinary) -> Expr {2021 Expr::ExprBinary(node)2022 }2023}2024impl From<ExprUnary> for Expr {2025 fn from(node: ExprUnary) -> Expr {2026 Expr::ExprUnary(node)2027 }2028}2029impl From<ExprSlice> for Expr {2030 fn from(node: ExprSlice) -> Expr {2031 Expr::ExprSlice(node)2032 }2033}2034impl From<ExprIndex> for Expr {2035 fn from(node: ExprIndex) -> Expr {2036 Expr::ExprIndex(node)2037 }2038}2039impl From<ExprIndexExpr> for Expr {2040 fn from(node: ExprIndexExpr) -> Expr {2041 Expr::ExprIndexExpr(node)2042 }2043}2044impl From<ExprApply> for Expr {2045 fn from(node: ExprApply) -> Expr {2046 Expr::ExprApply(node)2047 }2048}2049impl From<ExprObjExtend> for Expr {2050 fn from(node: ExprObjExtend) -> Expr {2051 Expr::ExprObjExtend(node)2052 }2053}2054impl From<ExprParened> for Expr {2055 fn from(node: ExprParened) -> Expr {2056 Expr::ExprParened(node)2057 }2058}2059impl From<ExprIntrinsicThisFile> for Expr {2060 fn from(node: ExprIntrinsicThisFile) -> Expr {2061 Expr::ExprIntrinsicThisFile(node)2062 }2063}2064impl From<ExprIntrinsicId> for Expr {2065 fn from(node: ExprIntrinsicId) -> Expr {2066 Expr::ExprIntrinsicId(node)2067 }2068}2069impl From<ExprIntrinsic> for Expr {2070 fn from(node: ExprIntrinsic) -> Expr {2071 Expr::ExprIntrinsic(node)2072 }2073}2074impl From<ExprString> for Expr {2075 fn from(node: ExprString) -> Expr {2076 Expr::ExprString(node)2077 }2078}2079impl From<ExprNumber> for Expr {2080 fn from(node: ExprNumber) -> Expr {2081 Expr::ExprNumber(node)2082 }2083}2084impl From<ExprLiteral> for Expr {2085 fn from(node: ExprLiteral) -> Expr {2086 Expr::ExprLiteral(node)2087 }2088}2089impl From<ExprArray> for Expr {2090 fn from(node: ExprArray) -> Expr {2091 Expr::ExprArray(node)2092 }2093}2094impl From<ExprObject> for Expr {2095 fn from(node: ExprObject) -> Expr {2096 Expr::ExprObject(node)2097 }2098}2099impl From<ExprArrayComp> for Expr {2100 fn from(node: ExprArrayComp) -> Expr {2101 Expr::ExprArrayComp(node)2102 }2103}2104impl From<ExprImport> for Expr {2105 fn from(node: ExprImport) -> Expr {2106 Expr::ExprImport(node)2107 }2108}2109impl From<ExprVar> for Expr {2110 fn from(node: ExprVar) -> Expr {2111 Expr::ExprVar(node)2112 }2113}2114impl From<ExprLocal> for Expr {2115 fn from(node: ExprLocal) -> Expr {2116 Expr::ExprLocal(node)2117 }2118}2119impl From<ExprIfThenElse> for Expr {2120 fn from(node: ExprIfThenElse) -> Expr {2121 Expr::ExprIfThenElse(node)2122 }2123}2124impl From<ExprFunction> for Expr {2125 fn from(node: ExprFunction) -> Expr {2126 Expr::ExprFunction(node)2127 }2128}2129impl From<ExprAssert> for Expr {2130 fn from(node: ExprAssert) -> Expr {2131 Expr::ExprAssert(node)2132 }2133}2134impl From<ExprError> for Expr {2135 fn from(node: ExprError) -> Expr {2136 Expr::ExprError(node)2137 }2138}2139impl AstNode for Expr {2140 fn can_cast(kind: SyntaxKind) -> bool {2141 match kind {2142 EXPR_BINARY2143 | EXPR_UNARY2144 | EXPR_SLICE2145 | EXPR_INDEX2146 | EXPR_INDEX_EXPR2147 | EXPR_APPLY2148 | EXPR_OBJ_EXTEND2149 | EXPR_PARENED2150 | EXPR_INTRINSIC_THIS_FILE2151 | EXPR_INTRINSIC_ID2152 | EXPR_INTRINSIC2153 | EXPR_STRING2154 | EXPR_NUMBER2155 | EXPR_LITERAL2156 | EXPR_ARRAY2157 | EXPR_OBJECT2158 | EXPR_ARRAY_COMP2159 | EXPR_IMPORT2160 | EXPR_VAR2161 | EXPR_LOCAL2162 | EXPR_IF_THEN_ELSE2163 | EXPR_FUNCTION2164 | EXPR_ASSERT2165 | EXPR_ERROR => true,2166 _ => false,2167 }2168 }2169 fn cast(syntax: SyntaxNode) -> Option<Self> {2170 let res = match syntax.kind() {2171 EXPR_BINARY => Expr::ExprBinary(ExprBinary { syntax }),2172 EXPR_UNARY => Expr::ExprUnary(ExprUnary { syntax }),2173 EXPR_SLICE => Expr::ExprSlice(ExprSlice { syntax }),2174 EXPR_INDEX => Expr::ExprIndex(ExprIndex { syntax }),2175 EXPR_INDEX_EXPR => Expr::ExprIndexExpr(ExprIndexExpr { syntax }),2176 EXPR_APPLY => Expr::ExprApply(ExprApply { syntax }),2177 EXPR_OBJ_EXTEND => Expr::ExprObjExtend(ExprObjExtend { syntax }),2178 EXPR_PARENED => Expr::ExprParened(ExprParened { syntax }),2179 EXPR_INTRINSIC_THIS_FILE => {2180 Expr::ExprIntrinsicThisFile(ExprIntrinsicThisFile { syntax })2181 }2182 EXPR_INTRINSIC_ID => Expr::ExprIntrinsicId(ExprIntrinsicId { syntax }),2183 EXPR_INTRINSIC => Expr::ExprIntrinsic(ExprIntrinsic { syntax }),2184 EXPR_STRING => Expr::ExprString(ExprString { syntax }),2185 EXPR_NUMBER => Expr::ExprNumber(ExprNumber { syntax }),2186 EXPR_LITERAL => Expr::ExprLiteral(ExprLiteral { syntax }),2187 EXPR_ARRAY => Expr::ExprArray(ExprArray { syntax }),2188 EXPR_OBJECT => Expr::ExprObject(ExprObject { syntax }),2189 EXPR_ARRAY_COMP => Expr::ExprArrayComp(ExprArrayComp { syntax }),2190 EXPR_IMPORT => Expr::ExprImport(ExprImport { syntax }),2191 EXPR_VAR => Expr::ExprVar(ExprVar { syntax }),2192 EXPR_LOCAL => Expr::ExprLocal(ExprLocal { syntax }),2193 EXPR_IF_THEN_ELSE => Expr::ExprIfThenElse(ExprIfThenElse { syntax }),2194 EXPR_FUNCTION => Expr::ExprFunction(ExprFunction { syntax }),2195 EXPR_ASSERT => Expr::ExprAssert(ExprAssert { syntax }),2196 EXPR_ERROR => Expr::ExprError(ExprError { syntax }),2197 _ => return None,2198 };2199 Some(res)2200 }2201 fn syntax(&self) -> &SyntaxNode {2202 match self {2203 Expr::ExprBinary(it) => &it.syntax,2204 Expr::ExprUnary(it) => &it.syntax,2205 Expr::ExprSlice(it) => &it.syntax,2206 Expr::ExprIndex(it) => &it.syntax,2207 Expr::ExprIndexExpr(it) => &it.syntax,2208 Expr::ExprApply(it) => &it.syntax,2209 Expr::ExprObjExtend(it) => &it.syntax,2210 Expr::ExprParened(it) => &it.syntax,2211 Expr::ExprIntrinsicThisFile(it) => &it.syntax,2212 Expr::ExprIntrinsicId(it) => &it.syntax,2213 Expr::ExprIntrinsic(it) => &it.syntax,2214 Expr::ExprString(it) => &it.syntax,2215 Expr::ExprNumber(it) => &it.syntax,2216 Expr::ExprLiteral(it) => &it.syntax,2217 Expr::ExprArray(it) => &it.syntax,2218 Expr::ExprObject(it) => &it.syntax,2219 Expr::ExprArrayComp(it) => &it.syntax,2220 Expr::ExprImport(it) => &it.syntax,2221 Expr::ExprVar(it) => &it.syntax,2222 Expr::ExprLocal(it) => &it.syntax,2223 Expr::ExprIfThenElse(it) => &it.syntax,2224 Expr::ExprFunction(it) => &it.syntax,2225 Expr::ExprAssert(it) => &it.syntax,2226 Expr::ExprError(it) => &it.syntax,2227 }2228 }2229}2230impl From<ObjBodyComp> for ObjBody {2231 fn from(node: ObjBodyComp) -> ObjBody {2232 ObjBody::ObjBodyComp(node)2233 }2234}2235impl From<ObjBodyMemberList> for ObjBody {2236 fn from(node: ObjBodyMemberList) -> ObjBody {2237 ObjBody::ObjBodyMemberList(node)2238 }2239}2240impl AstNode for ObjBody {2241 fn can_cast(kind: SyntaxKind) -> bool {2242 match kind {2243 OBJ_BODY_COMP | OBJ_BODY_MEMBER_LIST => true,2244 _ => false,2245 }2246 }2247 fn cast(syntax: SyntaxNode) -> Option<Self> {2248 let res = match syntax.kind() {2249 OBJ_BODY_COMP => ObjBody::ObjBodyComp(ObjBodyComp { syntax }),2250 OBJ_BODY_MEMBER_LIST => ObjBody::ObjBodyMemberList(ObjBodyMemberList { syntax }),2251 _ => return None,2252 };2253 Some(res)2254 }2255 fn syntax(&self) -> &SyntaxNode {2256 match self {2257 ObjBody::ObjBodyComp(it) => &it.syntax,2258 ObjBody::ObjBodyMemberList(it) => &it.syntax,2259 }2260 }2261}2262impl From<ForSpec> for CompSpec {2263 fn from(node: ForSpec) -> CompSpec {2264 CompSpec::ForSpec(node)2265 }2266}2267impl From<IfSpec> for CompSpec {2268 fn from(node: IfSpec) -> CompSpec {2269 CompSpec::IfSpec(node)2270 }2271}2272impl AstNode for CompSpec {2273 fn can_cast(kind: SyntaxKind) -> bool {2274 match kind {2275 FOR_SPEC | IF_SPEC => true,2276 _ => false,2277 }2278 }2279 fn cast(syntax: SyntaxNode) -> Option<Self> {2280 let res = match syntax.kind() {2281 FOR_SPEC => CompSpec::ForSpec(ForSpec { syntax }),2282 IF_SPEC => CompSpec::IfSpec(IfSpec { syntax }),2283 _ => return None,2284 };2285 Some(res)2286 }2287 fn syntax(&self) -> &SyntaxNode {2288 match self {2289 CompSpec::ForSpec(it) => &it.syntax,2290 CompSpec::IfSpec(it) => &it.syntax,2291 }2292 }2293}2294impl From<BindDestruct> for Bind {2295 fn from(node: BindDestruct) -> Bind {2296 Bind::BindDestruct(node)2297 }2298}2299impl From<BindFunction> for Bind {2300 fn from(node: BindFunction) -> Bind {2301 Bind::BindFunction(node)2302 }2303}2304impl AstNode for Bind {2305 fn can_cast(kind: SyntaxKind) -> bool {2306 match kind {2307 BIND_DESTRUCT | BIND_FUNCTION => true,2308 _ => false,2309 }2310 }2311 fn cast(syntax: SyntaxNode) -> Option<Self> {2312 let res = match syntax.kind() {2313 BIND_DESTRUCT => Bind::BindDestruct(BindDestruct { syntax }),2314 BIND_FUNCTION => Bind::BindFunction(BindFunction { syntax }),2315 _ => return None,2316 };2317 Some(res)2318 }2319 fn syntax(&self) -> &SyntaxNode {2320 match self {2321 Bind::BindDestruct(it) => &it.syntax,2322 Bind::BindFunction(it) => &it.syntax,2323 }2324 }2325}2326impl From<MemberBindStmt> for Member {2327 fn from(node: MemberBindStmt) -> Member {2328 Member::MemberBindStmt(node)2329 }2330}2331impl From<MemberAssertStmt> for Member {2332 fn from(node: MemberAssertStmt) -> Member {2333 Member::MemberAssertStmt(node)2334 }2335}2336impl From<MemberField> for Member {2337 fn from(node: MemberField) -> Member {2338 Member::MemberField(node)2339 }2340}2341impl AstNode for Member {2342 fn can_cast(kind: SyntaxKind) -> bool {2343 match kind {2344 MEMBER_BIND_STMT | MEMBER_ASSERT_STMT | MEMBER_FIELD => true,2345 _ => false,2346 }2347 }2348 fn cast(syntax: SyntaxNode) -> Option<Self> {2349 let res = match syntax.kind() {2350 MEMBER_BIND_STMT => Member::MemberBindStmt(MemberBindStmt { syntax }),2351 MEMBER_ASSERT_STMT => Member::MemberAssertStmt(MemberAssertStmt { syntax }),2352 MEMBER_FIELD => Member::MemberField(MemberField { syntax }),2353 _ => return None,2354 };2355 Some(res)2356 }2357 fn syntax(&self) -> &SyntaxNode {2358 match self {2359 Member::MemberBindStmt(it) => &it.syntax,2360 Member::MemberAssertStmt(it) => &it.syntax,2361 Member::MemberField(it) => &it.syntax,2362 }2363 }2364}2365impl From<FieldNormal> for Field {2366 fn from(node: FieldNormal) -> Field {2367 Field::FieldNormal(node)2368 }2369}2370impl From<FieldMethod> for Field {2371 fn from(node: FieldMethod) -> Field {2372 Field::FieldMethod(node)2373 }2374}2375impl AstNode for Field {2376 fn can_cast(kind: SyntaxKind) -> bool {2377 match kind {2378 FIELD_NORMAL | FIELD_METHOD => true,2379 _ => false,2380 }2381 }2382 fn cast(syntax: SyntaxNode) -> Option<Self> {2383 let res = match syntax.kind() {2384 FIELD_NORMAL => Field::FieldNormal(FieldNormal { syntax }),2385 FIELD_METHOD => Field::FieldMethod(FieldMethod { syntax }),2386 _ => return None,2387 };2388 Some(res)2389 }2390 fn syntax(&self) -> &SyntaxNode {2391 match self {2392 Field::FieldNormal(it) => &it.syntax,2393 Field::FieldMethod(it) => &it.syntax,2394 }2395 }2396}2397impl From<FieldNameFixed> for FieldName {2398 fn from(node: FieldNameFixed) -> FieldName {2399 FieldName::FieldNameFixed(node)2400 }2401}2402impl From<FieldNameDynamic> for FieldName {2403 fn from(node: FieldNameDynamic) -> FieldName {2404 FieldName::FieldNameDynamic(node)2405 }2406}2407impl AstNode for FieldName {2408 fn can_cast(kind: SyntaxKind) -> bool {2409 match kind {2410 FIELD_NAME_FIXED | FIELD_NAME_DYNAMIC => true,2411 _ => false,2412 }2413 }2414 fn cast(syntax: SyntaxNode) -> Option<Self> {2415 let res = match syntax.kind() {2416 FIELD_NAME_FIXED => FieldName::FieldNameFixed(FieldNameFixed { syntax }),2417 FIELD_NAME_DYNAMIC => FieldName::FieldNameDynamic(FieldNameDynamic { syntax }),2418 _ => return None,2419 };2420 Some(res)2421 }2422 fn syntax(&self) -> &SyntaxNode {2423 match self {2424 FieldName::FieldNameFixed(it) => &it.syntax,2425 FieldName::FieldNameDynamic(it) => &it.syntax,2426 }2427 }2428}2429impl From<DestructFull> for Destruct {2430 fn from(node: DestructFull) -> Destruct {2431 Destruct::DestructFull(node)2432 }2433}2434impl From<DestructSkip> for Destruct {2435 fn from(node: DestructSkip) -> Destruct {2436 Destruct::DestructSkip(node)2437 }2438}2439impl From<DestructArray> for Destruct {2440 fn from(node: DestructArray) -> Destruct {2441 Destruct::DestructArray(node)2442 }2443}2444impl From<DestructObject> for Destruct {2445 fn from(node: DestructObject) -> Destruct {2446 Destruct::DestructObject(node)2447 }2448}2449impl AstNode for Destruct {2450 fn can_cast(kind: SyntaxKind) -> bool {2451 match kind {2452 DESTRUCT_FULL | DESTRUCT_SKIP | DESTRUCT_ARRAY | DESTRUCT_OBJECT => true,2453 _ => false,2454 }2455 }2456 fn cast(syntax: SyntaxNode) -> Option<Self> {2457 let res = match syntax.kind() {2458 DESTRUCT_FULL => Destruct::DestructFull(DestructFull { syntax }),2459 DESTRUCT_SKIP => Destruct::DestructSkip(DestructSkip { syntax }),2460 DESTRUCT_ARRAY => Destruct::DestructArray(DestructArray { syntax }),2461 DESTRUCT_OBJECT => Destruct::DestructObject(DestructObject { syntax }),2462 _ => return None,2463 };2464 Some(res)2465 }2466 fn syntax(&self) -> &SyntaxNode {2467 match self {2468 Destruct::DestructFull(it) => &it.syntax,2469 Destruct::DestructSkip(it) => &it.syntax,2470 Destruct::DestructArray(it) => &it.syntax,2471 Destruct::DestructObject(it) => &it.syntax,2472 }2473 }2474}2475impl From<DestructArrayElement> for DestructArrayPart {2476 fn from(node: DestructArrayElement) -> DestructArrayPart {2477 DestructArrayPart::DestructArrayElement(node)2478 }2479}2480impl From<DestructRest> for DestructArrayPart {2481 fn from(node: DestructRest) -> DestructArrayPart {2482 DestructArrayPart::DestructRest(node)2483 }2484}2485impl AstNode for DestructArrayPart {2486 fn can_cast(kind: SyntaxKind) -> bool {2487 match kind {2488 DESTRUCT_ARRAY_ELEMENT | DESTRUCT_REST => true,2489 _ => false,2490 }2491 }2492 fn cast(syntax: SyntaxNode) -> Option<Self> {2493 let res = match syntax.kind() {2494 DESTRUCT_ARRAY_ELEMENT => {2495 DestructArrayPart::DestructArrayElement(DestructArrayElement { syntax })2496 }2497 DESTRUCT_REST => DestructArrayPart::DestructRest(DestructRest { syntax }),2498 _ => return None,2499 };2500 Some(res)2501 }2502 fn syntax(&self) -> &SyntaxNode {2503 match self {2504 DestructArrayPart::DestructArrayElement(it) => &it.syntax,2505 DestructArrayPart::DestructRest(it) => &it.syntax,2506 }2507 }2508}2509impl AstToken for BinaryOperator {2510 fn can_cast(kind: SyntaxKind) -> bool {2511 match kind {2512 OR | AND | BIT_OR | BIT_XOR | BIT_AND | EQ | NE | LT | GT | LE | GE | IN_KW | LHS2513 | RHS | PLUS | MINUS | MUL | DIV | MODULO | ERROR_NO_OPERATOR => true,2514 _ => false,2515 }2516 }2517 fn cast(syntax: SyntaxToken) -> Option<Self> {2518 let res = match syntax.kind() {2519 OR => BinaryOperator {2520 syntax,2521 kind: BinaryOperatorKind::Or,2522 },2523 AND => BinaryOperator {2524 syntax,2525 kind: BinaryOperatorKind::And,2526 },2527 BIT_OR => BinaryOperator {2528 syntax,2529 kind: BinaryOperatorKind::BitOr,2530 },2531 BIT_XOR => BinaryOperator {2532 syntax,2533 kind: BinaryOperatorKind::BitXor,2534 },2535 BIT_AND => BinaryOperator {2536 syntax,2537 kind: BinaryOperatorKind::BitAnd,2538 },2539 EQ => BinaryOperator {2540 syntax,2541 kind: BinaryOperatorKind::Eq,2542 },2543 NE => BinaryOperator {2544 syntax,2545 kind: BinaryOperatorKind::Ne,2546 },2547 LT => BinaryOperator {2548 syntax,2549 kind: BinaryOperatorKind::Lt,2550 },2551 GT => BinaryOperator {2552 syntax,2553 kind: BinaryOperatorKind::Gt,2554 },2555 LE => BinaryOperator {2556 syntax,2557 kind: BinaryOperatorKind::Le,2558 },2559 GE => BinaryOperator {2560 syntax,2561 kind: BinaryOperatorKind::Ge,2562 },2563 IN_KW => BinaryOperator {2564 syntax,2565 kind: BinaryOperatorKind::InKw,2566 },2567 LHS => BinaryOperator {2568 syntax,2569 kind: BinaryOperatorKind::Lhs,2570 },2571 RHS => BinaryOperator {2572 syntax,2573 kind: BinaryOperatorKind::Rhs,2574 },2575 PLUS => BinaryOperator {2576 syntax,2577 kind: BinaryOperatorKind::Plus,2578 },2579 MINUS => BinaryOperator {2580 syntax,2581 kind: BinaryOperatorKind::Minus,2582 },2583 MUL => BinaryOperator {2584 syntax,2585 kind: BinaryOperatorKind::Mul,2586 },2587 DIV => BinaryOperator {2588 syntax,2589 kind: BinaryOperatorKind::Div,2590 },2591 MODULO => BinaryOperator {2592 syntax,2593 kind: BinaryOperatorKind::Modulo,2594 },2595 ERROR_NO_OPERATOR => BinaryOperator {2596 syntax,2597 kind: BinaryOperatorKind::ErrorNoOperator,2598 },2599 _ => return None,2600 };2601 Some(res)2602 }2603 fn syntax(&self) -> &SyntaxToken {2604 &self.syntax2605 }2606}2607impl BinaryOperator {2608 pub fn kind(&self) -> BinaryOperatorKind {2609 self.kind2610 }2611}2612impl std::fmt::Display for BinaryOperator {2613 fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result {2614 std::fmt::Display::fmt(self.syntax(), f)2615 }2616}2617impl AstToken for UnaryOperator {2618 fn can_cast(kind: SyntaxKind) -> bool {2619 match kind {2620 MINUS | NOT | BIT_NOT => true,2621 _ => false,2622 }2623 }2624 fn cast(syntax: SyntaxToken) -> Option<Self> {2625 let res = match syntax.kind() {2626 MINUS => UnaryOperator {2627 syntax,2628 kind: UnaryOperatorKind::Minus,2629 },2630 NOT => UnaryOperator {2631 syntax,2632 kind: UnaryOperatorKind::Not,2633 },2634 BIT_NOT => UnaryOperator {2635 syntax,2636 kind: UnaryOperatorKind::BitNot,2637 },2638 _ => return None,2639 };2640 Some(res)2641 }2642 fn syntax(&self) -> &SyntaxToken {2643 &self.syntax2644 }2645}2646impl UnaryOperator {2647 pub fn kind(&self) -> UnaryOperatorKind {2648 self.kind2649 }2650}2651impl std::fmt::Display for UnaryOperator {2652 fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result {2653 std::fmt::Display::fmt(self.syntax(), f)2654 }2655}2656impl AstToken for Literal {2657 fn can_cast(kind: SyntaxKind) -> bool {2658 match kind {2659 NULL_KW | TRUE_KW | FALSE_KW | SELF_KW | DOLLAR | SUPER_KW => true,2660 _ => false,2661 }2662 }2663 fn cast(syntax: SyntaxToken) -> Option<Self> {2664 let res = match syntax.kind() {2665 NULL_KW => Literal {2666 syntax,2667 kind: LiteralKind::NullKw,2668 },2669 TRUE_KW => Literal {2670 syntax,2671 kind: LiteralKind::TrueKw,2672 },2673 FALSE_KW => Literal {2674 syntax,2675 kind: LiteralKind::FalseKw,2676 },2677 SELF_KW => Literal {2678 syntax,2679 kind: LiteralKind::SelfKw,2680 },2681 DOLLAR => Literal {2682 syntax,2683 kind: LiteralKind::Dollar,2684 },2685 SUPER_KW => Literal {2686 syntax,2687 kind: LiteralKind::SuperKw,2688 },2689 _ => return None,2690 };2691 Some(res)2692 }2693 fn syntax(&self) -> &SyntaxToken {2694 &self.syntax2695 }2696}2697impl Literal {2698 pub fn kind(&self) -> LiteralKind {2699 self.kind2700 }2701}2702impl std::fmt::Display for Literal {2703 fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result {2704 std::fmt::Display::fmt(self.syntax(), f)2705 }2706}2707impl AstToken for Text {2708 fn can_cast(kind: SyntaxKind) -> bool {2709 match kind {2710 STRING_DOUBLE2711 | ERROR_STRING_DOUBLE_UNTERMINATED2712 | STRING_SINGLE2713 | ERROR_STRING_SINGLE_UNTERMINATED2714 | STRING_DOUBLE_VERBATIM2715 | ERROR_STRING_DOUBLE_VERBATIM_UNTERMINATED2716 | STRING_SINGLE_VERBATIM2717 | ERROR_STRING_SINGLE_VERBATIM_UNTERMINATED2718 | ERROR_STRING_VERBATIM_MISSING_QUOTES2719 | STRING_BLOCK2720 | ERROR_STRING_BLOCK_UNEXPECTED_END2721 | ERROR_STRING_BLOCK_MISSING_NEW_LINE2722 | ERROR_STRING_BLOCK_MISSING_TERMINATION2723 | ERROR_STRING_BLOCK_MISSING_INDENT => true,2724 _ => false,2725 }2726 }2727 fn cast(syntax: SyntaxToken) -> Option<Self> {2728 let res = match syntax.kind() {2729 STRING_DOUBLE => Text {2730 syntax,2731 kind: TextKind::StringDouble,2732 },2733 ERROR_STRING_DOUBLE_UNTERMINATED => Text {2734 syntax,2735 kind: TextKind::ErrorStringDoubleUnterminated,2736 },2737 STRING_SINGLE => Text {2738 syntax,2739 kind: TextKind::StringSingle,2740 },2741 ERROR_STRING_SINGLE_UNTERMINATED => Text {2742 syntax,2743 kind: TextKind::ErrorStringSingleUnterminated,2744 },2745 STRING_DOUBLE_VERBATIM => Text {2746 syntax,2747 kind: TextKind::StringDoubleVerbatim,2748 },2749 ERROR_STRING_DOUBLE_VERBATIM_UNTERMINATED => Text {2750 syntax,2751 kind: TextKind::ErrorStringDoubleVerbatimUnterminated,2752 },2753 STRING_SINGLE_VERBATIM => Text {2754 syntax,2755 kind: TextKind::StringSingleVerbatim,2756 },2757 ERROR_STRING_SINGLE_VERBATIM_UNTERMINATED => Text {2758 syntax,2759 kind: TextKind::ErrorStringSingleVerbatimUnterminated,2760 },2761 ERROR_STRING_VERBATIM_MISSING_QUOTES => Text {2762 syntax,2763 kind: TextKind::ErrorStringVerbatimMissingQuotes,2764 },2765 STRING_BLOCK => Text {2766 syntax,2767 kind: TextKind::StringBlock,2768 },2769 ERROR_STRING_BLOCK_UNEXPECTED_END => Text {2770 syntax,2771 kind: TextKind::ErrorStringBlockUnexpectedEnd,2772 },2773 ERROR_STRING_BLOCK_MISSING_NEW_LINE => Text {2774 syntax,2775 kind: TextKind::ErrorStringBlockMissingNewLine,2776 },2777 ERROR_STRING_BLOCK_MISSING_TERMINATION => Text {2778 syntax,2779 kind: TextKind::ErrorStringBlockMissingTermination,2780 },2781 ERROR_STRING_BLOCK_MISSING_INDENT => Text {2782 syntax,2783 kind: TextKind::ErrorStringBlockMissingIndent,2784 },2785 _ => return None,2786 };2787 Some(res)2788 }2789 fn syntax(&self) -> &SyntaxToken {2790 &self.syntax2791 }2792}2793impl Text {2794 pub fn kind(&self) -> TextKind {2795 self.kind2796 }2797}2798impl std::fmt::Display for Text {2799 fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result {2800 std::fmt::Display::fmt(self.syntax(), f)2801 }2802}2803impl AstToken for Number {2804 fn can_cast(kind: SyntaxKind) -> bool {2805 match kind {2806 FLOAT2807 | ERROR_FLOAT_JUNK_AFTER_POINT2808 | ERROR_FLOAT_JUNK_AFTER_EXPONENT2809 | ERROR_FLOAT_JUNK_AFTER_EXPONENT_SIGN => true,2810 _ => false,2811 }2812 }2813 fn cast(syntax: SyntaxToken) -> Option<Self> {2814 let res = match syntax.kind() {2815 FLOAT => Number {2816 syntax,2817 kind: NumberKind::Float,2818 },2819 ERROR_FLOAT_JUNK_AFTER_POINT => Number {2820 syntax,2821 kind: NumberKind::ErrorFloatJunkAfterPoint,2822 },2823 ERROR_FLOAT_JUNK_AFTER_EXPONENT => Number {2824 syntax,2825 kind: NumberKind::ErrorFloatJunkAfterExponent,2826 },2827 ERROR_FLOAT_JUNK_AFTER_EXPONENT_SIGN => Number {2828 syntax,2829 kind: NumberKind::ErrorFloatJunkAfterExponentSign,2830 },2831 _ => return None,2832 };2833 Some(res)2834 }2835 fn syntax(&self) -> &SyntaxToken {2836 &self.syntax2837 }2838}2839impl Number {2840 pub fn kind(&self) -> NumberKind {2841 self.kind2842 }2843}2844impl std::fmt::Display for Number {2845 fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result {2846 std::fmt::Display::fmt(self.syntax(), f)2847 }2848}2849impl AstToken for ImportKind {2850 fn can_cast(kind: SyntaxKind) -> bool {2851 match kind {2852 IMPORTSTR_KW | IMPORTBIN_KW | IMPORT_KW => true,2853 _ => false,2854 }2855 }2856 fn cast(syntax: SyntaxToken) -> Option<Self> {2857 let res = match syntax.kind() {2858 IMPORTSTR_KW => ImportKind {2859 syntax,2860 kind: ImportKindKind::ImportstrKw,2861 },2862 IMPORTBIN_KW => ImportKind {2863 syntax,2864 kind: ImportKindKind::ImportbinKw,2865 },2866 IMPORT_KW => ImportKind {2867 syntax,2868 kind: ImportKindKind::ImportKw,2869 },2870 _ => return None,2871 };2872 Some(res)2873 }2874 fn syntax(&self) -> &SyntaxToken {2875 &self.syntax2876 }2877}2878impl ImportKind {2879 pub fn kind(&self) -> ImportKindKind {2880 self.kind2881 }2882}2883impl std::fmt::Display for ImportKind {2884 fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result {2885 std::fmt::Display::fmt(self.syntax(), f)2886 }2887}2888impl AstToken for Visibility {2889 fn can_cast(kind: SyntaxKind) -> bool {2890 match kind {2891 COLONCOLONCOLON | COLONCOLON | COLON => true,2892 _ => false,2893 }2894 }2895 fn cast(syntax: SyntaxToken) -> Option<Self> {2896 let res = match syntax.kind() {2897 COLONCOLONCOLON => Visibility {2898 syntax,2899 kind: VisibilityKind::Coloncoloncolon,2900 },2901 COLONCOLON => Visibility {2902 syntax,2903 kind: VisibilityKind::Coloncolon,2904 },2905 COLON => Visibility {2906 syntax,2907 kind: VisibilityKind::Colon,2908 },2909 _ => return None,2910 };2911 Some(res)2912 }2913 fn syntax(&self) -> &SyntaxToken {2914 &self.syntax2915 }2916}2917impl Visibility {2918 pub fn kind(&self) -> VisibilityKind {2919 self.kind2920 }2921}2922impl std::fmt::Display for Visibility {2923 fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result {2924 std::fmt::Display::fmt(self.syntax(), f)2925 }2926}2927impl AstToken for Trivia {2928 fn can_cast(kind: SyntaxKind) -> bool {2929 match kind {2930 WHITESPACE2931 | MULTI_LINE_COMMENT2932 | ERROR_COMMENT_TOO_SHORT2933 | ERROR_COMMENT_UNTERMINATED2934 | SINGLE_LINE_HASH_COMMENT2935 | SINGLE_LINE_SLASH_COMMENT => true,2936 _ => false,2937 }2938 }2939 fn cast(syntax: SyntaxToken) -> Option<Self> {2940 let res = match syntax.kind() {2941 WHITESPACE => Trivia {2942 syntax,2943 kind: TriviaKind::Whitespace,2944 },2945 MULTI_LINE_COMMENT => Trivia {2946 syntax,2947 kind: TriviaKind::MultiLineComment,2948 },2949 ERROR_COMMENT_TOO_SHORT => Trivia {2950 syntax,2951 kind: TriviaKind::ErrorCommentTooShort,2952 },2953 ERROR_COMMENT_UNTERMINATED => Trivia {2954 syntax,2955 kind: TriviaKind::ErrorCommentUnterminated,2956 },2957 SINGLE_LINE_HASH_COMMENT => Trivia {2958 syntax,2959 kind: TriviaKind::SingleLineHashComment,2960 },2961 SINGLE_LINE_SLASH_COMMENT => Trivia {2962 syntax,2963 kind: TriviaKind::SingleLineSlashComment,2964 },2965 _ => return None,2966 };2967 Some(res)2968 }2969 fn syntax(&self) -> &SyntaxToken {2970 &self.syntax2971 }2972}2973impl Trivia {2974 pub fn kind(&self) -> TriviaKind {2975 self.kind2976 }2977}2978impl std::fmt::Display for Trivia {2979 fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result {2980 std::fmt::Display::fmt(self.syntax(), f)2981 }2982}2983impl std::fmt::Display for Expr {2984 fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result {2985 std::fmt::Display::fmt(self.syntax(), f)2986 }2987}2988impl std::fmt::Display for ObjBody {2989 fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result {2990 std::fmt::Display::fmt(self.syntax(), f)2991 }2992}2993impl std::fmt::Display for CompSpec {2994 fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result {2995 std::fmt::Display::fmt(self.syntax(), f)2996 }2997}2998impl std::fmt::Display for Bind {2999 fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result {3000 std::fmt::Display::fmt(self.syntax(), f)3001 }3002}3003impl std::fmt::Display for Member {3004 fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result {3005 std::fmt::Display::fmt(self.syntax(), f)3006 }3007}3008impl std::fmt::Display for Field {3009 fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result {3010 std::fmt::Display::fmt(self.syntax(), f)3011 }3012}3013impl std::fmt::Display for FieldName {3014 fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result {3015 std::fmt::Display::fmt(self.syntax(), f)3016 }3017}3018impl std::fmt::Display for Destruct {3019 fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result {3020 std::fmt::Display::fmt(self.syntax(), f)3021 }3022}3023impl std::fmt::Display for DestructArrayPart {3024 fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result {3025 std::fmt::Display::fmt(self.syntax(), f)3026 }3027}3028impl std::fmt::Display for SourceFile {3029 fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result {3030 std::fmt::Display::fmt(self.syntax(), f)3031 }3032}3033impl std::fmt::Display for ExprBinary {3034 fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result {3035 std::fmt::Display::fmt(self.syntax(), f)3036 }3037}3038impl std::fmt::Display for LhsExpr {3039 fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result {3040 std::fmt::Display::fmt(self.syntax(), f)3041 }3042}3043impl std::fmt::Display for ExprUnary {3044 fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result {3045 std::fmt::Display::fmt(self.syntax(), f)3046 }3047}3048impl std::fmt::Display for ExprSlice {3049 fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result {3050 std::fmt::Display::fmt(self.syntax(), f)3051 }3052}3053impl std::fmt::Display for SliceDesc {3054 fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result {3055 std::fmt::Display::fmt(self.syntax(), f)3056 }3057}3058impl std::fmt::Display for ExprIndex {3059 fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result {3060 std::fmt::Display::fmt(self.syntax(), f)3061 }3062}3063impl std::fmt::Display for Name {3064 fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result {3065 std::fmt::Display::fmt(self.syntax(), f)3066 }3067}3068impl std::fmt::Display for ExprIndexExpr {3069 fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result {3070 std::fmt::Display::fmt(self.syntax(), f)3071 }3072}3073impl std::fmt::Display for ExprApply {3074 fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result {3075 std::fmt::Display::fmt(self.syntax(), f)3076 }3077}3078impl std::fmt::Display for ArgsDesc {3079 fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result {3080 std::fmt::Display::fmt(self.syntax(), f)3081 }3082}3083impl std::fmt::Display for ExprObjExtend {3084 fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result {3085 std::fmt::Display::fmt(self.syntax(), f)3086 }3087}3088impl std::fmt::Display for ExprParened {3089 fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result {3090 std::fmt::Display::fmt(self.syntax(), f)3091 }3092}3093impl std::fmt::Display for ExprLiteral {3094 fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result {3095 std::fmt::Display::fmt(self.syntax(), f)3096 }3097}3098impl std::fmt::Display for ExprIntrinsicThisFile {3099 fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result {3100 std::fmt::Display::fmt(self.syntax(), f)3101 }3102}3103impl std::fmt::Display for ExprIntrinsicId {3104 fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result {3105 std::fmt::Display::fmt(self.syntax(), f)3106 }3107}3108impl std::fmt::Display for ExprIntrinsic {3109 fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result {3110 std::fmt::Display::fmt(self.syntax(), f)3111 }3112}3113impl std::fmt::Display for ExprString {3114 fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result {3115 std::fmt::Display::fmt(self.syntax(), f)3116 }3117}3118impl std::fmt::Display for ExprNumber {3119 fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result {3120 std::fmt::Display::fmt(self.syntax(), f)3121 }3122}3123impl std::fmt::Display for ExprArray {3124 fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result {3125 std::fmt::Display::fmt(self.syntax(), f)3126 }3127}3128impl std::fmt::Display for ExprObject {3129 fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result {3130 std::fmt::Display::fmt(self.syntax(), f)3131 }3132}3133impl std::fmt::Display for ExprArrayComp {3134 fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result {3135 std::fmt::Display::fmt(self.syntax(), f)3136 }3137}3138impl std::fmt::Display for ExprImport {3139 fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result {3140 std::fmt::Display::fmt(self.syntax(), f)3141 }3142}3143impl std::fmt::Display for ExprVar {3144 fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result {3145 std::fmt::Display::fmt(self.syntax(), f)3146 }3147}3148impl std::fmt::Display for ExprLocal {3149 fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result {3150 std::fmt::Display::fmt(self.syntax(), f)3151 }3152}3153impl std::fmt::Display for ExprIfThenElse {3154 fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result {3155 std::fmt::Display::fmt(self.syntax(), f)3156 }3157}3158impl std::fmt::Display for TrueExpr {3159 fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result {3160 std::fmt::Display::fmt(self.syntax(), f)3161 }3162}3163impl std::fmt::Display for FalseExpr {3164 fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result {3165 std::fmt::Display::fmt(self.syntax(), f)3166 }3167}3168impl std::fmt::Display for ExprFunction {3169 fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result {3170 std::fmt::Display::fmt(self.syntax(), f)3171 }3172}3173impl std::fmt::Display for ParamsDesc {3174 fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result {3175 std::fmt::Display::fmt(self.syntax(), f)3176 }3177}3178impl std::fmt::Display for ExprAssert {3179 fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result {3180 std::fmt::Display::fmt(self.syntax(), f)3181 }3182}3183impl std::fmt::Display for Assertion {3184 fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result {3185 std::fmt::Display::fmt(self.syntax(), f)3186 }3187}3188impl std::fmt::Display for ExprError {3189 fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result {3190 std::fmt::Display::fmt(self.syntax(), f)3191 }3192}3193impl std::fmt::Display for SliceDescEnd {3194 fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result {3195 std::fmt::Display::fmt(self.syntax(), f)3196 }3197}3198impl std::fmt::Display for SliceDescStep {3199 fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result {3200 std::fmt::Display::fmt(self.syntax(), f)3201 }3202}3203impl std::fmt::Display for Arg {3204 fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result {3205 std::fmt::Display::fmt(self.syntax(), f)3206 }3207}3208impl std::fmt::Display for ObjBodyComp {3209 fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result {3210 std::fmt::Display::fmt(self.syntax(), f)3211 }3212}3213impl std::fmt::Display for ObjLocalPostComma {3214 fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result {3215 std::fmt::Display::fmt(self.syntax(), f)3216 }3217}3218impl std::fmt::Display for ObjLocalPreComma {3219 fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result {3220 std::fmt::Display::fmt(self.syntax(), f)3221 }3222}3223impl std::fmt::Display for ObjBodyMemberList {3224 fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result {3225 std::fmt::Display::fmt(self.syntax(), f)3226 }3227}3228impl std::fmt::Display for ObjLocal {3229 fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result {3230 std::fmt::Display::fmt(self.syntax(), f)3231 }3232}3233impl std::fmt::Display for MemberBindStmt {3234 fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result {3235 std::fmt::Display::fmt(self.syntax(), f)3236 }3237}3238impl std::fmt::Display for MemberAssertStmt {3239 fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result {3240 std::fmt::Display::fmt(self.syntax(), f)3241 }3242}3243impl std::fmt::Display for MemberField {3244 fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result {3245 std::fmt::Display::fmt(self.syntax(), f)3246 }3247}3248impl std::fmt::Display for FieldNormal {3249 fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result {3250 std::fmt::Display::fmt(self.syntax(), f)3251 }3252}3253impl std::fmt::Display for FieldMethod {3254 fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result {3255 std::fmt::Display::fmt(self.syntax(), f)3256 }3257}3258impl std::fmt::Display for FieldNameFixed {3259 fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result {3260 std::fmt::Display::fmt(self.syntax(), f)3261 }3262}3263impl std::fmt::Display for FieldNameDynamic {3264 fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result {3265 std::fmt::Display::fmt(self.syntax(), f)3266 }3267}3268impl std::fmt::Display for ForSpec {3269 fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result {3270 std::fmt::Display::fmt(self.syntax(), f)3271 }3272}3273impl std::fmt::Display for IfSpec {3274 fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result {3275 std::fmt::Display::fmt(self.syntax(), f)3276 }3277}3278impl std::fmt::Display for BindDestruct {3279 fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result {3280 std::fmt::Display::fmt(self.syntax(), f)3281 }3282}3283impl std::fmt::Display for BindFunction {3284 fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result {3285 std::fmt::Display::fmt(self.syntax(), f)3286 }3287}3288impl std::fmt::Display for Param {3289 fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result {3290 std::fmt::Display::fmt(self.syntax(), f)3291 }3292}3293impl std::fmt::Display for DestructFull {3294 fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result {3295 std::fmt::Display::fmt(self.syntax(), f)3296 }3297}3298impl std::fmt::Display for DestructSkip {3299 fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result {3300 std::fmt::Display::fmt(self.syntax(), f)3301 }3302}3303impl std::fmt::Display for DestructArray {3304 fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result {3305 std::fmt::Display::fmt(self.syntax(), f)3306 }3307}3308impl std::fmt::Display for DestructObject {3309 fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result {3310 std::fmt::Display::fmt(self.syntax(), f)3311 }3312}3313impl std::fmt::Display for DestructObjectField {3314 fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result {3315 std::fmt::Display::fmt(self.syntax(), f)3316 }3317}3318impl std::fmt::Display for DestructRest {3319 fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result {3320 std::fmt::Display::fmt(self.syntax(), f)3321 }3322}3323impl std::fmt::Display for DestructArrayElement {3324 fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result {3325 std::fmt::Display::fmt(self.syntax(), f)3326 }3327}1//! This is a generated file, please do not edit manually. Changes can be2//! made in codegeneration that lives in `xtask` top-level dir.34#![allow(non_snake_case, clippy::match_like_matches_macro)]5use crate::{6 ast::{support, AstChildren, AstNode, AstToken},7 SyntaxKind::{self, *},8 SyntaxNode, SyntaxToken, T,9};1011#[derive(Debug, Clone, PartialEq, Eq, Hash)]12pub struct SourceFile {13 pub(crate) syntax: SyntaxNode,14}15impl SourceFile {16 pub fn expr(&self) -> Option<Expr> {17 support::child(&self.syntax)18 }19}2021#[derive(Debug, Clone, PartialEq, Eq, Hash)]22pub struct ExprBinary {23 pub(crate) syntax: SyntaxNode,24}25impl ExprBinary {26 pub fn lhs(&self) -> Option<LhsExpr> {27 support::child(&self.syntax)28 }29 pub fn binary_operator(&self) -> Option<BinaryOperator> {30 support::token_child(&self.syntax)31 }32 pub fn rhs(&self) -> Option<Expr> {33 support::child(&self.syntax)34 }35}3637#[derive(Debug, Clone, PartialEq, Eq, Hash)]38pub struct LhsExpr {39 pub(crate) syntax: SyntaxNode,40}41impl LhsExpr {42 pub fn expr(&self) -> Option<Expr> {43 support::child(&self.syntax)44 }45}4647#[derive(Debug, Clone, PartialEq, Eq, Hash)]48pub struct ExprUnary {49 pub(crate) syntax: SyntaxNode,50}51impl ExprUnary {52 pub fn unary_operator(&self) -> Option<UnaryOperator> {53 support::token_child(&self.syntax)54 }55 pub fn rhs(&self) -> Option<Expr> {56 support::child(&self.syntax)57 }58}5960#[derive(Debug, Clone, PartialEq, Eq, Hash)]61pub struct ExprSlice {62 pub(crate) syntax: SyntaxNode,63}64impl ExprSlice {65 pub fn expr(&self) -> Option<Expr> {66 support::child(&self.syntax)67 }68 pub fn slice_desc(&self) -> Option<SliceDesc> {69 support::child(&self.syntax)70 }71}7273#[derive(Debug, Clone, PartialEq, Eq, Hash)]74pub struct SliceDesc {75 pub(crate) syntax: SyntaxNode,76}77impl SliceDesc {78 pub fn l_brack_token(&self) -> Option<SyntaxToken> {79 support::token(&self.syntax, T!['['])80 }81 pub fn from(&self) -> Option<Expr> {82 support::child(&self.syntax)83 }84 pub fn colon_token(&self) -> Option<SyntaxToken> {85 support::token(&self.syntax, T![:])86 }87 pub fn end(&self) -> Option<SliceDescEnd> {88 support::child(&self.syntax)89 }90 pub fn step(&self) -> Option<SliceDescStep> {91 support::child(&self.syntax)92 }93 pub fn r_brack_token(&self) -> Option<SyntaxToken> {94 support::token(&self.syntax, T![']'])95 }96}9798#[derive(Debug, Clone, PartialEq, Eq, Hash)]99pub struct ExprIndex {100 pub(crate) syntax: SyntaxNode,101}102impl ExprIndex {103 pub fn expr(&self) -> Option<Expr> {104 support::child(&self.syntax)105 }106 pub fn dot_token(&self) -> Option<SyntaxToken> {107 support::token(&self.syntax, T![.])108 }109 pub fn index(&self) -> Option<Name> {110 support::child(&self.syntax)111 }112}113114#[derive(Debug, Clone, PartialEq, Eq, Hash)]115pub struct Name {116 pub(crate) syntax: SyntaxNode,117}118impl Name {119 pub fn ident_lit(&self) -> Option<SyntaxToken> {120 support::token(&self.syntax, IDENT)121 }122}123124#[derive(Debug, Clone, PartialEq, Eq, Hash)]125pub struct ExprIndexExpr {126 pub(crate) syntax: SyntaxNode,127}128impl ExprIndexExpr {129 pub fn base(&self) -> Option<LhsExpr> {130 support::child(&self.syntax)131 }132 pub fn l_brack_token(&self) -> Option<SyntaxToken> {133 support::token(&self.syntax, T!['['])134 }135 pub fn index(&self) -> Option<Expr> {136 support::child(&self.syntax)137 }138 pub fn r_brack_token(&self) -> Option<SyntaxToken> {139 support::token(&self.syntax, T![']'])140 }141}142143#[derive(Debug, Clone, PartialEq, Eq, Hash)]144pub struct ExprApply {145 pub(crate) syntax: SyntaxNode,146}147impl ExprApply {148 pub fn expr(&self) -> Option<Expr> {149 support::child(&self.syntax)150 }151 pub fn args_desc(&self) -> Option<ArgsDesc> {152 support::child(&self.syntax)153 }154 pub fn tailstrict_kw_token(&self) -> Option<SyntaxToken> {155 support::token(&self.syntax, T![tailstrict])156 }157}158159#[derive(Debug, Clone, PartialEq, Eq, Hash)]160pub struct ArgsDesc {161 pub(crate) syntax: SyntaxNode,162}163impl ArgsDesc {164 pub fn l_paren_token(&self) -> Option<SyntaxToken> {165 support::token(&self.syntax, T!['('])166 }167 pub fn args(&self) -> AstChildren<Arg> {168 support::children(&self.syntax)169 }170 pub fn r_paren_token(&self) -> Option<SyntaxToken> {171 support::token(&self.syntax, T![')'])172 }173}174175#[derive(Debug, Clone, PartialEq, Eq, Hash)]176pub struct ExprObjExtend {177 pub(crate) syntax: SyntaxNode,178}179impl ExprObjExtend {180 pub fn lhs_expr(&self) -> Option<LhsExpr> {181 support::child(&self.syntax)182 }183 pub fn expr(&self) -> Option<Expr> {184 support::child(&self.syntax)185 }186}187188#[derive(Debug, Clone, PartialEq, Eq, Hash)]189pub struct ExprParened {190 pub(crate) syntax: SyntaxNode,191}192impl ExprParened {193 pub fn l_paren_token(&self) -> Option<SyntaxToken> {194 support::token(&self.syntax, T!['('])195 }196 pub fn expr(&self) -> Option<Expr> {197 support::child(&self.syntax)198 }199 pub fn r_paren_token(&self) -> Option<SyntaxToken> {200 support::token(&self.syntax, T![')'])201 }202}203204#[derive(Debug, Clone, PartialEq, Eq, Hash)]205pub struct ExprLiteral {206 pub(crate) syntax: SyntaxNode,207}208impl ExprLiteral {209 pub fn literal(&self) -> Option<Literal> {210 support::token_child(&self.syntax)211 }212}213214#[derive(Debug, Clone, PartialEq, Eq, Hash)]215pub struct ExprIntrinsicThisFile {216 pub(crate) syntax: SyntaxNode,217}218impl ExprIntrinsicThisFile {219 pub fn intrinsic_this_file_token(&self) -> Option<SyntaxToken> {220 support::token(&self.syntax, T!["$intrinsicThisFile"])221 }222}223224#[derive(Debug, Clone, PartialEq, Eq, Hash)]225pub struct ExprIntrinsicId {226 pub(crate) syntax: SyntaxNode,227}228impl ExprIntrinsicId {229 pub fn intrinsic_id_token(&self) -> Option<SyntaxToken> {230 support::token(&self.syntax, T!["$intrinsicId"])231 }232}233234#[derive(Debug, Clone, PartialEq, Eq, Hash)]235pub struct ExprIntrinsic {236 pub(crate) syntax: SyntaxNode,237}238impl ExprIntrinsic {239 pub fn intrinsic_token(&self) -> Option<SyntaxToken> {240 support::token(&self.syntax, T!["$intrinsic"])241 }242 pub fn l_paren_token(&self) -> Option<SyntaxToken> {243 support::token(&self.syntax, T!['('])244 }245 pub fn name(&self) -> Option<Name> {246 support::child(&self.syntax)247 }248 pub fn r_paren_token(&self) -> Option<SyntaxToken> {249 support::token(&self.syntax, T![')'])250 }251}252253#[derive(Debug, Clone, PartialEq, Eq, Hash)]254pub struct ExprString {255 pub(crate) syntax: SyntaxNode,256}257impl ExprString {258 pub fn text(&self) -> Option<Text> {259 support::token_child(&self.syntax)260 }261}262263#[derive(Debug, Clone, PartialEq, Eq, Hash)]264pub struct ExprNumber {265 pub(crate) syntax: SyntaxNode,266}267impl ExprNumber {268 pub fn number(&self) -> Option<Number> {269 support::token_child(&self.syntax)270 }271}272273#[derive(Debug, Clone, PartialEq, Eq, Hash)]274pub struct ExprArray {275 pub(crate) syntax: SyntaxNode,276}277impl ExprArray {278 pub fn l_brack_token(&self) -> Option<SyntaxToken> {279 support::token(&self.syntax, T!['['])280 }281 pub fn exprs(&self) -> AstChildren<Expr> {282 support::children(&self.syntax)283 }284 pub fn r_brack_token(&self) -> Option<SyntaxToken> {285 support::token(&self.syntax, T![']'])286 }287}288289#[derive(Debug, Clone, PartialEq, Eq, Hash)]290pub struct ExprObject {291 pub(crate) syntax: SyntaxNode,292}293impl ExprObject {294 pub fn l_brace_token(&self) -> Option<SyntaxToken> {295 support::token(&self.syntax, T!['{'])296 }297 pub fn obj_body(&self) -> Option<ObjBody> {298 support::child(&self.syntax)299 }300 pub fn r_brace_token(&self) -> Option<SyntaxToken> {301 support::token(&self.syntax, T!['}'])302 }303}304305#[derive(Debug, Clone, PartialEq, Eq, Hash)]306pub struct ExprArrayComp {307 pub(crate) syntax: SyntaxNode,308}309impl ExprArrayComp {310 pub fn l_brack_token(&self) -> Option<SyntaxToken> {311 support::token(&self.syntax, T!['['])312 }313 pub fn expr(&self) -> Option<Expr> {314 support::child(&self.syntax)315 }316 pub fn comma_token(&self) -> Option<SyntaxToken> {317 support::token(&self.syntax, T![,])318 }319 pub fn comp_specs(&self) -> AstChildren<CompSpec> {320 support::children(&self.syntax)321 }322 pub fn r_brack_token(&self) -> Option<SyntaxToken> {323 support::token(&self.syntax, T![']'])324 }325}326327#[derive(Debug, Clone, PartialEq, Eq, Hash)]328pub struct ExprImport {329 pub(crate) syntax: SyntaxNode,330}331impl ExprImport {332 pub fn import_kind(&self) -> Option<ImportKind> {333 support::token_child(&self.syntax)334 }335 pub fn text(&self) -> Option<Text> {336 support::token_child(&self.syntax)337 }338}339340#[derive(Debug, Clone, PartialEq, Eq, Hash)]341pub struct ExprVar {342 pub(crate) syntax: SyntaxNode,343}344impl ExprVar {345 pub fn name(&self) -> Option<Name> {346 support::child(&self.syntax)347 }348}349350#[derive(Debug, Clone, PartialEq, Eq, Hash)]351pub struct ExprLocal {352 pub(crate) syntax: SyntaxNode,353}354impl ExprLocal {355 pub fn local_kw_token(&self) -> Option<SyntaxToken> {356 support::token(&self.syntax, T![local])357 }358 pub fn binds(&self) -> AstChildren<Bind> {359 support::children(&self.syntax)360 }361 pub fn semi_token(&self) -> Option<SyntaxToken> {362 support::token(&self.syntax, T![;])363 }364 pub fn expr(&self) -> Option<Expr> {365 support::child(&self.syntax)366 }367}368369#[derive(Debug, Clone, PartialEq, Eq, Hash)]370pub struct ExprIfThenElse {371 pub(crate) syntax: SyntaxNode,372}373impl ExprIfThenElse {374 pub fn if_kw_token(&self) -> Option<SyntaxToken> {375 support::token(&self.syntax, T![if])376 }377 pub fn cond(&self) -> Option<Expr> {378 support::child(&self.syntax)379 }380 pub fn then_kw_token(&self) -> Option<SyntaxToken> {381 support::token(&self.syntax, T![then])382 }383 pub fn then(&self) -> Option<TrueExpr> {384 support::child(&self.syntax)385 }386 pub fn else_kw_token(&self) -> Option<SyntaxToken> {387 support::token(&self.syntax, T![else])388 }389 pub fn else_(&self) -> Option<FalseExpr> {390 support::child(&self.syntax)391 }392}393394#[derive(Debug, Clone, PartialEq, Eq, Hash)]395pub struct TrueExpr {396 pub(crate) syntax: SyntaxNode,397}398impl TrueExpr {399 pub fn expr(&self) -> Option<Expr> {400 support::child(&self.syntax)401 }402}403404#[derive(Debug, Clone, PartialEq, Eq, Hash)]405pub struct FalseExpr {406 pub(crate) syntax: SyntaxNode,407}408impl FalseExpr {409 pub fn expr(&self) -> Option<Expr> {410 support::child(&self.syntax)411 }412}413414#[derive(Debug, Clone, PartialEq, Eq, Hash)]415pub struct ExprFunction {416 pub(crate) syntax: SyntaxNode,417}418impl ExprFunction {419 pub fn function_kw_token(&self) -> Option<SyntaxToken> {420 support::token(&self.syntax, T![function])421 }422 pub fn l_paren_token(&self) -> Option<SyntaxToken> {423 support::token(&self.syntax, T!['('])424 }425 pub fn params_desc(&self) -> Option<ParamsDesc> {426 support::child(&self.syntax)427 }428 pub fn r_paren_token(&self) -> Option<SyntaxToken> {429 support::token(&self.syntax, T![')'])430 }431 pub fn expr(&self) -> Option<Expr> {432 support::child(&self.syntax)433 }434}435436#[derive(Debug, Clone, PartialEq, Eq, Hash)]437pub struct ParamsDesc {438 pub(crate) syntax: SyntaxNode,439}440impl ParamsDesc {441 pub fn l_paren_token(&self) -> Option<SyntaxToken> {442 support::token(&self.syntax, T!['('])443 }444 pub fn params(&self) -> AstChildren<Param> {445 support::children(&self.syntax)446 }447 pub fn r_paren_token(&self) -> Option<SyntaxToken> {448 support::token(&self.syntax, T![')'])449 }450}451452#[derive(Debug, Clone, PartialEq, Eq, Hash)]453pub struct ExprAssert {454 pub(crate) syntax: SyntaxNode,455}456impl ExprAssert {457 pub fn assertion(&self) -> Option<Assertion> {458 support::child(&self.syntax)459 }460 pub fn semi_token(&self) -> Option<SyntaxToken> {461 support::token(&self.syntax, T![;])462 }463 pub fn expr(&self) -> Option<Expr> {464 support::child(&self.syntax)465 }466}467468#[derive(Debug, Clone, PartialEq, Eq, Hash)]469pub struct Assertion {470 pub(crate) syntax: SyntaxNode,471}472impl Assertion {473 pub fn assert_kw_token(&self) -> Option<SyntaxToken> {474 support::token(&self.syntax, T![assert])475 }476 pub fn condition(&self) -> Option<LhsExpr> {477 support::child(&self.syntax)478 }479 pub fn colon_token(&self) -> Option<SyntaxToken> {480 support::token(&self.syntax, T![:])481 }482 pub fn message(&self) -> Option<Expr> {483 support::child(&self.syntax)484 }485}486487#[derive(Debug, Clone, PartialEq, Eq, Hash)]488pub struct ExprError {489 pub(crate) syntax: SyntaxNode,490}491impl ExprError {492 pub fn error_kw_token(&self) -> Option<SyntaxToken> {493 support::token(&self.syntax, T![error])494 }495 pub fn expr(&self) -> Option<Expr> {496 support::child(&self.syntax)497 }498}499500#[derive(Debug, Clone, PartialEq, Eq, Hash)]501pub struct SliceDescEnd {502 pub(crate) syntax: SyntaxNode,503}504impl SliceDescEnd {505 pub fn expr(&self) -> Option<Expr> {506 support::child(&self.syntax)507 }508}509510#[derive(Debug, Clone, PartialEq, Eq, Hash)]511pub struct SliceDescStep {512 pub(crate) syntax: SyntaxNode,513}514impl SliceDescStep {515 pub fn expr(&self) -> Option<Expr> {516 support::child(&self.syntax)517 }518}519520#[derive(Debug, Clone, PartialEq, Eq, Hash)]521pub struct Arg {522 pub(crate) syntax: SyntaxNode,523}524impl Arg {525 pub fn name(&self) -> Option<Name> {526 support::child(&self.syntax)527 }528 pub fn assign_token(&self) -> Option<SyntaxToken> {529 support::token(&self.syntax, T![=])530 }531 pub fn expr(&self) -> Option<Expr> {532 support::child(&self.syntax)533 }534}535536#[derive(Debug, Clone, PartialEq, Eq, Hash)]537pub struct ObjBodyComp {538 pub(crate) syntax: SyntaxNode,539}540impl ObjBodyComp {541 pub fn pre(&self) -> AstChildren<ObjLocalPostComma> {542 support::children(&self.syntax)543 }544 pub fn l_brack_token(&self) -> Option<SyntaxToken> {545 support::token(&self.syntax, T!['['])546 }547 pub fn key(&self) -> Option<LhsExpr> {548 support::child(&self.syntax)549 }550 pub fn r_brack_token(&self) -> Option<SyntaxToken> {551 support::token(&self.syntax, T![']'])552 }553 pub fn plus_token(&self) -> Option<SyntaxToken> {554 support::token(&self.syntax, T![+])555 }556 pub fn colon_token(&self) -> Option<SyntaxToken> {557 support::token(&self.syntax, T![:])558 }559 pub fn value(&self) -> Option<Expr> {560 support::child(&self.syntax)561 }562 pub fn post(&self) -> AstChildren<ObjLocalPreComma> {563 support::children(&self.syntax)564 }565 pub fn comp_specs(&self) -> AstChildren<CompSpec> {566 support::children(&self.syntax)567 }568}569570#[derive(Debug, Clone, PartialEq, Eq, Hash)]571pub struct ObjLocalPostComma {572 pub(crate) syntax: SyntaxNode,573}574impl ObjLocalPostComma {575 pub fn obj_local(&self) -> Option<ObjLocal> {576 support::child(&self.syntax)577 }578 pub fn comma_token(&self) -> Option<SyntaxToken> {579 support::token(&self.syntax, T![,])580 }581}582583#[derive(Debug, Clone, PartialEq, Eq, Hash)]584pub struct ObjLocalPreComma {585 pub(crate) syntax: SyntaxNode,586}587impl ObjLocalPreComma {588 pub fn comma_token(&self) -> Option<SyntaxToken> {589 support::token(&self.syntax, T![,])590 }591 pub fn obj_local(&self) -> Option<ObjLocal> {592 support::child(&self.syntax)593 }594}595596#[derive(Debug, Clone, PartialEq, Eq, Hash)]597pub struct ObjBodyMemberList {598 pub(crate) syntax: SyntaxNode,599}600impl ObjBodyMemberList {601 pub fn members(&self) -> AstChildren<Member> {602 support::children(&self.syntax)603 }604}605606#[derive(Debug, Clone, PartialEq, Eq, Hash)]607pub struct ObjLocal {608 pub(crate) syntax: SyntaxNode,609}610impl ObjLocal {611 pub fn local_kw_token(&self) -> Option<SyntaxToken> {612 support::token(&self.syntax, T![local])613 }614 pub fn bind(&self) -> Option<Bind> {615 support::child(&self.syntax)616 }617}618619#[derive(Debug, Clone, PartialEq, Eq, Hash)]620pub struct MemberBindStmt {621 pub(crate) syntax: SyntaxNode,622}623impl MemberBindStmt {624 pub fn obj_local(&self) -> Option<ObjLocal> {625 support::child(&self.syntax)626 }627}628629#[derive(Debug, Clone, PartialEq, Eq, Hash)]630pub struct MemberAssertStmt {631 pub(crate) syntax: SyntaxNode,632}633impl MemberAssertStmt {634 pub fn assertion(&self) -> Option<Assertion> {635 support::child(&self.syntax)636 }637}638639#[derive(Debug, Clone, PartialEq, Eq, Hash)]640pub struct MemberField {641 pub(crate) syntax: SyntaxNode,642}643impl MemberField {644 pub fn field(&self) -> Option<Field> {645 support::child(&self.syntax)646 }647}648649#[derive(Debug, Clone, PartialEq, Eq, Hash)]650pub struct FieldNormal {651 pub(crate) syntax: SyntaxNode,652}653impl FieldNormal {654 pub fn field_name(&self) -> Option<FieldName> {655 support::child(&self.syntax)656 }657 pub fn plus_token(&self) -> Option<SyntaxToken> {658 support::token(&self.syntax, T![+])659 }660 pub fn visibility(&self) -> Option<Visibility> {661 support::token_child(&self.syntax)662 }663 pub fn expr(&self) -> Option<Expr> {664 support::child(&self.syntax)665 }666}667668#[derive(Debug, Clone, PartialEq, Eq, Hash)]669pub struct FieldMethod {670 pub(crate) syntax: SyntaxNode,671}672impl FieldMethod {673 pub fn field_name(&self) -> Option<FieldName> {674 support::child(&self.syntax)675 }676 pub fn params_desc(&self) -> Option<ParamsDesc> {677 support::child(&self.syntax)678 }679 pub fn visibility(&self) -> Option<Visibility> {680 support::token_child(&self.syntax)681 }682 pub fn expr(&self) -> Option<Expr> {683 support::child(&self.syntax)684 }685}686687#[derive(Debug, Clone, PartialEq, Eq, Hash)]688pub struct FieldNameFixed {689 pub(crate) syntax: SyntaxNode,690}691impl FieldNameFixed {692 pub fn id(&self) -> Option<Name> {693 support::child(&self.syntax)694 }695 pub fn text(&self) -> Option<Text> {696 support::token_child(&self.syntax)697 }698}699700#[derive(Debug, Clone, PartialEq, Eq, Hash)]701pub struct FieldNameDynamic {702 pub(crate) syntax: SyntaxNode,703}704impl FieldNameDynamic {705 pub fn l_brack_token(&self) -> Option<SyntaxToken> {706 support::token(&self.syntax, T!['['])707 }708 pub fn expr(&self) -> Option<Expr> {709 support::child(&self.syntax)710 }711 pub fn r_brack_token(&self) -> Option<SyntaxToken> {712 support::token(&self.syntax, T![']'])713 }714}715716#[derive(Debug, Clone, PartialEq, Eq, Hash)]717pub struct ForSpec {718 pub(crate) syntax: SyntaxNode,719}720impl ForSpec {721 pub fn for_kw_token(&self) -> Option<SyntaxToken> {722 support::token(&self.syntax, T![for])723 }724 pub fn bind(&self) -> Option<Name> {725 support::child(&self.syntax)726 }727 pub fn in_kw_token(&self) -> Option<SyntaxToken> {728 support::token(&self.syntax, T![in])729 }730 pub fn expr(&self) -> Option<Expr> {731 support::child(&self.syntax)732 }733}734735#[derive(Debug, Clone, PartialEq, Eq, Hash)]736pub struct IfSpec {737 pub(crate) syntax: SyntaxNode,738}739impl IfSpec {740 pub fn if_kw_token(&self) -> Option<SyntaxToken> {741 support::token(&self.syntax, T![if])742 }743 pub fn expr(&self) -> Option<Expr> {744 support::child(&self.syntax)745 }746}747748#[derive(Debug, Clone, PartialEq, Eq, Hash)]749pub struct BindDestruct {750 pub(crate) syntax: SyntaxNode,751}752impl BindDestruct {753 pub fn into(&self) -> Option<Destruct> {754 support::child(&self.syntax)755 }756 pub fn assign_token(&self) -> Option<SyntaxToken> {757 support::token(&self.syntax, T![=])758 }759 pub fn value(&self) -> Option<Expr> {760 support::child(&self.syntax)761 }762}763764#[derive(Debug, Clone, PartialEq, Eq, Hash)]765pub struct BindFunction {766 pub(crate) syntax: SyntaxNode,767}768impl BindFunction {769 pub fn name(&self) -> Option<Name> {770 support::child(&self.syntax)771 }772 pub fn params(&self) -> Option<ParamsDesc> {773 support::child(&self.syntax)774 }775 pub fn assign_token(&self) -> Option<SyntaxToken> {776 support::token(&self.syntax, T![=])777 }778 pub fn value(&self) -> Option<Expr> {779 support::child(&self.syntax)780 }781}782783#[derive(Debug, Clone, PartialEq, Eq, Hash)]784pub struct Param {785 pub(crate) syntax: SyntaxNode,786}787impl Param {788 pub fn destruct(&self) -> Option<Destruct> {789 support::child(&self.syntax)790 }791 pub fn assign_token(&self) -> Option<SyntaxToken> {792 support::token(&self.syntax, T![=])793 }794 pub fn expr(&self) -> Option<Expr> {795 support::child(&self.syntax)796 }797}798799#[derive(Debug, Clone, PartialEq, Eq, Hash)]800pub struct DestructFull {801 pub(crate) syntax: SyntaxNode,802}803impl DestructFull {804 pub fn name(&self) -> Option<Name> {805 support::child(&self.syntax)806 }807}808809#[derive(Debug, Clone, PartialEq, Eq, Hash)]810pub struct DestructSkip {811 pub(crate) syntax: SyntaxNode,812}813impl DestructSkip {814 pub fn question_mark_token(&self) -> Option<SyntaxToken> {815 support::token(&self.syntax, T![?])816 }817}818819#[derive(Debug, Clone, PartialEq, Eq, Hash)]820pub struct DestructArray {821 pub(crate) syntax: SyntaxNode,822}823impl DestructArray {824 pub fn l_brack_token(&self) -> Option<SyntaxToken> {825 support::token(&self.syntax, T!['['])826 }827 pub fn destruct_array_parts(&self) -> AstChildren<DestructArrayPart> {828 support::children(&self.syntax)829 }830 pub fn r_brack_token(&self) -> Option<SyntaxToken> {831 support::token(&self.syntax, T![']'])832 }833}834835#[derive(Debug, Clone, PartialEq, Eq, Hash)]836pub struct DestructObject {837 pub(crate) syntax: SyntaxNode,838}839impl DestructObject {840 pub fn l_brace_token(&self) -> Option<SyntaxToken> {841 support::token(&self.syntax, T!['{'])842 }843 pub fn destruct_object_fields(&self) -> AstChildren<DestructObjectField> {844 support::children(&self.syntax)845 }846 pub fn destruct_rest(&self) -> Option<DestructRest> {847 support::child(&self.syntax)848 }849 pub fn comma_token(&self) -> Option<SyntaxToken> {850 support::token(&self.syntax, T![,])851 }852 pub fn r_brace_token(&self) -> Option<SyntaxToken> {853 support::token(&self.syntax, T!['}'])854 }855}856857#[derive(Debug, Clone, PartialEq, Eq, Hash)]858pub struct DestructObjectField {859 pub(crate) syntax: SyntaxNode,860}861impl DestructObjectField {862 pub fn field(&self) -> Option<Name> {863 support::child(&self.syntax)864 }865 pub fn colon_token(&self) -> Option<SyntaxToken> {866 support::token(&self.syntax, T![:])867 }868 pub fn destruct(&self) -> Option<Destruct> {869 support::child(&self.syntax)870 }871 pub fn assign_token(&self) -> Option<SyntaxToken> {872 support::token(&self.syntax, T![=])873 }874 pub fn expr(&self) -> Option<Expr> {875 support::child(&self.syntax)876 }877}878879#[derive(Debug, Clone, PartialEq, Eq, Hash)]880pub struct DestructRest {881 pub(crate) syntax: SyntaxNode,882}883impl DestructRest {884 pub fn dotdotdot_token(&self) -> Option<SyntaxToken> {885 support::token(&self.syntax, T![...])886 }887 pub fn into(&self) -> Option<Name> {888 support::child(&self.syntax)889 }890}891892#[derive(Debug, Clone, PartialEq, Eq, Hash)]893pub struct DestructArrayElement {894 pub(crate) syntax: SyntaxNode,895}896impl DestructArrayElement {897 pub fn destruct(&self) -> Option<Destruct> {898 support::child(&self.syntax)899 }900}901902#[derive(Debug, Clone, PartialEq, Eq, Hash)]903pub enum Expr {904 ExprBinary(ExprBinary),905 ExprUnary(ExprUnary),906 ExprSlice(ExprSlice),907 ExprIndex(ExprIndex),908 ExprIndexExpr(ExprIndexExpr),909 ExprApply(ExprApply),910 ExprObjExtend(ExprObjExtend),911 ExprParened(ExprParened),912 ExprIntrinsicThisFile(ExprIntrinsicThisFile),913 ExprIntrinsicId(ExprIntrinsicId),914 ExprIntrinsic(ExprIntrinsic),915 ExprString(ExprString),916 ExprNumber(ExprNumber),917 ExprLiteral(ExprLiteral),918 ExprArray(ExprArray),919 ExprObject(ExprObject),920 ExprArrayComp(ExprArrayComp),921 ExprImport(ExprImport),922 ExprVar(ExprVar),923 ExprLocal(ExprLocal),924 ExprIfThenElse(ExprIfThenElse),925 ExprFunction(ExprFunction),926 ExprAssert(ExprAssert),927 ExprError(ExprError),928}929930#[derive(Debug, Clone, PartialEq, Eq, Hash)]931pub enum ObjBody {932 ObjBodyComp(ObjBodyComp),933 ObjBodyMemberList(ObjBodyMemberList),934}935936#[derive(Debug, Clone, PartialEq, Eq, Hash)]937pub enum CompSpec {938 ForSpec(ForSpec),939 IfSpec(IfSpec),940}941942#[derive(Debug, Clone, PartialEq, Eq, Hash)]943pub enum Bind {944 BindDestruct(BindDestruct),945 BindFunction(BindFunction),946}947948#[derive(Debug, Clone, PartialEq, Eq, Hash)]949pub enum Member {950 MemberBindStmt(MemberBindStmt),951 MemberAssertStmt(MemberAssertStmt),952 MemberField(MemberField),953}954955#[derive(Debug, Clone, PartialEq, Eq, Hash)]956pub enum Field {957 FieldNormal(FieldNormal),958 FieldMethod(FieldMethod),959}960961#[derive(Debug, Clone, PartialEq, Eq, Hash)]962pub enum FieldName {963 FieldNameFixed(FieldNameFixed),964 FieldNameDynamic(FieldNameDynamic),965}966967#[derive(Debug, Clone, PartialEq, Eq, Hash)]968pub enum Destruct {969 DestructFull(DestructFull),970 DestructSkip(DestructSkip),971 DestructArray(DestructArray),972 DestructObject(DestructObject),973}974975#[derive(Debug, Clone, PartialEq, Eq, Hash)]976pub enum DestructArrayPart {977 DestructArrayElement(DestructArrayElement),978 DestructRest(DestructRest),979}980981#[derive(Debug, Clone, PartialEq, Eq, Hash)]982pub struct BinaryOperator {983 syntax: SyntaxToken,984 kind: BinaryOperatorKind,985}986987#[derive(Debug, Clone, Copy, PartialEq, Eq, Hash)]988pub enum BinaryOperatorKind {989 Or,990 And,991 BitOr,992 BitXor,993 BitAnd,994 Eq,995 Ne,996 Lt,997 Gt,998 Le,999 Ge,1000 InKw,1001 Lhs,1002 Rhs,1003 Plus,1004 Minus,1005 Mul,1006 Div,1007 Modulo,1008 MetaObjectApply,1009 ErrorNoOperator,1010}10111012#[derive(Debug, Clone, PartialEq, Eq, Hash)]1013pub struct UnaryOperator {1014 syntax: SyntaxToken,1015 kind: UnaryOperatorKind,1016}10171018#[derive(Debug, Clone, Copy, PartialEq, Eq, Hash)]1019pub enum UnaryOperatorKind {1020 Minus,1021 Not,1022 BitNot,1023}10241025#[derive(Debug, Clone, PartialEq, Eq, Hash)]1026pub struct Literal {1027 syntax: SyntaxToken,1028 kind: LiteralKind,1029}10301031#[derive(Debug, Clone, Copy, PartialEq, Eq, Hash)]1032pub enum LiteralKind {1033 NullKw,1034 TrueKw,1035 FalseKw,1036 SelfKw,1037 Dollar,1038 SuperKw,1039}10401041#[derive(Debug, Clone, PartialEq, Eq, Hash)]1042pub struct Text {1043 syntax: SyntaxToken,1044 kind: TextKind,1045}10461047#[derive(Debug, Clone, Copy, PartialEq, Eq, Hash)]1048pub enum TextKind {1049 StringDouble,1050 ErrorStringDoubleUnterminated,1051 StringSingle,1052 ErrorStringSingleUnterminated,1053 StringDoubleVerbatim,1054 ErrorStringDoubleVerbatimUnterminated,1055 StringSingleVerbatim,1056 ErrorStringSingleVerbatimUnterminated,1057 ErrorStringVerbatimMissingQuotes,1058 StringBlock,1059 ErrorStringBlockUnexpectedEnd,1060 ErrorStringBlockMissingNewLine,1061 ErrorStringBlockMissingTermination,1062 ErrorStringBlockMissingIndent,1063}10641065#[derive(Debug, Clone, PartialEq, Eq, Hash)]1066pub struct Number {1067 syntax: SyntaxToken,1068 kind: NumberKind,1069}10701071#[derive(Debug, Clone, Copy, PartialEq, Eq, Hash)]1072pub enum NumberKind {1073 Float,1074 ErrorFloatJunkAfterPoint,1075 ErrorFloatJunkAfterExponent,1076 ErrorFloatJunkAfterExponentSign,1077}10781079#[derive(Debug, Clone, PartialEq, Eq, Hash)]1080pub struct ImportKind {1081 syntax: SyntaxToken,1082 kind: ImportKindKind,1083}10841085#[derive(Debug, Clone, Copy, PartialEq, Eq, Hash)]1086pub enum ImportKindKind {1087 ImportstrKw,1088 ImportbinKw,1089 ImportKw,1090}10911092#[derive(Debug, Clone, PartialEq, Eq, Hash)]1093pub struct Visibility {1094 syntax: SyntaxToken,1095 kind: VisibilityKind,1096}10971098#[derive(Debug, Clone, Copy, PartialEq, Eq, Hash)]1099pub enum VisibilityKind {1100 Coloncoloncolon,1101 Coloncolon,1102 Colon,1103}11041105#[derive(Debug, Clone, PartialEq, Eq, Hash)]1106pub struct Trivia {1107 syntax: SyntaxToken,1108 kind: TriviaKind,1109}11101111#[derive(Debug, Clone, Copy, PartialEq, Eq, Hash)]1112pub enum TriviaKind {1113 Whitespace,1114 MultiLineComment,1115 ErrorCommentTooShort,1116 ErrorCommentUnterminated,1117 SingleLineHashComment,1118 SingleLineSlashComment,1119}1120impl AstNode for SourceFile {1121 fn can_cast(kind: SyntaxKind) -> bool {1122 kind == SOURCE_FILE1123 }1124 fn cast(syntax: SyntaxNode) -> Option<Self> {1125 if Self::can_cast(syntax.kind()) {1126 Some(Self { syntax })1127 } else {1128 None1129 }1130 }1131 fn syntax(&self) -> &SyntaxNode {1132 &self.syntax1133 }1134}1135impl AstNode for ExprBinary {1136 fn can_cast(kind: SyntaxKind) -> bool {1137 kind == EXPR_BINARY1138 }1139 fn cast(syntax: SyntaxNode) -> Option<Self> {1140 if Self::can_cast(syntax.kind()) {1141 Some(Self { syntax })1142 } else {1143 None1144 }1145 }1146 fn syntax(&self) -> &SyntaxNode {1147 &self.syntax1148 }1149}1150impl AstNode for LhsExpr {1151 fn can_cast(kind: SyntaxKind) -> bool {1152 kind == LHS_EXPR1153 }1154 fn cast(syntax: SyntaxNode) -> Option<Self> {1155 if Self::can_cast(syntax.kind()) {1156 Some(Self { syntax })1157 } else {1158 None1159 }1160 }1161 fn syntax(&self) -> &SyntaxNode {1162 &self.syntax1163 }1164}1165impl AstNode for ExprUnary {1166 fn can_cast(kind: SyntaxKind) -> bool {1167 kind == EXPR_UNARY1168 }1169 fn cast(syntax: SyntaxNode) -> Option<Self> {1170 if Self::can_cast(syntax.kind()) {1171 Some(Self { syntax })1172 } else {1173 None1174 }1175 }1176 fn syntax(&self) -> &SyntaxNode {1177 &self.syntax1178 }1179}1180impl AstNode for ExprSlice {1181 fn can_cast(kind: SyntaxKind) -> bool {1182 kind == EXPR_SLICE1183 }1184 fn cast(syntax: SyntaxNode) -> Option<Self> {1185 if Self::can_cast(syntax.kind()) {1186 Some(Self { syntax })1187 } else {1188 None1189 }1190 }1191 fn syntax(&self) -> &SyntaxNode {1192 &self.syntax1193 }1194}1195impl AstNode for SliceDesc {1196 fn can_cast(kind: SyntaxKind) -> bool {1197 kind == SLICE_DESC1198 }1199 fn cast(syntax: SyntaxNode) -> Option<Self> {1200 if Self::can_cast(syntax.kind()) {1201 Some(Self { syntax })1202 } else {1203 None1204 }1205 }1206 fn syntax(&self) -> &SyntaxNode {1207 &self.syntax1208 }1209}1210impl AstNode for ExprIndex {1211 fn can_cast(kind: SyntaxKind) -> bool {1212 kind == EXPR_INDEX1213 }1214 fn cast(syntax: SyntaxNode) -> Option<Self> {1215 if Self::can_cast(syntax.kind()) {1216 Some(Self { syntax })1217 } else {1218 None1219 }1220 }1221 fn syntax(&self) -> &SyntaxNode {1222 &self.syntax1223 }1224}1225impl AstNode for Name {1226 fn can_cast(kind: SyntaxKind) -> bool {1227 kind == NAME1228 }1229 fn cast(syntax: SyntaxNode) -> Option<Self> {1230 if Self::can_cast(syntax.kind()) {1231 Some(Self { syntax })1232 } else {1233 None1234 }1235 }1236 fn syntax(&self) -> &SyntaxNode {1237 &self.syntax1238 }1239}1240impl AstNode for ExprIndexExpr {1241 fn can_cast(kind: SyntaxKind) -> bool {1242 kind == EXPR_INDEX_EXPR1243 }1244 fn cast(syntax: SyntaxNode) -> Option<Self> {1245 if Self::can_cast(syntax.kind()) {1246 Some(Self { syntax })1247 } else {1248 None1249 }1250 }1251 fn syntax(&self) -> &SyntaxNode {1252 &self.syntax1253 }1254}1255impl AstNode for ExprApply {1256 fn can_cast(kind: SyntaxKind) -> bool {1257 kind == EXPR_APPLY1258 }1259 fn cast(syntax: SyntaxNode) -> Option<Self> {1260 if Self::can_cast(syntax.kind()) {1261 Some(Self { syntax })1262 } else {1263 None1264 }1265 }1266 fn syntax(&self) -> &SyntaxNode {1267 &self.syntax1268 }1269}1270impl AstNode for ArgsDesc {1271 fn can_cast(kind: SyntaxKind) -> bool {1272 kind == ARGS_DESC1273 }1274 fn cast(syntax: SyntaxNode) -> Option<Self> {1275 if Self::can_cast(syntax.kind()) {1276 Some(Self { syntax })1277 } else {1278 None1279 }1280 }1281 fn syntax(&self) -> &SyntaxNode {1282 &self.syntax1283 }1284}1285impl AstNode for ExprObjExtend {1286 fn can_cast(kind: SyntaxKind) -> bool {1287 kind == EXPR_OBJ_EXTEND1288 }1289 fn cast(syntax: SyntaxNode) -> Option<Self> {1290 if Self::can_cast(syntax.kind()) {1291 Some(Self { syntax })1292 } else {1293 None1294 }1295 }1296 fn syntax(&self) -> &SyntaxNode {1297 &self.syntax1298 }1299}1300impl AstNode for ExprParened {1301 fn can_cast(kind: SyntaxKind) -> bool {1302 kind == EXPR_PARENED1303 }1304 fn cast(syntax: SyntaxNode) -> Option<Self> {1305 if Self::can_cast(syntax.kind()) {1306 Some(Self { syntax })1307 } else {1308 None1309 }1310 }1311 fn syntax(&self) -> &SyntaxNode {1312 &self.syntax1313 }1314}1315impl AstNode for ExprLiteral {1316 fn can_cast(kind: SyntaxKind) -> bool {1317 kind == EXPR_LITERAL1318 }1319 fn cast(syntax: SyntaxNode) -> Option<Self> {1320 if Self::can_cast(syntax.kind()) {1321 Some(Self { syntax })1322 } else {1323 None1324 }1325 }1326 fn syntax(&self) -> &SyntaxNode {1327 &self.syntax1328 }1329}1330impl AstNode for ExprIntrinsicThisFile {1331 fn can_cast(kind: SyntaxKind) -> bool {1332 kind == EXPR_INTRINSIC_THIS_FILE1333 }1334 fn cast(syntax: SyntaxNode) -> Option<Self> {1335 if Self::can_cast(syntax.kind()) {1336 Some(Self { syntax })1337 } else {1338 None1339 }1340 }1341 fn syntax(&self) -> &SyntaxNode {1342 &self.syntax1343 }1344}1345impl AstNode for ExprIntrinsicId {1346 fn can_cast(kind: SyntaxKind) -> bool {1347 kind == EXPR_INTRINSIC_ID1348 }1349 fn cast(syntax: SyntaxNode) -> Option<Self> {1350 if Self::can_cast(syntax.kind()) {1351 Some(Self { syntax })1352 } else {1353 None1354 }1355 }1356 fn syntax(&self) -> &SyntaxNode {1357 &self.syntax1358 }1359}1360impl AstNode for ExprIntrinsic {1361 fn can_cast(kind: SyntaxKind) -> bool {1362 kind == EXPR_INTRINSIC1363 }1364 fn cast(syntax: SyntaxNode) -> Option<Self> {1365 if Self::can_cast(syntax.kind()) {1366 Some(Self { syntax })1367 } else {1368 None1369 }1370 }1371 fn syntax(&self) -> &SyntaxNode {1372 &self.syntax1373 }1374}1375impl AstNode for ExprString {1376 fn can_cast(kind: SyntaxKind) -> bool {1377 kind == EXPR_STRING1378 }1379 fn cast(syntax: SyntaxNode) -> Option<Self> {1380 if Self::can_cast(syntax.kind()) {1381 Some(Self { syntax })1382 } else {1383 None1384 }1385 }1386 fn syntax(&self) -> &SyntaxNode {1387 &self.syntax1388 }1389}1390impl AstNode for ExprNumber {1391 fn can_cast(kind: SyntaxKind) -> bool {1392 kind == EXPR_NUMBER1393 }1394 fn cast(syntax: SyntaxNode) -> Option<Self> {1395 if Self::can_cast(syntax.kind()) {1396 Some(Self { syntax })1397 } else {1398 None1399 }1400 }1401 fn syntax(&self) -> &SyntaxNode {1402 &self.syntax1403 }1404}1405impl AstNode for ExprArray {1406 fn can_cast(kind: SyntaxKind) -> bool {1407 kind == EXPR_ARRAY1408 }1409 fn cast(syntax: SyntaxNode) -> Option<Self> {1410 if Self::can_cast(syntax.kind()) {1411 Some(Self { syntax })1412 } else {1413 None1414 }1415 }1416 fn syntax(&self) -> &SyntaxNode {1417 &self.syntax1418 }1419}1420impl AstNode for ExprObject {1421 fn can_cast(kind: SyntaxKind) -> bool {1422 kind == EXPR_OBJECT1423 }1424 fn cast(syntax: SyntaxNode) -> Option<Self> {1425 if Self::can_cast(syntax.kind()) {1426 Some(Self { syntax })1427 } else {1428 None1429 }1430 }1431 fn syntax(&self) -> &SyntaxNode {1432 &self.syntax1433 }1434}1435impl AstNode for ExprArrayComp {1436 fn can_cast(kind: SyntaxKind) -> bool {1437 kind == EXPR_ARRAY_COMP1438 }1439 fn cast(syntax: SyntaxNode) -> Option<Self> {1440 if Self::can_cast(syntax.kind()) {1441 Some(Self { syntax })1442 } else {1443 None1444 }1445 }1446 fn syntax(&self) -> &SyntaxNode {1447 &self.syntax1448 }1449}1450impl AstNode for ExprImport {1451 fn can_cast(kind: SyntaxKind) -> bool {1452 kind == EXPR_IMPORT1453 }1454 fn cast(syntax: SyntaxNode) -> Option<Self> {1455 if Self::can_cast(syntax.kind()) {1456 Some(Self { syntax })1457 } else {1458 None1459 }1460 }1461 fn syntax(&self) -> &SyntaxNode {1462 &self.syntax1463 }1464}1465impl AstNode for ExprVar {1466 fn can_cast(kind: SyntaxKind) -> bool {1467 kind == EXPR_VAR1468 }1469 fn cast(syntax: SyntaxNode) -> Option<Self> {1470 if Self::can_cast(syntax.kind()) {1471 Some(Self { syntax })1472 } else {1473 None1474 }1475 }1476 fn syntax(&self) -> &SyntaxNode {1477 &self.syntax1478 }1479}1480impl AstNode for ExprLocal {1481 fn can_cast(kind: SyntaxKind) -> bool {1482 kind == EXPR_LOCAL1483 }1484 fn cast(syntax: SyntaxNode) -> Option<Self> {1485 if Self::can_cast(syntax.kind()) {1486 Some(Self { syntax })1487 } else {1488 None1489 }1490 }1491 fn syntax(&self) -> &SyntaxNode {1492 &self.syntax1493 }1494}1495impl AstNode for ExprIfThenElse {1496 fn can_cast(kind: SyntaxKind) -> bool {1497 kind == EXPR_IF_THEN_ELSE1498 }1499 fn cast(syntax: SyntaxNode) -> Option<Self> {1500 if Self::can_cast(syntax.kind()) {1501 Some(Self { syntax })1502 } else {1503 None1504 }1505 }1506 fn syntax(&self) -> &SyntaxNode {1507 &self.syntax1508 }1509}1510impl AstNode for TrueExpr {1511 fn can_cast(kind: SyntaxKind) -> bool {1512 kind == TRUE_EXPR1513 }1514 fn cast(syntax: SyntaxNode) -> Option<Self> {1515 if Self::can_cast(syntax.kind()) {1516 Some(Self { syntax })1517 } else {1518 None1519 }1520 }1521 fn syntax(&self) -> &SyntaxNode {1522 &self.syntax1523 }1524}1525impl AstNode for FalseExpr {1526 fn can_cast(kind: SyntaxKind) -> bool {1527 kind == FALSE_EXPR1528 }1529 fn cast(syntax: SyntaxNode) -> Option<Self> {1530 if Self::can_cast(syntax.kind()) {1531 Some(Self { syntax })1532 } else {1533 None1534 }1535 }1536 fn syntax(&self) -> &SyntaxNode {1537 &self.syntax1538 }1539}1540impl AstNode for ExprFunction {1541 fn can_cast(kind: SyntaxKind) -> bool {1542 kind == EXPR_FUNCTION1543 }1544 fn cast(syntax: SyntaxNode) -> Option<Self> {1545 if Self::can_cast(syntax.kind()) {1546 Some(Self { syntax })1547 } else {1548 None1549 }1550 }1551 fn syntax(&self) -> &SyntaxNode {1552 &self.syntax1553 }1554}1555impl AstNode for ParamsDesc {1556 fn can_cast(kind: SyntaxKind) -> bool {1557 kind == PARAMS_DESC1558 }1559 fn cast(syntax: SyntaxNode) -> Option<Self> {1560 if Self::can_cast(syntax.kind()) {1561 Some(Self { syntax })1562 } else {1563 None1564 }1565 }1566 fn syntax(&self) -> &SyntaxNode {1567 &self.syntax1568 }1569}1570impl AstNode for ExprAssert {1571 fn can_cast(kind: SyntaxKind) -> bool {1572 kind == EXPR_ASSERT1573 }1574 fn cast(syntax: SyntaxNode) -> Option<Self> {1575 if Self::can_cast(syntax.kind()) {1576 Some(Self { syntax })1577 } else {1578 None1579 }1580 }1581 fn syntax(&self) -> &SyntaxNode {1582 &self.syntax1583 }1584}1585impl AstNode for Assertion {1586 fn can_cast(kind: SyntaxKind) -> bool {1587 kind == ASSERTION1588 }1589 fn cast(syntax: SyntaxNode) -> Option<Self> {1590 if Self::can_cast(syntax.kind()) {1591 Some(Self { syntax })1592 } else {1593 None1594 }1595 }1596 fn syntax(&self) -> &SyntaxNode {1597 &self.syntax1598 }1599}1600impl AstNode for ExprError {1601 fn can_cast(kind: SyntaxKind) -> bool {1602 kind == EXPR_ERROR1603 }1604 fn cast(syntax: SyntaxNode) -> Option<Self> {1605 if Self::can_cast(syntax.kind()) {1606 Some(Self { syntax })1607 } else {1608 None1609 }1610 }1611 fn syntax(&self) -> &SyntaxNode {1612 &self.syntax1613 }1614}1615impl AstNode for SliceDescEnd {1616 fn can_cast(kind: SyntaxKind) -> bool {1617 kind == SLICE_DESC_END1618 }1619 fn cast(syntax: SyntaxNode) -> Option<Self> {1620 if Self::can_cast(syntax.kind()) {1621 Some(Self { syntax })1622 } else {1623 None1624 }1625 }1626 fn syntax(&self) -> &SyntaxNode {1627 &self.syntax1628 }1629}1630impl AstNode for SliceDescStep {1631 fn can_cast(kind: SyntaxKind) -> bool {1632 kind == SLICE_DESC_STEP1633 }1634 fn cast(syntax: SyntaxNode) -> Option<Self> {1635 if Self::can_cast(syntax.kind()) {1636 Some(Self { syntax })1637 } else {1638 None1639 }1640 }1641 fn syntax(&self) -> &SyntaxNode {1642 &self.syntax1643 }1644}1645impl AstNode for Arg {1646 fn can_cast(kind: SyntaxKind) -> bool {1647 kind == ARG1648 }1649 fn cast(syntax: SyntaxNode) -> Option<Self> {1650 if Self::can_cast(syntax.kind()) {1651 Some(Self { syntax })1652 } else {1653 None1654 }1655 }1656 fn syntax(&self) -> &SyntaxNode {1657 &self.syntax1658 }1659}1660impl AstNode for ObjBodyComp {1661 fn can_cast(kind: SyntaxKind) -> bool {1662 kind == OBJ_BODY_COMP1663 }1664 fn cast(syntax: SyntaxNode) -> Option<Self> {1665 if Self::can_cast(syntax.kind()) {1666 Some(Self { syntax })1667 } else {1668 None1669 }1670 }1671 fn syntax(&self) -> &SyntaxNode {1672 &self.syntax1673 }1674}1675impl AstNode for ObjLocalPostComma {1676 fn can_cast(kind: SyntaxKind) -> bool {1677 kind == OBJ_LOCAL_POST_COMMA1678 }1679 fn cast(syntax: SyntaxNode) -> Option<Self> {1680 if Self::can_cast(syntax.kind()) {1681 Some(Self { syntax })1682 } else {1683 None1684 }1685 }1686 fn syntax(&self) -> &SyntaxNode {1687 &self.syntax1688 }1689}1690impl AstNode for ObjLocalPreComma {1691 fn can_cast(kind: SyntaxKind) -> bool {1692 kind == OBJ_LOCAL_PRE_COMMA1693 }1694 fn cast(syntax: SyntaxNode) -> Option<Self> {1695 if Self::can_cast(syntax.kind()) {1696 Some(Self { syntax })1697 } else {1698 None1699 }1700 }1701 fn syntax(&self) -> &SyntaxNode {1702 &self.syntax1703 }1704}1705impl AstNode for ObjBodyMemberList {1706 fn can_cast(kind: SyntaxKind) -> bool {1707 kind == OBJ_BODY_MEMBER_LIST1708 }1709 fn cast(syntax: SyntaxNode) -> Option<Self> {1710 if Self::can_cast(syntax.kind()) {1711 Some(Self { syntax })1712 } else {1713 None1714 }1715 }1716 fn syntax(&self) -> &SyntaxNode {1717 &self.syntax1718 }1719}1720impl AstNode for ObjLocal {1721 fn can_cast(kind: SyntaxKind) -> bool {1722 kind == OBJ_LOCAL1723 }1724 fn cast(syntax: SyntaxNode) -> Option<Self> {1725 if Self::can_cast(syntax.kind()) {1726 Some(Self { syntax })1727 } else {1728 None1729 }1730 }1731 fn syntax(&self) -> &SyntaxNode {1732 &self.syntax1733 }1734}1735impl AstNode for MemberBindStmt {1736 fn can_cast(kind: SyntaxKind) -> bool {1737 kind == MEMBER_BIND_STMT1738 }1739 fn cast(syntax: SyntaxNode) -> Option<Self> {1740 if Self::can_cast(syntax.kind()) {1741 Some(Self { syntax })1742 } else {1743 None1744 }1745 }1746 fn syntax(&self) -> &SyntaxNode {1747 &self.syntax1748 }1749}1750impl AstNode for MemberAssertStmt {1751 fn can_cast(kind: SyntaxKind) -> bool {1752 kind == MEMBER_ASSERT_STMT1753 }1754 fn cast(syntax: SyntaxNode) -> Option<Self> {1755 if Self::can_cast(syntax.kind()) {1756 Some(Self { syntax })1757 } else {1758 None1759 }1760 }1761 fn syntax(&self) -> &SyntaxNode {1762 &self.syntax1763 }1764}1765impl AstNode for MemberField {1766 fn can_cast(kind: SyntaxKind) -> bool {1767 kind == MEMBER_FIELD1768 }1769 fn cast(syntax: SyntaxNode) -> Option<Self> {1770 if Self::can_cast(syntax.kind()) {1771 Some(Self { syntax })1772 } else {1773 None1774 }1775 }1776 fn syntax(&self) -> &SyntaxNode {1777 &self.syntax1778 }1779}1780impl AstNode for FieldNormal {1781 fn can_cast(kind: SyntaxKind) -> bool {1782 kind == FIELD_NORMAL1783 }1784 fn cast(syntax: SyntaxNode) -> Option<Self> {1785 if Self::can_cast(syntax.kind()) {1786 Some(Self { syntax })1787 } else {1788 None1789 }1790 }1791 fn syntax(&self) -> &SyntaxNode {1792 &self.syntax1793 }1794}1795impl AstNode for FieldMethod {1796 fn can_cast(kind: SyntaxKind) -> bool {1797 kind == FIELD_METHOD1798 }1799 fn cast(syntax: SyntaxNode) -> Option<Self> {1800 if Self::can_cast(syntax.kind()) {1801 Some(Self { syntax })1802 } else {1803 None1804 }1805 }1806 fn syntax(&self) -> &SyntaxNode {1807 &self.syntax1808 }1809}1810impl AstNode for FieldNameFixed {1811 fn can_cast(kind: SyntaxKind) -> bool {1812 kind == FIELD_NAME_FIXED1813 }1814 fn cast(syntax: SyntaxNode) -> Option<Self> {1815 if Self::can_cast(syntax.kind()) {1816 Some(Self { syntax })1817 } else {1818 None1819 }1820 }1821 fn syntax(&self) -> &SyntaxNode {1822 &self.syntax1823 }1824}1825impl AstNode for FieldNameDynamic {1826 fn can_cast(kind: SyntaxKind) -> bool {1827 kind == FIELD_NAME_DYNAMIC1828 }1829 fn cast(syntax: SyntaxNode) -> Option<Self> {1830 if Self::can_cast(syntax.kind()) {1831 Some(Self { syntax })1832 } else {1833 None1834 }1835 }1836 fn syntax(&self) -> &SyntaxNode {1837 &self.syntax1838 }1839}1840impl AstNode for ForSpec {1841 fn can_cast(kind: SyntaxKind) -> bool {1842 kind == FOR_SPEC1843 }1844 fn cast(syntax: SyntaxNode) -> Option<Self> {1845 if Self::can_cast(syntax.kind()) {1846 Some(Self { syntax })1847 } else {1848 None1849 }1850 }1851 fn syntax(&self) -> &SyntaxNode {1852 &self.syntax1853 }1854}1855impl AstNode for IfSpec {1856 fn can_cast(kind: SyntaxKind) -> bool {1857 kind == IF_SPEC1858 }1859 fn cast(syntax: SyntaxNode) -> Option<Self> {1860 if Self::can_cast(syntax.kind()) {1861 Some(Self { syntax })1862 } else {1863 None1864 }1865 }1866 fn syntax(&self) -> &SyntaxNode {1867 &self.syntax1868 }1869}1870impl AstNode for BindDestruct {1871 fn can_cast(kind: SyntaxKind) -> bool {1872 kind == BIND_DESTRUCT1873 }1874 fn cast(syntax: SyntaxNode) -> Option<Self> {1875 if Self::can_cast(syntax.kind()) {1876 Some(Self { syntax })1877 } else {1878 None1879 }1880 }1881 fn syntax(&self) -> &SyntaxNode {1882 &self.syntax1883 }1884}1885impl AstNode for BindFunction {1886 fn can_cast(kind: SyntaxKind) -> bool {1887 kind == BIND_FUNCTION1888 }1889 fn cast(syntax: SyntaxNode) -> Option<Self> {1890 if Self::can_cast(syntax.kind()) {1891 Some(Self { syntax })1892 } else {1893 None1894 }1895 }1896 fn syntax(&self) -> &SyntaxNode {1897 &self.syntax1898 }1899}1900impl AstNode for Param {1901 fn can_cast(kind: SyntaxKind) -> bool {1902 kind == PARAM1903 }1904 fn cast(syntax: SyntaxNode) -> Option<Self> {1905 if Self::can_cast(syntax.kind()) {1906 Some(Self { syntax })1907 } else {1908 None1909 }1910 }1911 fn syntax(&self) -> &SyntaxNode {1912 &self.syntax1913 }1914}1915impl AstNode for DestructFull {1916 fn can_cast(kind: SyntaxKind) -> bool {1917 kind == DESTRUCT_FULL1918 }1919 fn cast(syntax: SyntaxNode) -> Option<Self> {1920 if Self::can_cast(syntax.kind()) {1921 Some(Self { syntax })1922 } else {1923 None1924 }1925 }1926 fn syntax(&self) -> &SyntaxNode {1927 &self.syntax1928 }1929}1930impl AstNode for DestructSkip {1931 fn can_cast(kind: SyntaxKind) -> bool {1932 kind == DESTRUCT_SKIP1933 }1934 fn cast(syntax: SyntaxNode) -> Option<Self> {1935 if Self::can_cast(syntax.kind()) {1936 Some(Self { syntax })1937 } else {1938 None1939 }1940 }1941 fn syntax(&self) -> &SyntaxNode {1942 &self.syntax1943 }1944}1945impl AstNode for DestructArray {1946 fn can_cast(kind: SyntaxKind) -> bool {1947 kind == DESTRUCT_ARRAY1948 }1949 fn cast(syntax: SyntaxNode) -> Option<Self> {1950 if Self::can_cast(syntax.kind()) {1951 Some(Self { syntax })1952 } else {1953 None1954 }1955 }1956 fn syntax(&self) -> &SyntaxNode {1957 &self.syntax1958 }1959}1960impl AstNode for DestructObject {1961 fn can_cast(kind: SyntaxKind) -> bool {1962 kind == DESTRUCT_OBJECT1963 }1964 fn cast(syntax: SyntaxNode) -> Option<Self> {1965 if Self::can_cast(syntax.kind()) {1966 Some(Self { syntax })1967 } else {1968 None1969 }1970 }1971 fn syntax(&self) -> &SyntaxNode {1972 &self.syntax1973 }1974}1975impl AstNode for DestructObjectField {1976 fn can_cast(kind: SyntaxKind) -> bool {1977 kind == DESTRUCT_OBJECT_FIELD1978 }1979 fn cast(syntax: SyntaxNode) -> Option<Self> {1980 if Self::can_cast(syntax.kind()) {1981 Some(Self { syntax })1982 } else {1983 None1984 }1985 }1986 fn syntax(&self) -> &SyntaxNode {1987 &self.syntax1988 }1989}1990impl AstNode for DestructRest {1991 fn can_cast(kind: SyntaxKind) -> bool {1992 kind == DESTRUCT_REST1993 }1994 fn cast(syntax: SyntaxNode) -> Option<Self> {1995 if Self::can_cast(syntax.kind()) {1996 Some(Self { syntax })1997 } else {1998 None1999 }2000 }2001 fn syntax(&self) -> &SyntaxNode {2002 &self.syntax2003 }2004}2005impl AstNode for DestructArrayElement {2006 fn can_cast(kind: SyntaxKind) -> bool {2007 kind == DESTRUCT_ARRAY_ELEMENT2008 }2009 fn cast(syntax: SyntaxNode) -> Option<Self> {2010 if Self::can_cast(syntax.kind()) {2011 Some(Self { syntax })2012 } else {2013 None2014 }2015 }2016 fn syntax(&self) -> &SyntaxNode {2017 &self.syntax2018 }2019}2020impl From<ExprBinary> for Expr {2021 fn from(node: ExprBinary) -> Expr {2022 Expr::ExprBinary(node)2023 }2024}2025impl From<ExprUnary> for Expr {2026 fn from(node: ExprUnary) -> Expr {2027 Expr::ExprUnary(node)2028 }2029}2030impl From<ExprSlice> for Expr {2031 fn from(node: ExprSlice) -> Expr {2032 Expr::ExprSlice(node)2033 }2034}2035impl From<ExprIndex> for Expr {2036 fn from(node: ExprIndex) -> Expr {2037 Expr::ExprIndex(node)2038 }2039}2040impl From<ExprIndexExpr> for Expr {2041 fn from(node: ExprIndexExpr) -> Expr {2042 Expr::ExprIndexExpr(node)2043 }2044}2045impl From<ExprApply> for Expr {2046 fn from(node: ExprApply) -> Expr {2047 Expr::ExprApply(node)2048 }2049}2050impl From<ExprObjExtend> for Expr {2051 fn from(node: ExprObjExtend) -> Expr {2052 Expr::ExprObjExtend(node)2053 }2054}2055impl From<ExprParened> for Expr {2056 fn from(node: ExprParened) -> Expr {2057 Expr::ExprParened(node)2058 }2059}2060impl From<ExprIntrinsicThisFile> for Expr {2061 fn from(node: ExprIntrinsicThisFile) -> Expr {2062 Expr::ExprIntrinsicThisFile(node)2063 }2064}2065impl From<ExprIntrinsicId> for Expr {2066 fn from(node: ExprIntrinsicId) -> Expr {2067 Expr::ExprIntrinsicId(node)2068 }2069}2070impl From<ExprIntrinsic> for Expr {2071 fn from(node: ExprIntrinsic) -> Expr {2072 Expr::ExprIntrinsic(node)2073 }2074}2075impl From<ExprString> for Expr {2076 fn from(node: ExprString) -> Expr {2077 Expr::ExprString(node)2078 }2079}2080impl From<ExprNumber> for Expr {2081 fn from(node: ExprNumber) -> Expr {2082 Expr::ExprNumber(node)2083 }2084}2085impl From<ExprLiteral> for Expr {2086 fn from(node: ExprLiteral) -> Expr {2087 Expr::ExprLiteral(node)2088 }2089}2090impl From<ExprArray> for Expr {2091 fn from(node: ExprArray) -> Expr {2092 Expr::ExprArray(node)2093 }2094}2095impl From<ExprObject> for Expr {2096 fn from(node: ExprObject) -> Expr {2097 Expr::ExprObject(node)2098 }2099}2100impl From<ExprArrayComp> for Expr {2101 fn from(node: ExprArrayComp) -> Expr {2102 Expr::ExprArrayComp(node)2103 }2104}2105impl From<ExprImport> for Expr {2106 fn from(node: ExprImport) -> Expr {2107 Expr::ExprImport(node)2108 }2109}2110impl From<ExprVar> for Expr {2111 fn from(node: ExprVar) -> Expr {2112 Expr::ExprVar(node)2113 }2114}2115impl From<ExprLocal> for Expr {2116 fn from(node: ExprLocal) -> Expr {2117 Expr::ExprLocal(node)2118 }2119}2120impl From<ExprIfThenElse> for Expr {2121 fn from(node: ExprIfThenElse) -> Expr {2122 Expr::ExprIfThenElse(node)2123 }2124}2125impl From<ExprFunction> for Expr {2126 fn from(node: ExprFunction) -> Expr {2127 Expr::ExprFunction(node)2128 }2129}2130impl From<ExprAssert> for Expr {2131 fn from(node: ExprAssert) -> Expr {2132 Expr::ExprAssert(node)2133 }2134}2135impl From<ExprError> for Expr {2136 fn from(node: ExprError) -> Expr {2137 Expr::ExprError(node)2138 }2139}2140impl AstNode for Expr {2141 fn can_cast(kind: SyntaxKind) -> bool {2142 match kind {2143 EXPR_BINARY2144 | EXPR_UNARY2145 | EXPR_SLICE2146 | EXPR_INDEX2147 | EXPR_INDEX_EXPR2148 | EXPR_APPLY2149 | EXPR_OBJ_EXTEND2150 | EXPR_PARENED2151 | EXPR_INTRINSIC_THIS_FILE2152 | EXPR_INTRINSIC_ID2153 | EXPR_INTRINSIC2154 | EXPR_STRING2155 | EXPR_NUMBER2156 | EXPR_LITERAL2157 | EXPR_ARRAY2158 | EXPR_OBJECT2159 | EXPR_ARRAY_COMP2160 | EXPR_IMPORT2161 | EXPR_VAR2162 | EXPR_LOCAL2163 | EXPR_IF_THEN_ELSE2164 | EXPR_FUNCTION2165 | EXPR_ASSERT2166 | EXPR_ERROR => true,2167 _ => false,2168 }2169 }2170 fn cast(syntax: SyntaxNode) -> Option<Self> {2171 let res = match syntax.kind() {2172 EXPR_BINARY => Expr::ExprBinary(ExprBinary { syntax }),2173 EXPR_UNARY => Expr::ExprUnary(ExprUnary { syntax }),2174 EXPR_SLICE => Expr::ExprSlice(ExprSlice { syntax }),2175 EXPR_INDEX => Expr::ExprIndex(ExprIndex { syntax }),2176 EXPR_INDEX_EXPR => Expr::ExprIndexExpr(ExprIndexExpr { syntax }),2177 EXPR_APPLY => Expr::ExprApply(ExprApply { syntax }),2178 EXPR_OBJ_EXTEND => Expr::ExprObjExtend(ExprObjExtend { syntax }),2179 EXPR_PARENED => Expr::ExprParened(ExprParened { syntax }),2180 EXPR_INTRINSIC_THIS_FILE => {2181 Expr::ExprIntrinsicThisFile(ExprIntrinsicThisFile { syntax })2182 }2183 EXPR_INTRINSIC_ID => Expr::ExprIntrinsicId(ExprIntrinsicId { syntax }),2184 EXPR_INTRINSIC => Expr::ExprIntrinsic(ExprIntrinsic { syntax }),2185 EXPR_STRING => Expr::ExprString(ExprString { syntax }),2186 EXPR_NUMBER => Expr::ExprNumber(ExprNumber { syntax }),2187 EXPR_LITERAL => Expr::ExprLiteral(ExprLiteral { syntax }),2188 EXPR_ARRAY => Expr::ExprArray(ExprArray { syntax }),2189 EXPR_OBJECT => Expr::ExprObject(ExprObject { syntax }),2190 EXPR_ARRAY_COMP => Expr::ExprArrayComp(ExprArrayComp { syntax }),2191 EXPR_IMPORT => Expr::ExprImport(ExprImport { syntax }),2192 EXPR_VAR => Expr::ExprVar(ExprVar { syntax }),2193 EXPR_LOCAL => Expr::ExprLocal(ExprLocal { syntax }),2194 EXPR_IF_THEN_ELSE => Expr::ExprIfThenElse(ExprIfThenElse { syntax }),2195 EXPR_FUNCTION => Expr::ExprFunction(ExprFunction { syntax }),2196 EXPR_ASSERT => Expr::ExprAssert(ExprAssert { syntax }),2197 EXPR_ERROR => Expr::ExprError(ExprError { syntax }),2198 _ => return None,2199 };2200 Some(res)2201 }2202 fn syntax(&self) -> &SyntaxNode {2203 match self {2204 Expr::ExprBinary(it) => &it.syntax,2205 Expr::ExprUnary(it) => &it.syntax,2206 Expr::ExprSlice(it) => &it.syntax,2207 Expr::ExprIndex(it) => &it.syntax,2208 Expr::ExprIndexExpr(it) => &it.syntax,2209 Expr::ExprApply(it) => &it.syntax,2210 Expr::ExprObjExtend(it) => &it.syntax,2211 Expr::ExprParened(it) => &it.syntax,2212 Expr::ExprIntrinsicThisFile(it) => &it.syntax,2213 Expr::ExprIntrinsicId(it) => &it.syntax,2214 Expr::ExprIntrinsic(it) => &it.syntax,2215 Expr::ExprString(it) => &it.syntax,2216 Expr::ExprNumber(it) => &it.syntax,2217 Expr::ExprLiteral(it) => &it.syntax,2218 Expr::ExprArray(it) => &it.syntax,2219 Expr::ExprObject(it) => &it.syntax,2220 Expr::ExprArrayComp(it) => &it.syntax,2221 Expr::ExprImport(it) => &it.syntax,2222 Expr::ExprVar(it) => &it.syntax,2223 Expr::ExprLocal(it) => &it.syntax,2224 Expr::ExprIfThenElse(it) => &it.syntax,2225 Expr::ExprFunction(it) => &it.syntax,2226 Expr::ExprAssert(it) => &it.syntax,2227 Expr::ExprError(it) => &it.syntax,2228 }2229 }2230}2231impl From<ObjBodyComp> for ObjBody {2232 fn from(node: ObjBodyComp) -> ObjBody {2233 ObjBody::ObjBodyComp(node)2234 }2235}2236impl From<ObjBodyMemberList> for ObjBody {2237 fn from(node: ObjBodyMemberList) -> ObjBody {2238 ObjBody::ObjBodyMemberList(node)2239 }2240}2241impl AstNode for ObjBody {2242 fn can_cast(kind: SyntaxKind) -> bool {2243 match kind {2244 OBJ_BODY_COMP | OBJ_BODY_MEMBER_LIST => true,2245 _ => false,2246 }2247 }2248 fn cast(syntax: SyntaxNode) -> Option<Self> {2249 let res = match syntax.kind() {2250 OBJ_BODY_COMP => ObjBody::ObjBodyComp(ObjBodyComp { syntax }),2251 OBJ_BODY_MEMBER_LIST => ObjBody::ObjBodyMemberList(ObjBodyMemberList { syntax }),2252 _ => return None,2253 };2254 Some(res)2255 }2256 fn syntax(&self) -> &SyntaxNode {2257 match self {2258 ObjBody::ObjBodyComp(it) => &it.syntax,2259 ObjBody::ObjBodyMemberList(it) => &it.syntax,2260 }2261 }2262}2263impl From<ForSpec> for CompSpec {2264 fn from(node: ForSpec) -> CompSpec {2265 CompSpec::ForSpec(node)2266 }2267}2268impl From<IfSpec> for CompSpec {2269 fn from(node: IfSpec) -> CompSpec {2270 CompSpec::IfSpec(node)2271 }2272}2273impl AstNode for CompSpec {2274 fn can_cast(kind: SyntaxKind) -> bool {2275 match kind {2276 FOR_SPEC | IF_SPEC => true,2277 _ => false,2278 }2279 }2280 fn cast(syntax: SyntaxNode) -> Option<Self> {2281 let res = match syntax.kind() {2282 FOR_SPEC => CompSpec::ForSpec(ForSpec { syntax }),2283 IF_SPEC => CompSpec::IfSpec(IfSpec { syntax }),2284 _ => return None,2285 };2286 Some(res)2287 }2288 fn syntax(&self) -> &SyntaxNode {2289 match self {2290 CompSpec::ForSpec(it) => &it.syntax,2291 CompSpec::IfSpec(it) => &it.syntax,2292 }2293 }2294}2295impl From<BindDestruct> for Bind {2296 fn from(node: BindDestruct) -> Bind {2297 Bind::BindDestruct(node)2298 }2299}2300impl From<BindFunction> for Bind {2301 fn from(node: BindFunction) -> Bind {2302 Bind::BindFunction(node)2303 }2304}2305impl AstNode for Bind {2306 fn can_cast(kind: SyntaxKind) -> bool {2307 match kind {2308 BIND_DESTRUCT | BIND_FUNCTION => true,2309 _ => false,2310 }2311 }2312 fn cast(syntax: SyntaxNode) -> Option<Self> {2313 let res = match syntax.kind() {2314 BIND_DESTRUCT => Bind::BindDestruct(BindDestruct { syntax }),2315 BIND_FUNCTION => Bind::BindFunction(BindFunction { syntax }),2316 _ => return None,2317 };2318 Some(res)2319 }2320 fn syntax(&self) -> &SyntaxNode {2321 match self {2322 Bind::BindDestruct(it) => &it.syntax,2323 Bind::BindFunction(it) => &it.syntax,2324 }2325 }2326}2327impl From<MemberBindStmt> for Member {2328 fn from(node: MemberBindStmt) -> Member {2329 Member::MemberBindStmt(node)2330 }2331}2332impl From<MemberAssertStmt> for Member {2333 fn from(node: MemberAssertStmt) -> Member {2334 Member::MemberAssertStmt(node)2335 }2336}2337impl From<MemberField> for Member {2338 fn from(node: MemberField) -> Member {2339 Member::MemberField(node)2340 }2341}2342impl AstNode for Member {2343 fn can_cast(kind: SyntaxKind) -> bool {2344 match kind {2345 MEMBER_BIND_STMT | MEMBER_ASSERT_STMT | MEMBER_FIELD => true,2346 _ => false,2347 }2348 }2349 fn cast(syntax: SyntaxNode) -> Option<Self> {2350 let res = match syntax.kind() {2351 MEMBER_BIND_STMT => Member::MemberBindStmt(MemberBindStmt { syntax }),2352 MEMBER_ASSERT_STMT => Member::MemberAssertStmt(MemberAssertStmt { syntax }),2353 MEMBER_FIELD => Member::MemberField(MemberField { syntax }),2354 _ => return None,2355 };2356 Some(res)2357 }2358 fn syntax(&self) -> &SyntaxNode {2359 match self {2360 Member::MemberBindStmt(it) => &it.syntax,2361 Member::MemberAssertStmt(it) => &it.syntax,2362 Member::MemberField(it) => &it.syntax,2363 }2364 }2365}2366impl From<FieldNormal> for Field {2367 fn from(node: FieldNormal) -> Field {2368 Field::FieldNormal(node)2369 }2370}2371impl From<FieldMethod> for Field {2372 fn from(node: FieldMethod) -> Field {2373 Field::FieldMethod(node)2374 }2375}2376impl AstNode for Field {2377 fn can_cast(kind: SyntaxKind) -> bool {2378 match kind {2379 FIELD_NORMAL | FIELD_METHOD => true,2380 _ => false,2381 }2382 }2383 fn cast(syntax: SyntaxNode) -> Option<Self> {2384 let res = match syntax.kind() {2385 FIELD_NORMAL => Field::FieldNormal(FieldNormal { syntax }),2386 FIELD_METHOD => Field::FieldMethod(FieldMethod { syntax }),2387 _ => return None,2388 };2389 Some(res)2390 }2391 fn syntax(&self) -> &SyntaxNode {2392 match self {2393 Field::FieldNormal(it) => &it.syntax,2394 Field::FieldMethod(it) => &it.syntax,2395 }2396 }2397}2398impl From<FieldNameFixed> for FieldName {2399 fn from(node: FieldNameFixed) -> FieldName {2400 FieldName::FieldNameFixed(node)2401 }2402}2403impl From<FieldNameDynamic> for FieldName {2404 fn from(node: FieldNameDynamic) -> FieldName {2405 FieldName::FieldNameDynamic(node)2406 }2407}2408impl AstNode for FieldName {2409 fn can_cast(kind: SyntaxKind) -> bool {2410 match kind {2411 FIELD_NAME_FIXED | FIELD_NAME_DYNAMIC => true,2412 _ => false,2413 }2414 }2415 fn cast(syntax: SyntaxNode) -> Option<Self> {2416 let res = match syntax.kind() {2417 FIELD_NAME_FIXED => FieldName::FieldNameFixed(FieldNameFixed { syntax }),2418 FIELD_NAME_DYNAMIC => FieldName::FieldNameDynamic(FieldNameDynamic { syntax }),2419 _ => return None,2420 };2421 Some(res)2422 }2423 fn syntax(&self) -> &SyntaxNode {2424 match self {2425 FieldName::FieldNameFixed(it) => &it.syntax,2426 FieldName::FieldNameDynamic(it) => &it.syntax,2427 }2428 }2429}2430impl From<DestructFull> for Destruct {2431 fn from(node: DestructFull) -> Destruct {2432 Destruct::DestructFull(node)2433 }2434}2435impl From<DestructSkip> for Destruct {2436 fn from(node: DestructSkip) -> Destruct {2437 Destruct::DestructSkip(node)2438 }2439}2440impl From<DestructArray> for Destruct {2441 fn from(node: DestructArray) -> Destruct {2442 Destruct::DestructArray(node)2443 }2444}2445impl From<DestructObject> for Destruct {2446 fn from(node: DestructObject) -> Destruct {2447 Destruct::DestructObject(node)2448 }2449}2450impl AstNode for Destruct {2451 fn can_cast(kind: SyntaxKind) -> bool {2452 match kind {2453 DESTRUCT_FULL | DESTRUCT_SKIP | DESTRUCT_ARRAY | DESTRUCT_OBJECT => true,2454 _ => false,2455 }2456 }2457 fn cast(syntax: SyntaxNode) -> Option<Self> {2458 let res = match syntax.kind() {2459 DESTRUCT_FULL => Destruct::DestructFull(DestructFull { syntax }),2460 DESTRUCT_SKIP => Destruct::DestructSkip(DestructSkip { syntax }),2461 DESTRUCT_ARRAY => Destruct::DestructArray(DestructArray { syntax }),2462 DESTRUCT_OBJECT => Destruct::DestructObject(DestructObject { syntax }),2463 _ => return None,2464 };2465 Some(res)2466 }2467 fn syntax(&self) -> &SyntaxNode {2468 match self {2469 Destruct::DestructFull(it) => &it.syntax,2470 Destruct::DestructSkip(it) => &it.syntax,2471 Destruct::DestructArray(it) => &it.syntax,2472 Destruct::DestructObject(it) => &it.syntax,2473 }2474 }2475}2476impl From<DestructArrayElement> for DestructArrayPart {2477 fn from(node: DestructArrayElement) -> DestructArrayPart {2478 DestructArrayPart::DestructArrayElement(node)2479 }2480}2481impl From<DestructRest> for DestructArrayPart {2482 fn from(node: DestructRest) -> DestructArrayPart {2483 DestructArrayPart::DestructRest(node)2484 }2485}2486impl AstNode for DestructArrayPart {2487 fn can_cast(kind: SyntaxKind) -> bool {2488 match kind {2489 DESTRUCT_ARRAY_ELEMENT | DESTRUCT_REST => true,2490 _ => false,2491 }2492 }2493 fn cast(syntax: SyntaxNode) -> Option<Self> {2494 let res = match syntax.kind() {2495 DESTRUCT_ARRAY_ELEMENT => {2496 DestructArrayPart::DestructArrayElement(DestructArrayElement { syntax })2497 }2498 DESTRUCT_REST => DestructArrayPart::DestructRest(DestructRest { syntax }),2499 _ => return None,2500 };2501 Some(res)2502 }2503 fn syntax(&self) -> &SyntaxNode {2504 match self {2505 DestructArrayPart::DestructArrayElement(it) => &it.syntax,2506 DestructArrayPart::DestructRest(it) => &it.syntax,2507 }2508 }2509}2510impl AstToken for BinaryOperator {2511 fn can_cast(kind: SyntaxKind) -> bool {2512 BinaryOperatorKind::can_cast(kind)2513 }2514 fn cast(syntax: SyntaxToken) -> Option<Self> {2515 let kind = BinaryOperatorKind::cast(syntax.kind())?;2516 Some(BinaryOperator { syntax, kind })2517 }2518 fn syntax(&self) -> &SyntaxToken {2519 &self.syntax2520 }2521}2522impl BinaryOperatorKind {2523 fn can_cast(kind: SyntaxKind) -> bool {2524 match kind {2525 OR | AND | BIT_OR | BIT_XOR | BIT_AND | EQ | NE | LT | GT | LE | GE | IN_KW | LHS2526 | RHS | PLUS | MINUS | MUL | DIV | MODULO | META_OBJECT_APPLY | ERROR_NO_OPERATOR => true,2527 _ => false,2528 }2529 }2530 pub fn cast(kind: SyntaxKind) -> Option<Self> {2531 let res = match kind {2532 OR => Self::Or,2533 AND => Self::And,2534 BIT_OR => Self::BitOr,2535 BIT_XOR => Self::BitXor,2536 BIT_AND => Self::BitAnd,2537 EQ => Self::Eq,2538 NE => Self::Ne,2539 LT => Self::Lt,2540 GT => Self::Gt,2541 LE => Self::Le,2542 GE => Self::Ge,2543 IN_KW => Self::InKw,2544 LHS => Self::Lhs,2545 RHS => Self::Rhs,2546 PLUS => Self::Plus,2547 MINUS => Self::Minus,2548 MUL => Self::Mul,2549 DIV => Self::Div,2550 MODULO => Self::Modulo,2551 META_OBJECT_APPLY => Self::MetaObjectApply,2552 ERROR_NO_OPERATOR => Self::ErrorNoOperator,2553 _ => return None,2554 };2555 Some(res)2556 }2557}2558impl BinaryOperator {2559 pub fn kind(&self) -> BinaryOperatorKind {2560 self.kind2561 }2562}2563impl std::fmt::Display for BinaryOperator {2564 fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result {2565 std::fmt::Display::fmt(self.syntax(), f)2566 }2567}2568impl AstToken for UnaryOperator {2569 fn can_cast(kind: SyntaxKind) -> bool {2570 UnaryOperatorKind::can_cast(kind)2571 }2572 fn cast(syntax: SyntaxToken) -> Option<Self> {2573 let kind = UnaryOperatorKind::cast(syntax.kind())?;2574 Some(UnaryOperator { syntax, kind })2575 }2576 fn syntax(&self) -> &SyntaxToken {2577 &self.syntax2578 }2579}2580impl UnaryOperatorKind {2581 fn can_cast(kind: SyntaxKind) -> bool {2582 match kind {2583 MINUS | NOT | BIT_NOT => true,2584 _ => false,2585 }2586 }2587 pub fn cast(kind: SyntaxKind) -> Option<Self> {2588 let res = match kind {2589 MINUS => Self::Minus,2590 NOT => Self::Not,2591 BIT_NOT => Self::BitNot,2592 _ => return None,2593 };2594 Some(res)2595 }2596}2597impl UnaryOperator {2598 pub fn kind(&self) -> UnaryOperatorKind {2599 self.kind2600 }2601}2602impl std::fmt::Display for UnaryOperator {2603 fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result {2604 std::fmt::Display::fmt(self.syntax(), f)2605 }2606}2607impl AstToken for Literal {2608 fn can_cast(kind: SyntaxKind) -> bool {2609 LiteralKind::can_cast(kind)2610 }2611 fn cast(syntax: SyntaxToken) -> Option<Self> {2612 let kind = LiteralKind::cast(syntax.kind())?;2613 Some(Literal { syntax, kind })2614 }2615 fn syntax(&self) -> &SyntaxToken {2616 &self.syntax2617 }2618}2619impl LiteralKind {2620 fn can_cast(kind: SyntaxKind) -> bool {2621 match kind {2622 NULL_KW | TRUE_KW | FALSE_KW | SELF_KW | DOLLAR | SUPER_KW => true,2623 _ => false,2624 }2625 }2626 pub fn cast(kind: SyntaxKind) -> Option<Self> {2627 let res = match kind {2628 NULL_KW => Self::NullKw,2629 TRUE_KW => Self::TrueKw,2630 FALSE_KW => Self::FalseKw,2631 SELF_KW => Self::SelfKw,2632 DOLLAR => Self::Dollar,2633 SUPER_KW => Self::SuperKw,2634 _ => return None,2635 };2636 Some(res)2637 }2638}2639impl Literal {2640 pub fn kind(&self) -> LiteralKind {2641 self.kind2642 }2643}2644impl std::fmt::Display for Literal {2645 fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result {2646 std::fmt::Display::fmt(self.syntax(), f)2647 }2648}2649impl AstToken for Text {2650 fn can_cast(kind: SyntaxKind) -> bool {2651 TextKind::can_cast(kind)2652 }2653 fn cast(syntax: SyntaxToken) -> Option<Self> {2654 let kind = TextKind::cast(syntax.kind())?;2655 Some(Text { syntax, kind })2656 }2657 fn syntax(&self) -> &SyntaxToken {2658 &self.syntax2659 }2660}2661impl TextKind {2662 fn can_cast(kind: SyntaxKind) -> bool {2663 match kind {2664 STRING_DOUBLE2665 | ERROR_STRING_DOUBLE_UNTERMINATED2666 | STRING_SINGLE2667 | ERROR_STRING_SINGLE_UNTERMINATED2668 | STRING_DOUBLE_VERBATIM2669 | ERROR_STRING_DOUBLE_VERBATIM_UNTERMINATED2670 | STRING_SINGLE_VERBATIM2671 | ERROR_STRING_SINGLE_VERBATIM_UNTERMINATED2672 | ERROR_STRING_VERBATIM_MISSING_QUOTES2673 | STRING_BLOCK2674 | ERROR_STRING_BLOCK_UNEXPECTED_END2675 | ERROR_STRING_BLOCK_MISSING_NEW_LINE2676 | ERROR_STRING_BLOCK_MISSING_TERMINATION2677 | ERROR_STRING_BLOCK_MISSING_INDENT => true,2678 _ => false,2679 }2680 }2681 pub fn cast(kind: SyntaxKind) -> Option<Self> {2682 let res = match kind {2683 STRING_DOUBLE => Self::StringDouble,2684 ERROR_STRING_DOUBLE_UNTERMINATED => Self::ErrorStringDoubleUnterminated,2685 STRING_SINGLE => Self::StringSingle,2686 ERROR_STRING_SINGLE_UNTERMINATED => Self::ErrorStringSingleUnterminated,2687 STRING_DOUBLE_VERBATIM => Self::StringDoubleVerbatim,2688 ERROR_STRING_DOUBLE_VERBATIM_UNTERMINATED => {2689 Self::ErrorStringDoubleVerbatimUnterminated2690 }2691 STRING_SINGLE_VERBATIM => Self::StringSingleVerbatim,2692 ERROR_STRING_SINGLE_VERBATIM_UNTERMINATED => {2693 Self::ErrorStringSingleVerbatimUnterminated2694 }2695 ERROR_STRING_VERBATIM_MISSING_QUOTES => Self::ErrorStringVerbatimMissingQuotes,2696 STRING_BLOCK => Self::StringBlock,2697 ERROR_STRING_BLOCK_UNEXPECTED_END => Self::ErrorStringBlockUnexpectedEnd,2698 ERROR_STRING_BLOCK_MISSING_NEW_LINE => Self::ErrorStringBlockMissingNewLine,2699 ERROR_STRING_BLOCK_MISSING_TERMINATION => Self::ErrorStringBlockMissingTermination,2700 ERROR_STRING_BLOCK_MISSING_INDENT => Self::ErrorStringBlockMissingIndent,2701 _ => return None,2702 };2703 Some(res)2704 }2705}2706impl Text {2707 pub fn kind(&self) -> TextKind {2708 self.kind2709 }2710}2711impl std::fmt::Display for Text {2712 fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result {2713 std::fmt::Display::fmt(self.syntax(), f)2714 }2715}2716impl AstToken for Number {2717 fn can_cast(kind: SyntaxKind) -> bool {2718 NumberKind::can_cast(kind)2719 }2720 fn cast(syntax: SyntaxToken) -> Option<Self> {2721 let kind = NumberKind::cast(syntax.kind())?;2722 Some(Number { syntax, kind })2723 }2724 fn syntax(&self) -> &SyntaxToken {2725 &self.syntax2726 }2727}2728impl NumberKind {2729 fn can_cast(kind: SyntaxKind) -> bool {2730 match kind {2731 FLOAT2732 | ERROR_FLOAT_JUNK_AFTER_POINT2733 | ERROR_FLOAT_JUNK_AFTER_EXPONENT2734 | ERROR_FLOAT_JUNK_AFTER_EXPONENT_SIGN => true,2735 _ => false,2736 }2737 }2738 pub fn cast(kind: SyntaxKind) -> Option<Self> {2739 let res = match kind {2740 FLOAT => Self::Float,2741 ERROR_FLOAT_JUNK_AFTER_POINT => Self::ErrorFloatJunkAfterPoint,2742 ERROR_FLOAT_JUNK_AFTER_EXPONENT => Self::ErrorFloatJunkAfterExponent,2743 ERROR_FLOAT_JUNK_AFTER_EXPONENT_SIGN => Self::ErrorFloatJunkAfterExponentSign,2744 _ => return None,2745 };2746 Some(res)2747 }2748}2749impl Number {2750 pub fn kind(&self) -> NumberKind {2751 self.kind2752 }2753}2754impl std::fmt::Display for Number {2755 fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result {2756 std::fmt::Display::fmt(self.syntax(), f)2757 }2758}2759impl AstToken for ImportKind {2760 fn can_cast(kind: SyntaxKind) -> bool {2761 ImportKindKind::can_cast(kind)2762 }2763 fn cast(syntax: SyntaxToken) -> Option<Self> {2764 let kind = ImportKindKind::cast(syntax.kind())?;2765 Some(ImportKind { syntax, kind })2766 }2767 fn syntax(&self) -> &SyntaxToken {2768 &self.syntax2769 }2770}2771impl ImportKindKind {2772 fn can_cast(kind: SyntaxKind) -> bool {2773 match kind {2774 IMPORTSTR_KW | IMPORTBIN_KW | IMPORT_KW => true,2775 _ => false,2776 }2777 }2778 pub fn cast(kind: SyntaxKind) -> Option<Self> {2779 let res = match kind {2780 IMPORTSTR_KW => Self::ImportstrKw,2781 IMPORTBIN_KW => Self::ImportbinKw,2782 IMPORT_KW => Self::ImportKw,2783 _ => return None,2784 };2785 Some(res)2786 }2787}2788impl ImportKind {2789 pub fn kind(&self) -> ImportKindKind {2790 self.kind2791 }2792}2793impl std::fmt::Display for ImportKind {2794 fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result {2795 std::fmt::Display::fmt(self.syntax(), f)2796 }2797}2798impl AstToken for Visibility {2799 fn can_cast(kind: SyntaxKind) -> bool {2800 VisibilityKind::can_cast(kind)2801 }2802 fn cast(syntax: SyntaxToken) -> Option<Self> {2803 let kind = VisibilityKind::cast(syntax.kind())?;2804 Some(Visibility { syntax, kind })2805 }2806 fn syntax(&self) -> &SyntaxToken {2807 &self.syntax2808 }2809}2810impl VisibilityKind {2811 fn can_cast(kind: SyntaxKind) -> bool {2812 match kind {2813 COLONCOLONCOLON | COLONCOLON | COLON => true,2814 _ => false,2815 }2816 }2817 pub fn cast(kind: SyntaxKind) -> Option<Self> {2818 let res = match kind {2819 COLONCOLONCOLON => Self::Coloncoloncolon,2820 COLONCOLON => Self::Coloncolon,2821 COLON => Self::Colon,2822 _ => return None,2823 };2824 Some(res)2825 }2826}2827impl Visibility {2828 pub fn kind(&self) -> VisibilityKind {2829 self.kind2830 }2831}2832impl std::fmt::Display for Visibility {2833 fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result {2834 std::fmt::Display::fmt(self.syntax(), f)2835 }2836}2837impl AstToken for Trivia {2838 fn can_cast(kind: SyntaxKind) -> bool {2839 TriviaKind::can_cast(kind)2840 }2841 fn cast(syntax: SyntaxToken) -> Option<Self> {2842 let kind = TriviaKind::cast(syntax.kind())?;2843 Some(Trivia { syntax, kind })2844 }2845 fn syntax(&self) -> &SyntaxToken {2846 &self.syntax2847 }2848}2849impl TriviaKind {2850 fn can_cast(kind: SyntaxKind) -> bool {2851 match kind {2852 WHITESPACE2853 | MULTI_LINE_COMMENT2854 | ERROR_COMMENT_TOO_SHORT2855 | ERROR_COMMENT_UNTERMINATED2856 | SINGLE_LINE_HASH_COMMENT2857 | SINGLE_LINE_SLASH_COMMENT => true,2858 _ => false,2859 }2860 }2861 pub fn cast(kind: SyntaxKind) -> Option<Self> {2862 let res = match kind {2863 WHITESPACE => Self::Whitespace,2864 MULTI_LINE_COMMENT => Self::MultiLineComment,2865 ERROR_COMMENT_TOO_SHORT => Self::ErrorCommentTooShort,2866 ERROR_COMMENT_UNTERMINATED => Self::ErrorCommentUnterminated,2867 SINGLE_LINE_HASH_COMMENT => Self::SingleLineHashComment,2868 SINGLE_LINE_SLASH_COMMENT => Self::SingleLineSlashComment,2869 _ => return None,2870 };2871 Some(res)2872 }2873}2874impl Trivia {2875 pub fn kind(&self) -> TriviaKind {2876 self.kind2877 }2878}2879impl std::fmt::Display for Trivia {2880 fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result {2881 std::fmt::Display::fmt(self.syntax(), f)2882 }2883}2884impl std::fmt::Display for Expr {2885 fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result {2886 std::fmt::Display::fmt(self.syntax(), f)2887 }2888}2889impl std::fmt::Display for ObjBody {2890 fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result {2891 std::fmt::Display::fmt(self.syntax(), f)2892 }2893}2894impl std::fmt::Display for CompSpec {2895 fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result {2896 std::fmt::Display::fmt(self.syntax(), f)2897 }2898}2899impl std::fmt::Display for Bind {2900 fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result {2901 std::fmt::Display::fmt(self.syntax(), f)2902 }2903}2904impl std::fmt::Display for Member {2905 fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result {2906 std::fmt::Display::fmt(self.syntax(), f)2907 }2908}2909impl std::fmt::Display for Field {2910 fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result {2911 std::fmt::Display::fmt(self.syntax(), f)2912 }2913}2914impl std::fmt::Display for FieldName {2915 fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result {2916 std::fmt::Display::fmt(self.syntax(), f)2917 }2918}2919impl std::fmt::Display for Destruct {2920 fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result {2921 std::fmt::Display::fmt(self.syntax(), f)2922 }2923}2924impl std::fmt::Display for DestructArrayPart {2925 fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result {2926 std::fmt::Display::fmt(self.syntax(), f)2927 }2928}2929impl std::fmt::Display for SourceFile {2930 fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result {2931 std::fmt::Display::fmt(self.syntax(), f)2932 }2933}2934impl std::fmt::Display for ExprBinary {2935 fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result {2936 std::fmt::Display::fmt(self.syntax(), f)2937 }2938}2939impl std::fmt::Display for LhsExpr {2940 fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result {2941 std::fmt::Display::fmt(self.syntax(), f)2942 }2943}2944impl std::fmt::Display for ExprUnary {2945 fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result {2946 std::fmt::Display::fmt(self.syntax(), f)2947 }2948}2949impl std::fmt::Display for ExprSlice {2950 fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result {2951 std::fmt::Display::fmt(self.syntax(), f)2952 }2953}2954impl std::fmt::Display for SliceDesc {2955 fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result {2956 std::fmt::Display::fmt(self.syntax(), f)2957 }2958}2959impl std::fmt::Display for ExprIndex {2960 fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result {2961 std::fmt::Display::fmt(self.syntax(), f)2962 }2963}2964impl std::fmt::Display for Name {2965 fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result {2966 std::fmt::Display::fmt(self.syntax(), f)2967 }2968}2969impl std::fmt::Display for ExprIndexExpr {2970 fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result {2971 std::fmt::Display::fmt(self.syntax(), f)2972 }2973}2974impl std::fmt::Display for ExprApply {2975 fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result {2976 std::fmt::Display::fmt(self.syntax(), f)2977 }2978}2979impl std::fmt::Display for ArgsDesc {2980 fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result {2981 std::fmt::Display::fmt(self.syntax(), f)2982 }2983}2984impl std::fmt::Display for ExprObjExtend {2985 fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result {2986 std::fmt::Display::fmt(self.syntax(), f)2987 }2988}2989impl std::fmt::Display for ExprParened {2990 fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result {2991 std::fmt::Display::fmt(self.syntax(), f)2992 }2993}2994impl std::fmt::Display for ExprLiteral {2995 fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result {2996 std::fmt::Display::fmt(self.syntax(), f)2997 }2998}2999impl std::fmt::Display for ExprIntrinsicThisFile {3000 fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result {3001 std::fmt::Display::fmt(self.syntax(), f)3002 }3003}3004impl std::fmt::Display for ExprIntrinsicId {3005 fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result {3006 std::fmt::Display::fmt(self.syntax(), f)3007 }3008}3009impl std::fmt::Display for ExprIntrinsic {3010 fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result {3011 std::fmt::Display::fmt(self.syntax(), f)3012 }3013}3014impl std::fmt::Display for ExprString {3015 fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result {3016 std::fmt::Display::fmt(self.syntax(), f)3017 }3018}3019impl std::fmt::Display for ExprNumber {3020 fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result {3021 std::fmt::Display::fmt(self.syntax(), f)3022 }3023}3024impl std::fmt::Display for ExprArray {3025 fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result {3026 std::fmt::Display::fmt(self.syntax(), f)3027 }3028}3029impl std::fmt::Display for ExprObject {3030 fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result {3031 std::fmt::Display::fmt(self.syntax(), f)3032 }3033}3034impl std::fmt::Display for ExprArrayComp {3035 fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result {3036 std::fmt::Display::fmt(self.syntax(), f)3037 }3038}3039impl std::fmt::Display for ExprImport {3040 fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result {3041 std::fmt::Display::fmt(self.syntax(), f)3042 }3043}3044impl std::fmt::Display for ExprVar {3045 fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result {3046 std::fmt::Display::fmt(self.syntax(), f)3047 }3048}3049impl std::fmt::Display for ExprLocal {3050 fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result {3051 std::fmt::Display::fmt(self.syntax(), f)3052 }3053}3054impl std::fmt::Display for ExprIfThenElse {3055 fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result {3056 std::fmt::Display::fmt(self.syntax(), f)3057 }3058}3059impl std::fmt::Display for TrueExpr {3060 fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result {3061 std::fmt::Display::fmt(self.syntax(), f)3062 }3063}3064impl std::fmt::Display for FalseExpr {3065 fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result {3066 std::fmt::Display::fmt(self.syntax(), f)3067 }3068}3069impl std::fmt::Display for ExprFunction {3070 fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result {3071 std::fmt::Display::fmt(self.syntax(), f)3072 }3073}3074impl std::fmt::Display for ParamsDesc {3075 fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result {3076 std::fmt::Display::fmt(self.syntax(), f)3077 }3078}3079impl std::fmt::Display for ExprAssert {3080 fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result {3081 std::fmt::Display::fmt(self.syntax(), f)3082 }3083}3084impl std::fmt::Display for Assertion {3085 fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result {3086 std::fmt::Display::fmt(self.syntax(), f)3087 }3088}3089impl std::fmt::Display for ExprError {3090 fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result {3091 std::fmt::Display::fmt(self.syntax(), f)3092 }3093}3094impl std::fmt::Display for SliceDescEnd {3095 fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result {3096 std::fmt::Display::fmt(self.syntax(), f)3097 }3098}3099impl std::fmt::Display for SliceDescStep {3100 fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result {3101 std::fmt::Display::fmt(self.syntax(), f)3102 }3103}3104impl std::fmt::Display for Arg {3105 fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result {3106 std::fmt::Display::fmt(self.syntax(), f)3107 }3108}3109impl std::fmt::Display for ObjBodyComp {3110 fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result {3111 std::fmt::Display::fmt(self.syntax(), f)3112 }3113}3114impl std::fmt::Display for ObjLocalPostComma {3115 fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result {3116 std::fmt::Display::fmt(self.syntax(), f)3117 }3118}3119impl std::fmt::Display for ObjLocalPreComma {3120 fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result {3121 std::fmt::Display::fmt(self.syntax(), f)3122 }3123}3124impl std::fmt::Display for ObjBodyMemberList {3125 fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result {3126 std::fmt::Display::fmt(self.syntax(), f)3127 }3128}3129impl std::fmt::Display for ObjLocal {3130 fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result {3131 std::fmt::Display::fmt(self.syntax(), f)3132 }3133}3134impl std::fmt::Display for MemberBindStmt {3135 fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result {3136 std::fmt::Display::fmt(self.syntax(), f)3137 }3138}3139impl std::fmt::Display for MemberAssertStmt {3140 fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result {3141 std::fmt::Display::fmt(self.syntax(), f)3142 }3143}3144impl std::fmt::Display for MemberField {3145 fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result {3146 std::fmt::Display::fmt(self.syntax(), f)3147 }3148}3149impl std::fmt::Display for FieldNormal {3150 fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result {3151 std::fmt::Display::fmt(self.syntax(), f)3152 }3153}3154impl std::fmt::Display for FieldMethod {3155 fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result {3156 std::fmt::Display::fmt(self.syntax(), f)3157 }3158}3159impl std::fmt::Display for FieldNameFixed {3160 fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result {3161 std::fmt::Display::fmt(self.syntax(), f)3162 }3163}3164impl std::fmt::Display for FieldNameDynamic {3165 fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result {3166 std::fmt::Display::fmt(self.syntax(), f)3167 }3168}3169impl std::fmt::Display for ForSpec {3170 fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result {3171 std::fmt::Display::fmt(self.syntax(), f)3172 }3173}3174impl std::fmt::Display for IfSpec {3175 fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result {3176 std::fmt::Display::fmt(self.syntax(), f)3177 }3178}3179impl std::fmt::Display for BindDestruct {3180 fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result {3181 std::fmt::Display::fmt(self.syntax(), f)3182 }3183}3184impl std::fmt::Display for BindFunction {3185 fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result {3186 std::fmt::Display::fmt(self.syntax(), f)3187 }3188}3189impl std::fmt::Display for Param {3190 fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result {3191 std::fmt::Display::fmt(self.syntax(), f)3192 }3193}3194impl std::fmt::Display for DestructFull {3195 fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result {3196 std::fmt::Display::fmt(self.syntax(), f)3197 }3198}3199impl std::fmt::Display for DestructSkip {3200 fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result {3201 std::fmt::Display::fmt(self.syntax(), f)3202 }3203}3204impl std::fmt::Display for DestructArray {3205 fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result {3206 std::fmt::Display::fmt(self.syntax(), f)3207 }3208}3209impl std::fmt::Display for DestructObject {3210 fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result {3211 std::fmt::Display::fmt(self.syntax(), f)3212 }3213}3214impl std::fmt::Display for DestructObjectField {3215 fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result {3216 std::fmt::Display::fmt(self.syntax(), f)3217 }3218}3219impl std::fmt::Display for DestructRest {3220 fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result {3221 std::fmt::Display::fmt(self.syntax(), f)3222 }3223}3224impl std::fmt::Display for DestructArrayElement {3225 fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result {3226 std::fmt::Display::fmt(self.syntax(), f)3227 }3228}crates/jrsonnet-rowan-parser/src/generated/syntax_kinds.rsdiffbeforeafterboth--- a/crates/jrsonnet-rowan-parser/src/generated/syntax_kinds.rs
+++ b/crates/jrsonnet-rowan-parser/src/generated/syntax_kinds.rs
@@ -163,6 +163,7 @@
ERROR_KW,
#[token("in")]
IN_KW,
+ META_OBJECT_APPLY,
ERROR_NO_OPERATOR,
#[token("null")]
NULL_KW,
crates/jrsonnet-rowan-parser/src/lib.rsdiffbeforeafterboth--- a/crates/jrsonnet-rowan-parser/src/lib.rs
+++ b/crates/jrsonnet-rowan-parser/src/lib.rs
@@ -1,17 +1,16 @@
#![deny(unused_must_use)]
mod ast;
-mod binary;
mod event;
mod generated;
mod language;
mod lex;
mod marker;
mod parser;
+mod precedence;
mod string_block;
mod tests;
mod token_set;
-mod unary;
pub use ast::{AstChildren, AstNode, AstToken};
use event::Sink;
crates/jrsonnet-rowan-parser/src/parser.rsdiffbeforeafterboth--- a/crates/jrsonnet-rowan-parser/src/parser.rs
+++ b/crates/jrsonnet-rowan-parser/src/parser.rs
@@ -4,13 +4,11 @@
use rowan::{GreenNode, TextRange, TextSize};
use crate::{
- binary::BinaryOperator,
event::Event,
lex::Lexeme,
marker::{AsRange, CompletedMarker, Marker, Ranger},
- nodes::{Literal, Number, Text, Trivia},
+ nodes::{BinaryOperatorKind, Literal, Number, Text, Trivia, UnaryOperatorKind},
token_set::SyntaxKindSet,
- unary::UnaryOperator,
AstToken, SyntaxKind,
SyntaxKind::*,
SyntaxNode, T, TS,
@@ -397,18 +395,6 @@
enum ExpectedSyntaxTrackingState {
Named,
Unnamed,
-}
-macro_rules! at_match {
- ($p:ident {
- $($r:expr => $e:expr,)*
- _ => $else:expr $(,)?
- }) => {{
- $(
- if $p.at($r) {$e} else
- )* {
- $else
- }
- }}
}
fn expr(p: &mut Parser) -> Option<CompletedMarker> {
@@ -417,37 +403,16 @@
fn expr_binding_power(p: &mut Parser, minimum_binding_power: u8) -> Option<CompletedMarker> {
let mut lhs = lhs(p)?;
- loop {
- let op = at_match!(p {
- T![*] => BinaryOperator::Mul,
- T![/] => BinaryOperator::Div,
- T![%] => BinaryOperator::Mod,
- T![+] => BinaryOperator::Plus,
- T![-] => BinaryOperator::Minus,
- T![<<] => BinaryOperator::ShiftLeft,
- T![>>] => BinaryOperator::ShiftRight,
- T![<] => BinaryOperator::LessThan,
- T![>] => BinaryOperator::GreaterThan,
- T![<=] => BinaryOperator::LessThanOrEqual,
- T![>=] => BinaryOperator::GreaterThanOrEqual,
- T![==] => BinaryOperator::Equal,
- T![!=] => BinaryOperator::NotEqual,
- T![&] => BinaryOperator::BitAnd,
- T![^] => BinaryOperator::BitXor,
- T![|] => BinaryOperator::BitOr,
- T![&&] => BinaryOperator::And,
- T![||] => BinaryOperator::Or,
- T![in] => BinaryOperator::In,
- T!['{'] => BinaryOperator::ObjectApply,
- _ => break,
- });
+ while let Some(op) = BinaryOperatorKind::cast(p.current())
+ .or_else(|| p.at(T!['{']).then(|| BinaryOperatorKind::MetaObjectApply))
+ {
let (left_binding_power, right_binding_power) = op.binding_power();
if left_binding_power < minimum_binding_power {
break;
}
// Object apply is not a real operator, we dont have something to bump
- if op != BinaryOperator::ObjectApply {
+ if op != BinaryOperatorKind::MetaObjectApply {
p.bump();
}
@@ -455,7 +420,7 @@
let parsed_rhs = expr_binding_power(p, right_binding_power).is_some();
lhs = m.complete(
p,
- if op == BinaryOperator::ObjectApply {
+ if op == BinaryOperatorKind::MetaObjectApply {
EXPR_OBJ_EXTEND
} else {
EXPR_BINARY
@@ -998,13 +963,7 @@
p.bump();
text(p);
m.complete(p, EXPR_IMPORT)
- } else if p.at(T![-]) || p.at(T![!]) || p.at(T![~]) {
- let op = match p.current() {
- T![-] => UnaryOperator::Minus,
- T![!] => UnaryOperator::Not,
- T![~] => UnaryOperator::BitNegate,
- _ => unreachable!(),
- };
+ } else if let Some(op) = UnaryOperatorKind::cast(p.current()) {
let ((), right_binding_power) = op.binding_power();
let m = p.start();
crates/jrsonnet-rowan-parser/src/precedence.rsdiffbeforeafterboth--- /dev/null
+++ b/crates/jrsonnet-rowan-parser/src/precedence.rs
@@ -0,0 +1,30 @@
+use crate::nodes::{BinaryOperatorKind, UnaryOperatorKind};
+
+impl BinaryOperatorKind {
+ pub fn binding_power(&self) -> (u8, u8) {
+ match self {
+ Self::MetaObjectApply => (22, 23),
+ Self::Mul | Self::Div | Self::Modulo => (20, 21),
+ Self::Plus | Self::Minus => (18, 19),
+ Self::Lhs | Self::Rhs => (16, 17),
+ Self::Lt | Self::Gt | Self::Le | Self::Ge | Self::InKw => (14, 15),
+ Self::Eq | Self::Ne => (12, 13),
+ Self::BitAnd => (10, 11),
+ Self::BitXor => (8, 9),
+ Self::BitOr => (6, 7),
+ Self::And => (4, 5),
+ Self::Or => (2, 3),
+ Self::ErrorNoOperator => (0, 1),
+ }
+ }
+}
+
+impl UnaryOperatorKind {
+ pub fn binding_power(&self) -> ((), u8) {
+ match self {
+ Self::Minus => ((), 20),
+ Self::Not => ((), 20),
+ Self::BitNot => ((), 20),
+ }
+ }
+}
crates/jrsonnet-rowan-parser/src/unary.rsdiffbeforeafterboth--- a/crates/jrsonnet-rowan-parser/src/unary.rs
+++ /dev/null
@@ -1,15 +0,0 @@
-#[derive(Clone, Copy, Debug, PartialEq, Eq)]
-pub enum UnaryOperator {
- Minus,
- Not,
- BitNegate,
-}
-impl UnaryOperator {
- pub fn binding_power(&self) -> ((), u8) {
- match self {
- UnaryOperator::Minus => ((), 20),
- UnaryOperator::Not => ((), 20),
- UnaryOperator::BitNegate => ((), 20),
- }
- }
-}
xtask/src/sourcegen/mod.rsdiffbeforeafterboth--- a/xtask/src/sourcegen/mod.rs
+++ b/xtask/src/sourcegen/mod.rs
@@ -353,22 +353,30 @@
let ast_node = quote! {
impl AstToken for #name {
fn can_cast(kind: SyntaxKind) -> bool {
+ #kind_name::can_cast(kind)
+ }
+ fn cast(syntax: SyntaxToken) -> Option<Self> {
+ let kind = #kind_name::cast(syntax.kind())?;
+ Some(#name { syntax, kind })
+ }
+ fn syntax(&self) -> &SyntaxToken {
+ &self.syntax
+ }
+ }
+
+ impl #kind_name {
+ fn can_cast(kind: SyntaxKind) -> bool {
match kind {
#(#kinds)|* => true,
_ => false,
}
}
- fn cast(syntax: SyntaxToken) -> Option<Self> {
- let res = match syntax.kind() {
- #(
- #kinds => #name { syntax, kind: #kind_name::#variants },
- )*
+ pub fn cast(kind: SyntaxKind) -> Option<Self> {
+ let res = match kind {
+ #(#kinds => Self::#variants,)*
_ => return None,
};
Some(res)
- }
- fn syntax(&self) -> &SyntaxToken {
- &self.syntax
}
}
};