git.delta.rocks / jrsonnet / refs/commits / 26a3b24cc9cf

difftreelog

refactor(rowan-parser) remove intrinsic syntax

Yaroslav Bolyukin2023-09-04parent: #a6892a9.patch.diff
in: master

13 files changed

modifiedcmds/jrsonnet-fmt/src/children.rsdiffbeforeafterboth
--- a/cmds/jrsonnet-fmt/src/children.rs
+++ b/cmds/jrsonnet-fmt/src/children.rs
@@ -3,13 +3,11 @@
 use std::{fmt::Debug, mem};
 
 use jrsonnet_rowan_parser::{
-	nodes::{Trivia, TriviaKind},
-	AstNode, AstToken, SyntaxElement,
-	SyntaxKind::*,
-	SyntaxNode, TS,
+	nodes::{CustomError, Trivia, TriviaKind},
+	AstNode, AstToken, SyntaxElement, SyntaxNode, TS,
 };
 
-pub type ChildTrivia = Vec<Trivia>;
+pub type ChildTrivia = Vec<Result<Trivia, String>>;
 
 /// Node should have no non-trivia tokens before element
 pub fn trivia_before(node: SyntaxNode, end: Option<&SyntaxElement>) -> ChildTrivia {
@@ -20,12 +18,14 @@
 		}
 
 		if let Some(trivia) = item.as_token().cloned().and_then(Trivia::cast) {
-			out.push(trivia);
+			out.push(Ok(trivia));
+		} else if CustomError::can_cast(item.kind()) {
+			out.push(Err(item.to_string()));
 		} else if end.is_none() {
 			break;
 		} else {
 			assert!(
-				TS![, ;].contains(item.kind()) || item.kind() == ERROR,
+				TS![, ;].contains(item.kind()),
 				"silently eaten token: {:?}",
 				item.kind()
 			)
@@ -46,10 +46,12 @@
 	let mut out = Vec::new();
 	for item in iter {
 		if let Some(trivia) = item.as_token().cloned().and_then(Trivia::cast) {
-			out.push(trivia);
+			out.push(Ok(trivia));
+		} else if CustomError::can_cast(item.kind()) {
+			out.push(Err(item.to_string()))
 		} else {
 			assert!(
-				TS![, ;].contains(item.kind()) || item.kind() == ERROR,
+				TS![, ;].contains(item.kind()),
 				"silently eaten token: {:?}",
 				item.kind()
 			)
@@ -74,12 +76,14 @@
 	let mut out = Vec::new();
 	for item in iter.take_while(|i| Some(i) != end) {
 		if let Some(trivia) = item.as_token().cloned().and_then(Trivia::cast) {
-			out.push(trivia);
+			out.push(Ok(trivia));
+		} else if CustomError::can_cast(item.kind()) {
+			out.push(Err(item.to_string()))
 		} else if loose {
 			break;
 		} else {
 			assert!(
-				TS![, ;].contains(item.kind()) || item.kind() == ERROR,
+				TS![, ;].contains(item.kind()),
 				"silently eaten token: {:?}",
 				item.kind()
 			)
@@ -120,11 +124,16 @@
 fn count_newlines_before(tt: &ChildTrivia) -> usize {
 	let mut nl_count = 0;
 	for t in tt {
-		match t.kind() {
-			TriviaKind::Whitespace => {
-				nl_count += t.text().bytes().filter(|b| *b == b'\n').count();
+		match t {
+			Ok(t) => match t.kind() {
+				TriviaKind::Whitespace => {
+					nl_count += t.text().bytes().filter(|b| *b == b'\n').count();
+				}
+				_ => break,
+			},
+			Err(_) => {
+				nl_count += 1;
 			}
-			_ => break,
 		}
 	}
 	nl_count
@@ -132,19 +141,22 @@
 fn count_newlines_after(tt: &ChildTrivia) -> usize {
 	let mut nl_count = 0;
 	for t in tt.iter().rev() {
-		match t.kind() {
-			TriviaKind::Whitespace => {
-				nl_count += t.text().bytes().filter(|b| *b == b'\n').count();
-			}
-			TriviaKind::SingleLineHashComment => {
-				nl_count += 1;
-				break;
-			}
-			TriviaKind::SingleLineSlashComment => {
-				nl_count += 1;
-				break;
-			}
-			_ => {}
+		match t {
+			Ok(t) => match t.kind() {
+				TriviaKind::Whitespace => {
+					nl_count += t.text().bytes().filter(|b| *b == b'\n').count();
+				}
+				TriviaKind::SingleLineHashComment => {
+					nl_count += 1;
+					break;
+				}
+				TriviaKind::SingleLineSlashComment => {
+					nl_count += 1;
+					break;
+				}
+				_ => {}
+			},
+			Err(_) => nl_count += 1,
 		}
 	}
 	nl_count
@@ -187,16 +199,18 @@
 				|| current_child.is_none()
 				|| trivia.text().contains('\n') && !is_single_line_comment
 			{
-				next.push(trivia.clone());
+				next.push(Ok(trivia.clone()));
 				started_next = true;
 			} else {
 				let cur = current_child.as_mut().expect("checked not none");
-				cur.inline_trivia.push(trivia);
+				cur.inline_trivia.push(Ok(trivia));
 				if is_single_line_comment {
 					started_next = true;
 				}
 			}
 			had_some = true;
+		} else if CustomError::can_cast(item.kind()) {
+			next.push(Err(item.to_string()))
 		} else if loose {
 			if had_some {
 				break;
@@ -204,7 +218,7 @@
 			started_next = true;
 		} else {
 			assert!(
-				TS![, ;].contains(item.kind()) || item.kind() == ERROR,
+				TS![, ;].contains(item.kind()),
 				"silently eaten token: {:?}",
 				item.kind()
 			)
modifiedcmds/jrsonnet-fmt/src/comments.rsdiffbeforeafterboth
--- a/cmds/jrsonnet-fmt/src/comments.rs
+++ b/cmds/jrsonnet-fmt/src/comments.rs
@@ -17,6 +17,24 @@
 	let mut pi = p!(new:);
 
 	for c in comments {
+		let Ok(c) = c else {
+			let mut text = c.as_ref().unwrap_err() as &str;
+			while !text.is_empty() {
+				let pos = text.find(|c| c == '\n' || c == '\t').unwrap_or(text.len());
+				let sliced = &text[..pos];
+				p!(pi: string(sliced.to_string()));
+				text = &text[pos..];
+				if! text.is_empty(){
+					match text.as_bytes()[0] {
+						b'\n' => p!(pi: nl),
+						b'\t' => p!(pi: tab),
+						_ => unreachable!()
+					}
+					text = &text[1..];
+				}
+			}
+			continue;
+		};
 		match c.kind() {
 			TriviaKind::Whitespace => {}
 			TriviaKind::MultiLineComment => {
@@ -37,7 +55,7 @@
 				let mut immediate_start = true;
 				let mut lines = text
 					.split('\n')
-					.map(|l| l.trim_end())
+					.map(|l| l.trim_end().to_string())
 					.skip_while(|l| {
 						if l.is_empty() {
 							immediate_start = false;
@@ -51,7 +69,7 @@
 					lines.pop();
 				}
 				if lines.len() == 1 && !doc {
-					p!(pi: str("/* ") str(lines[0].trim()) str(" */") nl)
+					p!(pi: str("/* ") string(lines[0].trim().to_string()) str(" */") nl)
 				} else if !lines.is_empty() {
 					fn common_ws_prefix<'a>(a: &'a str, b: &str) -> &'a str {
 						let offset = a
@@ -62,17 +80,18 @@
 						&a[..offset]
 					}
 					// First line is not empty, extract ws prefix of it
-					let mut common_ws_padding = if immediate_start && lines.len() > 1 {
-						common_ws_prefix(lines[1], lines[1])
+					let mut common_ws_padding = (if immediate_start && lines.len() > 1 {
+						common_ws_prefix(&lines[1], &lines[1])
 					} else {
-						common_ws_prefix(lines[0], lines[0])
-					};
+						common_ws_prefix(&lines[0], &lines[0])
+					})
+					.to_string();
 					for line in lines
 						.iter()
 						.skip(if immediate_start { 2 } else { 1 })
 						.filter(|l| !l.is_empty())
 					{
-						common_ws_padding = common_ws_prefix(common_ws_padding, line);
+						common_ws_padding = common_ws_prefix(&common_ws_padding, line).to_string();
 					}
 					for line in lines
 						.iter_mut()
@@ -80,8 +99,9 @@
 						.filter(|l| !l.is_empty())
 					{
 						*line = line
-							.strip_prefix(common_ws_padding)
-							.expect("all non-empty lines start with this padding");
+							.strip_prefix(&common_ws_padding)
+							.expect("all non-empty lines start with this padding")
+							.to_string();
 					}
 
 					p!(pi: str("/*"));
@@ -105,9 +125,9 @@
 								} else {
 									p!(pi: tab);
 								}
-								line = new_line;
+								line = new_line.to_string();
 							}
-							p!(pi: str(line) nl)
+							p!(pi: string(line.to_string()) nl)
 						}
 					}
 					if doc {
@@ -136,7 +156,7 @@
 				if matches!(loc, CommentLocation::ItemInline) {
 					p!(pi: str(" "))
 				}
-				p!(pi: str("# ") str(c.text().strip_prefix('#').expect("hash comment starts with #").trim()));
+				p!(pi: str("# ") string(c.text().strip_prefix('#').expect("hash comment starts with #").trim().to_string()));
 				if !matches!(loc, CommentLocation::ItemInline) {
 					p!(pi: nl)
 				}
@@ -145,14 +165,14 @@
 				if matches!(loc, CommentLocation::ItemInline) {
 					p!(pi: str(" "))
 				}
-				p!(pi: str("// ") str(c.text().strip_prefix("//").expect("comment starts with //").trim()));
+				p!(pi: str("// ") string(c.text().strip_prefix("//").expect("comment starts with //").trim().to_string()));
 				if !matches!(loc, CommentLocation::ItemInline) {
 					p!(pi: nl)
 				}
 			}
 			// Garbage in - garbage out
 			TriviaKind::ErrorCommentTooShort => p!(pi: str("/*/")),
-			TriviaKind::ErrorCommentUnterminated => p!(pi: str(c.text())),
+			TriviaKind::ErrorCommentUnterminated => p!(pi: string(c.text().to_string())),
 		}
 	}
 
modifiedcmds/jrsonnet-fmt/src/main.rsdiffbeforeafterboth
--- a/cmds/jrsonnet-fmt/src/main.rs
+++ b/cmds/jrsonnet-fmt/src/main.rs
@@ -5,10 +5,11 @@
 use jrsonnet_rowan_parser::{
 	nodes::{
 		ArgsDesc, Assertion, BinaryOperator, Bind, CompSpec, Destruct, DestructArrayPart,
-		DestructRest, Expr, Field, FieldName, ForSpec, IfSpec, ImportKind, LhsExpr, Literal,
-		Member, Name, Number, ObjBody, ObjLocal, ParamsDesc, SliceDesc, SourceFile, Text,
-		UnaryOperator,
+		DestructRest, Expr, FieldName, ForSpec, IfSpec, ImportKind, LhsExpr, Literal, Member, Name,
+		Number, ObjBody, ObjLocal, ParamsDesc, SliceDesc, SourceFile, Text, UnaryOperator,
+		Visibility, VisibilityKind,
 	},
+	rowan::NodeOrToken,
 	AstNode, AstToken, SyntaxToken,
 };
 
@@ -37,6 +38,10 @@
 		$o.push_str($e);
 		pi!(@s; $o: $($t)*);
 	}};
+	(@s; $o:ident: string($e:expr $(,)?) $($t:tt)*) => {{
+		$o.push_string($e);
+		pi!(@s; $o: $($t)*);
+	}};
 	(@s; $o:ident: nl $($t:tt)*) => {{
 		$o.push_signal(dprint_core::formatting::Signal::NewLine);
 		pi!(@s; $o: $($t)*);
@@ -96,8 +101,8 @@
 		if let Some(v) = self {
 			v.print()
 		} else {
-			p!(new: str(
-				&format!(
+			p!(new: string(
+				format!(
 					"/*missing {}*/",
 					type_name::<P>().replace("jrsonnet_rowan_parser::generated::nodes::", "")
 				),
@@ -108,18 +113,18 @@
 
 impl Printable for SyntaxToken {
 	fn print(&self) -> PrintItems {
-		p!(new: str(&self.to_string()))
+		p!(new: string(self.to_string()))
 	}
 }
 
 impl Printable for Text {
 	fn print(&self) -> PrintItems {
-		p!(new: str(&format!("{}", self)))
+		p!(new: string(format!("{}", self)))
 	}
 }
 impl Printable for Number {
 	fn print(&self) -> PrintItems {
-		p!(new: str(&format!("{}", self)))
+		p!(new: string(format!("{}", self)))
 	}
 }
 
@@ -201,22 +206,10 @@
 		}
 	}
 }
-impl Printable for Field {
+
+impl Printable for Visibility {
 	fn print(&self) -> PrintItems {
-		let mut pi = p!(new:);
-		match self {
-			Field::FieldNormal(n) => {
-				p!(pi: {n.field_name()});
-				if n.plus_token().is_some() {
-					p!(pi: str("+"));
-				}
-				p!(pi: str(": ") {n.expr()});
-			}
-			Field::FieldMethod(m) => {
-				p!(pi: {m.field_name()} {m.params_desc()} str(": ") {m.expr()});
-			}
-		}
-		pi
+		p!(new: string(self.to_string()))
 	}
 }
 
@@ -282,10 +275,82 @@
 	}
 }
 
+impl Printable for Member {
+	fn print(&self) -> PrintItems {
+		match self {
+			Member::MemberBindStmt(b) => {
+				p!(new: {b.obj_local()})
+			}
+			Member::MemberAssertStmt(ass) => {
+				p!(new: {ass.assertion()})
+			}
+			Member::MemberFieldNormal(n) => {
+				p!(new: {n.field_name()} if(n.plus_token().is_some())({n.plus_token()}) {n.visibility()} str(" ") {n.expr()})
+			}
+			Member::MemberFieldMethod(_) => todo!(),
+		}
+	}
+}
+
 impl Printable for ObjBody {
 	fn print(&self) -> PrintItems {
 		match self {
-			ObjBody::ObjBodyComp(_) => todo!(),
+			ObjBody::ObjBodyComp(l) => {
+				let mut pi = p!(new: str("{") >i nl);
+				let (children, end_comments) = children_between::<Member>(
+					l.syntax().clone(),
+					l.l_brace_token().map(Into::into).as_ref(),
+					Some(
+						&(l.comp_specs()
+							.next()
+							.expect("at least one spec is defined")
+							.syntax()
+							.clone())
+						.into(),
+					),
+				);
+				for mem in children.into_iter() {
+					if mem.should_start_with_newline {
+						p!(pi: nl);
+					}
+					p!(pi: items(format_comments(&mem.before_trivia, CommentLocation::AboveItem)));
+					p!(pi: {mem.value} str(","));
+					p!(pi: items(format_comments(&mem.inline_trivia, CommentLocation::ItemInline)));
+					p!(pi: nl)
+				}
+
+				if end_comments.should_start_with_newline {
+					p!(pi: nl);
+				}
+				p!(pi: items(format_comments(&end_comments.trivia, CommentLocation::EndOfItems)));
+
+				let (compspecs, end_comments) = children_between::<CompSpec>(
+					l.syntax().clone(),
+					l.member_comps()
+						.last()
+						.map(|m| m.syntax().clone())
+						.map(Into::into)
+						.or_else(|| l.l_brace_token().map(Into::into))
+						.as_ref(),
+					l.r_brace_token().map(Into::into).as_ref(),
+				);
+				for mem in compspecs.into_iter() {
+					if mem.should_start_with_newline {
+						p!(pi: nl);
+					}
+					p!(pi: items(format_comments(&mem.before_trivia, CommentLocation::AboveItem)));
+					p!(pi: {mem.value});
+					p!(pi: items(format_comments(&mem.inline_trivia, CommentLocation::ItemInline)));
+					p!(pi: nl)
+				}
+				if end_comments.should_start_with_newline {
+					p!(pi: nl);
+				}
+				p!(pi: items(format_comments(&end_comments.trivia, CommentLocation::EndOfItems)));
+
+				p!(pi: <i str("}"));
+				pi
+			}
 			ObjBody::ObjBodyMemberList(l) => {
 				let mut pi = p!(new: str("{") >i nl);
 				let (children, end_comments) = children_between::<Member>(
@@ -298,18 +363,7 @@
 						p!(pi: nl);
 					}
 					p!(pi: items(format_comments(&mem.before_trivia, CommentLocation::AboveItem)));
-					match mem.value {
-						Member::MemberBindStmt(b) => {
-							p!(pi: {b.obj_local()})
-						}
-						Member::MemberAssertStmt(ass) => {
-							p!(pi: {ass.assertion()})
-						}
-						Member::MemberField(f) => {
-							p!(pi: {f.field()})
-						}
-					}
-					p!(pi: str(","));
+					p!(pi: {mem.value} str(","));
 					p!(pi: items(format_comments(&mem.inline_trivia, CommentLocation::ItemInline)));
 					p!(pi: nl)
 				}
@@ -326,12 +380,12 @@
 }
 impl Printable for UnaryOperator {
 	fn print(&self) -> PrintItems {
-		p!(new: str(self.text()))
+		p!(new: string(self.text().to_string()))
 	}
 }
 impl Printable for BinaryOperator {
 	fn print(&self) -> PrintItems {
-		p!(new: str(self.text()))
+		p!(new: string(self.text().to_string()))
 	}
 }
 impl Printable for Bind {
@@ -348,12 +402,12 @@
 }
 impl Printable for Literal {
 	fn print(&self) -> PrintItems {
-		p!(new: str(&self.syntax().to_string()))
+		p!(new: string(self.syntax().to_string()))
 	}
 }
 impl Printable for ImportKind {
 	fn print(&self) -> PrintItems {
-		p!(new: str(&self.syntax().to_string()))
+		p!(new: string(self.syntax().to_string()))
 	}
 }
 impl Printable for LhsExpr {
@@ -406,9 +460,6 @@
 			Expr::ExprParened(p) => {
 				p!(new: str("(") {p.expr()} str(")"))
 			}
-			Expr::ExprIntrinsicThisFile(_) => p!(new: str("$intrinsicThisFile")),
-			Expr::ExprIntrinsicId(_) => p!(new: str("$intrinsicId")),
-			Expr::ExprIntrinsic(i) => p!(new: str("$intrinsic(") {i.name()} str(")")),
 			Expr::ExprString(s) => p!(new: {s.text()}),
 			Expr::ExprNumber(n) => p!(new: {n.number()}),
 			Expr::ExprArray(a) => {
@@ -543,10 +594,6 @@
 		local ocomp = {[k]: 1 for k in v};
 
 		local ? = skip;
-
-		local intr = $intrinsic(test);
-		local intrId = $intrinsicId;
-		local intrThisFile = $intrinsicThisFile;
 
 		local ie = a[expr];
 
@@ -643,7 +690,13 @@
 
 		  2
 
-		  else Template {}
+		  else Template {},
+
+		  compspecs: {
+			obj_with_no_item: {for i in [1, 2, 3]},
+			obj_with_2_items: {a:1, b:2, for i in [1,2,3]},
+		  }
+
 		} + Template
 
 
modifiedcrates/jrsonnet-rowan-parser/jsonnet.ungramdiffbeforeafterboth
--- a/crates/jrsonnet-rowan-parser/jsonnet.ungram
+++ b/crates/jrsonnet-rowan-parser/jsonnet.ungram
@@ -38,15 +38,6 @@
 
 ExprLiteral =
     Literal
-ExprIntrinsicThisFile =
-    '$intrinsicThisFile'
-ExprIntrinsicId =
-    '$intrinsicId'
-ExprIntrinsic =
-    '$intrinsic'
-    '('
-    name:Name
-    ')'
 ExprString =
     Text
 ExprNumber =
@@ -110,9 +101,6 @@
 |   ExprApply
 |   ExprObjExtend
 |   ExprParened
-|   ExprIntrinsicThisFile
-|   ExprIntrinsicId
-|   ExprIntrinsic
 |   ExprString
 |   ExprNumber
 |   ExprLiteral
@@ -167,14 +155,7 @@
 
 ObjBodyComp =
     '{'
-    pre:ObjLocalPostComma*
-    '['
-    key:LhsExpr
-    ']'
-    '+'?
-    ':'
-    value:Expr
-    post:ObjLocalPreComma*
+    (MemberComp (',' MemberComp)* ','?)?
     CompSpec*
     '}'
 ObjBodyMemberList =
@@ -185,13 +166,6 @@
     ObjBodyComp
 |   ObjBodyMemberList
 
-ObjLocalPostComma =
-    ObjLocal
-    ','
-ObjLocalPreComma =
-    ','
-    ObjLocal
-
 MemberBindStmt = ObjLocal
 MemberAssertStmt = Assertion
 MemberFieldNormal =
@@ -204,6 +178,10 @@
     ParamsDesc
     Visibility
     Expr
+MemberComp =
+    MemberBindStmt
+|    MemberFieldNormal
+|   MemberFieldMethod
 Member =
     MemberBindStmt
 |   MemberAssertStmt
@@ -367,7 +345,7 @@
 |   'LIT_SINGLE_LINE_HASH_COMMENT!'
 |   'LIT_SINGLE_LINE_SLASH_COMMENT!'
 
-ParsingError =
+CustomError =
     'ERROR_MISSING_TOKEN!'
 |   'ERROR_UNEXPECTED_TOKEN!'
 |   'ERROR_CUSTOM!'
modifiedcrates/jrsonnet-rowan-parser/src/generated/nodes.rsdiffbeforeafterboth
211 }211 }
212}212}
213
214#[derive(Debug, Clone, PartialEq, Eq, Hash)]
215pub struct ExprIntrinsicThisFile {
216 pub(crate) syntax: SyntaxNode,
217}
218impl ExprIntrinsicThisFile {
219 pub fn intrinsic_this_file_token(&self) -> Option<SyntaxToken> {
220 support::token(&self.syntax, T!["$intrinsicThisFile"])
221 }
222}
223
224#[derive(Debug, Clone, PartialEq, Eq, Hash)]
225pub struct ExprIntrinsicId {
226 pub(crate) syntax: SyntaxNode,
227}
228impl ExprIntrinsicId {
229 pub fn intrinsic_id_token(&self) -> Option<SyntaxToken> {
230 support::token(&self.syntax, T!["$intrinsicId"])
231 }
232}
233
234#[derive(Debug, Clone, PartialEq, Eq, Hash)]
235pub struct ExprIntrinsic {
236 pub(crate) syntax: SyntaxNode,
237}
238impl ExprIntrinsic {
239 pub fn intrinsic_token(&self) -> Option<SyntaxToken> {
240 support::token(&self.syntax, T!["$intrinsic"])
241 }
242 pub fn l_paren_token(&self) -> Option<SyntaxToken> {
243 support::token(&self.syntax, T!['('])
244 }
245 pub fn name(&self) -> Option<Name> {
246 support::child(&self.syntax)
247 }
248 pub fn r_paren_token(&self) -> Option<SyntaxToken> {
249 support::token(&self.syntax, T![')'])
250 }
251}
252213
253#[derive(Debug, Clone, PartialEq, Eq, Hash)]214#[derive(Debug, Clone, PartialEq, Eq, Hash)]
254pub struct ExprString {215pub struct ExprString {
535 pub fn l_brace_token(&self) -> Option<SyntaxToken> {496 pub fn l_brace_token(&self) -> Option<SyntaxToken> {
536 support::token(&self.syntax, T!['{'])497 support::token(&self.syntax, T!['{'])
537 }498 }
538 pub fn pre(&self) -> AstChildren<ObjLocalPostComma> {499 pub fn member_comps(&self) -> AstChildren<MemberComp> {
539 support::children(&self.syntax)500 support::children(&self.syntax)
540 }501 }
541 pub fn l_brack_token(&self) -> Option<SyntaxToken> {
542 support::token(&self.syntax, T!['['])
543 }
544 pub fn key(&self) -> Option<LhsExpr> {
545 support::child(&self.syntax)
546 }
547 pub fn r_brack_token(&self) -> Option<SyntaxToken> {
548 support::token(&self.syntax, T![']'])
549 }
550 pub fn plus_token(&self) -> Option<SyntaxToken> {
551 support::token(&self.syntax, T![+])
552 }
553 pub fn colon_token(&self) -> Option<SyntaxToken> {
554 support::token(&self.syntax, T![:])
555 }
556 pub fn value(&self) -> Option<Expr> {
557 support::child(&self.syntax)
558 }
559 pub fn post(&self) -> AstChildren<ObjLocalPreComma> {
560 support::children(&self.syntax)
561 }
562 pub fn comp_specs(&self) -> AstChildren<CompSpec> {502 pub fn comp_specs(&self) -> AstChildren<CompSpec> {
563 support::children(&self.syntax)503 support::children(&self.syntax)
564 }504 }
567 }507 }
568}508}
569
570#[derive(Debug, Clone, PartialEq, Eq, Hash)]
571pub struct ObjLocalPostComma {
572 pub(crate) syntax: SyntaxNode,
573}
574impl ObjLocalPostComma {
575 pub fn obj_local(&self) -> Option<ObjLocal> {
576 support::child(&self.syntax)
577 }
578 pub fn comma_token(&self) -> Option<SyntaxToken> {
579 support::token(&self.syntax, T![,])
580 }
581}
582
583#[derive(Debug, Clone, PartialEq, Eq, Hash)]
584pub struct ObjLocalPreComma {
585 pub(crate) syntax: SyntaxNode,
586}
587impl ObjLocalPreComma {
588 pub fn comma_token(&self) -> Option<SyntaxToken> {
589 support::token(&self.syntax, T![,])
590 }
591 pub fn obj_local(&self) -> Option<ObjLocal> {
592 support::child(&self.syntax)
593 }
594}
595509
596#[derive(Debug, Clone, PartialEq, Eq, Hash)]510#[derive(Debug, Clone, PartialEq, Eq, Hash)]
597pub struct ObjBodyMemberList {511pub struct ObjBodyMemberList {
609 }523 }
610}524}
611
612#[derive(Debug, Clone, PartialEq, Eq, Hash)]
613pub struct ObjLocal {
614 pub(crate) syntax: SyntaxNode,
615}
616impl ObjLocal {
617 pub fn local_kw_token(&self) -> Option<SyntaxToken> {
618 support::token(&self.syntax, T![local])
619 }
620 pub fn bind(&self) -> Option<Bind> {
621 support::child(&self.syntax)
622 }
623}
624525
625#[derive(Debug, Clone, PartialEq, Eq, Hash)]526#[derive(Debug, Clone, PartialEq, Eq, Hash)]
626pub struct MemberBindStmt {527pub struct MemberBindStmt {
632 }533 }
633}534}
535
536#[derive(Debug, Clone, PartialEq, Eq, Hash)]
537pub struct ObjLocal {
538 pub(crate) syntax: SyntaxNode,
539}
540impl ObjLocal {
541 pub fn local_kw_token(&self) -> Option<SyntaxToken> {
542 support::token(&self.syntax, T![local])
543 }
544 pub fn bind(&self) -> Option<Bind> {
545 support::child(&self.syntax)
546 }
547}
634548
635#[derive(Debug, Clone, PartialEq, Eq, Hash)]549#[derive(Debug, Clone, PartialEq, Eq, Hash)]
636pub struct MemberAssertStmt {550pub struct MemberAssertStmt {
905 ExprApply(ExprApply),819 ExprApply(ExprApply),
906 ExprObjExtend(ExprObjExtend),820 ExprObjExtend(ExprObjExtend),
907 ExprParened(ExprParened),821 ExprParened(ExprParened),
908 ExprIntrinsicThisFile(ExprIntrinsicThisFile),
909 ExprIntrinsicId(ExprIntrinsicId),
910 ExprIntrinsic(ExprIntrinsic),
911 ExprString(ExprString),822 ExprString(ExprString),
912 ExprNumber(ExprNumber),823 ExprNumber(ExprNumber),
913 ExprLiteral(ExprLiteral),824 ExprLiteral(ExprLiteral),
941 BindFunction(BindFunction),852 BindFunction(BindFunction),
942}853}
854
855#[derive(Debug, Clone, PartialEq, Eq, Hash)]
856pub enum MemberComp {
857 MemberBindStmt(MemberBindStmt),
858 MemberFieldNormal(MemberFieldNormal),
859 MemberFieldMethod(MemberFieldMethod),
860}
943861
944#[derive(Debug, Clone, PartialEq, Eq, Hash)]862#[derive(Debug, Clone, PartialEq, Eq, Hash)]
945pub enum Member {863pub enum Member {
1110}1028}
11111029
1112#[derive(Debug, Clone, PartialEq, Eq, Hash)]1030#[derive(Debug, Clone, PartialEq, Eq, Hash)]
1113pub struct ParsingError {1031pub struct CustomError {
1114 syntax: SyntaxToken,1032 syntax: SyntaxToken,
1115 kind: ParsingErrorKind,1033 kind: CustomErrorKind,
1116}1034}
11171035
1118#[derive(Debug, Clone, Copy, PartialEq, Eq, Hash)]1036#[derive(Debug, Clone, Copy, PartialEq, Eq, Hash)]
1119pub enum ParsingErrorKind {1037pub enum CustomErrorKind {
1120 ErrorMissingToken,1038 ErrorMissingToken,
1121 ErrorUnexpectedToken,1039 ErrorUnexpectedToken,
1122 ErrorCustom,1040 ErrorCustom,
1331 &self.syntax1249 &self.syntax
1332 }1250 }
1333}1251}
1334impl AstNode for ExprIntrinsicThisFile {
1335 fn can_cast(kind: SyntaxKind) -> bool {
1336 kind == EXPR_INTRINSIC_THIS_FILE
1337 }
1338 fn cast(syntax: SyntaxNode) -> Option<Self> {
1339 if Self::can_cast(syntax.kind()) {
1340 Some(Self { syntax })
1341 } else {
1342 None
1343 }
1344 }
1345 fn syntax(&self) -> &SyntaxNode {
1346 &self.syntax
1347 }
1348}
1349impl AstNode for ExprIntrinsicId {
1350 fn can_cast(kind: SyntaxKind) -> bool {
1351 kind == EXPR_INTRINSIC_ID
1352 }
1353 fn cast(syntax: SyntaxNode) -> Option<Self> {
1354 if Self::can_cast(syntax.kind()) {
1355 Some(Self { syntax })
1356 } else {
1357 None
1358 }
1359 }
1360 fn syntax(&self) -> &SyntaxNode {
1361 &self.syntax
1362 }
1363}
1364impl AstNode for ExprIntrinsic {
1365 fn can_cast(kind: SyntaxKind) -> bool {
1366 kind == EXPR_INTRINSIC
1367 }
1368 fn cast(syntax: SyntaxNode) -> Option<Self> {
1369 if Self::can_cast(syntax.kind()) {
1370 Some(Self { syntax })
1371 } else {
1372 None
1373 }
1374 }
1375 fn syntax(&self) -> &SyntaxNode {
1376 &self.syntax
1377 }
1378}
1379impl AstNode for ExprString {1252impl AstNode for ExprString {
1380 fn can_cast(kind: SyntaxKind) -> bool {1253 fn can_cast(kind: SyntaxKind) -> bool {
1381 kind == EXPR_STRING1254 kind == EXPR_STRING
1676 &self.syntax1549 &self.syntax
1677 }1550 }
1678}1551}
1679impl AstNode for ObjLocalPostComma {
1680 fn can_cast(kind: SyntaxKind) -> bool {
1681 kind == OBJ_LOCAL_POST_COMMA
1682 }
1683 fn cast(syntax: SyntaxNode) -> Option<Self> {
1684 if Self::can_cast(syntax.kind()) {
1685 Some(Self { syntax })
1686 } else {
1687 None
1688 }
1689 }
1690 fn syntax(&self) -> &SyntaxNode {
1691 &self.syntax
1692 }
1693}
1694impl AstNode for ObjLocalPreComma {
1695 fn can_cast(kind: SyntaxKind) -> bool {
1696 kind == OBJ_LOCAL_PRE_COMMA
1697 }
1698 fn cast(syntax: SyntaxNode) -> Option<Self> {
1699 if Self::can_cast(syntax.kind()) {
1700 Some(Self { syntax })
1701 } else {
1702 None
1703 }
1704 }
1705 fn syntax(&self) -> &SyntaxNode {
1706 &self.syntax
1707 }
1708}
1709impl AstNode for ObjBodyMemberList {1552impl AstNode for ObjBodyMemberList {
1710 fn can_cast(kind: SyntaxKind) -> bool {1553 fn can_cast(kind: SyntaxKind) -> bool {
1711 kind == OBJ_BODY_MEMBER_LIST1554 kind == OBJ_BODY_MEMBER_LIST
1721 &self.syntax1564 &self.syntax
1722 }1565 }
1723}1566}
1724impl AstNode for ObjLocal {
1725 fn can_cast(kind: SyntaxKind) -> bool {
1726 kind == OBJ_LOCAL
1727 }
1728 fn cast(syntax: SyntaxNode) -> Option<Self> {
1729 if Self::can_cast(syntax.kind()) {
1730 Some(Self { syntax })
1731 } else {
1732 None
1733 }
1734 }
1735 fn syntax(&self) -> &SyntaxNode {
1736 &self.syntax
1737 }
1738}
1739impl AstNode for MemberBindStmt {1567impl AstNode for MemberBindStmt {
1740 fn can_cast(kind: SyntaxKind) -> bool {1568 fn can_cast(kind: SyntaxKind) -> bool {
1741 kind == MEMBER_BIND_STMT1569 kind == MEMBER_BIND_STMT
1751 &self.syntax1579 &self.syntax
1752 }1580 }
1753}1581}
1582impl AstNode for ObjLocal {
1583 fn can_cast(kind: SyntaxKind) -> bool {
1584 kind == OBJ_LOCAL
1585 }
1586 fn cast(syntax: SyntaxNode) -> Option<Self> {
1587 if Self::can_cast(syntax.kind()) {
1588 Some(Self { syntax })
1589 } else {
1590 None
1591 }
1592 }
1593 fn syntax(&self) -> &SyntaxNode {
1594 &self.syntax
1595 }
1596}
1754impl AstNode for MemberAssertStmt {1597impl AstNode for MemberAssertStmt {
1755 fn can_cast(kind: SyntaxKind) -> bool {1598 fn can_cast(kind: SyntaxKind) -> bool {
1756 kind == MEMBER_ASSERT_STMT1599 kind == MEMBER_ASSERT_STMT
2046 Expr::ExprParened(node)1889 Expr::ExprParened(node)
2047 }1890 }
2048}1891}
2049impl From<ExprIntrinsicThisFile> for Expr {
2050 fn from(node: ExprIntrinsicThisFile) -> Expr {
2051 Expr::ExprIntrinsicThisFile(node)
2052 }
2053}
2054impl From<ExprIntrinsicId> for Expr {
2055 fn from(node: ExprIntrinsicId) -> Expr {
2056 Expr::ExprIntrinsicId(node)
2057 }
2058}
2059impl From<ExprIntrinsic> for Expr {
2060 fn from(node: ExprIntrinsic) -> Expr {
2061 Expr::ExprIntrinsic(node)
2062 }
2063}
2064impl From<ExprString> for Expr {1892impl From<ExprString> for Expr {
2065 fn from(node: ExprString) -> Expr {1893 fn from(node: ExprString) -> Expr {
2066 Expr::ExprString(node)1894 Expr::ExprString(node)
2137 | EXPR_APPLY
2138 | EXPR_OBJ_EXTEND1961 | EXPR_OBJ_EXTEND | EXPR_PARENED | EXPR_STRING | EXPR_NUMBER | EXPR_LITERAL
2139 | EXPR_PARENED
2140 | EXPR_INTRINSIC_THIS_FILE
2141 | EXPR_INTRINSIC_ID
2142 | EXPR_INTRINSIC
2143 | EXPR_STRING
2144 | EXPR_NUMBER
2145 | EXPR_LITERAL
2166 EXPR_APPLY => Expr::ExprApply(ExprApply { syntax }),1974 EXPR_APPLY => Expr::ExprApply(ExprApply { syntax }),
2167 EXPR_OBJ_EXTEND => Expr::ExprObjExtend(ExprObjExtend { syntax }),1975 EXPR_OBJ_EXTEND => Expr::ExprObjExtend(ExprObjExtend { syntax }),
2168 EXPR_PARENED => Expr::ExprParened(ExprParened { syntax }),1976 EXPR_PARENED => Expr::ExprParened(ExprParened { syntax }),
2169 EXPR_INTRINSIC_THIS_FILE => {
2170 Expr::ExprIntrinsicThisFile(ExprIntrinsicThisFile { syntax })
2171 }
2172 EXPR_INTRINSIC_ID => Expr::ExprIntrinsicId(ExprIntrinsicId { syntax }),
2173 EXPR_INTRINSIC => Expr::ExprIntrinsic(ExprIntrinsic { syntax }),
2174 EXPR_STRING => Expr::ExprString(ExprString { syntax }),1977 EXPR_STRING => Expr::ExprString(ExprString { syntax }),
2175 EXPR_NUMBER => Expr::ExprNumber(ExprNumber { syntax }),1978 EXPR_NUMBER => Expr::ExprNumber(ExprNumber { syntax }),
2176 EXPR_LITERAL => Expr::ExprLiteral(ExprLiteral { syntax }),1979 EXPR_LITERAL => Expr::ExprLiteral(ExprLiteral { syntax }),
2198 Expr::ExprApply(it) => &it.syntax,2001 Expr::ExprApply(it) => &it.syntax,
2199 Expr::ExprObjExtend(it) => &it.syntax,2002 Expr::ExprObjExtend(it) => &it.syntax,
2200 Expr::ExprParened(it) => &it.syntax,2003 Expr::ExprParened(it) => &it.syntax,
2201 Expr::ExprIntrinsicThisFile(it) => &it.syntax,
2202 Expr::ExprIntrinsicId(it) => &it.syntax,
2203 Expr::ExprIntrinsic(it) => &it.syntax,
2204 Expr::ExprString(it) => &it.syntax,2004 Expr::ExprString(it) => &it.syntax,
2205 Expr::ExprNumber(it) => &it.syntax,2005 Expr::ExprNumber(it) => &it.syntax,
2206 Expr::ExprLiteral(it) => &it.syntax,2006 Expr::ExprLiteral(it) => &it.syntax,
2313 }2113 }
2314 }2114 }
2315}2115}
2116impl From<MemberBindStmt> for MemberComp {
2117 fn from(node: MemberBindStmt) -> MemberComp {
2118 MemberComp::MemberBindStmt(node)
2119 }
2120}
2121impl From<MemberFieldNormal> for MemberComp {
2122 fn from(node: MemberFieldNormal) -> MemberComp {
2123 MemberComp::MemberFieldNormal(node)
2124 }
2125}
2126impl From<MemberFieldMethod> for MemberComp {
2127 fn from(node: MemberFieldMethod) -> MemberComp {
2128 MemberComp::MemberFieldMethod(node)
2129 }
2130}
2131impl AstNode for MemberComp {
2132 fn can_cast(kind: SyntaxKind) -> bool {
2133 match kind {
2134 MEMBER_BIND_STMT | MEMBER_FIELD_NORMAL | MEMBER_FIELD_METHOD => true,
2135 _ => false,
2136 }
2137 }
2138 fn cast(syntax: SyntaxNode) -> Option<Self> {
2139 let res = match syntax.kind() {
2140 MEMBER_BIND_STMT => MemberComp::MemberBindStmt(MemberBindStmt { syntax }),
2141 MEMBER_FIELD_NORMAL => MemberComp::MemberFieldNormal(MemberFieldNormal { syntax }),
2142 MEMBER_FIELD_METHOD => MemberComp::MemberFieldMethod(MemberFieldMethod { syntax }),
2143 _ => return None,
2144 };
2145 Some(res)
2146 }
2147 fn syntax(&self) -> &SyntaxNode {
2148 match self {
2149 MemberComp::MemberBindStmt(it) => &it.syntax,
2150 MemberComp::MemberFieldNormal(it) => &it.syntax,
2151 MemberComp::MemberFieldMethod(it) => &it.syntax,
2152 }
2153 }
2154}
2316impl From<MemberBindStmt> for Member {2155impl From<MemberBindStmt> for Member {
2317 fn from(node: MemberBindStmt) -> Member {2156 fn from(node: MemberBindStmt) -> Member {
2318 Member::MemberBindStmt(node)2157 Member::MemberBindStmt(node)
2847 std::fmt::Display::fmt(self.syntax(), f)2686 std::fmt::Display::fmt(self.syntax(), f)
2848 }2687 }
2849}2688}
2850impl AstToken for ParsingError {2689impl AstToken for CustomError {
2851 fn can_cast(kind: SyntaxKind) -> bool {2690 fn can_cast(kind: SyntaxKind) -> bool {
2852 ParsingErrorKind::can_cast(kind)2691 CustomErrorKind::can_cast(kind)
2853 }2692 }
2854 fn cast(syntax: SyntaxToken) -> Option<Self> {2693 fn cast(syntax: SyntaxToken) -> Option<Self> {
2855 let kind = ParsingErrorKind::cast(syntax.kind())?;2694 let kind = CustomErrorKind::cast(syntax.kind())?;
2856 Some(ParsingError { syntax, kind })2695 Some(CustomError { syntax, kind })
2857 }2696 }
2858 fn syntax(&self) -> &SyntaxToken {2697 fn syntax(&self) -> &SyntaxToken {
2859 &self.syntax2698 &self.syntax
2860 }2699 }
2861}2700}
2862impl ParsingErrorKind {2701impl CustomErrorKind {
2863 fn can_cast(kind: SyntaxKind) -> bool {2702 fn can_cast(kind: SyntaxKind) -> bool {
2864 match kind {2703 match kind {
2865 ERROR_MISSING_TOKEN | ERROR_UNEXPECTED_TOKEN | ERROR_CUSTOM => true,2704 ERROR_MISSING_TOKEN | ERROR_UNEXPECTED_TOKEN | ERROR_CUSTOM => true,
2876 Some(res)2715 Some(res)
2877 }2716 }
2878}2717}
2879impl ParsingError {2718impl CustomError {
2880 pub fn kind(&self) -> ParsingErrorKind {2719 pub fn kind(&self) -> CustomErrorKind {
2881 self.kind2720 self.kind
2882 }2721 }
2883}2722}
2884impl std::fmt::Display for ParsingError {2723impl std::fmt::Display for CustomError {
2885 fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result {2724 fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result {
2886 std::fmt::Display::fmt(self.syntax(), f)2725 std::fmt::Display::fmt(self.syntax(), f)
2887 }2726 }
2906 std::fmt::Display::fmt(self.syntax(), f)2745 std::fmt::Display::fmt(self.syntax(), f)
2907 }2746 }
2908}2747}
2748impl std::fmt::Display for MemberComp {
2749 fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result {
2750 std::fmt::Display::fmt(self.syntax(), f)
2751 }
2752}
2909impl std::fmt::Display for Member {2753impl std::fmt::Display for Member {
2910 fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result {2754 fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result {
2911 std::fmt::Display::fmt(self.syntax(), f)2755 std::fmt::Display::fmt(self.syntax(), f)
2996 std::fmt::Display::fmt(self.syntax(), f)2840 std::fmt::Display::fmt(self.syntax(), f)
2997 }2841 }
2998}2842}
2999impl std::fmt::Display for ExprIntrinsicThisFile {
3000 fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result {
3001 std::fmt::Display::fmt(self.syntax(), f)
3002 }
3003}
3004impl std::fmt::Display for ExprIntrinsicId {
3005 fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result {
3006 std::fmt::Display::fmt(self.syntax(), f)
3007 }
3008}
3009impl std::fmt::Display for ExprIntrinsic {
3010 fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result {
3011 std::fmt::Display::fmt(self.syntax(), f)
3012 }
3013}
3014impl std::fmt::Display for ExprString {2843impl std::fmt::Display for ExprString {
3015 fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result {2844 fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result {
3016 std::fmt::Display::fmt(self.syntax(), f)2845 std::fmt::Display::fmt(self.syntax(), f)
3111 std::fmt::Display::fmt(self.syntax(), f)2940 std::fmt::Display::fmt(self.syntax(), f)
3112 }2941 }
3113}2942}
3114impl std::fmt::Display for ObjLocalPostComma {
3115 fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result {
3116 std::fmt::Display::fmt(self.syntax(), f)
3117 }
3118}
3119impl std::fmt::Display for ObjLocalPreComma {
3120 fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result {
3121 std::fmt::Display::fmt(self.syntax(), f)
3122 }
3123}
3124impl std::fmt::Display for ObjBodyMemberList {2943impl std::fmt::Display for ObjBodyMemberList {
3125 fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result {2944 fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result {
3126 std::fmt::Display::fmt(self.syntax(), f)2945 std::fmt::Display::fmt(self.syntax(), f)
3127 }2946 }
3128}2947}
3129impl std::fmt::Display for ObjLocal {
3130 fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result {
3131 std::fmt::Display::fmt(self.syntax(), f)
3132 }
3133}
3134impl std::fmt::Display for MemberBindStmt {2948impl std::fmt::Display for MemberBindStmt {
3135 fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result {2949 fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result {
3136 std::fmt::Display::fmt(self.syntax(), f)2950 std::fmt::Display::fmt(self.syntax(), f)
3137 }2951 }
3138}2952}
2953impl std::fmt::Display for ObjLocal {
2954 fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result {
2955 std::fmt::Display::fmt(self.syntax(), f)
2956 }
2957}
3139impl std::fmt::Display for MemberAssertStmt {2958impl std::fmt::Display for MemberAssertStmt {
3140 fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result {2959 fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result {
3141 std::fmt::Display::fmt(self.syntax(), f)2960 std::fmt::Display::fmt(self.syntax(), f)
modifiedcrates/jrsonnet-rowan-parser/src/generated/syntax_kinds.rsdiffbeforeafterboth
--- a/crates/jrsonnet-rowan-parser/src/generated/syntax_kinds.rs
+++ b/crates/jrsonnet-rowan-parser/src/generated/syntax_kinds.rs
@@ -89,12 +89,6 @@
 	ASSIGN,
 	#[token("?")]
 	QUESTION_MARK,
-	#[token("$intrinsicThisFile")]
-	INTRINSIC_THIS_FILE,
-	#[token("$intrinsicId")]
-	INTRINSIC_ID,
-	#[token("$intrinsic")]
-	INTRINSIC,
 	#[regex("(?:0|[1-9][0-9]*)(?:\\.[0-9]+)?(?:[eE][+-]?[0-9]+)?")]
 	FLOAT,
 	#[regex("(?:0|[1-9][0-9]*)\\.[^0-9]")]
@@ -199,9 +193,6 @@
 	EXPR_OBJ_EXTEND,
 	EXPR_PARENED,
 	EXPR_LITERAL,
-	EXPR_INTRINSIC_THIS_FILE,
-	EXPR_INTRINSIC_ID,
-	EXPR_INTRINSIC,
 	EXPR_STRING,
 	EXPR_NUMBER,
 	EXPR_ARRAY,
@@ -222,11 +213,9 @@
 	SLICE_DESC_STEP,
 	ARG,
 	OBJ_BODY_COMP,
-	OBJ_LOCAL_POST_COMMA,
-	OBJ_LOCAL_PRE_COMMA,
 	OBJ_BODY_MEMBER_LIST,
-	OBJ_LOCAL,
 	MEMBER_BIND_STMT,
+	OBJ_LOCAL,
 	MEMBER_ASSERT_STMT,
 	MEMBER_FIELD_NORMAL,
 	MEMBER_FIELD_METHOD,
@@ -248,6 +237,7 @@
 	OBJ_BODY,
 	COMP_SPEC,
 	BIND,
+	MEMBER_COMP,
 	MEMBER,
 	FIELD_NAME,
 	DESTRUCT,
@@ -260,7 +250,7 @@
 	IMPORT_KIND,
 	VISIBILITY,
 	TRIVIA,
-	PARSING_ERROR,
+	CUSTOM_ERROR,
 	#[doc(hidden)]
 	__LAST,
 }
@@ -271,18 +261,18 @@
 			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 | 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,
+			| DOTDOTDOT | COMMA | DOLLAR | ASSIGN | QUESTION_MARK | 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_enum(self) -> bool {
 		match self {
-			EXPR | OBJ_BODY | COMP_SPEC | BIND | MEMBER | FIELD_NAME | DESTRUCT
+			EXPR | OBJ_BODY | COMP_SPEC | BIND | MEMBER_COMP | MEMBER | FIELD_NAME | DESTRUCT
 			| DESTRUCT_ARRAY_PART | BINARY_OPERATOR | UNARY_OPERATOR | LITERAL | TEXT | NUMBER
-			| IMPORT_KIND | VISIBILITY | TRIVIA | PARSING_ERROR => true,
+			| IMPORT_KIND | VISIBILITY | TRIVIA | CUSTOM_ERROR => true,
 			_ => false,
 		}
 	}
@@ -295,5 +285,5 @@
 	}
 }
 #[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 } }
+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 } ; [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 } }
 pub use T;
modifiedcrates/jrsonnet-rowan-parser/src/parser.rsdiffbeforeafterboth
--- a/crates/jrsonnet-rowan-parser/src/parser.rs
+++ b/crates/jrsonnet-rowan-parser/src/parser.rs
@@ -114,7 +114,13 @@
 	pub fn parse(mut self) -> Vec<Event> {
 		let m = self.start();
 		expr(&mut self);
-		self.expect(EOF);
+		if !self.at(EOF) {
+			let m = self.start();
+			while !self.at(EOF) {
+				self.bump();
+			}
+			m.complete_error(&mut self, "unexpected tokens after end");
+		}
 		m.complete(&mut self, SOURCE_FILE);
 
 		self.events
@@ -832,21 +838,6 @@
 		let m = p.start();
 		name(p);
 		m.complete(p, EXPR_VAR)
-	} else if p.at(INTRINSIC_THIS_FILE) {
-		let m = p.start();
-		p.bump();
-		m.complete(p, EXPR_INTRINSIC_THIS_FILE)
-	} else if p.at(INTRINSIC_ID) {
-		let m = p.start();
-		p.bump();
-		m.complete(p, EXPR_INTRINSIC_ID)
-	} else if p.at(INTRINSIC) {
-		let m = p.start();
-		p.bump();
-		p.expect(T!['(']);
-		name(p);
-		p.expect(T![')']);
-		m.complete(p, EXPR_INTRINSIC)
 	} else if p.at(T![if]) {
 		let m = p.start();
 		p.bump();
addedcrates/jrsonnet-rowan-parser/src/snapshots/jrsonnet_rowan_parser__tests__continue_after_total_failure.snapdiffbeforeafterboth
--- /dev/null
+++ b/crates/jrsonnet-rowan-parser/src/snapshots/jrsonnet_rowan_parser__tests__continue_after_total_failure.snap
@@ -0,0 +1,74 @@
+---
+source: crates/jrsonnet-rowan-parser/src/tests.rs
+expression: "local intr = $intrinsic(test);\n\nlocal a = 1, b = 2, c = a + b;\n\n[c]\n"
+---
+SOURCE_FILE@0..68
+  EXPR_LOCAL@0..29
+    LOCAL_KW@0..5 "local"
+    WHITESPACE@5..6 " "
+    BIND_DESTRUCT@6..14
+      DESTRUCT_FULL@6..10
+        NAME@6..10
+          IDENT@6..10 "intr"
+      WHITESPACE@10..11 " "
+      ASSIGN@11..12 "="
+      WHITESPACE@12..13 " "
+      EXPR_LITERAL@13..14
+        DOLLAR@13..14 "$"
+    ERROR_UNEXPECTED_TOKEN@14..23
+      IDENT@14..23 "intrinsic"
+    EXPR_PARENED@23..29
+      L_PAREN@23..24 "("
+      EXPR_VAR@24..28
+        NAME@24..28
+          IDENT@24..28 "test"
+      R_PAREN@28..29 ")"
+  ERROR_CUSTOM@29..67
+    SEMI@29..30 ";"
+    WHITESPACE@30..32 "\n\n"
+    LOCAL_KW@32..37 "local"
+    WHITESPACE@37..38 " "
+    IDENT@38..39 "a"
+    WHITESPACE@39..40 " "
+    ASSIGN@40..41 "="
+    WHITESPACE@41..42 " "
+    FLOAT@42..43 "1"
+    COMMA@43..44 ","
+    WHITESPACE@44..45 " "
+    IDENT@45..46 "b"
+    WHITESPACE@46..47 " "
+    ASSIGN@47..48 "="
+    WHITESPACE@48..49 " "
+    FLOAT@49..50 "2"
+    COMMA@50..51 ","
+    WHITESPACE@51..52 " "
+    IDENT@52..53 "c"
+    WHITESPACE@53..54 " "
+    ASSIGN@54..55 "="
+    WHITESPACE@55..56 " "
+    IDENT@56..57 "a"
+    WHITESPACE@57..58 " "
+    PLUS@58..59 "+"
+    WHITESPACE@59..60 " "
+    IDENT@60..61 "b"
+    SEMI@61..62 ";"
+    WHITESPACE@62..64 "\n\n"
+    L_BRACK@64..65 "["
+    IDENT@65..66 "c"
+    R_BRACK@66..67 "]"
+  WHITESPACE@67..68 "\n"
+===
+LocatedSyntaxError { error: Unexpected { expected: Unnamed(SyntaxKindSet([L_BRACK, L_PAREN, L_BRACE, SEMI, DOT, COMMA])), found: IDENT }, range: 14..23 }
+LocatedSyntaxError { error: Custom { error: "unexpected tokens after end" }, range: 29..67 }
+===
+  x syntax error
+   ,-[1:1]
+ 1 | ,-> local intr = $intrinsic(test);
+   : ||              ^^^^|^^^^
+   : ||                  `-- expected L_BRACK, L_PAREN, L_BRACE, SEMI, DOT or COMMA, found IDENT
+ 2 | |
+ 3 | |   local a = 1, b = 2, c = a + b;
+ 4 | |
+ 5 | |-> [c]
+   : `---- unexpected tokens after end
+   `----
modifiedcrates/jrsonnet-rowan-parser/src/snapshots/jrsonnet_rowan_parser__tests__no_lhs.snapdiffbeforeafterboth
--- a/crates/jrsonnet-rowan-parser/src/snapshots/jrsonnet_rowan_parser__tests__no_lhs.snap
+++ b/crates/jrsonnet-rowan-parser/src/snapshots/jrsonnet_rowan_parser__tests__no_lhs.snap
@@ -2,19 +2,21 @@
 source: crates/jrsonnet-rowan-parser/src/tests.rs
 expression: "+ 2\n"
 ---
-SOURCE_FILE@0..2
+SOURCE_FILE@0..4
   ERROR_MISSING_TOKEN@0..0
-  ERROR_UNEXPECTED_TOKEN@0..1
+  ERROR_CUSTOM@0..3
     PLUS@0..1 "+"
-  WHITESPACE@1..2 " "
+    WHITESPACE@1..2 " "
+    FLOAT@2..3 "2"
+  WHITESPACE@3..4 "\n"
 ===
 LocatedSyntaxError { error: Missing { expected: Named("expression") }, range: 0..0 }
-LocatedSyntaxError { error: Unexpected { expected: Unnamed(SyntaxKindSet([EOF])), found: PLUS }, range: 0..1 }
+LocatedSyntaxError { error: Custom { error: "unexpected tokens after end" }, range: 0..3 }
 ===
   x syntax error
    ,----
  1 | + 2
-   : ^|
-   : |`-- expected EOF, found PLUS
+   : ^^|
+   : | `-- unexpected tokens after end
    : `-- missing expression
    `----
modifiedcrates/jrsonnet-rowan-parser/src/snapshots/jrsonnet_rowan_parser__tests__no_operator.snapdiffbeforeafterboth
--- a/crates/jrsonnet-rowan-parser/src/snapshots/jrsonnet_rowan_parser__tests__no_operator.snap
+++ b/crates/jrsonnet-rowan-parser/src/snapshots/jrsonnet_rowan_parser__tests__no_operator.snap
@@ -6,15 +6,15 @@
   EXPR_NUMBER@0..1
     FLOAT@0..1 "2"
   WHITESPACE@1..2 " "
-  ERROR_UNEXPECTED_TOKEN@2..3
+  ERROR_CUSTOM@2..3
     FLOAT@2..3 "2"
   WHITESPACE@3..4 "\n"
 ===
-LocatedSyntaxError { error: Unexpected { expected: Unnamed(SyntaxKindSet([EOF, L_BRACK, L_PAREN, L_BRACE, DOT])), found: FLOAT }, range: 2..3 }
+LocatedSyntaxError { error: Custom { error: "unexpected tokens after end" }, range: 2..3 }
 ===
   x syntax error
    ,----
  1 | 2 2
    :   |
-   :   `-- expected EOF, L_BRACK, L_PAREN, L_BRACE or DOT, found FLOAT
+   :   `-- unexpected tokens after end
    `----
modifiedcrates/jrsonnet-rowan-parser/src/tests.rsdiffbeforeafterboth
--- a/crates/jrsonnet-rowan-parser/src/tests.rs
+++ b/crates/jrsonnet-rowan-parser/src/tests.rs
@@ -228,6 +228,14 @@
 			a: function(x) x,
 		}
 	"#
+
+	continue_after_total_failure => r#"
+		local intr = $intrinsic(test);
+
+		local a = 1, b = 2, c = a + b;
+
+		[c]
+	"#
 );
 
 #[test]
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
@@ -27,7 +27,10 @@
 		SyntaxKindSet(self.0 | mask(kind))
 	}
 
-	pub const fn contains(&self, kind: SyntaxKind) -> bool {
+	pub fn contains(&self, kind: SyntaxKind) -> bool {
+		if !is_token(kind) {
+			return false;
+		}
 		self.0 & mask(kind) != 0
 	}
 }
@@ -74,6 +77,9 @@
 }
 
 const fn mask(kind: SyntaxKind) -> u128 {
+	if kind as u32 > 128 {
+		panic!("mask for not a token kind")
+	}
 	1u128 << (kind as u128)
 }
 
@@ -95,3 +101,6 @@
 		"can't keep KindSet as bitset"
 	);
 }
+fn is_token(kind: SyntaxKind) -> bool {
+	(kind as u32) < 127
+}
modifiedxtask/src/sourcegen/kinds.rsdiffbeforeafterboth
--- a/xtask/src/sourcegen/kinds.rs
+++ b/xtask/src/sourcegen/kinds.rs
@@ -247,9 +247,6 @@
 		"$" => "DOLLAR";
 		"=" => "ASSIGN";
 		"?" => "QUESTION_MARK";
-		"$intrinsicThisFile" => "INTRINSIC_THIS_FILE";
-		"$intrinsicId" => "INTRINSIC_ID";
-		"$intrinsic" => "INTRINSIC";
 		// Literals
 		lit("FLOAT") => r"(?:0|[1-9][0-9]*)(?:\.[0-9]+)?(?:[eE][+-]?[0-9]+)?";
 		error("FLOAT_JUNK_AFTER_POINT") => r"(?:0|[1-9][0-9]*)\.[^0-9]";