git.delta.rocks / jrsonnet / refs/commits / c678cf8e698f

difftreelog

refactor introduce ungrammar

Yaroslav Bolyukin2022-06-17parent: #5382799.patch.diff
in: master

23 files changed

added.cargo/configdiffbeforeafterboth
--- /dev/null
+++ b/.cargo/config
@@ -0,0 +1,2 @@
+[alias]
+xtask = "run --manifest-path ./xtask/Cargo.toml --"
modifiedCargo.tomldiffbeforeafterboth
--- a/Cargo.toml
+++ b/Cargo.toml
@@ -1,7 +1,7 @@
 [workspace]
 package.version = "0.5.0-pre95"
 package.repository = "https://github.com/CertainLach/jrsonnet"
-members = ["crates/*", "bindings/jsonnet", "cmds/*", "tests"]
+members = ["crates/*", "bindings/jsonnet", "cmds/*", "tests", "xtask"]
 default-members = ["cmds/jrsonnet"]
 resolver = "2"
 
modifiedcrates/jrsonnet-rowan-parser/Cargo.tomldiffbeforeafterboth
--- a/crates/jrsonnet-rowan-parser/Cargo.toml
+++ b/crates/jrsonnet-rowan-parser/Cargo.toml
@@ -18,3 +18,4 @@
 backtrace = "0.3.63"
 indoc = "1.0.3"
 insta = "1.10.0"
+anyhow = "1.0.57"
addedcrates/jrsonnet-rowan-parser/jsonnet.ungramdiffbeforeafterboth
--- /dev/null
+++ b/crates/jrsonnet-rowan-parser/jsonnet.ungram
@@ -0,0 +1,334 @@
+SourceFile = Expr
+
+ExprBinary =
+    lhs:Expr
+    BinaryOperator
+    rhs:Expr
+ExprUnary =
+    UnaryOperator
+    rhs:Expr
+ExprSlice =
+    Expr
+    '['
+    SliceDesc
+    ']'
+ExprIndex =
+    Expr
+    '.'
+    index:Name
+ExprIndexExpr =
+    base:Expr
+    '['
+    index:Expr
+    ']'
+ExprApply =
+    Expr
+    '('
+    ArgsDesc
+    ')'
+    'tailstrict'?
+ExprObjExtend =
+    Expr
+    '{'
+    ObjBody
+    '}'
+ExprParened =
+    '('
+    Expr
+    ')'
+
+ExprLiteral =
+    Literal
+ExprIntrinsicThisFile =
+    '$intrinsicThisFile'
+ExprIntrinsicId =
+    '$intrinsicId'
+ExprIntrinsic =
+    '$intrinsic'
+    '('
+    name:Name
+    ')'
+ExprString =
+    String
+ExprNumber =
+    Number
+ExprArray =
+    '['
+    (Expr (',' Expr)* ','?)?
+    ']'
+ExprObject =
+    '{'
+    ObjBody
+    '}'
+ExprArrayComp =
+    '['
+    Expr
+    ','?
+    ForSpec
+    CompSpec*
+    ']'
+ExprImport =
+    'importstr' String
+|   'importbin' String
+|   'import' String
+
+ExprVar =
+    name:Name
+ExprLocal =
+    'local'
+    (Bind (',' Bind)* ','?)
+    ';'
+ExprIfThenElse =
+    'if'
+    cond:Expr
+    'then'
+    then:Expr
+    ('else' else_:Expr)?
+ExprFunction =
+    'function'
+    '('
+    ParamsDesc
+    ')'
+    Expr
+ExprAssert =
+    Assertion
+    ';'
+    Expr
+ExprError =
+    'error'
+    Expr
+
+Expr =
+    ExprBinary
+|   ExprUnary
+|   ExprSlice
+|   ExprIndex
+|   ExprIndexExpr
+|   ExprApply
+|   ExprObjExtend
+|   ExprParened
+|   ExprIntrinsicThisFile
+|   ExprIntrinsicId
+|   ExprIntrinsic
+|   ExprString
+|   ExprNumber
+|   ExprArray
+|   ExprObject
+|   ExprArrayComp
+|   ExprImport
+|   ExprVar
+|   ExprLocal
+|   ExprIfThenElse
+|   ExprFunction
+|   ExprAssert
+|   ExprError
+
+BinaryOperator =
+    '||' | '&&'
+|   '|' | '^' | '&'
+|   '==' | '!=' | '<' | '>' | '<=' | '>=' | 'in'
+|   '<<' | '>>'
+|   '+' | '-'
+|   '*' | '/' | '%'
+
+UnaryOperator =
+    '-' | '!' | '~'
+
+SliceDesc =
+    from:Expr?
+    ':'
+    (
+        end:Expr?
+        (
+            ':'
+            step:Expr?
+        )?
+    )?
+
+Name =
+    'ident'
+
+ArgsDesc =
+    (Arg (',' Arg)* ','?)?
+Arg =
+    (name:Name '=')? Expr
+
+ObjBodyComp =
+    pre:ObjLocalPostComma*
+    '['
+    key:Expr
+    ']'
+    '+'?
+    ':'
+    value:Expr
+    post:ObjLocalPreComma*
+    ForSpec
+    CompSpec*
+ObjBodyMemberList =
+    (Member (',' Member) ','?)?
+ObjBody =
+    ObjBodyComp
+|   ObjBodyMemberList
+
+ObjLocalPostComma =
+    ObjLocal
+    ','
+ObjLocalPreComma =
+    ','
+    ObjLocal
+
+MemberBindStmt = ObjLocal
+MemberAssertStmt = Assertion
+MemberField = Field
+Member =
+    MemberBindStmt
+|   MemberAssertStmt
+|   MemberField
+
+ObjLocal =
+    'local'
+    Bind
+
+FieldNormal =
+    FieldName
+    '+'?
+    Visibility
+    Expr
+FieldMethod =
+    FieldName
+    '('
+    ParamsDesc
+    ')'
+    Visibility
+    Expr
+Field =
+    FieldNormal
+|   FieldMethod
+
+FieldNameFixed =
+    id:Name
+|   String
+FieldNameDynamic =
+    '['
+    Expr
+    ']'
+FieldName =
+    FieldNameFixed
+|   FieldNameDynamic
+
+Visibility =
+    ':::'
+|   '::'
+|   ':'
+
+Literal =
+    'null'
+|   'true'
+|   'false'
+|   'self'
+|   '$'
+|   'super'
+
+String =
+    'string_double'
+|   'string_single'
+|   'string_double_verbatim'
+|   'string_single_verbatim'
+|   'string_block'
+
+Number =
+    'number'
+
+ForSpec =
+    'for'
+    bind:Name
+    'in'
+    Expr
+IfSpec =
+    'if'
+    Expr
+CompSpec =
+    ForSpec
+|   IfSpec
+
+BindDestruct =
+    into:Destruct
+    '='
+    value:Expr
+BindFunction =
+    name:Name
+    '('
+    params:ParamsDesc
+    ')'
+    '='
+    value:Expr
+Bind =
+    BindDestruct
+|   BindFunction
+
+ParamsDesc =
+    (Param (',' Param)* ','?)?
+Param =
+    Destruct
+    (
+        '='
+        Expr
+    )?
+
+Assertion =
+    'assert'
+    condition:Expr
+    (
+        ':'
+        Expr
+    )?
+
+DestructFull =
+    into:Name
+DestructSkip =
+    '?'
+DestructArray =
+    '['
+    start:(
+        Destruct
+        (',' Destruct)*
+        ','?
+    )?
+    DestructRest?
+    ','?
+    end:(
+        Destruct
+        (',' Destruct)*
+        ','?
+    )
+    ']'
+DestructObject =
+    '{'
+    (
+        DestructObjectField
+        (',' DestructObjectField)*
+        ','?
+    )?
+    DestructRest?
+    ','?
+    '}'
+Destruct =
+    DestructFull
+    DestructSkip
+    DestructArray
+    DestructObject
+
+DestructRest =
+    '...'
+    into:Name?
+
+DestructObjectField =
+    field:Name
+    (
+        ':'
+        Destruct
+    )?
+    (
+        '='
+        Expr
+    )?
addedcrates/jrsonnet-rowan-parser/src/ast.rsdiffbeforeafterboth
--- /dev/null
+++ b/crates/jrsonnet-rowan-parser/src/ast.rs
@@ -0,0 +1 @@
+pub trait AstToken {}
modifiedcrates/jrsonnet-rowan-parser/src/event.rsdiffbeforeafterboth
--- a/crates/jrsonnet-rowan-parser/src/event.rs
+++ b/crates/jrsonnet-rowan-parser/src/event.rs
@@ -3,8 +3,9 @@
 use rowan::{GreenNode, GreenNodeBuilder, Language};
 
 use crate::{
-	lex::{Lang, Lexeme, SyntaxKind},
+	lex::Lexeme,
 	parser::{Parse, SyntaxError},
+	JsonnetLanguage, SyntaxKind,
 };
 
 #[derive(Clone, Debug, PartialEq, Eq)]
@@ -69,7 +70,7 @@
 					}
 
 					for kind in kinds.into_iter().rev() {
-						self.builder.start_node(Lang::kind_to_raw(kind));
+						self.builder.start_node(JsonnetLanguage::kind_to_raw(kind));
 					}
 				}
 				Event::Token => self.token(),
@@ -92,7 +93,7 @@
 	fn token(&mut self) {
 		let lexeme = self.lexemes[self.offset];
 		self.builder
-			.token(Lang::kind_to_raw(lexeme.kind), lexeme.text);
+			.token(JsonnetLanguage::kind_to_raw(lexeme.kind), lexeme.text);
 		self.offset += 1;
 	}
 	fn skip_whitespace(&mut self) {
addedcrates/jrsonnet-rowan-parser/src/generated/mod.rsdiffbeforeafterboth
--- /dev/null
+++ b/crates/jrsonnet-rowan-parser/src/generated/mod.rs
@@ -0,0 +1,3 @@
+// mod tokens;
+// mod nodes;
+pub mod syntax_kinds;
addedcrates/jrsonnet-rowan-parser/src/generated/nodes.rsdiffbeforeafterboth
after · crates/jrsonnet-rowan-parser/src/generated/nodes.rs
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)]5use crate::{6	ast::{self, support, AstChildren, AstNode},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> { support::child(&self.syntax) }17}1819#[derive(Debug, Clone, PartialEq, Eq, Hash)]20pub struct ExprBinary {21	pub(crate) syntax: SyntaxNode,22}23impl ExprBinary {24	pub fn lhs(&self) -> Option<Expr> { support::child(&self.syntax) }25	pub fn binary_operator(&self) -> Option<BinaryOperator> { support::child(&self.syntax) }26	pub fn rhs(&self) -> Option<Expr> { support::child(&self.syntax) }27}2829#[derive(Debug, Clone, PartialEq, Eq, Hash)]30pub struct BinaryOperator {31	pub(crate) syntax: SyntaxNode,32}33impl BinaryOperator {34	pub fn or_token(&self) -> Option<SyntaxToken> { support::token(&self.syntax, T![||]) }35	pub fn and_token(&self) -> Option<SyntaxToken> { support::token(&self.syntax, T![&&]) }36	pub fn bit_or_token(&self) -> Option<SyntaxToken> { support::token(&self.syntax, T![|]) }37	pub fn bit_xor_token(&self) -> Option<SyntaxToken> { support::token(&self.syntax, T![^]) }38	pub fn bit_and_token(&self) -> Option<SyntaxToken> { support::token(&self.syntax, T![&]) }39	pub fn eq_token(&self) -> Option<SyntaxToken> { support::token(&self.syntax, T![==]) }40	pub fn ne_token(&self) -> Option<SyntaxToken> { support::token(&self.syntax, T![!=]) }41	pub fn lt_token(&self) -> Option<SyntaxToken> { support::token(&self.syntax, T![<]) }42	pub fn gt_token(&self) -> Option<SyntaxToken> { support::token(&self.syntax, T![>]) }43	pub fn le_token(&self) -> Option<SyntaxToken> { support::token(&self.syntax, T![<=]) }44	pub fn ge_token(&self) -> Option<SyntaxToken> { support::token(&self.syntax, T![>=]) }45	pub fn in_token(&self) -> Option<SyntaxToken> { support::token(&self.syntax, T![in]) }46	pub fn lhs_token(&self) -> Option<SyntaxToken> { support::token(&self.syntax, T![<<]) }47	pub fn rhs_token(&self) -> Option<SyntaxToken> { support::token(&self.syntax, T![>>]) }48	pub fn plus_token(&self) -> Option<SyntaxToken> { support::token(&self.syntax, T![+]) }49	pub fn minus_token(&self) -> Option<SyntaxToken> { support::token(&self.syntax, T![-]) }50	pub fn mul_token(&self) -> Option<SyntaxToken> { support::token(&self.syntax, T![*]) }51	pub fn div_token(&self) -> Option<SyntaxToken> { support::token(&self.syntax, T![/]) }52	pub fn modulo_token(&self) -> Option<SyntaxToken> { support::token(&self.syntax, T![%]) }53}5455#[derive(Debug, Clone, PartialEq, Eq, Hash)]56pub struct ExprUnary {57	pub(crate) syntax: SyntaxNode,58}59impl ExprUnary {60	pub fn unary_operator(&self) -> Option<UnaryOperator> { support::child(&self.syntax) }61	pub fn rhs(&self) -> Option<Expr> { support::child(&self.syntax) }62}6364#[derive(Debug, Clone, PartialEq, Eq, Hash)]65pub struct UnaryOperator {66	pub(crate) syntax: SyntaxNode,67}68impl UnaryOperator {69	pub fn minus_token(&self) -> Option<SyntaxToken> { support::token(&self.syntax, T![-]) }70	pub fn not_token(&self) -> Option<SyntaxToken> { support::token(&self.syntax, T![!]) }71	pub fn bit_not_token(&self) -> Option<SyntaxToken> { support::token(&self.syntax, T![~]) }72}7374#[derive(Debug, Clone, PartialEq, Eq, Hash)]75pub struct ExprSlice {76	pub(crate) syntax: SyntaxNode,77}78impl ExprSlice {79	pub fn expr(&self) -> Option<Expr> { support::child(&self.syntax) }80	pub fn l_brack_token(&self) -> Option<SyntaxToken> { support::token(&self.syntax, T!['[']) }81	pub fn slice_desc(&self) -> Option<SliceDesc> { support::child(&self.syntax) }82	pub fn r_brack_token(&self) -> Option<SyntaxToken> { support::token(&self.syntax, T![']']) }83}8485#[derive(Debug, Clone, PartialEq, Eq, Hash)]86pub struct SliceDesc {87	pub(crate) syntax: SyntaxNode,88}89impl SliceDesc {90	pub fn from(&self) -> Option<Expr> { support::child(&self.syntax) }91	pub fn colon_token(&self) -> Option<SyntaxToken> { support::token(&self.syntax, T![:]) }92	pub fn end(&self) -> Option<Expr> { support::child(&self.syntax) }93	pub fn step(&self) -> Option<Expr> { support::child(&self.syntax) }94}9596#[derive(Debug, Clone, PartialEq, Eq, Hash)]97pub struct ExprIndex {98	pub(crate) syntax: SyntaxNode,99}100impl ExprIndex {101	pub fn expr(&self) -> Option<Expr> { support::child(&self.syntax) }102	pub fn dot_token(&self) -> Option<SyntaxToken> { support::token(&self.syntax, T![.]) }103	pub fn index(&self) -> Option<Name> { support::child(&self.syntax) }104}105106#[derive(Debug, Clone, PartialEq, Eq, Hash)]107pub struct Name {108	pub(crate) syntax: SyntaxNode,109}110impl Name {111	pub fn ident_token(&self) -> Option<SyntaxToken> { support::token(&self.syntax, T![ident]) }112}113114#[derive(Debug, Clone, PartialEq, Eq, Hash)]115pub struct ExprIndexExpr {116	pub(crate) syntax: SyntaxNode,117}118impl ExprIndexExpr {119	pub fn base(&self) -> Option<Expr> { support::child(&self.syntax) }120	pub fn l_brack_token(&self) -> Option<SyntaxToken> { support::token(&self.syntax, T!['[']) }121	pub fn index(&self) -> Option<Expr> { support::child(&self.syntax) }122	pub fn r_brack_token(&self) -> Option<SyntaxToken> { support::token(&self.syntax, T![']']) }123}124125#[derive(Debug, Clone, PartialEq, Eq, Hash)]126pub struct ExprApply {127	pub(crate) syntax: SyntaxNode,128}129impl ExprApply {130	pub fn expr(&self) -> Option<Expr> { support::child(&self.syntax) }131	pub fn l_paren_token(&self) -> Option<SyntaxToken> { support::token(&self.syntax, T!['(']) }132	pub fn args_desc(&self) -> Option<ArgsDesc> { support::child(&self.syntax) }133	pub fn r_paren_token(&self) -> Option<SyntaxToken> { support::token(&self.syntax, T![')']) }134	pub fn tailstrict_token(&self) -> Option<SyntaxToken> {135		support::token(&self.syntax, T![tailstrict])136	}137}138139#[derive(Debug, Clone, PartialEq, Eq, Hash)]140pub struct ArgsDesc {141	pub(crate) syntax: SyntaxNode,142}143impl ArgsDesc {144	pub fn args(&self) -> AstChildren<Arg> { support::children(&self.syntax) }145}146147#[derive(Debug, Clone, PartialEq, Eq, Hash)]148pub struct ExprObjExtend {149	pub(crate) syntax: SyntaxNode,150}151impl ExprObjExtend {152	pub fn expr(&self) -> Option<Expr> { support::child(&self.syntax) }153	pub fn l_brace_token(&self) -> Option<SyntaxToken> { support::token(&self.syntax, T!['{']) }154	pub fn obj_body(&self) -> Option<ObjBody> { support::child(&self.syntax) }155	pub fn r_brace_token(&self) -> Option<SyntaxToken> { support::token(&self.syntax, T!['}']) }156}157158#[derive(Debug, Clone, PartialEq, Eq, Hash)]159pub struct ExprParened {160	pub(crate) syntax: SyntaxNode,161}162impl ExprParened {163	pub fn l_paren_token(&self) -> Option<SyntaxToken> { support::token(&self.syntax, T!['(']) }164	pub fn expr(&self) -> Option<Expr> { support::child(&self.syntax) }165	pub fn r_paren_token(&self) -> Option<SyntaxToken> { support::token(&self.syntax, T![')']) }166}167168#[derive(Debug, Clone, PartialEq, Eq, Hash)]169pub struct ExprLiteral {170	pub(crate) syntax: SyntaxNode,171}172impl ExprLiteral {173	pub fn literal(&self) -> Option<Literal> { support::child(&self.syntax) }174}175176#[derive(Debug, Clone, PartialEq, Eq, Hash)]177pub struct Literal {178	pub(crate) syntax: SyntaxNode,179}180impl Literal {181	pub fn null_token(&self) -> Option<SyntaxToken> { support::token(&self.syntax, T![null]) }182	pub fn true_token(&self) -> Option<SyntaxToken> { support::token(&self.syntax, T![true]) }183	pub fn false_token(&self) -> Option<SyntaxToken> { support::token(&self.syntax, T![false]) }184	pub fn self_token(&self) -> Option<SyntaxToken> { support::token(&self.syntax, T![self]) }185	pub fn dollar_token(&self) -> Option<SyntaxToken> { support::token(&self.syntax, T!['$']) }186	pub fn super_token(&self) -> Option<SyntaxToken> { support::token(&self.syntax, T![super]) }187}188189#[derive(Debug, Clone, PartialEq, Eq, Hash)]190pub struct ExprIntrinsicThisFile {191	pub(crate) syntax: SyntaxNode,192}193impl ExprIntrinsicThisFile {194	pub fn intrinsic_this_file_token(&self) -> Option<SyntaxToken> {195		support::token(&self.syntax, T!["$intrinsicThisFile"])196	}197}198199#[derive(Debug, Clone, PartialEq, Eq, Hash)]200pub struct ExprIntrinsicId {201	pub(crate) syntax: SyntaxNode,202}203impl ExprIntrinsicId {204	pub fn intrinsic_id_token(&self) -> Option<SyntaxToken> {205		support::token(&self.syntax, T!["$intrinsicId"])206	}207}208209#[derive(Debug, Clone, PartialEq, Eq, Hash)]210pub struct ExprIntrinsic {211	pub(crate) syntax: SyntaxNode,212}213impl ExprIntrinsic {214	pub fn intrinsic_token(&self) -> Option<SyntaxToken> {215		support::token(&self.syntax, T!["$intrinsic"])216	}217	pub fn l_paren_token(&self) -> Option<SyntaxToken> { support::token(&self.syntax, T!['(']) }218	pub fn name(&self) -> Option<Name> { support::child(&self.syntax) }219	pub fn r_paren_token(&self) -> Option<SyntaxToken> { support::token(&self.syntax, T![')']) }220}221222#[derive(Debug, Clone, PartialEq, Eq, Hash)]223pub struct ExprString {224	pub(crate) syntax: SyntaxNode,225}226impl ExprString {227	pub fn string(&self) -> Option<String> { support::child(&self.syntax) }228}229230#[derive(Debug, Clone, PartialEq, Eq, Hash)]231pub struct String {232	pub(crate) syntax: SyntaxNode,233}234impl String {235	pub fn string_double_token(&self) -> Option<SyntaxToken> {236		support::token(&self.syntax, T![string_double])237	}238	pub fn string_single_token(&self) -> Option<SyntaxToken> {239		support::token(&self.syntax, T![string_single])240	}241	pub fn string_double_verbatim_token(&self) -> Option<SyntaxToken> {242		support::token(&self.syntax, T![string_double_verbatim])243	}244	pub fn string_single_verbatim_token(&self) -> Option<SyntaxToken> {245		support::token(&self.syntax, T![string_single_verbatim])246	}247	pub fn string_block_token(&self) -> Option<SyntaxToken> {248		support::token(&self.syntax, T![string_block])249	}250}251252#[derive(Debug, Clone, PartialEq, Eq, Hash)]253pub struct ExprNumber {254	pub(crate) syntax: SyntaxNode,255}256impl ExprNumber {257	pub fn number(&self) -> Option<Number> { support::child(&self.syntax) }258}259260#[derive(Debug, Clone, PartialEq, Eq, Hash)]261pub struct Number {262	pub(crate) syntax: SyntaxNode,263}264impl Number {265	pub fn number_token(&self) -> Option<SyntaxToken> { support::token(&self.syntax, T![number]) }266}267268#[derive(Debug, Clone, PartialEq, Eq, Hash)]269pub struct ExprArray {270	pub(crate) syntax: SyntaxNode,271}272impl ExprArray {273	pub fn l_brack_token(&self) -> Option<SyntaxToken> { support::token(&self.syntax, T!['[']) }274	pub fn exprs(&self) -> AstChildren<Expr> { support::children(&self.syntax) }275	pub fn r_brack_token(&self) -> Option<SyntaxToken> { support::token(&self.syntax, T![']']) }276}277278#[derive(Debug, Clone, PartialEq, Eq, Hash)]279pub struct ExprObject {280	pub(crate) syntax: SyntaxNode,281}282impl ExprObject {283	pub fn l_brace_token(&self) -> Option<SyntaxToken> { support::token(&self.syntax, T!['{']) }284	pub fn obj_body(&self) -> Option<ObjBody> { support::child(&self.syntax) }285	pub fn r_brace_token(&self) -> Option<SyntaxToken> { support::token(&self.syntax, T!['}']) }286}287288#[derive(Debug, Clone, PartialEq, Eq, Hash)]289pub struct ExprArrayComp {290	pub(crate) syntax: SyntaxNode,291}292impl ExprArrayComp {293	pub fn l_brack_token(&self) -> Option<SyntaxToken> { support::token(&self.syntax, T!['[']) }294	pub fn expr(&self) -> Option<Expr> { support::child(&self.syntax) }295	pub fn comma_token(&self) -> Option<SyntaxToken> { support::token(&self.syntax, T![,]) }296	pub fn for_spec(&self) -> Option<ForSpec> { support::child(&self.syntax) }297	pub fn comp_specs(&self) -> AstChildren<CompSpec> { support::children(&self.syntax) }298	pub fn r_brack_token(&self) -> Option<SyntaxToken> { support::token(&self.syntax, T![']']) }299}300301#[derive(Debug, Clone, PartialEq, Eq, Hash)]302pub struct ForSpec {303	pub(crate) syntax: SyntaxNode,304}305impl ForSpec {306	pub fn for_token(&self) -> Option<SyntaxToken> { support::token(&self.syntax, T![for]) }307	pub fn bind(&self) -> Option<Name> { support::child(&self.syntax) }308	pub fn in_token(&self) -> Option<SyntaxToken> { support::token(&self.syntax, T![in]) }309	pub fn expr(&self) -> Option<Expr> { support::child(&self.syntax) }310}311312#[derive(Debug, Clone, PartialEq, Eq, Hash)]313pub struct ExprImport {314	pub(crate) syntax: SyntaxNode,315}316impl ExprImport {317	pub fn importstr_token(&self) -> Option<SyntaxToken> {318		support::token(&self.syntax, T![importstr])319	}320	pub fn string(&self) -> Option<String> { support::child(&self.syntax) }321	pub fn importbin_token(&self) -> Option<SyntaxToken> {322		support::token(&self.syntax, T![importbin])323	}324	pub fn import_token(&self) -> Option<SyntaxToken> { support::token(&self.syntax, T![import]) }325}326327#[derive(Debug, Clone, PartialEq, Eq, Hash)]328pub struct ExprVar {329	pub(crate) syntax: SyntaxNode,330}331impl ExprVar {332	pub fn name(&self) -> Option<Name> { support::child(&self.syntax) }333}334335#[derive(Debug, Clone, PartialEq, Eq, Hash)]336pub struct ExprLocal {337	pub(crate) syntax: SyntaxNode,338}339impl ExprLocal {340	pub fn local_token(&self) -> Option<SyntaxToken> { support::token(&self.syntax, T![local]) }341	pub fn binds(&self) -> AstChildren<Bind> { support::children(&self.syntax) }342	pub fn semi_token(&self) -> Option<SyntaxToken> { support::token(&self.syntax, T![;]) }343}344345#[derive(Debug, Clone, PartialEq, Eq, Hash)]346pub struct ExprIfThenElse {347	pub(crate) syntax: SyntaxNode,348}349impl ExprIfThenElse {350	pub fn if_token(&self) -> Option<SyntaxToken> { support::token(&self.syntax, T![if]) }351	pub fn cond(&self) -> Option<Expr> { support::child(&self.syntax) }352	pub fn then_token(&self) -> Option<SyntaxToken> { support::token(&self.syntax, T![then]) }353	pub fn then(&self) -> Option<Expr> { support::child(&self.syntax) }354	pub fn else_token(&self) -> Option<SyntaxToken> { support::token(&self.syntax, T![else]) }355	pub fn else_(&self) -> Option<Expr> { support::child(&self.syntax) }356}357358#[derive(Debug, Clone, PartialEq, Eq, Hash)]359pub struct ExprFunction {360	pub(crate) syntax: SyntaxNode,361}362impl ExprFunction {363	pub fn function_token(&self) -> Option<SyntaxToken> {364		support::token(&self.syntax, T![function])365	}366	pub fn l_paren_token(&self) -> Option<SyntaxToken> { support::token(&self.syntax, T!['(']) }367	pub fn params_desc(&self) -> Option<ParamsDesc> { support::child(&self.syntax) }368	pub fn r_paren_token(&self) -> Option<SyntaxToken> { support::token(&self.syntax, T![')']) }369	pub fn expr(&self) -> Option<Expr> { support::child(&self.syntax) }370}371372#[derive(Debug, Clone, PartialEq, Eq, Hash)]373pub struct ParamsDesc {374	pub(crate) syntax: SyntaxNode,375}376impl ParamsDesc {377	pub fn params(&self) -> AstChildren<Param> { support::children(&self.syntax) }378}379380#[derive(Debug, Clone, PartialEq, Eq, Hash)]381pub struct ExprAssert {382	pub(crate) syntax: SyntaxNode,383}384impl ExprAssert {385	pub fn assertion(&self) -> Option<Assertion> { support::child(&self.syntax) }386	pub fn semi_token(&self) -> Option<SyntaxToken> { support::token(&self.syntax, T![;]) }387	pub fn expr(&self) -> Option<Expr> { support::child(&self.syntax) }388}389390#[derive(Debug, Clone, PartialEq, Eq, Hash)]391pub struct Assertion {392	pub(crate) syntax: SyntaxNode,393}394impl Assertion {395	pub fn assert_token(&self) -> Option<SyntaxToken> { support::token(&self.syntax, T![assert]) }396	pub fn condition(&self) -> Option<Expr> { support::child(&self.syntax) }397	pub fn colon_token(&self) -> Option<SyntaxToken> { support::token(&self.syntax, T![:]) }398	pub fn expr(&self) -> Option<Expr> { support::child(&self.syntax) }399}400401#[derive(Debug, Clone, PartialEq, Eq, Hash)]402pub struct ExprError {403	pub(crate) syntax: SyntaxNode,404}405impl ExprError {406	pub fn error_token(&self) -> Option<SyntaxToken> { support::token(&self.syntax, T![error]) }407	pub fn expr(&self) -> Option<Expr> { support::child(&self.syntax) }408}409410#[derive(Debug, Clone, PartialEq, Eq, Hash)]411pub struct Arg {412	pub(crate) syntax: SyntaxNode,413}414impl Arg {415	pub fn name(&self) -> Option<Name> { support::child(&self.syntax) }416	pub fn assign_token(&self) -> Option<SyntaxToken> { support::token(&self.syntax, T![=]) }417	pub fn expr(&self) -> Option<Expr> { support::child(&self.syntax) }418}419420#[derive(Debug, Clone, PartialEq, Eq, Hash)]421pub struct ObjBodyComp {422	pub(crate) syntax: SyntaxNode,423}424impl ObjBodyComp {425	pub fn pre(&self) -> AstChildren<ObjLocalPostComma> { support::children(&self.syntax) }426	pub fn l_brack_token(&self) -> Option<SyntaxToken> { support::token(&self.syntax, T!['[']) }427	pub fn key(&self) -> Option<Expr> { support::child(&self.syntax) }428	pub fn r_brack_token(&self) -> Option<SyntaxToken> { support::token(&self.syntax, T![']']) }429	pub fn plus_token(&self) -> Option<SyntaxToken> { support::token(&self.syntax, T![+]) }430	pub fn colon_token(&self) -> Option<SyntaxToken> { support::token(&self.syntax, T![:]) }431	pub fn value(&self) -> Option<Expr> { support::child(&self.syntax) }432	pub fn post(&self) -> AstChildren<ObjLocalPreComma> { support::children(&self.syntax) }433	pub fn for_spec(&self) -> Option<ForSpec> { support::child(&self.syntax) }434	pub fn comp_specs(&self) -> AstChildren<CompSpec> { support::children(&self.syntax) }435}436437#[derive(Debug, Clone, PartialEq, Eq, Hash)]438pub struct ObjLocalPostComma {439	pub(crate) syntax: SyntaxNode,440}441impl ObjLocalPostComma {442	pub fn obj_local(&self) -> Option<ObjLocal> { support::child(&self.syntax) }443	pub fn comma_token(&self) -> Option<SyntaxToken> { support::token(&self.syntax, T![,]) }444}445446#[derive(Debug, Clone, PartialEq, Eq, Hash)]447pub struct ObjLocalPreComma {448	pub(crate) syntax: SyntaxNode,449}450impl ObjLocalPreComma {451	pub fn comma_token(&self) -> Option<SyntaxToken> { support::token(&self.syntax, T![,]) }452	pub fn obj_local(&self) -> Option<ObjLocal> { support::child(&self.syntax) }453}454455#[derive(Debug, Clone, PartialEq, Eq, Hash)]456pub struct ObjBodyMemberList {457	pub(crate) syntax: SyntaxNode,458}459impl ObjBodyMemberList {460	pub fn member(&self) -> Option<Member> { support::child(&self.syntax) }461	pub fn comma_token(&self) -> Option<SyntaxToken> { support::token(&self.syntax, T![,]) }462}463464#[derive(Debug, Clone, PartialEq, Eq, Hash)]465pub struct ObjLocal {466	pub(crate) syntax: SyntaxNode,467}468impl ObjLocal {469	pub fn local_token(&self) -> Option<SyntaxToken> { support::token(&self.syntax, T![local]) }470	pub fn bind(&self) -> Option<Bind> { support::child(&self.syntax) }471}472473#[derive(Debug, Clone, PartialEq, Eq, Hash)]474pub struct MemberBindStmt {475	pub(crate) syntax: SyntaxNode,476}477impl MemberBindStmt {478	pub fn obj_local(&self) -> Option<ObjLocal> { support::child(&self.syntax) }479}480481#[derive(Debug, Clone, PartialEq, Eq, Hash)]482pub struct MemberAssertStmt {483	pub(crate) syntax: SyntaxNode,484}485impl MemberAssertStmt {486	pub fn assertion(&self) -> Option<Assertion> { support::child(&self.syntax) }487}488489#[derive(Debug, Clone, PartialEq, Eq, Hash)]490pub struct MemberField {491	pub(crate) syntax: SyntaxNode,492}493impl MemberField {494	pub fn field(&self) -> Option<Field> { support::child(&self.syntax) }495}496497#[derive(Debug, Clone, PartialEq, Eq, Hash)]498pub struct FieldNormal {499	pub(crate) syntax: SyntaxNode,500}501impl FieldNormal {502	pub fn field_name(&self) -> Option<FieldName> { support::child(&self.syntax) }503	pub fn plus_token(&self) -> Option<SyntaxToken> { support::token(&self.syntax, T![+]) }504	pub fn visibility(&self) -> Option<Visibility> { support::child(&self.syntax) }505	pub fn expr(&self) -> Option<Expr> { support::child(&self.syntax) }506}507508#[derive(Debug, Clone, PartialEq, Eq, Hash)]509pub struct Visibility {510	pub(crate) syntax: SyntaxNode,511}512impl Visibility {513	pub fn coloncoloncolon_token(&self) -> Option<SyntaxToken> {514		support::token(&self.syntax, T![:::])515	}516	pub fn coloncolon_token(&self) -> Option<SyntaxToken> { support::token(&self.syntax, T![::]) }517	pub fn colon_token(&self) -> Option<SyntaxToken> { support::token(&self.syntax, T![:]) }518}519520#[derive(Debug, Clone, PartialEq, Eq, Hash)]521pub struct FieldMethod {522	pub(crate) syntax: SyntaxNode,523}524impl FieldMethod {525	pub fn field_name(&self) -> Option<FieldName> { support::child(&self.syntax) }526	pub fn l_paren_token(&self) -> Option<SyntaxToken> { support::token(&self.syntax, T!['(']) }527	pub fn params_desc(&self) -> Option<ParamsDesc> { support::child(&self.syntax) }528	pub fn r_paren_token(&self) -> Option<SyntaxToken> { support::token(&self.syntax, T![')']) }529	pub fn visibility(&self) -> Option<Visibility> { support::child(&self.syntax) }530	pub fn expr(&self) -> Option<Expr> { support::child(&self.syntax) }531}532533#[derive(Debug, Clone, PartialEq, Eq, Hash)]534pub struct FieldNameFixed {535	pub(crate) syntax: SyntaxNode,536}537impl FieldNameFixed {538	pub fn id(&self) -> Option<Name> { support::child(&self.syntax) }539	pub fn string(&self) -> Option<String> { support::child(&self.syntax) }540}541542#[derive(Debug, Clone, PartialEq, Eq, Hash)]543pub struct FieldNameDynamic {544	pub(crate) syntax: SyntaxNode,545}546impl FieldNameDynamic {547	pub fn l_brack_token(&self) -> Option<SyntaxToken> { support::token(&self.syntax, T!['[']) }548	pub fn expr(&self) -> Option<Expr> { support::child(&self.syntax) }549	pub fn r_brack_token(&self) -> Option<SyntaxToken> { support::token(&self.syntax, T![']']) }550}551552#[derive(Debug, Clone, PartialEq, Eq, Hash)]553pub struct IfSpec {554	pub(crate) syntax: SyntaxNode,555}556impl IfSpec {557	pub fn if_token(&self) -> Option<SyntaxToken> { support::token(&self.syntax, T![if]) }558	pub fn expr(&self) -> Option<Expr> { support::child(&self.syntax) }559}560561#[derive(Debug, Clone, PartialEq, Eq, Hash)]562pub struct BindDestruct {563	pub(crate) syntax: SyntaxNode,564}565impl BindDestruct {566	pub fn into(&self) -> Option<Destruct> { support::child(&self.syntax) }567	pub fn assign_token(&self) -> Option<SyntaxToken> { support::token(&self.syntax, T![=]) }568	pub fn value(&self) -> Option<Expr> { support::child(&self.syntax) }569}570571#[derive(Debug, Clone, PartialEq, Eq, Hash)]572pub struct Destruct {573	pub(crate) syntax: SyntaxNode,574}575impl Destruct {576	pub fn destruct_full(&self) -> Option<DestructFull> { support::child(&self.syntax) }577	pub fn destruct_skip(&self) -> Option<DestructSkip> { support::child(&self.syntax) }578	pub fn destruct_array(&self) -> Option<DestructArray> { support::child(&self.syntax) }579	pub fn destruct_object(&self) -> Option<DestructObject> { support::child(&self.syntax) }580}581582#[derive(Debug, Clone, PartialEq, Eq, Hash)]583pub struct BindFunction {584	pub(crate) syntax: SyntaxNode,585}586impl BindFunction {587	pub fn name(&self) -> Option<Name> { support::child(&self.syntax) }588	pub fn l_paren_token(&self) -> Option<SyntaxToken> { support::token(&self.syntax, T!['(']) }589	pub fn params(&self) -> Option<ParamsDesc> { support::child(&self.syntax) }590	pub fn r_paren_token(&self) -> Option<SyntaxToken> { support::token(&self.syntax, T![')']) }591	pub fn assign_token(&self) -> Option<SyntaxToken> { support::token(&self.syntax, T![=]) }592	pub fn value(&self) -> Option<Expr> { support::child(&self.syntax) }593}594595#[derive(Debug, Clone, PartialEq, Eq, Hash)]596pub struct Param {597	pub(crate) syntax: SyntaxNode,598}599impl Param {600	pub fn destruct(&self) -> Option<Destruct> { support::child(&self.syntax) }601	pub fn assign_token(&self) -> Option<SyntaxToken> { support::token(&self.syntax, T![=]) }602	pub fn expr(&self) -> Option<Expr> { support::child(&self.syntax) }603}604605#[derive(Debug, Clone, PartialEq, Eq, Hash)]606pub struct DestructFull {607	pub(crate) syntax: SyntaxNode,608}609impl DestructFull {610	pub fn into(&self) -> Option<Name> { support::child(&self.syntax) }611}612613#[derive(Debug, Clone, PartialEq, Eq, Hash)]614pub struct DestructSkip {615	pub(crate) syntax: SyntaxNode,616}617impl DestructSkip {618	pub fn question_mark_token(&self) -> Option<SyntaxToken> { support::token(&self.syntax, T![?]) }619}620621#[derive(Debug, Clone, PartialEq, Eq, Hash)]622pub struct DestructArray {623	pub(crate) syntax: SyntaxNode,624}625impl DestructArray {626	pub fn l_brack_token(&self) -> Option<SyntaxToken> { support::token(&self.syntax, T!['[']) }627	pub fn start(&self) -> AstChildren<Destruct> { support::children(&self.syntax) }628	pub fn destruct_rest(&self) -> Option<DestructRest> { support::child(&self.syntax) }629	pub fn comma_token(&self) -> Option<SyntaxToken> { support::token(&self.syntax, T![,]) }630	pub fn end(&self) -> AstChildren<Destruct> { support::children(&self.syntax) }631	pub fn r_brack_token(&self) -> Option<SyntaxToken> { support::token(&self.syntax, T![']']) }632}633634#[derive(Debug, Clone, PartialEq, Eq, Hash)]635pub struct DestructRest {636	pub(crate) syntax: SyntaxNode,637}638impl DestructRest {639	pub fn dotdotdot_token(&self) -> Option<SyntaxToken> { support::token(&self.syntax, T![...]) }640	pub fn into(&self) -> Option<Name> { support::child(&self.syntax) }641}642643#[derive(Debug, Clone, PartialEq, Eq, Hash)]644pub struct DestructObject {645	pub(crate) syntax: SyntaxNode,646}647impl DestructObject {648	pub fn l_brace_token(&self) -> Option<SyntaxToken> { support::token(&self.syntax, T!['{']) }649	pub fn destruct_object_fields(&self) -> AstChildren<DestructObjectField> {650		support::children(&self.syntax)651	}652	pub fn destruct_rest(&self) -> Option<DestructRest> { support::child(&self.syntax) }653	pub fn comma_token(&self) -> Option<SyntaxToken> { support::token(&self.syntax, T![,]) }654	pub fn r_brace_token(&self) -> Option<SyntaxToken> { support::token(&self.syntax, T!['}']) }655}656657#[derive(Debug, Clone, PartialEq, Eq, Hash)]658pub struct DestructObjectField {659	pub(crate) syntax: SyntaxNode,660}661impl DestructObjectField {662	pub fn field(&self) -> Option<Name> { support::child(&self.syntax) }663	pub fn colon_token(&self) -> Option<SyntaxToken> { support::token(&self.syntax, T![:]) }664	pub fn destruct(&self) -> Option<Destruct> { support::child(&self.syntax) }665	pub fn assign_token(&self) -> Option<SyntaxToken> { support::token(&self.syntax, T![=]) }666	pub fn expr(&self) -> Option<Expr> { support::child(&self.syntax) }667}668669#[derive(Debug, Clone, PartialEq, Eq, Hash)]670pub enum Expr {671	ExprBinary(ExprBinary),672	ExprUnary(ExprUnary),673	ExprSlice(ExprSlice),674	ExprIndex(ExprIndex),675	ExprIndexExpr(ExprIndexExpr),676	ExprApply(ExprApply),677	ExprObjExtend(ExprObjExtend),678	ExprParened(ExprParened),679	ExprIntrinsicThisFile(ExprIntrinsicThisFile),680	ExprIntrinsicId(ExprIntrinsicId),681	ExprIntrinsic(ExprIntrinsic),682	ExprString(ExprString),683	ExprNumber(ExprNumber),684	ExprArray(ExprArray),685	ExprObject(ExprObject),686	ExprArrayComp(ExprArrayComp),687	ExprImport(ExprImport),688	ExprVar(ExprVar),689	ExprLocal(ExprLocal),690	ExprIfThenElse(ExprIfThenElse),691	ExprFunction(ExprFunction),692	ExprAssert(ExprAssert),693	ExprError(ExprError),694}695696#[derive(Debug, Clone, PartialEq, Eq, Hash)]697pub enum ObjBody {698	ObjBodyComp(ObjBodyComp),699	ObjBodyMemberList(ObjBodyMemberList),700}701702#[derive(Debug, Clone, PartialEq, Eq, Hash)]703pub enum CompSpec {704	ForSpec(ForSpec),705	IfSpec(IfSpec),706}707708#[derive(Debug, Clone, PartialEq, Eq, Hash)]709pub enum Bind {710	BindDestruct(BindDestruct),711	BindFunction(BindFunction),712}713714#[derive(Debug, Clone, PartialEq, Eq, Hash)]715pub enum Member {716	MemberBindStmt(MemberBindStmt),717	MemberAssertStmt(MemberAssertStmt),718	MemberField(MemberField),719}720721#[derive(Debug, Clone, PartialEq, Eq, Hash)]722pub enum Field {723	FieldNormal(FieldNormal),724	FieldMethod(FieldMethod),725}726727#[derive(Debug, Clone, PartialEq, Eq, Hash)]728pub enum FieldName {729	FieldNameFixed(FieldNameFixed),730	FieldNameDynamic(FieldNameDynamic),731}732impl AstNode for SourceFile {733	fn can_cast(kind: SyntaxKind) -> bool { kind == SOURCE_FILE }734	fn cast(syntax: SyntaxNode) -> Option<Self> {735		if Self::can_cast(syntax.kind()) {736			Some(Self { syntax })737		} else {738			None739		}740	}741	fn syntax(&self) -> &SyntaxNode { &self.syntax }742}743impl AstNode for ExprBinary {744	fn can_cast(kind: SyntaxKind) -> bool { kind == EXPR_BINARY }745	fn cast(syntax: SyntaxNode) -> Option<Self> {746		if Self::can_cast(syntax.kind()) {747			Some(Self { syntax })748		} else {749			None750		}751	}752	fn syntax(&self) -> &SyntaxNode { &self.syntax }753}754impl AstNode for BinaryOperator {755	fn can_cast(kind: SyntaxKind) -> bool { kind == BINARY_OPERATOR }756	fn cast(syntax: SyntaxNode) -> Option<Self> {757		if Self::can_cast(syntax.kind()) {758			Some(Self { syntax })759		} else {760			None761		}762	}763	fn syntax(&self) -> &SyntaxNode { &self.syntax }764}765impl AstNode for ExprUnary {766	fn can_cast(kind: SyntaxKind) -> bool { kind == EXPR_UNARY }767	fn cast(syntax: SyntaxNode) -> Option<Self> {768		if Self::can_cast(syntax.kind()) {769			Some(Self { syntax })770		} else {771			None772		}773	}774	fn syntax(&self) -> &SyntaxNode { &self.syntax }775}776impl AstNode for UnaryOperator {777	fn can_cast(kind: SyntaxKind) -> bool { kind == UNARY_OPERATOR }778	fn cast(syntax: SyntaxNode) -> Option<Self> {779		if Self::can_cast(syntax.kind()) {780			Some(Self { syntax })781		} else {782			None783		}784	}785	fn syntax(&self) -> &SyntaxNode { &self.syntax }786}787impl AstNode for ExprSlice {788	fn can_cast(kind: SyntaxKind) -> bool { kind == EXPR_SLICE }789	fn cast(syntax: SyntaxNode) -> Option<Self> {790		if Self::can_cast(syntax.kind()) {791			Some(Self { syntax })792		} else {793			None794		}795	}796	fn syntax(&self) -> &SyntaxNode { &self.syntax }797}798impl AstNode for SliceDesc {799	fn can_cast(kind: SyntaxKind) -> bool { kind == SLICE_DESC }800	fn cast(syntax: SyntaxNode) -> Option<Self> {801		if Self::can_cast(syntax.kind()) {802			Some(Self { syntax })803		} else {804			None805		}806	}807	fn syntax(&self) -> &SyntaxNode { &self.syntax }808}809impl AstNode for ExprIndex {810	fn can_cast(kind: SyntaxKind) -> bool { kind == EXPR_INDEX }811	fn cast(syntax: SyntaxNode) -> Option<Self> {812		if Self::can_cast(syntax.kind()) {813			Some(Self { syntax })814		} else {815			None816		}817	}818	fn syntax(&self) -> &SyntaxNode { &self.syntax }819}820impl AstNode for Name {821	fn can_cast(kind: SyntaxKind) -> bool { kind == NAME }822	fn cast(syntax: SyntaxNode) -> Option<Self> {823		if Self::can_cast(syntax.kind()) {824			Some(Self { syntax })825		} else {826			None827		}828	}829	fn syntax(&self) -> &SyntaxNode { &self.syntax }830}831impl AstNode for ExprIndexExpr {832	fn can_cast(kind: SyntaxKind) -> bool { kind == EXPR_INDEX_EXPR }833	fn cast(syntax: SyntaxNode) -> Option<Self> {834		if Self::can_cast(syntax.kind()) {835			Some(Self { syntax })836		} else {837			None838		}839	}840	fn syntax(&self) -> &SyntaxNode { &self.syntax }841}842impl AstNode for ExprApply {843	fn can_cast(kind: SyntaxKind) -> bool { kind == EXPR_APPLY }844	fn cast(syntax: SyntaxNode) -> Option<Self> {845		if Self::can_cast(syntax.kind()) {846			Some(Self { syntax })847		} else {848			None849		}850	}851	fn syntax(&self) -> &SyntaxNode { &self.syntax }852}853impl AstNode for ArgsDesc {854	fn can_cast(kind: SyntaxKind) -> bool { kind == ARGS_DESC }855	fn cast(syntax: SyntaxNode) -> Option<Self> {856		if Self::can_cast(syntax.kind()) {857			Some(Self { syntax })858		} else {859			None860		}861	}862	fn syntax(&self) -> &SyntaxNode { &self.syntax }863}864impl AstNode for ExprObjExtend {865	fn can_cast(kind: SyntaxKind) -> bool { kind == EXPR_OBJ_EXTEND }866	fn cast(syntax: SyntaxNode) -> Option<Self> {867		if Self::can_cast(syntax.kind()) {868			Some(Self { syntax })869		} else {870			None871		}872	}873	fn syntax(&self) -> &SyntaxNode { &self.syntax }874}875impl AstNode for ExprParened {876	fn can_cast(kind: SyntaxKind) -> bool { kind == EXPR_PARENED }877	fn cast(syntax: SyntaxNode) -> Option<Self> {878		if Self::can_cast(syntax.kind()) {879			Some(Self { syntax })880		} else {881			None882		}883	}884	fn syntax(&self) -> &SyntaxNode { &self.syntax }885}886impl AstNode for ExprLiteral {887	fn can_cast(kind: SyntaxKind) -> bool { kind == EXPR_LITERAL }888	fn cast(syntax: SyntaxNode) -> Option<Self> {889		if Self::can_cast(syntax.kind()) {890			Some(Self { syntax })891		} else {892			None893		}894	}895	fn syntax(&self) -> &SyntaxNode { &self.syntax }896}897impl AstNode for Literal {898	fn can_cast(kind: SyntaxKind) -> bool { kind == LITERAL }899	fn cast(syntax: SyntaxNode) -> Option<Self> {900		if Self::can_cast(syntax.kind()) {901			Some(Self { syntax })902		} else {903			None904		}905	}906	fn syntax(&self) -> &SyntaxNode { &self.syntax }907}908impl AstNode for ExprIntrinsicThisFile {909	fn can_cast(kind: SyntaxKind) -> bool { kind == EXPR_INTRINSIC_THIS_FILE }910	fn cast(syntax: SyntaxNode) -> Option<Self> {911		if Self::can_cast(syntax.kind()) {912			Some(Self { syntax })913		} else {914			None915		}916	}917	fn syntax(&self) -> &SyntaxNode { &self.syntax }918}919impl AstNode for ExprIntrinsicId {920	fn can_cast(kind: SyntaxKind) -> bool { kind == EXPR_INTRINSIC_ID }921	fn cast(syntax: SyntaxNode) -> Option<Self> {922		if Self::can_cast(syntax.kind()) {923			Some(Self { syntax })924		} else {925			None926		}927	}928	fn syntax(&self) -> &SyntaxNode { &self.syntax }929}930impl AstNode for ExprIntrinsic {931	fn can_cast(kind: SyntaxKind) -> bool { kind == EXPR_INTRINSIC }932	fn cast(syntax: SyntaxNode) -> Option<Self> {933		if Self::can_cast(syntax.kind()) {934			Some(Self { syntax })935		} else {936			None937		}938	}939	fn syntax(&self) -> &SyntaxNode { &self.syntax }940}941impl AstNode for ExprString {942	fn can_cast(kind: SyntaxKind) -> bool { kind == EXPR_STRING }943	fn cast(syntax: SyntaxNode) -> Option<Self> {944		if Self::can_cast(syntax.kind()) {945			Some(Self { syntax })946		} else {947			None948		}949	}950	fn syntax(&self) -> &SyntaxNode { &self.syntax }951}952impl AstNode for String {953	fn can_cast(kind: SyntaxKind) -> bool { kind == STRING }954	fn cast(syntax: SyntaxNode) -> Option<Self> {955		if Self::can_cast(syntax.kind()) {956			Some(Self { syntax })957		} else {958			None959		}960	}961	fn syntax(&self) -> &SyntaxNode { &self.syntax }962}963impl AstNode for ExprNumber {964	fn can_cast(kind: SyntaxKind) -> bool { kind == EXPR_NUMBER }965	fn cast(syntax: SyntaxNode) -> Option<Self> {966		if Self::can_cast(syntax.kind()) {967			Some(Self { syntax })968		} else {969			None970		}971	}972	fn syntax(&self) -> &SyntaxNode { &self.syntax }973}974impl AstNode for Number {975	fn can_cast(kind: SyntaxKind) -> bool { kind == NUMBER }976	fn cast(syntax: SyntaxNode) -> Option<Self> {977		if Self::can_cast(syntax.kind()) {978			Some(Self { syntax })979		} else {980			None981		}982	}983	fn syntax(&self) -> &SyntaxNode { &self.syntax }984}985impl AstNode for ExprArray {986	fn can_cast(kind: SyntaxKind) -> bool { kind == EXPR_ARRAY }987	fn cast(syntax: SyntaxNode) -> Option<Self> {988		if Self::can_cast(syntax.kind()) {989			Some(Self { syntax })990		} else {991			None992		}993	}994	fn syntax(&self) -> &SyntaxNode { &self.syntax }995}996impl AstNode for ExprObject {997	fn can_cast(kind: SyntaxKind) -> bool { kind == EXPR_OBJECT }998	fn cast(syntax: SyntaxNode) -> Option<Self> {999		if Self::can_cast(syntax.kind()) {1000			Some(Self { syntax })1001		} else {1002			None1003		}1004	}1005	fn syntax(&self) -> &SyntaxNode { &self.syntax }1006}1007impl AstNode for ExprArrayComp {1008	fn can_cast(kind: SyntaxKind) -> bool { kind == EXPR_ARRAY_COMP }1009	fn cast(syntax: SyntaxNode) -> Option<Self> {1010		if Self::can_cast(syntax.kind()) {1011			Some(Self { syntax })1012		} else {1013			None1014		}1015	}1016	fn syntax(&self) -> &SyntaxNode { &self.syntax }1017}1018impl AstNode for ForSpec {1019	fn can_cast(kind: SyntaxKind) -> bool { kind == FOR_SPEC }1020	fn cast(syntax: SyntaxNode) -> Option<Self> {1021		if Self::can_cast(syntax.kind()) {1022			Some(Self { syntax })1023		} else {1024			None1025		}1026	}1027	fn syntax(&self) -> &SyntaxNode { &self.syntax }1028}1029impl AstNode for ExprImport {1030	fn can_cast(kind: SyntaxKind) -> bool { kind == EXPR_IMPORT }1031	fn cast(syntax: SyntaxNode) -> Option<Self> {1032		if Self::can_cast(syntax.kind()) {1033			Some(Self { syntax })1034		} else {1035			None1036		}1037	}1038	fn syntax(&self) -> &SyntaxNode { &self.syntax }1039}1040impl AstNode for ExprVar {1041	fn can_cast(kind: SyntaxKind) -> bool { kind == EXPR_VAR }1042	fn cast(syntax: SyntaxNode) -> Option<Self> {1043		if Self::can_cast(syntax.kind()) {1044			Some(Self { syntax })1045		} else {1046			None1047		}1048	}1049	fn syntax(&self) -> &SyntaxNode { &self.syntax }1050}1051impl AstNode for ExprLocal {1052	fn can_cast(kind: SyntaxKind) -> bool { kind == EXPR_LOCAL }1053	fn cast(syntax: SyntaxNode) -> Option<Self> {1054		if Self::can_cast(syntax.kind()) {1055			Some(Self { syntax })1056		} else {1057			None1058		}1059	}1060	fn syntax(&self) -> &SyntaxNode { &self.syntax }1061}1062impl AstNode for ExprIfThenElse {1063	fn can_cast(kind: SyntaxKind) -> bool { kind == EXPR_IF_THEN_ELSE }1064	fn cast(syntax: SyntaxNode) -> Option<Self> {1065		if Self::can_cast(syntax.kind()) {1066			Some(Self { syntax })1067		} else {1068			None1069		}1070	}1071	fn syntax(&self) -> &SyntaxNode { &self.syntax }1072}1073impl AstNode for ExprFunction {1074	fn can_cast(kind: SyntaxKind) -> bool { kind == EXPR_FUNCTION }1075	fn cast(syntax: SyntaxNode) -> Option<Self> {1076		if Self::can_cast(syntax.kind()) {1077			Some(Self { syntax })1078		} else {1079			None1080		}1081	}1082	fn syntax(&self) -> &SyntaxNode { &self.syntax }1083}1084impl AstNode for ParamsDesc {1085	fn can_cast(kind: SyntaxKind) -> bool { kind == PARAMS_DESC }1086	fn cast(syntax: SyntaxNode) -> Option<Self> {1087		if Self::can_cast(syntax.kind()) {1088			Some(Self { syntax })1089		} else {1090			None1091		}1092	}1093	fn syntax(&self) -> &SyntaxNode { &self.syntax }1094}1095impl AstNode for ExprAssert {1096	fn can_cast(kind: SyntaxKind) -> bool { kind == EXPR_ASSERT }1097	fn cast(syntax: SyntaxNode) -> Option<Self> {1098		if Self::can_cast(syntax.kind()) {1099			Some(Self { syntax })1100		} else {1101			None1102		}1103	}1104	fn syntax(&self) -> &SyntaxNode { &self.syntax }1105}1106impl AstNode for Assertion {1107	fn can_cast(kind: SyntaxKind) -> bool { kind == ASSERTION }1108	fn cast(syntax: SyntaxNode) -> Option<Self> {1109		if Self::can_cast(syntax.kind()) {1110			Some(Self { syntax })1111		} else {1112			None1113		}1114	}1115	fn syntax(&self) -> &SyntaxNode { &self.syntax }1116}1117impl AstNode for ExprError {1118	fn can_cast(kind: SyntaxKind) -> bool { kind == EXPR_ERROR }1119	fn cast(syntax: SyntaxNode) -> Option<Self> {1120		if Self::can_cast(syntax.kind()) {1121			Some(Self { syntax })1122		} else {1123			None1124		}1125	}1126	fn syntax(&self) -> &SyntaxNode { &self.syntax }1127}1128impl AstNode for Arg {1129	fn can_cast(kind: SyntaxKind) -> bool { kind == ARG }1130	fn cast(syntax: SyntaxNode) -> Option<Self> {1131		if Self::can_cast(syntax.kind()) {1132			Some(Self { syntax })1133		} else {1134			None1135		}1136	}1137	fn syntax(&self) -> &SyntaxNode { &self.syntax }1138}1139impl AstNode for ObjBodyComp {1140	fn can_cast(kind: SyntaxKind) -> bool { kind == OBJ_BODY_COMP }1141	fn cast(syntax: SyntaxNode) -> Option<Self> {1142		if Self::can_cast(syntax.kind()) {1143			Some(Self { syntax })1144		} else {1145			None1146		}1147	}1148	fn syntax(&self) -> &SyntaxNode { &self.syntax }1149}1150impl AstNode for ObjLocalPostComma {1151	fn can_cast(kind: SyntaxKind) -> bool { kind == OBJ_LOCAL_POST_COMMA }1152	fn cast(syntax: SyntaxNode) -> Option<Self> {1153		if Self::can_cast(syntax.kind()) {1154			Some(Self { syntax })1155		} else {1156			None1157		}1158	}1159	fn syntax(&self) -> &SyntaxNode { &self.syntax }1160}1161impl AstNode for ObjLocalPreComma {1162	fn can_cast(kind: SyntaxKind) -> bool { kind == OBJ_LOCAL_PRE_COMMA }1163	fn cast(syntax: SyntaxNode) -> Option<Self> {1164		if Self::can_cast(syntax.kind()) {1165			Some(Self { syntax })1166		} else {1167			None1168		}1169	}1170	fn syntax(&self) -> &SyntaxNode { &self.syntax }1171}1172impl AstNode for ObjBodyMemberList {1173	fn can_cast(kind: SyntaxKind) -> bool { kind == OBJ_BODY_MEMBER_LIST }1174	fn cast(syntax: SyntaxNode) -> Option<Self> {1175		if Self::can_cast(syntax.kind()) {1176			Some(Self { syntax })1177		} else {1178			None1179		}1180	}1181	fn syntax(&self) -> &SyntaxNode { &self.syntax }1182}1183impl AstNode for ObjLocal {1184	fn can_cast(kind: SyntaxKind) -> bool { kind == OBJ_LOCAL }1185	fn cast(syntax: SyntaxNode) -> Option<Self> {1186		if Self::can_cast(syntax.kind()) {1187			Some(Self { syntax })1188		} else {1189			None1190		}1191	}1192	fn syntax(&self) -> &SyntaxNode { &self.syntax }1193}1194impl AstNode for MemberBindStmt {1195	fn can_cast(kind: SyntaxKind) -> bool { kind == MEMBER_BIND_STMT }1196	fn cast(syntax: SyntaxNode) -> Option<Self> {1197		if Self::can_cast(syntax.kind()) {1198			Some(Self { syntax })1199		} else {1200			None1201		}1202	}1203	fn syntax(&self) -> &SyntaxNode { &self.syntax }1204}1205impl AstNode for MemberAssertStmt {1206	fn can_cast(kind: SyntaxKind) -> bool { kind == MEMBER_ASSERT_STMT }1207	fn cast(syntax: SyntaxNode) -> Option<Self> {1208		if Self::can_cast(syntax.kind()) {1209			Some(Self { syntax })1210		} else {1211			None1212		}1213	}1214	fn syntax(&self) -> &SyntaxNode { &self.syntax }1215}1216impl AstNode for MemberField {1217	fn can_cast(kind: SyntaxKind) -> bool { kind == MEMBER_FIELD }1218	fn cast(syntax: SyntaxNode) -> Option<Self> {1219		if Self::can_cast(syntax.kind()) {1220			Some(Self { syntax })1221		} else {1222			None1223		}1224	}1225	fn syntax(&self) -> &SyntaxNode { &self.syntax }1226}1227impl AstNode for FieldNormal {1228	fn can_cast(kind: SyntaxKind) -> bool { kind == FIELD_NORMAL }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 { &self.syntax }1237}1238impl AstNode for Visibility {1239	fn can_cast(kind: SyntaxKind) -> bool { kind == VISIBILITY }1240	fn cast(syntax: SyntaxNode) -> Option<Self> {1241		if Self::can_cast(syntax.kind()) {1242			Some(Self { syntax })1243		} else {1244			None1245		}1246	}1247	fn syntax(&self) -> &SyntaxNode { &self.syntax }1248}1249impl AstNode for FieldMethod {1250	fn can_cast(kind: SyntaxKind) -> bool { kind == FIELD_METHOD }1251	fn cast(syntax: SyntaxNode) -> Option<Self> {1252		if Self::can_cast(syntax.kind()) {1253			Some(Self { syntax })1254		} else {1255			None1256		}1257	}1258	fn syntax(&self) -> &SyntaxNode { &self.syntax }1259}1260impl AstNode for FieldNameFixed {1261	fn can_cast(kind: SyntaxKind) -> bool { kind == FIELD_NAME_FIXED }1262	fn cast(syntax: SyntaxNode) -> Option<Self> {1263		if Self::can_cast(syntax.kind()) {1264			Some(Self { syntax })1265		} else {1266			None1267		}1268	}1269	fn syntax(&self) -> &SyntaxNode { &self.syntax }1270}1271impl AstNode for FieldNameDynamic {1272	fn can_cast(kind: SyntaxKind) -> bool { kind == FIELD_NAME_DYNAMIC }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 { &self.syntax }1281}1282impl AstNode for IfSpec {1283	fn can_cast(kind: SyntaxKind) -> bool { kind == IF_SPEC }1284	fn cast(syntax: SyntaxNode) -> Option<Self> {1285		if Self::can_cast(syntax.kind()) {1286			Some(Self { syntax })1287		} else {1288			None1289		}1290	}1291	fn syntax(&self) -> &SyntaxNode { &self.syntax }1292}1293impl AstNode for BindDestruct {1294	fn can_cast(kind: SyntaxKind) -> bool { kind == BIND_DESTRUCT }1295	fn cast(syntax: SyntaxNode) -> Option<Self> {1296		if Self::can_cast(syntax.kind()) {1297			Some(Self { syntax })1298		} else {1299			None1300		}1301	}1302	fn syntax(&self) -> &SyntaxNode { &self.syntax }1303}1304impl AstNode for Destruct {1305	fn can_cast(kind: SyntaxKind) -> bool { kind == DESTRUCT }1306	fn cast(syntax: SyntaxNode) -> Option<Self> {1307		if Self::can_cast(syntax.kind()) {1308			Some(Self { syntax })1309		} else {1310			None1311		}1312	}1313	fn syntax(&self) -> &SyntaxNode { &self.syntax }1314}1315impl AstNode for BindFunction {1316	fn can_cast(kind: SyntaxKind) -> bool { kind == BIND_FUNCTION }1317	fn cast(syntax: SyntaxNode) -> Option<Self> {1318		if Self::can_cast(syntax.kind()) {1319			Some(Self { syntax })1320		} else {1321			None1322		}1323	}1324	fn syntax(&self) -> &SyntaxNode { &self.syntax }1325}1326impl AstNode for Param {1327	fn can_cast(kind: SyntaxKind) -> bool { kind == PARAM }1328	fn cast(syntax: SyntaxNode) -> Option<Self> {1329		if Self::can_cast(syntax.kind()) {1330			Some(Self { syntax })1331		} else {1332			None1333		}1334	}1335	fn syntax(&self) -> &SyntaxNode { &self.syntax }1336}1337impl AstNode for DestructFull {1338	fn can_cast(kind: SyntaxKind) -> bool { kind == DESTRUCT_FULL }1339	fn cast(syntax: SyntaxNode) -> Option<Self> {1340		if Self::can_cast(syntax.kind()) {1341			Some(Self { syntax })1342		} else {1343			None1344		}1345	}1346	fn syntax(&self) -> &SyntaxNode { &self.syntax }1347}1348impl AstNode for DestructSkip {1349	fn can_cast(kind: SyntaxKind) -> bool { kind == DESTRUCT_SKIP }1350	fn cast(syntax: SyntaxNode) -> Option<Self> {1351		if Self::can_cast(syntax.kind()) {1352			Some(Self { syntax })1353		} else {1354			None1355		}1356	}1357	fn syntax(&self) -> &SyntaxNode { &self.syntax }1358}1359impl AstNode for DestructArray {1360	fn can_cast(kind: SyntaxKind) -> bool { kind == DESTRUCT_ARRAY }1361	fn cast(syntax: SyntaxNode) -> Option<Self> {1362		if Self::can_cast(syntax.kind()) {1363			Some(Self { syntax })1364		} else {1365			None1366		}1367	}1368	fn syntax(&self) -> &SyntaxNode { &self.syntax }1369}1370impl AstNode for DestructRest {1371	fn can_cast(kind: SyntaxKind) -> bool { kind == DESTRUCT_REST }1372	fn cast(syntax: SyntaxNode) -> Option<Self> {1373		if Self::can_cast(syntax.kind()) {1374			Some(Self { syntax })1375		} else {1376			None1377		}1378	}1379	fn syntax(&self) -> &SyntaxNode { &self.syntax }1380}1381impl AstNode for DestructObject {1382	fn can_cast(kind: SyntaxKind) -> bool { kind == DESTRUCT_OBJECT }1383	fn cast(syntax: SyntaxNode) -> Option<Self> {1384		if Self::can_cast(syntax.kind()) {1385			Some(Self { syntax })1386		} else {1387			None1388		}1389	}1390	fn syntax(&self) -> &SyntaxNode { &self.syntax }1391}1392impl AstNode for DestructObjectField {1393	fn can_cast(kind: SyntaxKind) -> bool { kind == DESTRUCT_OBJECT_FIELD }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 { &self.syntax }1402}1403impl From<ExprBinary> for Expr {1404	fn from(node: ExprBinary) -> Expr { Expr::ExprBinary(node) }1405}1406impl From<ExprUnary> for Expr {1407	fn from(node: ExprUnary) -> Expr { Expr::ExprUnary(node) }1408}1409impl From<ExprSlice> for Expr {1410	fn from(node: ExprSlice) -> Expr { Expr::ExprSlice(node) }1411}1412impl From<ExprIndex> for Expr {1413	fn from(node: ExprIndex) -> Expr { Expr::ExprIndex(node) }1414}1415impl From<ExprIndexExpr> for Expr {1416	fn from(node: ExprIndexExpr) -> Expr { Expr::ExprIndexExpr(node) }1417}1418impl From<ExprApply> for Expr {1419	fn from(node: ExprApply) -> Expr { Expr::ExprApply(node) }1420}1421impl From<ExprObjExtend> for Expr {1422	fn from(node: ExprObjExtend) -> Expr { Expr::ExprObjExtend(node) }1423}1424impl From<ExprParened> for Expr {1425	fn from(node: ExprParened) -> Expr { Expr::ExprParened(node) }1426}1427impl From<ExprIntrinsicThisFile> for Expr {1428	fn from(node: ExprIntrinsicThisFile) -> Expr { Expr::ExprIntrinsicThisFile(node) }1429}1430impl From<ExprIntrinsicId> for Expr {1431	fn from(node: ExprIntrinsicId) -> Expr { Expr::ExprIntrinsicId(node) }1432}1433impl From<ExprIntrinsic> for Expr {1434	fn from(node: ExprIntrinsic) -> Expr { Expr::ExprIntrinsic(node) }1435}1436impl From<ExprString> for Expr {1437	fn from(node: ExprString) -> Expr { Expr::ExprString(node) }1438}1439impl From<ExprNumber> for Expr {1440	fn from(node: ExprNumber) -> Expr { Expr::ExprNumber(node) }1441}1442impl From<ExprArray> for Expr {1443	fn from(node: ExprArray) -> Expr { Expr::ExprArray(node) }1444}1445impl From<ExprObject> for Expr {1446	fn from(node: ExprObject) -> Expr { Expr::ExprObject(node) }1447}1448impl From<ExprArrayComp> for Expr {1449	fn from(node: ExprArrayComp) -> Expr { Expr::ExprArrayComp(node) }1450}1451impl From<ExprImport> for Expr {1452	fn from(node: ExprImport) -> Expr { Expr::ExprImport(node) }1453}1454impl From<ExprVar> for Expr {1455	fn from(node: ExprVar) -> Expr { Expr::ExprVar(node) }1456}1457impl From<ExprLocal> for Expr {1458	fn from(node: ExprLocal) -> Expr { Expr::ExprLocal(node) }1459}1460impl From<ExprIfThenElse> for Expr {1461	fn from(node: ExprIfThenElse) -> Expr { Expr::ExprIfThenElse(node) }1462}1463impl From<ExprFunction> for Expr {1464	fn from(node: ExprFunction) -> Expr { Expr::ExprFunction(node) }1465}1466impl From<ExprAssert> for Expr {1467	fn from(node: ExprAssert) -> Expr { Expr::ExprAssert(node) }1468}1469impl From<ExprError> for Expr {1470	fn from(node: ExprError) -> Expr { Expr::ExprError(node) }1471}1472impl AstNode for Expr {1473	fn can_cast(kind: SyntaxKind) -> bool {1474		match kind {1475			EXPR_BINARY1476			| EXPR_UNARY1477			| EXPR_SLICE1478			| EXPR_INDEX1479			| EXPR_INDEX_EXPR1480			| EXPR_APPLY1481			| EXPR_OBJ_EXTEND1482			| EXPR_PARENED1483			| EXPR_INTRINSIC_THIS_FILE1484			| EXPR_INTRINSIC_ID1485			| EXPR_INTRINSIC1486			| EXPR_STRING1487			| EXPR_NUMBER1488			| EXPR_ARRAY1489			| EXPR_OBJECT1490			| EXPR_ARRAY_COMP1491			| EXPR_IMPORT1492			| EXPR_VAR1493			| EXPR_LOCAL1494			| EXPR_IF_THEN_ELSE1495			| EXPR_FUNCTION1496			| EXPR_ASSERT1497			| EXPR_ERROR => true,1498			_ => false,1499		}1500	}1501	fn cast(syntax: SyntaxNode) -> Option<Self> {1502		let res = match syntax.kind() {1503			EXPR_BINARY => Expr::ExprBinary(ExprBinary { syntax }),1504			EXPR_UNARY => Expr::ExprUnary(ExprUnary { syntax }),1505			EXPR_SLICE => Expr::ExprSlice(ExprSlice { syntax }),1506			EXPR_INDEX => Expr::ExprIndex(ExprIndex { syntax }),1507			EXPR_INDEX_EXPR => Expr::ExprIndexExpr(ExprIndexExpr { syntax }),1508			EXPR_APPLY => Expr::ExprApply(ExprApply { syntax }),1509			EXPR_OBJ_EXTEND => Expr::ExprObjExtend(ExprObjExtend { syntax }),1510			EXPR_PARENED => Expr::ExprParened(ExprParened { syntax }),1511			EXPR_INTRINSIC_THIS_FILE => {1512				Expr::ExprIntrinsicThisFile(ExprIntrinsicThisFile { syntax })1513			}1514			EXPR_INTRINSIC_ID => Expr::ExprIntrinsicId(ExprIntrinsicId { syntax }),1515			EXPR_INTRINSIC => Expr::ExprIntrinsic(ExprIntrinsic { syntax }),1516			EXPR_STRING => Expr::ExprString(ExprString { syntax }),1517			EXPR_NUMBER => Expr::ExprNumber(ExprNumber { syntax }),1518			EXPR_ARRAY => Expr::ExprArray(ExprArray { syntax }),1519			EXPR_OBJECT => Expr::ExprObject(ExprObject { syntax }),1520			EXPR_ARRAY_COMP => Expr::ExprArrayComp(ExprArrayComp { syntax }),1521			EXPR_IMPORT => Expr::ExprImport(ExprImport { syntax }),1522			EXPR_VAR => Expr::ExprVar(ExprVar { syntax }),1523			EXPR_LOCAL => Expr::ExprLocal(ExprLocal { syntax }),1524			EXPR_IF_THEN_ELSE => Expr::ExprIfThenElse(ExprIfThenElse { syntax }),1525			EXPR_FUNCTION => Expr::ExprFunction(ExprFunction { syntax }),1526			EXPR_ASSERT => Expr::ExprAssert(ExprAssert { syntax }),1527			EXPR_ERROR => Expr::ExprError(ExprError { syntax }),1528			_ => return None,1529		};1530		Some(res)1531	}1532	fn syntax(&self) -> &SyntaxNode {1533		match self {1534			Expr::ExprBinary(it) => &it.syntax,1535			Expr::ExprUnary(it) => &it.syntax,1536			Expr::ExprSlice(it) => &it.syntax,1537			Expr::ExprIndex(it) => &it.syntax,1538			Expr::ExprIndexExpr(it) => &it.syntax,1539			Expr::ExprApply(it) => &it.syntax,1540			Expr::ExprObjExtend(it) => &it.syntax,1541			Expr::ExprParened(it) => &it.syntax,1542			Expr::ExprIntrinsicThisFile(it) => &it.syntax,1543			Expr::ExprIntrinsicId(it) => &it.syntax,1544			Expr::ExprIntrinsic(it) => &it.syntax,1545			Expr::ExprString(it) => &it.syntax,1546			Expr::ExprNumber(it) => &it.syntax,1547			Expr::ExprArray(it) => &it.syntax,1548			Expr::ExprObject(it) => &it.syntax,1549			Expr::ExprArrayComp(it) => &it.syntax,1550			Expr::ExprImport(it) => &it.syntax,1551			Expr::ExprVar(it) => &it.syntax,1552			Expr::ExprLocal(it) => &it.syntax,1553			Expr::ExprIfThenElse(it) => &it.syntax,1554			Expr::ExprFunction(it) => &it.syntax,1555			Expr::ExprAssert(it) => &it.syntax,1556			Expr::ExprError(it) => &it.syntax,1557		}1558	}1559}1560impl From<ObjBodyComp> for ObjBody {1561	fn from(node: ObjBodyComp) -> ObjBody { ObjBody::ObjBodyComp(node) }1562}1563impl From<ObjBodyMemberList> for ObjBody {1564	fn from(node: ObjBodyMemberList) -> ObjBody { ObjBody::ObjBodyMemberList(node) }1565}1566impl AstNode for ObjBody {1567	fn can_cast(kind: SyntaxKind) -> bool {1568		match kind {1569			OBJ_BODY_COMP | OBJ_BODY_MEMBER_LIST => true,1570			_ => false,1571		}1572	}1573	fn cast(syntax: SyntaxNode) -> Option<Self> {1574		let res = match syntax.kind() {1575			OBJ_BODY_COMP => ObjBody::ObjBodyComp(ObjBodyComp { syntax }),1576			OBJ_BODY_MEMBER_LIST => ObjBody::ObjBodyMemberList(ObjBodyMemberList { syntax }),1577			_ => return None,1578		};1579		Some(res)1580	}1581	fn syntax(&self) -> &SyntaxNode {1582		match self {1583			ObjBody::ObjBodyComp(it) => &it.syntax,1584			ObjBody::ObjBodyMemberList(it) => &it.syntax,1585		}1586	}1587}1588impl From<ForSpec> for CompSpec {1589	fn from(node: ForSpec) -> CompSpec { CompSpec::ForSpec(node) }1590}1591impl From<IfSpec> for CompSpec {1592	fn from(node: IfSpec) -> CompSpec { CompSpec::IfSpec(node) }1593}1594impl AstNode for CompSpec {1595	fn can_cast(kind: SyntaxKind) -> bool {1596		match kind {1597			FOR_SPEC | IF_SPEC => true,1598			_ => false,1599		}1600	}1601	fn cast(syntax: SyntaxNode) -> Option<Self> {1602		let res = match syntax.kind() {1603			FOR_SPEC => CompSpec::ForSpec(ForSpec { syntax }),1604			IF_SPEC => CompSpec::IfSpec(IfSpec { syntax }),1605			_ => return None,1606		};1607		Some(res)1608	}1609	fn syntax(&self) -> &SyntaxNode {1610		match self {1611			CompSpec::ForSpec(it) => &it.syntax,1612			CompSpec::IfSpec(it) => &it.syntax,1613		}1614	}1615}1616impl From<BindDestruct> for Bind {1617	fn from(node: BindDestruct) -> Bind { Bind::BindDestruct(node) }1618}1619impl From<BindFunction> for Bind {1620	fn from(node: BindFunction) -> Bind { Bind::BindFunction(node) }1621}1622impl AstNode for Bind {1623	fn can_cast(kind: SyntaxKind) -> bool {1624		match kind {1625			BIND_DESTRUCT | BIND_FUNCTION => true,1626			_ => false,1627		}1628	}1629	fn cast(syntax: SyntaxNode) -> Option<Self> {1630		let res = match syntax.kind() {1631			BIND_DESTRUCT => Bind::BindDestruct(BindDestruct { syntax }),1632			BIND_FUNCTION => Bind::BindFunction(BindFunction { syntax }),1633			_ => return None,1634		};1635		Some(res)1636	}1637	fn syntax(&self) -> &SyntaxNode {1638		match self {1639			Bind::BindDestruct(it) => &it.syntax,1640			Bind::BindFunction(it) => &it.syntax,1641		}1642	}1643}1644impl From<MemberBindStmt> for Member {1645	fn from(node: MemberBindStmt) -> Member { Member::MemberBindStmt(node) }1646}1647impl From<MemberAssertStmt> for Member {1648	fn from(node: MemberAssertStmt) -> Member { Member::MemberAssertStmt(node) }1649}1650impl From<MemberField> for Member {1651	fn from(node: MemberField) -> Member { Member::MemberField(node) }1652}1653impl AstNode for Member {1654	fn can_cast(kind: SyntaxKind) -> bool {1655		match kind {1656			MEMBER_BIND_STMT | MEMBER_ASSERT_STMT | MEMBER_FIELD => true,1657			_ => false,1658		}1659	}1660	fn cast(syntax: SyntaxNode) -> Option<Self> {1661		let res = match syntax.kind() {1662			MEMBER_BIND_STMT => Member::MemberBindStmt(MemberBindStmt { syntax }),1663			MEMBER_ASSERT_STMT => Member::MemberAssertStmt(MemberAssertStmt { syntax }),1664			MEMBER_FIELD => Member::MemberField(MemberField { syntax }),1665			_ => return None,1666		};1667		Some(res)1668	}1669	fn syntax(&self) -> &SyntaxNode {1670		match self {1671			Member::MemberBindStmt(it) => &it.syntax,1672			Member::MemberAssertStmt(it) => &it.syntax,1673			Member::MemberField(it) => &it.syntax,1674		}1675	}1676}1677impl From<FieldNormal> for Field {1678	fn from(node: FieldNormal) -> Field { Field::FieldNormal(node) }1679}1680impl From<FieldMethod> for Field {1681	fn from(node: FieldMethod) -> Field { Field::FieldMethod(node) }1682}1683impl AstNode for Field {1684	fn can_cast(kind: SyntaxKind) -> bool {1685		match kind {1686			FIELD_NORMAL | FIELD_METHOD => true,1687			_ => false,1688		}1689	}1690	fn cast(syntax: SyntaxNode) -> Option<Self> {1691		let res = match syntax.kind() {1692			FIELD_NORMAL => Field::FieldNormal(FieldNormal { syntax }),1693			FIELD_METHOD => Field::FieldMethod(FieldMethod { syntax }),1694			_ => return None,1695		};1696		Some(res)1697	}1698	fn syntax(&self) -> &SyntaxNode {1699		match self {1700			Field::FieldNormal(it) => &it.syntax,1701			Field::FieldMethod(it) => &it.syntax,1702		}1703	}1704}1705impl From<FieldNameFixed> for FieldName {1706	fn from(node: FieldNameFixed) -> FieldName { FieldName::FieldNameFixed(node) }1707}1708impl From<FieldNameDynamic> for FieldName {1709	fn from(node: FieldNameDynamic) -> FieldName { FieldName::FieldNameDynamic(node) }1710}1711impl AstNode for FieldName {1712	fn can_cast(kind: SyntaxKind) -> bool {1713		match kind {1714			FIELD_NAME_FIXED | FIELD_NAME_DYNAMIC => true,1715			_ => false,1716		}1717	}1718	fn cast(syntax: SyntaxNode) -> Option<Self> {1719		let res = match syntax.kind() {1720			FIELD_NAME_FIXED => FieldName::FieldNameFixed(FieldNameFixed { syntax }),1721			FIELD_NAME_DYNAMIC => FieldName::FieldNameDynamic(FieldNameDynamic { syntax }),1722			_ => return None,1723		};1724		Some(res)1725	}1726	fn syntax(&self) -> &SyntaxNode {1727		match self {1728			FieldName::FieldNameFixed(it) => &it.syntax,1729			FieldName::FieldNameDynamic(it) => &it.syntax,1730		}1731	}1732}1733impl std::fmt::Display for Expr {1734	fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result {1735		std::fmt::Display::fmt(self.syntax(), f)1736	}1737}1738impl std::fmt::Display for ObjBody {1739	fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result {1740		std::fmt::Display::fmt(self.syntax(), f)1741	}1742}1743impl std::fmt::Display for CompSpec {1744	fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result {1745		std::fmt::Display::fmt(self.syntax(), f)1746	}1747}1748impl std::fmt::Display for Bind {1749	fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result {1750		std::fmt::Display::fmt(self.syntax(), f)1751	}1752}1753impl std::fmt::Display for Member {1754	fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result {1755		std::fmt::Display::fmt(self.syntax(), f)1756	}1757}1758impl std::fmt::Display for Field {1759	fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result {1760		std::fmt::Display::fmt(self.syntax(), f)1761	}1762}1763impl std::fmt::Display for FieldName {1764	fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result {1765		std::fmt::Display::fmt(self.syntax(), f)1766	}1767}1768impl std::fmt::Display for SourceFile {1769	fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result {1770		std::fmt::Display::fmt(self.syntax(), f)1771	}1772}1773impl std::fmt::Display for ExprBinary {1774	fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result {1775		std::fmt::Display::fmt(self.syntax(), f)1776	}1777}1778impl std::fmt::Display for BinaryOperator {1779	fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result {1780		std::fmt::Display::fmt(self.syntax(), f)1781	}1782}1783impl std::fmt::Display for ExprUnary {1784	fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result {1785		std::fmt::Display::fmt(self.syntax(), f)1786	}1787}1788impl std::fmt::Display for UnaryOperator {1789	fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result {1790		std::fmt::Display::fmt(self.syntax(), f)1791	}1792}1793impl std::fmt::Display for ExprSlice {1794	fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result {1795		std::fmt::Display::fmt(self.syntax(), f)1796	}1797}1798impl std::fmt::Display for SliceDesc {1799	fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result {1800		std::fmt::Display::fmt(self.syntax(), f)1801	}1802}1803impl std::fmt::Display for ExprIndex {1804	fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result {1805		std::fmt::Display::fmt(self.syntax(), f)1806	}1807}1808impl std::fmt::Display for Name {1809	fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result {1810		std::fmt::Display::fmt(self.syntax(), f)1811	}1812}1813impl std::fmt::Display for ExprIndexExpr {1814	fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result {1815		std::fmt::Display::fmt(self.syntax(), f)1816	}1817}1818impl std::fmt::Display for ExprApply {1819	fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result {1820		std::fmt::Display::fmt(self.syntax(), f)1821	}1822}1823impl std::fmt::Display for ArgsDesc {1824	fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result {1825		std::fmt::Display::fmt(self.syntax(), f)1826	}1827}1828impl std::fmt::Display for ExprObjExtend {1829	fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result {1830		std::fmt::Display::fmt(self.syntax(), f)1831	}1832}1833impl std::fmt::Display for ExprParened {1834	fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result {1835		std::fmt::Display::fmt(self.syntax(), f)1836	}1837}1838impl std::fmt::Display for ExprLiteral {1839	fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result {1840		std::fmt::Display::fmt(self.syntax(), f)1841	}1842}1843impl std::fmt::Display for Literal {1844	fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result {1845		std::fmt::Display::fmt(self.syntax(), f)1846	}1847}1848impl std::fmt::Display for ExprIntrinsicThisFile {1849	fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result {1850		std::fmt::Display::fmt(self.syntax(), f)1851	}1852}1853impl std::fmt::Display for ExprIntrinsicId {1854	fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result {1855		std::fmt::Display::fmt(self.syntax(), f)1856	}1857}1858impl std::fmt::Display for ExprIntrinsic {1859	fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result {1860		std::fmt::Display::fmt(self.syntax(), f)1861	}1862}1863impl std::fmt::Display for ExprString {1864	fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result {1865		std::fmt::Display::fmt(self.syntax(), f)1866	}1867}1868impl std::fmt::Display for String {1869	fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result {1870		std::fmt::Display::fmt(self.syntax(), f)1871	}1872}1873impl std::fmt::Display for ExprNumber {1874	fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result {1875		std::fmt::Display::fmt(self.syntax(), f)1876	}1877}1878impl std::fmt::Display for Number {1879	fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result {1880		std::fmt::Display::fmt(self.syntax(), f)1881	}1882}1883impl std::fmt::Display for ExprArray {1884	fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result {1885		std::fmt::Display::fmt(self.syntax(), f)1886	}1887}1888impl std::fmt::Display for ExprObject {1889	fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result {1890		std::fmt::Display::fmt(self.syntax(), f)1891	}1892}1893impl std::fmt::Display for ExprArrayComp {1894	fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result {1895		std::fmt::Display::fmt(self.syntax(), f)1896	}1897}1898impl std::fmt::Display for ForSpec {1899	fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result {1900		std::fmt::Display::fmt(self.syntax(), f)1901	}1902}1903impl std::fmt::Display for ExprImport {1904	fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result {1905		std::fmt::Display::fmt(self.syntax(), f)1906	}1907}1908impl std::fmt::Display for ExprVar {1909	fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result {1910		std::fmt::Display::fmt(self.syntax(), f)1911	}1912}1913impl std::fmt::Display for ExprLocal {1914	fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result {1915		std::fmt::Display::fmt(self.syntax(), f)1916	}1917}1918impl std::fmt::Display for ExprIfThenElse {1919	fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result {1920		std::fmt::Display::fmt(self.syntax(), f)1921	}1922}1923impl std::fmt::Display for ExprFunction {1924	fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result {1925		std::fmt::Display::fmt(self.syntax(), f)1926	}1927}1928impl std::fmt::Display for ParamsDesc {1929	fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result {1930		std::fmt::Display::fmt(self.syntax(), f)1931	}1932}1933impl std::fmt::Display for ExprAssert {1934	fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result {1935		std::fmt::Display::fmt(self.syntax(), f)1936	}1937}1938impl std::fmt::Display for Assertion {1939	fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result {1940		std::fmt::Display::fmt(self.syntax(), f)1941	}1942}1943impl std::fmt::Display for ExprError {1944	fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result {1945		std::fmt::Display::fmt(self.syntax(), f)1946	}1947}1948impl std::fmt::Display for Arg {1949	fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result {1950		std::fmt::Display::fmt(self.syntax(), f)1951	}1952}1953impl std::fmt::Display for ObjBodyComp {1954	fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result {1955		std::fmt::Display::fmt(self.syntax(), f)1956	}1957}1958impl std::fmt::Display for ObjLocalPostComma {1959	fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result {1960		std::fmt::Display::fmt(self.syntax(), f)1961	}1962}1963impl std::fmt::Display for ObjLocalPreComma {1964	fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result {1965		std::fmt::Display::fmt(self.syntax(), f)1966	}1967}1968impl std::fmt::Display for ObjBodyMemberList {1969	fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result {1970		std::fmt::Display::fmt(self.syntax(), f)1971	}1972}1973impl std::fmt::Display for ObjLocal {1974	fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result {1975		std::fmt::Display::fmt(self.syntax(), f)1976	}1977}1978impl std::fmt::Display for MemberBindStmt {1979	fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result {1980		std::fmt::Display::fmt(self.syntax(), f)1981	}1982}1983impl std::fmt::Display for MemberAssertStmt {1984	fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result {1985		std::fmt::Display::fmt(self.syntax(), f)1986	}1987}1988impl std::fmt::Display for MemberField {1989	fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result {1990		std::fmt::Display::fmt(self.syntax(), f)1991	}1992}1993impl std::fmt::Display for FieldNormal {1994	fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result {1995		std::fmt::Display::fmt(self.syntax(), f)1996	}1997}1998impl std::fmt::Display for Visibility {1999	fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result {2000		std::fmt::Display::fmt(self.syntax(), f)2001	}2002}2003impl std::fmt::Display for FieldMethod {2004	fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result {2005		std::fmt::Display::fmt(self.syntax(), f)2006	}2007}2008impl std::fmt::Display for FieldNameFixed {2009	fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result {2010		std::fmt::Display::fmt(self.syntax(), f)2011	}2012}2013impl std::fmt::Display for FieldNameDynamic {2014	fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result {2015		std::fmt::Display::fmt(self.syntax(), f)2016	}2017}2018impl std::fmt::Display for IfSpec {2019	fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result {2020		std::fmt::Display::fmt(self.syntax(), f)2021	}2022}2023impl std::fmt::Display for BindDestruct {2024	fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result {2025		std::fmt::Display::fmt(self.syntax(), f)2026	}2027}2028impl std::fmt::Display for Destruct {2029	fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result {2030		std::fmt::Display::fmt(self.syntax(), f)2031	}2032}2033impl std::fmt::Display for BindFunction {2034	fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result {2035		std::fmt::Display::fmt(self.syntax(), f)2036	}2037}2038impl std::fmt::Display for Param {2039	fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result {2040		std::fmt::Display::fmt(self.syntax(), f)2041	}2042}2043impl std::fmt::Display for DestructFull {2044	fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result {2045		std::fmt::Display::fmt(self.syntax(), f)2046	}2047}2048impl std::fmt::Display for DestructSkip {2049	fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result {2050		std::fmt::Display::fmt(self.syntax(), f)2051	}2052}2053impl std::fmt::Display for DestructArray {2054	fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result {2055		std::fmt::Display::fmt(self.syntax(), f)2056	}2057}2058impl std::fmt::Display for DestructRest {2059	fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result {2060		std::fmt::Display::fmt(self.syntax(), f)2061	}2062}2063impl std::fmt::Display for DestructObject {2064	fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result {2065		std::fmt::Display::fmt(self.syntax(), f)2066	}2067}2068impl std::fmt::Display for DestructObjectField {2069	fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result {2070		std::fmt::Display::fmt(self.syntax(), f)2071	}2072}
addedcrates/jrsonnet-rowan-parser/src/generated/syntax_kinds.rsdiffbeforeafterboth
--- /dev/null
+++ b/crates/jrsonnet-rowan-parser/src/generated/syntax_kinds.rs
@@ -0,0 +1,307 @@
+//! This is a generated file, please do not edit manually. Changes can be
+//! made in codegeneration that lives in `xtask` top-level dir.
+
+#![allow(bad_style, missing_docs, unreachable_pub)]
+use logos::Logos;
+#[doc = r" The kind of syntax node, e.g. `IDENT`, `USE_KW`, or `STRUCT`."]
+#[derive(Clone, Copy, PartialEq, Eq, PartialOrd, Ord, Hash, Debug, Logos)]
+#[repr(u16)]
+pub enum SyntaxKind {
+	#[doc(hidden)]
+	TOMBSTONE,
+	#[doc(hidden)]
+	EOF,
+	#[token("||")]
+	OR,
+	#[token("&&")]
+	AND,
+	#[token("|")]
+	BIT_OR,
+	#[token("^")]
+	BIT_XOR,
+	#[token("&")]
+	BIT_AND,
+	#[token("==")]
+	EQ,
+	#[token("!=")]
+	NE,
+	#[token("<")]
+	LT,
+	#[token(">")]
+	GT,
+	#[token("<=")]
+	LE,
+	#[token(">=")]
+	GE,
+	#[token("<<")]
+	LHS,
+	#[token(">>")]
+	RHS,
+	#[token("+")]
+	PLUS,
+	#[token("-")]
+	MINUS,
+	#[token("*")]
+	MUL,
+	#[token("/")]
+	DIV,
+	#[token("%")]
+	MODULO,
+	#[token("!")]
+	NOT,
+	#[token("~")]
+	BIT_NOT,
+	#[token("[")]
+	L_BRACK,
+	#[token("]")]
+	R_BRACK,
+	#[token("(")]
+	L_PAREN,
+	#[token(")")]
+	R_PAREN,
+	#[token("{")]
+	L_BRACE,
+	#[token("}")]
+	R_BRACE,
+	#[token(":")]
+	COLON,
+	#[token("::")]
+	COLONCOLON,
+	#[token(":::")]
+	COLONCOLONCOLON,
+	#[token(";")]
+	SEMI,
+	#[token(".")]
+	DOT,
+	#[token("...")]
+	DOTDOTDOT,
+	#[token(",")]
+	COMMA,
+	#[token("$")]
+	DOLLAR,
+	#[token("=")]
+	ASSIGN,
+	#[token("?")]
+	QUESTION_MARK,
+	#[token("$intrinsicThisFile")]
+	INTRINSIC_THIS_FILE,
+	#[token("$intrinsicId")]
+	INTRINSIC_ID,
+	#[token("$intrinsic")]
+	INTRINSIC,
+	#[token("tailstrict")]
+	TAILSTRICT_KW,
+	#[token("importstr")]
+	IMPORTSTR_KW,
+	#[token("importbin")]
+	IMPORTBIN_KW,
+	#[token("import")]
+	IMPORT_KW,
+	#[token("local")]
+	LOCAL_KW,
+	#[token("if")]
+	IF_KW,
+	#[token("then")]
+	THEN_KW,
+	#[token("else")]
+	ELSE_KW,
+	#[token("function")]
+	FUNCTION_KW,
+	#[token("error")]
+	ERROR_KW,
+	#[token("in")]
+	IN_KW,
+	#[token("null")]
+	NULL_KW,
+	#[token("true")]
+	TRUE_KW,
+	#[token("false")]
+	FALSE_KW,
+	#[token("self")]
+	SELF_KW,
+	#[token("super")]
+	SUPER_KW,
+	#[token("for")]
+	FOR_KW,
+	#[token("assert")]
+	ASSERT_KW,
+	#[regex("(?:0|[1-9][0-9]*)(?:\\.[0-9]+)?(?:[eE][+-]?[0-9]+)?")]
+	NUMBER,
+	#[regex("\"(?s:[^\"\\\\]|\\\\.)*\"")]
+	STRING_DOUBLE,
+	#[regex("'(?s:[^'\\\\]|\\\\.)*'")]
+	STRING_SINGLE,
+	#[regex("@\"(?:[^\"]|\"\")*\"")]
+	STRING_DOUBLE_VERBATIM,
+	#[regex("@'(?:[^']|'')*'")]
+	STRING_SINGLE_VERBATIM,
+	#[regex("\\|\\|\\|")]
+	STRING_BLOCK,
+	#[regex("[_a-zA-Z][_a-zA-Z0-9]*")]
+	IDENT,
+	#[regex("[ \\t\\n\\r]+")]
+	WHITESPACE,
+	#[regex("//[^\\r\\n]*(\\r\\n|\\n)?")]
+	SINGLE_LINE_SLASH_COMMENT,
+	#[regex("#[^\\r\\n]*(\\r\\n|\\n)?")]
+	SINGLE_LINE_HASH_COMMENT,
+	#[regex("/\\*([^*]|\\*[^/])*\\*/")]
+	MULTI_LINE_COMMENT,
+	#[error]
+	ERROR,
+	SOURCE_FILE,
+	EXPR_BINARY,
+	BINARY_OPERATOR,
+	EXPR_UNARY,
+	UNARY_OPERATOR,
+	EXPR_SLICE,
+	SLICE_DESC,
+	EXPR_INDEX,
+	NAME,
+	EXPR_INDEX_EXPR,
+	EXPR_APPLY,
+	ARGS_DESC,
+	EXPR_OBJ_EXTEND,
+	EXPR_PARENED,
+	EXPR_LITERAL,
+	LITERAL,
+	EXPR_INTRINSIC_THIS_FILE,
+	EXPR_INTRINSIC_ID,
+	EXPR_INTRINSIC,
+	EXPR_STRING,
+	STRING,
+	EXPR_NUMBER,
+	EXPR_ARRAY,
+	EXPR_OBJECT,
+	EXPR_ARRAY_COMP,
+	FOR_SPEC,
+	EXPR_IMPORT,
+	EXPR_VAR,
+	EXPR_LOCAL,
+	EXPR_IF_THEN_ELSE,
+	EXPR_FUNCTION,
+	PARAMS_DESC,
+	EXPR_ASSERT,
+	ASSERTION,
+	EXPR_ERROR,
+	ARG,
+	OBJ_BODY_COMP,
+	OBJ_LOCAL_POST_COMMA,
+	OBJ_LOCAL_PRE_COMMA,
+	OBJ_BODY_MEMBER_LIST,
+	OBJ_LOCAL,
+	MEMBER_BIND_STMT,
+	MEMBER_ASSERT_STMT,
+	MEMBER_FIELD,
+	FIELD_NORMAL,
+	VISIBILITY,
+	FIELD_METHOD,
+	FIELD_NAME_FIXED,
+	FIELD_NAME_DYNAMIC,
+	IF_SPEC,
+	BIND_DESTRUCT,
+	DESTRUCT,
+	BIND_FUNCTION,
+	PARAM,
+	DESTRUCT_FULL,
+	DESTRUCT_SKIP,
+	DESTRUCT_ARRAY,
+	DESTRUCT_REST,
+	DESTRUCT_OBJECT,
+	DESTRUCT_OBJECT_FIELD,
+	EXPR,
+	OBJ_BODY,
+	COMP_SPEC,
+	BIND,
+	MEMBER,
+	FIELD,
+	FIELD_NAME,
+	#[doc(hidden)]
+	__LAST,
+}
+use self::SyntaxKind::*;
+impl SyntaxKind {
+	pub fn is_keyword(self) -> bool {
+		match self {
+			TAILSTRICT_KW | IMPORTSTR_KW | IMPORTBIN_KW | IMPORT_KW | LOCAL_KW | IF_KW
+			| THEN_KW | ELSE_KW | FUNCTION_KW | ERROR_KW | IN_KW | NULL_KW | TRUE_KW | FALSE_KW
+			| SELF_KW | SUPER_KW | FOR_KW | ASSERT_KW => true,
+			_ => false,
+		}
+	}
+	pub fn is_punct(self) -> bool {
+		match self {
+			OR | AND | BIT_OR | BIT_XOR | BIT_AND | EQ | NE | LT | GT | LE | GE | LHS | RHS
+			| PLUS | MINUS | MUL | DIV | MODULO | NOT | BIT_NOT | L_BRACK | R_BRACK | L_PAREN
+			| R_PAREN | L_BRACE | R_BRACE | COLON | COLONCOLON | COLONCOLONCOLON | SEMI | DOT
+			| DOTDOTDOT | COMMA | DOLLAR | ASSIGN | QUESTION_MARK | INTRINSIC_THIS_FILE
+			| INTRINSIC_ID | INTRINSIC => true,
+			_ => false,
+		}
+	}
+	pub fn from_keyword(ident: &str) -> Option<SyntaxKind> {
+		let kw = match ident {
+			"tailstrict" => TAILSTRICT_KW,
+			"importstr" => IMPORTSTR_KW,
+			"importbin" => IMPORTBIN_KW,
+			"import" => IMPORT_KW,
+			"local" => LOCAL_KW,
+			"if" => IF_KW,
+			"then" => THEN_KW,
+			"else" => ELSE_KW,
+			"function" => FUNCTION_KW,
+			"error" => ERROR_KW,
+			"in" => IN_KW,
+			"null" => NULL_KW,
+			"true" => TRUE_KW,
+			"false" => FALSE_KW,
+			"self" => SELF_KW,
+			"super" => SUPER_KW,
+			"for" => FOR_KW,
+			"assert" => ASSERT_KW,
+			_ => return None,
+		};
+		Some(kw)
+	}
+	pub fn from_char(c: char) -> Option<SyntaxKind> {
+		let tok = match c {
+			'|' => BIT_OR,
+			'^' => BIT_XOR,
+			'&' => BIT_AND,
+			'<' => LT,
+			'>' => GT,
+			'+' => PLUS,
+			'-' => MINUS,
+			'*' => MUL,
+			'/' => DIV,
+			'%' => MODULO,
+			'!' => NOT,
+			'~' => BIT_NOT,
+			'[' => L_BRACK,
+			']' => R_BRACK,
+			'(' => L_PAREN,
+			')' => R_PAREN,
+			'{' => L_BRACE,
+			'}' => R_BRACE,
+			':' => COLON,
+			';' => SEMI,
+			'.' => DOT,
+			',' => COMMA,
+			'$' => DOLLAR,
+			'=' => ASSIGN,
+			'?' => QUESTION_MARK,
+			_ => return None,
+		};
+		Some(tok)
+	}
+	pub fn from_raw(r: u16) -> Self {
+		assert!(r < Self::__LAST as u16);
+		unsafe { std::mem::transmute(r) }
+	}
+	pub fn into_raw(self) -> u16 {
+		self as u16
+	}
+}
+#[macro_export]
+macro_rules ! T { [||] => { $ crate :: SyntaxKind :: OR } ; [&&] => { $ crate :: SyntaxKind :: AND } ; [|] => { $ crate :: SyntaxKind :: BIT_OR } ; [^] => { $ crate :: SyntaxKind :: BIT_XOR } ; [&] => { $ crate :: SyntaxKind :: BIT_AND } ; [==] => { $ crate :: SyntaxKind :: EQ } ; [!=] => { $ crate :: SyntaxKind :: NE } ; [<] => { $ crate :: SyntaxKind :: LT } ; [>] => { $ crate :: SyntaxKind :: GT } ; [<=] => { $ crate :: SyntaxKind :: LE } ; [>=] => { $ crate :: SyntaxKind :: GE } ; [<<] => { $ crate :: SyntaxKind :: LHS } ; [>>] => { $ crate :: SyntaxKind :: RHS } ; [+] => { $ crate :: SyntaxKind :: PLUS } ; [-] => { $ crate :: SyntaxKind :: MINUS } ; [*] => { $ crate :: SyntaxKind :: MUL } ; [/] => { $ crate :: SyntaxKind :: DIV } ; [%] => { $ crate :: SyntaxKind :: MODULO } ; [!] => { $ crate :: SyntaxKind :: NOT } ; [~] => { $ crate :: SyntaxKind :: BIT_NOT } ; ['['] => { $ crate :: SyntaxKind :: L_BRACK } ; [']'] => { $ crate :: SyntaxKind :: R_BRACK } ; ['('] => { $ crate :: SyntaxKind :: L_PAREN } ; [')'] => { $ crate :: SyntaxKind :: R_PAREN } ; ['{'] => { $ crate :: SyntaxKind :: L_BRACE } ; ['}'] => { $ crate :: SyntaxKind :: R_BRACE } ; [:] => { $ crate :: SyntaxKind :: COLON } ; [::] => { $ crate :: SyntaxKind :: COLONCOLON } ; [:::] => { $ crate :: SyntaxKind :: COLONCOLONCOLON } ; [;] => { $ crate :: SyntaxKind :: SEMI } ; [.] => { $ crate :: SyntaxKind :: DOT } ; [...] => { $ crate :: SyntaxKind :: DOTDOTDOT } ; [,] => { $ crate :: SyntaxKind :: COMMA } ; ['$'] => { $ crate :: SyntaxKind :: DOLLAR } ; [=] => { $ crate :: SyntaxKind :: ASSIGN } ; [?] => { $ crate :: SyntaxKind :: QUESTION_MARK } ; ["$intrinsicThisFile"] => { $ crate :: SyntaxKind :: INTRINSIC_THIS_FILE } ; ["$intrinsicId"] => { $ crate :: SyntaxKind :: INTRINSIC_ID } ; ["$intrinsic"] => { $ crate :: SyntaxKind :: INTRINSIC } ; [tailstrict] => { $ crate :: SyntaxKind :: TAILSTRICT_KW } ; [importstr] => { $ crate :: SyntaxKind :: IMPORTSTR_KW } ; [importbin] => { $ crate :: SyntaxKind :: IMPORTBIN_KW } ; [import] => { $ crate :: SyntaxKind :: IMPORT_KW } ; [local] => { $ crate :: SyntaxKind :: LOCAL_KW } ; [if] => { $ crate :: SyntaxKind :: IF_KW } ; [then] => { $ crate :: SyntaxKind :: THEN_KW } ; [else] => { $ crate :: SyntaxKind :: ELSE_KW } ; [function] => { $ crate :: SyntaxKind :: FUNCTION_KW } ; [error] => { $ crate :: SyntaxKind :: ERROR_KW } ; [in] => { $ crate :: SyntaxKind :: IN_KW } ; [null] => { $ crate :: SyntaxKind :: NULL_KW } ; [true] => { $ crate :: SyntaxKind :: TRUE_KW } ; [false] => { $ crate :: SyntaxKind :: FALSE_KW } ; [self] => { $ crate :: SyntaxKind :: SELF_KW } ; [super] => { $ crate :: SyntaxKind :: SUPER_KW } ; [for] => { $ crate :: SyntaxKind :: FOR_KW } ; [assert] => { $ crate :: SyntaxKind :: ASSERT_KW } ; [lifetime_ident] => { $ crate :: SyntaxKind :: LIFETIME_IDENT } ; [ident] => { $ crate :: SyntaxKind :: IDENT } ; [shebang] => { $ crate :: SyntaxKind :: SHEBANG } ; }
+pub use T;
addedcrates/jrsonnet-rowan-parser/src/generated/tokens.rsdiffbeforeafterboth
--- /dev/null
+++ b/crates/jrsonnet-rowan-parser/src/generated/tokens.rs
@@ -0,0 +1,155 @@
+//! This is a generated file, please do not edit manually. Changes can be
+//! made in codegeneration that lives in `xtask` top-level dir.
+
+use crate::{
+	ast::AstToken,
+	SyntaxKind::{self, *},
+	SyntaxToken,
+};
+
+#[derive(Debug, Clone, PartialEq, Eq, Hash)]
+pub struct Whitespace {
+	pub(crate) syntax: SyntaxToken,
+}
+impl std::fmt::Display for Whitespace {
+	fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result {
+		std::fmt::Display::fmt(&self.syntax, f)
+	}
+}
+impl AstToken for Whitespace {
+	fn can_cast(kind: SyntaxKind) -> bool { kind == WHITESPACE }
+	fn cast(syntax: SyntaxToken) -> Option<Self> {
+		if Self::can_cast(syntax.kind()) {
+			Some(Self { syntax })
+		} else {
+			None
+		}
+	}
+	fn syntax(&self) -> &SyntaxToken { &self.syntax }
+}
+
+#[derive(Debug, Clone, PartialEq, Eq, Hash)]
+pub struct Comment {
+	pub(crate) syntax: SyntaxToken,
+}
+impl std::fmt::Display for Comment {
+	fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result {
+		std::fmt::Display::fmt(&self.syntax, f)
+	}
+}
+impl AstToken for Comment {
+	fn can_cast(kind: SyntaxKind) -> bool { kind == COMMENT }
+	fn cast(syntax: SyntaxToken) -> Option<Self> {
+		if Self::can_cast(syntax.kind()) {
+			Some(Self { syntax })
+		} else {
+			None
+		}
+	}
+	fn syntax(&self) -> &SyntaxToken { &self.syntax }
+}
+
+#[derive(Debug, Clone, PartialEq, Eq, Hash)]
+pub struct String {
+	pub(crate) syntax: SyntaxToken,
+}
+impl std::fmt::Display for String {
+	fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result {
+		std::fmt::Display::fmt(&self.syntax, f)
+	}
+}
+impl AstToken for String {
+	fn can_cast(kind: SyntaxKind) -> bool { kind == STRING }
+	fn cast(syntax: SyntaxToken) -> Option<Self> {
+		if Self::can_cast(syntax.kind()) {
+			Some(Self { syntax })
+		} else {
+			None
+		}
+	}
+	fn syntax(&self) -> &SyntaxToken { &self.syntax }
+}
+
+#[derive(Debug, Clone, PartialEq, Eq, Hash)]
+pub struct StringVerbantim {
+	pub(crate) syntax: SyntaxToken,
+}
+impl std::fmt::Display for StringVerbantim {
+	fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result {
+		std::fmt::Display::fmt(&self.syntax, f)
+	}
+}
+impl AstToken for StringVerbantim {
+	fn can_cast(kind: SyntaxKind) -> bool { kind == STRING_VERBANTIM }
+	fn cast(syntax: SyntaxToken) -> Option<Self> {
+		if Self::can_cast(syntax.kind()) {
+			Some(Self { syntax })
+		} else {
+			None
+		}
+	}
+	fn syntax(&self) -> &SyntaxToken { &self.syntax }
+}
+
+#[derive(Debug, Clone, PartialEq, Eq, Hash)]
+pub struct StringBlock {
+	pub(crate) syntax: SyntaxToken,
+}
+impl std::fmt::Display for StringBlock {
+	fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result {
+		std::fmt::Display::fmt(&self.syntax, f)
+	}
+}
+impl AstToken for StringBlock {
+	fn can_cast(kind: SyntaxKind) -> bool { kind == STRING_BLOCK }
+	fn cast(syntax: SyntaxToken) -> Option<Self> {
+		if Self::can_cast(syntax.kind()) {
+			Some(Self { syntax })
+		} else {
+			None
+		}
+	}
+	fn syntax(&self) -> &SyntaxToken { &self.syntax }
+}
+
+#[derive(Debug, Clone, PartialEq, Eq, Hash)]
+pub struct Number {
+	pub(crate) syntax: SyntaxToken,
+}
+impl std::fmt::Display for Number {
+	fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result {
+		std::fmt::Display::fmt(&self.syntax, f)
+	}
+}
+impl AstToken for Number {
+	fn can_cast(kind: SyntaxKind) -> bool { kind == NUMBER }
+	fn cast(syntax: SyntaxToken) -> Option<Self> {
+		if Self::can_cast(syntax.kind()) {
+			Some(Self { syntax })
+		} else {
+			None
+		}
+	}
+	fn syntax(&self) -> &SyntaxToken { &self.syntax }
+}
+
+#[derive(Debug, Clone, PartialEq, Eq, Hash)]
+pub struct Ident {
+	pub(crate) syntax: SyntaxToken,
+}
+impl std::fmt::Display for Ident {
+	fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result {
+		std::fmt::Display::fmt(&self.syntax, f)
+	}
+}
+impl AstToken for Ident {
+	fn can_cast(kind: SyntaxKind) -> bool { kind == IDENT }
+	fn cast(syntax: SyntaxToken) -> Option<Self> {
+		if Self::can_cast(syntax.kind()) {
+			Some(Self { syntax })
+		} else {
+			None
+		}
+	}
+	fn syntax(&self) -> &SyntaxToken { &self.syntax }
+}
addedcrates/jrsonnet-rowan-parser/src/language.rsdiffbeforeafterboth
--- /dev/null
+++ b/crates/jrsonnet-rowan-parser/src/language.rs
@@ -0,0 +1,24 @@
+use rowan::Language;
+
+use crate::SyntaxKind;
+
+#[derive(Debug, Clone, Copy, PartialEq, Eq, PartialOrd, Ord, Hash)]
+pub enum JsonnetLanguage {}
+impl Language for JsonnetLanguage {
+	type Kind = SyntaxKind;
+
+	fn kind_from_raw(raw: rowan::SyntaxKind) -> SyntaxKind {
+		SyntaxKind::from_raw(raw.0)
+	}
+
+	fn kind_to_raw(kind: SyntaxKind) -> rowan::SyntaxKind {
+		rowan::SyntaxKind(kind.into_raw())
+	}
+}
+
+pub type SyntaxNode = rowan::SyntaxNode<JsonnetLanguage>;
+pub type SyntaxToken = rowan::SyntaxToken<JsonnetLanguage>;
+pub type SyntaxElement = rowan::SyntaxElement<JsonnetLanguage>;
+pub type SyntaxNodeChildren = rowan::SyntaxNodeChildren<JsonnetLanguage>;
+pub type SyntaxElementChildren = rowan::SyntaxElementChildren<JsonnetLanguage>;
+pub type PreorderWithTokens = rowan::api::PreorderWithTokens<JsonnetLanguage>;
modifiedcrates/jrsonnet-rowan-parser/src/lex.rsdiffbeforeafterboth
--- a/crates/jrsonnet-rowan-parser/src/lex.rs
+++ b/crates/jrsonnet-rowan-parser/src/lex.rs
@@ -1,249 +1,41 @@
-use crate::string_block::lex_str_block_test;
 use core::ops::Range;
-use logos::Logos;
-use rowan::{Checkpoint, TextRange, TextSize};
-use std::{convert::TryFrom, iter::Peekable};
-
-#[derive(Logos, Debug, PartialEq, Hash, Eq, PartialOrd, Ord, Clone, Copy)]
-#[repr(u16)]
-pub enum SyntaxKind {
-	#[token("assert")]
-	KeywordAssert = 0,
-
-	#[token("else")]
-	KeywordElse,
-
-	#[token("error")]
-	KeywordError,
-
-	#[token("false")]
-	KeywordFalse,
-
-	#[token("for")]
-	KeywordFor,
-
-	#[token("function")]
-	KeywordFunction,
-
-	#[token("if")]
-	KeywordIf,
-
-	#[token("import")]
-	KeywordImport,
-
-	#[token("importstr")]
-	KeywordImportStr,
-
-	#[token("local")]
-	KeywordLocal,
-
-	#[token("null")]
-	KeywordNull,
-
-	#[token("tailstrict")]
-	KeywordTailStrict,
-
-	#[token("then")]
-	KeywordThen,
-
-	#[token("self")]
-	KeywordSelf,
-
-	#[token("super")]
-	KeywordSuper,
-
-	#[token("true")]
-	KeywordTrue,
-
-	#[regex(r"[_a-zA-Z][_a-zA-Z0-9]*")]
-	Ident,
-
-	#[regex(r"(?:0|[1-9][0-9]*)(?:\.[0-9]+)?(?:[eE][+-]?[0-9]+)?")]
-	Number,
-
-	#[regex(r"(?:0|[1-9][0-9]*)\.[^0-9]")]
-	ErrorNumJunkAfterDecimalPoint,
-
-	#[regex(r"(?:0|[1-9][0-9]*)(?:\.[0-9]+)?[eE][^+\-0-9]")]
-	ErrorNumJunkAfterExponent,
-
-	#[regex(r"(?:0|[1-9][0-9]*)(?:\.[0-9]+)?[eE][+-][^0-9]")]
-	ErrorNumJunkAfterExponentSign,
-
-	#[token("{")]
-	SymbolLeftBrace,
-
-	#[token("}")]
-	SymbolRightBrace,
-
-	#[token("[")]
-	SymbolLeftBracket,
-
-	#[token("]")]
-	SymbolRightBracket,
-
-	#[token(",")]
-	SymbolComma,
-
-	#[token(".")]
-	SymbolDot,
-
-	#[token("(")]
-	LParen,
-
-	#[token(")")]
-	RParen,
-
-	#[token(";")]
-	SymbolSemi,
-	#[token(":")]
-	SymbolColon,
-
-	#[token("$")]
-	SymbolDollar,
-
-	#[token("*")]
-	OpMul,
-	#[token("/")]
-	OpDiv,
-	#[token("%")]
-	OpMod,
-	#[token("+")]
-	OpPlus,
-	#[token("-")]
-	OpMinus,
-	#[token("<<")]
-	OpShiftLeft,
-	#[token(">>")]
-	OpShiftRight,
-	#[token("<")]
-	OpLessThan,
-	#[token(">")]
-	OpGreaterThan,
-	#[token("<=")]
-	OpLessThanOrEqual,
-	#[token(">=")]
-	OpGreaterThanOrEqual,
-	#[token("==")]
-	OpEqual,
-	#[token("!=")]
-	OpNotEqual,
-	#[token("&")]
-	OpBitAnd,
-	#[token("^")]
-	OpBitXor,
-	#[token("|")]
-	OpBitOr,
-	#[token("&&")]
-	OpAnd,
-	#[token("||")]
-	OpOr,
-	#[token("in")]
-	OpIn,
-	#[token("!")]
-	OpNot,
-	#[token("~")]
-	OpBitNegate,
-	#[token("=")]
-	SymbolAssign,
+use std::convert::TryFrom;
 
-	#[regex("\"(?s:[^\"\\\\]|\\\\.)*\"")]
-	StringDoubleQuoted,
+use logos::Logos;
+use rowan::{TextRange, TextSize};
 
-	#[regex("'(?s:[^'\\\\]|\\\\.)*'")]
-	StringSingleQuoted,
-
-	#[regex("@\"(?:[^\"]|\"\")*\"")]
-	StringDoubleVerbatim,
-
-	#[regex("@'(?:[^']|'')*'")]
-	StringSingleVerbatim,
-
-	#[regex(r"\|\|\|", lex_str_block_test)]
-	StringBlock, //(StringBlockToken),
-
-	#[regex("\"(?s:[^\"\\\\]|\\\\.)*")]
-	ErrorStringDoubleQuotedUnterminated,
-
-	#[regex("'(?s:[^'\\\\]|\\\\.)*")]
-	ErrorStringSingleQuotedUnterminated,
-
-	#[regex("@\"(?:[^\"]|\"\")*")]
-	ErrorStringDoubleVerbatimUnterminated,
-
-	#[regex("@'(?:[^']|'')*")]
-	ErrorStringSingleVerbatimUnterminated,
-
-	#[regex("@[^\"'\\s]\\S+")]
-	ErrorStringMissingQuotes,
-
-	#[token("/*/")]
-	ErrorCommentTooShort,
-
-	#[regex(r"/\*([^*]|\*[^/])+")]
-	ErrorCommentUnterminated,
-
-	#[regex(r"[ \t\n\r]+")]
-	Whitespace,
-
-	#[regex(r"//[^\r\n]*(\r\n|\n)?")]
-	SingelLineSlashComment,
-
-	#[regex(r"#[^\r\n]*(\r\n|\n)?")]
-	SingleLineHashComment,
-
-	#[regex(r"/\*([^*]|\*[^/])*\*/")]
-	MultiLineComment,
-
-	#[error]
-	Error,
-
-	ErrorPositionalAfterNamed,
-
-	Literal,
-	Expr,
-	Array,
-	ArrayElem,
-	Object,
-	Field,
-
-	CompspecFor,
-	CompspecIf,
-
-	Slice,
-	FieldAccess,
-	ObjectApply,
-	FunctionCall,
-	FunctionDef,
-	BodyDef,
-
-	BinOp,
-	UnaryOp,
-	Local,
-	ExprError,
-	ExprAssert,
-	ExprImport,
-
-	DefParam,
-	DefParams,
-
-	DefArgs,
-	DefNamedArg,
-	DefPositionalArg,
-
-	Parened,
+use crate::SyntaxKind;
 
-	Root,
-}
-
 impl SyntaxKind {
 	pub fn is_trivia(self) -> bool {
 		matches!(
 			self,
-			Self::Whitespace
-				| Self::MultiLineComment
-				| Self::SingelLineSlashComment
-				| Self::SingleLineHashComment
+			Self::WHITESPACE
+				| Self::MULTI_LINE_COMMENT
+				| Self::SINGLE_LINE_HASH_COMMENT
+				| Self::SINGLE_LINE_SLASH_COMMENT
+		)
+	}
+	pub fn is_string(self) -> bool {
+		matches!(
+			self,
+			Self::STRING_SINGLE
+				| Self::STRING_DOUBLE
+				| Self::STRING_SINGLE_VERBATIM
+				| Self::STRING_DOUBLE_VERBATIM
+				| Self::STRING_BLOCK
+		)
+	}
+	pub fn is_number(self) -> bool {
+		matches!(self, Self::NUMBER)
+	}
+	pub fn is_literal(self) -> bool {
+		matches!(
+			self,
+			Self::NULL_KW
+				| Self::TRUE_KW | Self::FALSE_KW
+				| Self::SELF_KW | Self::DOLLAR
+				| Self::SUPER_KW
 		)
 	}
 }
@@ -291,25 +83,4 @@
 
 pub fn lex(input: &str) -> Vec<Lexeme<'_>> {
 	Lexer::new(input).collect()
-}
-
-impl From<SyntaxKind> for rowan::SyntaxKind {
-	fn from(kind: SyntaxKind) -> Self {
-		Self(kind as u16)
-	}
-}
-
-use SyntaxKind::*;
-
-#[derive(Debug, Clone, Copy, PartialEq, Eq, PartialOrd, Ord, Hash)]
-pub enum Lang {}
-impl rowan::Language for Lang {
-	type Kind = SyntaxKind;
-	fn kind_from_raw(raw: rowan::SyntaxKind) -> Self::Kind {
-		assert!(raw.0 <= Root as u16);
-		unsafe { std::mem::transmute::<u16, SyntaxKind>(raw.0) }
-	}
-	fn kind_to_raw(kind: Self::Kind) -> rowan::SyntaxKind {
-		kind.into()
-	}
 }
modifiedcrates/jrsonnet-rowan-parser/src/lib.rsdiffbeforeafterboth
--- a/crates/jrsonnet-rowan-parser/src/lib.rs
+++ b/crates/jrsonnet-rowan-parser/src/lib.rs
@@ -1,139 +1,20 @@
 #![deny(unused_must_use)]
 
+mod ast;
 mod binary;
 mod event;
+mod generated;
+mod language;
 mod lex;
 mod marker;
 mod parser;
 mod string_block;
+mod tests;
 mod token_set;
 mod unary;
-
-#[cfg(test)]
-mod tests {
-	use miette::{Diagnostic, GraphicalReportHandler, LabeledSpan};
-	use thiserror::Error;
 
-	use crate::parser::parse;
-
-	#[derive(Debug, Error)]
-	#[error("syntax error")]
-	struct MyDiagnostic {
-		code: String,
-		spans: Vec<LabeledSpan>,
-	}
-	impl Diagnostic for MyDiagnostic {
-		fn code<'a>(&'a self) -> Option<Box<dyn std::fmt::Display + 'a>> {
-			None
-		}
-
-		fn severity(&self) -> Option<miette::Severity> {
-			None
-		}
-
-		fn help<'a>(&'a self) -> Option<Box<dyn std::fmt::Display + 'a>> {
-			None
-		}
-
-		fn url<'a>(&'a self) -> Option<Box<dyn std::fmt::Display + 'a>> {
-			None
-		}
-
-		fn source_code(&self) -> Option<&dyn miette::SourceCode> {
-			Some(&self.code)
-		}
-
-		fn labels(&self) -> Option<Box<dyn Iterator<Item = miette::LabeledSpan> + '_>> {
-			Some(Box::new(self.spans.clone().into_iter()))
-		}
-
-		fn related<'a>(&'a self) -> Option<Box<dyn Iterator<Item = &'a dyn Diagnostic> + 'a>> {
-			None
-		}
-	}
-
-	fn process(text: &str) -> String {
-		use std::fmt::Write;
-		let mut out = String::new();
-		let node = parse(text);
-		write!(out, "{:#?}", node.syntax()).unwrap();
-		if !node.errors.is_empty() && !text.is_empty() {
-			writeln!(out, "===").unwrap();
-			for err in &node.errors {
-				writeln!(out, "{:?}", err).unwrap();
-			}
-			let diag = MyDiagnostic {
-				code: text.to_string(),
-				spans: node.errors.into_iter().map(|e| e.into()).collect(),
-			};
-
-			let handler = GraphicalReportHandler::new();
-
-			write!(out, "===").unwrap();
-			handler.render_report(&mut out, &diag).unwrap();
-		}
-		out
-	}
-	macro_rules! mk_test {
-		($($name:ident => $test:expr)+) => {$(
-			#[test]
-			fn $name() {
-				let src = indoc::indoc!($test);
-				let result = process(&src);
-				insta::assert_snapshot!(stringify!($name), result, src);
-
-			}
-		)+};
-	}
-	mk_test!(
-		empty => r#" "#
-		function => r#"
-			function(a, b = 1) a + b
-		"#
-		function_error_no_value => r#"
-			function(a, b = ) a + b
-		"#
-		function_error_rparen => r#"
-			function(a, b
-		"#
-		function_error_body => r#"
-			function(a, b)
-		"#
-		local_novalue => r#"
-			local a =
-		"#
-		local_no_value_recovery => r#"
-			local a =
-			local b = 3;
-			1
-		"#
-
-		array_comp => r#"
-			[a for a in [1, 2, 3]]
-		"#
-		array_comp_incompatible_with_multiple_elems => r#"
-			[a for a in [1, 2, 3], b]
-		"#
-
-		no_rhs => r#"
-			a +
-		"#
-		no_lhs => r#"
-			+ 2
-		"#
-		no_operator => "
-			2 2
-		"
-
-		named_before_positional => "
-			a(1, 2, b=4, 3, 5, k = 12, 6)
-		"
-
-		wrong_field_end => "
-			{
-				a: 1;
-				b: 2;
-			}
-		"
-	);
-}
+pub use generated::syntax_kinds::SyntaxKind;
+pub use language::{
+	JsonnetLanguage, PreorderWithTokens, SyntaxElement, SyntaxElementChildren, SyntaxNode,
+	SyntaxNodeChildren, SyntaxToken,
+};
modifiedcrates/jrsonnet-rowan-parser/src/marker.rsdiffbeforeafterboth
--- a/crates/jrsonnet-rowan-parser/src/marker.rs
+++ b/crates/jrsonnet-rowan-parser/src/marker.rs
@@ -1,7 +1,7 @@
 use drop_bomb::DropBomb;
 use rowan::TextRange;
 
-use crate::{event::Event, lex::SyntaxKind, parser::Parser};
+use crate::{event::Event, parser::Parser, SyntaxKind};
 
 pub struct Ranger {
 	pub pos: usize,
modifiedcrates/jrsonnet-rowan-parser/src/parser.rsdiffbeforeafterboth
--- a/crates/jrsonnet-rowan-parser/src/parser.rs
+++ b/crates/jrsonnet-rowan-parser/src/parser.rs
@@ -1,32 +1,19 @@
-use std::cell::Cell;
-use std::fmt::Display;
-use std::rc::Rc;
+use std::{cell::Cell, fmt::Display, rc::Rc};
 
-use miette::Diagnostic;
-use miette::LabeledSpan;
-use miette::SourceOffset;
-use miette::SourceSpan;
-use rowan::GreenNode;
+use miette::{LabeledSpan, SourceOffset, SourceSpan};
+use rowan::{GreenNode, TextRange, TextSize};
 
-use rowan::TextRange;
-use rowan::TextSize;
-use thiserror::Error;
-
-use crate::binary::BinaryOperator;
-use crate::event::Event;
-use crate::event::Sink;
-use crate::lex::lex;
-use crate::lex::Lang;
-use crate::lex::Lexeme;
-use crate::lex::SyntaxKind;
-use crate::lex::SyntaxKind::*;
-use crate::marker::AsRange;
-use crate::marker::CompletedMarker;
-use crate::marker::FinishedRanger;
-use crate::marker::Marker;
-use crate::marker::Ranger;
-use crate::token_set::TokenSet;
-use crate::unary::UnaryOperator;
+use crate::{
+	binary::BinaryOperator,
+	event::{Event, Sink},
+	lex::{lex, Lexeme},
+	marker::{AsRange, CompletedMarker, Marker, Ranger},
+	token_set::SyntaxKindSet,
+	unary::UnaryOperator,
+	SyntaxKind,
+	SyntaxKind::*,
+	SyntaxNode, T, TS,
+};
 
 pub struct Parse {
 	pub green_node: GreenNode,
@@ -58,13 +45,7 @@
 	expected_syntax_tracking_state: Rc<Cell<ExpectedSyntaxTrackingState>>,
 }
 
-const DEFAULT_RECOVERY_SET: TokenSet = TokenSet::new(&[
-	SymbolSemi,
-	RParen,
-	SymbolRightBracket,
-	SymbolRightBrace,
-	KeywordLocal,
-]);
+const DEFAULT_RECOVERY_SET: SyntaxKindSet = TS![; ')' ']' '}' local];
 
 #[derive(Clone, Debug, PartialEq, Eq)]
 pub enum SyntaxError {
@@ -172,16 +153,20 @@
 			let end = ranger.finish(&self);
 			self.custom_error(end, "unexpected input after expression");
 		}
-		m.complete(&mut self, Root);
+		m.complete(&mut self, SOURCE_FILE);
 
 		self.events
 	}
 
 	pub(crate) fn expect(&mut self, kind: SyntaxKind) {
-		self.expect_with_recovery_set(kind, TokenSet::default())
+		self.expect_with_recovery_set(kind, TS![])
 	}
 
-	pub(crate) fn expect_with_recovery_set(&mut self, kind: SyntaxKind, recovery_set: TokenSet) {
+	pub(crate) fn expect_with_recovery_set(
+		&mut self,
+		kind: SyntaxKind,
+		recovery_set: SyntaxKindSet,
+	) {
 		if self.at(kind) {
 			self.bump();
 		} else {
@@ -239,17 +224,17 @@
 	}
 	pub(crate) fn error_with_recovery_set(
 		&mut self,
-		recovery_set: TokenSet,
+		recovery_set: SyntaxKindSet,
 	) -> Option<CompletedMarker> {
 		self.error_with_recovery_set_no_default(recovery_set.union(DEFAULT_RECOVERY_SET))
 	}
 	pub fn error_with_no_skip(&mut self) -> Option<CompletedMarker> {
-		self.error_with_recovery_set_no_default(TokenSet::ALL)
+		self.error_with_recovery_set_no_default(SyntaxKindSet::ALL)
 	}
 
 	pub fn error_with_recovery_set_no_default(
 		&mut self,
-		recovery_set: TokenSet,
+		recovery_set: SyntaxKindSet,
 	) -> Option<CompletedMarker> {
 		let expected_syntax = self.expected_syntax.take().unwrap();
 		self.expected_syntax_tracking_state
@@ -280,7 +265,7 @@
 
 		let m = self.start();
 		self.bump();
-		Some(m.complete(self, SyntaxKind::Error))
+		Some(m.complete(self, SyntaxKind::ERROR))
 	}
 
 	fn bump(&mut self) {
@@ -323,7 +308,7 @@
 		}
 		self.peek() == Some(kind)
 	}
-	pub fn at_set(&mut self, set: TokenSet) -> bool {
+	pub fn at_set(&mut self, set: SyntaxKindSet) -> bool {
 		self.peek().map_or(false, |k| set.contains(k))
 	}
 	pub fn at_end(&mut self) -> bool {
@@ -356,7 +341,7 @@
 }
 macro_rules! at_match {
 	($p:ident {
-		$($r:ident => $e:expr,)*
+		$($r:expr => $e:expr,)*
 		_ => $else:expr $(,)?
 	}) => {{
 		$(
@@ -375,26 +360,26 @@
 
 	loop {
 		let op = at_match!(p {
-			OpMul => BinaryOperator::Mul,
-			OpDiv => BinaryOperator::Div,
-			OpMod => BinaryOperator::Mod,
-			OpPlus => BinaryOperator::Plus,
-			OpMinus => BinaryOperator::Minus,
-			OpShiftLeft => BinaryOperator::ShiftLeft,
-			OpShiftRight => BinaryOperator::ShiftRight,
-			OpLessThan => BinaryOperator::LessThan,
-			OpGreaterThan => BinaryOperator::GreaterThan,
-			OpLessThanOrEqual => BinaryOperator::LessThanOrEqual,
-			OpGreaterThanOrEqual => BinaryOperator::GreaterThanOrEqual,
-			OpEqual => BinaryOperator::Equal,
-			OpNotEqual => BinaryOperator::NotEqual,
-			OpBitAnd => BinaryOperator::BitAnd,
-			OpBitXor => BinaryOperator::BitXor,
-			OpBitOr => BinaryOperator::BitOr,
-			OpAnd => BinaryOperator::And,
-			OpOr => BinaryOperator::Or,
-			OpIn => BinaryOperator::In,
-			SymbolLeftBrace => BinaryOperator::ObjectApply,
+			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,
 		});
 		let (left_binding_power, right_binding_power) = op.binding_power();
@@ -412,9 +397,9 @@
 		lhs = m.complete(
 			p,
 			if op == BinaryOperator::ObjectApply {
-				ObjectApply
+				EXPR_OBJ_EXTEND
 			} else {
-				BinOp
+				EXPR_BINARY
 			},
 		);
 
@@ -425,37 +410,37 @@
 	Some(lhs)
 }
 fn compspec(p: &mut Parser) {
-	assert!(p.at(KeywordFor) || p.at(KeywordIf));
-	if p.at(KeywordFor) {
+	assert!(p.at(T![for]) || p.at(T![if]));
+	if p.at(T![for]) {
 		let m = p.start();
 		p.bump();
-		p.expect(Ident);
-		p.expect(OpIn);
+		p.expect(IDENT);
+		p.expect(T![in]);
 		expr(p);
-		m.complete(p, CompspecFor);
-	} else if p.at(KeywordIf) {
+		m.complete(p, FOR_SPEC);
+	} else if p.at(T![in]) {
 		let m = p.start();
 		p.bump();
 		expr(p);
-		m.complete(p, CompspecIf);
+		m.complete(p, IF_SPEC);
 	} else {
 		unreachable!()
 	}
 }
 fn comma(p: &mut Parser) -> bool {
-	if p.at(SymbolComma) {
+	if p.at(T![,]) {
 		p.bump();
 		true
 	} else {
 		false
 	}
 }
-fn comma_with_alternatives(p: &mut Parser, set: TokenSet) -> bool {
-	if p.at(SymbolComma) {
+fn comma_with_alternatives(p: &mut Parser, set: SyntaxKindSet) -> bool {
+	if p.at(T![,]) {
 		p.bump();
 		true
 	} else if p.at_set(set) {
-		p.expect_with_no_skip(SymbolComma);
+		p.expect_with_no_skip(T![,]);
 		p.bump();
 		true
 	} else {
@@ -464,94 +449,94 @@
 }
 fn field_name(p: &mut Parser) {
 	let _e = p.expected_syntax_name("field name");
-	if p.at(SymbolLeftBracket) {
+	if p.at(T!['[']) {
 		p.bump();
 		expr(p);
-		p.expect(SymbolRightBracket);
-	} else if p.at(Ident) {
+		p.expect(T![']']);
+	} else if p.at(IDENT) {
 		p.bump()
 	} else {
-		p.error_with_recovery_set(TokenSet::new(&[SymbolSemi]));
+		p.error_with_recovery_set(TS![;]);
 	}
 }
 fn object(p: &mut Parser) -> CompletedMarker {
-	assert!(p.at(SymbolLeftBrace));
+	assert!(p.at(T!['{']));
 	let m = p.start();
 	p.bump();
 
 	loop {
-		if p.at(SymbolRightBrace) {
+		if p.at(T!['}']) {
 			p.bump();
 			break;
 		}
 		let m = p.start();
 		field_name(p);
-		p.expect(SymbolColon);
+		p.expect(T![,]);
 		expr(p);
-		while p.at(KeywordFor) || p.at(KeywordIf) {
+		while p.at(T![for]) || p.at(T![if]) {
 			compspec(p)
 		}
-		m.complete(p, Field);
-		if comma_with_alternatives(p, TokenSet::new(&[SymbolAssign])) {
+		m.complete(p, MEMBER);
+		if comma_with_alternatives(p, SyntaxKindSet::new(&[T![=]])) {
 			continue;
 		}
-		p.expect(SymbolRightBrace);
+		p.expect(R_BRACE);
 		break;
 	}
 
-	m.complete(p, Object)
+	m.complete(p, OBJ_BODY)
 }
 
 fn params(p: &mut Parser) -> CompletedMarker {
-	assert!(p.at(LParen));
+	assert!(p.at(T!['(']));
 	let m = p.start();
 	p.bump();
 
 	loop {
-		if p.at(RParen) {
+		if p.at(T![')']) {
 			p.bump();
 			break;
 		}
 		let m = p.start();
-		p.expect(Ident);
-		if p.at(SymbolAssign) {
+		p.expect(IDENT);
+		if p.at(T![=]) {
 			p.bump();
 			expr(p);
 		}
-		m.complete(p, DefParam);
+		m.complete(p, PARAM);
 		if comma(p) {
 			continue;
 		}
-		p.expect(RParen);
+		p.expect(T![')']);
 		break;
 	}
 
-	m.complete(p, DefParams)
+	m.complete(p, PARAMS_DESC)
 }
 fn args(p: &mut Parser) {
-	assert!(p.at(LParen));
+	assert!(p.at(T!['(']));
 	p.bump();
 
 	let mut error_positional_start = None::<Marker>;
 	let mut started_named = Cell::new(false);
 	let mut on_positional = |p: &mut Parser, m: Marker| {
-		let c = m.complete(p, DefPositionalArg);
+		let c = m.complete(p, ARG);
 		if started_named.get() && error_positional_start.is_none() {
 			error_positional_start = Some(c.precede(p));
 		}
 	};
 	loop {
-		if p.at(RParen) {
+		if p.at(T![')']) {
 			break;
 		}
 
 		let m = p.start();
-		if p.at(Ident) {
+		if p.at(IDENT) {
 			p.bump();
-			if p.at(SymbolAssign) {
+			if p.at(T![=]) {
 				p.bump();
 				expr(p);
-				m.complete(p, DefNamedArg);
+				m.complete(p, ARG);
 				started_named.set(true);
 			} else {
 				on_positional(p, m);
@@ -566,14 +551,14 @@
 		break;
 	}
 	if let Some(error_positional_start) = error_positional_start {
-		let c = error_positional_start.complete(p, ErrorPositionalAfterNamed);
+		let c = error_positional_start.complete(p, ERROR);
 		p.custom_error(c, "positional arguments can't be placed after named")
 	}
-	p.expect(RParen);
+	p.expect(T![')']);
 }
 
 fn array(p: &mut Parser) -> CompletedMarker {
-	assert!(p.at(SymbolLeftBracket));
+	assert!(p.at(T!['[']));
 	// Start the list node
 	let m = p.start();
 	p.bump(); // '['
@@ -583,31 +568,25 @@
 	let mut elems = 0;
 
 	loop {
-		if p.at(SymbolRightBracket) {
+		if p.at(T![']']) {
 			p.bump();
 			break;
 		}
 		elems += 1;
-		let m = p.start();
-		{
-			let m = p.start();
-			expr(p);
-			m.complete(p, BodyDef);
-		}
+		expr(p);
 		let c = p.start_ranger();
 		let mut had_spec = false;
-		while p.at(KeywordFor) || p.at(KeywordIf) {
+		while p.at(T![for]) || p.at(T![if]) {
 			had_spec = true;
 			compspec(p)
 		}
 		if had_spec {
 			compspecs.push(c.finish(p));
 		}
-		m.complete(p, ArrayElem);
 		if comma(p) {
 			continue;
 		}
-		p.expect(SymbolRightBracket);
+		p.expect(T![']']);
 		break;
 	}
 
@@ -618,47 +597,51 @@
 				"compspec may only be used if there is only one array element",
 			)
 		}
-	}
 
-	m.complete(p, Array)
+		m.complete(p, EXPR_ARRAY)
+	} else if !compspecs.is_empty() {
+		m.complete(p, EXPR_ARRAY_COMP)
+	} else {
+		m.complete(p, EXPR_ARRAY)
+	}
 }
 
 fn lhs(p: &mut Parser) -> Option<CompletedMarker> {
 	let mut lhs = lhs_basic(p)?;
 
 	loop {
-		if p.at(SymbolDot) {
+		if p.at(T![.]) {
 			let m = lhs.precede(p);
 			p.bump();
-			p.expect(Ident);
-			lhs = m.complete(p, FieldAccess);
-		} else if p.at(SymbolLeftBracket) {
+			p.expect(IDENT);
+			lhs = m.complete(p, EXPR_INDEX);
+		} else if p.at(T!['[']) {
 			let m = lhs.precede(p);
 			p.bump();
 			// Start
-			if !p.at(SymbolColon) {
+			if !p.at(T![:]) {
 				expr(p);
 			}
-			if p.at(SymbolColon) {
+			if p.at(T![:]) {
 				p.bump();
 				// End
-				if !p.at(SymbolRightBracket) && !p.at(SymbolColon) {
+				if !p.at(T![']']) && !p.at(T![:]) {
 					expr(p);
 				}
-				if p.at(SymbolColon) {
+				if p.at(T![:]) {
 					p.bump();
 					// Step
-					if !p.at(SymbolRightBracket) {
+					if !p.at(T![']']) {
 						expr(p);
 					}
 				}
 			}
-			p.expect(SymbolRightBracket);
-			lhs = m.complete(p, Slice);
-		} else if p.at(LParen) {
+			p.expect(T![']']);
+			lhs = m.complete(p, EXPR_SLICE);
+		} else if p.at(T!['(']) {
 			let m = lhs.precede(p);
 			args(p);
-			lhs = m.complete(p, FunctionCall);
+			lhs = m.complete(p, EXPR_APPLY);
 		} else {
 			break;
 		}
@@ -669,128 +652,104 @@
 
 fn lhs_basic(p: &mut Parser) -> Option<CompletedMarker> {
 	let _e = p.expected_syntax_name("value");
-	Some(
-		if p.at(Number)
-			|| p.at(StringSingleQuoted)
-			|| p.at(StringDoubleQuoted)
-			|| p.at(StringSingleVerbatim)
-			|| p.at(StringDoubleVerbatim)
-			|| p.at(StringBlock)
-			|| p.at(KeywordNull)
-			|| p.at(SymbolDollar)
-			|| p.at(KeywordSuper)
-			|| p.at(KeywordSelf)
-		{
-			let m = p.start();
-			p.bump();
-			m.complete(p, Literal)
-		} else if p.at(Ident) {
-			let m = p.start();
-			p.bump();
-			m.complete(p, Ident)
-		} else if p.at(SymbolLeftBracket) {
-			array(p)
-		} else if p.at(SymbolLeftBrace) {
-			object(p)
-		} else if p.at(KeywordLocal) {
-			let m = p.start();
-			p.bump();
-			let mut sus_local = None;
-			loop {
-				p.expect_with_recovery_set(
-					Ident,
-					TokenSet::new(&[SymbolAssign, SymbolSemi, KeywordLocal]),
-				);
-				if p.at(LParen) {
-					params(p);
-				}
+	Some(if p.peek().map(|l| l.is_literal()).unwrap_or(false) {
+		let m = p.start();
+		p.bump();
+		m.complete(p, EXPR_LITERAL)
+	} else if p.peek().map(|l| l.is_string()).unwrap_or(false) {
+		let m = p.start();
+		p.bump();
+		m.complete(p, EXPR_STRING)
+	} else if p.peek().map(|l| l.is_number()).unwrap_or(false) {
+		let m = p.start();
+		p.bump();
+		m.complete(p, EXPR_NUMBER)
+	} else if p.at(IDENT) {
+		let m = p.start();
+		p.bump();
+		m.complete(p, EXPR_VAR)
+	} else if p.at(T!['[']) {
+		array(p)
+	} else if p.at(T!['{']) {
+		object(p)
+	} else if p.at(T![local]) {
+		let m = p.start();
+		p.bump();
+		let mut sus_local = None;
+		loop {
+			p.expect_with_recovery_set(IDENT, TS![= ; local]);
+			if p.at(T!['(']) {
+				params(p);
+			}
 
-				let sus_local_candidate = p.start_ranger();
-				p.expect_with_recovery_set(
-					SymbolAssign,
-					TokenSet::new(&[SymbolSemi, KeywordLocal]),
-				);
+			let sus_local_candidate = p.start_ranger();
+			p.expect_with_recovery_set(T![=], TS![; local]);
 
-				sus_local = p.at(KeywordLocal).then(|| sus_local_candidate.finish(p));
-				expr(p);
+			sus_local = p.at(T![local]).then(|| sus_local_candidate.finish(p));
+			expr(p);
 
-				if !comma(p) {
-					break;
-				}
-			}
-			p.expect(SymbolSemi);
-			if let Some(sus_local) = sus_local {
-				if sus_local.had_error_since(p) {
-					p.custom_error(sus_local, "unusal local placement, missing ';' ?")
-				}
-			}
-			{
-				let m = p.start();
-				expr(p);
-				m.complete(p, BodyDef);
-			}
-			m.complete(p, Local)
-		} else if p.at(KeywordFunction) {
-			let m = p.start();
-			p.bump();
-			args(p);
-			{
-				let m = p.start();
-				expr(p);
-				m.complete(p, BodyDef);
+			if !comma(p) {
+				break;
 			}
-			m.complete(p, FunctionDef)
-		} else if p.at(KeywordError) {
-			let m = p.start();
-			p.bump();
-			expr(p);
-			m.complete(p, ExprError)
-		} else if p.at(KeywordAssert) {
-			let m = p.start();
-			p.bump();
-			expr(p);
-			if p.at(SymbolColon) {
-				p.bump();
-				expr(p);
+		}
+		p.expect(T![;]);
+		if let Some(sus_local) = sus_local {
+			if sus_local.had_error_since(p) {
+				p.custom_error(sus_local, "unusal local placement, missing ';' ?")
 			}
-			m.complete(p, ExprAssert)
-		} else if p.at(KeywordImport) || p.at(KeywordImportStr) {
-			let m = p.start();
+		}
+		expr(p);
+		m.complete(p, T![local])
+	} else if p.at(T![function]) {
+		let m = p.start();
+		p.bump();
+		args(p);
+		expr(p);
+		m.complete(p, EXPR_FUNCTION)
+	} else if p.at(T![error]) {
+		let m = p.start();
+		p.bump();
+		expr(p);
+		m.complete(p, EXPR_ERROR)
+	} else if p.at(T![assert]) {
+		let m = p.start();
+		p.bump();
+		expr(p);
+		if p.at(T![:]) {
 			p.bump();
 			expr(p);
-			m.complete(p, ExprImport)
-		} else if p.at(OpMinus) || p.at(OpNot) || p.at(OpBitNegate) {
-			let op = match p.peek().unwrap() {
-				OpMinus => UnaryOperator::Minus,
-				OpNot => UnaryOperator::Not,
-				OpBitNegate => UnaryOperator::BitNegate,
-				_ => unreachable!(),
-			};
-			let ((), right_binding_power) = op.binding_power();
+		}
+		m.complete(p, EXPR_ASSERT)
+	} else if p.at(T![import]) || p.at(T![importstr]) || p.at(T![importbin]) {
+		let m = p.start();
+		p.bump();
+		expr(p);
+		m.complete(p, EXPR_IMPORT)
+	} else if p.at(T![-]) || p.at(T![!]) || p.at(T![~]) {
+		let op = match p.peek().unwrap() {
+			T![-] => UnaryOperator::Minus,
+			T![!] => UnaryOperator::Not,
+			T![~] => UnaryOperator::BitNegate,
+			_ => unreachable!(),
+		};
+		let ((), right_binding_power) = op.binding_power();
 
-			let m = p.start();
-			p.bump();
-			expr_binding_power(p, right_binding_power);
-			m.complete(p, UnaryOp)
-		} else if p.at(LParen) {
-			let m = p.start();
-			p.bump();
-			expr(p);
-			assert!(p.at(RParen));
-			p.bump();
-			m.complete(p, Parened)
-		} else {
-			p.error_with_no_skip();
-			return None;
-		},
-	)
+		let m = p.start();
+		p.bump();
+		expr_binding_power(p, right_binding_power);
+		m.complete(p, EXPR_UNARY)
+	} else if p.at(T!['(']) {
+		let m = p.start();
+		p.bump();
+		expr(p);
+		assert!(p.at(T![')']));
+		p.bump();
+		m.complete(p, EXPR_PARENED)
+	} else {
+		p.error_with_no_skip();
+		return None;
+	})
 }
-
-type SyntaxNode = rowan::SyntaxNode<Lang>;
-#[allow(unused)]
-type SyntaxToken = rowan::SyntaxToken<Lang>;
-#[allow(unused)]
-type SyntaxElement = rowan::NodeOrToken<SyntaxNode, SyntaxToken>;
 
 impl Parse {
 	pub fn syntax(&self) -> SyntaxNode {
modifiedcrates/jrsonnet-rowan-parser/src/string_block.rsdiffbeforeafterboth
--- a/crates/jrsonnet-rowan-parser/src/string_block.rs
+++ b/crates/jrsonnet-rowan-parser/src/string_block.rs
@@ -11,7 +11,7 @@
 
 use StringBlockToken::*;
 
-use crate::lex::SyntaxKind;
+use crate::SyntaxKind;
 
 pub fn lex_str_block_test<'a>(lex: &mut logos::Lexer<'a, SyntaxKind>) {
 	lex_str_block(lex);
addedcrates/jrsonnet-rowan-parser/src/tests.rsdiffbeforeafterboth
--- /dev/null
+++ b/crates/jrsonnet-rowan-parser/src/tests.rs
@@ -0,0 +1,127 @@
+#![cfg(test)]
+
+use miette::{Diagnostic, GraphicalReportHandler, LabeledSpan};
+use thiserror::Error;
+
+use crate::parser::parse;
+
+#[derive(Debug, Error)]
+#[error("syntax error")]
+struct MyDiagnostic {
+	code: String,
+	spans: Vec<LabeledSpan>,
+}
+impl Diagnostic for MyDiagnostic {
+	fn code<'a>(&'a self) -> Option<Box<dyn std::fmt::Display + 'a>> {
+		None
+	}
+
+	fn severity(&self) -> Option<miette::Severity> {
+		None
+	}
+
+	fn help<'a>(&'a self) -> Option<Box<dyn std::fmt::Display + 'a>> {
+		None
+	}
+
+	fn url<'a>(&'a self) -> Option<Box<dyn std::fmt::Display + 'a>> {
+		None
+	}
+
+	fn source_code(&self) -> Option<&dyn miette::SourceCode> {
+		Some(&self.code)
+	}
+
+	fn labels(&self) -> Option<Box<dyn Iterator<Item = miette::LabeledSpan> + '_>> {
+		Some(Box::new(self.spans.clone().into_iter()))
+	}
+
+	fn related<'a>(&'a self) -> Option<Box<dyn Iterator<Item = &'a dyn Diagnostic> + 'a>> {
+		None
+	}
+}
+
+fn process(text: &str) -> String {
+	use std::fmt::Write;
+	let mut out = String::new();
+	let node = parse(text);
+	write!(out, "{:#?}", node.syntax()).unwrap();
+	if !node.errors.is_empty() && !text.is_empty() {
+		writeln!(out, "===").unwrap();
+		for err in &node.errors {
+			writeln!(out, "{:?}", err).unwrap();
+		}
+		let diag = MyDiagnostic {
+			code: text.to_string(),
+			spans: node.errors.into_iter().map(|e| e.into()).collect(),
+		};
+
+		let handler = GraphicalReportHandler::new();
+
+		write!(out, "===").unwrap();
+		handler.render_report(&mut out, &diag).unwrap();
+	}
+	out
+}
+macro_rules! mk_test {
+		($($name:ident => $test:expr)+) => {$(
+			#[test]
+			fn $name() {
+				let src = indoc::indoc!($test);
+				let result = process(&src);
+				insta::assert_snapshot!(stringify!($name), result, src);
+
+			}
+		)+};
+	}
+mk_test!(
+	empty => r#" "#
+	function => r#"
+			function(a, b = 1) a + b
+		"#
+	function_error_no_value => r#"
+			function(a, b = ) a + b
+		"#
+	function_error_rparen => r#"
+			function(a, b
+		"#
+	function_error_body => r#"
+			function(a, b)
+		"#
+	local_novalue => r#"
+			local a =
+		"#
+	local_no_value_recovery => r#"
+			local a =
+			local b = 3;
+			1
+		"#
+
+	array_comp => r#"
+			[a for a in [1, 2, 3]]
+		"#
+	array_comp_incompatible_with_multiple_elems => r#"
+			[a for a in [1, 2, 3], b]
+		"#
+
+	no_rhs => r#"
+			a +
+		"#
+	no_lhs => r#"
+			+ 2
+		"#
+	no_operator => "
+			2 2
+		"
+
+	named_before_positional => "
+			a(1, 2, b=4, 3, 5, k = 12, 6)
+		"
+
+	wrong_field_end => "
+			{
+				a: 1;
+				b: 2;
+			}
+		"
+);
modifiedcrates/jrsonnet-rowan-parser/src/token_set.rsdiffbeforeafterboth
--- a/crates/jrsonnet-rowan-parser/src/token_set.rs
+++ b/crates/jrsonnet-rowan-parser/src/token_set.rs
@@ -1,24 +1,24 @@
-use crate::lex::SyntaxKind;
+use crate::SyntaxKind;
 
 #[derive(Clone, Copy, Default)]
-pub struct TokenSet(u64);
+pub struct SyntaxKindSet(u64);
 
-impl TokenSet {
+impl SyntaxKindSet {
 	pub const EMPTY: Self = Self(0);
 	pub const ALL: Self = Self(u64::MAX);
 
-	pub const fn new(kinds: &[SyntaxKind]) -> TokenSet {
+	pub const fn new(kinds: &[SyntaxKind]) -> SyntaxKindSet {
 		let mut res = 0u64;
 		let mut i = 0;
 		while i < kinds.len() {
 			res |= mask(kinds[i]);
 			i += 1
 		}
-		TokenSet(res)
+		SyntaxKindSet(res)
 	}
 
-	pub const fn union(self, other: TokenSet) -> TokenSet {
-		TokenSet(self.0 | other.0)
+	pub const fn union(self, other: SyntaxKindSet) -> SyntaxKindSet {
+		SyntaxKindSet(self.0 | other.0)
 	}
 
 	pub const fn contains(&self, kind: SyntaxKind) -> bool {
@@ -29,3 +29,14 @@
 const fn mask(kind: SyntaxKind) -> u64 {
 	1u64 << (kind as usize)
 }
+
+#[macro_export]
+macro_rules! TS {
+	($($tt:tt)*) => {
+		SyntaxKindSet::new(&[
+			$(
+				T![$tt]
+			),*
+		])
+	};
+}
addedxtask/Cargo.tomldiffbeforeafterboth
--- /dev/null
+++ b/xtask/Cargo.toml
@@ -0,0 +1,12 @@
+[package]
+name = "xtask"
+version = "0.1.0"
+edition = "2021"
+
+[dependencies]
+anyhow = "1.0.57"
+itertools = "0.10.3"
+proc-macro2 = "1.0.39"
+quote = "1.0.18"
+ungrammar = "1.16.1"
+xshell = "0.2.2"
addedxtask/src/main.rsdiffbeforeafterboth
--- /dev/null
+++ b/xtask/src/main.rs
@@ -0,0 +1,7 @@
+use anyhow::Result;
+
+mod sourcegen;
+
+fn main() -> Result<()> {
+	sourcegen::generate_ungrammar()
+}
addedxtask/src/sourcegen/ast.rsdiffbeforeafterboth
--- /dev/null
+++ b/xtask/src/sourcegen/ast.rs
@@ -0,0 +1,93 @@
+use proc_macro2::TokenStream;
+use quote::{format_ident, quote};
+
+use super::{escape_token_macro, KindsSrc};
+
+impl AstNodeSrc {
+	pub fn remove_field(&mut self, to_remove: Vec<usize>) {
+		to_remove.into_iter().rev().for_each(|idx| {
+			self.fields.remove(idx);
+		});
+	}
+}
+
+#[allow(dead_code)]
+#[derive(Default, Debug)]
+pub struct AstSrc {
+	pub tokens: Vec<String>,
+	pub nodes: Vec<AstNodeSrc>,
+	pub enums: Vec<AstEnumSrc>,
+}
+#[derive(Debug)]
+pub struct AstNodeSrc {
+	pub doc: Vec<String>,
+	pub name: String,
+	pub traits: Vec<String>,
+	pub fields: Vec<Field>,
+}
+
+#[derive(Debug, Eq, PartialEq)]
+pub enum Field {
+	Token(String),
+	Node {
+		name: String,
+		ty: String,
+		cardinality: Cardinality,
+	},
+}
+
+#[derive(Debug, Eq, PartialEq)]
+pub enum Cardinality {
+	Optional,
+	Many,
+}
+
+#[derive(Debug, Clone)]
+pub struct AstEnumSrc {
+	pub doc: Vec<String>,
+	pub name: String,
+	pub traits: Vec<String>,
+	pub variants: Vec<String>,
+}
+
+impl Field {
+	pub fn is_many(&self) -> bool {
+		matches!(
+			self,
+			Field::Node {
+				cardinality: Cardinality::Many,
+				..
+			}
+		)
+	}
+	pub fn token_kind(&self) -> Option<TokenStream> {
+		match self {
+			Field::Token(token) => {
+				let token: TokenStream = escape_token_macro(token);
+				Some(quote! { T![#token] })
+			}
+			_ => None,
+		}
+	}
+
+	pub fn method_name(&self, kinds: &KindsSrc) -> proc_macro2::Ident {
+		match self {
+			Field::Token(name) => {
+				if let Some(punct_name) = kinds.get_punct_name(name) {
+					format_ident!("{}_token", punct_name.to_lowercase())
+				} else {
+					format_ident!("{}_token", name.to_lowercase())
+				}
+			}
+			Field::Node { name, .. } => {
+				format_ident!("{}", name)
+			}
+		}
+	}
+	pub fn ty(&self) -> proc_macro2::Ident {
+		match self {
+			Field::Token(_) => format_ident!("SyntaxToken"),
+			Field::Node { ty, .. } => format_ident!("{}", ty),
+		}
+	}
+}
addedxtask/src/sourcegen/mod.rsdiffbeforeafterboth
--- /dev/null
+++ b/xtask/src/sourcegen/mod.rs
@@ -0,0 +1,922 @@
+use std::{
+	collections::{BTreeSet, HashSet},
+	path::PathBuf,
+};
+
+use anyhow::Result;
+use ast::{AstEnumSrc, AstNodeSrc, AstSrc, Cardinality, Field};
+use itertools::Itertools;
+use proc_macro2::{Punct, Spacing, TokenStream};
+use quote::{format_ident, quote};
+use ungrammar::{Grammar, Rule};
+use util::{
+	ensure_file_contents, pluralize, reformat, to_lower_snake_case, to_pascal_case,
+	to_upper_snake_case,
+};
+
+mod ast;
+mod util;
+
+pub fn generate_ungrammar() -> Result<()> {
+	let grammar: Grammar = include_str!(concat!(
+		env!("CARGO_MANIFEST_DIR"),
+		"/../crates/jrsonnet-rowan-parser/jsonnet.ungram"
+	))
+	.parse()?;
+
+	let mut kinds: KindsSrc = KindsSrc {
+		punct: puncts![
+			"||" => "OR";
+			"&&" => "AND";
+			"|" => "BIT_OR";
+			"^" => "BIT_XOR";
+			"&" => "BIT_AND";
+			"==" => "EQ";
+			"!=" => "NE";
+			"<" => "LT";
+			">" => "GT";
+			"<=" => "LE";
+			">=" => "GE";
+			"<<" => "LHS";
+			">>" => "RHS";
+			"+" => "PLUS";
+			"-" => "MINUS";
+			"*" => "MUL";
+			"/" => "DIV";
+			"%" => "MODULO";
+			"!" => "NOT";
+			"~" => "BIT_NOT";
+			"[" => "L_BRACK";
+			"]" => "R_BRACK";
+			"(" => "L_PAREN";
+			")" => "R_PAREN";
+			"{" => "L_BRACE";
+			"}" => "R_BRACE";
+			":" => "COLON";
+			"::" => "COLONCOLON";
+			":::" => "COLONCOLONCOLON";
+			";" => "SEMI";
+			"." => "DOT";
+			"..." => "DOTDOTDOT";
+			"," => "COMMA";
+			"$" => "DOLLAR";
+			"=" => "ASSIGN";
+			"?" => "QUESTION_MARK";
+			"$intrinsicThisFile" => "INTRINSIC_THIS_FILE";
+			"$intrinsicId" => "INTRINSIC_ID";
+			"$intrinsic" => "INTRINSIC";
+		],
+		keywords: vec![],
+		literals: literals![
+			"NUMBER" => r"(?:0|[1-9][0-9]*)(?:\.[0-9]+)?(?:[eE][+-]?[0-9]+)?";
+			"STRING_DOUBLE" => "\"(?s:[^\"\\\\]|\\\\.)*\"";
+			"STRING_SINGLE" => "'(?s:[^'\\\\]|\\\\.)*'";
+			"STRING_DOUBLE_VERBATIM" => "@\"(?:[^\"]|\"\")*\"";
+			"STRING_SINGLE_VERBATIM" => "@'(?:[^']|'')*'";
+			"STRING_BLOCK" => r"\|\|\|";
+
+			"IDENT" => r"[_a-zA-Z][_a-zA-Z0-9]*";
+			"WHITESPACE" => r"[ \t\n\r]+";
+			"SINGLE_LINE_SLASH_COMMENT" => r"//[^\r\n]*(\r\n|\n)?";
+			"SINGLE_LINE_HASH_COMMENT" => r"#[^\r\n]*(\r\n|\n)?";
+			"MULTI_LINE_COMMENT" => r"/\*([^*]|\*[^/])*\*/";
+		],
+		nodes: vec![],
+	};
+
+	let ast = lower(&kinds, &grammar);
+
+	for node in &ast.nodes {
+		let name = to_upper_snake_case(&node.name);
+		if !kinds.is_literal(&name) {
+			kinds.nodes.push(name);
+		}
+	}
+	for enum_ in &ast.enums {
+		let name = to_upper_snake_case(&enum_.name);
+		if !kinds.is_literal(&name) {
+			kinds.nodes.push(name);
+		}
+	}
+	for token in grammar.tokens() {
+		let token = &grammar[token];
+		let token = &token.name.clone();
+		let name = to_upper_snake_case(token);
+		if !kinds.is_punct(token) && !kinds.is_literal(&name) {
+			kinds.keywords.push(token.to_owned());
+		}
+	}
+
+	let syntax_kinds = generate_syntax_kinds(&kinds)?;
+
+	let tokens = generate_tokens(&ast)?;
+
+	let nodes = generate_nodes(&kinds, &ast)?;
+	ensure_file_contents(
+		&PathBuf::from(concat!(
+			env!("CARGO_MANIFEST_DIR"),
+			"/../crates/jrsonnet-rowan-parser/src/generated/syntax_kinds.rs",
+		)),
+		&syntax_kinds,
+	)?;
+	ensure_file_contents(
+		&PathBuf::from(concat!(
+			env!("CARGO_MANIFEST_DIR"),
+			"/../crates/jrsonnet-rowan-parser/src/generated/tokens.rs",
+		)),
+		&tokens,
+	)?;
+	ensure_file_contents(
+		&PathBuf::from(concat!(
+			env!("CARGO_MANIFEST_DIR"),
+			"/../crates/jrsonnet-rowan-parser/src/generated/nodes.rs",
+		)),
+		&nodes,
+	)?;
+	Ok(())
+}
+
+fn generate_tokens(grammar: &AstSrc) -> Result<String> {
+	let tokens = grammar.tokens.iter().map(|token| {
+		let name = format_ident!("{}", token);
+		let kind = format_ident!("{}", to_upper_snake_case(token));
+		quote! {
+			#[derive(Debug, Clone, PartialEq, Eq, Hash)]
+			pub struct #name {
+				pub(crate) syntax: SyntaxToken,
+			}
+			impl std::fmt::Display for #name {
+				fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result {
+					std::fmt::Display::fmt(&self.syntax, f)
+				}
+			}
+			impl AstToken for #name {
+				fn can_cast(kind: SyntaxKind) -> bool { kind == #kind }
+				fn cast(syntax: SyntaxToken) -> Option<Self> {
+					if Self::can_cast(syntax.kind()) { Some(Self { syntax }) } else { None }
+				}
+				fn syntax(&self) -> &SyntaxToken { &self.syntax }
+			}
+		}
+	});
+
+	Ok(reformat(
+		&quote! {
+			use crate::{SyntaxKind::{self, *}, SyntaxToken, ast::AstToken};
+			#(#tokens)*
+		}
+		.to_string(),
+	)?
+	.replace("#[derive", "\n#[derive"))
+}
+
+fn generate_syntax_kinds(grammar: &KindsSrc) -> Result<String> {
+	let (single_byte_tokens_values, single_byte_tokens): (Vec<_>, Vec<_>) = grammar
+		.punct
+		.iter()
+		.filter(|(token, _name)| token.len() == 1)
+		.map(|(token, name)| (token.chars().next().unwrap(), format_ident!("{}", name)))
+		.unzip();
+
+	let punctuation_values = grammar
+		.punct
+		.iter()
+		.map(|(token, _name)| escape_token_macro(token));
+	let punctuation = grammar
+		.punct
+		.iter()
+		.map(|(_token, name)| format_ident!("{}", name))
+		.collect::<Vec<_>>();
+	let punctuation_enum = grammar
+		.punct
+		.iter()
+		.map(|(token, name)| {
+			let id = format_ident!("{}", name);
+			quote! {
+				#[token(#token)]
+				#id
+			}
+		})
+		.collect::<Vec<_>>();
+
+	let x = |name: &str| format_ident!("{}_KW", to_upper_snake_case(name));
+	let full_keywords_values = &grammar.keywords;
+	let full_keywords = full_keywords_values.iter().map(|s| x(s.as_str()));
+
+	let all_keywords_values = grammar.keywords.to_vec();
+	let all_keywords_idents = all_keywords_values.iter().map(|kw| format_ident!("{}", kw));
+	let all_keywords = all_keywords_values
+		.iter()
+		.map(|s| x(&**s))
+		.collect::<Vec<_>>();
+	let all_keywords_enum = all_keywords_values
+		.iter()
+		.map(|s| {
+			let id = x(&**s);
+			quote! {
+				#[token(#s)]
+				#id
+			}
+		})
+		.collect::<Vec<_>>();
+
+	let tokens_enum = grammar
+		.literals
+		.iter()
+		.map(|l| {
+			let regex = &l.regex;
+			let id = format_ident!("{}", l.name);
+			let lexer = l
+				.lexer
+				.as_ref()
+				.map(|l| {
+					let id: TokenStream = l.parse().expect("path");
+					quote! {
+						, #id
+					}
+				})
+				.unwrap_or_else(|| quote! {});
+			quote! {
+				#[regex(#regex #lexer)]
+				#id
+			}
+		})
+		.collect::<Vec<_>>();
+
+	let nodes = grammar
+		.nodes
+		.iter()
+		.map(|name| format_ident!("{}", name))
+		.collect::<Vec<_>>();
+
+	let ast = quote! {
+		#![allow(bad_style, missing_docs, unreachable_pub)]
+		use logos::Logos;
+
+		/// The kind of syntax node, e.g. `IDENT`, `USE_KW`, or `STRUCT`.
+		#[derive(Clone, Copy, PartialEq, Eq, PartialOrd, Ord, Hash, Debug, Logos)]
+		#[repr(u16)]
+		pub enum SyntaxKind {
+			#[doc(hidden)]
+			TOMBSTONE,
+			#[doc(hidden)]
+			EOF,
+			#(#punctuation_enum,)*
+			#(#all_keywords_enum,)*
+			#(#tokens_enum,)*
+			#[error]
+			ERROR,
+			#(#nodes,)*
+			#[doc(hidden)]
+			__LAST,
+		}
+		use self::SyntaxKind::*;
+
+		impl SyntaxKind {
+			pub fn is_keyword(self) -> bool {
+				match self {
+					#(#all_keywords)|* => true,
+					_ => false,
+				}
+			}
+
+			pub fn is_punct(self) -> bool {
+				match self {
+					#(#punctuation)|* => true,
+					_ => false,
+				}
+			}
+
+			pub fn from_keyword(ident: &str) -> Option<SyntaxKind> {
+				let kw = match ident {
+					#(#full_keywords_values => #full_keywords,)*
+					_ => return None,
+				};
+				Some(kw)
+			}
+
+			pub fn from_char(c: char) -> Option<SyntaxKind> {
+				let tok = match c {
+					#(#single_byte_tokens_values => #single_byte_tokens,)*
+					_ => return None,
+				};
+				Some(tok)
+			}
+
+			pub fn from_raw(r: u16) -> Self {
+				assert!(r < Self::__LAST as u16);
+				unsafe { std::mem::transmute(r) }
+			}
+			pub fn into_raw(self) -> u16 {
+				self as u16
+			}
+		}
+
+		#[macro_export]
+		macro_rules! T {
+			#([#punctuation_values] => { $crate::SyntaxKind::#punctuation };)*
+			#([#all_keywords_idents] => { $crate::SyntaxKind::#all_keywords };)*
+			[lifetime_ident] => { $crate::SyntaxKind::LIFETIME_IDENT };
+			[ident] => { $crate::SyntaxKind::IDENT };
+			[shebang] => { $crate::SyntaxKind::SHEBANG };
+		}
+		pub use T;
+	};
+
+	reformat(&ast.to_string())
+}
+
+pub struct KindsSrc {
+	pub punct: Vec<(String, String)>,
+	pub keywords: Vec<String>,
+	pub literals: Vec<LiteralKind>,
+	pub nodes: Vec<String>,
+}
+
+pub struct LiteralKind {
+	name: String,
+	regex: String,
+	lexer: Option<String>,
+}
+
+#[macro_export]
+macro_rules! literals {
+	($($name:expr => $regex:expr $(, $lexer:expr)?);* $(;)?) => {
+		vec![
+			$(LiteralKind {
+				name: $name.to_owned(),
+				regex: $regex.to_owned(),
+				lexer: None $(.or_else(|| Some($lexer.to_string())))?,
+			}),*
+		]
+	};
+}
+
+#[macro_export]
+macro_rules! puncts {
+	($($tok:expr => $name:expr);* $(;)?) => {
+		vec![
+			$(($tok.to_owned(), $name.to_owned())),*
+		]
+	};
+}
+use crate::{literals, puncts};
+
+impl KindsSrc {
+	pub fn is_punct(&self, tok: &str) -> bool {
+		self.punct.iter().any(|(t, _)| *t == tok)
+	}
+	pub fn is_literal(&self, tok: &str) -> bool {
+		self.literals.iter().any(|l| l.name == tok)
+	}
+
+	fn get_punct_name(&self, tok: &str) -> Option<&str> {
+		self.punct
+			.iter()
+			.find(|(t, _)| *t == tok)
+			.map(|(_, n)| n.as_str())
+	}
+}
+
+fn generate_nodes(kinds: &KindsSrc, grammar: &AstSrc) -> Result<String> {
+	let (node_defs, node_boilerplate_impls): (Vec<_>, Vec<_>) = grammar
+		.nodes
+		.iter()
+		.map(|node| {
+			let name = format_ident!("{}", node.name);
+			let kind = format_ident!("{}", to_upper_snake_case(&node.name));
+			let traits = node.traits.iter().map(|trait_name| {
+				let trait_name = format_ident!("{}", trait_name);
+				quote!(impl ast::#trait_name for #name {})
+			});
+
+			let methods = node.fields.iter().map(|field| {
+				let method_name = field.method_name(kinds);
+				let ty = field.ty();
+
+				if field.is_many() {
+					quote! {
+						pub fn #method_name(&self) -> AstChildren<#ty> {
+							support::children(&self.syntax)
+						}
+					}
+				} else if let Some(token_kind) = field.token_kind() {
+					quote! {
+						pub fn #method_name(&self) -> Option<#ty> {
+							support::token(&self.syntax, #token_kind)
+						}
+					}
+				} else {
+					quote! {
+						pub fn #method_name(&self) -> Option<#ty> {
+							support::child(&self.syntax)
+						}
+					}
+				}
+			});
+			(
+				quote! {
+					#[pretty_doc_comment_placeholder_workaround]
+					#[derive(Debug, Clone, PartialEq, Eq, Hash)]
+					pub struct #name {
+						pub(crate) syntax: SyntaxNode,
+					}
+
+					#(#traits)*
+
+					impl #name {
+						#(#methods)*
+					}
+				},
+				quote! {
+					impl AstNode for #name {
+						fn can_cast(kind: SyntaxKind) -> bool {
+							kind == #kind
+						}
+						fn cast(syntax: SyntaxNode) -> Option<Self> {
+							if Self::can_cast(syntax.kind()) { Some(Self { syntax }) } else { None }
+						}
+						fn syntax(&self) -> &SyntaxNode { &self.syntax }
+					}
+				},
+			)
+		})
+		.unzip();
+
+	let (enum_defs, enum_boilerplate_impls): (Vec<_>, Vec<_>) = grammar
+		.enums
+		.iter()
+		.map(|en| {
+			let variants: Vec<_> = en
+				.variants
+				.iter()
+				.map(|var| format_ident!("{}", var))
+				.collect();
+			let name = format_ident!("{}", en.name);
+			let kinds: Vec<_> = variants
+				.iter()
+				.map(|name| format_ident!("{}", to_upper_snake_case(&name.to_string())))
+				.collect();
+			let traits = en.traits.iter().map(|trait_name| {
+				let trait_name = format_ident!("{}", trait_name);
+				quote!(impl ast::#trait_name for #name {})
+			});
+
+			let ast_node = quote! {
+				impl AstNode for #name {
+					fn can_cast(kind: SyntaxKind) -> bool {
+						match kind {
+							#(#kinds)|* => true,
+							_ => false,
+						}
+					}
+					fn cast(syntax: SyntaxNode) -> Option<Self> {
+						let res = match syntax.kind() {
+							#(
+							#kinds => #name::#variants(#variants { syntax }),
+							)*
+							_ => return None,
+						};
+						Some(res)
+					}
+					fn syntax(&self) -> &SyntaxNode {
+						match self {
+							#(
+							#name::#variants(it) => &it.syntax,
+							)*
+						}
+					}
+				}
+			};
+
+			(
+				quote! {
+					#[pretty_doc_comment_placeholder_workaround]
+					#[derive(Debug, Clone, PartialEq, Eq, Hash)]
+					pub enum #name {
+						#(#variants(#variants),)*
+					}
+
+					#(#traits)*
+				},
+				quote! {
+					#(
+						impl From<#variants> for #name {
+							fn from(node: #variants) -> #name {
+								#name::#variants(node)
+							}
+						}
+					)*
+					#ast_node
+				},
+			)
+		})
+		.unzip();
+
+	let (any_node_defs, any_node_boilerplate_impls): (Vec<_>, Vec<_>) = grammar
+		.nodes
+		.iter()
+		.flat_map(|node| node.traits.iter().map(move |t| (t, node)))
+		.into_group_map()
+		.into_iter()
+		.sorted_by_key(|(k, _)| *k)
+		.map(|(trait_name, nodes)| {
+			let name = format_ident!("Any{}", trait_name);
+			let trait_name = format_ident!("{}", trait_name);
+			let kinds: Vec<_> = nodes
+				.iter()
+				.map(|name| format_ident!("{}", to_upper_snake_case(&name.name.to_string())))
+				.collect();
+
+			(
+				quote! {
+					#[pretty_doc_comment_placeholder_workaround]
+					#[derive(Debug, Clone, PartialEq, Eq, Hash)]
+					pub struct #name {
+						pub(crate) syntax: SyntaxNode,
+					}
+					impl ast::#trait_name for #name {}
+				},
+				quote! {
+					impl #name {
+						#[inline]
+						pub fn new<T: ast::#trait_name>(node: T) -> #name {
+							#name {
+								syntax: node.syntax().clone()
+							}
+						}
+					}
+					impl AstNode for #name {
+						fn can_cast(kind: SyntaxKind) -> bool {
+							match kind {
+								#(#kinds)|* => true,
+								_ => false,
+							}
+						}
+						fn cast(syntax: SyntaxNode) -> Option<Self> {
+							Self::can_cast(syntax.kind()).then(|| #name { syntax })
+						}
+						fn syntax(&self) -> &SyntaxNode {
+							&self.syntax
+						}
+					}
+				},
+			)
+		})
+		.unzip();
+
+	let enum_names = grammar.enums.iter().map(|it| &it.name);
+	let node_names = grammar.nodes.iter().map(|it| &it.name);
+
+	let display_impls = enum_names
+		.chain(node_names.clone())
+		.map(|it| format_ident!("{}", it))
+		.map(|name| {
+			quote! {
+				impl std::fmt::Display for #name {
+					fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result {
+						std::fmt::Display::fmt(self.syntax(), f)
+					}
+				}
+			}
+		});
+
+	let defined_nodes: HashSet<_> = node_names.collect();
+
+	for node in kinds
+		.nodes
+		.iter()
+		.map(|kind| to_pascal_case(kind))
+		.filter(|name| !defined_nodes.iter().any(|&it| it == name))
+	{
+		drop(node)
+		// FIXME: restore this
+		// eprintln!("Warning: node {} not defined in ast source", node);
+	}
+
+	let ast = quote! {
+		#![allow(non_snake_case)]
+		use crate::{
+			SyntaxNode, SyntaxToken, SyntaxKind::{self, *},
+			ast::{self, AstNode, AstChildren, support},
+			T,
+		};
+
+		#(#node_defs)*
+		#(#enum_defs)*
+		#(#any_node_defs)*
+		#(#node_boilerplate_impls)*
+		#(#enum_boilerplate_impls)*
+		#(#any_node_boilerplate_impls)*
+		#(#display_impls)*
+	};
+
+	let ast = ast.to_string().replace("T ! [", "T![");
+
+	let mut res = String::with_capacity(ast.len() * 2);
+
+	let mut docs = grammar
+		.nodes
+		.iter()
+		.map(|it| &it.doc)
+		.chain(grammar.enums.iter().map(|it| &it.doc));
+
+	for chunk in ast.split("# [pretty_doc_comment_placeholder_workaround] ") {
+		res.push_str(chunk);
+		if let Some(doc) = docs.next() {
+			write_doc_comment(doc, &mut res);
+		}
+	}
+
+	let res = reformat(&res)?;
+	Ok(res.replace("#[derive", "\n#[derive"))
+}
+
+fn write_doc_comment(contents: &[String], dest: &mut String) {
+	use std::fmt::Write;
+	for line in contents {
+		writeln!(dest, "///{}", line).unwrap();
+	}
+}
+
+fn lower(kinds: &KindsSrc, grammar: &Grammar) -> AstSrc {
+	let tokens = "Whitespace Comment String StringVerbantim StringBlock Number Ident"
+		.split_ascii_whitespace()
+		.map(|it| it.to_string())
+		.collect::<Vec<_>>();
+
+	let mut res = AstSrc {
+		tokens,
+		..Default::default()
+	};
+
+	let nodes = grammar.iter().collect::<Vec<_>>();
+
+	for &node in &nodes {
+		let name = grammar[node].name.clone();
+		let rule = &grammar[node].rule;
+		match lower_enum(grammar, rule) {
+			Some(variants) => {
+				let enum_src = AstEnumSrc {
+					doc: Vec::new(),
+					name,
+					traits: Vec::new(),
+					variants,
+				};
+				res.enums.push(enum_src);
+			}
+			None => {
+				let mut fields = Vec::new();
+				lower_rule(&mut fields, grammar, None, rule);
+				res.nodes.push(AstNodeSrc {
+					doc: Vec::new(),
+					name,
+					traits: Vec::new(),
+					fields,
+				});
+			}
+		}
+	}
+
+	deduplicate_fields(&mut res);
+	extract_enums(&mut res);
+	extract_struct_traits(kinds, &mut res);
+	extract_enum_traits(&mut res);
+	res
+}
+
+fn lower_enum(grammar: &Grammar, rule: &Rule) -> Option<Vec<String>> {
+	let alternatives = match rule {
+		Rule::Alt(it) => it,
+		_ => return None,
+	};
+	let mut variants = Vec::new();
+	for alternative in alternatives {
+		match alternative {
+			Rule::Node(it) => variants.push(grammar[*it].name.clone()),
+			Rule::Token(it) if grammar[*it].name == ";" => (),
+			_ => return None,
+		}
+	}
+	Some(variants)
+}
+
+fn lower_rule(acc: &mut Vec<Field>, grammar: &Grammar, label: Option<&String>, rule: &Rule) {
+	if lower_comma_list(acc, grammar, label, rule) {
+		return;
+	}
+
+	match rule {
+		Rule::Node(node) => {
+			let ty = grammar[*node].name.clone();
+			let name = label.cloned().unwrap_or_else(|| to_lower_snake_case(&ty));
+			let field = Field::Node {
+				name,
+				ty,
+				cardinality: Cardinality::Optional,
+			};
+			acc.push(field);
+		}
+		Rule::Token(token) => {
+			assert!(label.is_none(), "uexpected label: {:?}", label);
+			let name = grammar[*token].name.clone();
+			let field = Field::Token(name);
+			acc.push(field);
+		}
+		Rule::Rep(inner) => {
+			if let Rule::Node(node) = &**inner {
+				let ty = grammar[*node].name.clone();
+				let name = label
+					.cloned()
+					.unwrap_or_else(|| pluralize(&to_lower_snake_case(&ty)));
+				let field = Field::Node {
+					name,
+					ty,
+					cardinality: Cardinality::Many,
+				};
+				acc.push(field);
+				return;
+			}
+			todo!("unsupported repitition: {:?}", rule)
+		}
+		Rule::Labeled { label: l, rule } => {
+			assert!(label.is_none());
+			lower_rule(acc, grammar, Some(l), rule);
+		}
+		Rule::Seq(rules) | Rule::Alt(rules) => {
+			for rule in rules {
+				lower_rule(acc, grammar, label, rule)
+			}
+		}
+		Rule::Opt(rule) => lower_rule(acc, grammar, label, rule),
+	}
+}
+
+// (T (',' T)* ','?)
+fn lower_comma_list(
+	acc: &mut Vec<Field>,
+	grammar: &Grammar,
+	label: Option<&String>,
+	rule: &Rule,
+) -> bool {
+	let rule = match rule {
+		Rule::Seq(it) => it,
+		_ => return false,
+	};
+	let (node, repeat, trailing_comma) = match rule.as_slice() {
+		[Rule::Node(node), Rule::Rep(repeat), Rule::Opt(trailing_comma)] => {
+			(node, repeat, trailing_comma)
+		}
+		_ => return false,
+	};
+	let repeat = match &**repeat {
+		Rule::Seq(it) => it,
+		_ => return false,
+	};
+	match repeat.as_slice() {
+		[comma, Rule::Node(n)] if comma == &**trailing_comma && n == node => (),
+		_ => return false,
+	}
+	let ty = grammar[*node].name.clone();
+	let name = label
+		.cloned()
+		.unwrap_or_else(|| pluralize(&to_lower_snake_case(&ty)));
+	let field = Field::Node {
+		name,
+		ty,
+		cardinality: Cardinality::Many,
+	};
+	acc.push(field);
+	true
+}
+
+fn deduplicate_fields(ast: &mut AstSrc) {
+	for node in &mut ast.nodes {
+		let mut i = 0;
+		'outer: while i < node.fields.len() {
+			for j in 0..i {
+				let f1 = &node.fields[i];
+				let f2 = &node.fields[j];
+				if f1 == f2 {
+					node.fields.remove(i);
+					continue 'outer;
+				}
+			}
+			i += 1;
+		}
+	}
+}
+
+fn extract_enums(ast: &mut AstSrc) {
+	for node in &mut ast.nodes {
+		for enm in &ast.enums {
+			let mut to_remove = Vec::new();
+			for (i, field) in node.fields.iter().enumerate() {
+				let ty = field.ty().to_string();
+				if enm.variants.iter().any(|it| it == &ty) {
+					to_remove.push(i);
+				}
+			}
+			if to_remove.len() == enm.variants.len() {
+				node.remove_field(to_remove);
+				let ty = enm.name.clone();
+				let name = to_lower_snake_case(&ty);
+				node.fields.push(Field::Node {
+					name,
+					ty,
+					cardinality: Cardinality::Optional,
+				});
+			}
+		}
+	}
+}
+
+fn extract_struct_traits(kinds: &KindsSrc, ast: &mut AstSrc) {
+	// TODO: add common accessor traits here.
+	let traits: &[(&str, &[&str])] = &[];
+
+	for node in &mut ast.nodes {
+		for (name, methods) in traits {
+			extract_struct_trait(kinds, node, name, methods);
+		}
+	}
+}
+
+fn extract_struct_trait(
+	kinds: &KindsSrc,
+	node: &mut AstNodeSrc,
+	trait_name: &str,
+	methods: &[&str],
+) {
+	let mut to_remove = Vec::new();
+	for (i, field) in node.fields.iter().enumerate() {
+		let method_name = field.method_name(kinds).to_string();
+		if methods.iter().any(|&it| it == method_name) {
+			to_remove.push(i);
+		}
+	}
+	if to_remove.len() == methods.len() {
+		node.traits.push(trait_name.to_string());
+		node.remove_field(to_remove);
+	}
+}
+
+fn extract_enum_traits(ast: &mut AstSrc) {
+	let enums = ast.enums.clone();
+	for enm in &mut ast.enums {
+		if enm.name == "Stmt" {
+			continue;
+		}
+		let nodes = &ast.nodes;
+
+		let mut variant_traits = enm.variants.iter().map(|var| {
+			nodes
+				.iter()
+				.find_map(|node| {
+					if &node.name != var {
+						return None;
+					}
+					Some(node.traits.iter().cloned().collect::<BTreeSet<_>>())
+				})
+				.unwrap_or_else(|| {
+					enums
+						.iter()
+						.find_map(|node| {
+							if &node.name != var {
+								return None;
+							}
+							Some(node.traits.iter().cloned().collect::<BTreeSet<_>>())
+						})
+						.unwrap_or_else(|| {
+							panic!("{}", {
+								&format!(
+									"Could not find a struct `{}` for enum `{}::{}`",
+									var, enm.name, var
+								)
+							})
+						})
+				})
+		});
+
+		let mut enum_traits = match variant_traits.next() {
+			Some(it) => it,
+			None => continue,
+		};
+		for traits in variant_traits {
+			enum_traits = enum_traits.intersection(&traits).cloned().collect();
+		}
+		enm.traits = enum_traits.into_iter().collect();
+	}
+}
+
+pub fn escape_token_macro(token: &str) -> TokenStream {
+	if "{}[]()$".contains(token) {
+		let c = token.chars().next().unwrap();
+		quote! { #c }
+	} else if token.contains('$') {
+		quote! { #token }
+	} else {
+		let cs = token.chars().map(|c| Punct::new(c, Spacing::Joint));
+		quote! { #(#cs)* }
+	}
+}
addedxtask/src/sourcegen/util.rsdiffbeforeafterboth
--- /dev/null
+++ b/xtask/src/sourcegen/util.rs
@@ -0,0 +1,92 @@
+use std::{fs, path::Path};
+
+use anyhow::{bail, Result};
+use xshell::{cmd, Shell};
+
+/// Checks that the `file` has the specified `contents`. If that is not the
+/// case, updates the file and then fails the test.
+pub fn ensure_file_contents(file: &Path, contents: &str) -> Result<()> {
+	if let Ok(old_contents) = fs::read_to_string(file) {
+		if normalize_newlines(&old_contents) == normalize_newlines(contents) {
+			// File is already up to date.
+			return Ok(());
+		}
+	}
+
+	eprintln!(" {} was not up-to-date, updating\n", file.display());
+	if std::env::var("CI").is_ok() {
+		eprintln!("NOTE: run `cargo test` locally and commit the updated files\n");
+	}
+	if let Some(parent) = file.parent() {
+		let _ = fs::create_dir_all(parent);
+	}
+	fs::write(file, contents).unwrap();
+	bail!("some file was not up to date and has been updated, simply re-run the tests");
+}
+
+// Eww, someone configured git to use crlf?
+fn normalize_newlines(s: &str) -> String {
+	s.replace("\r\n", "\n")
+}
+
+pub(crate) fn pluralize(s: &str) -> String {
+	format!("{}s", s)
+}
+
+pub fn to_upper_snake_case(s: &str) -> String {
+	let mut buf = String::with_capacity(s.len());
+	let mut prev = false;
+	for c in s.chars() {
+		if c.is_ascii_uppercase() && prev {
+			buf.push('_')
+		}
+		prev = true;
+
+		buf.push(c.to_ascii_uppercase());
+	}
+	buf
+}
+pub fn to_lower_snake_case(s: &str) -> String {
+	let mut buf = String::with_capacity(s.len());
+	let mut prev = false;
+	for c in s.chars() {
+		if c.is_ascii_uppercase() && prev {
+			buf.push('_')
+		}
+		prev = true;
+
+		buf.push(c.to_ascii_lowercase());
+	}
+	buf
+}
+
+pub fn to_pascal_case(s: &str) -> String {
+	let mut buf = String::with_capacity(s.len());
+	let mut prev_is_underscore = true;
+	for c in s.chars() {
+		if c == '_' {
+			prev_is_underscore = true;
+		} else if prev_is_underscore {
+			buf.push(c.to_ascii_uppercase());
+			prev_is_underscore = false;
+		} else {
+			buf.push(c.to_ascii_lowercase());
+		}
+	}
+	buf
+}
+
+pub fn reformat(text: &str) -> Result<String> {
+	// let _e = pushenv("RUSTUP_TOOLCHAIN", "stable");
+	// rustfmt()?;
+	let sh = Shell::new()?;
+	let stdout = cmd!(sh, "rustfmt --config fn_single_line=true")
+		.stdin(text)
+		.read()?;
+	Ok(format!(
+		"{}\n\n{}\n",
+		"//! This is a generated file, please do not edit manually. Changes can be
+//! made in codegeneration that lives in `xtask` top-level dir.",
+		stdout
+	))
+}