From ffbb210910095bef7500e9f20d89e456ad7bfa74 Mon Sep 17 00:00:00 2001 From: Igor Matuszewski Date: Mon, 20 May 2024 11:40:04 +0200 Subject: [PATCH 1/4] refactor!: Rename RuleKind, TokenKind and NodeLabel --- .../cargo/src/runtime/generated/kinds.rs | 12 +- .../cargo/src/runtime/generated/language.rs | 8 +- .../runtime/cargo/src/runtime/kinds.rs.jinja2 | 16 +- .../cargo/src/runtime/language.rs.jinja2 | 18 +- .../runtime/cargo/src/runtime/lexer.rs | 26 +- .../codegen/runtime/cargo/src/runtime/mod.rs | 14 +- .../napi_interface/ast_selectors.rs.jinja2 | 86 +- .../cargo/src/runtime/napi_interface/cst.rs | 50 +- .../src/runtime/napi_interface/cursor.rs | 46 +- .../napi_interface/generated/ast_selectors.rs | 38 +- .../cargo/src/runtime/napi_interface/mod.rs | 12 +- .../runtime/napi_interface/parse_output.rs | 4 +- .../runtime/cargo/src/runtime/parse_error.rs | 8 +- .../runtime/parser_support/choice_helper.rs | 6 +- .../src/runtime/parser_support/context.rs | 13 +- .../runtime/parser_support/parser_function.rs | 34 +- .../runtime/parser_support/parser_result.rs | 76 +- .../parser_support/precedence_helper.rs | 45 +- .../src/runtime/parser_support/recovery.rs | 10 +- .../parser_support/separated_helper.rs | 12 +- .../runtime/parser_support/sequence_helper.rs | 20 +- .../src/keyword_scanner_definition.rs | 2 +- crates/codegen/runtime/generator/src/model.rs | 24 +- .../generator/src/parser_definition.rs | 38 +- .../src/precedence_parser_definition.rs | 22 +- crates/codegen/runtime/generator/src/trie.rs | 20 +- .../npm/src/runtime/ast/ast_types.ts.jinja2 | 54 +- .../runtime/npm/src/runtime/cst/index.ts | 8 +- .../runtime/npm/src/runtime/kinds/index.ts | 12 +- .../napi-bindings/generated/index.d.ts | 52 +- .../napi/bindings/index.d.ts.jinja2 | 2 +- crates/metaslang/cst/src/cst.rs | 130 +- crates/metaslang/cst/src/cursor.rs | 97 +- crates/metaslang/cst/src/lib.rs | 4 +- crates/metaslang/cst/src/query/engine.rs | 16 +- crates/metaslang/cst/src/query/model.rs | 24 +- crates/metaslang/cst/src/query/parser.rs | 8 +- .../src/generated/generated/kinds.rs | 12 +- .../src/generated/generated/language.rs | 4539 +++++++++-------- .../slang_solidity/src/generated/lexer.rs | 26 +- .../cargo/slang_solidity/src/generated/mod.rs | 14 +- .../src/generated/napi_interface/cst.rs | 50 +- .../src/generated/napi_interface/cursor.rs | 46 +- .../napi_interface/generated/ast_selectors.rs | 3083 ++++++----- .../src/generated/napi_interface/mod.rs | 12 +- .../generated/napi_interface/parse_output.rs | 4 +- .../src/generated/parse_error.rs | 8 +- .../generated/parser_support/choice_helper.rs | 6 +- .../src/generated/parser_support/context.rs | 13 +- .../parser_support/parser_function.rs | 34 +- .../generated/parser_support/parser_result.rs | 76 +- .../parser_support/precedence_helper.rs | 45 +- .../src/generated/parser_support/recovery.rs | 10 +- .../parser_support/separated_helper.rs | 12 +- .../parser_support/sequence_helper.rs | 20 +- .../outputs/cargo/slang_solidity/src/main.rs | 4 +- .../cargo/tests/src/cst_output/renderer.rs | 28 +- .../cargo/tests/src/cst_output/runner.rs | 6 +- .../src/doc_examples/tree_query_language.rs | 40 +- .../tests/src/doc_examples/using_queries.rs | 4 +- .../src/doc_examples/using_the_cursor.rs | 34 +- .../src/doc_examples/using_the_parser.rs | 26 +- .../outputs/cargo/tests/src/trivia.rs | 10 +- .../src/generated/ast/generated/ast_types.ts | 3409 +++++++------ .../npm/package/src/generated/cst/index.ts | 8 +- .../npm/package/src/generated/kinds/index.ts | 12 +- .../napi-bindings/generated/index.d.ts | 52 +- .../tests/src/doc-examples/using-queries.ts | 16 +- .../tests/src/doc-examples/using-the-ast.ts | 8 +- .../src/doc-examples/using-the-cursor.ts | 22 +- .../src/doc-examples/using-the-parser.ts | 24 +- .../solidity/testing/sanctuary/src/tests.rs | 4 +- .../src/generated/generated/kinds.rs | 12 +- .../src/generated/generated/language.rs | 250 +- .../slang_testlang/src/generated/lexer.rs | 26 +- .../cargo/slang_testlang/src/generated/mod.rs | 14 +- .../src/generated/napi_interface/cst.rs | 50 +- .../src/generated/napi_interface/cursor.rs | 46 +- .../napi_interface/generated/ast_selectors.rs | 173 +- .../src/generated/napi_interface/mod.rs | 12 +- .../generated/napi_interface/parse_output.rs | 4 +- .../src/generated/parse_error.rs | 8 +- .../generated/parser_support/choice_helper.rs | 6 +- .../src/generated/parser_support/context.rs | 13 +- .../parser_support/parser_function.rs | 34 +- .../generated/parser_support/parser_result.rs | 76 +- .../parser_support/precedence_helper.rs | 45 +- .../src/generated/parser_support/recovery.rs | 10 +- .../parser_support/separated_helper.rs | 12 +- .../parser_support/sequence_helper.rs | 20 +- .../cargo/tests/src/query/engine_tests.rs | 42 +- .../src/generated/ast/generated/ast_types.ts | 176 +- .../npm/package/src/generated/cst/index.ts | 8 +- .../npm/package/src/generated/kinds/index.ts | 12 +- .../napi-bindings/generated/index.d.ts | 52 +- .../outputs/npm/tests/src/tests/ast.ts | 84 +- .../outputs/npm/tests/src/tests/cst-cursor.ts | 66 +- .../outputs/npm/tests/src/tests/cst-output.ts | 30 +- .../outputs/npm/tests/src/tests/errors.ts | 4 +- .../outputs/npm/tests/src/tests/public-api.ts | 14 +- .../outputs/npm/tests/src/tests/query.ts | 8 +- .../npm/tests/src/utils/cst-helpers.ts | 20 +- documentation/public/user-guide/concepts.md | 2 +- 103 files changed, 7390 insertions(+), 6723 deletions(-) diff --git a/crates/codegen/runtime/cargo/src/runtime/generated/kinds.rs b/crates/codegen/runtime/cargo/src/runtime/generated/kinds.rs index e691d07dae..2b3f00611f 100644 --- a/crates/codegen/runtime/cargo/src/runtime/generated/kinds.rs +++ b/crates/codegen/runtime/cargo/src/runtime/generated/kinds.rs @@ -17,13 +17,13 @@ use napi_derive::napi; )] #[cfg_attr(feature = "slang_napi_interfaces", /* derives `Clone` and `Copy` */ napi(string_enum, namespace = "kinds"))] #[cfg_attr(not(feature = "slang_napi_interfaces"), derive(Clone, Copy))] -pub enum RuleKind { +pub enum NonTerminalKind { Stub1, Stub2, Stub3, } -impl metaslang_cst::NonTerminalKind for RuleKind {} +impl metaslang_cst::NonTerminalKind for NonTerminalKind {} #[derive( Debug, @@ -40,7 +40,7 @@ impl metaslang_cst::NonTerminalKind for RuleKind {} #[strum(serialize_all = "snake_case")] #[cfg_attr(feature = "slang_napi_interfaces", /* derives `Clone` and `Copy` */ napi(string_enum, namespace = "kinds"))] #[cfg_attr(not(feature = "slang_napi_interfaces"), derive(Clone, Copy))] -pub enum NodeLabel { +pub enum EdgeLabel { // Built-in: Item, Variant, @@ -57,7 +57,7 @@ pub enum NodeLabel { Stub3, } -impl metaslang_cst::EdgeKind for NodeLabel {} +impl metaslang_cst::EdgeLabel for EdgeLabel {} #[derive( Debug, @@ -73,7 +73,7 @@ impl metaslang_cst::EdgeKind for NodeLabel {} )] #[cfg_attr(feature = "slang_napi_interfaces", /* derives `Clone` and `Copy` */ napi(string_enum, namespace = "kinds"))] #[cfg_attr(not(feature = "slang_napi_interfaces"), derive(Clone, Copy))] -pub enum TokenKind { +pub enum TerminalKind { // Built-in: SKIPPED, @@ -83,7 +83,7 @@ pub enum TokenKind { Stub3, } -impl metaslang_cst::TerminalKind for TokenKind { +impl metaslang_cst::TerminalKind for TerminalKind { fn is_trivia(&self) -> bool { false } diff --git a/crates/codegen/runtime/cargo/src/runtime/generated/language.rs b/crates/codegen/runtime/cargo/src/runtime/generated/language.rs index ff12d1b9c8..fe6c01ef38 100644 --- a/crates/codegen/runtime/cargo/src/runtime/generated/language.rs +++ b/crates/codegen/runtime/cargo/src/runtime/generated/language.rs @@ -16,7 +16,7 @@ use semver::Version; use crate::cst; use crate::kinds::{ - IsLexicalContext, LexicalContext, LexicalContextType, NodeLabel, RuleKind, TokenKind, + EdgeLabel, IsLexicalContext, LexicalContext, LexicalContextType, NonTerminalKind, TerminalKind, }; use crate::lexer::{KeywordScan, Lexer, ScannedToken}; #[cfg(feature = "slang_napi_interfaces")] @@ -65,7 +65,7 @@ impl Language { &self.version } - pub fn parse(&self, kind: RuleKind, input: &str) -> ParseOutput { + pub fn parse(&self, kind: NonTerminalKind, input: &str) -> ParseOutput { unreachable!("Attempting to parse in stubs: {kind}: {input}") } } @@ -79,7 +79,7 @@ impl Lexer for Language { unreachable!("Invoking trailing_trivia in stubs: {input:#?}") } - fn delimiters() -> &'static [(TokenKind, TokenKind)] { + fn delimiters() -> &'static [(TerminalKind, TerminalKind)] { unreachable!("Invoking delimiters in stubs.") } @@ -123,7 +123,7 @@ impl Language { )] pub fn parse_napi( &self, - #[napi(ts_arg_type = "kinds.RuleKind")] kind: RuleKind, + #[napi(ts_arg_type = "kinds.NonTerminalKind")] kind: NonTerminalKind, input: String, ) -> NAPIParseOutput { self.parse(kind, input.as_str()).into() diff --git a/crates/codegen/runtime/cargo/src/runtime/kinds.rs.jinja2 b/crates/codegen/runtime/cargo/src/runtime/kinds.rs.jinja2 index e45543aee6..c6bd2aab26 100644 --- a/crates/codegen/runtime/cargo/src/runtime/kinds.rs.jinja2 +++ b/crates/codegen/runtime/cargo/src/runtime/kinds.rs.jinja2 @@ -15,20 +15,20 @@ use napi_derive::napi; )] #[cfg_attr(feature = "slang_napi_interfaces", /* derives `Clone` and `Copy` */ napi(string_enum, namespace = "kinds"))] #[cfg_attr(not(feature = "slang_napi_interfaces"), derive(Clone, Copy))] -pub enum RuleKind { +pub enum NonTerminalKind { {%- if rendering_in_stubs -%} Stub1, Stub2, Stub3, {%- else -%} - {%- for variant in model.rule_kinds -%} + {%- for variant in model.nonterminal_kinds -%} {# variant.documentation | indent(prefix = "/// ", first = true, blank = true) #} {{ variant }}, {%- endfor -%} {%- endif -%} } -impl metaslang_cst::NonTerminalKind for RuleKind {} +impl metaslang_cst::NonTerminalKind for NonTerminalKind {} #[derive( Debug, @@ -45,7 +45,7 @@ impl metaslang_cst::NonTerminalKind for RuleKind {} #[strum(serialize_all = "snake_case")] #[cfg_attr(feature = "slang_napi_interfaces", /* derives `Clone` and `Copy` */ napi(string_enum, namespace = "kinds"))] #[cfg_attr(not(feature = "slang_napi_interfaces"), derive(Clone, Copy))] -pub enum NodeLabel { +pub enum EdgeLabel { // Built-in: {# _SLANG_INTERNAL_RESERVED_NODE_LABELS_ (keep in sync) #} Item, @@ -69,7 +69,7 @@ pub enum NodeLabel { {%- endif -%} } -impl metaslang_cst::EdgeKind for NodeLabel {} +impl metaslang_cst::EdgeLabel for EdgeLabel {} #[derive( Debug, @@ -85,7 +85,7 @@ impl metaslang_cst::EdgeKind for NodeLabel {} )] #[cfg_attr(feature = "slang_napi_interfaces", /* derives `Clone` and `Copy` */ napi(string_enum, namespace = "kinds"))] #[cfg_attr(not(feature = "slang_napi_interfaces"), derive(Clone, Copy))] -pub enum TokenKind { +pub enum TerminalKind { // Built-in: SKIPPED, @@ -95,14 +95,14 @@ pub enum TokenKind { Stub2, Stub3, {%- else -%} - {%- for variant in model.token_kinds -%} + {%- for variant in model.terminal_kinds -%} {# variant.documentation | indent(prefix = "/// ", first = true, blank = true) #} {{ variant }}, {%- endfor -%} {%- endif -%} } -impl metaslang_cst::TerminalKind for TokenKind { +impl metaslang_cst::TerminalKind for TerminalKind { fn is_trivia(&self) -> bool { {%- if rendering_in_stubs -%} false diff --git a/crates/codegen/runtime/cargo/src/runtime/language.rs.jinja2 b/crates/codegen/runtime/cargo/src/runtime/language.rs.jinja2 index ef0248d1ab..8d3f3fc883 100644 --- a/crates/codegen/runtime/cargo/src/runtime/language.rs.jinja2 +++ b/crates/codegen/runtime/cargo/src/runtime/language.rs.jinja2 @@ -14,7 +14,7 @@ use napi_derive::napi; use crate::cst; use crate::kinds::{ - NodeLabel, IsLexicalContext, LexicalContext, LexicalContextType, RuleKind, TokenKind, + EdgeLabel, IsLexicalContext, LexicalContext, LexicalContextType, NonTerminalKind, TerminalKind, }; use crate::lexer::{KeywordScan, Lexer, ScannedToken}; #[cfg(feature = "slang_napi_interfaces")] @@ -115,13 +115,13 @@ impl Language { {% endif %} - pub fn parse(&self, kind: RuleKind, input: &str) -> ParseOutput { + pub fn parse(&self, kind: NonTerminalKind, input: &str) -> ParseOutput { {%- if rendering_in_stubs -%} unreachable!("Attempting to parse in stubs: {kind}: {input}") {%- else -%} match kind { {%- for parser_name, _ in model.parser_functions -%} - RuleKind::{{ parser_name }} => Self::{{ parser_name | snake_case }}.parse(self, input), + NonTerminalKind::{{ parser_name }} => Self::{{ parser_name | snake_case }}.parse(self, input), {%- endfor -%} } {%- endif -%} @@ -145,7 +145,7 @@ impl Lexer for Language { {%- endif -%} } - fn delimiters() -> &'static [(TokenKind, TokenKind)] { + fn delimiters() -> &'static [(TerminalKind, TerminalKind)] { {%- if rendering_in_stubs -%} unreachable!("Invoking delimiters in stubs.") {%- else -%} @@ -153,7 +153,7 @@ impl Lexer for Language { {%- for context_name, context in model.scanner_contexts %} LexicalContext::{{ context_name }} => &[ {%- for open, close in context.delimiters %} - (TokenKind::{{ open }}, TokenKind::{{ close }}), + (TerminalKind::{{ open }}, TerminalKind::{{ close }}), {%- endfor %} ], {%- endfor %} @@ -175,7 +175,7 @@ impl Lexer for Language { if self.$function(input) && input.position() > furthest_position { furthest_position = input.position(); - longest_token = Some(TokenKind::$kind); + longest_token = Some(TerminalKind::$kind); } input.set_position(save); )* @@ -209,7 +209,7 @@ impl Lexer for Language { if let Some(identifier) = longest_token.filter(|tok| [ {% for name in context.promotable_identifier_scanners %} - TokenKind::{{ name }}, + TerminalKind::{{ name }}, {% endfor %} ] .contains(tok) @@ -260,7 +260,7 @@ impl Lexer for Language { // Skip a character if possible and if we didn't recognize a token None if input.peek().is_some() => { let _ = input.next(); - Some(ScannedToken::Single(TokenKind::SKIPPED)) + Some(ScannedToken::Single(TerminalKind::SKIPPED)) }, None => None, } @@ -294,7 +294,7 @@ impl Language { #[napi(js_name = "parse", ts_return_type = "parse_output.ParseOutput", catch_unwind)] pub fn parse_napi( &self, - #[napi(ts_arg_type = "kinds.RuleKind")] kind: RuleKind, + #[napi(ts_arg_type = "kinds.NonTerminalKind")] kind: NonTerminalKind, input: String ) -> NAPIParseOutput { self.parse(kind, input.as_str()).into() diff --git a/crates/codegen/runtime/cargo/src/runtime/lexer.rs b/crates/codegen/runtime/cargo/src/runtime/lexer.rs index 3094fea736..5d12ca8fec 100644 --- a/crates/codegen/runtime/cargo/src/runtime/lexer.rs +++ b/crates/codegen/runtime/cargo/src/runtime/lexer.rs @@ -1,5 +1,5 @@ -use crate::cst::{self, LabeledNode}; -use crate::kinds::{IsLexicalContext, TokenKind}; +use crate::cst::{self, Edge}; +use crate::kinds::{IsLexicalContext, TerminalKind}; use crate::parser_support::{ParserContext, ParserResult}; /// Whether a keyword has been scanned and if so, whether it is reserved (unusable as an identifier) @@ -10,22 +10,22 @@ pub enum KeywordScan { Absent, /// The keyword is present, but is not reserved. #[allow(unused)] - Present(TokenKind), + Present(TerminalKind), /// The keyword is present and is reserved. - Reserved(TokenKind), + Reserved(TerminalKind), } #[derive(Debug, Clone, Copy, PartialEq, Eq)] pub enum ScannedToken { - Single(TokenKind), + Single(TerminalKind), IdentifierOrKeyword { - identifier: TokenKind, + identifier: TerminalKind, kw: KeywordScan, }, } impl ScannedToken { - pub fn accepted_as(self, expected: TokenKind) -> bool { + pub fn accepted_as(self, expected: TerminalKind) -> bool { match self { Self::Single(kind) => kind == expected, Self::IdentifierOrKeyword { identifier, kw } => match kw { @@ -40,7 +40,7 @@ impl ScannedToken { /// /// If the scanned token is an identifier, returns the specific keyword kind if the keyword is reserved, /// otherwise returns the general identifier kind. For other tokens, returns the token kind itself. - pub fn unambiguous(self) -> TokenKind { + pub fn unambiguous(self) -> TerminalKind { match self { Self::Single(kind) => kind, Self::IdentifierOrKeyword { identifier, kw } => match kw { @@ -67,7 +67,7 @@ pub(crate) trait Lexer { fn trailing_trivia(&self, input: &mut ParserContext<'_>) -> ParserResult; #[doc(hidden)] /// Returns valid grouping delimiters in the given lexical context. - fn delimiters() -> &'static [(TokenKind, TokenKind)]; + fn delimiters() -> &'static [(TerminalKind, TerminalKind)]; /// Peeks the next token, including trivia. Does not advance the input. fn peek_token( @@ -98,7 +98,7 @@ pub(crate) trait Lexer { fn parse_token( &self, input: &mut ParserContext<'_>, - kind: TokenKind, + kind: TerminalKind, ) -> ParserResult { let start = input.position(); if !self @@ -111,7 +111,7 @@ pub(crate) trait Lexer { let end = input.position(); ParserResult::r#match( - vec![LabeledNode::anonymous(cst::Node::token( + vec![Edge::anonymous(cst::Node::terminal( kind, input.content(start.utf8..end.utf8), ))], @@ -124,7 +124,7 @@ pub(crate) trait Lexer { fn parse_token_with_trivia( &self, input: &mut ParserContext<'_>, - kind: TokenKind, + kind: TerminalKind, ) -> ParserResult { let mut children = vec![]; @@ -144,7 +144,7 @@ pub(crate) trait Lexer { return ParserResult::no_match(vec![kind]); } let end = input.position(); - children.push(LabeledNode::anonymous(cst::Node::token( + children.push(Edge::anonymous(cst::Node::terminal( kind, input.content(start.utf8..end.utf8), ))); diff --git a/crates/codegen/runtime/cargo/src/runtime/mod.rs b/crates/codegen/runtime/cargo/src/runtime/mod.rs index 9fe8614b84..09ac4d197f 100644 --- a/crates/codegen/runtime/cargo/src/runtime/mod.rs +++ b/crates/codegen/runtime/cargo/src/runtime/mod.rs @@ -28,9 +28,9 @@ mod metaslang_cst { pub enum KindTypes {} impl metaslang_cst::KindTypes for KindTypes { - type NonTerminalKind = crate::kinds::RuleKind; - type TerminalKind = crate::kinds::TokenKind; - type EdgeKind = crate::kinds::NodeLabel; + type NonTerminalKind = crate::kinds::NonTerminalKind; + type TerminalKind = crate::kinds::TerminalKind; + type EdgeLabel = crate::kinds::EdgeLabel; } } @@ -40,9 +40,9 @@ pub mod cst { use super::metaslang_cst::KindTypes; pub type Node = cst::Node; - pub type RuleNode = cst::NonTerminalNode; - pub type TokenNode = cst::TerminalNode; - pub type LabeledNode = cst::LabeledNode; + pub type NonTerminalNode = cst::NonTerminalNode; + pub type TerminalNode = cst::TerminalNode; + pub type Edge = cst::Edge; } pub mod cursor { @@ -51,7 +51,7 @@ pub mod cursor { use super::metaslang_cst::KindTypes; pub type Cursor = cursor::Cursor; - pub type CursorWithLabels = cursor::CursorWithLabels; + pub type CursorWithEdges = cursor::CursorWithEdges; } pub mod query { diff --git a/crates/codegen/runtime/cargo/src/runtime/napi_interface/ast_selectors.rs.jinja2 b/crates/codegen/runtime/cargo/src/runtime/napi_interface/ast_selectors.rs.jinja2 index c6e80611e7..f31662c8bf 100644 --- a/crates/codegen/runtime/cargo/src/runtime/napi_interface/ast_selectors.rs.jinja2 +++ b/crates/codegen/runtime/cargo/src/runtime/napi_interface/ast_selectors.rs.jinja2 @@ -5,8 +5,8 @@ use std::rc::Rc; use napi::Either; use napi_derive::napi; -use crate::napi_interface::cst::{NAPINodeExtensions, RuleNode, TokenNode}; -use crate::napi_interface::{RuleKind, RustLabeledNode, RustNode, RustRuleNode, TokenKind}; +use crate::napi_interface::cst::{NAPINodeExtensions, NonTerminalNode, TerminalNode}; +use crate::napi_interface::{NonTerminalKind, RustLabeledNode, RustNode, RustRuleNode, TerminalKind}; // // Sequences: @@ -18,8 +18,8 @@ use crate::napi_interface::{RuleKind, RustLabeledNode, RustNode, RustRuleNode, T catch_unwind, )] pub fn select_sequence( - #[napi(ts_arg_type = "cst.RuleNode")] node: &RuleNode, -) -> Result>>> { + #[napi(ts_arg_type = "cst.NonTerminalNode")] node: &NonTerminalNode, +) -> Result>>> { {%- if rendering_in_stubs -%} unreachable!("Invoking AST selectors in stubs: {node:#?}") {%- else -%} @@ -27,7 +27,7 @@ pub fn select_sequence( let result = match node.kind() { {%- for sequence in model.ast.sequences -%} - RuleKind::{{ sequence.name }} => { + NonTerminalKind::{{ sequence.name }} => { selector.{{ sequence.name | snake_case }}()? }, {%- endfor -%} @@ -44,16 +44,16 @@ pub fn select_sequence( {%- if not rendering_in_stubs -%} {% for sequence in model.ast.sequences %} impl Selector { - fn {{ sequence.name | snake_case }}(&mut self) -> Result>>> { + fn {{ sequence.name | snake_case }}(&mut self) -> Result>>> { Ok(vec![ {%- for field in sequence.fields -%} {%- if field.is_optional -%} self.try_select(|node| { {%- if field.is_terminal -%} - node.is_token_with_kind(TokenKind::{{ field.reference }}) + node.is_terminal_with_kind(TerminalKind::{{ field.reference }}) {%- else -%} - node.is_rule_with_kind(RuleKind::{{ field.reference }}) + node.is_nonterminal_with_kind(NonTerminalKind::{{ field.reference }}) {%- endif -%} })?, @@ -61,9 +61,9 @@ pub fn select_sequence( Some(self.select(|node| { {%- if field.is_terminal -%} - node.is_token_with_kind(TokenKind::{{ field.reference }}) + node.is_terminal_with_kind(TerminalKind::{{ field.reference }}) {%- else -%} - node.is_rule_with_kind(RuleKind::{{ field.reference }}) + node.is_nonterminal_with_kind(NonTerminalKind::{{ field.reference }}) {%- endif -%} })?), @@ -85,8 +85,8 @@ pub fn select_sequence( catch_unwind, )] pub fn select_choice( - #[napi(ts_arg_type = "cst.RuleNode")] node: &RuleNode, -) -> Result> { + #[napi(ts_arg_type = "cst.NonTerminalNode")] node: &NonTerminalNode, +) -> Result> { {%- if rendering_in_stubs -%} unreachable!("Invoking AST selectors in stubs: {node:#?}") {%- else -%} @@ -94,7 +94,7 @@ pub fn select_choice( let result = match node.kind() { {%- for choice in model.ast.choices -%} - RuleKind::{{ choice.name }} => { + NonTerminalKind::{{ choice.name }} => { selector.{{ choice.name | snake_case }}()? }, {%- endfor -%} @@ -111,17 +111,17 @@ pub fn select_choice( {% if not rendering_in_stubs %} {% for choice in model.ast.choices %} impl Selector { - fn {{ choice.name | snake_case }}(&mut self) -> Result> { + fn {{ choice.name | snake_case }}(&mut self) -> Result> { self.select(|node| { {%- set non_terminals_len = choice.non_terminals | length -%} {%- set terminals_len = choice.terminals | length -%} {%- if non_terminals_len == 1 -%} - node.is_rule_with_kind(RuleKind::{{ choice.non_terminals[0] }}) + node.is_nonterminal_with_kind(NonTerminalKind::{{ choice.non_terminals[0] }}) {%- elif non_terminals_len > 1 -%} - node.is_rule_with_kinds(&[ + node.is_nonterminal_with_kinds(&[ {%- for non_terminal in choice.non_terminals -%} - RuleKind::{{ non_terminal }}, + NonTerminalKind::{{ non_terminal }}, {%- endfor -%} ]) {%- endif -%} @@ -131,11 +131,11 @@ pub fn select_choice( {%- endif -%} {%- if terminals_len == 1 -%} - node.is_token_with_kind(TokenKind::{{ choice.terminals[0] }}) + node.is_terminal_with_kind(TerminalKind::{{ choice.terminals[0] }}) {%- elif terminals_len > 1 -%} - node.is_token_with_kinds(&[ + node.is_terminal_with_kinds(&[ {%- for terminal in choice.terminals -%} - TokenKind::{{ terminal }}, + TerminalKind::{{ terminal }}, {%- endfor -%} ]) {%- endif -%} @@ -155,8 +155,8 @@ pub fn select_choice( catch_unwind, )] pub fn select_repeated( - #[napi(ts_arg_type = "cst.RuleNode")] node: &RuleNode, -) -> Result>> { + #[napi(ts_arg_type = "cst.NonTerminalNode")] node: &NonTerminalNode, +) -> Result>> { {%- if rendering_in_stubs -%} unreachable!("Invoking AST selectors in stubs: {node:#?}") {%- else -%} @@ -164,7 +164,7 @@ pub fn select_repeated( let result = match node.kind() { {%- for repeated in model.ast.repeated -%} - RuleKind::{{ repeated.name }} => { + NonTerminalKind::{{ repeated.name }} => { selector.{{ repeated.name | snake_case }}()? }, {%- endfor -%} @@ -181,14 +181,14 @@ pub fn select_repeated( {% if not rendering_in_stubs %} {% for repeated in model.ast.repeated %} impl Selector { - fn {{ repeated.name | snake_case }}(&mut self) -> Result>> { + fn {{ repeated.name | snake_case }}(&mut self) -> Result>> { let mut items = vec![]; while let Some(item) = self.try_select(|node| { {%- if repeated.is_terminal -%} - node.is_token_with_kind(TokenKind::{{ repeated.reference }}) + node.is_terminal_with_kind(TerminalKind::{{ repeated.reference }}) {%- else -%} - node.is_rule_with_kind(RuleKind::{{ repeated.reference }}) + node.is_nonterminal_with_kind(NonTerminalKind::{{ repeated.reference }}) {%- endif -%} })? { items.push(item); @@ -210,8 +210,8 @@ pub fn select_repeated( catch_unwind, )] pub fn select_separated( - #[napi(ts_arg_type = "cst.RuleNode")] node: &RuleNode, -) -> Result>>> { + #[napi(ts_arg_type = "cst.NonTerminalNode")] node: &NonTerminalNode, +) -> Result>>> { {%- if rendering_in_stubs -%} unreachable!("Invoking AST selectors in stubs: {node:#?}") {%- else -%} @@ -219,7 +219,7 @@ pub fn select_separated( let result = match node.kind() { {%- for separated in model.ast.separated -%} - RuleKind::{{ separated.name }} => { + NonTerminalKind::{{ separated.name }} => { selector.{{ separated.name | snake_case }}()? }, {%- endfor -%} @@ -236,27 +236,27 @@ pub fn select_separated( {% if not rendering_in_stubs %} {% for separated in model.ast.separated %} impl Selector { - fn {{ separated.name | snake_case }}(&mut self) -> Result>>> { + fn {{ separated.name | snake_case }}(&mut self) -> Result>>> { let mut separated = vec![]; let mut separators = vec![]; if let Some(first) = self.try_select(|node| { {%- if separated.is_terminal -%} - node.is_token_with_kind(TokenKind::{{ separated.reference }}) + node.is_terminal_with_kind(TerminalKind::{{ separated.reference }}) {%- else -%} - node.is_rule_with_kind(RuleKind::{{ separated.reference }}) + node.is_nonterminal_with_kind(NonTerminalKind::{{ separated.reference }}) {%- endif -%} })? { separated.push(first); - while let Some(separator) = self.try_select(|node| node.is_token_with_kind(TokenKind::{{ separated.separator }}))? { + while let Some(separator) = self.try_select(|node| node.is_terminal_with_kind(TerminalKind::{{ separated.separator }}))? { separators.push(separator); separated.push(self.select(|node| { {%- if separated.is_terminal -%} - node.is_token_with_kind(TokenKind::{{ separated.reference }}) + node.is_terminal_with_kind(TerminalKind::{{ separated.reference }}) {%- else -%} - node.is_rule_with_kind(RuleKind::{{ separated.reference }}) + node.is_nonterminal_with_kind(NonTerminalKind::{{ separated.reference }}) {%- endif -%} })?); } @@ -278,21 +278,21 @@ struct Selector { } impl Selector { - fn new(node: &RuleNode) -> Self { + fn new(node: &NonTerminalNode) -> Self { Self { node: Rc::clone(&node.0), index: 0, } } - fn select(&mut self, filter: impl FnOnce(&RustNode) -> bool) -> Result> { + fn select(&mut self, filter: impl FnOnce(&RustNode) -> bool) -> Result> { match self.try_select(filter)? { Some(node) => Ok(node), None => Error::MissingChild(self.index).into(), } } - fn try_select(&mut self, filter: impl FnOnce(&RustNode) -> bool) -> Result>> { + fn try_select(&mut self, filter: impl FnOnce(&RustNode) -> bool) -> Result>> { while let Some(child) = self.node.children.get(self.index) { match child { node if node.is_trivia() => { @@ -301,9 +301,9 @@ impl Selector { continue; } RustLabeledNode { - label: _, - node: RustNode::Token(token), - } if matches!(token.kind, TokenKind::SKIPPED) => { + node: RustNode::Terminal(terminal), + .. + } if matches!(terminal.kind, TerminalKind::SKIPPED) => { return Error::SkippedToken(self.index).into(); } labeled if filter(labeled) => { @@ -333,8 +333,8 @@ type Result = std::result::Result; #[derive(Debug, thiserror::Error)] enum Error { // Should not theoretically happen, since we're only called from our own generated AST types. - #[error("Unexpected parent node with RuleKind '{0}'.")] - UnexpectedParent(RuleKind), + #[error("Unexpected parent node with NonTerminalKind '{0}'.")] + UnexpectedParent(NonTerminalKind), // Should not theoretically happen, since we're only called from our own generated AST types. #[error("Unexpected trailing children at index '{0}'.")] diff --git a/crates/codegen/runtime/cargo/src/runtime/napi_interface/cst.rs b/crates/codegen/runtime/cargo/src/runtime/napi_interface/cst.rs index cf5edf9cb9..98870f9d85 100644 --- a/crates/codegen/runtime/cargo/src/runtime/napi_interface/cst.rs +++ b/crates/codegen/runtime/cargo/src/runtime/napi_interface/cst.rs @@ -6,51 +6,51 @@ use napi_derive::napi; use crate::napi_interface::cursor::Cursor; use crate::napi_interface::text_index::TextIndex; use crate::napi_interface::{ - RuleKind, RustNode, RustRuleNode, RustTextIndex, RustTokenNode, TokenKind, + NonTerminalKind, RustNode, RustRuleNode, RustTextIndex, RustTokenNode, TerminalKind, }; #[napi(namespace = "cst", string_enum)] pub enum NodeType { - Rule, - Token, + NonTerminal, + Terminal, } pub trait NAPINodeExtensions { - fn into_js_either_node(self) -> Either; + fn into_js_either_node(self) -> Either; } impl NAPINodeExtensions for RustNode { - /// Converts the node into `napi` wrapper for `RuleNode | TokenNode` JS object. - fn into_js_either_node(self) -> Either { + /// Converts the node into `napi` wrapper for `NonTerminalNode | TerminalNode` JS object. + fn into_js_either_node(self) -> Either { match self { - RustNode::Rule(rule) => Either::A(RuleNode(rule)), - RustNode::Token(token) => Either::B(TokenNode(token)), + RustNode::NonTerminal(nonterminal) => Either::A(NonTerminalNode(nonterminal)), + RustNode::Terminal(terminal) => Either::B(TerminalNode(terminal)), } } } #[derive(Debug)] #[napi(namespace = "cst")] -pub struct RuleNode(pub(crate) Rc); +pub struct NonTerminalNode(pub(crate) Rc); #[derive(Debug)] #[napi(namespace = "cst")] -pub struct TokenNode(pub(crate) Rc); +pub struct TerminalNode(pub(crate) Rc); #[napi(namespace = "cst")] -impl RuleNode { +impl NonTerminalNode { #[napi( getter, js_name = "type", - ts_return_type = "NodeType.Rule", + ts_return_type = "NodeType.NonTerminal", catch_unwind )] pub fn tipe(&self) -> NodeType { - NodeType::Rule + NodeType::NonTerminal } - #[napi(getter, ts_return_type = "kinds.RuleKind", catch_unwind)] - pub fn kind(&self) -> RuleKind { + #[napi(getter, ts_return_type = "kinds.NonTerminalKind", catch_unwind)] + pub fn kind(&self) -> NonTerminalKind { self.0.kind } @@ -65,7 +65,7 @@ impl RuleNode { } #[napi(ts_return_type = "Array", catch_unwind)] - pub fn children(&self) -> Vec> { + pub fn children(&self) -> Vec> { self.0 .children .iter() @@ -78,7 +78,7 @@ impl RuleNode { &self, #[napi(ts_arg_type = "text_index.TextIndex")] text_offset: TextIndex, ) -> Cursor { - RustNode::Rule(Rc::clone(&self.0)) + RustNode::NonTerminal(Rc::clone(&self.0)) .cursor_with_offset(text_offset.into()) .into() } @@ -105,7 +105,7 @@ impl RuleNode { skip_typescript, catch_unwind )] - pub fn __children(&self) -> Vec> { + pub fn __children(&self) -> Vec> { Self::children(self) } @@ -125,19 +125,19 @@ impl RuleNode { } #[napi(namespace = "cst")] -impl TokenNode { +impl TerminalNode { #[napi( getter, js_name = "type", - ts_return_type = "NodeType.Token", + ts_return_type = "NodeType.Terminal", catch_unwind )] pub fn tipe(&self) -> NodeType { - NodeType::Token + NodeType::Terminal } - #[napi(getter, ts_return_type = "kinds.TokenKind", catch_unwind)] - pub fn kind(&self) -> TokenKind { + #[napi(getter, ts_return_type = "kinds.TerminalKind", catch_unwind)] + pub fn kind(&self) -> TerminalKind { self.0.kind } @@ -158,7 +158,7 @@ impl TokenNode { } #[napi(catch_unwind, js_name = "toJSON")] - /// Serialize the token node to JSON. + /// Serialize the terminal node to JSON. /// /// This method is intended for debugging purposes and may not be stable. pub fn to_json(&self) -> String { @@ -170,7 +170,7 @@ impl TokenNode { &self, #[napi(ts_arg_type = "text_index.TextIndex")] text_offset: TextIndex, ) -> Cursor { - RustNode::Token(Rc::clone(&self.0)) + RustNode::Terminal(Rc::clone(&self.0)) .cursor_with_offset(text_offset.into()) .into() } diff --git a/crates/codegen/runtime/cargo/src/runtime/napi_interface/cursor.rs b/crates/codegen/runtime/cargo/src/runtime/napi_interface/cursor.rs index 6411848b2e..8aa88d5c9e 100644 --- a/crates/codegen/runtime/cargo/src/runtime/napi_interface/cursor.rs +++ b/crates/codegen/runtime/cargo/src/runtime/napi_interface/cursor.rs @@ -7,8 +7,8 @@ use napi::Either; use napi_derive::napi; use text_index::{TextIndex, TextRange}; -use crate::napi_interface::cst::{self, NAPINodeExtensions, RuleNode, TokenNode}; -use crate::napi_interface::{text_index, NodeLabel, RuleKind, RustCursor, TokenKind}; +use crate::napi_interface::cst::{self, NAPINodeExtensions, NonTerminalNode, TerminalNode}; +use crate::napi_interface::{text_index, EdgeLabel, NonTerminalKind, RustCursor, TerminalKind}; #[napi(namespace = "cursor")] pub struct Cursor(pub(super) RustCursor); @@ -52,12 +52,12 @@ impl Cursor { } #[napi(ts_return_type = "cst.Node", catch_unwind)] - pub fn node(&self) -> Either { + pub fn node(&self) -> Either { self.0.node().into_js_either_node() } - #[napi(getter, ts_return_type = "kinds.NodeLabel", catch_unwind)] - pub fn label(&self) -> Option { + #[napi(getter, ts_return_type = "kinds.EdgeLabel", catch_unwind)] + pub fn label(&self) -> Option { self.0.label() } @@ -77,9 +77,9 @@ impl Cursor { self.0.depth() as u32 } - #[napi(ts_return_type = "Array", catch_unwind)] - pub fn ancestors(&self) -> Vec { - self.0.ancestors().map(cst::RuleNode).collect() + #[napi(ts_return_type = "Array", catch_unwind)] + pub fn ancestors(&self) -> Vec { + self.0.ancestors().map(cst::NonTerminalNode).collect() } #[napi(catch_unwind)] @@ -128,44 +128,44 @@ impl Cursor { } #[napi(catch_unwind)] - pub fn go_to_next_token(&mut self) -> bool { - self.0.go_to_next_token() + pub fn go_to_next_terminal(&mut self) -> bool { + self.0.go_to_next_terminal() } #[napi(catch_unwind)] - pub fn go_to_next_token_with_kind( + pub fn go_to_next_terminal_with_kind( &mut self, - #[napi(ts_arg_type = "kinds.TokenKind")] kind: TokenKind, + #[napi(ts_arg_type = "kinds.TerminalKind")] kind: TerminalKind, ) -> bool { - self.0.go_to_next_token_with_kind(kind) + self.0.go_to_next_terminal_with_kind(kind) } #[napi(catch_unwind)] pub fn go_to_next_token_with_kinds( &mut self, - #[napi(ts_arg_type = "Array")] kinds: Vec, + #[napi(ts_arg_type = "Array")] kinds: Vec, ) -> bool { - self.0.go_to_next_token_with_kinds(&kinds) + self.0.go_to_next_terminal_with_kinds(&kinds) } #[napi(catch_unwind)] - pub fn go_to_next_rule(&mut self) -> bool { - self.0.go_to_next_rule() + pub fn go_to_next_nonterminal(&mut self) -> bool { + self.0.go_to_next_nonterminal() } #[napi(catch_unwind)] - pub fn go_to_next_rule_with_kind( + pub fn go_to_next_nonterminal_with_kind( &mut self, - #[napi(ts_arg_type = "kinds.RuleKind")] kind: RuleKind, + #[napi(ts_arg_type = "kinds.NonTerminalKind")] kind: NonTerminalKind, ) -> bool { - self.0.go_to_next_rule_with_kind(kind) + self.0.go_to_next_nonterminal_with_kind(kind) } #[napi(catch_unwind)] - pub fn go_to_next_rule_with_kinds( + pub fn go_to_next_nonterminal_with_kinds( &mut self, - #[napi(ts_arg_type = "Array")] kinds: Vec, + #[napi(ts_arg_type = "Array")] kinds: Vec, ) -> bool { - self.0.go_to_next_rule_with_kinds(&kinds) + self.0.go_to_next_nonterminal_with_kinds(&kinds) } } diff --git a/crates/codegen/runtime/cargo/src/runtime/napi_interface/generated/ast_selectors.rs b/crates/codegen/runtime/cargo/src/runtime/napi_interface/generated/ast_selectors.rs index c21a8c4e55..d02f055609 100644 --- a/crates/codegen/runtime/cargo/src/runtime/napi_interface/generated/ast_selectors.rs +++ b/crates/codegen/runtime/cargo/src/runtime/napi_interface/generated/ast_selectors.rs @@ -7,8 +7,10 @@ use std::rc::Rc; use napi::Either; use napi_derive::napi; -use crate::napi_interface::cst::{NAPINodeExtensions, RuleNode, TokenNode}; -use crate::napi_interface::{RuleKind, RustLabeledNode, RustNode, RustRuleNode, TokenKind}; +use crate::napi_interface::cst::{NAPINodeExtensions, NonTerminalNode, TerminalNode}; +use crate::napi_interface::{ + NonTerminalKind, RustLabeledNode, RustNode, RustRuleNode, TerminalKind, +}; // // Sequences: @@ -20,8 +22,8 @@ use crate::napi_interface::{RuleKind, RustLabeledNode, RustNode, RustRuleNode, T catch_unwind )] pub fn select_sequence( - #[napi(ts_arg_type = "cst.RuleNode")] node: &RuleNode, -) -> Result>>> { + #[napi(ts_arg_type = "cst.NonTerminalNode")] node: &NonTerminalNode, +) -> Result>>> { unreachable!("Invoking AST selectors in stubs: {node:#?}") } // // Choices: @@ -29,8 +31,8 @@ pub fn select_sequence( #[napi(namespace = "ast_internal", ts_return_type = "cst.Node", catch_unwind)] pub fn select_choice( - #[napi(ts_arg_type = "cst.RuleNode")] node: &RuleNode, -) -> Result> { + #[napi(ts_arg_type = "cst.NonTerminalNode")] node: &NonTerminalNode, +) -> Result> { unreachable!("Invoking AST selectors in stubs: {node:#?}") } @@ -44,8 +46,8 @@ pub fn select_choice( catch_unwind )] pub fn select_repeated( - #[napi(ts_arg_type = "cst.RuleNode")] node: &RuleNode, -) -> Result>> { + #[napi(ts_arg_type = "cst.NonTerminalNode")] node: &NonTerminalNode, +) -> Result>> { unreachable!("Invoking AST selectors in stubs: {node:#?}") } @@ -59,8 +61,8 @@ pub fn select_repeated( catch_unwind )] pub fn select_separated( - #[napi(ts_arg_type = "cst.RuleNode")] node: &RuleNode, -) -> Result>>> { + #[napi(ts_arg_type = "cst.NonTerminalNode")] node: &NonTerminalNode, +) -> Result>>> { unreachable!("Invoking AST selectors in stubs: {node:#?}") } @@ -74,7 +76,7 @@ struct Selector { } impl Selector { - fn new(node: &RuleNode) -> Self { + fn new(node: &NonTerminalNode) -> Self { Self { node: Rc::clone(&node.0), index: 0, @@ -84,7 +86,7 @@ impl Selector { fn select( &mut self, filter: impl FnOnce(&RustNode) -> bool, - ) -> Result> { + ) -> Result> { match self.try_select(filter)? { Some(node) => Ok(node), None => Error::MissingChild(self.index).into(), @@ -94,7 +96,7 @@ impl Selector { fn try_select( &mut self, filter: impl FnOnce(&RustNode) -> bool, - ) -> Result>> { + ) -> Result>> { while let Some(child) = self.node.children.get(self.index) { match child { node if node.is_trivia() => { @@ -103,9 +105,9 @@ impl Selector { continue; } RustLabeledNode { - label: _, - node: RustNode::Token(token), - } if matches!(token.kind, TokenKind::SKIPPED) => { + node: RustNode::Terminal(terminal), + .. + } if matches!(terminal.kind, TerminalKind::SKIPPED) => { return Error::SkippedToken(self.index).into(); } labeled if filter(labeled) => { @@ -135,8 +137,8 @@ type Result = std::result::Result; #[derive(Debug, thiserror::Error)] enum Error { // Should not theoretically happen, since we're only called from our own generated AST types. - #[error("Unexpected parent node with RuleKind '{0}'.")] - UnexpectedParent(RuleKind), + #[error("Unexpected parent node with NonTerminalKind '{0}'.")] + UnexpectedParent(NonTerminalKind), // Should not theoretically happen, since we're only called from our own generated AST types. #[error("Unexpected trailing children at index '{0}'.")] diff --git a/crates/codegen/runtime/cargo/src/runtime/napi_interface/mod.rs b/crates/codegen/runtime/cargo/src/runtime/napi_interface/mod.rs index 2c6d569d03..37be74b80b 100644 --- a/crates/codegen/runtime/cargo/src/runtime/napi_interface/mod.rs +++ b/crates/codegen/runtime/cargo/src/runtime/napi_interface/mod.rs @@ -9,18 +9,18 @@ pub mod text_index; pub mod ast_selectors; type RustCursor = crate::cursor::Cursor; -type RustLabeledNode = crate::cst::LabeledNode; +type RustLabeledNode = crate::cst::Edge; type RustNode = crate::cst::Node; type RustParseError = crate::parse_error::ParseError; type RustParseOutput = crate::parse_output::ParseOutput; type RustQuery = crate::query::Query; type RustQueryResult = crate::query::QueryResult; type RustQueryResultIterator = crate::query::QueryResultIterator; -type RustRuleNode = crate::cst::RuleNode; +type RustRuleNode = crate::cst::NonTerminalNode; type RustTextIndex = crate::text_index::TextIndex; type RustTextRange = crate::text_index::TextRange; -type RustTokenNode = crate::cst::TokenNode; +type RustTokenNode = crate::cst::TerminalNode; -type RuleKind = crate::kinds::RuleKind; -type TokenKind = crate::kinds::TokenKind; -type NodeLabel = crate::kinds::NodeLabel; +type NonTerminalKind = crate::kinds::NonTerminalKind; +type TerminalKind = crate::kinds::TerminalKind; +type EdgeLabel = crate::kinds::EdgeLabel; diff --git a/crates/codegen/runtime/cargo/src/runtime/napi_interface/parse_output.rs b/crates/codegen/runtime/cargo/src/runtime/napi_interface/parse_output.rs index d12fbf8a7c..8a518e1074 100644 --- a/crates/codegen/runtime/cargo/src/runtime/napi_interface/parse_output.rs +++ b/crates/codegen/runtime/cargo/src/runtime/napi_interface/parse_output.rs @@ -1,7 +1,7 @@ use napi::Either; use napi_derive::napi; -use crate::napi_interface::cst::{NAPINodeExtensions, RuleNode, TokenNode}; +use crate::napi_interface::cst::{NAPINodeExtensions, NonTerminalNode, TerminalNode}; use crate::napi_interface::{cursor, parse_error, RustParseOutput}; #[napi(namespace = "parse_output")] @@ -16,7 +16,7 @@ impl From for ParseOutput { #[napi(namespace = "parse_output")] impl ParseOutput { #[napi(ts_return_type = "cst.Node", catch_unwind)] - pub fn tree(&self) -> Either { + pub fn tree(&self) -> Either { self.0.tree().into_js_either_node() } diff --git a/crates/codegen/runtime/cargo/src/runtime/parse_error.rs b/crates/codegen/runtime/cargo/src/runtime/parse_error.rs index 950656c97f..ee88a23f1c 100644 --- a/crates/codegen/runtime/cargo/src/runtime/parse_error.rs +++ b/crates/codegen/runtime/cargo/src/runtime/parse_error.rs @@ -1,12 +1,12 @@ use std::collections::BTreeSet; -use crate::kinds::TokenKind; +use crate::kinds::TerminalKind; use crate::text_index::{TextRange, TextRangeExtensions}; #[derive(Debug, PartialEq, Eq, Clone)] pub struct ParseError { pub(crate) text_range: TextRange, - pub(crate) tokens_that_would_have_allowed_more_progress: Vec, + pub(crate) tokens_that_would_have_allowed_more_progress: Vec, } impl ParseError { @@ -22,7 +22,7 @@ impl ParseError { tokens_that_would_have_allowed_more_progress .into_iter() - .map(TokenKind::to_string) + .map(TerminalKind::to_string) .collect() } @@ -34,7 +34,7 @@ impl ParseError { impl ParseError { pub(crate) fn new( text_range: TextRange, - tokens_that_would_have_allowed_more_progress: Vec, + tokens_that_would_have_allowed_more_progress: Vec, ) -> Self { Self { text_range, diff --git a/crates/codegen/runtime/cargo/src/runtime/parser_support/choice_helper.rs b/crates/codegen/runtime/cargo/src/runtime/parser_support/choice_helper.rs index 2aaca22274..e0949ab1e7 100644 --- a/crates/codegen/runtime/cargo/src/runtime/parser_support/choice_helper.rs +++ b/crates/codegen/runtime/cargo/src/runtime/parser_support/choice_helper.rs @@ -2,7 +2,7 @@ use std::mem; use std::ops::ControlFlow; use crate::cst; -use crate::kinds::TokenKind; +use crate::kinds::TerminalKind; use crate::parse_error::ParseError; use crate::parser_support::context::{Marker, ParserContext}; use crate::parser_support::ParserResult; @@ -137,7 +137,9 @@ pub fn total_not_skipped_span(result: &ParserResult) -> usize { .iter() .flat_map(|child| child.cursor_with_offset(TextIndex::ZERO)) .filter_map(|node| match node { - cst::Node::Token(token) if token.kind != TokenKind::SKIPPED => Some(token.text.len()), + cst::Node::Terminal(terminal) if terminal.kind != TerminalKind::SKIPPED => { + Some(terminal.text.len()) + } _ => None, }) .sum() diff --git a/crates/codegen/runtime/cargo/src/runtime/parser_support/context.rs b/crates/codegen/runtime/cargo/src/runtime/parser_support/context.rs index bfcb0556d3..21b4a22fd9 100644 --- a/crates/codegen/runtime/cargo/src/runtime/parser_support/context.rs +++ b/crates/codegen/runtime/cargo/src/runtime/parser_support/context.rs @@ -1,7 +1,7 @@ use std::mem; use std::ops::Range; -use crate::kinds::TokenKind; +use crate::kinds::TerminalKind; use crate::parse_error::ParseError; use crate::text_index::TextIndex; @@ -11,7 +11,7 @@ pub struct ParserContext<'s> { position: TextIndex, undo_position: Option, errors: Vec, - closing_delimiters: Vec, + closing_delimiters: Vec, } #[derive(Copy, Clone)] @@ -61,7 +61,10 @@ impl<'s> ParserContext<'s> { } /// Creates a RAII guard that will pop the closing delimiter when dropped. - pub(crate) fn open_delim<'a>(&'a mut self, closing_delim: TokenKind) -> DelimiterGuard<'a, 's> { + pub(crate) fn open_delim<'a>( + &'a mut self, + closing_delim: TerminalKind, + ) -> DelimiterGuard<'a, 's> { self.closing_delimiters.push(closing_delim); DelimiterGuard { @@ -70,7 +73,7 @@ impl<'s> ParserContext<'s> { } } - pub fn closing_delimiters(&self) -> &[TokenKind] { + pub fn closing_delimiters(&self) -> &[TerminalKind] { &self.closing_delimiters } @@ -112,7 +115,7 @@ impl<'s> ParserContext<'s> { pub(crate) struct DelimiterGuard<'a, 's> { pub(crate) input: &'a mut ParserContext<'s>, - closing_delim: TokenKind, + closing_delim: TerminalKind, } impl Drop for DelimiterGuard<'_, '_> { diff --git a/crates/codegen/runtime/cargo/src/runtime/parser_support/parser_function.rs b/crates/codegen/runtime/cargo/src/runtime/parser_support/parser_function.rs index cba495fb1c..743e6c85fb 100644 --- a/crates/codegen/runtime/cargo/src/runtime/parser_support/parser_function.rs +++ b/crates/codegen/runtime/cargo/src/runtime/parser_support/parser_function.rs @@ -1,7 +1,7 @@ use std::rc::Rc; -use crate::cst::{self, LabeledNode}; -use crate::kinds::TokenKind; +use crate::cst::{self, Edge}; +use crate::kinds::TerminalKind; use crate::lexer::Lexer; use crate::parse_error::ParseError; use crate::parse_output::ParseOutput; @@ -40,11 +40,13 @@ where _ => None, }; - if let (cst::Node::Rule(rule), Some(eof_trivia)) = (&mut topmost.node, eof_trivia) { - let mut new_children = rule.children.clone(); + if let (cst::Node::NonTerminal(nonterminal), Some(eof_trivia)) = + (&mut topmost.node, eof_trivia) + { + let mut new_children = nonterminal.children.clone(); new_children.extend(eof_trivia); - topmost.node = cst::Node::rule(rule.kind, new_children); + topmost.node = cst::Node::nonterminal(nonterminal.kind, new_children); } } @@ -55,7 +57,7 @@ where ParserResult::PrattOperatorMatch(..) => unreachable!("PrattOperatorMatch is internal"), ParserResult::NoMatch(no_match) => ParseOutput { - parse_tree: cst::Node::token(TokenKind::SKIPPED, input.to_string()), + parse_tree: cst::Node::terminal(TerminalKind::SKIPPED, input.to_string()), errors: vec![ParseError::new( TextIndex::ZERO..input.into(), no_match.expected_tokens, @@ -80,8 +82,8 @@ where }) => (nodes, vec![expected]), }; - let topmost_rule = match &nodes[..] { - [LabeledNode { node: cst::Node::Rule(rule), ..} ] => Rc::clone(rule), + let topmost_node = match &nodes[..] { + [Edge { node: cst::Node::NonTerminal(nonterminal), ..} ] => Rc::clone(nonterminal), [_] => unreachable!( "(Incomplete)Match at the top level of a parser is not a Rule node" ), @@ -97,24 +99,24 @@ where // so needs a separate check here. if start.utf8 < input.len() || is_incomplete || is_recovering { let start = if is_recovering { - topmost_rule.text_len + topmost_node.text_len } else { start }; let skipped_node = - cst::Node::token(TokenKind::SKIPPED, input[start.utf8..].to_string()); - let mut new_children = topmost_rule.children.clone(); - new_children.push(LabeledNode::anonymous(skipped_node)); + cst::Node::terminal(TerminalKind::SKIPPED, input[start.utf8..].to_string()); + let mut new_children = topmost_node.children.clone(); + new_children.push(Edge::anonymous(skipped_node)); let mut errors = stream.into_errors(); errors.push(ParseError::new(start..input.into(), expected_tokens)); ParseOutput { - parse_tree: cst::Node::rule(topmost_rule.kind, new_children), + parse_tree: cst::Node::nonterminal(topmost_node.kind, new_children), errors, } } else { - let parse_tree = cst::Node::Rule(topmost_rule); + let parse_tree = cst::Node::NonTerminal(topmost_node); let errors = stream.into_errors(); // Sanity check: Make sure that succesful parse is equivalent to not having any SKIPPED nodes @@ -122,7 +124,9 @@ where errors.is_empty(), parse_tree .cursor_with_offset(TextIndex::ZERO) - .all(|node| node.as_token_with_kind(TokenKind::SKIPPED).is_none()) + .all(|node| node + .as_terminal_with_kind(TerminalKind::SKIPPED) + .is_none()) ); ParseOutput { parse_tree, errors } diff --git a/crates/codegen/runtime/cargo/src/runtime/parser_support/parser_result.rs b/crates/codegen/runtime/cargo/src/runtime/parser_support/parser_result.rs index 8e951948fe..6e93306e39 100644 --- a/crates/codegen/runtime/cargo/src/runtime/parser_support/parser_result.rs +++ b/crates/codegen/runtime/cargo/src/runtime/parser_support/parser_result.rs @@ -1,9 +1,9 @@ use std::ops::ControlFlow; -use metaslang_cst::TerminalKind; +use metaslang_cst::TerminalKind as _; -use crate::cst::{self, LabeledNode, Node}; -use crate::kinds::{NodeLabel, RuleKind, TokenKind}; +use crate::cst::{self, Edge, Node}; +use crate::kinds::{EdgeLabel, NonTerminalKind, TerminalKind}; use crate::text_index::TextIndex; #[derive(PartialEq, Eq, Clone, Debug)] @@ -24,7 +24,7 @@ impl Default for ParserResult { } impl ParserResult { - pub fn r#match(nodes: Vec, expected_tokens: Vec) -> Self { + pub fn r#match(nodes: Vec, expected_tokens: Vec) -> Self { ParserResult::Match(Match::new(nodes, expected_tokens)) } @@ -32,7 +32,7 @@ impl ParserResult { ParserResult::PrattOperatorMatch(PrattOperatorMatch::new(elements)) } - pub fn incomplete_match(nodes: Vec, expected_tokens: Vec) -> Self { + pub fn incomplete_match(nodes: Vec, expected_tokens: Vec) -> Self { ParserResult::IncompleteMatch(IncompleteMatch::new(nodes, expected_tokens)) } @@ -41,29 +41,29 @@ impl ParserResult { Self::no_match(vec![]) } - pub fn no_match(expected_tokens: Vec) -> Self { + pub fn no_match(expected_tokens: Vec) -> Self { ParserResult::NoMatch(NoMatch::new(expected_tokens)) } #[must_use] - pub fn with_kind(self, new_kind: RuleKind) -> ParserResult { + pub fn with_kind(self, new_kind: NonTerminalKind) -> ParserResult { match self { ParserResult::Match(r#match) => ParserResult::r#match( - vec![LabeledNode::anonymous(cst::Node::rule( + vec![Edge::anonymous(cst::Node::nonterminal( new_kind, r#match.nodes, ))], r#match.expected_tokens, ), ParserResult::IncompleteMatch(incomplete_match) => ParserResult::incomplete_match( - vec![LabeledNode::anonymous(cst::Node::rule( + vec![Edge::anonymous(cst::Node::nonterminal( new_kind, incomplete_match.nodes, ))], incomplete_match.expected_tokens, ), ParserResult::SkippedUntil(skipped) => ParserResult::SkippedUntil(SkippedUntil { - nodes: vec![LabeledNode::anonymous(cst::Node::rule( + nodes: vec![Edge::anonymous(cst::Node::nonterminal( new_kind, skipped.nodes, ))], @@ -71,14 +71,14 @@ impl ParserResult { }), ParserResult::NoMatch(_) => self, ParserResult::PrattOperatorMatch(_) => { - unreachable!("PrattOperatorMatch cannot be converted to a rule") + unreachable!("PrattOperatorMatch cannot be converted to a nonterminal") } } } #[must_use] - pub fn with_label(mut self, label: NodeLabel) -> ParserResult { - if let Some(LabeledNode { + pub fn with_label(mut self, label: EdgeLabel) -> ParserResult { + if let Some(Edge { label: prev_label, .. }) = self.significant_node_mut() { @@ -87,7 +87,7 @@ impl ParserResult { // Also allow to name a single trivia token node else if let ParserResult::Match(Match { nodes, .. }) = &mut self { if let [node] = nodes.as_mut_slice() { - if node.as_token().is_some_and(|tok| tok.kind.is_trivia()) { + if node.as_terminal().is_some_and(|tok| tok.kind.is_trivia()) { node.label = Some(label); } } @@ -97,7 +97,7 @@ impl ParserResult { } /// Returns a significant (non-trivia) node if there is exactly one. - pub(crate) fn significant_node_mut(&mut self) -> Option<&mut cst::LabeledNode> { + pub(crate) fn significant_node_mut(&mut self) -> Option<&mut cst::Edge> { let nodes = match self { ParserResult::Match(r#match) => &mut r#match.nodes[..], ParserResult::IncompleteMatch(incomplete_match) => &mut incomplete_match.nodes[..], @@ -121,13 +121,13 @@ impl ParserResult { #[derive(PartialEq, Eq, Clone, Debug)] pub struct Match { - pub nodes: Vec, + pub nodes: Vec, /// Tokens that would have allowed for more progress. Collected for the purposes of error reporting. - pub expected_tokens: Vec, + pub expected_tokens: Vec, } impl Match { - pub fn new(nodes: Vec, expected_tokens: Vec) -> Self { + pub fn new(nodes: Vec, expected_tokens: Vec) -> Self { Self { nodes, expected_tokens, @@ -138,41 +138,41 @@ impl Match { self.nodes .iter() .flat_map(|node| node.cursor_with_offset(TextIndex::ZERO)) - .all(|node| node.as_token_with_kind(TokenKind::SKIPPED).is_none()) + .all(|node| node.as_terminal_with_kind(TerminalKind::SKIPPED).is_none()) } } #[derive(PartialEq, Eq, Clone, Debug)] pub enum PrattElement { Expression { - nodes: Vec, + nodes: Vec, }, Prefix { - kind: RuleKind, - nodes: Vec, + kind: NonTerminalKind, + nodes: Vec, right: u8, }, Binary { - kind: RuleKind, - nodes: Vec, + kind: NonTerminalKind, + nodes: Vec, left: u8, right: u8, }, Postfix { - kind: RuleKind, - nodes: Vec, + kind: NonTerminalKind, + nodes: Vec, left: u8, }, } impl PrattElement { - pub fn into_nodes(self) -> Vec { + pub fn into_nodes(self) -> Vec { match self { Self::Expression { nodes } => nodes, Self::Binary { kind, nodes, .. } | Self::Prefix { kind, nodes, .. } | Self::Postfix { kind, nodes, .. } => { - vec![LabeledNode::anonymous(cst::Node::rule(kind, nodes))] + vec![Edge::anonymous(cst::Node::nonterminal(kind, nodes))] } } } @@ -191,13 +191,13 @@ impl PrattOperatorMatch { #[derive(PartialEq, Eq, Clone, Debug)] pub struct IncompleteMatch { - pub nodes: Vec, + pub nodes: Vec, /// Tokens that would have allowed for more progress. Collected for the purposes of error reporting. - pub expected_tokens: Vec, + pub expected_tokens: Vec, } impl IncompleteMatch { - pub fn new(nodes: Vec, expected_tokens: Vec) -> Self { + pub fn new(nodes: Vec, expected_tokens: Vec) -> Self { Self { nodes, expected_tokens, @@ -212,7 +212,9 @@ impl IncompleteMatch { .flat_map(|node| node.cursor_with_offset(TextIndex::ZERO)) .try_fold(0u8, |mut acc, node| { match node { - Node::Token(tok) if tok.kind != TokenKind::SKIPPED && !tok.kind.is_trivia() => { + Node::Terminal(tok) + if tok.kind != TerminalKind::SKIPPED && !tok.kind.is_trivia() => + { acc += 1; } _ => {} @@ -235,22 +237,22 @@ impl IncompleteMatch { #[derive(PartialEq, Eq, Clone, Debug)] pub struct NoMatch { /// Tokens that would have allowed for more progress. Collected for the purposes of error reporting. - pub expected_tokens: Vec, + pub expected_tokens: Vec, } impl NoMatch { - pub fn new(expected_tokens: Vec) -> Self { + pub fn new(expected_tokens: Vec) -> Self { Self { expected_tokens } } } #[derive(PartialEq, Eq, Clone, Debug)] pub struct SkippedUntil { - pub nodes: Vec, + pub nodes: Vec, /// Skipped text following the last node pub skipped: String, /// At which token was the stream pointing at when we bailed - pub found: TokenKind, + pub found: TerminalKind, /// Token we expected to skip until - pub expected: TokenKind, + pub expected: TerminalKind, } diff --git a/crates/codegen/runtime/cargo/src/runtime/parser_support/precedence_helper.rs b/crates/codegen/runtime/cargo/src/runtime/parser_support/precedence_helper.rs index 181f843dee..fa3bde8f59 100644 --- a/crates/codegen/runtime/cargo/src/runtime/parser_support/precedence_helper.rs +++ b/crates/codegen/runtime/cargo/src/runtime/parser_support/precedence_helper.rs @@ -1,5 +1,5 @@ -use crate::cst::{self, LabeledNode}; -use crate::kinds::{NodeLabel, RuleKind}; +use crate::cst::{self, Edge}; +use crate::kinds::{EdgeLabel, NonTerminalKind}; use crate::parser_support::parser_result::PrattElement::{ self, Binary, Expression, Postfix, Prefix, }; @@ -8,7 +8,11 @@ use crate::parser_support::parser_result::{ParserResult, PrattOperatorMatch}; pub struct PrecedenceHelper; impl PrecedenceHelper { - pub fn to_prefix_operator(kind: RuleKind, right: u8, result: ParserResult) -> ParserResult { + pub fn to_prefix_operator( + kind: NonTerminalKind, + right: u8, + result: ParserResult, + ) -> ParserResult { match result { ParserResult::Match(r#match) => ParserResult::pratt_operator_match(vec![Prefix { nodes: r#match.nodes, @@ -22,7 +26,11 @@ impl PrecedenceHelper { } } - pub fn to_postfix_operator(kind: RuleKind, left: u8, result: ParserResult) -> ParserResult { + pub fn to_postfix_operator( + kind: NonTerminalKind, + left: u8, + result: ParserResult, + ) -> ParserResult { match result { ParserResult::Match(r#match) => ParserResult::pratt_operator_match(vec![Postfix { nodes: r#match.nodes, @@ -37,7 +45,7 @@ impl PrecedenceHelper { } pub fn to_binary_operator( - kind: RuleKind, + kind: NonTerminalKind, left: u8, right: u8, result: ParserResult, @@ -57,7 +65,10 @@ impl PrecedenceHelper { } #[allow(clippy::too_many_lines, clippy::redundant_else)] // Explicit on purpose, see below. - pub fn reduce_precedence_result(child_kind: RuleKind, result: ParserResult) -> ParserResult { + pub fn reduce_precedence_result( + child_kind: NonTerminalKind, + result: ParserResult, + ) -> ParserResult { // This requires some careful thinking. It could be more compact, // but I'm favouring obviousness here. That is also why there are // so many `unreachable!` - not only should they never be reached, @@ -149,23 +160,23 @@ impl PrecedenceHelper { // 2. Reduce the operator and it's child expressions to a new expression let make_expression = |left: Option, - kind: RuleKind, - nodes: Vec, + kind: NonTerminalKind, + nodes: Vec, right: Option| { assert!(left.is_some() || right.is_some()); let left_label = right .as_ref() - .map_or(NodeLabel::Operand, |_| NodeLabel::LeftOperand); + .map_or(EdgeLabel::Operand, |_| EdgeLabel::LeftOperand); let right_label = left .as_ref() - .map_or(NodeLabel::Operand, |_| NodeLabel::RightOperand); + .map_or(EdgeLabel::Operand, |_| EdgeLabel::RightOperand); let left_nodes = match left { Some(Expression { nodes }) => { - vec![LabeledNode { + vec![Edge { label: Some(left_label), - node: cst::Node::rule(child_kind, nodes), + node: cst::Node::nonterminal(child_kind, nodes), }] } None => vec![], @@ -174,9 +185,9 @@ impl PrecedenceHelper { let right_nodes = match right { Some(Expression { nodes }) => { - vec![LabeledNode { + vec![Edge { label: Some(right_label), - node: cst::Node::rule(child_kind, nodes), + node: cst::Node::nonterminal(child_kind, nodes), }] } None => vec![], @@ -186,9 +197,9 @@ impl PrecedenceHelper { let children = [left_nodes, nodes, right_nodes].concat(); Expression { - nodes: vec![LabeledNode { - label: Some(NodeLabel::Variant), - node: cst::Node::rule(kind, children), + nodes: vec![Edge { + label: Some(EdgeLabel::Variant), + node: cst::Node::nonterminal(kind, children), }], } }; diff --git a/crates/codegen/runtime/cargo/src/runtime/parser_support/recovery.rs b/crates/codegen/runtime/cargo/src/runtime/parser_support/recovery.rs index a4222e15ad..b7a5781ac5 100644 --- a/crates/codegen/runtime/cargo/src/runtime/parser_support/recovery.rs +++ b/crates/codegen/runtime/cargo/src/runtime/parser_support/recovery.rs @@ -1,5 +1,5 @@ use crate::cst; -use crate::kinds::{IsLexicalContext, TokenKind}; +use crate::kinds::{IsLexicalContext, TerminalKind}; use crate::lexer::{Lexer, ScannedToken}; use crate::parse_error::ParseError; use crate::parser_support::context::ParserContext; @@ -16,7 +16,7 @@ pub(crate) struct TokenAcceptanceThreshold(pub(crate) u8); fn opt_parse( input: &mut ParserContext<'_>, parse: impl Fn(&mut ParserContext<'_>) -> ParserResult, -) -> Vec { +) -> Vec { let start = input.position(); if let ParserResult::Match(r#match) = parse(input) { r#match.nodes @@ -38,7 +38,7 @@ impl ParserResult { self, input: &mut ParserContext<'_>, lexer: &L, - expected: TokenKind, + expected: TerminalKind, acceptance_threshold: TokenAcceptanceThreshold, ) -> ParserResult { enum ParseResultKind { @@ -120,8 +120,8 @@ impl ParserResult { pub(crate) fn skip_until_with_nested_delims( input: &mut ParserContext<'_>, lexer: &L, - until: TokenKind, -) -> Option<(TokenKind, TextRange)> { + until: TerminalKind, +) -> Option<(TerminalKind, TextRange)> { let delims = L::delimiters::(); let start = input.position(); diff --git a/crates/codegen/runtime/cargo/src/runtime/parser_support/separated_helper.rs b/crates/codegen/runtime/cargo/src/runtime/parser_support/separated_helper.rs index 3982112a4e..a2c8fe01bb 100644 --- a/crates/codegen/runtime/cargo/src/runtime/parser_support/separated_helper.rs +++ b/crates/codegen/runtime/cargo/src/runtime/parser_support/separated_helper.rs @@ -1,5 +1,5 @@ -use crate::cst::{self, LabeledNode}; -use crate::kinds::{IsLexicalContext, NodeLabel, TokenKind}; +use crate::cst::{self, Edge}; +use crate::kinds::{EdgeLabel, IsLexicalContext, TerminalKind}; use crate::lexer::Lexer; use crate::parse_error::ParseError; use crate::parser_support::parser_result::{ParserResult, SkippedUntil}; @@ -14,8 +14,8 @@ impl SeparatedHelper { input: &mut ParserContext<'_>, lexer: &L, body_parser: impl Fn(&mut ParserContext<'_>) -> ParserResult, - separator: TokenKind, - separator_label: NodeLabel, + separator: TerminalKind, + separator_label: EdgeLabel, ) -> ParserResult { let mut accum = vec![]; loop { @@ -53,8 +53,8 @@ impl SeparatedHelper { match skip_until_with_nested_delims::<_, LexCtx>(input, lexer, separator) { // A separator was found, so we can recover the incomplete match Some((found, skipped_range)) if found == separator => { - accum.push(LabeledNode::anonymous(cst::Node::token( - TokenKind::SKIPPED, + accum.push(Edge::anonymous(cst::Node::terminal( + TerminalKind::SKIPPED, input.content(skipped_range.utf8()), ))); input.emit(ParseError { diff --git a/crates/codegen/runtime/cargo/src/runtime/parser_support/sequence_helper.rs b/crates/codegen/runtime/cargo/src/runtime/parser_support/sequence_helper.rs index 724e8cd01a..6e99617799 100644 --- a/crates/codegen/runtime/cargo/src/runtime/parser_support/sequence_helper.rs +++ b/crates/codegen/runtime/cargo/src/runtime/parser_support/sequence_helper.rs @@ -1,9 +1,9 @@ use std::ops::ControlFlow; -use metaslang_cst::TerminalKind; +use metaslang_cst::TerminalKind as _; -use crate::cst::{self, LabeledNode}; -use crate::kinds::{NodeLabel, TokenKind}; +use crate::cst::{self, Edge}; +use crate::kinds::{EdgeLabel, TerminalKind}; use crate::parser_support::parser_result::{Match, ParserResult, PrattElement, SkippedUntil}; /// Keeps accumulating parses sequentially until it hits an incomplete or no match. @@ -129,8 +129,8 @@ impl SequenceHelper { // Sanity check that we are recovering to the expected one. let next_token = next.nodes.iter().try_fold(None, |acc, node| { match &**node { - cst::Node::Token(token) if token.kind.is_trivia() => Ok(acc), - cst::Node::Token(token) => { + cst::Node::Terminal(token) if token.kind.is_trivia() => Ok(acc), + cst::Node::Terminal(token) => { match acc { None => Ok(Some(token.kind)), Some(..) => { @@ -139,16 +139,16 @@ impl SequenceHelper { } } } - cst::Node::Rule(rule) => { - debug_assert!(false, "Recovery skipped to a rule: {rule:?}"); + cst::Node::NonTerminal(node) => { + debug_assert!(false, "Recovery skipped to a nonterminal: {node:?}"); Err(()) } } }); debug_assert_eq!(next_token, Ok(Some(running.found))); - running.nodes.push(LabeledNode::anonymous(cst::Node::token( - TokenKind::SKIPPED, + running.nodes.push(Edge::anonymous(cst::Node::terminal( + TerminalKind::SKIPPED, std::mem::take(&mut running.skipped), ))); running.nodes.extend(next.nodes); @@ -197,7 +197,7 @@ impl SequenceHelper { /// Shorthand for `self.elem(value.with_label(label))`. pub fn elem_labeled( &mut self, - label: NodeLabel, + label: EdgeLabel, value: ParserResult, ) -> ControlFlow { self.elem(value.with_label(label)) diff --git a/crates/codegen/runtime/generator/src/keyword_scanner_definition.rs b/crates/codegen/runtime/generator/src/keyword_scanner_definition.rs index 2a7af0e1a7..a53669887e 100644 --- a/crates/codegen/runtime/generator/src/keyword_scanner_definition.rs +++ b/crates/codegen/runtime/generator/src/keyword_scanner_definition.rs @@ -14,7 +14,7 @@ pub trait KeywordScannerDefinitionExtensions { impl KeywordScannerDefinitionExtensions for KeywordScannerDefinitionRef { fn to_scanner_code(&self) -> TokenStream { let name_ident = format_ident!("{}", self.name()); - let token_kind = quote! { TokenKind::#name_ident }; + let token_kind = quote! { TerminalKind::#name_ident }; let kw_scanners: Vec<_> = self .definitions() diff --git a/crates/codegen/runtime/generator/src/model.rs b/crates/codegen/runtime/generator/src/model.rs index cef9f2a15d..51b0032415 100644 --- a/crates/codegen/runtime/generator/src/model.rs +++ b/crates/codegen/runtime/generator/src/model.rs @@ -26,8 +26,8 @@ pub struct RuntimeModel { all_versions: BTreeSet, referenced_versions: BTreeSet, - rule_kinds: BTreeSet<&'static str>, - token_kinds: BTreeSet<&'static str>, + nonterminal_kinds: BTreeSet<&'static str>, + terminal_kinds: BTreeSet<&'static str>, trivia_scanner_names: BTreeSet<&'static str>, labels: BTreeSet, @@ -219,13 +219,13 @@ impl GrammarVisitor for RuntimeModel { // Have to set this regardless so that we can collect referenced scanners self.set_current_context(parser.context()); if !parser.is_inline() { - self.rule_kinds.insert(parser.name()); + self.nonterminal_kinds.insert(parser.name()); let code = parser.to_parser_code(); self.parser_functions.insert( parser.name(), { - let rule_kind = format_ident!("{}", parser.name()); - quote! { #code.with_kind(RuleKind::#rule_kind) } + let nonterminal_kind = format_ident!("{}", parser.name()); + quote! { #code.with_kind(NonTerminalKind::#nonterminal_kind) } } .to_string(), ); @@ -234,12 +234,12 @@ impl GrammarVisitor for RuntimeModel { fn precedence_parser_definition_enter(&mut self, parser: &PrecedenceParserDefinitionRef) { self.set_current_context(parser.context()); - self.rule_kinds.insert(parser.name()); + self.nonterminal_kinds.insert(parser.name()); for (_, name, _) in &parser.node().operators { - self.rule_kinds.insert(name); + self.nonterminal_kinds.insert(name); } - // While it's not common to parse a precedence expression as a standalone rule, + // While it's not common to parse a precedence expression as a standalone nonterminal node, // we generate a function for completeness. for (name, code) in parser.to_precedence_expression_parser_code() { self.parser_functions.insert(name, code.to_string()); @@ -249,8 +249,8 @@ impl GrammarVisitor for RuntimeModel { parser.name(), { let code = parser.to_parser_code(); - let rule_kind = format_ident!("{}", parser.name()); - quote! { #code.with_kind(RuleKind::#rule_kind) } + let nonterminal_kind = format_ident!("{}", parser.name()); + quote! { #code.with_kind(NonTerminalKind::#nonterminal_kind) } } .to_string(), ); @@ -273,14 +273,14 @@ impl GrammarVisitor for RuntimeModel { } ParserDefinitionNode::ScannerDefinition(scanner) => { self.top_level_scanner_names.insert(scanner.name()); - self.token_kinds.insert(scanner.name()); + self.terminal_kinds.insert(scanner.name()); self.current_context() .scanner_definitions .insert(scanner.name()); } ParserDefinitionNode::KeywordScannerDefinition(scanner) => { - self.token_kinds.insert(scanner.name()); + self.terminal_kinds.insert(scanner.name()); self.current_context() .keyword_scanner_defs diff --git a/crates/codegen/runtime/generator/src/parser_definition.rs b/crates/codegen/runtime/generator/src/parser_definition.rs index 486c583bc5..7e9011271f 100644 --- a/crates/codegen/runtime/generator/src/parser_definition.rs +++ b/crates/codegen/runtime/generator/src/parser_definition.rs @@ -56,7 +56,7 @@ impl ParserDefinitionNodeExtensions for ParserDefinitionNode { let name = format_ident!("{}", label.to_pascal_case()); quote! { - #parser.with_label(NodeLabel::#name) + #parser.with_label(EdgeLabel::#name) } }; @@ -74,7 +74,7 @@ impl ParserDefinitionNodeExtensions for ParserDefinitionNode { let name = format_ident!("{}", label.to_pascal_case()); quote! { - #parser.with_label(NodeLabel::#name) + #parser.with_label(EdgeLabel::#name) } }; @@ -93,7 +93,7 @@ impl ParserDefinitionNodeExtensions for ParserDefinitionNode { let name = format_ident!("{}", label.to_pascal_case()); quote! { - #parser.with_label(NodeLabel::#name) + #parser.with_label(EdgeLabel::#name) } } } @@ -120,7 +120,7 @@ impl ParserDefinitionNodeExtensions for ParserDefinitionNode { let name = format_ident!("{}", label.to_pascal_case()); quote! { - #parser.with_label(NodeLabel::#name) + #parser.with_label(EdgeLabel::#name) } } } @@ -135,7 +135,7 @@ impl ParserDefinitionNodeExtensions for ParserDefinitionNode { }; quote! { - self.#parse_token::<#lex_ctx>(input, TokenKind::#kind) + self.#parse_token::<#lex_ctx>(input, TerminalKind::#kind) } } @@ -150,7 +150,7 @@ impl ParserDefinitionNodeExtensions for ParserDefinitionNode { }; quote! { - self.#parse_token::<#lex_ctx>(input, TokenKind::#kind) + self.#parse_token::<#lex_ctx>(input, TerminalKind::#kind) } } @@ -209,7 +209,7 @@ impl ParserDefinitionNodeExtensions for ParserDefinitionNode { seq.elem(#parser .recover_until_with_nested_delims::<_, #lex_ctx>(input, self, - TokenKind::#close_delim, + TerminalKind::#close_delim, TokenAcceptanceThreshold(#threshold), ) )?; @@ -219,17 +219,17 @@ impl ParserDefinitionNodeExtensions for ParserDefinitionNode { quote! { SequenceHelper::run(|mut seq| { - let mut delim_guard = input.open_delim(TokenKind::#close_delim); + let mut delim_guard = input.open_delim(TerminalKind::#close_delim); let input = delim_guard.ctx(); seq.elem_labeled( - NodeLabel::#open_label, - self.parse_token_with_trivia::<#lex_ctx>(input, TokenKind::#open_delim) + EdgeLabel::#open_label, + self.parse_token_with_trivia::<#lex_ctx>(input, TerminalKind::#open_delim) )?; #body_parser seq.elem_labeled( - NodeLabel::#close_label, - self.parse_token_with_trivia::<#lex_ctx>(input, TokenKind::#close_delim) + EdgeLabel::#close_label, + self.parse_token_with_trivia::<#lex_ctx>(input, TerminalKind::#close_delim) )?; seq.finish() }) @@ -252,9 +252,9 @@ impl ParserDefinitionNodeExtensions for ParserDefinitionNode { SeparatedHelper::run::<_, #lex_ctx>( input, self, - |input| #parser.with_label(NodeLabel::#body_label), - TokenKind::#separator, - NodeLabel::#separator_label, + |input| #parser.with_label(EdgeLabel::#body_label), + TerminalKind::#separator, + EdgeLabel::#separator_label, ) } } @@ -275,7 +275,7 @@ impl ParserDefinitionNodeExtensions for ParserDefinitionNode { #parser .recover_until_with_nested_delims::<_, #lex_ctx>(input, self, - TokenKind::#terminator, + TerminalKind::#terminator, // Requires at least a partial match not to risk misparsing TokenAcceptanceThreshold(1u8), ) @@ -288,8 +288,8 @@ impl ParserDefinitionNodeExtensions for ParserDefinitionNode { SequenceHelper::run(|mut seq| { #body_parser seq.elem_labeled( - NodeLabel::#terminator_label, - self.parse_token_with_trivia::<#lex_ctx>(input, TokenKind::#terminator) + EdgeLabel::#terminator_label, + self.parse_token_with_trivia::<#lex_ctx>(input, TerminalKind::#terminator) )?; seq.finish() }) @@ -381,7 +381,7 @@ pub fn make_sequence_versioned( } else { let label = format_ident!("{}", name.to_pascal_case()); - quote! { seq.elem_labeled(NodeLabel::#label, #parser)?; } + quote! { seq.elem_labeled(EdgeLabel::#label, #parser)?; } }; versions.wrap_code(code, None) diff --git a/crates/codegen/runtime/generator/src/precedence_parser_definition.rs b/crates/codegen/runtime/generator/src/precedence_parser_definition.rs index 91d0c01673..5d5b09c97f 100644 --- a/crates/codegen/runtime/generator/src/precedence_parser_definition.rs +++ b/crates/codegen/runtime/generator/src/precedence_parser_definition.rs @@ -26,10 +26,10 @@ impl PrecedenceParserDefinitionExtensions for PrecedenceParserDefinitionRef { fn to_precedence_expression_parser_code(&self) -> Vec<(&'static str, TokenStream)> { let mut res = vec![]; let parser_name = format_ident!("{}", self.name().to_snake_case()); - let rule_name = format_ident!("{}", self.name().to_pascal_case()); + let nonterminal_name = format_ident!("{}", self.name().to_pascal_case()); for name in &self.node().precedence_expression_names { - let op_rule_name = format_ident!("{}", name.to_pascal_case()); + let op_nonterminal_name = format_ident!("{}", name.to_pascal_case()); // Ensure that the parser correctly identifies a single node of the expected type, // which contains a single child node representing the expected precedence operator. @@ -40,8 +40,8 @@ impl PrecedenceParserDefinitionExtensions for PrecedenceParserDefinitionRef { // If the result won't match exactly, we return a dummy `ParserResult::no_match`, since // can't precisely determine the expected tokens or completeness of the match otherwise. match &r#match.nodes[..] { - [cst::LabeledNode { label: _, node: cst::Node::Rule(node) }] if node.kind == RuleKind::#rule_name => match &node.children[..] { - [inner @ cst::LabeledNode { label: _, node: cst::Node::Rule(rule) }] if rule.kind == RuleKind::#op_rule_name => { + [cst::Edge { node: cst::Node::NonTerminal(node), .. }] if node.kind == NonTerminalKind::#nonterminal_name => match &node.children[..] { + [inner @ cst::Edge { node: cst::Node::NonTerminal(node), .. }] if node.kind == NonTerminalKind::#op_nonterminal_name => { ParserResult::r#match(vec![inner.clone()], r#match.expected_tokens.clone()) } _ => ParserResult::no_match(vec![]), @@ -89,7 +89,7 @@ impl PrecedenceParserDefinitionNodeExtensions for PrecedenceParserDefinitionNode // // The second pass is to use the binding strengths to resolve the linear structure into a // tree, and maybe wrap each child of each Operator as a node with the kind of the overall - // precedence parser root e.g. `RuleKind::Expression`. + // precedence parser root e.g. `NonTerminalKind::Expression`. // // Given the result of step one, this second pass cannot fail to correctly resolve to a // single node. So all the panics disappear and Pratt parsing becomes “… so simple that @@ -113,7 +113,7 @@ impl PrecedenceParserDefinitionNodeExtensions for PrecedenceParserDefinitionNode let mut binding_power = 1u8; for (model, name, operator_definition) in &self.operators { let operator_code = operator_definition.to_parser_code(context_name, false); - let rule_kind = format_ident!("{}", name); + let nonterminal_kind = format_ident!("{}", name); let model_name = match model { PrecedenceOperatorModel::BinaryLeftAssociative => "left", PrecedenceOperatorModel::BinaryRightAssociative => "right", @@ -130,7 +130,7 @@ impl PrecedenceParserDefinitionNodeExtensions for PrecedenceParserDefinitionNode operator_closures.push(quote! { let #closure_name = |input: &mut ParserContext<'_>| PrecedenceHelper::to_binary_operator( - RuleKind::#rule_kind, + NonTerminalKind::#nonterminal_kind, #binding_power, #binding_power + 1, #operator_code @@ -142,7 +142,7 @@ impl PrecedenceParserDefinitionNodeExtensions for PrecedenceParserDefinitionNode operator_closures.push(quote! { let #closure_name = |input: &mut ParserContext<'_>| PrecedenceHelper::to_binary_operator( - RuleKind::#rule_kind, + NonTerminalKind::#nonterminal_kind, #binding_power + 1, #binding_power, #operator_code @@ -154,7 +154,7 @@ impl PrecedenceParserDefinitionNodeExtensions for PrecedenceParserDefinitionNode operator_closures.push(quote! { let #closure_name = |input: &mut ParserContext<'_>| PrecedenceHelper::to_prefix_operator( - RuleKind::#rule_kind, + NonTerminalKind::#nonterminal_kind, #binding_power, #operator_code ); @@ -165,7 +165,7 @@ impl PrecedenceParserDefinitionNodeExtensions for PrecedenceParserDefinitionNode operator_closures.push(quote! { let #closure_name = |input: &mut ParserContext<'_>| PrecedenceHelper::to_postfix_operator( - RuleKind::#rule_kind, + NonTerminalKind::#nonterminal_kind, #binding_power, #operator_code ); @@ -228,7 +228,7 @@ impl PrecedenceParserDefinitionNodeExtensions for PrecedenceParserDefinitionNode #operator_closures )* - PrecedenceHelper::reduce_precedence_result(RuleKind::#expression_kind, linear_expression_parser(input)) + PrecedenceHelper::reduce_precedence_result(NonTerminalKind::#expression_kind, linear_expression_parser(input)) } } } diff --git a/crates/codegen/runtime/generator/src/trie.rs b/crates/codegen/runtime/generator/src/trie.rs index 391b569d6c..d2232f1e59 100644 --- a/crates/codegen/runtime/generator/src/trie.rs +++ b/crates/codegen/runtime/generator/src/trie.rs @@ -127,7 +127,7 @@ impl Payload for ScannerDefinitionRef { let kind = format_ident!("{}", self.name()); self.node().applicable_version_quality_ranges().wrap_code( - quote! { Some(TokenKind::#kind) }, + quote! { Some(TerminalKind::#kind) }, Some(Self::default_case()), ) } @@ -150,41 +150,41 @@ impl Payload for KeywordScannerAtomic { // Simplify the emitted code if we trivially know that reserved or enabled is true match (&*reserved_cond.to_string(), &*enabled_cond.to_string()) { - ("true", _) => quote!(KeywordScan::Reserved(TokenKind::#kind)), - ("false", "true") => quote!(KeywordScan::Present(TokenKind::#kind)), + ("true", _) => quote!(KeywordScan::Reserved(TerminalKind::#kind)), + ("false", "true") => quote!(KeywordScan::Present(TerminalKind::#kind)), ("false", _) => quote! { if #enabled_cond { - KeywordScan::Present(TokenKind::#kind) + KeywordScan::Present(TerminalKind::#kind) } else { KeywordScan::Absent } }, (_, "false") => quote! { if #reserved_cond { - KeywordScan::Reserved(TokenKind::#kind) + KeywordScan::Reserved(TerminalKind::#kind) } else { KeywordScan::Absent } }, (_, "true") => quote! { if #reserved_cond { - KeywordScan::Reserved(TokenKind::#kind) + KeywordScan::Reserved(TerminalKind::#kind) } else { - KeywordScan::Present(TokenKind::#kind) + KeywordScan::Present(TerminalKind::#kind) } }, (reserved, enabled) if reserved == enabled => quote! { if #reserved_cond { - KeywordScan::Reserved(TokenKind::#kind) + KeywordScan::Reserved(TerminalKind::#kind) } else { KeywordScan::Absent } }, _ => quote! { if #reserved_cond { - KeywordScan::Reserved(TokenKind::#kind) + KeywordScan::Reserved(TerminalKind::#kind) } else if #enabled_cond { - KeywordScan::Present(TokenKind::#kind) + KeywordScan::Present(TerminalKind::#kind) } else { KeywordScan::Absent } diff --git a/crates/codegen/runtime/npm/src/runtime/ast/ast_types.ts.jinja2 b/crates/codegen/runtime/npm/src/runtime/ast/ast_types.ts.jinja2 index 413426f8cb..9013cf80f8 100644 --- a/crates/codegen/runtime/npm/src/runtime/ast/ast_types.ts.jinja2 +++ b/crates/codegen/runtime/npm/src/runtime/ast/ast_types.ts.jinja2 @@ -3,8 +3,8 @@ {%- else -%} import * as assert from "node:assert"; import { ast_internal } from "../../napi-bindings/generated"; - import { RuleNode, TokenNode } from "../../cst"; - import { RuleKind, TokenKind } from "../../kinds"; + import { NonTerminalNode, TerminalNode } from "../../cst"; + import { NonTerminalKind, TerminalKind } from "../../kinds"; /* * Sequences: @@ -26,22 +26,22 @@ ${{ field.name | camel_case }} === null ? undefined : {%- endif -%} {%- if field.is_terminal -%} - ${{ field.name | camel_case }} as TokenNode, + ${{ field.name | camel_case }} as TerminalNode, {%- else -%} - new {{ field.reference }}(${{ field.name | camel_case }} as RuleNode), + new {{ field.reference }}(${{ field.name | camel_case }} as NonTerminalNode), {%- endif -%} {% endfor -%} }; }); - public constructor(public readonly cst: RuleNode) { - assertKind(this.cst.kind, RuleKind.{{ sequence.name }}); + public constructor(public readonly cst: NonTerminalNode) { + assertKind(this.cst.kind, NonTerminalKind.{{ sequence.name }}); } {% for field in sequence.fields %} public get {{ field.name | camel_case }}() : {%- if field.is_terminal -%} - TokenNode + TerminalNode {%- else -%} {{ field.reference }} {%- endif -%} @@ -63,7 +63,7 @@ export class {{ choice.name }} { {%- set variant_types = choice.non_terminals -%} {%- if choice.terminals | length > 0 -%} - {%- set variant_types = variant_types | concat(with = "TokenNode") -%} + {%- set variant_types = variant_types | concat(with = "TerminalNode") -%} {%- endif -%} {%- set variant_types = variant_types | join(sep = " | ") -%} @@ -72,15 +72,15 @@ switch (variant.kind) { {%- for non_terminal in choice.non_terminals %} - case RuleKind.{{ non_terminal }}: - return new {{ non_terminal }}(variant as RuleNode); + case NonTerminalKind.{{ non_terminal }}: + return new {{ non_terminal }}(variant as NonTerminalNode); {%- endfor %} {% if choice.terminals | length > 0 %} {%- for terminal in choice.terminals %} - case TokenKind.{{ terminal }}: + case TerminalKind.{{ terminal }}: {%- endfor %} - return variant as TokenNode; + return variant as TerminalNode; {%- endif %} default: @@ -88,8 +88,8 @@ } }); - public constructor(public readonly cst: RuleNode) { - assertKind(this.cst.kind, RuleKind.{{ choice.name }}); + public constructor(public readonly cst: NonTerminalNode) { + assertKind(this.cst.kind, NonTerminalKind.{{ choice.name }}); } public get variant(): {{ variant_types }} { @@ -108,19 +108,19 @@ const items = ast_internal.selectRepeated(this.cst); {%- if repeated.is_terminal -%} - return items as TokenNode[]; + return items as TerminalNode[]; {%- else -%} - return items.map((item) => new {{ repeated.reference }}(item as RuleNode)); + return items.map((item) => new {{ repeated.reference }}(item as NonTerminalNode)); {%- endif -%} }); - public constructor(public readonly cst: RuleNode) { - assertKind(this.cst.kind, RuleKind.{{ repeated.name }}); + public constructor(public readonly cst: NonTerminalNode) { + assertKind(this.cst.kind, NonTerminalKind.{{ repeated.name }}); } public get items(): {%- if repeated.is_terminal -%} - readonly TokenNode[] + readonly TerminalNode[] {%- else -%} readonly {{ repeated.reference }}[] {%- endif -%} @@ -141,21 +141,21 @@ return { {%- if separated.is_terminal -%} - items: items as TokenNode[], + items: items as TerminalNode[], {%- else -%} - items: items.map((item) => new {{ separated.reference }}(item as RuleNode)), + items: items.map((item) => new {{ separated.reference }}(item as NonTerminalNode)), {%- endif -%} - separators: separators as TokenNode[], + separators: separators as TerminalNode[], }; }); - public constructor(public readonly cst: RuleNode) { - assertKind(this.cst.kind, RuleKind.{{ separated.name }}); + public constructor(public readonly cst: NonTerminalNode) { + assertKind(this.cst.kind, NonTerminalKind.{{ separated.name }}); } public get items(): {%- if separated.is_terminal -%} - readonly TokenNode[] + readonly TerminalNode[] {%- else -%} readonly {{ separated.reference }}[] {%- endif -%} @@ -163,7 +163,7 @@ return this.fetch().items; } - public get separators(): readonly TokenNode[] { + public get separators(): readonly TerminalNode[] { return this.fetch().separators; } } @@ -183,7 +183,7 @@ }; } - function assertKind(actual: RuleKind, expected: RuleKind): void { + function assertKind(actual: NonTerminalKind, expected: NonTerminalKind): void { assert.equal(actual, expected, `${expected} can only be initialized with a CST node of the same kind.`); } {%- endif %} diff --git a/crates/codegen/runtime/npm/src/runtime/cst/index.ts b/crates/codegen/runtime/npm/src/runtime/cst/index.ts index a156422a81..bd7bbd94e7 100644 --- a/crates/codegen/runtime/npm/src/runtime/cst/index.ts +++ b/crates/codegen/runtime/npm/src/runtime/cst/index.ts @@ -5,8 +5,8 @@ export type Node = generated.cst.Node; export const NodeType = generated.cst.NodeType; export type NodeType = generated.cst.NodeType; -export const RuleNode = generated.cst.RuleNode; -export type RuleNode = generated.cst.RuleNode; +export const NonTerminalNode = generated.cst.NonTerminalNode; +export type NonTerminalNode = generated.cst.NonTerminalNode; -export const TokenNode = generated.cst.TokenNode; -export type TokenNode = generated.cst.TokenNode; +export const TerminalNode = generated.cst.TerminalNode; +export type TerminalNode = generated.cst.TerminalNode; diff --git a/crates/codegen/runtime/npm/src/runtime/kinds/index.ts b/crates/codegen/runtime/npm/src/runtime/kinds/index.ts index e4929309eb..7dbab0e96d 100644 --- a/crates/codegen/runtime/npm/src/runtime/kinds/index.ts +++ b/crates/codegen/runtime/npm/src/runtime/kinds/index.ts @@ -1,10 +1,10 @@ import * as generated from "../napi-bindings/generated"; -export const RuleKind = generated.kinds.RuleKind; -export type RuleKind = generated.kinds.RuleKind; +export const NonTerminalKind = generated.kinds.NonTerminalKind; +export type NonTerminalKind = generated.kinds.NonTerminalKind; -export const TokenKind = generated.kinds.TokenKind; -export type TokenKind = generated.kinds.TokenKind; +export const TerminalKind = generated.kinds.TerminalKind; +export type TerminalKind = generated.kinds.TerminalKind; -export const NodeLabel = generated.kinds.NodeLabel; -export type NodeLabel = generated.kinds.NodeLabel; +export const EdgeLabel = generated.kinds.EdgeLabel; +export type EdgeLabel = generated.kinds.EdgeLabel; diff --git a/crates/codegen/runtime/npm/src/runtime/napi-bindings/generated/index.d.ts b/crates/codegen/runtime/npm/src/runtime/napi-bindings/generated/index.d.ts index 822c31129f..d04c4fbb40 100644 --- a/crates/codegen/runtime/npm/src/runtime/napi-bindings/generated/index.d.ts +++ b/crates/codegen/runtime/npm/src/runtime/napi-bindings/generated/index.d.ts @@ -9,12 +9,12 @@ /* auto-generated by NAPI-RS */ export namespace kinds { - export enum RuleKind { + export enum NonTerminalKind { Stub1 = "Stub1", Stub2 = "Stub2", Stub3 = "Stub3", } - export enum NodeLabel { + export enum EdgeLabel { Item = "Item", Variant = "Variant", Separator = "Separator", @@ -27,7 +27,7 @@ export namespace kinds { Stub2 = "Stub2", Stub3 = "Stub3", } - export enum TokenKind { + export enum TerminalKind { SKIPPED = "SKIPPED", Stub1 = "Stub1", Stub2 = "Stub2", @@ -39,17 +39,17 @@ export namespace language { constructor(version: string); get version(): string; static supportedVersions(): Array; - parse(kind: kinds.RuleKind, input: string): parse_output.ParseOutput; + parse(kind: kinds.NonTerminalKind, input: string): parse_output.ParseOutput; } } export namespace cst { export enum NodeType { - Rule = "Rule", - Token = "Token", + NonTerminal = "NonTerminal", + Terminal = "Terminal", } - export class RuleNode { - get type(): NodeType.Rule; - get kind(): kinds.RuleKind; + export class NonTerminalNode { + get type(): NodeType.NonTerminal; + get kind(): kinds.NonTerminalKind; get textLength(): text_index.TextIndex; children(): Array; createCursor(textOffset: text_index.TextIndex): cursor.Cursor; @@ -57,13 +57,13 @@ export namespace cst { toJSON(): string; unparse(): string; } - export class TokenNode { - get type(): NodeType.Token; - get kind(): kinds.TokenKind; + export class TerminalNode { + get type(): NodeType.Terminal; + get kind(): kinds.TerminalKind; get textLength(): text_index.TextIndex; get text(): string; /** - * Serialize the token node to JSON. + * Serialize the terminal node to JSON. * * This method is intended for debugging purposes and may not be stable. */ @@ -79,11 +79,11 @@ export namespace cursor { spawn(): Cursor; get isCompleted(): boolean; node(): cst.Node; - get label(): kinds.NodeLabel; + get label(): kinds.EdgeLabel; get textOffset(): text_index.TextIndex; get textRange(): text_index.TextRange; get depth(): number; - ancestors(): Array; + ancestors(): Array; goToNext(): boolean; goToNextNonDescendent(): boolean; goToPrevious(): boolean; @@ -93,12 +93,12 @@ export namespace cursor { goToNthChild(childNumber: number): boolean; goToNextSibling(): boolean; goToPreviousSibling(): boolean; - goToNextToken(): boolean; - goToNextTokenWithKind(kind: kinds.TokenKind): boolean; - goToNextTokenWithKinds(kinds: Array): boolean; - goToNextRule(): boolean; - goToNextRuleWithKind(kind: kinds.RuleKind): boolean; - goToNextRuleWithKinds(kinds: Array): boolean; + goToNextTerminal(): boolean; + goToNextTerminalWithKind(kind: kinds.TerminalKind): boolean; + goToNextTokenWithKinds(kinds: Array): boolean; + goToNextNonterminal(): boolean; + goToNextNonterminalWithKind(kind: kinds.NonTerminalKind): boolean; + goToNextNonterminalWithKinds(kinds: Array): boolean; query(queries: Array): query.QueryResultIterator; } } @@ -141,12 +141,12 @@ export namespace text_index { } } export namespace ast_internal { - export function selectSequence(node: cst.RuleNode): Array; - export function selectChoice(node: cst.RuleNode): cst.Node; - export function selectRepeated(node: cst.RuleNode): Array; - export function selectSeparated(node: cst.RuleNode): [Array, Array]; + export function selectSequence(node: cst.NonTerminalNode): Array; + export function selectChoice(node: cst.NonTerminalNode): cst.Node; + export function selectRepeated(node: cst.NonTerminalNode): Array; + export function selectSeparated(node: cst.NonTerminalNode): [Array, Array]; } export namespace cst { - export type Node = RuleNode | TokenNode; + export type Node = TerminalNode | NonTerminalNode; } diff --git a/crates/infra/cli/src/toolchains/napi/bindings/index.d.ts.jinja2 b/crates/infra/cli/src/toolchains/napi/bindings/index.d.ts.jinja2 index 570cb75214..bf736f11e1 100644 --- a/crates/infra/cli/src/toolchains/napi/bindings/index.d.ts.jinja2 +++ b/crates/infra/cli/src/toolchains/napi/bindings/index.d.ts.jinja2 @@ -8,5 +8,5 @@ {# Manual Additions: #} export namespace cst { - export type Node = RuleNode | TokenNode; + export type Node = TerminalNode | NonTerminalNode; } diff --git a/crates/metaslang/cst/src/cst.rs b/crates/metaslang/cst/src/cst.rs index b1d582c817..bf0238c38b 100644 --- a/crates/metaslang/cst/src/cst.rs +++ b/crates/metaslang/cst/src/cst.rs @@ -17,29 +17,29 @@ pub struct NonTerminalNode { pub kind: T::NonTerminalKind, pub text_len: TextIndex, #[serde(skip_serializing_if = "Vec::is_empty")] - pub children: Vec>, + pub children: Vec>, } #[derive(Clone, Debug, PartialEq, Eq, Serialize)] pub enum Node { - Rule(Rc>), - Token(Rc>), + NonTerminal(Rc>), + Terminal(Rc>), } #[derive(Clone, Debug, PartialEq, Eq, Serialize)] -pub struct LabeledNode { - pub label: Option, +pub struct Edge { + pub label: Option, pub node: Node, } -impl LabeledNode { - /// Creates an anonymous node (without a label). +impl Edge { + /// Creates a anonymous node (without a label). pub fn anonymous(node: Node) -> Self { Self { label: None, node } } } -impl std::ops::Deref for LabeledNode { +impl std::ops::Deref for Edge { type Target = Node; fn deref(&self) -> &Self::Target { @@ -48,32 +48,32 @@ impl std::ops::Deref for LabeledNode { } impl Node { - pub fn rule(kind: T::NonTerminalKind, children: Vec>) -> Self { + pub fn nonterminal(kind: T::NonTerminalKind, children: Vec>) -> Self { let text_len = children.iter().map(|node| node.text_len()).sum(); - Self::Rule(Rc::new(NonTerminalNode { + Self::NonTerminal(Rc::new(NonTerminalNode { kind, text_len, children, })) } - pub fn token(kind: T::TerminalKind, text: String) -> Self { - Self::Token(Rc::new(TerminalNode { kind, text })) + pub fn terminal(kind: T::TerminalKind, text: String) -> Self { + Self::Terminal(Rc::new(TerminalNode { kind, text })) } pub fn text_len(&self) -> TextIndex { match self { - Self::Rule(node) => node.text_len, - Self::Token(node) => (&node.text).into(), + Self::NonTerminal(node) => node.text_len, + Self::Terminal(node) => (&node.text).into(), } } /// Returns a slice of the children (not all descendants) of this node. - pub fn children(&self) -> &[LabeledNode] { + pub fn children(&self) -> &[Edge] { match self { - Self::Rule(node) => &node.children, - Self::Token(_) => &[], + Self::NonTerminal(node) => &node.children, + Self::Terminal(_) => &[], } } @@ -85,106 +85,114 @@ impl Node { /// Reconstructs the original source code from the parse tree. pub fn unparse(self) -> String { match self { - Self::Rule(rule) => rule.unparse(), - Self::Token(token) => token.text.clone(), + Self::NonTerminal(nonterminal) => nonterminal.unparse(), + Self::Terminal(terminal) => terminal.text.clone(), } } - pub fn into_rule(self) -> Option>> { + pub fn into_nonterminal(self) -> Option>> { match self { - Self::Rule(rule) => Some(rule), - Self::Token(..) => None, + Self::NonTerminal(nonterminal) => Some(nonterminal), + Self::Terminal(..) => None, } } - pub fn is_rule(&self) -> bool { - self.as_rule().is_some() + pub fn is_nonterminal(&self) -> bool { + self.as_nonterminal().is_some() } - pub fn as_rule(&self) -> Option<&Rc>> { + pub fn as_nonterminal(&self) -> Option<&Rc>> { match self { - Self::Rule(rule) => Some(rule), - Self::Token(..) => None, + Self::NonTerminal(nonterminal) => Some(nonterminal), + Self::Terminal(..) => None, } } - pub fn is_rule_with_kind(&self, kind: T::NonTerminalKind) -> bool { - self.as_rule_with_kind(kind).is_some() + pub fn is_nonterminal_with_kind(&self, kind: T::NonTerminalKind) -> bool { + self.as_nonterminal_with_kind(kind).is_some() } - pub fn as_rule_with_kind(&self, kind: T::NonTerminalKind) -> Option<&Rc>> { - self.as_rule().filter(|rule| rule.kind == kind) + pub fn as_nonterminal_with_kind( + &self, + kind: T::NonTerminalKind, + ) -> Option<&Rc>> { + self.as_nonterminal().filter(|node| node.kind == kind) } - pub fn is_rule_with_kinds(&self, kinds: &[T::NonTerminalKind]) -> bool { - self.as_rule_with_kinds(kinds).is_some() + pub fn is_nonterminal_with_kinds(&self, kinds: &[T::NonTerminalKind]) -> bool { + self.as_nonterminal_with_kinds(kinds).is_some() } - pub fn as_rule_with_kinds( + pub fn as_nonterminal_with_kinds( &self, kinds: &[T::NonTerminalKind], ) -> Option<&Rc>> { - self.as_rule().filter(|rule| kinds.contains(&rule.kind)) + self.as_nonterminal() + .filter(|nonterminal| kinds.contains(&nonterminal.kind)) } - pub fn into_token(self) -> Option>> { + pub fn into_terminal(self) -> Option>> { match self { - Self::Token(token) => Some(token), - Self::Rule(..) => None, + Self::Terminal(terminal) => Some(terminal), + Self::NonTerminal(..) => None, } } - pub fn is_token(&self) -> bool { - self.as_token().is_some() + pub fn is_terminal(&self) -> bool { + self.as_terminal().is_some() } - pub fn as_token(&self) -> Option<&Rc>> { + pub fn as_terminal(&self) -> Option<&Rc>> { match self { - Self::Token(token) => Some(token), - Self::Rule(..) => None, + Self::Terminal(terminal) => Some(terminal), + Self::NonTerminal(..) => None, } } - pub fn is_token_with_kind(&self, kind: T::TerminalKind) -> bool { - self.as_token_with_kind(kind).is_some() + pub fn is_terminal_with_kind(&self, kind: T::TerminalKind) -> bool { + self.as_terminal_with_kind(kind).is_some() } - pub fn as_token_with_kind(&self, kind: T::TerminalKind) -> Option<&Rc>> { - self.as_token().filter(|token| token.kind == kind) + pub fn as_terminal_with_kind(&self, kind: T::TerminalKind) -> Option<&Rc>> { + self.as_terminal().filter(|terminal| terminal.kind == kind) } - pub fn is_token_with_kinds(&self, kinds: &[T::TerminalKind]) -> bool { - self.as_token_with_kinds(kinds).is_some() + pub fn is_terminal_with_kinds(&self, kinds: &[T::TerminalKind]) -> bool { + self.as_terminal_with_kinds(kinds).is_some() } - pub fn as_token_with_kinds(&self, kinds: &[T::TerminalKind]) -> Option<&Rc>> { - self.as_token().filter(|token| kinds.contains(&token.kind)) + pub fn as_terminal_with_kinds( + &self, + kinds: &[T::TerminalKind], + ) -> Option<&Rc>> { + self.as_terminal() + .filter(|terminal| kinds.contains(&terminal.kind)) } pub fn is_trivia(&self) -> bool { match self { - Self::Rule(_) => false, - Self::Token(token) => token.kind.is_trivia(), + Self::NonTerminal(_) => false, + Self::Terminal(terminal) => terminal.kind.is_trivia(), } } } impl From>> for Node { - fn from(node: Rc>) -> Self { - Self::Rule(node) + fn from(nonterminal: Rc>) -> Self { + Self::NonTerminal(nonterminal) } } impl From>> for Node { - fn from(node: Rc>) -> Self { - Self::Token(node) + fn from(terminal: Rc>) -> Self { + Self::Terminal(terminal) } } impl NonTerminalNode { /// Creates a [`Cursor`] that starts at the current node as the root and a given initial `text_offset`. pub fn cursor_with_offset(self: Rc, text_offset: TextIndex) -> Cursor { - Cursor::new(Node::Rule(self), text_offset) + Cursor::new(Node::NonTerminal(self), text_offset) } /// Reconstructs the original source code from the parse tree. @@ -192,9 +200,9 @@ impl NonTerminalNode { let acc = String::with_capacity(self.text_len.utf8); self.cursor_with_offset(TextIndex::ZERO) - .filter_map(|node| node.into_token()) - .fold(acc, |mut acc, token| { - acc.push_str(&token.text); + .filter_map(|node| node.into_terminal()) + .fold(acc, |mut acc, terminal| { + acc.push_str(&terminal.text); acc }) } diff --git a/crates/metaslang/cst/src/cursor.rs b/crates/metaslang/cst/src/cursor.rs index 2aae0b30c0..f9b05d499a 100644 --- a/crates/metaslang/cst/src/cursor.rs +++ b/crates/metaslang/cst/src/cursor.rs @@ -2,7 +2,7 @@ use std::rc::Rc; -use crate::cst::{LabeledNode, Node, NonTerminalNode}; +use crate::cst::{Edge, Node, NonTerminalNode}; use crate::text_index::{TextIndex, TextRange}; use crate::KindTypes; @@ -10,7 +10,7 @@ use crate::KindTypes; #[derive(Clone, Debug, PartialEq, Eq)] struct PathAncestor { parent: Option>>, - rule_node: Rc>, + nonterminal_node: Rc>, child_number: usize, text_offset: TextIndex, } @@ -36,10 +36,10 @@ pub struct Cursor { impl Cursor { fn as_ancestor_node(&self) -> Option>> { - if let Node::::Rule(rule_node) = &self.node { + if let Node::::NonTerminal(nonterminal_node) = &self.node { Some(Rc::new(PathAncestor { parent: self.parent.clone(), - rule_node: rule_node.clone(), + nonterminal_node: nonterminal_node.clone(), child_number: self.child_number, text_offset: self.text_offset, })) @@ -50,7 +50,7 @@ impl Cursor { fn set_from_ancestor_node(&mut self, ancestor: &Rc>) { self.parent = ancestor.parent.clone(); - self.node = Node::::Rule(ancestor.rule_node.clone()); + self.node = Node::::NonTerminal(ancestor.nonterminal_node.clone()); self.child_number = ancestor.child_number; self.text_offset = ancestor.text_offset; } @@ -124,9 +124,9 @@ impl Cursor { self.node.clone() } - pub fn label(&self) -> Option { + pub fn label(&self) -> Option { self.parent.as_ref().and_then(|parent| { - let this = &parent.rule_node.children[self.child_number]; + let this = &parent.nonterminal_node.children[self.child_number]; this.label }) @@ -170,7 +170,7 @@ impl Cursor { fn next(&mut self) -> Option { if let Some(a) = self.a.take() { self.a = a.parent.clone(); - Some(a.rule_node.clone()) + Some(a.nonterminal_node.clone()) } else { None } @@ -253,7 +253,7 @@ impl Cursor { // If the current cursor is a node and it has children, go to first children if let Some(new_parent) = self.as_ancestor_node() { - if let Some(new_child) = new_parent.rule_node.children.first().cloned() { + if let Some(new_child) = new_parent.nonterminal_node.children.first().cloned() { self.parent = Some(new_parent); self.node = new_child.node; self.child_number = 0; @@ -274,10 +274,10 @@ impl Cursor { } if let Some(new_parent) = self.as_ancestor_node() { - if let Some(new_child) = new_parent.rule_node.children.last().cloned() { - self.child_number = new_parent.rule_node.children.len() - 1; + if let Some(new_child) = new_parent.nonterminal_node.children.last().cloned() { + self.child_number = new_parent.nonterminal_node.children.len() - 1; // This is cheaper than summing up the length of the children - self.text_offset += new_parent.rule_node.text_len - new_child.text_len(); + self.text_offset += new_parent.nonterminal_node.text_len - new_child.text_len(); self.node = new_child.node; self.parent = Some(new_parent); @@ -297,12 +297,17 @@ impl Cursor { } if let Some(new_parent) = self.as_ancestor_node() { - if let Some(new_child) = new_parent.rule_node.children.get(child_number).cloned() { + if let Some(new_child) = new_parent + .nonterminal_node + .children + .get(child_number) + .cloned() + { self.node = new_child.node; self.child_number = child_number; // Sum up the length of the children before this child // TODO(#871): it might sometimes be quicker to start from the end (like `go_to_last_child`) - self.text_offset += new_parent.rule_node.children[..child_number] + self.text_offset += new_parent.nonterminal_node.children[..child_number] .iter() .map(|node| node.text_len()) .sum(); @@ -325,7 +330,7 @@ impl Cursor { if let Some(parent) = &self.parent { let new_child_number = self.child_number + 1; - if let Some(new_child) = parent.rule_node.children.get(new_child_number) { + if let Some(new_child) = parent.nonterminal_node.children.get(new_child_number) { self.text_offset += self.node.text_len(); self.node = new_child.node.clone(); self.child_number = new_child_number; @@ -348,7 +353,7 @@ impl Cursor { if let Some(parent) = &self.parent { if self.child_number > 0 { let new_child_number = self.child_number - 1; - let new_child = &parent.rule_node.children[new_child_number]; + let new_child = &parent.nonterminal_node.children[new_child_number]; self.text_offset -= new_child.node.text_len(); self.node = new_child.node.clone(); self.child_number = new_child_number; @@ -360,46 +365,46 @@ impl Cursor { false } - /// Attempts to go to the next token, according to the DFS pre-order traversal. + /// Attempts to go to the next terminal node, according to the DFS pre-order traversal. /// /// Returns `false` if the cursor is finished and at the root. - pub fn go_to_next_token(&mut self) -> bool { - self.go_to_next_matching(|node| node.is_token()) + pub fn go_to_next_terminal(&mut self) -> bool { + self.go_to_next_matching(|node| node.is_terminal()) } - /// Attempts to go to the next token with the given kind, according to the DFS pre-order traversal. + /// Attempts to go to the next terminal node with the given kind, according to the DFS pre-order traversal. /// /// Returns `false` if the cursor is finished and at the root. - pub fn go_to_next_token_with_kind(&mut self, kind: T::TerminalKind) -> bool { - self.go_to_next_matching(|node| node.is_token_with_kind(kind)) + pub fn go_to_next_terminal_with_kind(&mut self, kind: T::TerminalKind) -> bool { + self.go_to_next_matching(|node| node.is_terminal_with_kind(kind)) } - /// Attempts to go to the next token with any of the given kinds, according to the DFS pre-order traversal. + /// Attempts to go to the next terminal node with any of the given kinds, according to the DFS pre-order traversal. /// /// Returns `false` if the cursor is finished and at the root. - pub fn go_to_next_token_with_kinds(&mut self, kinds: &[T::TerminalKind]) -> bool { - self.go_to_next_matching(|node| node.is_token_with_kinds(kinds)) + pub fn go_to_next_terminal_with_kinds(&mut self, kinds: &[T::TerminalKind]) -> bool { + self.go_to_next_matching(|node| node.is_terminal_with_kinds(kinds)) } - /// Attempts to go to the next rule, according to the DFS pre-order traversal. + /// Attempts to go to the next non-terminal node, according to the DFS pre-order traversal. /// /// Returns `false` if the cursor is finished and at the root. - pub fn go_to_next_rule(&mut self) -> bool { - self.go_to_next_matching(|node| node.is_rule()) + pub fn go_to_next_nonterminal(&mut self) -> bool { + self.go_to_next_matching(|node| node.is_nonterminal()) } - /// Attempts to go to the next rule with the given kind, according to the DFS pre-order traversal. + /// Attempts to go to the next non-terminal node with the given kind, according to the DFS pre-order traversal. /// /// Returns `false` if the cursor is finished and at the root. - pub fn go_to_next_rule_with_kind(&mut self, kind: T::NonTerminalKind) -> bool { - self.go_to_next_matching(|node| node.is_rule_with_kind(kind)) + pub fn go_to_next_nonterminal_with_kind(&mut self, kind: T::NonTerminalKind) -> bool { + self.go_to_next_matching(|node| node.is_nonterminal_with_kind(kind)) } - /// Attempts to go to the next rule with any of the given kinds, according to the DFS pre-order traversal. + /// Attempts to go to the next non-terminal node with any of the given kinds, according to the DFS pre-order traversal. /// /// Returns `false` if the cursor is finished and at the root. - pub fn go_to_next_rule_with_kinds(&mut self, kinds: &[T::NonTerminalKind]) -> bool { - self.go_to_next_matching(|node| node.is_rule_with_kinds(kinds)) + pub fn go_to_next_nonterminal_with_kinds(&mut self, kinds: &[T::NonTerminalKind]) -> bool { + self.go_to_next_matching(|node| node.is_nonterminal_with_kinds(kinds)) } fn go_to_next_matching(&mut self, pred: impl Fn(&Node) -> bool) -> bool { @@ -414,18 +419,18 @@ impl Cursor { } /// A [`Cursor`] that also keeps track of the labels of the nodes it visits. -pub struct CursorWithLabels { +pub struct CursorWithEdges { cursor: Cursor, } -impl CursorWithLabels { - pub fn without_labels(self) -> Cursor { +impl CursorWithEdges { + pub fn without_edges(self) -> Cursor { self.cursor } } -impl Iterator for CursorWithLabels { - type Item = LabeledNode; +impl Iterator for CursorWithEdges { + type Item = Edge; fn next(&mut self) -> Option { let label = self.cursor.label(); @@ -434,7 +439,7 @@ impl Iterator for CursorWithLabels { } } -impl std::ops::Deref for CursorWithLabels { +impl std::ops::Deref for CursorWithEdges { type Target = Cursor; fn deref(&self) -> &Self::Target { @@ -442,21 +447,21 @@ impl std::ops::Deref for CursorWithLabels { } } -impl std::ops::DerefMut for CursorWithLabels { +impl std::ops::DerefMut for CursorWithEdges { fn deref_mut(&mut self) -> &mut Self::Target { &mut self.cursor } } impl Cursor { - /// Returns a [`CursorWithLabels`] that wraps this cursor. - pub fn with_labels(self) -> CursorWithLabels { - CursorWithLabels::::from(self) + /// Returns a [`CursorWithEdges`] that wraps this cursor. + pub fn with_edges(self) -> CursorWithEdges { + CursorWithEdges::::from(self) } } -impl From> for CursorWithLabels { +impl From> for CursorWithEdges { fn from(cursor: Cursor) -> Self { - CursorWithLabels:: { cursor } + CursorWithEdges:: { cursor } } } diff --git a/crates/metaslang/cst/src/lib.rs b/crates/metaslang/cst/src/lib.rs index b38d987908..579f10df03 100644 --- a/crates/metaslang/cst/src/lib.rs +++ b/crates/metaslang/cst/src/lib.rs @@ -35,10 +35,10 @@ pub trait TerminalKind: Kind { pub trait NonTerminalKind: Kind {} -pub trait EdgeKind: Kind {} +pub trait EdgeLabel: Kind {} pub trait KindTypes: Clone + PartialEq { type NonTerminalKind: NonTerminalKind; type TerminalKind: TerminalKind; - type EdgeKind: EdgeKind; + type EdgeLabel: EdgeLabel; } diff --git a/crates/metaslang/cst/src/query/engine.rs b/crates/metaslang/cst/src/query/engine.rs index a19ea30aed..34ee6132f8 100644 --- a/crates/metaslang/cst/src/query/engine.rs +++ b/crates/metaslang/cst/src/query/engine.rs @@ -27,27 +27,27 @@ impl Cursor { fn matches_node_selector(&self, node_selector: &NodeSelector) -> bool { match self.node() { - Node::::Rule(rule) => match node_selector { + Node::::NonTerminal(nonterminal) => match node_selector { NodeSelector::Anonymous => true, - NodeSelector::Kind { kind } => Kind::Rule(rule.kind) == *kind, + NodeSelector::Kind { kind } => Kind::Terminal(nonterminal.kind) == *kind, NodeSelector::Text { .. } => false, NodeSelector::Label { label } => Some(*label) == self.label(), NodeSelector::LabelAndKind { label, kind } => { - Some(*label) == self.label() && Kind::Rule(rule.kind) == *kind + Some(*label) == self.label() && Kind::Terminal(nonterminal.kind) == *kind } NodeSelector::LabelAndText { .. } => false, }, - Node::::Token(token) => match node_selector { + Node::::Terminal(terminal) => match node_selector { NodeSelector::Anonymous => true, - NodeSelector::Kind { kind } => Kind::Token(token.kind) == *kind, - NodeSelector::Text { text } => token.text == *text, + NodeSelector::Kind { kind } => Kind::NonTerminal(terminal.kind) == *kind, + NodeSelector::Text { text } => terminal.text == *text, NodeSelector::Label { label } => Some(*label) == self.label(), NodeSelector::LabelAndKind { label, kind } => { - Some(*label) == self.label() && Kind::Token(token.kind) == *kind + Some(*label) == self.label() && Kind::NonTerminal(terminal.kind) == *kind } NodeSelector::LabelAndText { label, text } => { - Some(*label) == self.label() && token.text == *text + Some(*label) == self.label() && terminal.text == *text } }, } diff --git a/crates/metaslang/cst/src/query/model.rs b/crates/metaslang/cst/src/query/model.rs index 5b7a77c665..8d04bc8caa 100644 --- a/crates/metaslang/cst/src/query/model.rs +++ b/crates/metaslang/cst/src/query/model.rs @@ -87,15 +87,15 @@ impl fmt::Display for Matcher { #[derive(Copy, Clone, PartialEq, Eq)] pub(super) enum Kind { - Rule(T::NonTerminalKind), - Token(T::TerminalKind), + Terminal(T::NonTerminalKind), + NonTerminal(T::TerminalKind), } impl fmt::Display for Kind { fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result { match self { - Self::Rule(rule) => write!(f, "{rule}"), - Self::Token(token) => write!(f, "{token}"), + Self::Terminal(kind) => write!(f, "{kind}"), + Self::NonTerminal(kind) => write!(f, "{kind}"), } } } @@ -105,9 +105,9 @@ pub(super) enum NodeSelector { Anonymous, Kind { kind: Kind }, Text { text: String }, - Label { label: T::EdgeKind }, - LabelAndKind { label: T::EdgeKind, kind: Kind }, - LabelAndText { label: T::EdgeKind, text: String }, + Label { label: T::EdgeLabel }, + LabelAndKind { label: T::EdgeLabel, kind: Kind }, + LabelAndText { label: T::EdgeLabel, text: String }, } impl fmt::Display for NodeSelector { @@ -133,12 +133,12 @@ impl fmt::Display for NodeSelector { Self::Anonymous => write!(f, "_"), Self::Kind { kind } => kind.fmt(f), Self::Text { text } => write!(f, "\"{}\"", escape_string(text)), - Self::Label { label } => label.fmt(f), - Self::LabelAndKind { label, kind } => { - write!(f, "{label}; {kind}") + Self::Label { label: edge } => edge.fmt(f), + Self::LabelAndKind { label: edge, kind } => { + write!(f, "{edge}; {kind}") } - Self::LabelAndText { label, text } => { - write!(f, "{label}: \"{}\"", escape_string(text)) + Self::LabelAndText { label: edge, text } => { + write!(f, "{edge}: \"{}\"", escape_string(text)) } } } diff --git a/crates/metaslang/cst/src/query/parser.rs b/crates/metaslang/cst/src/query/parser.rs index 7ed8e4ff4c..2bfb065aad 100644 --- a/crates/metaslang/cst/src/query/parser.rs +++ b/crates/metaslang/cst/src/query/parser.rs @@ -177,16 +177,16 @@ fn kind_token(i: &str) -> IResult<&str, Kind, VerboseError<&str terminated(raw_identifier, multispace0) .map(|id| { T::TerminalKind::try_from(id.as_str()) - .map(Kind::Token) - .or_else(|_| T::NonTerminalKind::try_from(id.as_str()).map(Kind::Rule)) + .map(Kind::NonTerminal) + .or_else(|_| T::NonTerminalKind::try_from(id.as_str()).map(Kind::Terminal)) .unwrap() // TODO }) .parse(i) } -fn label_token(i: &str) -> IResult<&str, T::EdgeKind, VerboseError<&str>> { +fn label_token(i: &str) -> IResult<&str, T::EdgeLabel, VerboseError<&str>> { terminated(raw_identifier, token(':')) - .map(|id| T::EdgeKind::try_from(id.as_str()).unwrap()) + .map(|id| T::EdgeLabel::try_from(id.as_str()).unwrap()) .parse(i) } diff --git a/crates/solidity/outputs/cargo/slang_solidity/src/generated/generated/kinds.rs b/crates/solidity/outputs/cargo/slang_solidity/src/generated/generated/kinds.rs index 37968d6126..a8799ddc36 100644 --- a/crates/solidity/outputs/cargo/slang_solidity/src/generated/generated/kinds.rs +++ b/crates/solidity/outputs/cargo/slang_solidity/src/generated/generated/kinds.rs @@ -17,7 +17,7 @@ use napi_derive::napi; )] #[cfg_attr(feature = "slang_napi_interfaces", /* derives `Clone` and `Copy` */ napi(string_enum, namespace = "kinds"))] #[cfg_attr(not(feature = "slang_napi_interfaces"), derive(Clone, Copy))] -pub enum RuleKind { +pub enum NonTerminalKind { ABICoderPragma, AdditiveExpression, AddressType, @@ -234,7 +234,7 @@ pub enum RuleKind { YulVariableDeclarationValue, } -impl metaslang_cst::NonTerminalKind for RuleKind {} +impl metaslang_cst::NonTerminalKind for NonTerminalKind {} #[derive( Debug, @@ -251,7 +251,7 @@ impl metaslang_cst::NonTerminalKind for RuleKind {} #[strum(serialize_all = "snake_case")] #[cfg_attr(feature = "slang_napi_interfaces", /* derives `Clone` and `Copy` */ napi(string_enum, namespace = "kinds"))] #[cfg_attr(not(feature = "slang_napi_interfaces"), derive(Clone, Copy))] -pub enum NodeLabel { +pub enum EdgeLabel { // Built-in: Item, Variant, @@ -388,7 +388,7 @@ pub enum NodeLabel { WhileKeyword, } -impl metaslang_cst::EdgeKind for NodeLabel {} +impl metaslang_cst::EdgeLabel for EdgeLabel {} #[derive( Debug, @@ -404,7 +404,7 @@ impl metaslang_cst::EdgeKind for NodeLabel {} )] #[cfg_attr(feature = "slang_napi_interfaces", /* derives `Clone` and `Copy` */ napi(string_enum, namespace = "kinds"))] #[cfg_attr(not(feature = "slang_napi_interfaces"), derive(Clone, Copy))] -pub enum TokenKind { +pub enum TerminalKind { // Built-in: SKIPPED, @@ -778,7 +778,7 @@ pub enum TokenKind { YulYearsKeyword, } -impl metaslang_cst::TerminalKind for TokenKind { +impl metaslang_cst::TerminalKind for TerminalKind { fn is_trivia(&self) -> bool { matches!(self, |Self::EndOfLine| Self::MultiLineComment | Self::MultiLineNatSpecComment diff --git a/crates/solidity/outputs/cargo/slang_solidity/src/generated/generated/language.rs b/crates/solidity/outputs/cargo/slang_solidity/src/generated/generated/language.rs index c9d31f6011..ae2d196bf4 100644 --- a/crates/solidity/outputs/cargo/slang_solidity/src/generated/generated/language.rs +++ b/crates/solidity/outputs/cargo/slang_solidity/src/generated/generated/language.rs @@ -16,7 +16,7 @@ use semver::Version; use crate::cst; use crate::kinds::{ - IsLexicalContext, LexicalContext, LexicalContextType, NodeLabel, RuleKind, TokenKind, + EdgeLabel, IsLexicalContext, LexicalContext, LexicalContextType, NonTerminalKind, TerminalKind, }; use crate::lexer::{KeywordScan, Lexer, ScannedToken}; #[cfg(feature = "slang_napi_interfaces")] @@ -218,22 +218,22 @@ impl Language { fn abi_coder_pragma(&self, input: &mut ParserContext<'_>) -> ParserResult { SequenceHelper::run(|mut seq| { seq.elem_labeled( - NodeLabel::AbicoderKeyword, + EdgeLabel::AbicoderKeyword, self.parse_token_with_trivia::( input, - TokenKind::AbicoderKeyword, + TerminalKind::AbicoderKeyword, ), )?; seq.elem_labeled( - NodeLabel::Version, + EdgeLabel::Version, self.parse_token_with_trivia::( input, - TokenKind::Identifier, + TerminalKind::Identifier, ), )?; seq.finish() }) - .with_kind(RuleKind::ABICoderPragma) + .with_kind(NonTerminalKind::ABICoderPragma) } #[allow(unused_assignments, unused_parens)] @@ -243,14 +243,14 @@ impl Language { return result; }; match &r#match.nodes[..] { - [cst::LabeledNode { - label: _, - node: cst::Node::Rule(node), - }] if node.kind == RuleKind::Expression => match &node.children[..] { - [inner @ cst::LabeledNode { - label: _, - node: cst::Node::Rule(rule), - }] if rule.kind == RuleKind::AdditiveExpression => { + [cst::Edge { + node: cst::Node::NonTerminal(node), + .. + }] if node.kind == NonTerminalKind::Expression => match &node.children[..] { + [inner @ cst::Edge { + node: cst::Node::NonTerminal(node), + .. + }] if node.kind == NonTerminalKind::AdditiveExpression => { ParserResult::r#match(vec![inner.clone()], r#match.expected_tokens.clone()) } _ => ParserResult::no_match(vec![]), @@ -263,24 +263,24 @@ impl Language { fn address_type(&self, input: &mut ParserContext<'_>) -> ParserResult { SequenceHelper::run(|mut seq| { seq.elem_labeled( - NodeLabel::AddressKeyword, + EdgeLabel::AddressKeyword, self.parse_token_with_trivia::( input, - TokenKind::AddressKeyword, + TerminalKind::AddressKeyword, ), )?; seq.elem_labeled( - NodeLabel::PayableKeyword, + EdgeLabel::PayableKeyword, OptionalHelper::transform( self.parse_token_with_trivia::( input, - TokenKind::PayableKeyword, + TerminalKind::PayableKeyword, ), ), )?; seq.finish() }) - .with_kind(RuleKind::AddressType) + .with_kind(NonTerminalKind::AddressType) } #[allow(unused_assignments, unused_parens)] @@ -290,14 +290,14 @@ impl Language { return result; }; match &r#match.nodes[..] { - [cst::LabeledNode { - label: _, - node: cst::Node::Rule(node), - }] if node.kind == RuleKind::Expression => match &node.children[..] { - [inner @ cst::LabeledNode { - label: _, - node: cst::Node::Rule(rule), - }] if rule.kind == RuleKind::AndExpression => { + [cst::Edge { + node: cst::Node::NonTerminal(node), + .. + }] if node.kind == NonTerminalKind::Expression => match &node.children[..] { + [inner @ cst::Edge { + node: cst::Node::NonTerminal(node), + .. + }] if node.kind == NonTerminalKind::AndExpression => { ParserResult::r#match(vec![inner.clone()], r#match.expected_tokens.clone()) } _ => ParserResult::no_match(vec![]), @@ -315,42 +315,42 @@ impl Language { choice.consider(input, result)?; choice.finish(input) }) - .with_label(NodeLabel::Variant) - .with_kind(RuleKind::ArgumentsDeclaration) + .with_label(EdgeLabel::Variant) + .with_kind(NonTerminalKind::ArgumentsDeclaration) } #[allow(unused_assignments, unused_parens)] fn array_expression(&self, input: &mut ParserContext<'_>) -> ParserResult { SequenceHelper::run(|mut seq| { - let mut delim_guard = input.open_delim(TokenKind::CloseBracket); + let mut delim_guard = input.open_delim(TerminalKind::CloseBracket); let input = delim_guard.ctx(); seq.elem_labeled( - NodeLabel::OpenBracket, + EdgeLabel::OpenBracket, self.parse_token_with_trivia::( input, - TokenKind::OpenBracket, + TerminalKind::OpenBracket, ), )?; seq.elem( self.array_values(input) - .with_label(NodeLabel::Items) + .with_label(EdgeLabel::Items) .recover_until_with_nested_delims::<_, LexicalContextType::Default>( input, self, - TokenKind::CloseBracket, + TerminalKind::CloseBracket, TokenAcceptanceThreshold(0u8), ), )?; seq.elem_labeled( - NodeLabel::CloseBracket, + EdgeLabel::CloseBracket, self.parse_token_with_trivia::( input, - TokenKind::CloseBracket, + TerminalKind::CloseBracket, ), )?; seq.finish() }) - .with_kind(RuleKind::ArrayExpression) + .with_kind(NonTerminalKind::ArrayExpression) } #[allow(unused_assignments, unused_parens)] @@ -360,14 +360,14 @@ impl Language { return result; }; match &r#match.nodes[..] { - [cst::LabeledNode { - label: _, - node: cst::Node::Rule(node), - }] if node.kind == RuleKind::TypeName => match &node.children[..] { - [inner @ cst::LabeledNode { - label: _, - node: cst::Node::Rule(rule), - }] if rule.kind == RuleKind::ArrayTypeName => { + [cst::Edge { + node: cst::Node::NonTerminal(node), + .. + }] if node.kind == NonTerminalKind::TypeName => match &node.children[..] { + [inner @ cst::Edge { + node: cst::Node::NonTerminal(node), + .. + }] if node.kind == NonTerminalKind::ArrayTypeName => { ParserResult::r#match(vec![inner.clone()], r#match.expected_tokens.clone()) } _ => ParserResult::no_match(vec![]), @@ -381,11 +381,11 @@ impl Language { SeparatedHelper::run::<_, LexicalContextType::Default>( input, self, - |input| self.expression(input).with_label(NodeLabel::Item), - TokenKind::Comma, - NodeLabel::Separator, + |input| self.expression(input).with_label(EdgeLabel::Item), + TerminalKind::Comma, + EdgeLabel::Separator, ) - .with_kind(RuleKind::ArrayValues) + .with_kind(NonTerminalKind::ArrayValues) } #[allow(unused_assignments, unused_parens)] @@ -393,69 +393,69 @@ impl Language { SeparatedHelper::run::<_, LexicalContextType::Default>( input, self, - |input| self.string_literal(input).with_label(NodeLabel::Item), - TokenKind::Comma, - NodeLabel::Separator, + |input| self.string_literal(input).with_label(EdgeLabel::Item), + TerminalKind::Comma, + EdgeLabel::Separator, ) - .with_kind(RuleKind::AssemblyFlags) + .with_kind(NonTerminalKind::AssemblyFlags) } #[allow(unused_assignments, unused_parens)] fn assembly_flags_declaration(&self, input: &mut ParserContext<'_>) -> ParserResult { SequenceHelper::run(|mut seq| { - let mut delim_guard = input.open_delim(TokenKind::CloseParen); + let mut delim_guard = input.open_delim(TerminalKind::CloseParen); let input = delim_guard.ctx(); seq.elem_labeled( - NodeLabel::OpenParen, + EdgeLabel::OpenParen, self.parse_token_with_trivia::( input, - TokenKind::OpenParen, + TerminalKind::OpenParen, ), )?; seq.elem( self.assembly_flags(input) - .with_label(NodeLabel::Flags) + .with_label(EdgeLabel::Flags) .recover_until_with_nested_delims::<_, LexicalContextType::Default>( input, self, - TokenKind::CloseParen, + TerminalKind::CloseParen, TokenAcceptanceThreshold(0u8), ), )?; seq.elem_labeled( - NodeLabel::CloseParen, + EdgeLabel::CloseParen, self.parse_token_with_trivia::( input, - TokenKind::CloseParen, + TerminalKind::CloseParen, ), )?; seq.finish() }) - .with_kind(RuleKind::AssemblyFlagsDeclaration) + .with_kind(NonTerminalKind::AssemblyFlagsDeclaration) } #[allow(unused_assignments, unused_parens)] fn assembly_statement(&self, input: &mut ParserContext<'_>) -> ParserResult { SequenceHelper::run(|mut seq| { seq.elem_labeled( - NodeLabel::AssemblyKeyword, + EdgeLabel::AssemblyKeyword, self.parse_token_with_trivia::( input, - TokenKind::AssemblyKeyword, + TerminalKind::AssemblyKeyword, ), )?; seq.elem_labeled( - NodeLabel::Label, + EdgeLabel::Label, OptionalHelper::transform(self.string_literal(input)), )?; seq.elem_labeled( - NodeLabel::Flags, + EdgeLabel::Flags, OptionalHelper::transform(self.assembly_flags_declaration(input)), )?; - seq.elem_labeled(NodeLabel::Body, self.yul_block(input))?; + seq.elem_labeled(EdgeLabel::Body, self.yul_block(input))?; seq.finish() }) - .with_kind(RuleKind::AssemblyStatement) + .with_kind(NonTerminalKind::AssemblyStatement) } #[allow(unused_assignments, unused_parens)] @@ -465,14 +465,14 @@ impl Language { return result; }; match &r#match.nodes[..] { - [cst::LabeledNode { - label: _, - node: cst::Node::Rule(node), - }] if node.kind == RuleKind::Expression => match &node.children[..] { - [inner @ cst::LabeledNode { - label: _, - node: cst::Node::Rule(rule), - }] if rule.kind == RuleKind::AssignmentExpression => { + [cst::Edge { + node: cst::Node::NonTerminal(node), + .. + }] if node.kind == NonTerminalKind::Expression => match &node.children[..] { + [inner @ cst::Edge { + node: cst::Node::NonTerminal(node), + .. + }] if node.kind == NonTerminalKind::AssignmentExpression => { ParserResult::r#match(vec![inner.clone()], r#match.expected_tokens.clone()) } _ => ParserResult::no_match(vec![]), @@ -488,14 +488,14 @@ impl Language { return result; }; match &r#match.nodes[..] { - [cst::LabeledNode { - label: _, - node: cst::Node::Rule(node), - }] if node.kind == RuleKind::Expression => match &node.children[..] { - [inner @ cst::LabeledNode { - label: _, - node: cst::Node::Rule(rule), - }] if rule.kind == RuleKind::BitwiseAndExpression => { + [cst::Edge { + node: cst::Node::NonTerminal(node), + .. + }] if node.kind == NonTerminalKind::Expression => match &node.children[..] { + [inner @ cst::Edge { + node: cst::Node::NonTerminal(node), + .. + }] if node.kind == NonTerminalKind::BitwiseAndExpression => { ParserResult::r#match(vec![inner.clone()], r#match.expected_tokens.clone()) } _ => ParserResult::no_match(vec![]), @@ -511,14 +511,14 @@ impl Language { return result; }; match &r#match.nodes[..] { - [cst::LabeledNode { - label: _, - node: cst::Node::Rule(node), - }] if node.kind == RuleKind::Expression => match &node.children[..] { - [inner @ cst::LabeledNode { - label: _, - node: cst::Node::Rule(rule), - }] if rule.kind == RuleKind::BitwiseOrExpression => { + [cst::Edge { + node: cst::Node::NonTerminal(node), + .. + }] if node.kind == NonTerminalKind::Expression => match &node.children[..] { + [inner @ cst::Edge { + node: cst::Node::NonTerminal(node), + .. + }] if node.kind == NonTerminalKind::BitwiseOrExpression => { ParserResult::r#match(vec![inner.clone()], r#match.expected_tokens.clone()) } _ => ParserResult::no_match(vec![]), @@ -534,14 +534,14 @@ impl Language { return result; }; match &r#match.nodes[..] { - [cst::LabeledNode { - label: _, - node: cst::Node::Rule(node), - }] if node.kind == RuleKind::Expression => match &node.children[..] { - [inner @ cst::LabeledNode { - label: _, - node: cst::Node::Rule(rule), - }] if rule.kind == RuleKind::BitwiseXorExpression => { + [cst::Edge { + node: cst::Node::NonTerminal(node), + .. + }] if node.kind == NonTerminalKind::Expression => match &node.children[..] { + [inner @ cst::Edge { + node: cst::Node::NonTerminal(node), + .. + }] if node.kind == NonTerminalKind::BitwiseXorExpression => { ParserResult::r#match(vec![inner.clone()], r#match.expected_tokens.clone()) } _ => ParserResult::no_match(vec![]), @@ -553,35 +553,35 @@ impl Language { #[allow(unused_assignments, unused_parens)] fn block(&self, input: &mut ParserContext<'_>) -> ParserResult { SequenceHelper::run(|mut seq| { - let mut delim_guard = input.open_delim(TokenKind::CloseBrace); + let mut delim_guard = input.open_delim(TerminalKind::CloseBrace); let input = delim_guard.ctx(); seq.elem_labeled( - NodeLabel::OpenBrace, + EdgeLabel::OpenBrace, self.parse_token_with_trivia::( input, - TokenKind::OpenBrace, + TerminalKind::OpenBrace, ), )?; seq.elem( self.statements(input) - .with_label(NodeLabel::Statements) + .with_label(EdgeLabel::Statements) .recover_until_with_nested_delims::<_, LexicalContextType::Default>( input, self, - TokenKind::CloseBrace, + TerminalKind::CloseBrace, TokenAcceptanceThreshold(0u8), ), )?; seq.elem_labeled( - NodeLabel::CloseBrace, + EdgeLabel::CloseBrace, self.parse_token_with_trivia::( input, - TokenKind::CloseBrace, + TerminalKind::CloseBrace, ), )?; seq.finish() }) - .with_kind(RuleKind::Block) + .with_kind(NonTerminalKind::Block) } #[allow(unused_assignments, unused_parens)] @@ -590,26 +590,26 @@ impl Language { seq.elem( self.parse_token_with_trivia::( input, - TokenKind::BreakKeyword, + TerminalKind::BreakKeyword, ) - .with_label(NodeLabel::BreakKeyword) + .with_label(EdgeLabel::BreakKeyword) .recover_until_with_nested_delims::<_, LexicalContextType::Default>( input, self, - TokenKind::Semicolon, + TerminalKind::Semicolon, TokenAcceptanceThreshold(1u8), ), )?; seq.elem_labeled( - NodeLabel::Semicolon, + EdgeLabel::Semicolon, self.parse_token_with_trivia::( input, - TokenKind::Semicolon, + TerminalKind::Semicolon, ), )?; seq.finish() }) - .with_kind(RuleKind::BreakStatement) + .with_kind(NonTerminalKind::BreakStatement) } #[allow(unused_assignments, unused_parens)] @@ -618,14 +618,14 @@ impl Language { SeparatedHelper::run::<_, LexicalContextType::Default>( input, self, - |input| self.named_argument(input).with_label(NodeLabel::Item), - TokenKind::Comma, - NodeLabel::Separator, + |input| self.named_argument(input).with_label(EdgeLabel::Item), + TerminalKind::Comma, + EdgeLabel::Separator, ) } else { ParserResult::disabled() } - .with_kind(RuleKind::CallOptions) + .with_kind(NonTerminalKind::CallOptions) } #[allow(unused_assignments, unused_parens)] @@ -635,14 +635,14 @@ impl Language { return result; }; match &r#match.nodes[..] { - [cst::LabeledNode { - label: _, - node: cst::Node::Rule(node), - }] if node.kind == RuleKind::Expression => match &node.children[..] { - [inner @ cst::LabeledNode { - label: _, - node: cst::Node::Rule(rule), - }] if rule.kind == RuleKind::CallOptionsExpression => { + [cst::Edge { + node: cst::Node::NonTerminal(node), + .. + }] if node.kind == NonTerminalKind::Expression => match &node.children[..] { + [inner @ cst::Edge { + node: cst::Node::NonTerminal(node), + .. + }] if node.kind == NonTerminalKind::CallOptionsExpression => { ParserResult::r#match(vec![inner.clone()], r#match.expected_tokens.clone()) } _ => ParserResult::no_match(vec![]), @@ -656,23 +656,23 @@ impl Language { if self.version_is_at_least_0_6_0 { SequenceHelper::run(|mut seq| { seq.elem_labeled( - NodeLabel::CatchKeyword, + EdgeLabel::CatchKeyword, self.parse_token_with_trivia::( input, - TokenKind::CatchKeyword, + TerminalKind::CatchKeyword, ), )?; seq.elem_labeled( - NodeLabel::Error, + EdgeLabel::Error, OptionalHelper::transform(self.catch_clause_error(input)), )?; - seq.elem_labeled(NodeLabel::Body, self.block(input))?; + seq.elem_labeled(EdgeLabel::Body, self.block(input))?; seq.finish() }) } else { ParserResult::disabled() } - .with_kind(RuleKind::CatchClause) + .with_kind(NonTerminalKind::CatchClause) } #[allow(unused_assignments, unused_parens)] @@ -680,33 +680,33 @@ impl Language { if self.version_is_at_least_0_6_0 { SequenceHelper::run(|mut seq| { seq.elem_labeled( - NodeLabel::Name, + EdgeLabel::Name, OptionalHelper::transform( self.parse_token_with_trivia::( input, - TokenKind::Identifier, + TerminalKind::Identifier, ), ), )?; - seq.elem_labeled(NodeLabel::Parameters, self.parameters_declaration(input))?; + seq.elem_labeled(EdgeLabel::Parameters, self.parameters_declaration(input))?; seq.finish() }) } else { ParserResult::disabled() } - .with_kind(RuleKind::CatchClauseError) + .with_kind(NonTerminalKind::CatchClauseError) } #[allow(unused_assignments, unused_parens)] fn catch_clauses(&self, input: &mut ParserContext<'_>) -> ParserResult { if self.version_is_at_least_0_6_0 { OneOrMoreHelper::run(input, |input| { - self.catch_clause(input).with_label(NodeLabel::Item) + self.catch_clause(input).with_label(EdgeLabel::Item) }) } else { ParserResult::disabled() } - .with_kind(RuleKind::CatchClauses) + .with_kind(NonTerminalKind::CatchClauses) } #[allow(unused_assignments, unused_parens)] @@ -716,14 +716,14 @@ impl Language { return result; }; match &r#match.nodes[..] { - [cst::LabeledNode { - label: _, - node: cst::Node::Rule(node), - }] if node.kind == RuleKind::Expression => match &node.children[..] { - [inner @ cst::LabeledNode { - label: _, - node: cst::Node::Rule(rule), - }] if rule.kind == RuleKind::ComparisonExpression => { + [cst::Edge { + node: cst::Node::NonTerminal(node), + .. + }] if node.kind == NonTerminalKind::Expression => match &node.children[..] { + [inner @ cst::Edge { + node: cst::Node::NonTerminal(node), + .. + }] if node.kind == NonTerminalKind::ComparisonExpression => { ParserResult::r#match(vec![inner.clone()], r#match.expected_tokens.clone()) } _ => ParserResult::no_match(vec![]), @@ -739,14 +739,14 @@ impl Language { return result; }; match &r#match.nodes[..] { - [cst::LabeledNode { - label: _, - node: cst::Node::Rule(node), - }] if node.kind == RuleKind::Expression => match &node.children[..] { - [inner @ cst::LabeledNode { - label: _, - node: cst::Node::Rule(rule), - }] if rule.kind == RuleKind::ConditionalExpression => { + [cst::Edge { + node: cst::Node::NonTerminal(node), + .. + }] if node.kind == NonTerminalKind::Expression => match &node.children[..] { + [inner @ cst::Edge { + node: cst::Node::NonTerminal(node), + .. + }] if node.kind == NonTerminalKind::ConditionalExpression => { ParserResult::r#match(vec![inner.clone()], r#match.expected_tokens.clone()) } _ => ParserResult::no_match(vec![]), @@ -761,43 +761,43 @@ impl Language { SequenceHelper::run(|mut seq| { seq.elem( SequenceHelper::run(|mut seq| { - seq.elem_labeled(NodeLabel::TypeName, self.type_name(input))?; + seq.elem_labeled(EdgeLabel::TypeName, self.type_name(input))?; seq.elem_labeled( - NodeLabel::ConstantKeyword, + EdgeLabel::ConstantKeyword, self.parse_token_with_trivia::( input, - TokenKind::ConstantKeyword, + TerminalKind::ConstantKeyword, ), )?; seq.elem_labeled( - NodeLabel::Name, + EdgeLabel::Name, self.parse_token_with_trivia::( input, - TokenKind::Identifier, + TerminalKind::Identifier, ), )?; seq.elem_labeled( - NodeLabel::Equal, + EdgeLabel::Equal, self.parse_token_with_trivia::( input, - TokenKind::Equal, + TerminalKind::Equal, ), )?; - seq.elem_labeled(NodeLabel::Value, self.expression(input))?; + seq.elem_labeled(EdgeLabel::Value, self.expression(input))?; seq.finish() }) .recover_until_with_nested_delims::<_, LexicalContextType::Default>( input, self, - TokenKind::Semicolon, + TerminalKind::Semicolon, TokenAcceptanceThreshold(1u8), ), )?; seq.elem_labeled( - NodeLabel::Semicolon, + EdgeLabel::Semicolon, self.parse_token_with_trivia::( input, - TokenKind::Semicolon, + TerminalKind::Semicolon, ), )?; seq.finish() @@ -805,7 +805,7 @@ impl Language { } else { ParserResult::disabled() } - .with_kind(RuleKind::ConstantDefinition) + .with_kind(NonTerminalKind::ConstantDefinition) } #[allow(unused_assignments, unused_parens)] @@ -816,40 +816,40 @@ impl Language { choice.consider(input, result)?; let result = self.parse_token_with_trivia::( input, - TokenKind::InternalKeyword, + TerminalKind::InternalKeyword, ); choice.consider(input, result)?; if self.version_is_at_least_0_6_0 && !self.version_is_at_least_0_6_7 { let result = self.parse_token_with_trivia::( input, - TokenKind::OverrideKeyword, + TerminalKind::OverrideKeyword, ); choice.consider(input, result)?; } let result = self.parse_token_with_trivia::( input, - TokenKind::PayableKeyword, + TerminalKind::PayableKeyword, ); choice.consider(input, result)?; let result = self.parse_token_with_trivia::( input, - TokenKind::PublicKeyword, + TerminalKind::PublicKeyword, ); choice.consider(input, result)?; if self.version_is_at_least_0_6_0 && !self.version_is_at_least_0_6_7 { let result = self.parse_token_with_trivia::( input, - TokenKind::VirtualKeyword, + TerminalKind::VirtualKeyword, ); choice.consider(input, result)?; } choice.finish(input) }) - .with_label(NodeLabel::Variant) + .with_label(EdgeLabel::Variant) } else { ParserResult::disabled() } - .with_kind(RuleKind::ConstructorAttribute) + .with_kind(NonTerminalKind::ConstructorAttribute) } #[allow(unused_assignments, unused_parens)] @@ -857,12 +857,12 @@ impl Language { if self.version_is_at_least_0_4_22 { ZeroOrMoreHelper::run(input, |input| { self.constructor_attribute(input) - .with_label(NodeLabel::Item) + .with_label(EdgeLabel::Item) }) } else { ParserResult::disabled() } - .with_kind(RuleKind::ConstructorAttributes) + .with_kind(NonTerminalKind::ConstructorAttributes) } #[allow(unused_assignments, unused_parens)] @@ -870,21 +870,21 @@ impl Language { if self.version_is_at_least_0_4_22 { SequenceHelper::run(|mut seq| { seq.elem_labeled( - NodeLabel::ConstructorKeyword, + EdgeLabel::ConstructorKeyword, self.parse_token_with_trivia::( input, - TokenKind::ConstructorKeyword, + TerminalKind::ConstructorKeyword, ), )?; - seq.elem_labeled(NodeLabel::Parameters, self.parameters_declaration(input))?; - seq.elem_labeled(NodeLabel::Attributes, self.constructor_attributes(input))?; - seq.elem_labeled(NodeLabel::Body, self.block(input))?; + seq.elem_labeled(EdgeLabel::Parameters, self.parameters_declaration(input))?; + seq.elem_labeled(EdgeLabel::Attributes, self.constructor_attributes(input))?; + seq.elem_labeled(EdgeLabel::Body, self.block(input))?; seq.finish() }) } else { ParserResult::disabled() } - .with_kind(RuleKind::ConstructorDefinition) + .with_kind(NonTerminalKind::ConstructorDefinition) } #[allow(unused_assignments, unused_parens)] @@ -893,26 +893,26 @@ impl Language { seq.elem( self.parse_token_with_trivia::( input, - TokenKind::ContinueKeyword, + TerminalKind::ContinueKeyword, ) - .with_label(NodeLabel::ContinueKeyword) + .with_label(EdgeLabel::ContinueKeyword) .recover_until_with_nested_delims::<_, LexicalContextType::Default>( input, self, - TokenKind::Semicolon, + TerminalKind::Semicolon, TokenAcceptanceThreshold(1u8), ), )?; seq.elem_labeled( - NodeLabel::Semicolon, + EdgeLabel::Semicolon, self.parse_token_with_trivia::( input, - TokenKind::Semicolon, + TerminalKind::Semicolon, ), )?; seq.finish() }) - .with_kind(RuleKind::ContinueStatement) + .with_kind(NonTerminalKind::ContinueStatement) } #[allow(unused_assignments, unused_parens)] @@ -920,65 +920,65 @@ impl Language { SequenceHelper::run(|mut seq| { if self.version_is_at_least_0_6_0 { seq.elem_labeled( - NodeLabel::AbstractKeyword, + EdgeLabel::AbstractKeyword, OptionalHelper::transform( self.parse_token_with_trivia::( input, - TokenKind::AbstractKeyword, + TerminalKind::AbstractKeyword, ), ), )?; } seq.elem_labeled( - NodeLabel::ContractKeyword, + EdgeLabel::ContractKeyword, self.parse_token_with_trivia::( input, - TokenKind::ContractKeyword, + TerminalKind::ContractKeyword, ), )?; seq.elem_labeled( - NodeLabel::Name, + EdgeLabel::Name, self.parse_token_with_trivia::( input, - TokenKind::Identifier, + TerminalKind::Identifier, ), )?; seq.elem_labeled( - NodeLabel::Inheritence, + EdgeLabel::Inheritence, OptionalHelper::transform(self.inheritance_specifier(input)), )?; seq.elem(SequenceHelper::run(|mut seq| { - let mut delim_guard = input.open_delim(TokenKind::CloseBrace); + let mut delim_guard = input.open_delim(TerminalKind::CloseBrace); let input = delim_guard.ctx(); seq.elem_labeled( - NodeLabel::OpenBrace, + EdgeLabel::OpenBrace, self.parse_token_with_trivia::( input, - TokenKind::OpenBrace, + TerminalKind::OpenBrace, ), )?; seq.elem( self.contract_members(input) - .with_label(NodeLabel::Members) + .with_label(EdgeLabel::Members) .recover_until_with_nested_delims::<_, LexicalContextType::Default>( input, self, - TokenKind::CloseBrace, + TerminalKind::CloseBrace, TokenAcceptanceThreshold(0u8), ), )?; seq.elem_labeled( - NodeLabel::CloseBrace, + EdgeLabel::CloseBrace, self.parse_token_with_trivia::( input, - TokenKind::CloseBrace, + TerminalKind::CloseBrace, ), )?; seq.finish() }))?; seq.finish() }) - .with_kind(RuleKind::ContractDefinition) + .with_kind(NonTerminalKind::ContractDefinition) } #[allow(unused_assignments, unused_parens)] @@ -1024,35 +1024,35 @@ impl Language { } choice.finish(input) }) - .with_label(NodeLabel::Variant) - .with_kind(RuleKind::ContractMember) + .with_label(EdgeLabel::Variant) + .with_kind(NonTerminalKind::ContractMember) } #[allow(unused_assignments, unused_parens)] fn contract_members(&self, input: &mut ParserContext<'_>) -> ParserResult { ZeroOrMoreHelper::run(input, |input| { - self.contract_member(input).with_label(NodeLabel::Item) + self.contract_member(input).with_label(EdgeLabel::Item) }) - .with_kind(RuleKind::ContractMembers) + .with_kind(NonTerminalKind::ContractMembers) } #[allow(unused_assignments, unused_parens)] fn decimal_number_expression(&self, input: &mut ParserContext<'_>) -> ParserResult { SequenceHelper::run(|mut seq| { seq.elem_labeled( - NodeLabel::Literal, + EdgeLabel::Literal, self.parse_token_with_trivia::( input, - TokenKind::DecimalLiteral, + TerminalKind::DecimalLiteral, ), )?; seq.elem_labeled( - NodeLabel::Unit, + EdgeLabel::Unit, OptionalHelper::transform(self.number_unit(input)), )?; seq.finish() }) - .with_kind(RuleKind::DecimalNumberExpression) + .with_kind(NonTerminalKind::DecimalNumberExpression) } #[allow(unused_assignments, unused_parens)] @@ -1061,45 +1061,45 @@ impl Language { seq.elem( SequenceHelper::run(|mut seq| { seq.elem_labeled( - NodeLabel::DoKeyword, + EdgeLabel::DoKeyword, self.parse_token_with_trivia::( input, - TokenKind::DoKeyword, + TerminalKind::DoKeyword, ), )?; - seq.elem_labeled(NodeLabel::Body, self.statement(input))?; + seq.elem_labeled(EdgeLabel::Body, self.statement(input))?; seq.elem_labeled( - NodeLabel::WhileKeyword, + EdgeLabel::WhileKeyword, self.parse_token_with_trivia::( input, - TokenKind::WhileKeyword, + TerminalKind::WhileKeyword, ), )?; seq.elem(SequenceHelper::run(|mut seq| { - let mut delim_guard = input.open_delim(TokenKind::CloseParen); + let mut delim_guard = input.open_delim(TerminalKind::CloseParen); let input = delim_guard.ctx(); seq.elem_labeled( - NodeLabel::OpenParen, + EdgeLabel::OpenParen, self.parse_token_with_trivia::( input, - TokenKind::OpenParen, + TerminalKind::OpenParen, ), )?; seq.elem( self.expression(input) - .with_label(NodeLabel::Condition) + .with_label(EdgeLabel::Condition) .recover_until_with_nested_delims::<_, LexicalContextType::Default>( input, self, - TokenKind::CloseParen, + TerminalKind::CloseParen, TokenAcceptanceThreshold(0u8), ), )?; seq.elem_labeled( - NodeLabel::CloseParen, + EdgeLabel::CloseParen, self.parse_token_with_trivia::( input, - TokenKind::CloseParen, + TerminalKind::CloseParen, ), )?; seq.finish() @@ -1109,20 +1109,20 @@ impl Language { .recover_until_with_nested_delims::<_, LexicalContextType::Default>( input, self, - TokenKind::Semicolon, + TerminalKind::Semicolon, TokenAcceptanceThreshold(1u8), ), )?; seq.elem_labeled( - NodeLabel::Semicolon, + EdgeLabel::Semicolon, self.parse_token_with_trivia::( input, - TokenKind::Semicolon, + TerminalKind::Semicolon, ), )?; seq.finish() }) - .with_kind(RuleKind::DoWhileStatement) + .with_kind(NonTerminalKind::DoWhileStatement) } #[allow(unused_assignments, unused_parens)] @@ -1130,68 +1130,68 @@ impl Language { ChoiceHelper::run(input, |mut choice, input| { let result = self.parse_token_with_trivia::( input, - TokenKind::BoolKeyword, + TerminalKind::BoolKeyword, ); choice.consider(input, result)?; if !self.version_is_at_least_0_8_0 { let result = self.parse_token_with_trivia::( input, - TokenKind::ByteKeyword, + TerminalKind::ByteKeyword, ); choice.consider(input, result)?; } let result = self.parse_token_with_trivia::( input, - TokenKind::StringKeyword, + TerminalKind::StringKeyword, ); choice.consider(input, result)?; let result = self.address_type(input); choice.consider(input, result)?; let result = self.parse_token_with_trivia::( input, - TokenKind::BytesKeyword, + TerminalKind::BytesKeyword, ); choice.consider(input, result)?; let result = self.parse_token_with_trivia::( input, - TokenKind::IntKeyword, + TerminalKind::IntKeyword, ); choice.consider(input, result)?; let result = self.parse_token_with_trivia::( input, - TokenKind::UintKeyword, + TerminalKind::UintKeyword, ); choice.consider(input, result)?; let result = self.parse_token_with_trivia::( input, - TokenKind::FixedKeyword, + TerminalKind::FixedKeyword, ); choice.consider(input, result)?; let result = self.parse_token_with_trivia::( input, - TokenKind::UfixedKeyword, + TerminalKind::UfixedKeyword, ); choice.consider(input, result)?; choice.finish(input) }) - .with_label(NodeLabel::Variant) - .with_kind(RuleKind::ElementaryType) + .with_label(EdgeLabel::Variant) + .with_kind(NonTerminalKind::ElementaryType) } #[allow(unused_assignments, unused_parens)] fn else_branch(&self, input: &mut ParserContext<'_>) -> ParserResult { SequenceHelper::run(|mut seq| { seq.elem_labeled( - NodeLabel::ElseKeyword, + EdgeLabel::ElseKeyword, self.parse_token_with_trivia::( input, - TokenKind::ElseKeyword, + TerminalKind::ElseKeyword, ), )?; - seq.elem_labeled(NodeLabel::Body, self.statement(input))?; + seq.elem_labeled(EdgeLabel::Body, self.statement(input))?; seq.finish() }) - .with_kind(RuleKind::ElseBranch) + .with_kind(NonTerminalKind::ElseBranch) } #[allow(unused_assignments, unused_parens)] @@ -1201,28 +1201,28 @@ impl Language { seq.elem( SequenceHelper::run(|mut seq| { seq.elem_labeled( - NodeLabel::EmitKeyword, + EdgeLabel::EmitKeyword, self.parse_token_with_trivia::( input, - TokenKind::EmitKeyword, + TerminalKind::EmitKeyword, ), )?; - seq.elem_labeled(NodeLabel::Event, self.identifier_path(input))?; - seq.elem_labeled(NodeLabel::Arguments, self.arguments_declaration(input))?; + seq.elem_labeled(EdgeLabel::Event, self.identifier_path(input))?; + seq.elem_labeled(EdgeLabel::Arguments, self.arguments_declaration(input))?; seq.finish() }) .recover_until_with_nested_delims::<_, LexicalContextType::Default>( input, self, - TokenKind::Semicolon, + TerminalKind::Semicolon, TokenAcceptanceThreshold(1u8), ), )?; seq.elem_labeled( - NodeLabel::Semicolon, + EdgeLabel::Semicolon, self.parse_token_with_trivia::( input, - TokenKind::Semicolon, + TerminalKind::Semicolon, ), )?; seq.finish() @@ -1230,58 +1230,58 @@ impl Language { } else { ParserResult::disabled() } - .with_kind(RuleKind::EmitStatement) + .with_kind(NonTerminalKind::EmitStatement) } #[allow(unused_assignments, unused_parens)] fn enum_definition(&self, input: &mut ParserContext<'_>) -> ParserResult { SequenceHelper::run(|mut seq| { seq.elem_labeled( - NodeLabel::EnumKeyword, + EdgeLabel::EnumKeyword, self.parse_token_with_trivia::( input, - TokenKind::EnumKeyword, + TerminalKind::EnumKeyword, ), )?; seq.elem_labeled( - NodeLabel::Name, + EdgeLabel::Name, self.parse_token_with_trivia::( input, - TokenKind::Identifier, + TerminalKind::Identifier, ), )?; seq.elem(SequenceHelper::run(|mut seq| { - let mut delim_guard = input.open_delim(TokenKind::CloseBrace); + let mut delim_guard = input.open_delim(TerminalKind::CloseBrace); let input = delim_guard.ctx(); seq.elem_labeled( - NodeLabel::OpenBrace, + EdgeLabel::OpenBrace, self.parse_token_with_trivia::( input, - TokenKind::OpenBrace, + TerminalKind::OpenBrace, ), )?; seq.elem( self.enum_members(input) - .with_label(NodeLabel::Members) + .with_label(EdgeLabel::Members) .recover_until_with_nested_delims::<_, LexicalContextType::Default>( input, self, - TokenKind::CloseBrace, + TerminalKind::CloseBrace, TokenAcceptanceThreshold(0u8), ), )?; seq.elem_labeled( - NodeLabel::CloseBrace, + EdgeLabel::CloseBrace, self.parse_token_with_trivia::( input, - TokenKind::CloseBrace, + TerminalKind::CloseBrace, ), )?; seq.finish() }))?; seq.finish() }) - .with_kind(RuleKind::EnumDefinition) + .with_kind(NonTerminalKind::EnumDefinition) } #[allow(unused_assignments, unused_parens)] @@ -1292,14 +1292,14 @@ impl Language { |input| { self.parse_token_with_trivia::( input, - TokenKind::Identifier, + TerminalKind::Identifier, ) - .with_label(NodeLabel::Item) + .with_label(EdgeLabel::Item) }, - TokenKind::Comma, - NodeLabel::Separator, + TerminalKind::Comma, + EdgeLabel::Separator, )) - .with_kind(RuleKind::EnumMembers) + .with_kind(NonTerminalKind::EnumMembers) } #[allow(unused_assignments, unused_parens)] @@ -1309,14 +1309,14 @@ impl Language { return result; }; match &r#match.nodes[..] { - [cst::LabeledNode { - label: _, - node: cst::Node::Rule(node), - }] if node.kind == RuleKind::Expression => match &node.children[..] { - [inner @ cst::LabeledNode { - label: _, - node: cst::Node::Rule(rule), - }] if rule.kind == RuleKind::EqualityExpression => { + [cst::Edge { + node: cst::Node::NonTerminal(node), + .. + }] if node.kind == NonTerminalKind::Expression => match &node.children[..] { + [inner @ cst::Edge { + node: cst::Node::NonTerminal(node), + .. + }] if node.kind == NonTerminalKind::EqualityExpression => { ParserResult::r#match(vec![inner.clone()], r#match.expected_tokens.clone()) } _ => ParserResult::no_match(vec![]), @@ -1332,21 +1332,21 @@ impl Language { seq.elem( SequenceHelper::run(|mut seq| { seq.elem_labeled( - NodeLabel::ErrorKeyword, + EdgeLabel::ErrorKeyword, self.parse_token_with_trivia::( input, - TokenKind::ErrorKeyword, + TerminalKind::ErrorKeyword, ), )?; seq.elem_labeled( - NodeLabel::Name, + EdgeLabel::Name, self.parse_token_with_trivia::( input, - TokenKind::Identifier, + TerminalKind::Identifier, ), )?; seq.elem_labeled( - NodeLabel::Members, + EdgeLabel::Members, self.error_parameters_declaration(input), )?; seq.finish() @@ -1354,15 +1354,15 @@ impl Language { .recover_until_with_nested_delims::<_, LexicalContextType::Default>( input, self, - TokenKind::Semicolon, + TerminalKind::Semicolon, TokenAcceptanceThreshold(1u8), ), )?; seq.elem_labeled( - NodeLabel::Semicolon, + EdgeLabel::Semicolon, self.parse_token_with_trivia::( input, - TokenKind::Semicolon, + TerminalKind::Semicolon, ), )?; seq.finish() @@ -1370,20 +1370,20 @@ impl Language { } else { ParserResult::disabled() } - .with_kind(RuleKind::ErrorDefinition) + .with_kind(NonTerminalKind::ErrorDefinition) } #[allow(unused_assignments, unused_parens)] fn error_parameter(&self, input: &mut ParserContext<'_>) -> ParserResult { if self.version_is_at_least_0_8_4 { SequenceHelper::run(|mut seq| { - seq.elem_labeled(NodeLabel::TypeName, self.type_name(input))?; + seq.elem_labeled(EdgeLabel::TypeName, self.type_name(input))?; seq.elem_labeled( - NodeLabel::Name, + EdgeLabel::Name, OptionalHelper::transform( self.parse_token_with_trivia::( input, - TokenKind::Identifier, + TerminalKind::Identifier, ), ), )?; @@ -1392,7 +1392,7 @@ impl Language { } else { ParserResult::disabled() } - .with_kind(RuleKind::ErrorParameter) + .with_kind(NonTerminalKind::ErrorParameter) } #[allow(unused_assignments, unused_parens)] @@ -1401,44 +1401,44 @@ impl Language { OptionalHelper::transform(SeparatedHelper::run::<_, LexicalContextType::Default>( input, self, - |input| self.error_parameter(input).with_label(NodeLabel::Item), - TokenKind::Comma, - NodeLabel::Separator, + |input| self.error_parameter(input).with_label(EdgeLabel::Item), + TerminalKind::Comma, + EdgeLabel::Separator, )) } else { ParserResult::disabled() } - .with_kind(RuleKind::ErrorParameters) + .with_kind(NonTerminalKind::ErrorParameters) } #[allow(unused_assignments, unused_parens)] fn error_parameters_declaration(&self, input: &mut ParserContext<'_>) -> ParserResult { if self.version_is_at_least_0_8_4 { SequenceHelper::run(|mut seq| { - let mut delim_guard = input.open_delim(TokenKind::CloseParen); + let mut delim_guard = input.open_delim(TerminalKind::CloseParen); let input = delim_guard.ctx(); seq.elem_labeled( - NodeLabel::OpenParen, + EdgeLabel::OpenParen, self.parse_token_with_trivia::( input, - TokenKind::OpenParen, + TerminalKind::OpenParen, ), )?; seq.elem( self.error_parameters(input) - .with_label(NodeLabel::Parameters) + .with_label(EdgeLabel::Parameters) .recover_until_with_nested_delims::<_, LexicalContextType::Default>( input, self, - TokenKind::CloseParen, + TerminalKind::CloseParen, TokenAcceptanceThreshold(0u8), ), )?; seq.elem_labeled( - NodeLabel::CloseParen, + EdgeLabel::CloseParen, self.parse_token_with_trivia::( input, - TokenKind::CloseParen, + TerminalKind::CloseParen, ), )?; seq.finish() @@ -1446,7 +1446,7 @@ impl Language { } else { ParserResult::disabled() } - .with_kind(RuleKind::ErrorParametersDeclaration) + .with_kind(NonTerminalKind::ErrorParametersDeclaration) } #[allow(unused_assignments, unused_parens)] @@ -1455,29 +1455,29 @@ impl Language { seq.elem( SequenceHelper::run(|mut seq| { seq.elem_labeled( - NodeLabel::EventKeyword, + EdgeLabel::EventKeyword, self.parse_token_with_trivia::( input, - TokenKind::EventKeyword, + TerminalKind::EventKeyword, ), )?; seq.elem_labeled( - NodeLabel::Name, + EdgeLabel::Name, self.parse_token_with_trivia::( input, - TokenKind::Identifier, + TerminalKind::Identifier, ), )?; seq.elem_labeled( - NodeLabel::Parameters, + EdgeLabel::Parameters, self.event_parameters_declaration(input), )?; seq.elem_labeled( - NodeLabel::AnonymousKeyword, + EdgeLabel::AnonymousKeyword, OptionalHelper::transform( self.parse_token_with_trivia::( input, - TokenKind::AnonymousKeyword, + TerminalKind::AnonymousKeyword, ), ), )?; @@ -1486,47 +1486,47 @@ impl Language { .recover_until_with_nested_delims::<_, LexicalContextType::Default>( input, self, - TokenKind::Semicolon, + TerminalKind::Semicolon, TokenAcceptanceThreshold(1u8), ), )?; seq.elem_labeled( - NodeLabel::Semicolon, + EdgeLabel::Semicolon, self.parse_token_with_trivia::( input, - TokenKind::Semicolon, + TerminalKind::Semicolon, ), )?; seq.finish() }) - .with_kind(RuleKind::EventDefinition) + .with_kind(NonTerminalKind::EventDefinition) } #[allow(unused_assignments, unused_parens)] fn event_parameter(&self, input: &mut ParserContext<'_>) -> ParserResult { SequenceHelper::run(|mut seq| { - seq.elem_labeled(NodeLabel::TypeName, self.type_name(input))?; + seq.elem_labeled(EdgeLabel::TypeName, self.type_name(input))?; seq.elem_labeled( - NodeLabel::IndexedKeyword, + EdgeLabel::IndexedKeyword, OptionalHelper::transform( self.parse_token_with_trivia::( input, - TokenKind::IndexedKeyword, + TerminalKind::IndexedKeyword, ), ), )?; seq.elem_labeled( - NodeLabel::Name, + EdgeLabel::Name, OptionalHelper::transform( self.parse_token_with_trivia::( input, - TokenKind::Identifier, + TerminalKind::Identifier, ), ), )?; seq.finish() }) - .with_kind(RuleKind::EventParameter) + .with_kind(NonTerminalKind::EventParameter) } #[allow(unused_assignments, unused_parens)] @@ -1534,45 +1534,45 @@ impl Language { OptionalHelper::transform(SeparatedHelper::run::<_, LexicalContextType::Default>( input, self, - |input| self.event_parameter(input).with_label(NodeLabel::Item), - TokenKind::Comma, - NodeLabel::Separator, + |input| self.event_parameter(input).with_label(EdgeLabel::Item), + TerminalKind::Comma, + EdgeLabel::Separator, )) - .with_kind(RuleKind::EventParameters) + .with_kind(NonTerminalKind::EventParameters) } #[allow(unused_assignments, unused_parens)] fn event_parameters_declaration(&self, input: &mut ParserContext<'_>) -> ParserResult { SequenceHelper::run(|mut seq| { - let mut delim_guard = input.open_delim(TokenKind::CloseParen); + let mut delim_guard = input.open_delim(TerminalKind::CloseParen); let input = delim_guard.ctx(); seq.elem_labeled( - NodeLabel::OpenParen, + EdgeLabel::OpenParen, self.parse_token_with_trivia::( input, - TokenKind::OpenParen, + TerminalKind::OpenParen, ), )?; seq.elem( self.event_parameters(input) - .with_label(NodeLabel::Parameters) + .with_label(EdgeLabel::Parameters) .recover_until_with_nested_delims::<_, LexicalContextType::Default>( input, self, - TokenKind::CloseParen, + TerminalKind::CloseParen, TokenAcceptanceThreshold(0u8), ), )?; seq.elem_labeled( - NodeLabel::CloseParen, + EdgeLabel::CloseParen, self.parse_token_with_trivia::( input, - TokenKind::CloseParen, + TerminalKind::CloseParen, ), )?; seq.finish() }) - .with_kind(RuleKind::EventParametersDeclaration) + .with_kind(NonTerminalKind::EventParametersDeclaration) } #[allow(unused_assignments, unused_parens)] @@ -1580,31 +1580,31 @@ impl Language { ChoiceHelper::run(input, |mut choice, input| { let result = self.parse_token_with_trivia::( input, - TokenKind::Identifier, + TerminalKind::Identifier, ); choice.consider(input, result)?; let result = self.string_literal(input); choice.consider(input, result)?; choice.finish(input) }) - .with_label(NodeLabel::Variant) - .with_kind(RuleKind::ExperimentalFeature) + .with_label(EdgeLabel::Variant) + .with_kind(NonTerminalKind::ExperimentalFeature) } #[allow(unused_assignments, unused_parens)] fn experimental_pragma(&self, input: &mut ParserContext<'_>) -> ParserResult { SequenceHelper::run(|mut seq| { seq.elem_labeled( - NodeLabel::ExperimentalKeyword, + EdgeLabel::ExperimentalKeyword, self.parse_token_with_trivia::( input, - TokenKind::ExperimentalKeyword, + TerminalKind::ExperimentalKeyword, ), )?; - seq.elem_labeled(NodeLabel::Feature, self.experimental_feature(input))?; + seq.elem_labeled(EdgeLabel::Feature, self.experimental_feature(input))?; seq.finish() }) - .with_kind(RuleKind::ExperimentalPragma) + .with_kind(NonTerminalKind::ExperimentalPragma) } #[allow(unused_assignments, unused_parens)] @@ -1614,14 +1614,14 @@ impl Language { return result; }; match &r#match.nodes[..] { - [cst::LabeledNode { - label: _, - node: cst::Node::Rule(node), - }] if node.kind == RuleKind::Expression => match &node.children[..] { - [inner @ cst::LabeledNode { - label: _, - node: cst::Node::Rule(rule), - }] if rule.kind == RuleKind::ExponentiationExpression => { + [cst::Edge { + node: cst::Node::NonTerminal(node), + .. + }] if node.kind == NonTerminalKind::Expression => match &node.children[..] { + [inner @ cst::Edge { + node: cst::Node::NonTerminal(node), + .. + }] if node.kind == NonTerminalKind::ExponentiationExpression => { ParserResult::r#match(vec![inner.clone()], r#match.expected_tokens.clone()) } _ => ParserResult::no_match(vec![]), @@ -1634,93 +1634,93 @@ impl Language { fn expression(&self, input: &mut ParserContext<'_>) -> ParserResult { let parse_left_assignment_expression = |input: &mut ParserContext<'_>| { PrecedenceHelper::to_binary_operator( - RuleKind::AssignmentExpression, + NonTerminalKind::AssignmentExpression, 1u8, 1u8 + 1, ChoiceHelper::run(input, |mut choice, input| { let result = self .parse_token_with_trivia::( input, - TokenKind::Equal, + TerminalKind::Equal, ) - .with_label(NodeLabel::Operator); + .with_label(EdgeLabel::Operator); choice.consider(input, result)?; let result = self .parse_token_with_trivia::( input, - TokenKind::BarEqual, + TerminalKind::BarEqual, ) - .with_label(NodeLabel::Operator); + .with_label(EdgeLabel::Operator); choice.consider(input, result)?; let result = self .parse_token_with_trivia::( input, - TokenKind::PlusEqual, + TerminalKind::PlusEqual, ) - .with_label(NodeLabel::Operator); + .with_label(EdgeLabel::Operator); choice.consider(input, result)?; let result = self .parse_token_with_trivia::( input, - TokenKind::MinusEqual, + TerminalKind::MinusEqual, ) - .with_label(NodeLabel::Operator); + .with_label(EdgeLabel::Operator); choice.consider(input, result)?; let result = self .parse_token_with_trivia::( input, - TokenKind::CaretEqual, + TerminalKind::CaretEqual, ) - .with_label(NodeLabel::Operator); + .with_label(EdgeLabel::Operator); choice.consider(input, result)?; let result = self .parse_token_with_trivia::( input, - TokenKind::SlashEqual, + TerminalKind::SlashEqual, ) - .with_label(NodeLabel::Operator); + .with_label(EdgeLabel::Operator); choice.consider(input, result)?; let result = self .parse_token_with_trivia::( input, - TokenKind::PercentEqual, + TerminalKind::PercentEqual, ) - .with_label(NodeLabel::Operator); + .with_label(EdgeLabel::Operator); choice.consider(input, result)?; let result = self .parse_token_with_trivia::( input, - TokenKind::AsteriskEqual, + TerminalKind::AsteriskEqual, ) - .with_label(NodeLabel::Operator); + .with_label(EdgeLabel::Operator); choice.consider(input, result)?; let result = self .parse_token_with_trivia::( input, - TokenKind::AmpersandEqual, + TerminalKind::AmpersandEqual, ) - .with_label(NodeLabel::Operator); + .with_label(EdgeLabel::Operator); choice.consider(input, result)?; let result = self .parse_token_with_trivia::( input, - TokenKind::LessThanLessThanEqual, + TerminalKind::LessThanLessThanEqual, ) - .with_label(NodeLabel::Operator); + .with_label(EdgeLabel::Operator); choice.consider(input, result)?; let result = self .parse_token_with_trivia::( input, - TokenKind::GreaterThanGreaterThanEqual, + TerminalKind::GreaterThanGreaterThanEqual, ) - .with_label(NodeLabel::Operator); + .with_label(EdgeLabel::Operator); choice.consider(input, result)?; let result = self .parse_token_with_trivia::( input, - TokenKind::GreaterThanGreaterThanGreaterThanEqual, + TerminalKind::GreaterThanGreaterThanGreaterThanEqual, ) - .with_label(NodeLabel::Operator); + .with_label(EdgeLabel::Operator); choice.consider(input, result)?; choice.finish(input) }), @@ -1728,72 +1728,72 @@ impl Language { }; let parse_postfix_conditional_expression = |input: &mut ParserContext<'_>| { PrecedenceHelper::to_postfix_operator( - RuleKind::ConditionalExpression, + NonTerminalKind::ConditionalExpression, 3u8, SequenceHelper::run(|mut seq| { seq.elem_labeled( - NodeLabel::QuestionMark, + EdgeLabel::QuestionMark, self.parse_token_with_trivia::( input, - TokenKind::QuestionMark, + TerminalKind::QuestionMark, ), )?; - seq.elem_labeled(NodeLabel::TrueExpression, self.expression(input))?; + seq.elem_labeled(EdgeLabel::TrueExpression, self.expression(input))?; seq.elem_labeled( - NodeLabel::Colon, + EdgeLabel::Colon, self.parse_token_with_trivia::( input, - TokenKind::Colon, + TerminalKind::Colon, ), )?; - seq.elem_labeled(NodeLabel::FalseExpression, self.expression(input))?; + seq.elem_labeled(EdgeLabel::FalseExpression, self.expression(input))?; seq.finish() }), ) }; let parse_left_or_expression = |input: &mut ParserContext<'_>| { PrecedenceHelper::to_binary_operator( - RuleKind::OrExpression, + NonTerminalKind::OrExpression, 5u8, 5u8 + 1, self.parse_token_with_trivia::( input, - TokenKind::BarBar, + TerminalKind::BarBar, ) - .with_label(NodeLabel::Operator), + .with_label(EdgeLabel::Operator), ) }; let parse_left_and_expression = |input: &mut ParserContext<'_>| { PrecedenceHelper::to_binary_operator( - RuleKind::AndExpression, + NonTerminalKind::AndExpression, 7u8, 7u8 + 1, self.parse_token_with_trivia::( input, - TokenKind::AmpersandAmpersand, + TerminalKind::AmpersandAmpersand, ) - .with_label(NodeLabel::Operator), + .with_label(EdgeLabel::Operator), ) }; let parse_left_equality_expression = |input: &mut ParserContext<'_>| { PrecedenceHelper::to_binary_operator( - RuleKind::EqualityExpression, + NonTerminalKind::EqualityExpression, 9u8, 9u8 + 1, ChoiceHelper::run(input, |mut choice, input| { let result = self .parse_token_with_trivia::( input, - TokenKind::EqualEqual, + TerminalKind::EqualEqual, ) - .with_label(NodeLabel::Operator); + .with_label(EdgeLabel::Operator); choice.consider(input, result)?; let result = self .parse_token_with_trivia::( input, - TokenKind::BangEqual, + TerminalKind::BangEqual, ) - .with_label(NodeLabel::Operator); + .with_label(EdgeLabel::Operator); choice.consider(input, result)?; choice.finish(input) }), @@ -1801,37 +1801,37 @@ impl Language { }; let parse_left_comparison_expression = |input: &mut ParserContext<'_>| { PrecedenceHelper::to_binary_operator( - RuleKind::ComparisonExpression, + NonTerminalKind::ComparisonExpression, 11u8, 11u8 + 1, ChoiceHelper::run(input, |mut choice, input| { let result = self .parse_token_with_trivia::( input, - TokenKind::LessThan, + TerminalKind::LessThan, ) - .with_label(NodeLabel::Operator); + .with_label(EdgeLabel::Operator); choice.consider(input, result)?; let result = self .parse_token_with_trivia::( input, - TokenKind::GreaterThan, + TerminalKind::GreaterThan, ) - .with_label(NodeLabel::Operator); + .with_label(EdgeLabel::Operator); choice.consider(input, result)?; let result = self .parse_token_with_trivia::( input, - TokenKind::LessThanEqual, + TerminalKind::LessThanEqual, ) - .with_label(NodeLabel::Operator); + .with_label(EdgeLabel::Operator); choice.consider(input, result)?; let result = self .parse_token_with_trivia::( input, - TokenKind::GreaterThanEqual, + TerminalKind::GreaterThanEqual, ) - .with_label(NodeLabel::Operator); + .with_label(EdgeLabel::Operator); choice.consider(input, result)?; choice.finish(input) }), @@ -1839,63 +1839,66 @@ impl Language { }; let parse_left_bitwise_or_expression = |input: &mut ParserContext<'_>| { PrecedenceHelper::to_binary_operator( - RuleKind::BitwiseOrExpression, + NonTerminalKind::BitwiseOrExpression, 13u8, 13u8 + 1, - self.parse_token_with_trivia::(input, TokenKind::Bar) - .with_label(NodeLabel::Operator), + self.parse_token_with_trivia::( + input, + TerminalKind::Bar, + ) + .with_label(EdgeLabel::Operator), ) }; let parse_left_bitwise_xor_expression = |input: &mut ParserContext<'_>| { PrecedenceHelper::to_binary_operator( - RuleKind::BitwiseXorExpression, + NonTerminalKind::BitwiseXorExpression, 15u8, 15u8 + 1, self.parse_token_with_trivia::( input, - TokenKind::Caret, + TerminalKind::Caret, ) - .with_label(NodeLabel::Operator), + .with_label(EdgeLabel::Operator), ) }; let parse_left_bitwise_and_expression = |input: &mut ParserContext<'_>| { PrecedenceHelper::to_binary_operator( - RuleKind::BitwiseAndExpression, + NonTerminalKind::BitwiseAndExpression, 17u8, 17u8 + 1, self.parse_token_with_trivia::( input, - TokenKind::Ampersand, + TerminalKind::Ampersand, ) - .with_label(NodeLabel::Operator), + .with_label(EdgeLabel::Operator), ) }; let parse_left_shift_expression = |input: &mut ParserContext<'_>| { PrecedenceHelper::to_binary_operator( - RuleKind::ShiftExpression, + NonTerminalKind::ShiftExpression, 19u8, 19u8 + 1, ChoiceHelper::run(input, |mut choice, input| { let result = self .parse_token_with_trivia::( input, - TokenKind::LessThanLessThan, + TerminalKind::LessThanLessThan, ) - .with_label(NodeLabel::Operator); + .with_label(EdgeLabel::Operator); choice.consider(input, result)?; let result = self .parse_token_with_trivia::( input, - TokenKind::GreaterThanGreaterThan, + TerminalKind::GreaterThanGreaterThan, ) - .with_label(NodeLabel::Operator); + .with_label(EdgeLabel::Operator); choice.consider(input, result)?; let result = self .parse_token_with_trivia::( input, - TokenKind::GreaterThanGreaterThanGreaterThan, + TerminalKind::GreaterThanGreaterThanGreaterThan, ) - .with_label(NodeLabel::Operator); + .with_label(EdgeLabel::Operator); choice.consider(input, result)?; choice.finish(input) }), @@ -1903,23 +1906,23 @@ impl Language { }; let parse_left_additive_expression = |input: &mut ParserContext<'_>| { PrecedenceHelper::to_binary_operator( - RuleKind::AdditiveExpression, + NonTerminalKind::AdditiveExpression, 21u8, 21u8 + 1, ChoiceHelper::run(input, |mut choice, input| { let result = self .parse_token_with_trivia::( input, - TokenKind::Plus, + TerminalKind::Plus, ) - .with_label(NodeLabel::Operator); + .with_label(EdgeLabel::Operator); choice.consider(input, result)?; let result = self .parse_token_with_trivia::( input, - TokenKind::Minus, + TerminalKind::Minus, ) - .with_label(NodeLabel::Operator); + .with_label(EdgeLabel::Operator); choice.consider(input, result)?; choice.finish(input) }), @@ -1927,30 +1930,30 @@ impl Language { }; let parse_left_multiplicative_expression = |input: &mut ParserContext<'_>| { PrecedenceHelper::to_binary_operator( - RuleKind::MultiplicativeExpression, + NonTerminalKind::MultiplicativeExpression, 23u8, 23u8 + 1, ChoiceHelper::run(input, |mut choice, input| { let result = self .parse_token_with_trivia::( input, - TokenKind::Asterisk, + TerminalKind::Asterisk, ) - .with_label(NodeLabel::Operator); + .with_label(EdgeLabel::Operator); choice.consider(input, result)?; let result = self .parse_token_with_trivia::( input, - TokenKind::Slash, + TerminalKind::Slash, ) - .with_label(NodeLabel::Operator); + .with_label(EdgeLabel::Operator); choice.consider(input, result)?; let result = self .parse_token_with_trivia::( input, - TokenKind::Percent, + TerminalKind::Percent, ) - .with_label(NodeLabel::Operator); + .with_label(EdgeLabel::Operator); choice.consider(input, result)?; choice.finish(input) }), @@ -1958,7 +1961,7 @@ impl Language { }; let parse_left_exponentiation_expression = |input: &mut ParserContext<'_>| { PrecedenceHelper::to_binary_operator( - RuleKind::ExponentiationExpression, + NonTerminalKind::ExponentiationExpression, 25u8, 25u8 + 1, ChoiceHelper::run(input, |mut choice, input| { @@ -1966,9 +1969,9 @@ impl Language { let result = self .parse_token_with_trivia::( input, - TokenKind::AsteriskAsterisk, + TerminalKind::AsteriskAsterisk, ) - .with_label(NodeLabel::Operator); + .with_label(EdgeLabel::Operator); choice.consider(input, result)?; } choice.finish(input) @@ -1977,7 +1980,7 @@ impl Language { }; let parse_right_exponentiation_expression = |input: &mut ParserContext<'_>| { PrecedenceHelper::to_binary_operator( - RuleKind::ExponentiationExpression, + NonTerminalKind::ExponentiationExpression, 27u8 + 1, 27u8, ChoiceHelper::run(input, |mut choice, input| { @@ -1985,9 +1988,9 @@ impl Language { let result = self .parse_token_with_trivia::( input, - TokenKind::AsteriskAsterisk, + TerminalKind::AsteriskAsterisk, ) - .with_label(NodeLabel::Operator); + .with_label(EdgeLabel::Operator); choice.consider(input, result)?; } choice.finish(input) @@ -1996,22 +1999,22 @@ impl Language { }; let parse_postfix_postfix_expression = |input: &mut ParserContext<'_>| { PrecedenceHelper::to_postfix_operator( - RuleKind::PostfixExpression, + NonTerminalKind::PostfixExpression, 29u8, ChoiceHelper::run(input, |mut choice, input| { let result = self .parse_token_with_trivia::( input, - TokenKind::PlusPlus, + TerminalKind::PlusPlus, ) - .with_label(NodeLabel::Operator); + .with_label(EdgeLabel::Operator); choice.consider(input, result)?; let result = self .parse_token_with_trivia::( input, - TokenKind::MinusMinus, + TerminalKind::MinusMinus, ) - .with_label(NodeLabel::Operator); + .with_label(EdgeLabel::Operator); choice.consider(input, result)?; choice.finish(input) }), @@ -2019,59 +2022,59 @@ impl Language { }; let parse_prefix_prefix_expression = |input: &mut ParserContext<'_>| { PrecedenceHelper::to_prefix_operator( - RuleKind::PrefixExpression, + NonTerminalKind::PrefixExpression, 31u8, ChoiceHelper::run(input, |mut choice, input| { let result = self .parse_token_with_trivia::( input, - TokenKind::PlusPlus, + TerminalKind::PlusPlus, ) - .with_label(NodeLabel::Operator); + .with_label(EdgeLabel::Operator); choice.consider(input, result)?; let result = self .parse_token_with_trivia::( input, - TokenKind::MinusMinus, + TerminalKind::MinusMinus, ) - .with_label(NodeLabel::Operator); + .with_label(EdgeLabel::Operator); choice.consider(input, result)?; let result = self .parse_token_with_trivia::( input, - TokenKind::Tilde, + TerminalKind::Tilde, ) - .with_label(NodeLabel::Operator); + .with_label(EdgeLabel::Operator); choice.consider(input, result)?; let result = self .parse_token_with_trivia::( input, - TokenKind::Bang, + TerminalKind::Bang, ) - .with_label(NodeLabel::Operator); + .with_label(EdgeLabel::Operator); choice.consider(input, result)?; let result = self .parse_token_with_trivia::( input, - TokenKind::Minus, + TerminalKind::Minus, ) - .with_label(NodeLabel::Operator); + .with_label(EdgeLabel::Operator); choice.consider(input, result)?; if !self.version_is_at_least_0_5_0 { let result = self .parse_token_with_trivia::( input, - TokenKind::Plus, + TerminalKind::Plus, ) - .with_label(NodeLabel::Operator); + .with_label(EdgeLabel::Operator); choice.consider(input, result)?; } let result = self .parse_token_with_trivia::( input, - TokenKind::DeleteKeyword, + TerminalKind::DeleteKeyword, ) - .with_label(NodeLabel::Operator); + .with_label(EdgeLabel::Operator); choice.consider(input, result)?; choice.finish(input) }), @@ -2079,34 +2082,34 @@ impl Language { }; let parse_postfix_function_call_expression = |input: &mut ParserContext<'_>| { PrecedenceHelper::to_postfix_operator( - RuleKind::FunctionCallExpression, + NonTerminalKind::FunctionCallExpression, 33u8, self.arguments_declaration(input) - .with_label(NodeLabel::Arguments), + .with_label(EdgeLabel::Arguments), ) }; let parse_postfix_call_options_expression = |input: &mut ParserContext<'_>| { PrecedenceHelper::to_postfix_operator( - RuleKind::CallOptionsExpression, + NonTerminalKind::CallOptionsExpression, 35u8, ChoiceHelper::run(input, |mut choice, input| { if self.version_is_at_least_0_6_2 { let result = SequenceHelper::run(|mut seq| { - let mut delim_guard = input.open_delim(TokenKind::CloseBrace); + let mut delim_guard = input.open_delim(TerminalKind::CloseBrace); let input = delim_guard.ctx(); seq.elem_labeled( - NodeLabel::OpenBrace, + EdgeLabel::OpenBrace, self.parse_token_with_trivia::( input, - TokenKind::OpenBrace, + TerminalKind::OpenBrace, ), )?; - seq . elem (self . call_options (input) . with_label (NodeLabel :: Options) . recover_until_with_nested_delims :: < _ , LexicalContextType :: Default > (input , self , TokenKind :: CloseBrace , TokenAcceptanceThreshold (2u8) ,)) ? ; + seq . elem (self . call_options (input) . with_label (EdgeLabel :: Options) . recover_until_with_nested_delims :: < _ , LexicalContextType :: Default > (input , self , TerminalKind :: CloseBrace , TokenAcceptanceThreshold (2u8) ,)) ? ; seq.elem_labeled( - NodeLabel::CloseBrace, + EdgeLabel::CloseBrace, self.parse_token_with_trivia::( input, - TokenKind::CloseBrace, + TerminalKind::CloseBrace, ), )?; seq.finish() @@ -2119,43 +2122,43 @@ impl Language { }; let parse_postfix_member_access_expression = |input: &mut ParserContext<'_>| { PrecedenceHelper::to_postfix_operator( - RuleKind::MemberAccessExpression, + NonTerminalKind::MemberAccessExpression, 37u8, SequenceHelper::run(|mut seq| { seq.elem_labeled( - NodeLabel::Period, + EdgeLabel::Period, self.parse_token_with_trivia::( input, - TokenKind::Period, + TerminalKind::Period, ), )?; - seq.elem_labeled(NodeLabel::Member, self.member_access(input))?; + seq.elem_labeled(EdgeLabel::Member, self.member_access(input))?; seq.finish() }), ) }; let parse_postfix_index_access_expression = |input: &mut ParserContext<'_>| { PrecedenceHelper::to_postfix_operator( - RuleKind::IndexAccessExpression, + NonTerminalKind::IndexAccessExpression, 39u8, SequenceHelper::run(|mut seq| { - let mut delim_guard = input.open_delim(TokenKind::CloseBracket); + let mut delim_guard = input.open_delim(TerminalKind::CloseBracket); let input = delim_guard.ctx(); seq.elem_labeled( - NodeLabel::OpenBracket, + EdgeLabel::OpenBracket, self.parse_token_with_trivia::( input, - TokenKind::OpenBracket, + TerminalKind::OpenBracket, ), )?; seq.elem( SequenceHelper::run(|mut seq| { seq.elem_labeled( - NodeLabel::Start, + EdgeLabel::Start, OptionalHelper::transform(self.expression(input)), )?; seq.elem_labeled( - NodeLabel::End, + EdgeLabel::End, OptionalHelper::transform(self.index_access_end(input)), )?; seq.finish() @@ -2163,15 +2166,15 @@ impl Language { .recover_until_with_nested_delims::<_, LexicalContextType::Default>( input, self, - TokenKind::CloseBracket, + TerminalKind::CloseBracket, TokenAcceptanceThreshold(0u8), ), )?; seq.elem_labeled( - NodeLabel::CloseBracket, + EdgeLabel::CloseBracket, self.parse_token_with_trivia::( input, - TokenKind::CloseBracket, + TerminalKind::CloseBracket, ), )?; seq.finish() @@ -2208,28 +2211,28 @@ impl Language { if self.version_is_at_least_0_6_0 { let result = self.parse_token_with_trivia::( input, - TokenKind::PayableKeyword, + TerminalKind::PayableKeyword, ); choice.consider(input, result)?; } let result = self.parse_token_with_trivia::( input, - TokenKind::TrueKeyword, + TerminalKind::TrueKeyword, ); choice.consider(input, result)?; let result = self.parse_token_with_trivia::( input, - TokenKind::FalseKeyword, + TerminalKind::FalseKeyword, ); choice.consider(input, result)?; let result = self.parse_token_with_trivia::( input, - TokenKind::Identifier, + TerminalKind::Identifier, ); choice.consider(input, result)?; choice.finish(input) }) - .with_label(NodeLabel::Variant) + .with_label(EdgeLabel::Variant) }; let postfix_operator_parser = |input: &mut ParserContext<'_>| { ChoiceHelper::run(input, |mut choice, input| { @@ -2301,10 +2304,10 @@ impl Language { }) }; PrecedenceHelper::reduce_precedence_result( - RuleKind::Expression, + NonTerminalKind::Expression, linear_expression_parser(input), ) - .with_kind(RuleKind::Expression) + .with_kind(NonTerminalKind::Expression) } #[allow(unused_assignments, unused_parens)] @@ -2312,24 +2315,24 @@ impl Language { SequenceHelper::run(|mut seq| { seq.elem( self.expression(input) - .with_label(NodeLabel::Expression) + .with_label(EdgeLabel::Expression) .recover_until_with_nested_delims::<_, LexicalContextType::Default>( input, self, - TokenKind::Semicolon, + TerminalKind::Semicolon, TokenAcceptanceThreshold(1u8), ), )?; seq.elem_labeled( - NodeLabel::Semicolon, + EdgeLabel::Semicolon, self.parse_token_with_trivia::( input, - TokenKind::Semicolon, + TerminalKind::Semicolon, ), )?; seq.finish() }) - .with_kind(RuleKind::ExpressionStatement) + .with_kind(NonTerminalKind::ExpressionStatement) } #[allow(unused_assignments, unused_parens)] @@ -2342,36 +2345,36 @@ impl Language { choice.consider(input, result)?; let result = self.parse_token_with_trivia::( input, - TokenKind::ExternalKeyword, + TerminalKind::ExternalKeyword, ); choice.consider(input, result)?; let result = self.parse_token_with_trivia::( input, - TokenKind::PayableKeyword, + TerminalKind::PayableKeyword, ); choice.consider(input, result)?; let result = self.parse_token_with_trivia::( input, - TokenKind::PureKeyword, + TerminalKind::PureKeyword, ); choice.consider(input, result)?; let result = self.parse_token_with_trivia::( input, - TokenKind::ViewKeyword, + TerminalKind::ViewKeyword, ); choice.consider(input, result)?; let result = self.parse_token_with_trivia::( input, - TokenKind::VirtualKeyword, + TerminalKind::VirtualKeyword, ); choice.consider(input, result)?; choice.finish(input) }) - .with_label(NodeLabel::Variant) + .with_label(EdgeLabel::Variant) } else { ParserResult::disabled() } - .with_kind(RuleKind::FallbackFunctionAttribute) + .with_kind(NonTerminalKind::FallbackFunctionAttribute) } #[allow(unused_assignments, unused_parens)] @@ -2379,12 +2382,12 @@ impl Language { if self.version_is_at_least_0_6_0 { ZeroOrMoreHelper::run(input, |input| { self.fallback_function_attribute(input) - .with_label(NodeLabel::Item) + .with_label(EdgeLabel::Item) }) } else { ParserResult::disabled() } - .with_kind(RuleKind::FallbackFunctionAttributes) + .with_kind(NonTerminalKind::FallbackFunctionAttributes) } #[allow(unused_assignments, unused_parens)] @@ -2392,62 +2395,62 @@ impl Language { if self.version_is_at_least_0_6_0 { SequenceHelper::run(|mut seq| { seq.elem_labeled( - NodeLabel::FallbackKeyword, + EdgeLabel::FallbackKeyword, self.parse_token_with_trivia::( input, - TokenKind::FallbackKeyword, + TerminalKind::FallbackKeyword, ), )?; - seq.elem_labeled(NodeLabel::Parameters, self.parameters_declaration(input))?; + seq.elem_labeled(EdgeLabel::Parameters, self.parameters_declaration(input))?; seq.elem_labeled( - NodeLabel::Attributes, + EdgeLabel::Attributes, self.fallback_function_attributes(input), )?; seq.elem_labeled( - NodeLabel::Returns, + EdgeLabel::Returns, OptionalHelper::transform(self.returns_declaration(input)), )?; - seq.elem_labeled(NodeLabel::Body, self.function_body(input))?; + seq.elem_labeled(EdgeLabel::Body, self.function_body(input))?; seq.finish() }) } else { ParserResult::disabled() } - .with_kind(RuleKind::FallbackFunctionDefinition) + .with_kind(NonTerminalKind::FallbackFunctionDefinition) } #[allow(unused_assignments, unused_parens)] fn for_statement(&self, input: &mut ParserContext<'_>) -> ParserResult { SequenceHelper::run(|mut seq| { seq.elem_labeled( - NodeLabel::ForKeyword, + EdgeLabel::ForKeyword, self.parse_token_with_trivia::( input, - TokenKind::ForKeyword, + TerminalKind::ForKeyword, ), )?; seq.elem(SequenceHelper::run(|mut seq| { - let mut delim_guard = input.open_delim(TokenKind::CloseParen); + let mut delim_guard = input.open_delim(TerminalKind::CloseParen); let input = delim_guard.ctx(); seq.elem_labeled( - NodeLabel::OpenParen, + EdgeLabel::OpenParen, self.parse_token_with_trivia::( input, - TokenKind::OpenParen, + TerminalKind::OpenParen, ), )?; seq.elem( SequenceHelper::run(|mut seq| { seq.elem_labeled( - NodeLabel::Initialization, + EdgeLabel::Initialization, self.for_statement_initialization(input), )?; seq.elem_labeled( - NodeLabel::Condition, + EdgeLabel::Condition, self.for_statement_condition(input), )?; seq.elem_labeled( - NodeLabel::Iterator, + EdgeLabel::Iterator, OptionalHelper::transform(self.expression(input)), )?; seq.finish() @@ -2455,23 +2458,23 @@ impl Language { .recover_until_with_nested_delims::<_, LexicalContextType::Default>( input, self, - TokenKind::CloseParen, + TerminalKind::CloseParen, TokenAcceptanceThreshold(0u8), ), )?; seq.elem_labeled( - NodeLabel::CloseParen, + EdgeLabel::CloseParen, self.parse_token_with_trivia::( input, - TokenKind::CloseParen, + TerminalKind::CloseParen, ), )?; seq.finish() }))?; - seq.elem_labeled(NodeLabel::Body, self.statement(input))?; + seq.elem_labeled(EdgeLabel::Body, self.statement(input))?; seq.finish() }) - .with_kind(RuleKind::ForStatement) + .with_kind(NonTerminalKind::ForStatement) } #[allow(unused_assignments, unused_parens)] @@ -2481,13 +2484,13 @@ impl Language { choice.consider(input, result)?; let result = self.parse_token_with_trivia::( input, - TokenKind::Semicolon, + TerminalKind::Semicolon, ); choice.consider(input, result)?; choice.finish(input) }) - .with_label(NodeLabel::Variant) - .with_kind(RuleKind::ForStatementCondition) + .with_label(EdgeLabel::Variant) + .with_kind(NonTerminalKind::ForStatementCondition) } #[allow(unused_assignments, unused_parens)] @@ -2501,13 +2504,13 @@ impl Language { choice.consider(input, result)?; let result = self.parse_token_with_trivia::( input, - TokenKind::Semicolon, + TerminalKind::Semicolon, ); choice.consider(input, result)?; choice.finish(input) }) - .with_label(NodeLabel::Variant) - .with_kind(RuleKind::ForStatementInitialization) + .with_label(EdgeLabel::Variant) + .with_kind(NonTerminalKind::ForStatementInitialization) } #[allow(unused_assignments, unused_parens)] @@ -2522,68 +2525,68 @@ impl Language { if !self.version_is_at_least_0_5_0 { let result = self.parse_token_with_trivia::( input, - TokenKind::ConstantKeyword, + TerminalKind::ConstantKeyword, ); choice.consider(input, result)?; } let result = self.parse_token_with_trivia::( input, - TokenKind::ExternalKeyword, + TerminalKind::ExternalKeyword, ); choice.consider(input, result)?; let result = self.parse_token_with_trivia::( input, - TokenKind::InternalKeyword, + TerminalKind::InternalKeyword, ); choice.consider(input, result)?; let result = self.parse_token_with_trivia::( input, - TokenKind::PayableKeyword, + TerminalKind::PayableKeyword, ); choice.consider(input, result)?; let result = self.parse_token_with_trivia::( input, - TokenKind::PrivateKeyword, + TerminalKind::PrivateKeyword, ); choice.consider(input, result)?; let result = self.parse_token_with_trivia::( input, - TokenKind::PublicKeyword, + TerminalKind::PublicKeyword, ); choice.consider(input, result)?; if self.version_is_at_least_0_4_16 { let result = self.parse_token_with_trivia::( input, - TokenKind::PureKeyword, + TerminalKind::PureKeyword, ); choice.consider(input, result)?; } if self.version_is_at_least_0_4_16 { let result = self.parse_token_with_trivia::( input, - TokenKind::ViewKeyword, + TerminalKind::ViewKeyword, ); choice.consider(input, result)?; } if self.version_is_at_least_0_6_0 { let result = self.parse_token_with_trivia::( input, - TokenKind::VirtualKeyword, + TerminalKind::VirtualKeyword, ); choice.consider(input, result)?; } choice.finish(input) }) - .with_label(NodeLabel::Variant) - .with_kind(RuleKind::FunctionAttribute) + .with_label(EdgeLabel::Variant) + .with_kind(NonTerminalKind::FunctionAttribute) } #[allow(unused_assignments, unused_parens)] fn function_attributes(&self, input: &mut ParserContext<'_>) -> ParserResult { ZeroOrMoreHelper::run(input, |input| { - self.function_attribute(input).with_label(NodeLabel::Item) + self.function_attribute(input).with_label(EdgeLabel::Item) }) - .with_kind(RuleKind::FunctionAttributes) + .with_kind(NonTerminalKind::FunctionAttributes) } #[allow(unused_assignments, unused_parens)] @@ -2593,13 +2596,13 @@ impl Language { choice.consider(input, result)?; let result = self.parse_token_with_trivia::( input, - TokenKind::Semicolon, + TerminalKind::Semicolon, ); choice.consider(input, result)?; choice.finish(input) }) - .with_label(NodeLabel::Variant) - .with_kind(RuleKind::FunctionBody) + .with_label(EdgeLabel::Variant) + .with_kind(NonTerminalKind::FunctionBody) } #[allow(unused_assignments, unused_parens)] @@ -2609,14 +2612,14 @@ impl Language { return result; }; match &r#match.nodes[..] { - [cst::LabeledNode { - label: _, - node: cst::Node::Rule(node), - }] if node.kind == RuleKind::Expression => match &node.children[..] { - [inner @ cst::LabeledNode { - label: _, - node: cst::Node::Rule(rule), - }] if rule.kind == RuleKind::FunctionCallExpression => { + [cst::Edge { + node: cst::Node::NonTerminal(node), + .. + }] if node.kind == NonTerminalKind::Expression => match &node.children[..] { + [inner @ cst::Edge { + node: cst::Node::NonTerminal(node), + .. + }] if node.kind == NonTerminalKind::FunctionCallExpression => { ParserResult::r#match(vec![inner.clone()], r#match.expected_tokens.clone()) } _ => ParserResult::no_match(vec![]), @@ -2629,23 +2632,23 @@ impl Language { fn function_definition(&self, input: &mut ParserContext<'_>) -> ParserResult { SequenceHelper::run(|mut seq| { seq.elem_labeled( - NodeLabel::FunctionKeyword, + EdgeLabel::FunctionKeyword, self.parse_token_with_trivia::( input, - TokenKind::FunctionKeyword, + TerminalKind::FunctionKeyword, ), )?; - seq.elem_labeled(NodeLabel::Name, self.function_name(input))?; - seq.elem_labeled(NodeLabel::Parameters, self.parameters_declaration(input))?; - seq.elem_labeled(NodeLabel::Attributes, self.function_attributes(input))?; + seq.elem_labeled(EdgeLabel::Name, self.function_name(input))?; + seq.elem_labeled(EdgeLabel::Parameters, self.parameters_declaration(input))?; + seq.elem_labeled(EdgeLabel::Attributes, self.function_attributes(input))?; seq.elem_labeled( - NodeLabel::Returns, + EdgeLabel::Returns, OptionalHelper::transform(self.returns_declaration(input)), )?; - seq.elem_labeled(NodeLabel::Body, self.function_body(input))?; + seq.elem_labeled(EdgeLabel::Body, self.function_body(input))?; seq.finish() }) - .with_kind(RuleKind::FunctionDefinition) + .with_kind(NonTerminalKind::FunctionDefinition) } #[allow(unused_assignments, unused_parens)] @@ -2653,44 +2656,44 @@ impl Language { ChoiceHelper::run(input, |mut choice, input| { let result = self.parse_token_with_trivia::( input, - TokenKind::Identifier, + TerminalKind::Identifier, ); choice.consider(input, result)?; let result = self.parse_token_with_trivia::( input, - TokenKind::FallbackKeyword, + TerminalKind::FallbackKeyword, ); choice.consider(input, result)?; let result = self.parse_token_with_trivia::( input, - TokenKind::ReceiveKeyword, + TerminalKind::ReceiveKeyword, ); choice.consider(input, result)?; choice.finish(input) }) - .with_label(NodeLabel::Variant) - .with_kind(RuleKind::FunctionName) + .with_label(EdgeLabel::Variant) + .with_kind(NonTerminalKind::FunctionName) } #[allow(unused_assignments, unused_parens)] fn function_type(&self, input: &mut ParserContext<'_>) -> ParserResult { SequenceHelper::run(|mut seq| { seq.elem_labeled( - NodeLabel::FunctionKeyword, + EdgeLabel::FunctionKeyword, self.parse_token_with_trivia::( input, - TokenKind::FunctionKeyword, + TerminalKind::FunctionKeyword, ), )?; - seq.elem_labeled(NodeLabel::Parameters, self.parameters_declaration(input))?; - seq.elem_labeled(NodeLabel::Attributes, self.function_type_attributes(input))?; + seq.elem_labeled(EdgeLabel::Parameters, self.parameters_declaration(input))?; + seq.elem_labeled(EdgeLabel::Attributes, self.function_type_attributes(input))?; seq.elem_labeled( - NodeLabel::Returns, + EdgeLabel::Returns, OptionalHelper::transform(self.returns_declaration(input)), )?; seq.finish() }) - .with_kind(RuleKind::FunctionType) + .with_kind(NonTerminalKind::FunctionType) } #[allow(unused_assignments, unused_parens)] @@ -2698,84 +2701,84 @@ impl Language { ChoiceHelper::run(input, |mut choice, input| { let result = self.parse_token_with_trivia::( input, - TokenKind::InternalKeyword, + TerminalKind::InternalKeyword, ); choice.consider(input, result)?; let result = self.parse_token_with_trivia::( input, - TokenKind::ExternalKeyword, + TerminalKind::ExternalKeyword, ); choice.consider(input, result)?; let result = self.parse_token_with_trivia::( input, - TokenKind::PrivateKeyword, + TerminalKind::PrivateKeyword, ); choice.consider(input, result)?; let result = self.parse_token_with_trivia::( input, - TokenKind::PublicKeyword, + TerminalKind::PublicKeyword, ); choice.consider(input, result)?; if !self.version_is_at_least_0_5_0 { let result = self.parse_token_with_trivia::( input, - TokenKind::ConstantKeyword, + TerminalKind::ConstantKeyword, ); choice.consider(input, result)?; } if self.version_is_at_least_0_4_16 { let result = self.parse_token_with_trivia::( input, - TokenKind::PureKeyword, + TerminalKind::PureKeyword, ); choice.consider(input, result)?; } if self.version_is_at_least_0_4_16 { let result = self.parse_token_with_trivia::( input, - TokenKind::ViewKeyword, + TerminalKind::ViewKeyword, ); choice.consider(input, result)?; } let result = self.parse_token_with_trivia::( input, - TokenKind::PayableKeyword, + TerminalKind::PayableKeyword, ); choice.consider(input, result)?; choice.finish(input) }) - .with_label(NodeLabel::Variant) - .with_kind(RuleKind::FunctionTypeAttribute) + .with_label(EdgeLabel::Variant) + .with_kind(NonTerminalKind::FunctionTypeAttribute) } #[allow(unused_assignments, unused_parens)] fn function_type_attributes(&self, input: &mut ParserContext<'_>) -> ParserResult { ZeroOrMoreHelper::run(input, |input| { self.function_type_attribute(input) - .with_label(NodeLabel::Item) + .with_label(EdgeLabel::Item) }) - .with_kind(RuleKind::FunctionTypeAttributes) + .with_kind(NonTerminalKind::FunctionTypeAttributes) } #[allow(unused_assignments, unused_parens)] fn hex_number_expression(&self, input: &mut ParserContext<'_>) -> ParserResult { SequenceHelper::run(|mut seq| { seq.elem_labeled( - NodeLabel::Literal, + EdgeLabel::Literal, self.parse_token_with_trivia::( input, - TokenKind::HexLiteral, + TerminalKind::HexLiteral, ), )?; if !self.version_is_at_least_0_5_0 { seq.elem_labeled( - NodeLabel::Unit, + EdgeLabel::Unit, OptionalHelper::transform(self.number_unit(input)), )?; } seq.finish() }) - .with_kind(RuleKind::HexNumberExpression) + .with_kind(NonTerminalKind::HexNumberExpression) } #[allow(unused_assignments, unused_parens)] @@ -2783,30 +2786,30 @@ impl Language { ChoiceHelper::run(input, |mut choice, input| { let result = self.parse_token_with_trivia::( input, - TokenKind::SingleQuotedHexStringLiteral, + TerminalKind::SingleQuotedHexStringLiteral, ); choice.consider(input, result)?; let result = self.parse_token_with_trivia::( input, - TokenKind::DoubleQuotedHexStringLiteral, + TerminalKind::DoubleQuotedHexStringLiteral, ); choice.consider(input, result)?; choice.finish(input) }) - .with_label(NodeLabel::Variant) - .with_kind(RuleKind::HexStringLiteral) + .with_label(EdgeLabel::Variant) + .with_kind(NonTerminalKind::HexStringLiteral) } #[allow(unused_assignments, unused_parens)] fn hex_string_literals(&self, input: &mut ParserContext<'_>) -> ParserResult { if self.version_is_at_least_0_5_14 { OneOrMoreHelper::run(input, |input| { - self.hex_string_literal(input).with_label(NodeLabel::Item) + self.hex_string_literal(input).with_label(EdgeLabel::Item) }) } else { ParserResult::disabled() } - .with_kind(RuleKind::HexStringLiterals) + .with_kind(NonTerminalKind::HexStringLiterals) } #[allow(unused_assignments, unused_parens)] @@ -2817,85 +2820,85 @@ impl Language { |input| { self.parse_token_with_trivia::( input, - TokenKind::Identifier, + TerminalKind::Identifier, ) - .with_label(NodeLabel::Item) + .with_label(EdgeLabel::Item) }, - TokenKind::Period, - NodeLabel::Separator, + TerminalKind::Period, + EdgeLabel::Separator, ) - .with_kind(RuleKind::IdentifierPath) + .with_kind(NonTerminalKind::IdentifierPath) } #[allow(unused_assignments, unused_parens)] fn if_statement(&self, input: &mut ParserContext<'_>) -> ParserResult { SequenceHelper::run(|mut seq| { seq.elem_labeled( - NodeLabel::IfKeyword, + EdgeLabel::IfKeyword, self.parse_token_with_trivia::( input, - TokenKind::IfKeyword, + TerminalKind::IfKeyword, ), )?; seq.elem(SequenceHelper::run(|mut seq| { - let mut delim_guard = input.open_delim(TokenKind::CloseParen); + let mut delim_guard = input.open_delim(TerminalKind::CloseParen); let input = delim_guard.ctx(); seq.elem_labeled( - NodeLabel::OpenParen, + EdgeLabel::OpenParen, self.parse_token_with_trivia::( input, - TokenKind::OpenParen, + TerminalKind::OpenParen, ), )?; seq.elem( self.expression(input) - .with_label(NodeLabel::Condition) + .with_label(EdgeLabel::Condition) .recover_until_with_nested_delims::<_, LexicalContextType::Default>( input, self, - TokenKind::CloseParen, + TerminalKind::CloseParen, TokenAcceptanceThreshold(0u8), ), )?; seq.elem_labeled( - NodeLabel::CloseParen, + EdgeLabel::CloseParen, self.parse_token_with_trivia::( input, - TokenKind::CloseParen, + TerminalKind::CloseParen, ), )?; seq.finish() }))?; - seq.elem_labeled(NodeLabel::Body, self.statement(input))?; + seq.elem_labeled(EdgeLabel::Body, self.statement(input))?; seq.elem_labeled( - NodeLabel::ElseBranch, + EdgeLabel::ElseBranch, OptionalHelper::transform(self.else_branch(input)), )?; seq.finish() }) - .with_kind(RuleKind::IfStatement) + .with_kind(NonTerminalKind::IfStatement) } #[allow(unused_assignments, unused_parens)] fn import_alias(&self, input: &mut ParserContext<'_>) -> ParserResult { SequenceHelper::run(|mut seq| { seq.elem_labeled( - NodeLabel::AsKeyword, + EdgeLabel::AsKeyword, self.parse_token_with_trivia::( input, - TokenKind::AsKeyword, + TerminalKind::AsKeyword, ), )?; seq.elem_labeled( - NodeLabel::Identifier, + EdgeLabel::Identifier, self.parse_token_with_trivia::( input, - TokenKind::Identifier, + TerminalKind::Identifier, ), )?; seq.finish() }) - .with_kind(RuleKind::ImportAlias) + .with_kind(NonTerminalKind::ImportAlias) } #[allow(unused_assignments, unused_parens)] @@ -2909,72 +2912,72 @@ impl Language { choice.consider(input, result)?; choice.finish(input) }) - .with_label(NodeLabel::Variant) - .with_kind(RuleKind::ImportClause) + .with_label(EdgeLabel::Variant) + .with_kind(NonTerminalKind::ImportClause) } #[allow(unused_assignments, unused_parens)] fn import_deconstruction(&self, input: &mut ParserContext<'_>) -> ParserResult { SequenceHelper::run(|mut seq| { seq.elem(SequenceHelper::run(|mut seq| { - let mut delim_guard = input.open_delim(TokenKind::CloseBrace); + let mut delim_guard = input.open_delim(TerminalKind::CloseBrace); let input = delim_guard.ctx(); seq.elem_labeled( - NodeLabel::OpenBrace, + EdgeLabel::OpenBrace, self.parse_token_with_trivia::( input, - TokenKind::OpenBrace, + TerminalKind::OpenBrace, ), )?; seq.elem( self.import_deconstruction_symbols(input) - .with_label(NodeLabel::Symbols) + .with_label(EdgeLabel::Symbols) .recover_until_with_nested_delims::<_, LexicalContextType::Default>( input, self, - TokenKind::CloseBrace, + TerminalKind::CloseBrace, TokenAcceptanceThreshold(0u8), ), )?; seq.elem_labeled( - NodeLabel::CloseBrace, + EdgeLabel::CloseBrace, self.parse_token_with_trivia::( input, - TokenKind::CloseBrace, + TerminalKind::CloseBrace, ), )?; seq.finish() }))?; seq.elem_labeled( - NodeLabel::FromKeyword, + EdgeLabel::FromKeyword, self.parse_token_with_trivia::( input, - TokenKind::FromKeyword, + TerminalKind::FromKeyword, ), )?; - seq.elem_labeled(NodeLabel::Path, self.string_literal(input))?; + seq.elem_labeled(EdgeLabel::Path, self.string_literal(input))?; seq.finish() }) - .with_kind(RuleKind::ImportDeconstruction) + .with_kind(NonTerminalKind::ImportDeconstruction) } #[allow(unused_assignments, unused_parens)] fn import_deconstruction_symbol(&self, input: &mut ParserContext<'_>) -> ParserResult { SequenceHelper::run(|mut seq| { seq.elem_labeled( - NodeLabel::Name, + EdgeLabel::Name, self.parse_token_with_trivia::( input, - TokenKind::Identifier, + TerminalKind::Identifier, ), )?; seq.elem_labeled( - NodeLabel::Alias, + EdgeLabel::Alias, OptionalHelper::transform(self.import_alias(input)), )?; seq.finish() }) - .with_kind(RuleKind::ImportDeconstructionSymbol) + .with_kind(NonTerminalKind::ImportDeconstructionSymbol) } #[allow(unused_assignments, unused_parens)] @@ -2984,12 +2987,12 @@ impl Language { self, |input| { self.import_deconstruction_symbol(input) - .with_label(NodeLabel::Item) + .with_label(EdgeLabel::Item) }, - TokenKind::Comma, - NodeLabel::Separator, + TerminalKind::Comma, + EdgeLabel::Separator, ) - .with_kind(RuleKind::ImportDeconstructionSymbols) + .with_kind(NonTerminalKind::ImportDeconstructionSymbols) } #[allow(unused_assignments, unused_parens)] @@ -2998,51 +3001,51 @@ impl Language { seq.elem( SequenceHelper::run(|mut seq| { seq.elem_labeled( - NodeLabel::ImportKeyword, + EdgeLabel::ImportKeyword, self.parse_token_with_trivia::( input, - TokenKind::ImportKeyword, + TerminalKind::ImportKeyword, ), )?; - seq.elem_labeled(NodeLabel::Clause, self.import_clause(input))?; + seq.elem_labeled(EdgeLabel::Clause, self.import_clause(input))?; seq.finish() }) .recover_until_with_nested_delims::<_, LexicalContextType::Default>( input, self, - TokenKind::Semicolon, + TerminalKind::Semicolon, TokenAcceptanceThreshold(1u8), ), )?; seq.elem_labeled( - NodeLabel::Semicolon, + EdgeLabel::Semicolon, self.parse_token_with_trivia::( input, - TokenKind::Semicolon, + TerminalKind::Semicolon, ), )?; seq.finish() }) - .with_kind(RuleKind::ImportDirective) + .with_kind(NonTerminalKind::ImportDirective) } #[allow(unused_assignments, unused_parens)] fn index_access_end(&self, input: &mut ParserContext<'_>) -> ParserResult { SequenceHelper::run(|mut seq| { seq.elem_labeled( - NodeLabel::Colon, + EdgeLabel::Colon, self.parse_token_with_trivia::( input, - TokenKind::Colon, + TerminalKind::Colon, ), )?; seq.elem_labeled( - NodeLabel::End, + EdgeLabel::End, OptionalHelper::transform(self.expression(input)), )?; seq.finish() }) - .with_kind(RuleKind::IndexAccessEnd) + .with_kind(NonTerminalKind::IndexAccessEnd) } #[allow(unused_assignments, unused_parens)] @@ -3052,14 +3055,14 @@ impl Language { return result; }; match &r#match.nodes[..] { - [cst::LabeledNode { - label: _, - node: cst::Node::Rule(node), - }] if node.kind == RuleKind::Expression => match &node.children[..] { - [inner @ cst::LabeledNode { - label: _, - node: cst::Node::Rule(rule), - }] if rule.kind == RuleKind::IndexAccessExpression => { + [cst::Edge { + node: cst::Node::NonTerminal(node), + .. + }] if node.kind == NonTerminalKind::Expression => match &node.children[..] { + [inner @ cst::Edge { + node: cst::Node::NonTerminal(node), + .. + }] if node.kind == NonTerminalKind::IndexAccessExpression => { ParserResult::r#match(vec![inner.clone()], r#match.expected_tokens.clone()) } _ => ParserResult::no_match(vec![]), @@ -3072,29 +3075,29 @@ impl Language { fn inheritance_specifier(&self, input: &mut ParserContext<'_>) -> ParserResult { SequenceHelper::run(|mut seq| { seq.elem_labeled( - NodeLabel::IsKeyword, + EdgeLabel::IsKeyword, self.parse_token_with_trivia::( input, - TokenKind::IsKeyword, + TerminalKind::IsKeyword, ), )?; - seq.elem_labeled(NodeLabel::Types, self.inheritance_types(input))?; + seq.elem_labeled(EdgeLabel::Types, self.inheritance_types(input))?; seq.finish() }) - .with_kind(RuleKind::InheritanceSpecifier) + .with_kind(NonTerminalKind::InheritanceSpecifier) } #[allow(unused_assignments, unused_parens)] fn inheritance_type(&self, input: &mut ParserContext<'_>) -> ParserResult { SequenceHelper::run(|mut seq| { - seq.elem_labeled(NodeLabel::TypeName, self.identifier_path(input))?; + seq.elem_labeled(EdgeLabel::TypeName, self.identifier_path(input))?; seq.elem_labeled( - NodeLabel::Arguments, + EdgeLabel::Arguments, OptionalHelper::transform(self.arguments_declaration(input)), )?; seq.finish() }) - .with_kind(RuleKind::InheritanceType) + .with_kind(NonTerminalKind::InheritanceType) } #[allow(unused_assignments, unused_parens)] @@ -3102,153 +3105,153 @@ impl Language { SeparatedHelper::run::<_, LexicalContextType::Default>( input, self, - |input| self.inheritance_type(input).with_label(NodeLabel::Item), - TokenKind::Comma, - NodeLabel::Separator, + |input| self.inheritance_type(input).with_label(EdgeLabel::Item), + TerminalKind::Comma, + EdgeLabel::Separator, ) - .with_kind(RuleKind::InheritanceTypes) + .with_kind(NonTerminalKind::InheritanceTypes) } #[allow(unused_assignments, unused_parens)] fn interface_definition(&self, input: &mut ParserContext<'_>) -> ParserResult { SequenceHelper::run(|mut seq| { seq.elem_labeled( - NodeLabel::InterfaceKeyword, + EdgeLabel::InterfaceKeyword, self.parse_token_with_trivia::( input, - TokenKind::InterfaceKeyword, + TerminalKind::InterfaceKeyword, ), )?; seq.elem_labeled( - NodeLabel::Name, + EdgeLabel::Name, self.parse_token_with_trivia::( input, - TokenKind::Identifier, + TerminalKind::Identifier, ), )?; seq.elem_labeled( - NodeLabel::Inheritence, + EdgeLabel::Inheritence, OptionalHelper::transform(self.inheritance_specifier(input)), )?; seq.elem(SequenceHelper::run(|mut seq| { - let mut delim_guard = input.open_delim(TokenKind::CloseBrace); + let mut delim_guard = input.open_delim(TerminalKind::CloseBrace); let input = delim_guard.ctx(); seq.elem_labeled( - NodeLabel::OpenBrace, + EdgeLabel::OpenBrace, self.parse_token_with_trivia::( input, - TokenKind::OpenBrace, + TerminalKind::OpenBrace, ), )?; seq.elem( self.interface_members(input) - .with_label(NodeLabel::Members) + .with_label(EdgeLabel::Members) .recover_until_with_nested_delims::<_, LexicalContextType::Default>( input, self, - TokenKind::CloseBrace, + TerminalKind::CloseBrace, TokenAcceptanceThreshold(0u8), ), )?; seq.elem_labeled( - NodeLabel::CloseBrace, + EdgeLabel::CloseBrace, self.parse_token_with_trivia::( input, - TokenKind::CloseBrace, + TerminalKind::CloseBrace, ), )?; seq.finish() }))?; seq.finish() }) - .with_kind(RuleKind::InterfaceDefinition) + .with_kind(NonTerminalKind::InterfaceDefinition) } #[allow(unused_assignments, unused_parens)] fn interface_members(&self, input: &mut ParserContext<'_>) -> ParserResult { ZeroOrMoreHelper::run(input, |input| { - self.contract_member(input).with_label(NodeLabel::Item) + self.contract_member(input).with_label(EdgeLabel::Item) }) - .with_kind(RuleKind::InterfaceMembers) + .with_kind(NonTerminalKind::InterfaceMembers) } #[allow(unused_assignments, unused_parens)] fn library_definition(&self, input: &mut ParserContext<'_>) -> ParserResult { SequenceHelper::run(|mut seq| { seq.elem_labeled( - NodeLabel::LibraryKeyword, + EdgeLabel::LibraryKeyword, self.parse_token_with_trivia::( input, - TokenKind::LibraryKeyword, + TerminalKind::LibraryKeyword, ), )?; seq.elem_labeled( - NodeLabel::Name, + EdgeLabel::Name, self.parse_token_with_trivia::( input, - TokenKind::Identifier, + TerminalKind::Identifier, ), )?; seq.elem(SequenceHelper::run(|mut seq| { - let mut delim_guard = input.open_delim(TokenKind::CloseBrace); + let mut delim_guard = input.open_delim(TerminalKind::CloseBrace); let input = delim_guard.ctx(); seq.elem_labeled( - NodeLabel::OpenBrace, + EdgeLabel::OpenBrace, self.parse_token_with_trivia::( input, - TokenKind::OpenBrace, + TerminalKind::OpenBrace, ), )?; seq.elem( self.library_members(input) - .with_label(NodeLabel::Members) + .with_label(EdgeLabel::Members) .recover_until_with_nested_delims::<_, LexicalContextType::Default>( input, self, - TokenKind::CloseBrace, + TerminalKind::CloseBrace, TokenAcceptanceThreshold(0u8), ), )?; seq.elem_labeled( - NodeLabel::CloseBrace, + EdgeLabel::CloseBrace, self.parse_token_with_trivia::( input, - TokenKind::CloseBrace, + TerminalKind::CloseBrace, ), )?; seq.finish() }))?; seq.finish() }) - .with_kind(RuleKind::LibraryDefinition) + .with_kind(NonTerminalKind::LibraryDefinition) } #[allow(unused_assignments, unused_parens)] fn library_members(&self, input: &mut ParserContext<'_>) -> ParserResult { ZeroOrMoreHelper::run(input, |input| { - self.contract_member(input).with_label(NodeLabel::Item) + self.contract_member(input).with_label(EdgeLabel::Item) }) - .with_kind(RuleKind::LibraryMembers) + .with_kind(NonTerminalKind::LibraryMembers) } #[allow(unused_assignments, unused_parens)] fn mapping_key(&self, input: &mut ParserContext<'_>) -> ParserResult { SequenceHelper::run(|mut seq| { - seq.elem_labeled(NodeLabel::KeyType, self.mapping_key_type(input))?; + seq.elem_labeled(EdgeLabel::KeyType, self.mapping_key_type(input))?; if self.version_is_at_least_0_8_18 { seq.elem_labeled( - NodeLabel::Name, + EdgeLabel::Name, OptionalHelper::transform( self.parse_token_with_trivia::( input, - TokenKind::Identifier, + TerminalKind::Identifier, ), ), )?; } seq.finish() }) - .with_kind(RuleKind::MappingKey) + .with_kind(NonTerminalKind::MappingKey) } #[allow(unused_assignments, unused_parens)] @@ -3260,82 +3263,82 @@ impl Language { choice.consider(input, result)?; choice.finish(input) }) - .with_label(NodeLabel::Variant) - .with_kind(RuleKind::MappingKeyType) + .with_label(EdgeLabel::Variant) + .with_kind(NonTerminalKind::MappingKeyType) } #[allow(unused_assignments, unused_parens)] fn mapping_type(&self, input: &mut ParserContext<'_>) -> ParserResult { SequenceHelper::run(|mut seq| { seq.elem_labeled( - NodeLabel::MappingKeyword, + EdgeLabel::MappingKeyword, self.parse_token_with_trivia::( input, - TokenKind::MappingKeyword, + TerminalKind::MappingKeyword, ), )?; seq.elem(SequenceHelper::run(|mut seq| { - let mut delim_guard = input.open_delim(TokenKind::CloseParen); + let mut delim_guard = input.open_delim(TerminalKind::CloseParen); let input = delim_guard.ctx(); seq.elem_labeled( - NodeLabel::OpenParen, + EdgeLabel::OpenParen, self.parse_token_with_trivia::( input, - TokenKind::OpenParen, + TerminalKind::OpenParen, ), )?; seq.elem( SequenceHelper::run(|mut seq| { - seq.elem_labeled(NodeLabel::KeyType, self.mapping_key(input))?; + seq.elem_labeled(EdgeLabel::KeyType, self.mapping_key(input))?; seq.elem_labeled( - NodeLabel::EqualGreaterThan, + EdgeLabel::EqualGreaterThan, self.parse_token_with_trivia::( input, - TokenKind::EqualGreaterThan, + TerminalKind::EqualGreaterThan, ), )?; - seq.elem_labeled(NodeLabel::ValueType, self.mapping_value(input))?; + seq.elem_labeled(EdgeLabel::ValueType, self.mapping_value(input))?; seq.finish() }) .recover_until_with_nested_delims::<_, LexicalContextType::Default>( input, self, - TokenKind::CloseParen, + TerminalKind::CloseParen, TokenAcceptanceThreshold(0u8), ), )?; seq.elem_labeled( - NodeLabel::CloseParen, + EdgeLabel::CloseParen, self.parse_token_with_trivia::( input, - TokenKind::CloseParen, + TerminalKind::CloseParen, ), )?; seq.finish() }))?; seq.finish() }) - .with_kind(RuleKind::MappingType) + .with_kind(NonTerminalKind::MappingType) } #[allow(unused_assignments, unused_parens)] fn mapping_value(&self, input: &mut ParserContext<'_>) -> ParserResult { SequenceHelper::run(|mut seq| { - seq.elem_labeled(NodeLabel::TypeName, self.type_name(input))?; + seq.elem_labeled(EdgeLabel::TypeName, self.type_name(input))?; if self.version_is_at_least_0_8_18 { seq.elem_labeled( - NodeLabel::Name, + EdgeLabel::Name, OptionalHelper::transform( self.parse_token_with_trivia::( input, - TokenKind::Identifier, + TerminalKind::Identifier, ), ), )?; } seq.finish() }) - .with_kind(RuleKind::MappingValue) + .with_kind(NonTerminalKind::MappingValue) } #[allow(unused_assignments, unused_parens)] @@ -3343,18 +3346,18 @@ impl Language { ChoiceHelper::run(input, |mut choice, input| { let result = self.parse_token_with_trivia::( input, - TokenKind::Identifier, + TerminalKind::Identifier, ); choice.consider(input, result)?; let result = self.parse_token_with_trivia::( input, - TokenKind::AddressKeyword, + TerminalKind::AddressKeyword, ); choice.consider(input, result)?; choice.finish(input) }) - .with_label(NodeLabel::Variant) - .with_kind(RuleKind::MemberAccess) + .with_label(EdgeLabel::Variant) + .with_kind(NonTerminalKind::MemberAccess) } #[allow(unused_assignments, unused_parens)] @@ -3364,14 +3367,14 @@ impl Language { return result; }; match &r#match.nodes[..] { - [cst::LabeledNode { - label: _, - node: cst::Node::Rule(node), - }] if node.kind == RuleKind::Expression => match &node.children[..] { - [inner @ cst::LabeledNode { - label: _, - node: cst::Node::Rule(rule), - }] if rule.kind == RuleKind::MemberAccessExpression => { + [cst::Edge { + node: cst::Node::NonTerminal(node), + .. + }] if node.kind == NonTerminalKind::Expression => match &node.children[..] { + [inner @ cst::Edge { + node: cst::Node::NonTerminal(node), + .. + }] if node.kind == NonTerminalKind::MemberAccessExpression => { ParserResult::r#match(vec![inner.clone()], r#match.expected_tokens.clone()) } _ => ParserResult::no_match(vec![]), @@ -3390,63 +3393,63 @@ impl Language { if self.version_is_at_least_0_6_0 { let result = self.parse_token_with_trivia::( input, - TokenKind::VirtualKeyword, + TerminalKind::VirtualKeyword, ); choice.consider(input, result)?; } choice.finish(input) }) - .with_label(NodeLabel::Variant) - .with_kind(RuleKind::ModifierAttribute) + .with_label(EdgeLabel::Variant) + .with_kind(NonTerminalKind::ModifierAttribute) } #[allow(unused_assignments, unused_parens)] fn modifier_attributes(&self, input: &mut ParserContext<'_>) -> ParserResult { ZeroOrMoreHelper::run(input, |input| { - self.modifier_attribute(input).with_label(NodeLabel::Item) + self.modifier_attribute(input).with_label(EdgeLabel::Item) }) - .with_kind(RuleKind::ModifierAttributes) + .with_kind(NonTerminalKind::ModifierAttributes) } #[allow(unused_assignments, unused_parens)] fn modifier_definition(&self, input: &mut ParserContext<'_>) -> ParserResult { SequenceHelper::run(|mut seq| { seq.elem_labeled( - NodeLabel::ModifierKeyword, + EdgeLabel::ModifierKeyword, self.parse_token_with_trivia::( input, - TokenKind::ModifierKeyword, + TerminalKind::ModifierKeyword, ), )?; seq.elem_labeled( - NodeLabel::Name, + EdgeLabel::Name, self.parse_token_with_trivia::( input, - TokenKind::Identifier, + TerminalKind::Identifier, ), )?; seq.elem_labeled( - NodeLabel::Parameters, + EdgeLabel::Parameters, OptionalHelper::transform(self.parameters_declaration(input)), )?; - seq.elem_labeled(NodeLabel::Attributes, self.modifier_attributes(input))?; - seq.elem_labeled(NodeLabel::Body, self.function_body(input))?; + seq.elem_labeled(EdgeLabel::Attributes, self.modifier_attributes(input))?; + seq.elem_labeled(EdgeLabel::Body, self.function_body(input))?; seq.finish() }) - .with_kind(RuleKind::ModifierDefinition) + .with_kind(NonTerminalKind::ModifierDefinition) } #[allow(unused_assignments, unused_parens)] fn modifier_invocation(&self, input: &mut ParserContext<'_>) -> ParserResult { SequenceHelper::run(|mut seq| { - seq.elem_labeled(NodeLabel::Name, self.identifier_path(input))?; + seq.elem_labeled(EdgeLabel::Name, self.identifier_path(input))?; seq.elem_labeled( - NodeLabel::Arguments, + EdgeLabel::Arguments, OptionalHelper::transform(self.arguments_declaration(input)), )?; seq.finish() }) - .with_kind(RuleKind::ModifierInvocation) + .with_kind(NonTerminalKind::ModifierInvocation) } #[allow(unused_assignments, unused_parens)] @@ -3456,14 +3459,14 @@ impl Language { return result; }; match &r#match.nodes[..] { - [cst::LabeledNode { - label: _, - node: cst::Node::Rule(node), - }] if node.kind == RuleKind::Expression => match &node.children[..] { - [inner @ cst::LabeledNode { - label: _, - node: cst::Node::Rule(rule), - }] if rule.kind == RuleKind::MultiplicativeExpression => { + [cst::Edge { + node: cst::Node::NonTerminal(node), + .. + }] if node.kind == NonTerminalKind::Expression => match &node.children[..] { + [inner @ cst::Edge { + node: cst::Node::NonTerminal(node), + .. + }] if node.kind == NonTerminalKind::MultiplicativeExpression => { ParserResult::r#match(vec![inner.clone()], r#match.expected_tokens.clone()) } _ => ParserResult::no_match(vec![]), @@ -3476,57 +3479,57 @@ impl Language { fn named_argument(&self, input: &mut ParserContext<'_>) -> ParserResult { SequenceHelper::run(|mut seq| { seq.elem_labeled( - NodeLabel::Name, + EdgeLabel::Name, self.parse_token_with_trivia::( input, - TokenKind::Identifier, + TerminalKind::Identifier, ), )?; seq.elem_labeled( - NodeLabel::Colon, + EdgeLabel::Colon, self.parse_token_with_trivia::( input, - TokenKind::Colon, + TerminalKind::Colon, ), )?; - seq.elem_labeled(NodeLabel::Value, self.expression(input))?; + seq.elem_labeled(EdgeLabel::Value, self.expression(input))?; seq.finish() }) - .with_kind(RuleKind::NamedArgument) + .with_kind(NonTerminalKind::NamedArgument) } #[allow(unused_assignments, unused_parens)] fn named_argument_group(&self, input: &mut ParserContext<'_>) -> ParserResult { SequenceHelper::run(|mut seq| { - let mut delim_guard = input.open_delim(TokenKind::CloseBrace); + let mut delim_guard = input.open_delim(TerminalKind::CloseBrace); let input = delim_guard.ctx(); seq.elem_labeled( - NodeLabel::OpenBrace, + EdgeLabel::OpenBrace, self.parse_token_with_trivia::( input, - TokenKind::OpenBrace, + TerminalKind::OpenBrace, ), )?; seq.elem( self.named_arguments(input) - .with_label(NodeLabel::Arguments) + .with_label(EdgeLabel::Arguments) .recover_until_with_nested_delims::<_, LexicalContextType::Default>( input, self, - TokenKind::CloseBrace, + TerminalKind::CloseBrace, TokenAcceptanceThreshold(0u8), ), )?; seq.elem_labeled( - NodeLabel::CloseBrace, + EdgeLabel::CloseBrace, self.parse_token_with_trivia::( input, - TokenKind::CloseBrace, + TerminalKind::CloseBrace, ), )?; seq.finish() }) - .with_kind(RuleKind::NamedArgumentGroup) + .with_kind(NonTerminalKind::NamedArgumentGroup) } #[allow(unused_assignments, unused_parens)] @@ -3534,85 +3537,85 @@ impl Language { OptionalHelper::transform(SeparatedHelper::run::<_, LexicalContextType::Default>( input, self, - |input| self.named_argument(input).with_label(NodeLabel::Item), - TokenKind::Comma, - NodeLabel::Separator, + |input| self.named_argument(input).with_label(EdgeLabel::Item), + TerminalKind::Comma, + EdgeLabel::Separator, )) - .with_kind(RuleKind::NamedArguments) + .with_kind(NonTerminalKind::NamedArguments) } #[allow(unused_assignments, unused_parens)] fn named_arguments_declaration(&self, input: &mut ParserContext<'_>) -> ParserResult { SequenceHelper::run(|mut seq| { - let mut delim_guard = input.open_delim(TokenKind::CloseParen); + let mut delim_guard = input.open_delim(TerminalKind::CloseParen); let input = delim_guard.ctx(); seq.elem_labeled( - NodeLabel::OpenParen, + EdgeLabel::OpenParen, self.parse_token_with_trivia::( input, - TokenKind::OpenParen, + TerminalKind::OpenParen, ), )?; seq.elem( OptionalHelper::transform(self.named_argument_group(input)) - .with_label(NodeLabel::Arguments) + .with_label(EdgeLabel::Arguments) .recover_until_with_nested_delims::<_, LexicalContextType::Default>( input, self, - TokenKind::CloseParen, + TerminalKind::CloseParen, TokenAcceptanceThreshold(0u8), ), )?; seq.elem_labeled( - NodeLabel::CloseParen, + EdgeLabel::CloseParen, self.parse_token_with_trivia::( input, - TokenKind::CloseParen, + TerminalKind::CloseParen, ), )?; seq.finish() }) - .with_kind(RuleKind::NamedArgumentsDeclaration) + .with_kind(NonTerminalKind::NamedArgumentsDeclaration) } #[allow(unused_assignments, unused_parens)] fn named_import(&self, input: &mut ParserContext<'_>) -> ParserResult { SequenceHelper::run(|mut seq| { seq.elem_labeled( - NodeLabel::Asterisk, + EdgeLabel::Asterisk, self.parse_token_with_trivia::( input, - TokenKind::Asterisk, + TerminalKind::Asterisk, ), )?; - seq.elem_labeled(NodeLabel::Alias, self.import_alias(input))?; + seq.elem_labeled(EdgeLabel::Alias, self.import_alias(input))?; seq.elem_labeled( - NodeLabel::FromKeyword, + EdgeLabel::FromKeyword, self.parse_token_with_trivia::( input, - TokenKind::FromKeyword, + TerminalKind::FromKeyword, ), )?; - seq.elem_labeled(NodeLabel::Path, self.string_literal(input))?; + seq.elem_labeled(EdgeLabel::Path, self.string_literal(input))?; seq.finish() }) - .with_kind(RuleKind::NamedImport) + .with_kind(NonTerminalKind::NamedImport) } #[allow(unused_assignments, unused_parens)] fn new_expression(&self, input: &mut ParserContext<'_>) -> ParserResult { SequenceHelper::run(|mut seq| { seq.elem_labeled( - NodeLabel::NewKeyword, + EdgeLabel::NewKeyword, self.parse_token_with_trivia::( input, - TokenKind::NewKeyword, + TerminalKind::NewKeyword, ), )?; - seq.elem_labeled(NodeLabel::TypeName, self.type_name(input))?; + seq.elem_labeled(EdgeLabel::TypeName, self.type_name(input))?; seq.finish() }) - .with_kind(RuleKind::NewExpression) + .with_kind(NonTerminalKind::NewExpression) } #[allow(unused_assignments, unused_parens)] @@ -3620,71 +3623,71 @@ impl Language { ChoiceHelper::run(input, |mut choice, input| { let result = self.parse_token_with_trivia::( input, - TokenKind::WeiKeyword, + TerminalKind::WeiKeyword, ); choice.consider(input, result)?; if self.version_is_at_least_0_6_11 { let result = self.parse_token_with_trivia::( input, - TokenKind::GweiKeyword, + TerminalKind::GweiKeyword, ); choice.consider(input, result)?; } if !self.version_is_at_least_0_7_0 { let result = self.parse_token_with_trivia::( input, - TokenKind::SzaboKeyword, + TerminalKind::SzaboKeyword, ); choice.consider(input, result)?; } if !self.version_is_at_least_0_7_0 { let result = self.parse_token_with_trivia::( input, - TokenKind::FinneyKeyword, + TerminalKind::FinneyKeyword, ); choice.consider(input, result)?; } let result = self.parse_token_with_trivia::( input, - TokenKind::EtherKeyword, + TerminalKind::EtherKeyword, ); choice.consider(input, result)?; let result = self.parse_token_with_trivia::( input, - TokenKind::SecondsKeyword, + TerminalKind::SecondsKeyword, ); choice.consider(input, result)?; let result = self.parse_token_with_trivia::( input, - TokenKind::MinutesKeyword, + TerminalKind::MinutesKeyword, ); choice.consider(input, result)?; let result = self.parse_token_with_trivia::( input, - TokenKind::HoursKeyword, + TerminalKind::HoursKeyword, ); choice.consider(input, result)?; let result = self.parse_token_with_trivia::( input, - TokenKind::DaysKeyword, + TerminalKind::DaysKeyword, ); choice.consider(input, result)?; let result = self.parse_token_with_trivia::( input, - TokenKind::WeeksKeyword, + TerminalKind::WeeksKeyword, ); choice.consider(input, result)?; if !self.version_is_at_least_0_5_0 { let result = self.parse_token_with_trivia::( input, - TokenKind::YearsKeyword, + TerminalKind::YearsKeyword, ); choice.consider(input, result)?; } choice.finish(input) }) - .with_label(NodeLabel::Variant) - .with_kind(RuleKind::NumberUnit) + .with_label(EdgeLabel::Variant) + .with_kind(NonTerminalKind::NumberUnit) } #[allow(unused_assignments, unused_parens)] @@ -3694,14 +3697,14 @@ impl Language { return result; }; match &r#match.nodes[..] { - [cst::LabeledNode { - label: _, - node: cst::Node::Rule(node), - }] if node.kind == RuleKind::Expression => match &node.children[..] { - [inner @ cst::LabeledNode { - label: _, - node: cst::Node::Rule(rule), - }] if rule.kind == RuleKind::OrExpression => { + [cst::Edge { + node: cst::Node::NonTerminal(node), + .. + }] if node.kind == NonTerminalKind::Expression => match &node.children[..] { + [inner @ cst::Edge { + node: cst::Node::NonTerminal(node), + .. + }] if node.kind == NonTerminalKind::OrExpression => { ParserResult::r#match(vec![inner.clone()], r#match.expected_tokens.clone()) } _ => ParserResult::no_match(vec![]), @@ -3716,44 +3719,44 @@ impl Language { SeparatedHelper::run::<_, LexicalContextType::Default>( input, self, - |input| self.identifier_path(input).with_label(NodeLabel::Item), - TokenKind::Comma, - NodeLabel::Separator, + |input| self.identifier_path(input).with_label(EdgeLabel::Item), + TerminalKind::Comma, + EdgeLabel::Separator, ) } else { ParserResult::disabled() } - .with_kind(RuleKind::OverridePaths) + .with_kind(NonTerminalKind::OverridePaths) } #[allow(unused_assignments, unused_parens)] fn override_paths_declaration(&self, input: &mut ParserContext<'_>) -> ParserResult { if self.version_is_at_least_0_6_0 { SequenceHelper::run(|mut seq| { - let mut delim_guard = input.open_delim(TokenKind::CloseParen); + let mut delim_guard = input.open_delim(TerminalKind::CloseParen); let input = delim_guard.ctx(); seq.elem_labeled( - NodeLabel::OpenParen, + EdgeLabel::OpenParen, self.parse_token_with_trivia::( input, - TokenKind::OpenParen, + TerminalKind::OpenParen, ), )?; seq.elem( self.override_paths(input) - .with_label(NodeLabel::Paths) + .with_label(EdgeLabel::Paths) .recover_until_with_nested_delims::<_, LexicalContextType::Default>( input, self, - TokenKind::CloseParen, + TerminalKind::CloseParen, TokenAcceptanceThreshold(0u8), ), )?; seq.elem_labeled( - NodeLabel::CloseParen, + EdgeLabel::CloseParen, self.parse_token_with_trivia::( input, - TokenKind::CloseParen, + TerminalKind::CloseParen, ), )?; seq.finish() @@ -3761,7 +3764,7 @@ impl Language { } else { ParserResult::disabled() } - .with_kind(RuleKind::OverridePathsDeclaration) + .with_kind(NonTerminalKind::OverridePathsDeclaration) } #[allow(unused_assignments, unused_parens)] @@ -3769,14 +3772,14 @@ impl Language { if self.version_is_at_least_0_6_0 { SequenceHelper::run(|mut seq| { seq.elem_labeled( - NodeLabel::OverrideKeyword, + EdgeLabel::OverrideKeyword, self.parse_token_with_trivia::( input, - TokenKind::OverrideKeyword, + TerminalKind::OverrideKeyword, ), )?; seq.elem_labeled( - NodeLabel::Overridden, + EdgeLabel::Overridden, OptionalHelper::transform(self.override_paths_declaration(input)), )?; seq.finish() @@ -3784,29 +3787,29 @@ impl Language { } else { ParserResult::disabled() } - .with_kind(RuleKind::OverrideSpecifier) + .with_kind(NonTerminalKind::OverrideSpecifier) } #[allow(unused_assignments, unused_parens)] fn parameter(&self, input: &mut ParserContext<'_>) -> ParserResult { SequenceHelper::run(|mut seq| { - seq.elem_labeled(NodeLabel::TypeName, self.type_name(input))?; + seq.elem_labeled(EdgeLabel::TypeName, self.type_name(input))?; seq.elem_labeled( - NodeLabel::StorageLocation, + EdgeLabel::StorageLocation, OptionalHelper::transform(self.storage_location(input)), )?; seq.elem_labeled( - NodeLabel::Name, + EdgeLabel::Name, OptionalHelper::transform( self.parse_token_with_trivia::( input, - TokenKind::Identifier, + TerminalKind::Identifier, ), ), )?; seq.finish() }) - .with_kind(RuleKind::Parameter) + .with_kind(NonTerminalKind::Parameter) } #[allow(unused_assignments, unused_parens)] @@ -3814,58 +3817,58 @@ impl Language { OptionalHelper::transform(SeparatedHelper::run::<_, LexicalContextType::Default>( input, self, - |input| self.parameter(input).with_label(NodeLabel::Item), - TokenKind::Comma, - NodeLabel::Separator, + |input| self.parameter(input).with_label(EdgeLabel::Item), + TerminalKind::Comma, + EdgeLabel::Separator, )) - .with_kind(RuleKind::Parameters) + .with_kind(NonTerminalKind::Parameters) } #[allow(unused_assignments, unused_parens)] fn parameters_declaration(&self, input: &mut ParserContext<'_>) -> ParserResult { SequenceHelper::run(|mut seq| { - let mut delim_guard = input.open_delim(TokenKind::CloseParen); + let mut delim_guard = input.open_delim(TerminalKind::CloseParen); let input = delim_guard.ctx(); seq.elem_labeled( - NodeLabel::OpenParen, + EdgeLabel::OpenParen, self.parse_token_with_trivia::( input, - TokenKind::OpenParen, + TerminalKind::OpenParen, ), )?; seq.elem( self.parameters(input) - .with_label(NodeLabel::Parameters) + .with_label(EdgeLabel::Parameters) .recover_until_with_nested_delims::<_, LexicalContextType::Default>( input, self, - TokenKind::CloseParen, + TerminalKind::CloseParen, TokenAcceptanceThreshold(0u8), ), )?; seq.elem_labeled( - NodeLabel::CloseParen, + EdgeLabel::CloseParen, self.parse_token_with_trivia::( input, - TokenKind::CloseParen, + TerminalKind::CloseParen, ), )?; seq.finish() }) - .with_kind(RuleKind::ParametersDeclaration) + .with_kind(NonTerminalKind::ParametersDeclaration) } #[allow(unused_assignments, unused_parens)] fn path_import(&self, input: &mut ParserContext<'_>) -> ParserResult { SequenceHelper::run(|mut seq| { - seq.elem_labeled(NodeLabel::Path, self.string_literal(input))?; + seq.elem_labeled(EdgeLabel::Path, self.string_literal(input))?; seq.elem_labeled( - NodeLabel::Alias, + EdgeLabel::Alias, OptionalHelper::transform(self.import_alias(input)), )?; seq.finish() }) - .with_kind(RuleKind::PathImport) + .with_kind(NonTerminalKind::PathImport) } #[allow(unused_assignments, unused_parens)] @@ -3873,45 +3876,45 @@ impl Language { OptionalHelper::transform(SeparatedHelper::run::<_, LexicalContextType::Default>( input, self, - |input| self.expression(input).with_label(NodeLabel::Item), - TokenKind::Comma, - NodeLabel::Separator, + |input| self.expression(input).with_label(EdgeLabel::Item), + TerminalKind::Comma, + EdgeLabel::Separator, )) - .with_kind(RuleKind::PositionalArguments) + .with_kind(NonTerminalKind::PositionalArguments) } #[allow(unused_assignments, unused_parens)] fn positional_arguments_declaration(&self, input: &mut ParserContext<'_>) -> ParserResult { SequenceHelper::run(|mut seq| { - let mut delim_guard = input.open_delim(TokenKind::CloseParen); + let mut delim_guard = input.open_delim(TerminalKind::CloseParen); let input = delim_guard.ctx(); seq.elem_labeled( - NodeLabel::OpenParen, + EdgeLabel::OpenParen, self.parse_token_with_trivia::( input, - TokenKind::OpenParen, + TerminalKind::OpenParen, ), )?; seq.elem( self.positional_arguments(input) - .with_label(NodeLabel::Arguments) + .with_label(EdgeLabel::Arguments) .recover_until_with_nested_delims::<_, LexicalContextType::Default>( input, self, - TokenKind::CloseParen, + TerminalKind::CloseParen, TokenAcceptanceThreshold(0u8), ), )?; seq.elem_labeled( - NodeLabel::CloseParen, + EdgeLabel::CloseParen, self.parse_token_with_trivia::( input, - TokenKind::CloseParen, + TerminalKind::CloseParen, ), )?; seq.finish() }) - .with_kind(RuleKind::PositionalArgumentsDeclaration) + .with_kind(NonTerminalKind::PositionalArgumentsDeclaration) } #[allow(unused_assignments, unused_parens)] @@ -3921,14 +3924,14 @@ impl Language { return result; }; match &r#match.nodes[..] { - [cst::LabeledNode { - label: _, - node: cst::Node::Rule(node), - }] if node.kind == RuleKind::Expression => match &node.children[..] { - [inner @ cst::LabeledNode { - label: _, - node: cst::Node::Rule(rule), - }] if rule.kind == RuleKind::PostfixExpression => { + [cst::Edge { + node: cst::Node::NonTerminal(node), + .. + }] if node.kind == NonTerminalKind::Expression => match &node.children[..] { + [inner @ cst::Edge { + node: cst::Node::NonTerminal(node), + .. + }] if node.kind == NonTerminalKind::PostfixExpression => { ParserResult::r#match(vec![inner.clone()], r#match.expected_tokens.clone()) } _ => ParserResult::no_match(vec![]), @@ -3948,8 +3951,8 @@ impl Language { choice.consider(input, result)?; choice.finish(input) }) - .with_label(NodeLabel::Variant) - .with_kind(RuleKind::Pragma) + .with_label(EdgeLabel::Variant) + .with_kind(NonTerminalKind::Pragma) } #[allow(unused_assignments, unused_parens)] @@ -3958,32 +3961,32 @@ impl Language { seq.elem( SequenceHelper::run(|mut seq| { seq.elem_labeled( - NodeLabel::PragmaKeyword, + EdgeLabel::PragmaKeyword, self.parse_token_with_trivia::( input, - TokenKind::PragmaKeyword, + TerminalKind::PragmaKeyword, ), )?; - seq.elem_labeled(NodeLabel::Pragma, self.pragma(input))?; + seq.elem_labeled(EdgeLabel::Pragma, self.pragma(input))?; seq.finish() }) .recover_until_with_nested_delims::<_, LexicalContextType::Pragma>( input, self, - TokenKind::Semicolon, + TerminalKind::Semicolon, TokenAcceptanceThreshold(1u8), ), )?; seq.elem_labeled( - NodeLabel::Semicolon, + EdgeLabel::Semicolon, self.parse_token_with_trivia::( input, - TokenKind::Semicolon, + TerminalKind::Semicolon, ), )?; seq.finish() }) - .with_kind(RuleKind::PragmaDirective) + .with_kind(NonTerminalKind::PragmaDirective) } #[allow(unused_assignments, unused_parens)] @@ -3993,14 +3996,14 @@ impl Language { return result; }; match &r#match.nodes[..] { - [cst::LabeledNode { - label: _, - node: cst::Node::Rule(node), - }] if node.kind == RuleKind::Expression => match &node.children[..] { - [inner @ cst::LabeledNode { - label: _, - node: cst::Node::Rule(rule), - }] if rule.kind == RuleKind::PrefixExpression => { + [cst::Edge { + node: cst::Node::NonTerminal(node), + .. + }] if node.kind == NonTerminalKind::Expression => match &node.children[..] { + [inner @ cst::Edge { + node: cst::Node::NonTerminal(node), + .. + }] if node.kind == NonTerminalKind::PrefixExpression => { ParserResult::r#match(vec![inner.clone()], r#match.expected_tokens.clone()) } _ => ParserResult::no_match(vec![]), @@ -4019,26 +4022,26 @@ impl Language { choice.consider(input, result)?; let result = self.parse_token_with_trivia::( input, - TokenKind::ExternalKeyword, + TerminalKind::ExternalKeyword, ); choice.consider(input, result)?; let result = self.parse_token_with_trivia::( input, - TokenKind::PayableKeyword, + TerminalKind::PayableKeyword, ); choice.consider(input, result)?; let result = self.parse_token_with_trivia::( input, - TokenKind::VirtualKeyword, + TerminalKind::VirtualKeyword, ); choice.consider(input, result)?; choice.finish(input) }) - .with_label(NodeLabel::Variant) + .with_label(EdgeLabel::Variant) } else { ParserResult::disabled() } - .with_kind(RuleKind::ReceiveFunctionAttribute) + .with_kind(NonTerminalKind::ReceiveFunctionAttribute) } #[allow(unused_assignments, unused_parens)] @@ -4046,12 +4049,12 @@ impl Language { if self.version_is_at_least_0_6_0 { ZeroOrMoreHelper::run(input, |input| { self.receive_function_attribute(input) - .with_label(NodeLabel::Item) + .with_label(EdgeLabel::Item) }) } else { ParserResult::disabled() } - .with_kind(RuleKind::ReceiveFunctionAttributes) + .with_kind(NonTerminalKind::ReceiveFunctionAttributes) } #[allow(unused_assignments, unused_parens)] @@ -4059,24 +4062,24 @@ impl Language { if self.version_is_at_least_0_6_0 { SequenceHelper::run(|mut seq| { seq.elem_labeled( - NodeLabel::ReceiveKeyword, + EdgeLabel::ReceiveKeyword, self.parse_token_with_trivia::( input, - TokenKind::ReceiveKeyword, + TerminalKind::ReceiveKeyword, ), )?; - seq.elem_labeled(NodeLabel::Parameters, self.parameters_declaration(input))?; + seq.elem_labeled(EdgeLabel::Parameters, self.parameters_declaration(input))?; seq.elem_labeled( - NodeLabel::Attributes, + EdgeLabel::Attributes, self.receive_function_attributes(input), )?; - seq.elem_labeled(NodeLabel::Body, self.function_body(input))?; + seq.elem_labeled(EdgeLabel::Body, self.function_body(input))?; seq.finish() }) } else { ParserResult::disabled() } - .with_kind(RuleKind::ReceiveFunctionDefinition) + .with_kind(NonTerminalKind::ReceiveFunctionDefinition) } #[allow(unused_assignments, unused_parens)] @@ -4085,14 +4088,14 @@ impl Language { seq.elem( SequenceHelper::run(|mut seq| { seq.elem_labeled( - NodeLabel::ReturnKeyword, + EdgeLabel::ReturnKeyword, self.parse_token_with_trivia::( input, - TokenKind::ReturnKeyword, + TerminalKind::ReturnKeyword, ), )?; seq.elem_labeled( - NodeLabel::Expression, + EdgeLabel::Expression, OptionalHelper::transform(self.expression(input)), )?; seq.finish() @@ -4100,36 +4103,36 @@ impl Language { .recover_until_with_nested_delims::<_, LexicalContextType::Default>( input, self, - TokenKind::Semicolon, + TerminalKind::Semicolon, TokenAcceptanceThreshold(1u8), ), )?; seq.elem_labeled( - NodeLabel::Semicolon, + EdgeLabel::Semicolon, self.parse_token_with_trivia::( input, - TokenKind::Semicolon, + TerminalKind::Semicolon, ), )?; seq.finish() }) - .with_kind(RuleKind::ReturnStatement) + .with_kind(NonTerminalKind::ReturnStatement) } #[allow(unused_assignments, unused_parens)] fn returns_declaration(&self, input: &mut ParserContext<'_>) -> ParserResult { SequenceHelper::run(|mut seq| { seq.elem_labeled( - NodeLabel::ReturnsKeyword, + EdgeLabel::ReturnsKeyword, self.parse_token_with_trivia::( input, - TokenKind::ReturnsKeyword, + TerminalKind::ReturnsKeyword, ), )?; - seq.elem_labeled(NodeLabel::Variables, self.parameters_declaration(input))?; + seq.elem_labeled(EdgeLabel::Variables, self.parameters_declaration(input))?; seq.finish() }) - .with_kind(RuleKind::ReturnsDeclaration) + .with_kind(NonTerminalKind::ReturnsDeclaration) } #[allow(unused_assignments, unused_parens)] @@ -4139,31 +4142,31 @@ impl Language { seq.elem( SequenceHelper::run(|mut seq| { seq.elem_labeled( - NodeLabel::RevertKeyword, + EdgeLabel::RevertKeyword, self.parse_token_with_trivia::( input, - TokenKind::RevertKeyword, + TerminalKind::RevertKeyword, ), )?; seq.elem_labeled( - NodeLabel::Error, + EdgeLabel::Error, OptionalHelper::transform(self.identifier_path(input)), )?; - seq.elem_labeled(NodeLabel::Arguments, self.arguments_declaration(input))?; + seq.elem_labeled(EdgeLabel::Arguments, self.arguments_declaration(input))?; seq.finish() }) .recover_until_with_nested_delims::<_, LexicalContextType::Default>( input, self, - TokenKind::Semicolon, + TerminalKind::Semicolon, TokenAcceptanceThreshold(1u8), ), )?; seq.elem_labeled( - NodeLabel::Semicolon, + EdgeLabel::Semicolon, self.parse_token_with_trivia::( input, - TokenKind::Semicolon, + TerminalKind::Semicolon, ), )?; seq.finish() @@ -4171,7 +4174,7 @@ impl Language { } else { ParserResult::disabled() } - .with_kind(RuleKind::RevertStatement) + .with_kind(NonTerminalKind::RevertStatement) } #[allow(unused_assignments, unused_parens)] @@ -4181,14 +4184,14 @@ impl Language { return result; }; match &r#match.nodes[..] { - [cst::LabeledNode { - label: _, - node: cst::Node::Rule(node), - }] if node.kind == RuleKind::Expression => match &node.children[..] { - [inner @ cst::LabeledNode { - label: _, - node: cst::Node::Rule(rule), - }] if rule.kind == RuleKind::ShiftExpression => { + [cst::Edge { + node: cst::Node::NonTerminal(node), + .. + }] if node.kind == NonTerminalKind::Expression => match &node.children[..] { + [inner @ cst::Edge { + node: cst::Node::NonTerminal(node), + .. + }] if node.kind == NonTerminalKind::ShiftExpression => { ParserResult::r#match(vec![inner.clone()], r#match.expected_tokens.clone()) } _ => ParserResult::no_match(vec![]), @@ -4200,8 +4203,8 @@ impl Language { #[allow(unused_assignments, unused_parens)] fn source_unit(&self, input: &mut ParserContext<'_>) -> ParserResult { self.source_unit_members(input) - .with_label(NodeLabel::Members) - .with_kind(RuleKind::SourceUnit) + .with_label(EdgeLabel::Members) + .with_kind(NonTerminalKind::SourceUnit) } #[allow(unused_assignments, unused_parens)] @@ -4251,16 +4254,16 @@ impl Language { } choice.finish(input) }) - .with_label(NodeLabel::Variant) - .with_kind(RuleKind::SourceUnitMember) + .with_label(EdgeLabel::Variant) + .with_kind(NonTerminalKind::SourceUnitMember) } #[allow(unused_assignments, unused_parens)] fn source_unit_members(&self, input: &mut ParserContext<'_>) -> ParserResult { ZeroOrMoreHelper::run(input, |input| { - self.source_unit_member(input).with_label(NodeLabel::Item) + self.source_unit_member(input).with_label(EdgeLabel::Item) }) - .with_kind(RuleKind::SourceUnitMembers) + .with_kind(NonTerminalKind::SourceUnitMembers) } #[allow(unused_assignments, unused_parens)] @@ -4272,44 +4275,44 @@ impl Language { } let result = self.parse_token_with_trivia::( input, - TokenKind::ConstantKeyword, + TerminalKind::ConstantKeyword, ); choice.consider(input, result)?; let result = self.parse_token_with_trivia::( input, - TokenKind::InternalKeyword, + TerminalKind::InternalKeyword, ); choice.consider(input, result)?; let result = self.parse_token_with_trivia::( input, - TokenKind::PrivateKeyword, + TerminalKind::PrivateKeyword, ); choice.consider(input, result)?; let result = self.parse_token_with_trivia::( input, - TokenKind::PublicKeyword, + TerminalKind::PublicKeyword, ); choice.consider(input, result)?; if self.version_is_at_least_0_6_5 { let result = self.parse_token_with_trivia::( input, - TokenKind::ImmutableKeyword, + TerminalKind::ImmutableKeyword, ); choice.consider(input, result)?; } choice.finish(input) }) - .with_label(NodeLabel::Variant) - .with_kind(RuleKind::StateVariableAttribute) + .with_label(EdgeLabel::Variant) + .with_kind(NonTerminalKind::StateVariableAttribute) } #[allow(unused_assignments, unused_parens)] fn state_variable_attributes(&self, input: &mut ParserContext<'_>) -> ParserResult { ZeroOrMoreHelper::run(input, |input| { self.state_variable_attribute(input) - .with_label(NodeLabel::Item) + .with_label(EdgeLabel::Item) }) - .with_kind(RuleKind::StateVariableAttributes) + .with_kind(NonTerminalKind::StateVariableAttributes) } #[allow(unused_assignments, unused_parens)] @@ -4317,17 +4320,17 @@ impl Language { SequenceHelper::run(|mut seq| { seq.elem( SequenceHelper::run(|mut seq| { - seq.elem_labeled(NodeLabel::TypeName, self.type_name(input))?; - seq.elem_labeled(NodeLabel::Attributes, self.state_variable_attributes(input))?; + seq.elem_labeled(EdgeLabel::TypeName, self.type_name(input))?; + seq.elem_labeled(EdgeLabel::Attributes, self.state_variable_attributes(input))?; seq.elem_labeled( - NodeLabel::Name, + EdgeLabel::Name, self.parse_token_with_trivia::( input, - TokenKind::Identifier, + TerminalKind::Identifier, ), )?; seq.elem_labeled( - NodeLabel::Value, + EdgeLabel::Value, OptionalHelper::transform(self.state_variable_definition_value(input)), )?; seq.finish() @@ -4335,36 +4338,36 @@ impl Language { .recover_until_with_nested_delims::<_, LexicalContextType::Default>( input, self, - TokenKind::Semicolon, + TerminalKind::Semicolon, TokenAcceptanceThreshold(1u8), ), )?; seq.elem_labeled( - NodeLabel::Semicolon, + EdgeLabel::Semicolon, self.parse_token_with_trivia::( input, - TokenKind::Semicolon, + TerminalKind::Semicolon, ), )?; seq.finish() }) - .with_kind(RuleKind::StateVariableDefinition) + .with_kind(NonTerminalKind::StateVariableDefinition) } #[allow(unused_assignments, unused_parens)] fn state_variable_definition_value(&self, input: &mut ParserContext<'_>) -> ParserResult { SequenceHelper::run(|mut seq| { seq.elem_labeled( - NodeLabel::Equal, + EdgeLabel::Equal, self.parse_token_with_trivia::( input, - TokenKind::Equal, + TerminalKind::Equal, ), )?; - seq.elem_labeled(NodeLabel::Value, self.expression(input))?; + seq.elem_labeled(EdgeLabel::Value, self.expression(input))?; seq.finish() }) - .with_kind(RuleKind::StateVariableDefinitionValue) + .with_kind(NonTerminalKind::StateVariableDefinitionValue) } #[allow(unused_assignments, unused_parens)] @@ -4416,16 +4419,16 @@ impl Language { } choice.finish(input) }) - .with_label(NodeLabel::Variant) - .with_kind(RuleKind::Statement) + .with_label(EdgeLabel::Variant) + .with_kind(NonTerminalKind::Statement) } #[allow(unused_assignments, unused_parens)] fn statements(&self, input: &mut ParserContext<'_>) -> ParserResult { ZeroOrMoreHelper::run(input, |input| { - self.statement(input).with_label(NodeLabel::Item) + self.statement(input).with_label(EdgeLabel::Item) }) - .with_kind(RuleKind::Statements) + .with_kind(NonTerminalKind::Statements) } #[allow(unused_assignments, unused_parens)] @@ -4433,25 +4436,25 @@ impl Language { ChoiceHelper::run(input, |mut choice, input| { let result = self.parse_token_with_trivia::( input, - TokenKind::MemoryKeyword, + TerminalKind::MemoryKeyword, ); choice.consider(input, result)?; let result = self.parse_token_with_trivia::( input, - TokenKind::StorageKeyword, + TerminalKind::StorageKeyword, ); choice.consider(input, result)?; if self.version_is_at_least_0_5_0 { let result = self.parse_token_with_trivia::( input, - TokenKind::CallDataKeyword, + TerminalKind::CallDataKeyword, ); choice.consider(input, result)?; } choice.finish(input) }) - .with_label(NodeLabel::Variant) - .with_kind(RuleKind::StorageLocation) + .with_label(EdgeLabel::Variant) + .with_kind(NonTerminalKind::StorageLocation) } #[allow(unused_assignments, unused_parens)] @@ -4479,8 +4482,8 @@ impl Language { } choice.finish(input) }) - .with_label(NodeLabel::Variant) - .with_kind(RuleKind::StringExpression) + .with_label(EdgeLabel::Variant) + .with_kind(NonTerminalKind::StringExpression) } #[allow(unused_assignments, unused_parens)] @@ -4488,81 +4491,81 @@ impl Language { ChoiceHelper::run(input, |mut choice, input| { let result = self.parse_token_with_trivia::( input, - TokenKind::SingleQuotedStringLiteral, + TerminalKind::SingleQuotedStringLiteral, ); choice.consider(input, result)?; let result = self.parse_token_with_trivia::( input, - TokenKind::DoubleQuotedStringLiteral, + TerminalKind::DoubleQuotedStringLiteral, ); choice.consider(input, result)?; choice.finish(input) }) - .with_label(NodeLabel::Variant) - .with_kind(RuleKind::StringLiteral) + .with_label(EdgeLabel::Variant) + .with_kind(NonTerminalKind::StringLiteral) } #[allow(unused_assignments, unused_parens)] fn string_literals(&self, input: &mut ParserContext<'_>) -> ParserResult { if self.version_is_at_least_0_5_14 { OneOrMoreHelper::run(input, |input| { - self.string_literal(input).with_label(NodeLabel::Item) + self.string_literal(input).with_label(EdgeLabel::Item) }) } else { ParserResult::disabled() } - .with_kind(RuleKind::StringLiterals) + .with_kind(NonTerminalKind::StringLiterals) } #[allow(unused_assignments, unused_parens)] fn struct_definition(&self, input: &mut ParserContext<'_>) -> ParserResult { SequenceHelper::run(|mut seq| { seq.elem_labeled( - NodeLabel::StructKeyword, + EdgeLabel::StructKeyword, self.parse_token_with_trivia::( input, - TokenKind::StructKeyword, + TerminalKind::StructKeyword, ), )?; seq.elem_labeled( - NodeLabel::Name, + EdgeLabel::Name, self.parse_token_with_trivia::( input, - TokenKind::Identifier, + TerminalKind::Identifier, ), )?; seq.elem(SequenceHelper::run(|mut seq| { - let mut delim_guard = input.open_delim(TokenKind::CloseBrace); + let mut delim_guard = input.open_delim(TerminalKind::CloseBrace); let input = delim_guard.ctx(); seq.elem_labeled( - NodeLabel::OpenBrace, + EdgeLabel::OpenBrace, self.parse_token_with_trivia::( input, - TokenKind::OpenBrace, + TerminalKind::OpenBrace, ), )?; seq.elem( self.struct_members(input) - .with_label(NodeLabel::Members) + .with_label(EdgeLabel::Members) .recover_until_with_nested_delims::<_, LexicalContextType::Default>( input, self, - TokenKind::CloseBrace, + TerminalKind::CloseBrace, TokenAcceptanceThreshold(0u8), ), )?; seq.elem_labeled( - NodeLabel::CloseBrace, + EdgeLabel::CloseBrace, self.parse_token_with_trivia::( input, - TokenKind::CloseBrace, + TerminalKind::CloseBrace, ), )?; seq.finish() }))?; seq.finish() }) - .with_kind(RuleKind::StructDefinition) + .with_kind(NonTerminalKind::StructDefinition) } #[allow(unused_assignments, unused_parens)] @@ -4570,12 +4573,12 @@ impl Language { SequenceHelper::run(|mut seq| { seq.elem( SequenceHelper::run(|mut seq| { - seq.elem_labeled(NodeLabel::TypeName, self.type_name(input))?; + seq.elem_labeled(EdgeLabel::TypeName, self.type_name(input))?; seq.elem_labeled( - NodeLabel::Name, + EdgeLabel::Name, self.parse_token_with_trivia::( input, - TokenKind::Identifier, + TerminalKind::Identifier, ), )?; seq.finish() @@ -4583,28 +4586,28 @@ impl Language { .recover_until_with_nested_delims::<_, LexicalContextType::Default>( input, self, - TokenKind::Semicolon, + TerminalKind::Semicolon, TokenAcceptanceThreshold(1u8), ), )?; seq.elem_labeled( - NodeLabel::Semicolon, + EdgeLabel::Semicolon, self.parse_token_with_trivia::( input, - TokenKind::Semicolon, + TerminalKind::Semicolon, ), )?; seq.finish() }) - .with_kind(RuleKind::StructMember) + .with_kind(NonTerminalKind::StructMember) } #[allow(unused_assignments, unused_parens)] fn struct_members(&self, input: &mut ParserContext<'_>) -> ParserResult { ZeroOrMoreHelper::run(input, |input| { - self.struct_member(input).with_label(NodeLabel::Item) + self.struct_member(input).with_label(EdgeLabel::Item) }) - .with_kind(RuleKind::StructMembers) + .with_kind(NonTerminalKind::StructMembers) } #[allow(unused_assignments, unused_parens)] @@ -4614,21 +4617,21 @@ impl Language { seq.elem( self.parse_token_with_trivia::( input, - TokenKind::ThrowKeyword, + TerminalKind::ThrowKeyword, ) - .with_label(NodeLabel::ThrowKeyword) + .with_label(EdgeLabel::ThrowKeyword) .recover_until_with_nested_delims::<_, LexicalContextType::Default>( input, self, - TokenKind::Semicolon, + TerminalKind::Semicolon, TokenAcceptanceThreshold(1u8), ), )?; seq.elem_labeled( - NodeLabel::Semicolon, + EdgeLabel::Semicolon, self.parse_token_with_trivia::( input, - TokenKind::Semicolon, + TerminalKind::Semicolon, ), )?; seq.finish() @@ -4636,7 +4639,7 @@ impl Language { } else { ParserResult::disabled() } - .with_kind(RuleKind::ThrowStatement) + .with_kind(NonTerminalKind::ThrowStatement) } #[allow(unused_assignments, unused_parens)] @@ -4644,32 +4647,32 @@ impl Language { if self.version_is_at_least_0_6_0 { SequenceHelper::run(|mut seq| { seq.elem_labeled( - NodeLabel::TryKeyword, + EdgeLabel::TryKeyword, self.parse_token_with_trivia::( input, - TokenKind::TryKeyword, + TerminalKind::TryKeyword, ), )?; - seq.elem_labeled(NodeLabel::Expression, self.expression(input))?; + seq.elem_labeled(EdgeLabel::Expression, self.expression(input))?; seq.elem_labeled( - NodeLabel::Returns, + EdgeLabel::Returns, OptionalHelper::transform(self.returns_declaration(input)), )?; - seq.elem_labeled(NodeLabel::Body, self.block(input))?; - seq.elem_labeled(NodeLabel::CatchClauses, self.catch_clauses(input))?; + seq.elem_labeled(EdgeLabel::Body, self.block(input))?; + seq.elem_labeled(EdgeLabel::CatchClauses, self.catch_clauses(input))?; seq.finish() }) } else { ParserResult::disabled() } - .with_kind(RuleKind::TryStatement) + .with_kind(NonTerminalKind::TryStatement) } #[allow(unused_assignments, unused_parens)] fn tuple_deconstruction_element(&self, input: &mut ParserContext<'_>) -> ParserResult { OptionalHelper::transform(self.tuple_member(input)) - .with_label(NodeLabel::Member) - .with_kind(RuleKind::TupleDeconstructionElement) + .with_label(EdgeLabel::Member) + .with_kind(NonTerminalKind::TupleDeconstructionElement) } #[allow(unused_assignments, unused_parens)] @@ -4679,12 +4682,12 @@ impl Language { self, |input| { self.tuple_deconstruction_element(input) - .with_label(NodeLabel::Item) + .with_label(EdgeLabel::Item) }, - TokenKind::Comma, - NodeLabel::Separator, + TerminalKind::Comma, + EdgeLabel::Separator, ) - .with_kind(RuleKind::TupleDeconstructionElements) + .with_kind(NonTerminalKind::TupleDeconstructionElements) } #[allow(unused_assignments, unused_parens)] @@ -4694,105 +4697,105 @@ impl Language { SequenceHelper::run(|mut seq| { if !self.version_is_at_least_0_5_0 { seq.elem_labeled( - NodeLabel::VarKeyword, + EdgeLabel::VarKeyword, OptionalHelper::transform( self.parse_token_with_trivia::( input, - TokenKind::VarKeyword, + TerminalKind::VarKeyword, ), ), )?; } seq.elem(SequenceHelper::run(|mut seq| { - let mut delim_guard = input.open_delim(TokenKind::CloseParen); + let mut delim_guard = input.open_delim(TerminalKind::CloseParen); let input = delim_guard.ctx(); seq.elem_labeled( - NodeLabel::OpenParen, + EdgeLabel::OpenParen, self.parse_token_with_trivia::( input, - TokenKind::OpenParen, + TerminalKind::OpenParen, ), )?; seq.elem( self.tuple_deconstruction_elements(input) - .with_label(NodeLabel::Elements) + .with_label(EdgeLabel::Elements) .recover_until_with_nested_delims::<_, LexicalContextType::Default>( input, self, - TokenKind::CloseParen, + TerminalKind::CloseParen, TokenAcceptanceThreshold(0u8), ), )?; seq.elem_labeled( - NodeLabel::CloseParen, + EdgeLabel::CloseParen, self.parse_token_with_trivia::( input, - TokenKind::CloseParen, + TerminalKind::CloseParen, ), )?; seq.finish() }))?; seq.elem_labeled( - NodeLabel::Equal, + EdgeLabel::Equal, self.parse_token_with_trivia::( input, - TokenKind::Equal, + TerminalKind::Equal, ), )?; - seq.elem_labeled(NodeLabel::Expression, self.expression(input))?; + seq.elem_labeled(EdgeLabel::Expression, self.expression(input))?; seq.finish() }) .recover_until_with_nested_delims::<_, LexicalContextType::Default>( input, self, - TokenKind::Semicolon, + TerminalKind::Semicolon, TokenAcceptanceThreshold(1u8), ), )?; seq.elem_labeled( - NodeLabel::Semicolon, + EdgeLabel::Semicolon, self.parse_token_with_trivia::( input, - TokenKind::Semicolon, + TerminalKind::Semicolon, ), )?; seq.finish() }) - .with_kind(RuleKind::TupleDeconstructionStatement) + .with_kind(NonTerminalKind::TupleDeconstructionStatement) } #[allow(unused_assignments, unused_parens)] fn tuple_expression(&self, input: &mut ParserContext<'_>) -> ParserResult { SequenceHelper::run(|mut seq| { - let mut delim_guard = input.open_delim(TokenKind::CloseParen); + let mut delim_guard = input.open_delim(TerminalKind::CloseParen); let input = delim_guard.ctx(); seq.elem_labeled( - NodeLabel::OpenParen, + EdgeLabel::OpenParen, self.parse_token_with_trivia::( input, - TokenKind::OpenParen, + TerminalKind::OpenParen, ), )?; seq.elem( self.tuple_values(input) - .with_label(NodeLabel::Items) + .with_label(EdgeLabel::Items) .recover_until_with_nested_delims::<_, LexicalContextType::Default>( input, self, - TokenKind::CloseParen, + TerminalKind::CloseParen, TokenAcceptanceThreshold(0u8), ), )?; seq.elem_labeled( - NodeLabel::CloseParen, + EdgeLabel::CloseParen, self.parse_token_with_trivia::( input, - TokenKind::CloseParen, + TerminalKind::CloseParen, ), )?; seq.finish() }) - .with_kind(RuleKind::TupleExpression) + .with_kind(NonTerminalKind::TupleExpression) } #[allow(unused_assignments, unused_parens)] @@ -4804,15 +4807,15 @@ impl Language { choice.consider(input, result)?; choice.finish(input) }) - .with_label(NodeLabel::Variant) - .with_kind(RuleKind::TupleMember) + .with_label(EdgeLabel::Variant) + .with_kind(NonTerminalKind::TupleMember) } #[allow(unused_assignments, unused_parens)] fn tuple_value(&self, input: &mut ParserContext<'_>) -> ParserResult { OptionalHelper::transform(self.expression(input)) - .with_label(NodeLabel::Expression) - .with_kind(RuleKind::TupleValue) + .with_label(EdgeLabel::Expression) + .with_kind(NonTerminalKind::TupleValue) } #[allow(unused_assignments, unused_parens)] @@ -4820,11 +4823,11 @@ impl Language { SeparatedHelper::run::<_, LexicalContextType::Default>( input, self, - |input| self.tuple_value(input).with_label(NodeLabel::Item), - TokenKind::Comma, - NodeLabel::Separator, + |input| self.tuple_value(input).with_label(EdgeLabel::Item), + TerminalKind::Comma, + EdgeLabel::Separator, ) - .with_kind(RuleKind::TupleValues) + .with_kind(NonTerminalKind::TupleValues) } #[allow(unused_assignments, unused_parens)] @@ -4832,37 +4835,37 @@ impl Language { if self.version_is_at_least_0_5_3 { SequenceHelper::run(|mut seq| { seq.elem_labeled( - NodeLabel::TypeKeyword, + EdgeLabel::TypeKeyword, self.parse_token_with_trivia::( input, - TokenKind::TypeKeyword, + TerminalKind::TypeKeyword, ), )?; seq.elem(SequenceHelper::run(|mut seq| { - let mut delim_guard = input.open_delim(TokenKind::CloseParen); + let mut delim_guard = input.open_delim(TerminalKind::CloseParen); let input = delim_guard.ctx(); seq.elem_labeled( - NodeLabel::OpenParen, + EdgeLabel::OpenParen, self.parse_token_with_trivia::( input, - TokenKind::OpenParen, + TerminalKind::OpenParen, ), )?; seq.elem( self.type_name(input) - .with_label(NodeLabel::TypeName) + .with_label(EdgeLabel::TypeName) .recover_until_with_nested_delims::<_, LexicalContextType::Default>( input, self, - TokenKind::CloseParen, + TerminalKind::CloseParen, TokenAcceptanceThreshold(0u8), ), )?; seq.elem_labeled( - NodeLabel::CloseParen, + EdgeLabel::CloseParen, self.parse_token_with_trivia::( input, - TokenKind::CloseParen, + TerminalKind::CloseParen, ), )?; seq.finish() @@ -4872,40 +4875,40 @@ impl Language { } else { ParserResult::disabled() } - .with_kind(RuleKind::TypeExpression) + .with_kind(NonTerminalKind::TypeExpression) } #[allow(unused_assignments, unused_parens)] fn type_name(&self, input: &mut ParserContext<'_>) -> ParserResult { let parse_postfix_array_type_name = |input: &mut ParserContext<'_>| { PrecedenceHelper::to_postfix_operator( - RuleKind::ArrayTypeName, + NonTerminalKind::ArrayTypeName, 1u8, SequenceHelper::run(|mut seq| { - let mut delim_guard = input.open_delim(TokenKind::CloseBracket); + let mut delim_guard = input.open_delim(TerminalKind::CloseBracket); let input = delim_guard.ctx(); seq.elem_labeled( - NodeLabel::OpenBracket, + EdgeLabel::OpenBracket, self.parse_token_with_trivia::( input, - TokenKind::OpenBracket, + TerminalKind::OpenBracket, ), )?; seq.elem( OptionalHelper::transform(self.expression(input)) - .with_label(NodeLabel::Index) + .with_label(EdgeLabel::Index) .recover_until_with_nested_delims::<_, LexicalContextType::Default>( input, self, - TokenKind::CloseBracket, + TerminalKind::CloseBracket, TokenAcceptanceThreshold(0u8), ), )?; seq.elem_labeled( - NodeLabel::CloseBracket, + EdgeLabel::CloseBracket, self.parse_token_with_trivia::( input, - TokenKind::CloseBracket, + TerminalKind::CloseBracket, ), )?; seq.finish() @@ -4924,7 +4927,7 @@ impl Language { choice.consider(input, result)?; choice.finish(input) }) - .with_label(NodeLabel::Variant) + .with_label(EdgeLabel::Variant) }; let postfix_operator_parser = |input: &mut ParserContext<'_>| { ChoiceHelper::run(input, |mut choice, input| { @@ -4941,30 +4944,30 @@ impl Language { }) }; PrecedenceHelper::reduce_precedence_result( - RuleKind::TypeName, + NonTerminalKind::TypeName, linear_expression_parser(input), ) - .with_kind(RuleKind::TypeName) + .with_kind(NonTerminalKind::TypeName) } #[allow(unused_assignments, unused_parens)] fn typed_tuple_member(&self, input: &mut ParserContext<'_>) -> ParserResult { SequenceHelper::run(|mut seq| { - seq.elem_labeled(NodeLabel::TypeName, self.type_name(input))?; + seq.elem_labeled(EdgeLabel::TypeName, self.type_name(input))?; seq.elem_labeled( - NodeLabel::StorageLocation, + EdgeLabel::StorageLocation, OptionalHelper::transform(self.storage_location(input)), )?; seq.elem_labeled( - NodeLabel::Name, + EdgeLabel::Name, self.parse_token_with_trivia::( input, - TokenKind::Identifier, + TerminalKind::Identifier, ), )?; seq.finish() }) - .with_kind(RuleKind::TypedTupleMember) + .with_kind(NonTerminalKind::TypedTupleMember) } #[allow(unused_assignments, unused_parens)] @@ -4972,19 +4975,19 @@ impl Language { if self.version_is_at_least_0_8_0 { SequenceHelper::run(|mut seq| { seq.elem_labeled( - NodeLabel::UncheckedKeyword, + EdgeLabel::UncheckedKeyword, self.parse_token_with_trivia::( input, - TokenKind::UncheckedKeyword, + TerminalKind::UncheckedKeyword, ), )?; - seq.elem_labeled(NodeLabel::Block, self.block(input))?; + seq.elem_labeled(EdgeLabel::Block, self.block(input))?; seq.finish() }) } else { ParserResult::disabled() } - .with_kind(RuleKind::UncheckedBlock) + .with_kind(NonTerminalKind::UncheckedBlock) } #[allow(unused_assignments, unused_parens)] @@ -4993,21 +4996,21 @@ impl Language { ChoiceHelper::run(input, |mut choice, input| { let result = self.parse_token_with_trivia::( input, - TokenKind::SingleQuotedUnicodeStringLiteral, + TerminalKind::SingleQuotedUnicodeStringLiteral, ); choice.consider(input, result)?; let result = self.parse_token_with_trivia::( input, - TokenKind::DoubleQuotedUnicodeStringLiteral, + TerminalKind::DoubleQuotedUnicodeStringLiteral, ); choice.consider(input, result)?; choice.finish(input) }) - .with_label(NodeLabel::Variant) + .with_label(EdgeLabel::Variant) } else { ParserResult::disabled() } - .with_kind(RuleKind::UnicodeStringLiteral) + .with_kind(NonTerminalKind::UnicodeStringLiteral) } #[allow(unused_assignments, unused_parens)] @@ -5015,12 +5018,12 @@ impl Language { if self.version_is_at_least_0_7_0 { OneOrMoreHelper::run(input, |input| { self.unicode_string_literal(input) - .with_label(NodeLabel::Item) + .with_label(EdgeLabel::Item) }) } else { ParserResult::disabled() } - .with_kind(RuleKind::UnicodeStringLiterals) + .with_kind(NonTerminalKind::UnicodeStringLiterals) } #[allow(unused_assignments, unused_parens)] @@ -5032,62 +5035,62 @@ impl Language { if !self.version_is_at_least_0_5_0 { let result = self.parse_token_with_trivia::( input, - TokenKind::ConstantKeyword, + TerminalKind::ConstantKeyword, ); choice.consider(input, result)?; } let result = self.parse_token_with_trivia::( input, - TokenKind::ExternalKeyword, + TerminalKind::ExternalKeyword, ); choice.consider(input, result)?; if !self.version_is_at_least_0_5_0 { let result = self.parse_token_with_trivia::( input, - TokenKind::InternalKeyword, + TerminalKind::InternalKeyword, ); choice.consider(input, result)?; } let result = self.parse_token_with_trivia::( input, - TokenKind::PayableKeyword, + TerminalKind::PayableKeyword, ); choice.consider(input, result)?; if !self.version_is_at_least_0_5_0 { let result = self.parse_token_with_trivia::( input, - TokenKind::PrivateKeyword, + TerminalKind::PrivateKeyword, ); choice.consider(input, result)?; } if !self.version_is_at_least_0_5_0 { let result = self.parse_token_with_trivia::( input, - TokenKind::PublicKeyword, + TerminalKind::PublicKeyword, ); choice.consider(input, result)?; } if self.version_is_at_least_0_4_16 && !self.version_is_at_least_0_6_0 { let result = self.parse_token_with_trivia::( input, - TokenKind::PureKeyword, + TerminalKind::PureKeyword, ); choice.consider(input, result)?; } if self.version_is_at_least_0_4_16 && !self.version_is_at_least_0_6_0 { let result = self.parse_token_with_trivia::( input, - TokenKind::ViewKeyword, + TerminalKind::ViewKeyword, ); choice.consider(input, result)?; } choice.finish(input) }) - .with_label(NodeLabel::Variant) + .with_label(EdgeLabel::Variant) } else { ParserResult::disabled() } - .with_kind(RuleKind::UnnamedFunctionAttribute) + .with_kind(NonTerminalKind::UnnamedFunctionAttribute) } #[allow(unused_assignments, unused_parens)] @@ -5095,12 +5098,12 @@ impl Language { if !self.version_is_at_least_0_6_0 { ZeroOrMoreHelper::run(input, |input| { self.unnamed_function_attribute(input) - .with_label(NodeLabel::Item) + .with_label(EdgeLabel::Item) }) } else { ParserResult::disabled() } - .with_kind(RuleKind::UnnamedFunctionAttributes) + .with_kind(NonTerminalKind::UnnamedFunctionAttributes) } #[allow(unused_assignments, unused_parens)] @@ -5108,43 +5111,43 @@ impl Language { if !self.version_is_at_least_0_6_0 { SequenceHelper::run(|mut seq| { seq.elem_labeled( - NodeLabel::FunctionKeyword, + EdgeLabel::FunctionKeyword, self.parse_token_with_trivia::( input, - TokenKind::FunctionKeyword, + TerminalKind::FunctionKeyword, ), )?; - seq.elem_labeled(NodeLabel::Parameters, self.parameters_declaration(input))?; + seq.elem_labeled(EdgeLabel::Parameters, self.parameters_declaration(input))?; seq.elem_labeled( - NodeLabel::Attributes, + EdgeLabel::Attributes, self.unnamed_function_attributes(input), )?; - seq.elem_labeled(NodeLabel::Body, self.function_body(input))?; + seq.elem_labeled(EdgeLabel::Body, self.function_body(input))?; seq.finish() }) } else { ParserResult::disabled() } - .with_kind(RuleKind::UnnamedFunctionDefinition) + .with_kind(NonTerminalKind::UnnamedFunctionDefinition) } #[allow(unused_assignments, unused_parens)] fn untyped_tuple_member(&self, input: &mut ParserContext<'_>) -> ParserResult { SequenceHelper::run(|mut seq| { seq.elem_labeled( - NodeLabel::StorageLocation, + EdgeLabel::StorageLocation, OptionalHelper::transform(self.storage_location(input)), )?; seq.elem_labeled( - NodeLabel::Name, + EdgeLabel::Name, self.parse_token_with_trivia::( input, - TokenKind::Identifier, + TerminalKind::Identifier, ), )?; seq.finish() }) - .with_kind(RuleKind::UntypedTupleMember) + .with_kind(NonTerminalKind::UntypedTupleMember) } #[allow(unused_assignments, unused_parens)] @@ -5154,41 +5157,41 @@ impl Language { seq.elem( SequenceHelper::run(|mut seq| { seq.elem_labeled( - NodeLabel::TypeKeyword, + EdgeLabel::TypeKeyword, self.parse_token_with_trivia::( input, - TokenKind::TypeKeyword, + TerminalKind::TypeKeyword, ), )?; seq.elem_labeled( - NodeLabel::Name, + EdgeLabel::Name, self.parse_token_with_trivia::( input, - TokenKind::Identifier, + TerminalKind::Identifier, ), )?; seq.elem_labeled( - NodeLabel::IsKeyword, + EdgeLabel::IsKeyword, self.parse_token_with_trivia::( input, - TokenKind::IsKeyword, + TerminalKind::IsKeyword, ), )?; - seq.elem_labeled(NodeLabel::ValueType, self.elementary_type(input))?; + seq.elem_labeled(EdgeLabel::ValueType, self.elementary_type(input))?; seq.finish() }) .recover_until_with_nested_delims::<_, LexicalContextType::Default>( input, self, - TokenKind::Semicolon, + TerminalKind::Semicolon, TokenAcceptanceThreshold(1u8), ), )?; seq.elem_labeled( - NodeLabel::Semicolon, + EdgeLabel::Semicolon, self.parse_token_with_trivia::( input, - TokenKind::Semicolon, + TerminalKind::Semicolon, ), )?; seq.finish() @@ -5196,7 +5199,7 @@ impl Language { } else { ParserResult::disabled() } - .with_kind(RuleKind::UserDefinedValueTypeDefinition) + .with_kind(NonTerminalKind::UserDefinedValueTypeDefinition) } #[allow(unused_assignments, unused_parens)] @@ -5204,19 +5207,19 @@ impl Language { if self.version_is_at_least_0_8_19 { SequenceHelper::run(|mut seq| { seq.elem_labeled( - NodeLabel::AsKeyword, + EdgeLabel::AsKeyword, self.parse_token_with_trivia::( input, - TokenKind::AsKeyword, + TerminalKind::AsKeyword, ), )?; - seq.elem_labeled(NodeLabel::Operator, self.using_operator(input))?; + seq.elem_labeled(EdgeLabel::Operator, self.using_operator(input))?; seq.finish() }) } else { ParserResult::disabled() } - .with_kind(RuleKind::UsingAlias) + .with_kind(NonTerminalKind::UsingAlias) } #[allow(unused_assignments, unused_parens)] @@ -5230,38 +5233,38 @@ impl Language { } choice.finish(input) }) - .with_label(NodeLabel::Variant) - .with_kind(RuleKind::UsingClause) + .with_label(EdgeLabel::Variant) + .with_kind(NonTerminalKind::UsingClause) } #[allow(unused_assignments, unused_parens)] fn using_deconstruction(&self, input: &mut ParserContext<'_>) -> ParserResult { if self.version_is_at_least_0_8_13 { SequenceHelper::run(|mut seq| { - let mut delim_guard = input.open_delim(TokenKind::CloseBrace); + let mut delim_guard = input.open_delim(TerminalKind::CloseBrace); let input = delim_guard.ctx(); seq.elem_labeled( - NodeLabel::OpenBrace, + EdgeLabel::OpenBrace, self.parse_token_with_trivia::( input, - TokenKind::OpenBrace, + TerminalKind::OpenBrace, ), )?; seq.elem( self.using_deconstruction_symbols(input) - .with_label(NodeLabel::Symbols) + .with_label(EdgeLabel::Symbols) .recover_until_with_nested_delims::<_, LexicalContextType::Default>( input, self, - TokenKind::CloseBrace, + TerminalKind::CloseBrace, TokenAcceptanceThreshold(0u8), ), )?; seq.elem_labeled( - NodeLabel::CloseBrace, + EdgeLabel::CloseBrace, self.parse_token_with_trivia::( input, - TokenKind::CloseBrace, + TerminalKind::CloseBrace, ), )?; seq.finish() @@ -5269,17 +5272,17 @@ impl Language { } else { ParserResult::disabled() } - .with_kind(RuleKind::UsingDeconstruction) + .with_kind(NonTerminalKind::UsingDeconstruction) } #[allow(unused_assignments, unused_parens)] fn using_deconstruction_symbol(&self, input: &mut ParserContext<'_>) -> ParserResult { if self.version_is_at_least_0_8_13 { SequenceHelper::run(|mut seq| { - seq.elem_labeled(NodeLabel::Name, self.identifier_path(input))?; + seq.elem_labeled(EdgeLabel::Name, self.identifier_path(input))?; if self.version_is_at_least_0_8_19 { seq.elem_labeled( - NodeLabel::Alias, + EdgeLabel::Alias, OptionalHelper::transform(self.using_alias(input)), )?; } @@ -5288,7 +5291,7 @@ impl Language { } else { ParserResult::disabled() } - .with_kind(RuleKind::UsingDeconstructionSymbol) + .with_kind(NonTerminalKind::UsingDeconstructionSymbol) } #[allow(unused_assignments, unused_parens)] @@ -5299,15 +5302,15 @@ impl Language { self, |input| { self.using_deconstruction_symbol(input) - .with_label(NodeLabel::Item) + .with_label(EdgeLabel::Item) }, - TokenKind::Comma, - NodeLabel::Separator, + TerminalKind::Comma, + EdgeLabel::Separator, ) } else { ParserResult::disabled() } - .with_kind(RuleKind::UsingDeconstructionSymbols) + .with_kind(NonTerminalKind::UsingDeconstructionSymbols) } #[allow(unused_assignments, unused_parens)] @@ -5316,28 +5319,28 @@ impl Language { seq.elem( SequenceHelper::run(|mut seq| { seq.elem_labeled( - NodeLabel::UsingKeyword, + EdgeLabel::UsingKeyword, self.parse_token_with_trivia::( input, - TokenKind::UsingKeyword, + TerminalKind::UsingKeyword, ), )?; - seq.elem_labeled(NodeLabel::Clause, self.using_clause(input))?; + seq.elem_labeled(EdgeLabel::Clause, self.using_clause(input))?; seq.elem_labeled( - NodeLabel::ForKeyword, + EdgeLabel::ForKeyword, self.parse_token_with_trivia::( input, - TokenKind::ForKeyword, + TerminalKind::ForKeyword, ), )?; - seq.elem_labeled(NodeLabel::Target, self.using_target(input))?; + seq.elem_labeled(EdgeLabel::Target, self.using_target(input))?; if self.version_is_at_least_0_8_13 { seq.elem_labeled( - NodeLabel::GlobalKeyword, + EdgeLabel::GlobalKeyword, OptionalHelper::transform( self.parse_token_with_trivia::( input, - TokenKind::GlobalKeyword, + TerminalKind::GlobalKeyword, ), ), )?; @@ -5347,20 +5350,20 @@ impl Language { .recover_until_with_nested_delims::<_, LexicalContextType::Default>( input, self, - TokenKind::Semicolon, + TerminalKind::Semicolon, TokenAcceptanceThreshold(1u8), ), )?; seq.elem_labeled( - NodeLabel::Semicolon, + EdgeLabel::Semicolon, self.parse_token_with_trivia::( input, - TokenKind::Semicolon, + TerminalKind::Semicolon, ), )?; seq.finish() }) - .with_kind(RuleKind::UsingDirective) + .with_kind(NonTerminalKind::UsingDirective) } #[allow(unused_assignments, unused_parens)] @@ -5369,82 +5372,86 @@ impl Language { ChoiceHelper::run(input, |mut choice, input| { let result = self.parse_token_with_trivia::( input, - TokenKind::Ampersand, + TerminalKind::Ampersand, ); choice.consider(input, result)?; let result = self.parse_token_with_trivia::( input, - TokenKind::Asterisk, + TerminalKind::Asterisk, ); choice.consider(input, result)?; let result = self.parse_token_with_trivia::( input, - TokenKind::BangEqual, + TerminalKind::BangEqual, ); choice.consider(input, result)?; - let result = self - .parse_token_with_trivia::(input, TokenKind::Bar); + let result = self.parse_token_with_trivia::( + input, + TerminalKind::Bar, + ); choice.consider(input, result)?; let result = self.parse_token_with_trivia::( input, - TokenKind::Caret, + TerminalKind::Caret, ); choice.consider(input, result)?; let result = self.parse_token_with_trivia::( input, - TokenKind::EqualEqual, + TerminalKind::EqualEqual, ); choice.consider(input, result)?; let result = self.parse_token_with_trivia::( input, - TokenKind::GreaterThan, + TerminalKind::GreaterThan, ); choice.consider(input, result)?; let result = self.parse_token_with_trivia::( input, - TokenKind::GreaterThanEqual, + TerminalKind::GreaterThanEqual, ); choice.consider(input, result)?; let result = self.parse_token_with_trivia::( input, - TokenKind::LessThan, + TerminalKind::LessThan, ); choice.consider(input, result)?; let result = self.parse_token_with_trivia::( input, - TokenKind::LessThanEqual, + TerminalKind::LessThanEqual, ); choice.consider(input, result)?; let result = self.parse_token_with_trivia::( input, - TokenKind::Minus, + TerminalKind::Minus, ); choice.consider(input, result)?; let result = self.parse_token_with_trivia::( input, - TokenKind::Percent, + TerminalKind::Percent, ); choice.consider(input, result)?; - let result = self - .parse_token_with_trivia::(input, TokenKind::Plus); + let result = self.parse_token_with_trivia::( + input, + TerminalKind::Plus, + ); choice.consider(input, result)?; let result = self.parse_token_with_trivia::( input, - TokenKind::Slash, + TerminalKind::Slash, ); choice.consider(input, result)?; let result = self.parse_token_with_trivia::( input, - TokenKind::Tilde, + TerminalKind::Tilde, ); choice.consider(input, result)?; choice.finish(input) }) - .with_label(NodeLabel::Variant) + .with_label(EdgeLabel::Variant) } else { ParserResult::disabled() } - .with_kind(RuleKind::UsingOperator) + .with_kind(NonTerminalKind::UsingOperator) } #[allow(unused_assignments, unused_parens)] @@ -5452,13 +5459,15 @@ impl Language { ChoiceHelper::run(input, |mut choice, input| { let result = self.type_name(input); choice.consider(input, result)?; - let result = self - .parse_token_with_trivia::(input, TokenKind::Asterisk); + let result = self.parse_token_with_trivia::( + input, + TerminalKind::Asterisk, + ); choice.consider(input, result)?; choice.finish(input) }) - .with_label(NodeLabel::Variant) - .with_kind(RuleKind::UsingTarget) + .with_label(EdgeLabel::Variant) + .with_kind(NonTerminalKind::UsingTarget) } #[allow(unused_assignments, unused_parens)] @@ -5467,22 +5476,22 @@ impl Language { seq.elem( SequenceHelper::run(|mut seq| { seq.elem_labeled( - NodeLabel::VariableType, + EdgeLabel::VariableType, self.variable_declaration_type(input), )?; seq.elem_labeled( - NodeLabel::StorageLocation, + EdgeLabel::StorageLocation, OptionalHelper::transform(self.storage_location(input)), )?; seq.elem_labeled( - NodeLabel::Name, + EdgeLabel::Name, self.parse_token_with_trivia::( input, - TokenKind::Identifier, + TerminalKind::Identifier, ), )?; seq.elem_labeled( - NodeLabel::Value, + EdgeLabel::Value, OptionalHelper::transform(self.variable_declaration_value(input)), )?; seq.finish() @@ -5490,20 +5499,20 @@ impl Language { .recover_until_with_nested_delims::<_, LexicalContextType::Default>( input, self, - TokenKind::Semicolon, + TerminalKind::Semicolon, TokenAcceptanceThreshold(1u8), ), )?; seq.elem_labeled( - NodeLabel::Semicolon, + EdgeLabel::Semicolon, self.parse_token_with_trivia::( input, - TokenKind::Semicolon, + TerminalKind::Semicolon, ), )?; seq.finish() }) - .with_kind(RuleKind::VariableDeclarationStatement) + .with_kind(NonTerminalKind::VariableDeclarationStatement) } #[allow(unused_assignments, unused_parens)] @@ -5514,30 +5523,30 @@ impl Language { if !self.version_is_at_least_0_5_0 { let result = self.parse_token_with_trivia::( input, - TokenKind::VarKeyword, + TerminalKind::VarKeyword, ); choice.consider(input, result)?; } choice.finish(input) }) - .with_label(NodeLabel::Variant) - .with_kind(RuleKind::VariableDeclarationType) + .with_label(EdgeLabel::Variant) + .with_kind(NonTerminalKind::VariableDeclarationType) } #[allow(unused_assignments, unused_parens)] fn variable_declaration_value(&self, input: &mut ParserContext<'_>) -> ParserResult { SequenceHelper::run(|mut seq| { seq.elem_labeled( - NodeLabel::Equal, + EdgeLabel::Equal, self.parse_token_with_trivia::( input, - TokenKind::Equal, + TerminalKind::Equal, ), )?; - seq.elem_labeled(NodeLabel::Expression, self.expression(input))?; + seq.elem_labeled(EdgeLabel::Expression, self.expression(input))?; seq.finish() }) - .with_kind(RuleKind::VariableDeclarationValue) + .with_kind(NonTerminalKind::VariableDeclarationValue) } #[allow(unused_assignments, unused_parens)] @@ -5547,14 +5556,14 @@ impl Language { return result; }; match &r#match.nodes[..] { - [cst::LabeledNode { - label: _, - node: cst::Node::Rule(node), - }] if node.kind == RuleKind::VersionExpression => match &node.children[..] { - [inner @ cst::LabeledNode { - label: _, - node: cst::Node::Rule(rule), - }] if rule.kind == RuleKind::VersionComparator => { + [cst::Edge { + node: cst::Node::NonTerminal(node), + .. + }] if node.kind == NonTerminalKind::VersionExpression => match &node.children[..] { + [inner @ cst::Edge { + node: cst::Node::NonTerminal(node), + .. + }] if node.kind == NonTerminalKind::VersionComparator => { ParserResult::r#match(vec![inner.clone()], r#match.expected_tokens.clone()) } _ => ParserResult::no_match(vec![]), @@ -5567,66 +5576,69 @@ impl Language { fn version_expression(&self, input: &mut ParserContext<'_>) -> ParserResult { let parse_left_version_range = |input: &mut ParserContext<'_>| { PrecedenceHelper::to_binary_operator( - RuleKind::VersionRange, + NonTerminalKind::VersionRange, 1u8, 1u8 + 1, - self.parse_token_with_trivia::(input, TokenKind::Minus) - .with_label(NodeLabel::Operator), + self.parse_token_with_trivia::( + input, + TerminalKind::Minus, + ) + .with_label(EdgeLabel::Operator), ) }; let parse_prefix_version_comparator = |input: &mut ParserContext<'_>| { PrecedenceHelper::to_prefix_operator( - RuleKind::VersionComparator, + NonTerminalKind::VersionComparator, 3u8, ChoiceHelper::run(input, |mut choice, input| { let result = self .parse_token_with_trivia::( input, - TokenKind::Caret, + TerminalKind::Caret, ) - .with_label(NodeLabel::Operator); + .with_label(EdgeLabel::Operator); choice.consider(input, result)?; let result = self .parse_token_with_trivia::( input, - TokenKind::Tilde, + TerminalKind::Tilde, ) - .with_label(NodeLabel::Operator); + .with_label(EdgeLabel::Operator); choice.consider(input, result)?; let result = self .parse_token_with_trivia::( input, - TokenKind::Equal, + TerminalKind::Equal, ) - .with_label(NodeLabel::Operator); + .with_label(EdgeLabel::Operator); choice.consider(input, result)?; let result = self .parse_token_with_trivia::( input, - TokenKind::LessThan, + TerminalKind::LessThan, ) - .with_label(NodeLabel::Operator); + .with_label(EdgeLabel::Operator); choice.consider(input, result)?; let result = self .parse_token_with_trivia::( input, - TokenKind::GreaterThan, + TerminalKind::GreaterThan, ) - .with_label(NodeLabel::Operator); + .with_label(EdgeLabel::Operator); choice.consider(input, result)?; let result = self .parse_token_with_trivia::( input, - TokenKind::LessThanEqual, + TerminalKind::LessThanEqual, ) - .with_label(NodeLabel::Operator); + .with_label(EdgeLabel::Operator); choice.consider(input, result)?; let result = self .parse_token_with_trivia::( input, - TokenKind::GreaterThanEqual, + TerminalKind::GreaterThanEqual, ) - .with_label(NodeLabel::Operator); + .with_label(EdgeLabel::Operator); choice.consider(input, result)?; choice.finish(input) }), @@ -5645,17 +5657,17 @@ impl Language { choice.consider(input, result)?; let result = self.parse_token_with_trivia::( input, - TokenKind::SingleQuotedVersionLiteral, + TerminalKind::SingleQuotedVersionLiteral, ); choice.consider(input, result)?; let result = self.parse_token_with_trivia::( input, - TokenKind::DoubleQuotedVersionLiteral, + TerminalKind::DoubleQuotedVersionLiteral, ); choice.consider(input, result)?; choice.finish(input) }) - .with_label(NodeLabel::Variant) + .with_label(EdgeLabel::Variant) }; let binary_operand_parser = |input: &mut ParserContext<'_>| { SequenceHelper::run(|mut seq| { @@ -5685,18 +5697,18 @@ impl Language { }) }; PrecedenceHelper::reduce_precedence_result( - RuleKind::VersionExpression, + NonTerminalKind::VersionExpression, linear_expression_parser(input), ) - .with_kind(RuleKind::VersionExpression) + .with_kind(NonTerminalKind::VersionExpression) } #[allow(unused_assignments, unused_parens)] fn version_expression_set(&self, input: &mut ParserContext<'_>) -> ParserResult { OneOrMoreHelper::run(input, |input| { - self.version_expression(input).with_label(NodeLabel::Item) + self.version_expression(input).with_label(EdgeLabel::Item) }) - .with_kind(RuleKind::VersionExpressionSet) + .with_kind(NonTerminalKind::VersionExpressionSet) } #[allow(unused_assignments, unused_parens)] @@ -5706,28 +5718,28 @@ impl Language { self, |input| { self.version_expression_set(input) - .with_label(NodeLabel::Item) + .with_label(EdgeLabel::Item) }, - TokenKind::BarBar, - NodeLabel::Separator, + TerminalKind::BarBar, + EdgeLabel::Separator, ) - .with_kind(RuleKind::VersionExpressionSets) + .with_kind(NonTerminalKind::VersionExpressionSets) } #[allow(unused_assignments, unused_parens)] fn version_pragma(&self, input: &mut ParserContext<'_>) -> ParserResult { SequenceHelper::run(|mut seq| { seq.elem_labeled( - NodeLabel::SolidityKeyword, + EdgeLabel::SolidityKeyword, self.parse_token_with_trivia::( input, - TokenKind::SolidityKeyword, + TerminalKind::SolidityKeyword, ), )?; - seq.elem_labeled(NodeLabel::Sets, self.version_expression_sets(input))?; + seq.elem_labeled(EdgeLabel::Sets, self.version_expression_sets(input))?; seq.finish() }) - .with_kind(RuleKind::VersionPragma) + .with_kind(NonTerminalKind::VersionPragma) } #[allow(unused_assignments, unused_parens)] @@ -5737,14 +5749,14 @@ impl Language { return result; }; match &r#match.nodes[..] { - [cst::LabeledNode { - label: _, - node: cst::Node::Rule(node), - }] if node.kind == RuleKind::VersionExpression => match &node.children[..] { - [inner @ cst::LabeledNode { - label: _, - node: cst::Node::Rule(rule), - }] if rule.kind == RuleKind::VersionRange => { + [cst::Edge { + node: cst::Node::NonTerminal(node), + .. + }] if node.kind == NonTerminalKind::VersionExpression => match &node.children[..] { + [inner @ cst::Edge { + node: cst::Node::NonTerminal(node), + .. + }] if node.kind == NonTerminalKind::VersionRange => { ParserResult::r#match(vec![inner.clone()], r#match.expected_tokens.clone()) } _ => ParserResult::no_match(vec![]), @@ -5761,59 +5773,59 @@ impl Language { |input| { self.parse_token_with_trivia::( input, - TokenKind::VersionSpecifier, + TerminalKind::VersionSpecifier, ) - .with_label(NodeLabel::Item) + .with_label(EdgeLabel::Item) }, - TokenKind::Period, - NodeLabel::Separator, + TerminalKind::Period, + EdgeLabel::Separator, ) - .with_kind(RuleKind::VersionSpecifiers) + .with_kind(NonTerminalKind::VersionSpecifiers) } #[allow(unused_assignments, unused_parens)] fn while_statement(&self, input: &mut ParserContext<'_>) -> ParserResult { SequenceHelper::run(|mut seq| { seq.elem_labeled( - NodeLabel::WhileKeyword, + EdgeLabel::WhileKeyword, self.parse_token_with_trivia::( input, - TokenKind::WhileKeyword, + TerminalKind::WhileKeyword, ), )?; seq.elem(SequenceHelper::run(|mut seq| { - let mut delim_guard = input.open_delim(TokenKind::CloseParen); + let mut delim_guard = input.open_delim(TerminalKind::CloseParen); let input = delim_guard.ctx(); seq.elem_labeled( - NodeLabel::OpenParen, + EdgeLabel::OpenParen, self.parse_token_with_trivia::( input, - TokenKind::OpenParen, + TerminalKind::OpenParen, ), )?; seq.elem( self.expression(input) - .with_label(NodeLabel::Condition) + .with_label(EdgeLabel::Condition) .recover_until_with_nested_delims::<_, LexicalContextType::Default>( input, self, - TokenKind::CloseParen, + TerminalKind::CloseParen, TokenAcceptanceThreshold(0u8), ), )?; seq.elem_labeled( - NodeLabel::CloseParen, + EdgeLabel::CloseParen, self.parse_token_with_trivia::( input, - TokenKind::CloseParen, + TerminalKind::CloseParen, ), )?; seq.finish() }))?; - seq.elem_labeled(NodeLabel::Body, self.statement(input))?; + seq.elem_labeled(EdgeLabel::Body, self.statement(input))?; seq.finish() }) - .with_kind(RuleKind::WhileStatement) + .with_kind(NonTerminalKind::WhileStatement) } #[allow(unused_assignments, unused_parens)] @@ -5821,11 +5833,11 @@ impl Language { OptionalHelper::transform(SeparatedHelper::run::<_, LexicalContextType::Yul>( input, self, - |input| self.yul_expression(input).with_label(NodeLabel::Item), - TokenKind::Comma, - NodeLabel::Separator, + |input| self.yul_expression(input).with_label(EdgeLabel::Item), + TerminalKind::Comma, + EdgeLabel::Separator, )) - .with_kind(RuleKind::YulArguments) + .with_kind(NonTerminalKind::YulArguments) } #[allow(unused_assignments, unused_parens)] @@ -5835,65 +5847,70 @@ impl Language { let result = self.yul_colon_and_equal(input); choice.consider(input, result)?; } - let result = self - .parse_token_with_trivia::(input, TokenKind::ColonEqual); + let result = self.parse_token_with_trivia::( + input, + TerminalKind::ColonEqual, + ); choice.consider(input, result)?; choice.finish(input) }) - .with_label(NodeLabel::Variant) - .with_kind(RuleKind::YulAssignmentOperator) + .with_label(EdgeLabel::Variant) + .with_kind(NonTerminalKind::YulAssignmentOperator) } #[allow(unused_assignments, unused_parens)] fn yul_assignment_statement(&self, input: &mut ParserContext<'_>) -> ParserResult { SequenceHelper::run(|mut seq| { - seq.elem_labeled(NodeLabel::Names, self.yul_paths(input))?; - seq.elem_labeled(NodeLabel::Assignment, self.yul_assignment_operator(input))?; - seq.elem_labeled(NodeLabel::Expression, self.yul_expression(input))?; + seq.elem_labeled(EdgeLabel::Names, self.yul_paths(input))?; + seq.elem_labeled(EdgeLabel::Assignment, self.yul_assignment_operator(input))?; + seq.elem_labeled(EdgeLabel::Expression, self.yul_expression(input))?; seq.finish() }) - .with_kind(RuleKind::YulAssignmentStatement) + .with_kind(NonTerminalKind::YulAssignmentStatement) } #[allow(unused_assignments, unused_parens)] fn yul_block(&self, input: &mut ParserContext<'_>) -> ParserResult { SequenceHelper::run(|mut seq| { - let mut delim_guard = input.open_delim(TokenKind::CloseBrace); + let mut delim_guard = input.open_delim(TerminalKind::CloseBrace); let input = delim_guard.ctx(); seq.elem_labeled( - NodeLabel::OpenBrace, + EdgeLabel::OpenBrace, self.parse_token_with_trivia::( input, - TokenKind::OpenBrace, + TerminalKind::OpenBrace, ), )?; seq.elem( self.yul_statements(input) - .with_label(NodeLabel::Statements) + .with_label(EdgeLabel::Statements) .recover_until_with_nested_delims::<_, LexicalContextType::Yul>( input, self, - TokenKind::CloseBrace, + TerminalKind::CloseBrace, TokenAcceptanceThreshold(0u8), ), )?; seq.elem_labeled( - NodeLabel::CloseBrace, + EdgeLabel::CloseBrace, self.parse_token_with_trivia::( input, - TokenKind::CloseBrace, + TerminalKind::CloseBrace, ), )?; seq.finish() }) - .with_kind(RuleKind::YulBlock) + .with_kind(NonTerminalKind::YulBlock) } #[allow(unused_assignments, unused_parens)] fn yul_break_statement(&self, input: &mut ParserContext<'_>) -> ParserResult { - self.parse_token_with_trivia::(input, TokenKind::YulBreakKeyword) - .with_label(NodeLabel::BreakKeyword) - .with_kind(RuleKind::YulBreakStatement) + self.parse_token_with_trivia::( + input, + TerminalKind::YulBreakKeyword, + ) + .with_label(EdgeLabel::BreakKeyword) + .with_kind(NonTerminalKind::YulBreakStatement) } #[allow(unused_assignments, unused_parens)] @@ -5901,437 +5918,445 @@ impl Language { ChoiceHelper::run(input, |mut choice, input| { let result = self.parse_token_with_trivia::( input, - TokenKind::YulAddKeyword, + TerminalKind::YulAddKeyword, ); choice.consider(input, result)?; let result = self.parse_token_with_trivia::( input, - TokenKind::YulAddModKeyword, + TerminalKind::YulAddModKeyword, ); choice.consider(input, result)?; let result = self.parse_token_with_trivia::( input, - TokenKind::YulAddressKeyword, + TerminalKind::YulAddressKeyword, ); choice.consider(input, result)?; let result = self.parse_token_with_trivia::( input, - TokenKind::YulAndKeyword, + TerminalKind::YulAndKeyword, ); choice.consider(input, result)?; let result = self.parse_token_with_trivia::( input, - TokenKind::YulBalanceKeyword, + TerminalKind::YulBalanceKeyword, ); choice.consider(input, result)?; let result = self.parse_token_with_trivia::( input, - TokenKind::YulBlockHashKeyword, + TerminalKind::YulBlockHashKeyword, ); choice.consider(input, result)?; let result = self.parse_token_with_trivia::( input, - TokenKind::YulByteKeyword, + TerminalKind::YulByteKeyword, ); choice.consider(input, result)?; let result = self.parse_token_with_trivia::( input, - TokenKind::YulCallCodeKeyword, + TerminalKind::YulCallCodeKeyword, ); choice.consider(input, result)?; let result = self.parse_token_with_trivia::( input, - TokenKind::YulCallDataCopyKeyword, + TerminalKind::YulCallDataCopyKeyword, ); choice.consider(input, result)?; let result = self.parse_token_with_trivia::( input, - TokenKind::YulCallDataLoadKeyword, + TerminalKind::YulCallDataLoadKeyword, ); choice.consider(input, result)?; let result = self.parse_token_with_trivia::( input, - TokenKind::YulCallDataSizeKeyword, + TerminalKind::YulCallDataSizeKeyword, ); choice.consider(input, result)?; let result = self.parse_token_with_trivia::( input, - TokenKind::YulCallerKeyword, + TerminalKind::YulCallerKeyword, ); choice.consider(input, result)?; let result = self.parse_token_with_trivia::( input, - TokenKind::YulCallKeyword, + TerminalKind::YulCallKeyword, ); choice.consider(input, result)?; let result = self.parse_token_with_trivia::( input, - TokenKind::YulCallValueKeyword, + TerminalKind::YulCallValueKeyword, ); choice.consider(input, result)?; let result = self.parse_token_with_trivia::( input, - TokenKind::YulCoinBaseKeyword, + TerminalKind::YulCoinBaseKeyword, ); choice.consider(input, result)?; let result = self.parse_token_with_trivia::( input, - TokenKind::YulCreateKeyword, + TerminalKind::YulCreateKeyword, ); choice.consider(input, result)?; let result = self.parse_token_with_trivia::( input, - TokenKind::YulDelegateCallKeyword, + TerminalKind::YulDelegateCallKeyword, ); choice.consider(input, result)?; let result = self.parse_token_with_trivia::( input, - TokenKind::YulDivKeyword, + TerminalKind::YulDivKeyword, ); choice.consider(input, result)?; - let result = self - .parse_token_with_trivia::(input, TokenKind::YulEqKeyword); + let result = self.parse_token_with_trivia::( + input, + TerminalKind::YulEqKeyword, + ); choice.consider(input, result)?; let result = self.parse_token_with_trivia::( input, - TokenKind::YulExpKeyword, + TerminalKind::YulExpKeyword, ); choice.consider(input, result)?; let result = self.parse_token_with_trivia::( input, - TokenKind::YulExtCodeCopyKeyword, + TerminalKind::YulExtCodeCopyKeyword, ); choice.consider(input, result)?; let result = self.parse_token_with_trivia::( input, - TokenKind::YulExtCodeSizeKeyword, + TerminalKind::YulExtCodeSizeKeyword, ); choice.consider(input, result)?; let result = self.parse_token_with_trivia::( input, - TokenKind::YulGasKeyword, + TerminalKind::YulGasKeyword, ); choice.consider(input, result)?; let result = self.parse_token_with_trivia::( input, - TokenKind::YulGasLimitKeyword, + TerminalKind::YulGasLimitKeyword, ); choice.consider(input, result)?; let result = self.parse_token_with_trivia::( input, - TokenKind::YulGasPriceKeyword, + TerminalKind::YulGasPriceKeyword, ); choice.consider(input, result)?; - let result = self - .parse_token_with_trivia::(input, TokenKind::YulGtKeyword); + let result = self.parse_token_with_trivia::( + input, + TerminalKind::YulGtKeyword, + ); choice.consider(input, result)?; let result = self.parse_token_with_trivia::( input, - TokenKind::YulInvalidKeyword, + TerminalKind::YulInvalidKeyword, ); choice.consider(input, result)?; let result = self.parse_token_with_trivia::( input, - TokenKind::YulIsZeroKeyword, + TerminalKind::YulIsZeroKeyword, ); choice.consider(input, result)?; let result = self.parse_token_with_trivia::( input, - TokenKind::YulLog0Keyword, + TerminalKind::YulLog0Keyword, ); choice.consider(input, result)?; let result = self.parse_token_with_trivia::( input, - TokenKind::YulLog1Keyword, + TerminalKind::YulLog1Keyword, ); choice.consider(input, result)?; let result = self.parse_token_with_trivia::( input, - TokenKind::YulLog2Keyword, + TerminalKind::YulLog2Keyword, ); choice.consider(input, result)?; let result = self.parse_token_with_trivia::( input, - TokenKind::YulLog3Keyword, + TerminalKind::YulLog3Keyword, ); choice.consider(input, result)?; let result = self.parse_token_with_trivia::( input, - TokenKind::YulLog4Keyword, + TerminalKind::YulLog4Keyword, ); choice.consider(input, result)?; - let result = self - .parse_token_with_trivia::(input, TokenKind::YulLtKeyword); + let result = self.parse_token_with_trivia::( + input, + TerminalKind::YulLtKeyword, + ); choice.consider(input, result)?; let result = self.parse_token_with_trivia::( input, - TokenKind::YulMLoadKeyword, + TerminalKind::YulMLoadKeyword, ); choice.consider(input, result)?; let result = self.parse_token_with_trivia::( input, - TokenKind::YulModKeyword, + TerminalKind::YulModKeyword, ); choice.consider(input, result)?; let result = self.parse_token_with_trivia::( input, - TokenKind::YulMSizeKeyword, + TerminalKind::YulMSizeKeyword, ); choice.consider(input, result)?; let result = self.parse_token_with_trivia::( input, - TokenKind::YulMStore8Keyword, + TerminalKind::YulMStore8Keyword, ); choice.consider(input, result)?; let result = self.parse_token_with_trivia::( input, - TokenKind::YulMStoreKeyword, + TerminalKind::YulMStoreKeyword, ); choice.consider(input, result)?; let result = self.parse_token_with_trivia::( input, - TokenKind::YulMulKeyword, + TerminalKind::YulMulKeyword, ); choice.consider(input, result)?; let result = self.parse_token_with_trivia::( input, - TokenKind::YulMulModKeyword, + TerminalKind::YulMulModKeyword, ); choice.consider(input, result)?; let result = self.parse_token_with_trivia::( input, - TokenKind::YulNotKeyword, + TerminalKind::YulNotKeyword, ); choice.consider(input, result)?; let result = self.parse_token_with_trivia::( input, - TokenKind::YulNumberKeyword, + TerminalKind::YulNumberKeyword, ); choice.consider(input, result)?; let result = self.parse_token_with_trivia::( input, - TokenKind::YulOriginKeyword, + TerminalKind::YulOriginKeyword, ); choice.consider(input, result)?; - let result = self - .parse_token_with_trivia::(input, TokenKind::YulOrKeyword); + let result = self.parse_token_with_trivia::( + input, + TerminalKind::YulOrKeyword, + ); choice.consider(input, result)?; let result = self.parse_token_with_trivia::( input, - TokenKind::YulPopKeyword, + TerminalKind::YulPopKeyword, ); choice.consider(input, result)?; let result = self.parse_token_with_trivia::( input, - TokenKind::YulReturnKeyword, + TerminalKind::YulReturnKeyword, ); choice.consider(input, result)?; let result = self.parse_token_with_trivia::( input, - TokenKind::YulRevertKeyword, + TerminalKind::YulRevertKeyword, ); choice.consider(input, result)?; let result = self.parse_token_with_trivia::( input, - TokenKind::YulSDivKeyword, + TerminalKind::YulSDivKeyword, ); choice.consider(input, result)?; let result = self.parse_token_with_trivia::( input, - TokenKind::YulSelfDestructKeyword, + TerminalKind::YulSelfDestructKeyword, ); choice.consider(input, result)?; let result = self.parse_token_with_trivia::( input, - TokenKind::YulSgtKeyword, + TerminalKind::YulSgtKeyword, ); choice.consider(input, result)?; let result = self.parse_token_with_trivia::( input, - TokenKind::YulSignExtendKeyword, + TerminalKind::YulSignExtendKeyword, ); choice.consider(input, result)?; let result = self.parse_token_with_trivia::( input, - TokenKind::YulSLoadKeyword, + TerminalKind::YulSLoadKeyword, ); choice.consider(input, result)?; let result = self.parse_token_with_trivia::( input, - TokenKind::YulSltKeyword, + TerminalKind::YulSltKeyword, ); choice.consider(input, result)?; let result = self.parse_token_with_trivia::( input, - TokenKind::YulSModKeyword, + TerminalKind::YulSModKeyword, ); choice.consider(input, result)?; let result = self.parse_token_with_trivia::( input, - TokenKind::YulSStoreKeyword, + TerminalKind::YulSStoreKeyword, ); choice.consider(input, result)?; let result = self.parse_token_with_trivia::( input, - TokenKind::YulStopKeyword, + TerminalKind::YulStopKeyword, ); choice.consider(input, result)?; let result = self.parse_token_with_trivia::( input, - TokenKind::YulSubKeyword, + TerminalKind::YulSubKeyword, ); choice.consider(input, result)?; let result = self.parse_token_with_trivia::( input, - TokenKind::YulTimestampKeyword, + TerminalKind::YulTimestampKeyword, ); choice.consider(input, result)?; let result = self.parse_token_with_trivia::( input, - TokenKind::YulXorKeyword, + TerminalKind::YulXorKeyword, ); choice.consider(input, result)?; if self.version_is_at_least_0_4_12 { let result = self.parse_token_with_trivia::( input, - TokenKind::YulKeccak256Keyword, + TerminalKind::YulKeccak256Keyword, ); choice.consider(input, result)?; } if !self.version_is_at_least_0_5_0 { let result = self.parse_token_with_trivia::( input, - TokenKind::YulSha3Keyword, + TerminalKind::YulSha3Keyword, ); choice.consider(input, result)?; } if !self.version_is_at_least_0_5_0 { let result = self.parse_token_with_trivia::( input, - TokenKind::YulSuicideKeyword, + TerminalKind::YulSuicideKeyword, ); choice.consider(input, result)?; } if self.version_is_at_least_0_4_12 { let result = self.parse_token_with_trivia::( input, - TokenKind::YulReturnDataCopyKeyword, + TerminalKind::YulReturnDataCopyKeyword, ); choice.consider(input, result)?; } if self.version_is_at_least_0_4_12 { let result = self.parse_token_with_trivia::( input, - TokenKind::YulReturnDataSizeKeyword, + TerminalKind::YulReturnDataSizeKeyword, ); choice.consider(input, result)?; } if self.version_is_at_least_0_4_12 { let result = self.parse_token_with_trivia::( input, - TokenKind::YulStaticCallKeyword, + TerminalKind::YulStaticCallKeyword, ); choice.consider(input, result)?; } if self.version_is_at_least_0_4_12 { let result = self.parse_token_with_trivia::( input, - TokenKind::YulCreate2Keyword, + TerminalKind::YulCreate2Keyword, ); choice.consider(input, result)?; } if self.version_is_at_least_0_5_0 { let result = self.parse_token_with_trivia::( input, - TokenKind::YulExtCodeHashKeyword, + TerminalKind::YulExtCodeHashKeyword, ); choice.consider(input, result)?; } let result = self.parse_token_with_trivia::( input, - TokenKind::YulSarKeyword, + TerminalKind::YulSarKeyword, ); choice.consider(input, result)?; let result = self.parse_token_with_trivia::( input, - TokenKind::YulShlKeyword, + TerminalKind::YulShlKeyword, ); choice.consider(input, result)?; let result = self.parse_token_with_trivia::( input, - TokenKind::YulShrKeyword, + TerminalKind::YulShrKeyword, ); choice.consider(input, result)?; let result = self.parse_token_with_trivia::( input, - TokenKind::YulChainIdKeyword, + TerminalKind::YulChainIdKeyword, ); choice.consider(input, result)?; let result = self.parse_token_with_trivia::( input, - TokenKind::YulSelfBalanceKeyword, + TerminalKind::YulSelfBalanceKeyword, ); choice.consider(input, result)?; if self.version_is_at_least_0_8_7 { let result = self.parse_token_with_trivia::( input, - TokenKind::YulBaseFeeKeyword, + TerminalKind::YulBaseFeeKeyword, ); choice.consider(input, result)?; } if !self.version_is_at_least_0_8_18 { let result = self.parse_token_with_trivia::( input, - TokenKind::YulDifficultyKeyword, + TerminalKind::YulDifficultyKeyword, ); choice.consider(input, result)?; } if self.version_is_at_least_0_8_18 { let result = self.parse_token_with_trivia::( input, - TokenKind::YulPrevRandaoKeyword, + TerminalKind::YulPrevRandaoKeyword, ); choice.consider(input, result)?; } if self.version_is_at_least_0_8_24 { let result = self.parse_token_with_trivia::( input, - TokenKind::YulBlobBaseFeeKeyword, + TerminalKind::YulBlobBaseFeeKeyword, ); choice.consider(input, result)?; } if self.version_is_at_least_0_8_24 { let result = self.parse_token_with_trivia::( input, - TokenKind::YulBlobHashKeyword, + TerminalKind::YulBlobHashKeyword, ); choice.consider(input, result)?; } if self.version_is_at_least_0_8_24 { let result = self.parse_token_with_trivia::( input, - TokenKind::YulTLoadKeyword, + TerminalKind::YulTLoadKeyword, ); choice.consider(input, result)?; } if self.version_is_at_least_0_8_24 { let result = self.parse_token_with_trivia::( input, - TokenKind::YulTStoreKeyword, + TerminalKind::YulTStoreKeyword, ); choice.consider(input, result)?; } if self.version_is_at_least_0_8_24 { let result = self.parse_token_with_trivia::( input, - TokenKind::YulMCopyKeyword, + TerminalKind::YulMCopyKeyword, ); choice.consider(input, result)?; } choice.finish(input) }) - .with_label(NodeLabel::Variant) - .with_kind(RuleKind::YulBuiltInFunction) + .with_label(EdgeLabel::Variant) + .with_kind(NonTerminalKind::YulBuiltInFunction) } #[allow(unused_assignments, unused_parens)] @@ -6339,17 +6364,17 @@ impl Language { if !self.version_is_at_least_0_5_5 { SequenceHelper::run(|mut seq| { seq.elem_labeled( - NodeLabel::Colon, + EdgeLabel::Colon, self.parse_token_with_trivia::( input, - TokenKind::Colon, + TerminalKind::Colon, ), )?; seq.elem_labeled( - NodeLabel::Equal, + EdgeLabel::Equal, self.parse_token_with_trivia::( input, - TokenKind::Equal, + TerminalKind::Equal, ), )?; seq.finish() @@ -6357,66 +6382,66 @@ impl Language { } else { ParserResult::disabled() } - .with_kind(RuleKind::YulColonAndEqual) + .with_kind(NonTerminalKind::YulColonAndEqual) } #[allow(unused_assignments, unused_parens)] fn yul_continue_statement(&self, input: &mut ParserContext<'_>) -> ParserResult { self.parse_token_with_trivia::( input, - TokenKind::YulContinueKeyword, + TerminalKind::YulContinueKeyword, ) - .with_label(NodeLabel::ContinueKeyword) - .with_kind(RuleKind::YulContinueStatement) + .with_label(EdgeLabel::ContinueKeyword) + .with_kind(NonTerminalKind::YulContinueStatement) } #[allow(unused_assignments, unused_parens)] fn yul_default_case(&self, input: &mut ParserContext<'_>) -> ParserResult { SequenceHelper::run(|mut seq| { seq.elem_labeled( - NodeLabel::DefaultKeyword, + EdgeLabel::DefaultKeyword, self.parse_token_with_trivia::( input, - TokenKind::YulDefaultKeyword, + TerminalKind::YulDefaultKeyword, ), )?; - seq.elem_labeled(NodeLabel::Body, self.yul_block(input))?; + seq.elem_labeled(EdgeLabel::Body, self.yul_block(input))?; seq.finish() }) - .with_kind(RuleKind::YulDefaultCase) + .with_kind(NonTerminalKind::YulDefaultCase) } #[allow(unused_assignments, unused_parens)] fn yul_expression(&self, input: &mut ParserContext<'_>) -> ParserResult { let parse_postfix_yul_function_call_expression = |input: &mut ParserContext<'_>| { PrecedenceHelper::to_postfix_operator( - RuleKind::YulFunctionCallExpression, + NonTerminalKind::YulFunctionCallExpression, 1u8, SequenceHelper::run(|mut seq| { - let mut delim_guard = input.open_delim(TokenKind::CloseParen); + let mut delim_guard = input.open_delim(TerminalKind::CloseParen); let input = delim_guard.ctx(); seq.elem_labeled( - NodeLabel::OpenParen, + EdgeLabel::OpenParen, self.parse_token_with_trivia::( input, - TokenKind::OpenParen, + TerminalKind::OpenParen, ), )?; seq.elem( self.yul_arguments(input) - .with_label(NodeLabel::Arguments) + .with_label(EdgeLabel::Arguments) .recover_until_with_nested_delims::<_, LexicalContextType::Yul>( input, self, - TokenKind::CloseParen, + TerminalKind::CloseParen, TokenAcceptanceThreshold(0u8), ), )?; seq.elem_labeled( - NodeLabel::CloseParen, + EdgeLabel::CloseParen, self.parse_token_with_trivia::( input, - TokenKind::CloseParen, + TerminalKind::CloseParen, ), )?; seq.finish() @@ -6433,7 +6458,7 @@ impl Language { choice.consider(input, result)?; choice.finish(input) }) - .with_label(NodeLabel::Variant) + .with_label(EdgeLabel::Variant) }; let postfix_operator_parser = |input: &mut ParserContext<'_>| { ChoiceHelper::run(input, |mut choice, input| { @@ -6450,29 +6475,29 @@ impl Language { }) }; PrecedenceHelper::reduce_precedence_result( - RuleKind::YulExpression, + NonTerminalKind::YulExpression, linear_expression_parser(input), ) - .with_kind(RuleKind::YulExpression) + .with_kind(NonTerminalKind::YulExpression) } #[allow(unused_assignments, unused_parens)] fn yul_for_statement(&self, input: &mut ParserContext<'_>) -> ParserResult { SequenceHelper::run(|mut seq| { seq.elem_labeled( - NodeLabel::ForKeyword, + EdgeLabel::ForKeyword, self.parse_token_with_trivia::( input, - TokenKind::YulForKeyword, + TerminalKind::YulForKeyword, ), )?; - seq.elem_labeled(NodeLabel::Initialization, self.yul_block(input))?; - seq.elem_labeled(NodeLabel::Condition, self.yul_expression(input))?; - seq.elem_labeled(NodeLabel::Iterator, self.yul_block(input))?; - seq.elem_labeled(NodeLabel::Body, self.yul_block(input))?; + seq.elem_labeled(EdgeLabel::Initialization, self.yul_block(input))?; + seq.elem_labeled(EdgeLabel::Condition, self.yul_expression(input))?; + seq.elem_labeled(EdgeLabel::Iterator, self.yul_block(input))?; + seq.elem_labeled(EdgeLabel::Body, self.yul_block(input))?; seq.finish() }) - .with_kind(RuleKind::YulForStatement) + .with_kind(NonTerminalKind::YulForStatement) } #[allow(unused_assignments, unused_parens)] @@ -6482,14 +6507,14 @@ impl Language { return result; }; match &r#match.nodes[..] { - [cst::LabeledNode { - label: _, - node: cst::Node::Rule(node), - }] if node.kind == RuleKind::YulExpression => match &node.children[..] { - [inner @ cst::LabeledNode { - label: _, - node: cst::Node::Rule(rule), - }] if rule.kind == RuleKind::YulFunctionCallExpression => { + [cst::Edge { + node: cst::Node::NonTerminal(node), + .. + }] if node.kind == NonTerminalKind::YulExpression => match &node.children[..] { + [inner @ cst::Edge { + node: cst::Node::NonTerminal(node), + .. + }] if node.kind == NonTerminalKind::YulFunctionCallExpression => { ParserResult::r#match(vec![inner.clone()], r#match.expected_tokens.clone()) } _ => ParserResult::no_match(vec![]), @@ -6502,48 +6527,48 @@ impl Language { fn yul_function_definition(&self, input: &mut ParserContext<'_>) -> ParserResult { SequenceHelper::run(|mut seq| { seq.elem_labeled( - NodeLabel::FunctionKeyword, + EdgeLabel::FunctionKeyword, self.parse_token_with_trivia::( input, - TokenKind::YulFunctionKeyword, + TerminalKind::YulFunctionKeyword, ), )?; seq.elem_labeled( - NodeLabel::Name, + EdgeLabel::Name, self.parse_token_with_trivia::( input, - TokenKind::YulIdentifier, + TerminalKind::YulIdentifier, ), )?; seq.elem_labeled( - NodeLabel::Parameters, + EdgeLabel::Parameters, self.yul_parameters_declaration(input), )?; seq.elem_labeled( - NodeLabel::Returns, + EdgeLabel::Returns, OptionalHelper::transform(self.yul_returns_declaration(input)), )?; - seq.elem_labeled(NodeLabel::Body, self.yul_block(input))?; + seq.elem_labeled(EdgeLabel::Body, self.yul_block(input))?; seq.finish() }) - .with_kind(RuleKind::YulFunctionDefinition) + .with_kind(NonTerminalKind::YulFunctionDefinition) } #[allow(unused_assignments, unused_parens)] fn yul_if_statement(&self, input: &mut ParserContext<'_>) -> ParserResult { SequenceHelper::run(|mut seq| { seq.elem_labeled( - NodeLabel::IfKeyword, + EdgeLabel::IfKeyword, self.parse_token_with_trivia::( input, - TokenKind::YulIfKeyword, + TerminalKind::YulIfKeyword, ), )?; - seq.elem_labeled(NodeLabel::Condition, self.yul_expression(input))?; - seq.elem_labeled(NodeLabel::Body, self.yul_block(input))?; + seq.elem_labeled(EdgeLabel::Condition, self.yul_expression(input))?; + seq.elem_labeled(EdgeLabel::Body, self.yul_block(input))?; seq.finish() }) - .with_kind(RuleKind::YulIfStatement) + .with_kind(NonTerminalKind::YulIfStatement) } #[allow(unused_assignments, unused_parens)] @@ -6551,17 +6576,17 @@ impl Language { if !self.version_is_at_least_0_5_0 { SequenceHelper::run(|mut seq| { seq.elem_labeled( - NodeLabel::Label, + EdgeLabel::Label, self.parse_token_with_trivia::( input, - TokenKind::YulIdentifier, + TerminalKind::YulIdentifier, ), )?; seq.elem_labeled( - NodeLabel::Colon, + EdgeLabel::Colon, self.parse_token_with_trivia::( input, - TokenKind::Colon, + TerminalKind::Colon, ), )?; seq.finish() @@ -6569,7 +6594,7 @@ impl Language { } else { ParserResult::disabled() } - .with_kind(RuleKind::YulLabel) + .with_kind(NonTerminalKind::YulLabel) } #[allow(unused_assignments, unused_parens)] @@ -6577,13 +6602,13 @@ impl Language { if self.version_is_at_least_0_6_0 { self.parse_token_with_trivia::( input, - TokenKind::YulLeaveKeyword, + TerminalKind::YulLeaveKeyword, ) - .with_label(NodeLabel::LeaveKeyword) + .with_label(EdgeLabel::LeaveKeyword) } else { ParserResult::disabled() } - .with_kind(RuleKind::YulLeaveStatement) + .with_kind(NonTerminalKind::YulLeaveStatement) } #[allow(unused_assignments, unused_parens)] @@ -6591,22 +6616,22 @@ impl Language { ChoiceHelper::run(input, |mut choice, input| { let result = self.parse_token_with_trivia::( input, - TokenKind::YulTrueKeyword, + TerminalKind::YulTrueKeyword, ); choice.consider(input, result)?; let result = self.parse_token_with_trivia::( input, - TokenKind::YulFalseKeyword, + TerminalKind::YulFalseKeyword, ); choice.consider(input, result)?; let result = self.parse_token_with_trivia::( input, - TokenKind::YulDecimalLiteral, + TerminalKind::YulDecimalLiteral, ); choice.consider(input, result)?; let result = self.parse_token_with_trivia::( input, - TokenKind::YulHexLiteral, + TerminalKind::YulHexLiteral, ); choice.consider(input, result)?; let result = self.hex_string_literal(input); @@ -6615,8 +6640,8 @@ impl Language { choice.consider(input, result)?; choice.finish(input) }) - .with_label(NodeLabel::Variant) - .with_kind(RuleKind::YulLiteral) + .with_label(EdgeLabel::Variant) + .with_kind(NonTerminalKind::YulLiteral) } #[allow(unused_assignments, unused_parens)] @@ -6627,48 +6652,48 @@ impl Language { |input| { self.parse_token_with_trivia::( input, - TokenKind::YulIdentifier, + TerminalKind::YulIdentifier, ) - .with_label(NodeLabel::Item) + .with_label(EdgeLabel::Item) }, - TokenKind::Comma, - NodeLabel::Separator, + TerminalKind::Comma, + EdgeLabel::Separator, )) - .with_kind(RuleKind::YulParameters) + .with_kind(NonTerminalKind::YulParameters) } #[allow(unused_assignments, unused_parens)] fn yul_parameters_declaration(&self, input: &mut ParserContext<'_>) -> ParserResult { SequenceHelper::run(|mut seq| { - let mut delim_guard = input.open_delim(TokenKind::CloseParen); + let mut delim_guard = input.open_delim(TerminalKind::CloseParen); let input = delim_guard.ctx(); seq.elem_labeled( - NodeLabel::OpenParen, + EdgeLabel::OpenParen, self.parse_token_with_trivia::( input, - TokenKind::OpenParen, + TerminalKind::OpenParen, ), )?; seq.elem( self.yul_parameters(input) - .with_label(NodeLabel::Parameters) + .with_label(EdgeLabel::Parameters) .recover_until_with_nested_delims::<_, LexicalContextType::Yul>( input, self, - TokenKind::CloseParen, + TerminalKind::CloseParen, TokenAcceptanceThreshold(0u8), ), )?; seq.elem_labeled( - NodeLabel::CloseParen, + EdgeLabel::CloseParen, self.parse_token_with_trivia::( input, - TokenKind::CloseParen, + TerminalKind::CloseParen, ), )?; seq.finish() }) - .with_kind(RuleKind::YulParametersDeclaration) + .with_kind(NonTerminalKind::YulParametersDeclaration) } #[allow(unused_assignments, unused_parens)] @@ -6676,11 +6701,11 @@ impl Language { SeparatedHelper::run::<_, LexicalContextType::Yul>( input, self, - |input| self.yul_path_component(input).with_label(NodeLabel::Item), - TokenKind::Period, - NodeLabel::Separator, + |input| self.yul_path_component(input).with_label(EdgeLabel::Item), + TerminalKind::Period, + EdgeLabel::Separator, ) - .with_kind(RuleKind::YulPath) + .with_kind(NonTerminalKind::YulPath) } #[allow(unused_assignments, unused_parens)] @@ -6688,20 +6713,20 @@ impl Language { ChoiceHelper::run(input, |mut choice, input| { let result = self.parse_token_with_trivia::( input, - TokenKind::YulIdentifier, + TerminalKind::YulIdentifier, ); choice.consider(input, result)?; if self.version_is_at_least_0_8_10 { let result = self.parse_token_with_trivia::( input, - TokenKind::YulAddressKeyword, + TerminalKind::YulAddressKeyword, ); choice.consider(input, result)?; } choice.finish(input) }) - .with_label(NodeLabel::Variant) - .with_kind(RuleKind::YulPathComponent) + .with_label(EdgeLabel::Variant) + .with_kind(NonTerminalKind::YulPathComponent) } #[allow(unused_assignments, unused_parens)] @@ -6709,11 +6734,11 @@ impl Language { SeparatedHelper::run::<_, LexicalContextType::Yul>( input, self, - |input| self.yul_path(input).with_label(NodeLabel::Item), - TokenKind::Comma, - NodeLabel::Separator, + |input| self.yul_path(input).with_label(EdgeLabel::Item), + TerminalKind::Comma, + EdgeLabel::Separator, ) - .with_kind(RuleKind::YulPaths) + .with_kind(NonTerminalKind::YulPaths) } #[allow(unused_assignments, unused_parens)] @@ -6724,30 +6749,30 @@ impl Language { |input| { self.parse_token_with_trivia::( input, - TokenKind::YulIdentifier, + TerminalKind::YulIdentifier, ) - .with_label(NodeLabel::Item) + .with_label(EdgeLabel::Item) }, - TokenKind::Comma, - NodeLabel::Separator, + TerminalKind::Comma, + EdgeLabel::Separator, ) - .with_kind(RuleKind::YulReturnVariables) + .with_kind(NonTerminalKind::YulReturnVariables) } #[allow(unused_assignments, unused_parens)] fn yul_returns_declaration(&self, input: &mut ParserContext<'_>) -> ParserResult { SequenceHelper::run(|mut seq| { seq.elem_labeled( - NodeLabel::MinusGreaterThan, + EdgeLabel::MinusGreaterThan, self.parse_token_with_trivia::( input, - TokenKind::MinusGreaterThan, + TerminalKind::MinusGreaterThan, ), )?; - seq.elem_labeled(NodeLabel::Variables, self.yul_return_variables(input))?; + seq.elem_labeled(EdgeLabel::Variables, self.yul_return_variables(input))?; seq.finish() }) - .with_kind(RuleKind::YulReturnsDeclaration) + .with_kind(NonTerminalKind::YulReturnsDeclaration) } #[allow(unused_assignments, unused_parens)] @@ -6783,16 +6808,16 @@ impl Language { choice.consider(input, result)?; choice.finish(input) }) - .with_label(NodeLabel::Variant) - .with_kind(RuleKind::YulStatement) + .with_label(EdgeLabel::Variant) + .with_kind(NonTerminalKind::YulStatement) } #[allow(unused_assignments, unused_parens)] fn yul_statements(&self, input: &mut ParserContext<'_>) -> ParserResult { ZeroOrMoreHelper::run(input, |input| { - self.yul_statement(input).with_label(NodeLabel::Item) + self.yul_statement(input).with_label(EdgeLabel::Item) }) - .with_kind(RuleKind::YulStatements) + .with_kind(NonTerminalKind::YulStatements) } #[allow(unused_assignments, unused_parens)] @@ -6804,86 +6829,86 @@ impl Language { choice.consider(input, result)?; choice.finish(input) }) - .with_label(NodeLabel::Variant) - .with_kind(RuleKind::YulSwitchCase) + .with_label(EdgeLabel::Variant) + .with_kind(NonTerminalKind::YulSwitchCase) } #[allow(unused_assignments, unused_parens)] fn yul_switch_cases(&self, input: &mut ParserContext<'_>) -> ParserResult { OneOrMoreHelper::run(input, |input| { - self.yul_switch_case(input).with_label(NodeLabel::Item) + self.yul_switch_case(input).with_label(EdgeLabel::Item) }) - .with_kind(RuleKind::YulSwitchCases) + .with_kind(NonTerminalKind::YulSwitchCases) } #[allow(unused_assignments, unused_parens)] fn yul_switch_statement(&self, input: &mut ParserContext<'_>) -> ParserResult { SequenceHelper::run(|mut seq| { seq.elem_labeled( - NodeLabel::SwitchKeyword, + EdgeLabel::SwitchKeyword, self.parse_token_with_trivia::( input, - TokenKind::YulSwitchKeyword, + TerminalKind::YulSwitchKeyword, ), )?; - seq.elem_labeled(NodeLabel::Expression, self.yul_expression(input))?; - seq.elem_labeled(NodeLabel::Cases, self.yul_switch_cases(input))?; + seq.elem_labeled(EdgeLabel::Expression, self.yul_expression(input))?; + seq.elem_labeled(EdgeLabel::Cases, self.yul_switch_cases(input))?; seq.finish() }) - .with_kind(RuleKind::YulSwitchStatement) + .with_kind(NonTerminalKind::YulSwitchStatement) } #[allow(unused_assignments, unused_parens)] fn yul_value_case(&self, input: &mut ParserContext<'_>) -> ParserResult { SequenceHelper::run(|mut seq| { seq.elem_labeled( - NodeLabel::CaseKeyword, + EdgeLabel::CaseKeyword, self.parse_token_with_trivia::( input, - TokenKind::YulCaseKeyword, + TerminalKind::YulCaseKeyword, ), )?; - seq.elem_labeled(NodeLabel::Value, self.yul_literal(input))?; - seq.elem_labeled(NodeLabel::Body, self.yul_block(input))?; + seq.elem_labeled(EdgeLabel::Value, self.yul_literal(input))?; + seq.elem_labeled(EdgeLabel::Body, self.yul_block(input))?; seq.finish() }) - .with_kind(RuleKind::YulValueCase) + .with_kind(NonTerminalKind::YulValueCase) } #[allow(unused_assignments, unused_parens)] fn yul_variable_declaration_statement(&self, input: &mut ParserContext<'_>) -> ParserResult { SequenceHelper::run(|mut seq| { seq.elem_labeled( - NodeLabel::LetKeyword, + EdgeLabel::LetKeyword, self.parse_token_with_trivia::( input, - TokenKind::YulLetKeyword, + TerminalKind::YulLetKeyword, ), )?; seq.elem_labeled( - NodeLabel::Names, + EdgeLabel::Names, self.parse_token_with_trivia::( input, - TokenKind::YulIdentifier, + TerminalKind::YulIdentifier, ), )?; seq.elem_labeled( - NodeLabel::Value, + EdgeLabel::Value, OptionalHelper::transform(self.yul_variable_declaration_value(input)), )?; seq.finish() }) - .with_kind(RuleKind::YulVariableDeclarationStatement) + .with_kind(NonTerminalKind::YulVariableDeclarationStatement) } #[allow(unused_assignments, unused_parens)] fn yul_variable_declaration_value(&self, input: &mut ParserContext<'_>) -> ParserResult { SequenceHelper::run(|mut seq| { - seq.elem_labeled(NodeLabel::Assignment, self.yul_assignment_operator(input))?; - seq.elem_labeled(NodeLabel::Expression, self.yul_expression(input))?; + seq.elem_labeled(EdgeLabel::Assignment, self.yul_assignment_operator(input))?; + seq.elem_labeled(EdgeLabel::Expression, self.yul_expression(input))?; seq.finish() }) - .with_kind(RuleKind::YulVariableDeclarationValue) + .with_kind(NonTerminalKind::YulVariableDeclarationValue) } #[allow(unused_assignments, unused_parens)] @@ -6891,34 +6916,40 @@ impl Language { OneOrMoreHelper::run(input, |input| { ChoiceHelper::run(input, |mut choice, input| { let result = self - .parse_token::(input, TokenKind::Whitespace) - .with_label(NodeLabel::LeadingTrivia); + .parse_token::(input, TerminalKind::Whitespace) + .with_label(EdgeLabel::LeadingTrivia); choice.consider(input, result)?; let result = self - .parse_token::(input, TokenKind::EndOfLine) - .with_label(NodeLabel::LeadingTrivia); + .parse_token::(input, TerminalKind::EndOfLine) + .with_label(EdgeLabel::LeadingTrivia); choice.consider(input, result)?; let result = self - .parse_token::(input, TokenKind::SingleLineComment) - .with_label(NodeLabel::LeadingTrivia); + .parse_token::( + input, + TerminalKind::SingleLineComment, + ) + .with_label(EdgeLabel::LeadingTrivia); choice.consider(input, result)?; let result = self - .parse_token::(input, TokenKind::MultiLineComment) - .with_label(NodeLabel::LeadingTrivia); + .parse_token::( + input, + TerminalKind::MultiLineComment, + ) + .with_label(EdgeLabel::LeadingTrivia); choice.consider(input, result)?; let result = self .parse_token::( input, - TokenKind::SingleLineNatSpecComment, + TerminalKind::SingleLineNatSpecComment, ) - .with_label(NodeLabel::LeadingTrivia); + .with_label(EdgeLabel::LeadingTrivia); choice.consider(input, result)?; let result = self .parse_token::( input, - TokenKind::MultiLineNatSpecComment, + TerminalKind::MultiLineNatSpecComment, ) - .with_label(NodeLabel::LeadingTrivia); + .with_label(EdgeLabel::LeadingTrivia); choice.consider(input, result)?; choice.finish(input) }) @@ -6929,19 +6960,19 @@ impl Language { fn trailing_trivia(&self, input: &mut ParserContext<'_>) -> ParserResult { SequenceHelper::run(|mut seq| { seq.elem(OptionalHelper::transform( - self.parse_token::(input, TokenKind::Whitespace) - .with_label(NodeLabel::TrailingTrivia), + self.parse_token::(input, TerminalKind::Whitespace) + .with_label(EdgeLabel::TrailingTrivia), ))?; seq.elem(OptionalHelper::transform( self.parse_token::( input, - TokenKind::SingleLineComment, + TerminalKind::SingleLineComment, ) - .with_label(NodeLabel::TrailingTrivia), + .with_label(EdgeLabel::TrailingTrivia), ))?; seq.elem( - self.parse_token::(input, TokenKind::EndOfLine) - .with_label(NodeLabel::TrailingTrivia), + self.parse_token::(input, TerminalKind::EndOfLine) + .with_label(EdgeLabel::TrailingTrivia), )?; seq.finish() }) @@ -7610,7 +7641,7 @@ impl Language { ) ) ) { - KeywordScan::Reserved(TokenKind::BytesKeyword) + KeywordScan::Reserved(TerminalKind::BytesKeyword) } else { KeywordScan::Absent } @@ -7623,7 +7654,7 @@ impl Language { input, ident, if scan_chars!(input, 'f', 'i', 'x', 'e', 'd') { - KeywordScan::Reserved(TokenKind::FixedKeyword) + KeywordScan::Reserved(TerminalKind::FixedKeyword) } else { KeywordScan::Absent }, @@ -7669,7 +7700,7 @@ impl Language { scan_chars!(input, '1', '6') ) ) { - KeywordScan::Reserved(TokenKind::FixedKeyword) + KeywordScan::Reserved(TerminalKind::FixedKeyword) } else { KeywordScan::Absent }, @@ -7724,7 +7755,7 @@ impl Language { scan_chars!(input, '1', '8', '4', 'x', '1', '6') ) ) { - KeywordScan::Reserved(TokenKind::FixedKeyword) + KeywordScan::Reserved(TerminalKind::FixedKeyword) } else { KeywordScan::Absent }, @@ -7790,9 +7821,9 @@ impl Language { ) ) { if self.version_is_at_least_0_4_14 { - KeywordScan::Reserved(TokenKind::FixedKeyword) + KeywordScan::Reserved(TerminalKind::FixedKeyword) } else { - KeywordScan::Present(TokenKind::FixedKeyword) + KeywordScan::Present(TerminalKind::FixedKeyword) } } else { KeywordScan::Absent @@ -7911,9 +7942,9 @@ impl Language { ) ) { if self.version_is_at_least_0_4_14 { - KeywordScan::Reserved(TokenKind::FixedKeyword) + KeywordScan::Reserved(TerminalKind::FixedKeyword) } else { - KeywordScan::Present(TokenKind::FixedKeyword) + KeywordScan::Present(TerminalKind::FixedKeyword) } } else { KeywordScan::Absent @@ -7967,7 +7998,7 @@ impl Language { ) ) ) { - KeywordScan::Reserved(TokenKind::IntKeyword) + KeywordScan::Reserved(TerminalKind::IntKeyword) } else { KeywordScan::Absent } @@ -7980,7 +8011,7 @@ impl Language { input, ident, if scan_chars!(input, 'u', 'f', 'i', 'x', 'e', 'd') { - KeywordScan::Reserved(TokenKind::UfixedKeyword) + KeywordScan::Reserved(TerminalKind::UfixedKeyword) } else { KeywordScan::Absent }, @@ -8026,7 +8057,7 @@ impl Language { scan_chars!(input, '1', '6') ) ) { - KeywordScan::Reserved(TokenKind::UfixedKeyword) + KeywordScan::Reserved(TerminalKind::UfixedKeyword) } else { KeywordScan::Absent }, @@ -8081,7 +8112,7 @@ impl Language { scan_chars!(input, '1', '8', '4', 'x', '1', '6') ) ) { - KeywordScan::Reserved(TokenKind::UfixedKeyword) + KeywordScan::Reserved(TerminalKind::UfixedKeyword) } else { KeywordScan::Absent }, @@ -8147,9 +8178,9 @@ impl Language { ) ) { if self.version_is_at_least_0_4_14 { - KeywordScan::Reserved(TokenKind::UfixedKeyword) + KeywordScan::Reserved(TerminalKind::UfixedKeyword) } else { - KeywordScan::Present(TokenKind::UfixedKeyword) + KeywordScan::Present(TerminalKind::UfixedKeyword) } } else { KeywordScan::Absent @@ -8268,9 +8299,9 @@ impl Language { ) ) { if self.version_is_at_least_0_4_14 { - KeywordScan::Reserved(TokenKind::UfixedKeyword) + KeywordScan::Reserved(TerminalKind::UfixedKeyword) } else { - KeywordScan::Present(TokenKind::UfixedKeyword) + KeywordScan::Present(TerminalKind::UfixedKeyword) } } else { KeywordScan::Absent @@ -8324,7 +8355,7 @@ impl Language { ) ) ) { - KeywordScan::Reserved(TokenKind::UintKeyword) + KeywordScan::Reserved(TerminalKind::UintKeyword) } else { KeywordScan::Absent } @@ -8379,7 +8410,7 @@ impl Language { ) ) { - KeywordScan::Reserved(TokenKind::YulBytesKeyword) + KeywordScan::Reserved(TerminalKind::YulBytesKeyword) } else { KeywordScan::Absent } @@ -8392,7 +8423,7 @@ impl Language { input, ident, if !self.version_is_at_least_0_7_1 && scan_chars!(input, 'f', 'i', 'x', 'e', 'd') { - KeywordScan::Reserved(TokenKind::YulFixedKeyword) + KeywordScan::Reserved(TerminalKind::YulFixedKeyword) } else { KeywordScan::Absent }, @@ -8440,7 +8471,7 @@ impl Language { ) ) { - KeywordScan::Reserved(TokenKind::YulFixedKeyword) + KeywordScan::Reserved(TerminalKind::YulFixedKeyword) } else { KeywordScan::Absent }, @@ -8497,7 +8528,7 @@ impl Language { ) ) { - KeywordScan::Reserved(TokenKind::YulFixedKeyword) + KeywordScan::Reserved(TerminalKind::YulFixedKeyword) } else { KeywordScan::Absent }, @@ -8565,7 +8596,7 @@ impl Language { ) ) { - KeywordScan::Reserved(TokenKind::YulFixedKeyword) + KeywordScan::Reserved(TerminalKind::YulFixedKeyword) } else { KeywordScan::Absent }, @@ -8685,7 +8716,7 @@ impl Language { ) ) { - KeywordScan::Reserved(TokenKind::YulFixedKeyword) + KeywordScan::Reserved(TerminalKind::YulFixedKeyword) } else { KeywordScan::Absent } @@ -8740,7 +8771,7 @@ impl Language { ) ) { - KeywordScan::Reserved(TokenKind::YulIntKeyword) + KeywordScan::Reserved(TerminalKind::YulIntKeyword) } else { KeywordScan::Absent } @@ -8753,7 +8784,7 @@ impl Language { input, ident, if !self.version_is_at_least_0_7_1 && scan_chars!(input, 'u', 'f', 'i', 'x', 'e', 'd') { - KeywordScan::Reserved(TokenKind::YulUfixedKeyword) + KeywordScan::Reserved(TerminalKind::YulUfixedKeyword) } else { KeywordScan::Absent }, @@ -8801,7 +8832,7 @@ impl Language { ) ) { - KeywordScan::Reserved(TokenKind::YulUfixedKeyword) + KeywordScan::Reserved(TerminalKind::YulUfixedKeyword) } else { KeywordScan::Absent }, @@ -8858,7 +8889,7 @@ impl Language { ) ) { - KeywordScan::Reserved(TokenKind::YulUfixedKeyword) + KeywordScan::Reserved(TerminalKind::YulUfixedKeyword) } else { KeywordScan::Absent }, @@ -8926,7 +8957,7 @@ impl Language { ) ) { - KeywordScan::Reserved(TokenKind::YulUfixedKeyword) + KeywordScan::Reserved(TerminalKind::YulUfixedKeyword) } else { KeywordScan::Absent }, @@ -9046,7 +9077,7 @@ impl Language { ) ) { - KeywordScan::Reserved(TokenKind::YulUfixedKeyword) + KeywordScan::Reserved(TerminalKind::YulUfixedKeyword) } else { KeywordScan::Absent } @@ -9101,293 +9132,347 @@ impl Language { ) ) { - KeywordScan::Reserved(TokenKind::YulUintKeyword) + KeywordScan::Reserved(TerminalKind::YulUintKeyword) } else { KeywordScan::Absent } ) } - pub fn parse(&self, kind: RuleKind, input: &str) -> ParseOutput { + pub fn parse(&self, kind: NonTerminalKind, input: &str) -> ParseOutput { match kind { - RuleKind::ABICoderPragma => Self::abi_coder_pragma.parse(self, input), - RuleKind::AdditiveExpression => Self::additive_expression.parse(self, input), - RuleKind::AddressType => Self::address_type.parse(self, input), - RuleKind::AndExpression => Self::and_expression.parse(self, input), - RuleKind::ArgumentsDeclaration => Self::arguments_declaration.parse(self, input), - RuleKind::ArrayExpression => Self::array_expression.parse(self, input), - RuleKind::ArrayTypeName => Self::array_type_name.parse(self, input), - RuleKind::ArrayValues => Self::array_values.parse(self, input), - RuleKind::AssemblyFlags => Self::assembly_flags.parse(self, input), - RuleKind::AssemblyFlagsDeclaration => { + NonTerminalKind::ABICoderPragma => Self::abi_coder_pragma.parse(self, input), + NonTerminalKind::AdditiveExpression => Self::additive_expression.parse(self, input), + NonTerminalKind::AddressType => Self::address_type.parse(self, input), + NonTerminalKind::AndExpression => Self::and_expression.parse(self, input), + NonTerminalKind::ArgumentsDeclaration => Self::arguments_declaration.parse(self, input), + NonTerminalKind::ArrayExpression => Self::array_expression.parse(self, input), + NonTerminalKind::ArrayTypeName => Self::array_type_name.parse(self, input), + NonTerminalKind::ArrayValues => Self::array_values.parse(self, input), + NonTerminalKind::AssemblyFlags => Self::assembly_flags.parse(self, input), + NonTerminalKind::AssemblyFlagsDeclaration => { Self::assembly_flags_declaration.parse(self, input) } - RuleKind::AssemblyStatement => Self::assembly_statement.parse(self, input), - RuleKind::AssignmentExpression => Self::assignment_expression.parse(self, input), - RuleKind::BitwiseAndExpression => Self::bitwise_and_expression.parse(self, input), - RuleKind::BitwiseOrExpression => Self::bitwise_or_expression.parse(self, input), - RuleKind::BitwiseXorExpression => Self::bitwise_xor_expression.parse(self, input), - RuleKind::Block => Self::block.parse(self, input), - RuleKind::BreakStatement => Self::break_statement.parse(self, input), - RuleKind::CallOptions => Self::call_options.parse(self, input), - RuleKind::CallOptionsExpression => Self::call_options_expression.parse(self, input), - RuleKind::CatchClause => Self::catch_clause.parse(self, input), - RuleKind::CatchClauseError => Self::catch_clause_error.parse(self, input), - RuleKind::CatchClauses => Self::catch_clauses.parse(self, input), - RuleKind::ComparisonExpression => Self::comparison_expression.parse(self, input), - RuleKind::ConditionalExpression => Self::conditional_expression.parse(self, input), - RuleKind::ConstantDefinition => Self::constant_definition.parse(self, input), - RuleKind::ConstructorAttribute => Self::constructor_attribute.parse(self, input), - RuleKind::ConstructorAttributes => Self::constructor_attributes.parse(self, input), - RuleKind::ConstructorDefinition => Self::constructor_definition.parse(self, input), - RuleKind::ContinueStatement => Self::continue_statement.parse(self, input), - RuleKind::ContractDefinition => Self::contract_definition.parse(self, input), - RuleKind::ContractMember => Self::contract_member.parse(self, input), - RuleKind::ContractMembers => Self::contract_members.parse(self, input), - RuleKind::DecimalNumberExpression => Self::decimal_number_expression.parse(self, input), - RuleKind::DoWhileStatement => Self::do_while_statement.parse(self, input), - RuleKind::ElementaryType => Self::elementary_type.parse(self, input), - RuleKind::ElseBranch => Self::else_branch.parse(self, input), - RuleKind::EmitStatement => Self::emit_statement.parse(self, input), - RuleKind::EnumDefinition => Self::enum_definition.parse(self, input), - RuleKind::EnumMembers => Self::enum_members.parse(self, input), - RuleKind::EqualityExpression => Self::equality_expression.parse(self, input), - RuleKind::ErrorDefinition => Self::error_definition.parse(self, input), - RuleKind::ErrorParameter => Self::error_parameter.parse(self, input), - RuleKind::ErrorParameters => Self::error_parameters.parse(self, input), - RuleKind::ErrorParametersDeclaration => { + NonTerminalKind::AssemblyStatement => Self::assembly_statement.parse(self, input), + NonTerminalKind::AssignmentExpression => Self::assignment_expression.parse(self, input), + NonTerminalKind::BitwiseAndExpression => { + Self::bitwise_and_expression.parse(self, input) + } + NonTerminalKind::BitwiseOrExpression => Self::bitwise_or_expression.parse(self, input), + NonTerminalKind::BitwiseXorExpression => { + Self::bitwise_xor_expression.parse(self, input) + } + NonTerminalKind::Block => Self::block.parse(self, input), + NonTerminalKind::BreakStatement => Self::break_statement.parse(self, input), + NonTerminalKind::CallOptions => Self::call_options.parse(self, input), + NonTerminalKind::CallOptionsExpression => { + Self::call_options_expression.parse(self, input) + } + NonTerminalKind::CatchClause => Self::catch_clause.parse(self, input), + NonTerminalKind::CatchClauseError => Self::catch_clause_error.parse(self, input), + NonTerminalKind::CatchClauses => Self::catch_clauses.parse(self, input), + NonTerminalKind::ComparisonExpression => Self::comparison_expression.parse(self, input), + NonTerminalKind::ConditionalExpression => { + Self::conditional_expression.parse(self, input) + } + NonTerminalKind::ConstantDefinition => Self::constant_definition.parse(self, input), + NonTerminalKind::ConstructorAttribute => Self::constructor_attribute.parse(self, input), + NonTerminalKind::ConstructorAttributes => { + Self::constructor_attributes.parse(self, input) + } + NonTerminalKind::ConstructorDefinition => { + Self::constructor_definition.parse(self, input) + } + NonTerminalKind::ContinueStatement => Self::continue_statement.parse(self, input), + NonTerminalKind::ContractDefinition => Self::contract_definition.parse(self, input), + NonTerminalKind::ContractMember => Self::contract_member.parse(self, input), + NonTerminalKind::ContractMembers => Self::contract_members.parse(self, input), + NonTerminalKind::DecimalNumberExpression => { + Self::decimal_number_expression.parse(self, input) + } + NonTerminalKind::DoWhileStatement => Self::do_while_statement.parse(self, input), + NonTerminalKind::ElementaryType => Self::elementary_type.parse(self, input), + NonTerminalKind::ElseBranch => Self::else_branch.parse(self, input), + NonTerminalKind::EmitStatement => Self::emit_statement.parse(self, input), + NonTerminalKind::EnumDefinition => Self::enum_definition.parse(self, input), + NonTerminalKind::EnumMembers => Self::enum_members.parse(self, input), + NonTerminalKind::EqualityExpression => Self::equality_expression.parse(self, input), + NonTerminalKind::ErrorDefinition => Self::error_definition.parse(self, input), + NonTerminalKind::ErrorParameter => Self::error_parameter.parse(self, input), + NonTerminalKind::ErrorParameters => Self::error_parameters.parse(self, input), + NonTerminalKind::ErrorParametersDeclaration => { Self::error_parameters_declaration.parse(self, input) } - RuleKind::EventDefinition => Self::event_definition.parse(self, input), - RuleKind::EventParameter => Self::event_parameter.parse(self, input), - RuleKind::EventParameters => Self::event_parameters.parse(self, input), - RuleKind::EventParametersDeclaration => { + NonTerminalKind::EventDefinition => Self::event_definition.parse(self, input), + NonTerminalKind::EventParameter => Self::event_parameter.parse(self, input), + NonTerminalKind::EventParameters => Self::event_parameters.parse(self, input), + NonTerminalKind::EventParametersDeclaration => { Self::event_parameters_declaration.parse(self, input) } - RuleKind::ExperimentalFeature => Self::experimental_feature.parse(self, input), - RuleKind::ExperimentalPragma => Self::experimental_pragma.parse(self, input), - RuleKind::ExponentiationExpression => { + NonTerminalKind::ExperimentalFeature => Self::experimental_feature.parse(self, input), + NonTerminalKind::ExperimentalPragma => Self::experimental_pragma.parse(self, input), + NonTerminalKind::ExponentiationExpression => { Self::exponentiation_expression.parse(self, input) } - RuleKind::Expression => Self::expression.parse(self, input), - RuleKind::ExpressionStatement => Self::expression_statement.parse(self, input), - RuleKind::FallbackFunctionAttribute => { + NonTerminalKind::Expression => Self::expression.parse(self, input), + NonTerminalKind::ExpressionStatement => Self::expression_statement.parse(self, input), + NonTerminalKind::FallbackFunctionAttribute => { Self::fallback_function_attribute.parse(self, input) } - RuleKind::FallbackFunctionAttributes => { + NonTerminalKind::FallbackFunctionAttributes => { Self::fallback_function_attributes.parse(self, input) } - RuleKind::FallbackFunctionDefinition => { + NonTerminalKind::FallbackFunctionDefinition => { Self::fallback_function_definition.parse(self, input) } - RuleKind::ForStatement => Self::for_statement.parse(self, input), - RuleKind::ForStatementCondition => Self::for_statement_condition.parse(self, input), - RuleKind::ForStatementInitialization => { + NonTerminalKind::ForStatement => Self::for_statement.parse(self, input), + NonTerminalKind::ForStatementCondition => { + Self::for_statement_condition.parse(self, input) + } + NonTerminalKind::ForStatementInitialization => { Self::for_statement_initialization.parse(self, input) } - RuleKind::FunctionAttribute => Self::function_attribute.parse(self, input), - RuleKind::FunctionAttributes => Self::function_attributes.parse(self, input), - RuleKind::FunctionBody => Self::function_body.parse(self, input), - RuleKind::FunctionCallExpression => Self::function_call_expression.parse(self, input), - RuleKind::FunctionDefinition => Self::function_definition.parse(self, input), - RuleKind::FunctionName => Self::function_name.parse(self, input), - RuleKind::FunctionType => Self::function_type.parse(self, input), - RuleKind::FunctionTypeAttribute => Self::function_type_attribute.parse(self, input), - RuleKind::FunctionTypeAttributes => Self::function_type_attributes.parse(self, input), - RuleKind::HexNumberExpression => Self::hex_number_expression.parse(self, input), - RuleKind::HexStringLiteral => Self::hex_string_literal.parse(self, input), - RuleKind::HexStringLiterals => Self::hex_string_literals.parse(self, input), - RuleKind::IdentifierPath => Self::identifier_path.parse(self, input), - RuleKind::IfStatement => Self::if_statement.parse(self, input), - RuleKind::ImportAlias => Self::import_alias.parse(self, input), - RuleKind::ImportClause => Self::import_clause.parse(self, input), - RuleKind::ImportDeconstruction => Self::import_deconstruction.parse(self, input), - RuleKind::ImportDeconstructionSymbol => { + NonTerminalKind::FunctionAttribute => Self::function_attribute.parse(self, input), + NonTerminalKind::FunctionAttributes => Self::function_attributes.parse(self, input), + NonTerminalKind::FunctionBody => Self::function_body.parse(self, input), + NonTerminalKind::FunctionCallExpression => { + Self::function_call_expression.parse(self, input) + } + NonTerminalKind::FunctionDefinition => Self::function_definition.parse(self, input), + NonTerminalKind::FunctionName => Self::function_name.parse(self, input), + NonTerminalKind::FunctionType => Self::function_type.parse(self, input), + NonTerminalKind::FunctionTypeAttribute => { + Self::function_type_attribute.parse(self, input) + } + NonTerminalKind::FunctionTypeAttributes => { + Self::function_type_attributes.parse(self, input) + } + NonTerminalKind::HexNumberExpression => Self::hex_number_expression.parse(self, input), + NonTerminalKind::HexStringLiteral => Self::hex_string_literal.parse(self, input), + NonTerminalKind::HexStringLiterals => Self::hex_string_literals.parse(self, input), + NonTerminalKind::IdentifierPath => Self::identifier_path.parse(self, input), + NonTerminalKind::IfStatement => Self::if_statement.parse(self, input), + NonTerminalKind::ImportAlias => Self::import_alias.parse(self, input), + NonTerminalKind::ImportClause => Self::import_clause.parse(self, input), + NonTerminalKind::ImportDeconstruction => Self::import_deconstruction.parse(self, input), + NonTerminalKind::ImportDeconstructionSymbol => { Self::import_deconstruction_symbol.parse(self, input) } - RuleKind::ImportDeconstructionSymbols => { + NonTerminalKind::ImportDeconstructionSymbols => { Self::import_deconstruction_symbols.parse(self, input) } - RuleKind::ImportDirective => Self::import_directive.parse(self, input), - RuleKind::IndexAccessEnd => Self::index_access_end.parse(self, input), - RuleKind::IndexAccessExpression => Self::index_access_expression.parse(self, input), - RuleKind::InheritanceSpecifier => Self::inheritance_specifier.parse(self, input), - RuleKind::InheritanceType => Self::inheritance_type.parse(self, input), - RuleKind::InheritanceTypes => Self::inheritance_types.parse(self, input), - RuleKind::InterfaceDefinition => Self::interface_definition.parse(self, input), - RuleKind::InterfaceMembers => Self::interface_members.parse(self, input), - RuleKind::LibraryDefinition => Self::library_definition.parse(self, input), - RuleKind::LibraryMembers => Self::library_members.parse(self, input), - RuleKind::MappingKey => Self::mapping_key.parse(self, input), - RuleKind::MappingKeyType => Self::mapping_key_type.parse(self, input), - RuleKind::MappingType => Self::mapping_type.parse(self, input), - RuleKind::MappingValue => Self::mapping_value.parse(self, input), - RuleKind::MemberAccess => Self::member_access.parse(self, input), - RuleKind::MemberAccessExpression => Self::member_access_expression.parse(self, input), - RuleKind::ModifierAttribute => Self::modifier_attribute.parse(self, input), - RuleKind::ModifierAttributes => Self::modifier_attributes.parse(self, input), - RuleKind::ModifierDefinition => Self::modifier_definition.parse(self, input), - RuleKind::ModifierInvocation => Self::modifier_invocation.parse(self, input), - RuleKind::MultiplicativeExpression => { + NonTerminalKind::ImportDirective => Self::import_directive.parse(self, input), + NonTerminalKind::IndexAccessEnd => Self::index_access_end.parse(self, input), + NonTerminalKind::IndexAccessExpression => { + Self::index_access_expression.parse(self, input) + } + NonTerminalKind::InheritanceSpecifier => Self::inheritance_specifier.parse(self, input), + NonTerminalKind::InheritanceType => Self::inheritance_type.parse(self, input), + NonTerminalKind::InheritanceTypes => Self::inheritance_types.parse(self, input), + NonTerminalKind::InterfaceDefinition => Self::interface_definition.parse(self, input), + NonTerminalKind::InterfaceMembers => Self::interface_members.parse(self, input), + NonTerminalKind::LibraryDefinition => Self::library_definition.parse(self, input), + NonTerminalKind::LibraryMembers => Self::library_members.parse(self, input), + NonTerminalKind::MappingKey => Self::mapping_key.parse(self, input), + NonTerminalKind::MappingKeyType => Self::mapping_key_type.parse(self, input), + NonTerminalKind::MappingType => Self::mapping_type.parse(self, input), + NonTerminalKind::MappingValue => Self::mapping_value.parse(self, input), + NonTerminalKind::MemberAccess => Self::member_access.parse(self, input), + NonTerminalKind::MemberAccessExpression => { + Self::member_access_expression.parse(self, input) + } + NonTerminalKind::ModifierAttribute => Self::modifier_attribute.parse(self, input), + NonTerminalKind::ModifierAttributes => Self::modifier_attributes.parse(self, input), + NonTerminalKind::ModifierDefinition => Self::modifier_definition.parse(self, input), + NonTerminalKind::ModifierInvocation => Self::modifier_invocation.parse(self, input), + NonTerminalKind::MultiplicativeExpression => { Self::multiplicative_expression.parse(self, input) } - RuleKind::NamedArgument => Self::named_argument.parse(self, input), - RuleKind::NamedArgumentGroup => Self::named_argument_group.parse(self, input), - RuleKind::NamedArguments => Self::named_arguments.parse(self, input), - RuleKind::NamedArgumentsDeclaration => { + NonTerminalKind::NamedArgument => Self::named_argument.parse(self, input), + NonTerminalKind::NamedArgumentGroup => Self::named_argument_group.parse(self, input), + NonTerminalKind::NamedArguments => Self::named_arguments.parse(self, input), + NonTerminalKind::NamedArgumentsDeclaration => { Self::named_arguments_declaration.parse(self, input) } - RuleKind::NamedImport => Self::named_import.parse(self, input), - RuleKind::NewExpression => Self::new_expression.parse(self, input), - RuleKind::NumberUnit => Self::number_unit.parse(self, input), - RuleKind::OrExpression => Self::or_expression.parse(self, input), - RuleKind::OverridePaths => Self::override_paths.parse(self, input), - RuleKind::OverridePathsDeclaration => { + NonTerminalKind::NamedImport => Self::named_import.parse(self, input), + NonTerminalKind::NewExpression => Self::new_expression.parse(self, input), + NonTerminalKind::NumberUnit => Self::number_unit.parse(self, input), + NonTerminalKind::OrExpression => Self::or_expression.parse(self, input), + NonTerminalKind::OverridePaths => Self::override_paths.parse(self, input), + NonTerminalKind::OverridePathsDeclaration => { Self::override_paths_declaration.parse(self, input) } - RuleKind::OverrideSpecifier => Self::override_specifier.parse(self, input), - RuleKind::Parameter => Self::parameter.parse(self, input), - RuleKind::Parameters => Self::parameters.parse(self, input), - RuleKind::ParametersDeclaration => Self::parameters_declaration.parse(self, input), - RuleKind::PathImport => Self::path_import.parse(self, input), - RuleKind::PositionalArguments => Self::positional_arguments.parse(self, input), - RuleKind::PositionalArgumentsDeclaration => { + NonTerminalKind::OverrideSpecifier => Self::override_specifier.parse(self, input), + NonTerminalKind::Parameter => Self::parameter.parse(self, input), + NonTerminalKind::Parameters => Self::parameters.parse(self, input), + NonTerminalKind::ParametersDeclaration => { + Self::parameters_declaration.parse(self, input) + } + NonTerminalKind::PathImport => Self::path_import.parse(self, input), + NonTerminalKind::PositionalArguments => Self::positional_arguments.parse(self, input), + NonTerminalKind::PositionalArgumentsDeclaration => { Self::positional_arguments_declaration.parse(self, input) } - RuleKind::PostfixExpression => Self::postfix_expression.parse(self, input), - RuleKind::Pragma => Self::pragma.parse(self, input), - RuleKind::PragmaDirective => Self::pragma_directive.parse(self, input), - RuleKind::PrefixExpression => Self::prefix_expression.parse(self, input), - RuleKind::ReceiveFunctionAttribute => { + NonTerminalKind::PostfixExpression => Self::postfix_expression.parse(self, input), + NonTerminalKind::Pragma => Self::pragma.parse(self, input), + NonTerminalKind::PragmaDirective => Self::pragma_directive.parse(self, input), + NonTerminalKind::PrefixExpression => Self::prefix_expression.parse(self, input), + NonTerminalKind::ReceiveFunctionAttribute => { Self::receive_function_attribute.parse(self, input) } - RuleKind::ReceiveFunctionAttributes => { + NonTerminalKind::ReceiveFunctionAttributes => { Self::receive_function_attributes.parse(self, input) } - RuleKind::ReceiveFunctionDefinition => { + NonTerminalKind::ReceiveFunctionDefinition => { Self::receive_function_definition.parse(self, input) } - RuleKind::ReturnStatement => Self::return_statement.parse(self, input), - RuleKind::ReturnsDeclaration => Self::returns_declaration.parse(self, input), - RuleKind::RevertStatement => Self::revert_statement.parse(self, input), - RuleKind::ShiftExpression => Self::shift_expression.parse(self, input), - RuleKind::SourceUnit => Self::source_unit.parse(self, input), - RuleKind::SourceUnitMember => Self::source_unit_member.parse(self, input), - RuleKind::SourceUnitMembers => Self::source_unit_members.parse(self, input), - RuleKind::StateVariableAttribute => Self::state_variable_attribute.parse(self, input), - RuleKind::StateVariableAttributes => Self::state_variable_attributes.parse(self, input), - RuleKind::StateVariableDefinition => Self::state_variable_definition.parse(self, input), - RuleKind::StateVariableDefinitionValue => { + NonTerminalKind::ReturnStatement => Self::return_statement.parse(self, input), + NonTerminalKind::ReturnsDeclaration => Self::returns_declaration.parse(self, input), + NonTerminalKind::RevertStatement => Self::revert_statement.parse(self, input), + NonTerminalKind::ShiftExpression => Self::shift_expression.parse(self, input), + NonTerminalKind::SourceUnit => Self::source_unit.parse(self, input), + NonTerminalKind::SourceUnitMember => Self::source_unit_member.parse(self, input), + NonTerminalKind::SourceUnitMembers => Self::source_unit_members.parse(self, input), + NonTerminalKind::StateVariableAttribute => { + Self::state_variable_attribute.parse(self, input) + } + NonTerminalKind::StateVariableAttributes => { + Self::state_variable_attributes.parse(self, input) + } + NonTerminalKind::StateVariableDefinition => { + Self::state_variable_definition.parse(self, input) + } + NonTerminalKind::StateVariableDefinitionValue => { Self::state_variable_definition_value.parse(self, input) } - RuleKind::Statement => Self::statement.parse(self, input), - RuleKind::Statements => Self::statements.parse(self, input), - RuleKind::StorageLocation => Self::storage_location.parse(self, input), - RuleKind::StringExpression => Self::string_expression.parse(self, input), - RuleKind::StringLiteral => Self::string_literal.parse(self, input), - RuleKind::StringLiterals => Self::string_literals.parse(self, input), - RuleKind::StructDefinition => Self::struct_definition.parse(self, input), - RuleKind::StructMember => Self::struct_member.parse(self, input), - RuleKind::StructMembers => Self::struct_members.parse(self, input), - RuleKind::ThrowStatement => Self::throw_statement.parse(self, input), - RuleKind::TryStatement => Self::try_statement.parse(self, input), - RuleKind::TupleDeconstructionElement => { + NonTerminalKind::Statement => Self::statement.parse(self, input), + NonTerminalKind::Statements => Self::statements.parse(self, input), + NonTerminalKind::StorageLocation => Self::storage_location.parse(self, input), + NonTerminalKind::StringExpression => Self::string_expression.parse(self, input), + NonTerminalKind::StringLiteral => Self::string_literal.parse(self, input), + NonTerminalKind::StringLiterals => Self::string_literals.parse(self, input), + NonTerminalKind::StructDefinition => Self::struct_definition.parse(self, input), + NonTerminalKind::StructMember => Self::struct_member.parse(self, input), + NonTerminalKind::StructMembers => Self::struct_members.parse(self, input), + NonTerminalKind::ThrowStatement => Self::throw_statement.parse(self, input), + NonTerminalKind::TryStatement => Self::try_statement.parse(self, input), + NonTerminalKind::TupleDeconstructionElement => { Self::tuple_deconstruction_element.parse(self, input) } - RuleKind::TupleDeconstructionElements => { + NonTerminalKind::TupleDeconstructionElements => { Self::tuple_deconstruction_elements.parse(self, input) } - RuleKind::TupleDeconstructionStatement => { + NonTerminalKind::TupleDeconstructionStatement => { Self::tuple_deconstruction_statement.parse(self, input) } - RuleKind::TupleExpression => Self::tuple_expression.parse(self, input), - RuleKind::TupleMember => Self::tuple_member.parse(self, input), - RuleKind::TupleValue => Self::tuple_value.parse(self, input), - RuleKind::TupleValues => Self::tuple_values.parse(self, input), - RuleKind::TypeExpression => Self::type_expression.parse(self, input), - RuleKind::TypeName => Self::type_name.parse(self, input), - RuleKind::TypedTupleMember => Self::typed_tuple_member.parse(self, input), - RuleKind::UncheckedBlock => Self::unchecked_block.parse(self, input), - RuleKind::UnicodeStringLiteral => Self::unicode_string_literal.parse(self, input), - RuleKind::UnicodeStringLiterals => Self::unicode_string_literals.parse(self, input), - RuleKind::UnnamedFunctionAttribute => { + NonTerminalKind::TupleExpression => Self::tuple_expression.parse(self, input), + NonTerminalKind::TupleMember => Self::tuple_member.parse(self, input), + NonTerminalKind::TupleValue => Self::tuple_value.parse(self, input), + NonTerminalKind::TupleValues => Self::tuple_values.parse(self, input), + NonTerminalKind::TypeExpression => Self::type_expression.parse(self, input), + NonTerminalKind::TypeName => Self::type_name.parse(self, input), + NonTerminalKind::TypedTupleMember => Self::typed_tuple_member.parse(self, input), + NonTerminalKind::UncheckedBlock => Self::unchecked_block.parse(self, input), + NonTerminalKind::UnicodeStringLiteral => { + Self::unicode_string_literal.parse(self, input) + } + NonTerminalKind::UnicodeStringLiterals => { + Self::unicode_string_literals.parse(self, input) + } + NonTerminalKind::UnnamedFunctionAttribute => { Self::unnamed_function_attribute.parse(self, input) } - RuleKind::UnnamedFunctionAttributes => { + NonTerminalKind::UnnamedFunctionAttributes => { Self::unnamed_function_attributes.parse(self, input) } - RuleKind::UnnamedFunctionDefinition => { + NonTerminalKind::UnnamedFunctionDefinition => { Self::unnamed_function_definition.parse(self, input) } - RuleKind::UntypedTupleMember => Self::untyped_tuple_member.parse(self, input), - RuleKind::UserDefinedValueTypeDefinition => { + NonTerminalKind::UntypedTupleMember => Self::untyped_tuple_member.parse(self, input), + NonTerminalKind::UserDefinedValueTypeDefinition => { Self::user_defined_value_type_definition.parse(self, input) } - RuleKind::UsingAlias => Self::using_alias.parse(self, input), - RuleKind::UsingClause => Self::using_clause.parse(self, input), - RuleKind::UsingDeconstruction => Self::using_deconstruction.parse(self, input), - RuleKind::UsingDeconstructionSymbol => { + NonTerminalKind::UsingAlias => Self::using_alias.parse(self, input), + NonTerminalKind::UsingClause => Self::using_clause.parse(self, input), + NonTerminalKind::UsingDeconstruction => Self::using_deconstruction.parse(self, input), + NonTerminalKind::UsingDeconstructionSymbol => { Self::using_deconstruction_symbol.parse(self, input) } - RuleKind::UsingDeconstructionSymbols => { + NonTerminalKind::UsingDeconstructionSymbols => { Self::using_deconstruction_symbols.parse(self, input) } - RuleKind::UsingDirective => Self::using_directive.parse(self, input), - RuleKind::UsingOperator => Self::using_operator.parse(self, input), - RuleKind::UsingTarget => Self::using_target.parse(self, input), - RuleKind::VariableDeclarationStatement => { + NonTerminalKind::UsingDirective => Self::using_directive.parse(self, input), + NonTerminalKind::UsingOperator => Self::using_operator.parse(self, input), + NonTerminalKind::UsingTarget => Self::using_target.parse(self, input), + NonTerminalKind::VariableDeclarationStatement => { Self::variable_declaration_statement.parse(self, input) } - RuleKind::VariableDeclarationType => Self::variable_declaration_type.parse(self, input), - RuleKind::VariableDeclarationValue => { + NonTerminalKind::VariableDeclarationType => { + Self::variable_declaration_type.parse(self, input) + } + NonTerminalKind::VariableDeclarationValue => { Self::variable_declaration_value.parse(self, input) } - RuleKind::VersionComparator => Self::version_comparator.parse(self, input), - RuleKind::VersionExpression => Self::version_expression.parse(self, input), - RuleKind::VersionExpressionSet => Self::version_expression_set.parse(self, input), - RuleKind::VersionExpressionSets => Self::version_expression_sets.parse(self, input), - RuleKind::VersionPragma => Self::version_pragma.parse(self, input), - RuleKind::VersionRange => Self::version_range.parse(self, input), - RuleKind::VersionSpecifiers => Self::version_specifiers.parse(self, input), - RuleKind::WhileStatement => Self::while_statement.parse(self, input), - RuleKind::YulArguments => Self::yul_arguments.parse(self, input), - RuleKind::YulAssignmentOperator => Self::yul_assignment_operator.parse(self, input), - RuleKind::YulAssignmentStatement => Self::yul_assignment_statement.parse(self, input), - RuleKind::YulBlock => Self::yul_block.parse(self, input), - RuleKind::YulBreakStatement => Self::yul_break_statement.parse(self, input), - RuleKind::YulBuiltInFunction => Self::yul_built_in_function.parse(self, input), - RuleKind::YulColonAndEqual => Self::yul_colon_and_equal.parse(self, input), - RuleKind::YulContinueStatement => Self::yul_continue_statement.parse(self, input), - RuleKind::YulDefaultCase => Self::yul_default_case.parse(self, input), - RuleKind::YulExpression => Self::yul_expression.parse(self, input), - RuleKind::YulForStatement => Self::yul_for_statement.parse(self, input), - RuleKind::YulFunctionCallExpression => { + NonTerminalKind::VersionComparator => Self::version_comparator.parse(self, input), + NonTerminalKind::VersionExpression => Self::version_expression.parse(self, input), + NonTerminalKind::VersionExpressionSet => { + Self::version_expression_set.parse(self, input) + } + NonTerminalKind::VersionExpressionSets => { + Self::version_expression_sets.parse(self, input) + } + NonTerminalKind::VersionPragma => Self::version_pragma.parse(self, input), + NonTerminalKind::VersionRange => Self::version_range.parse(self, input), + NonTerminalKind::VersionSpecifiers => Self::version_specifiers.parse(self, input), + NonTerminalKind::WhileStatement => Self::while_statement.parse(self, input), + NonTerminalKind::YulArguments => Self::yul_arguments.parse(self, input), + NonTerminalKind::YulAssignmentOperator => { + Self::yul_assignment_operator.parse(self, input) + } + NonTerminalKind::YulAssignmentStatement => { + Self::yul_assignment_statement.parse(self, input) + } + NonTerminalKind::YulBlock => Self::yul_block.parse(self, input), + NonTerminalKind::YulBreakStatement => Self::yul_break_statement.parse(self, input), + NonTerminalKind::YulBuiltInFunction => Self::yul_built_in_function.parse(self, input), + NonTerminalKind::YulColonAndEqual => Self::yul_colon_and_equal.parse(self, input), + NonTerminalKind::YulContinueStatement => { + Self::yul_continue_statement.parse(self, input) + } + NonTerminalKind::YulDefaultCase => Self::yul_default_case.parse(self, input), + NonTerminalKind::YulExpression => Self::yul_expression.parse(self, input), + NonTerminalKind::YulForStatement => Self::yul_for_statement.parse(self, input), + NonTerminalKind::YulFunctionCallExpression => { Self::yul_function_call_expression.parse(self, input) } - RuleKind::YulFunctionDefinition => Self::yul_function_definition.parse(self, input), - RuleKind::YulIfStatement => Self::yul_if_statement.parse(self, input), - RuleKind::YulLabel => Self::yul_label.parse(self, input), - RuleKind::YulLeaveStatement => Self::yul_leave_statement.parse(self, input), - RuleKind::YulLiteral => Self::yul_literal.parse(self, input), - RuleKind::YulParameters => Self::yul_parameters.parse(self, input), - RuleKind::YulParametersDeclaration => { + NonTerminalKind::YulFunctionDefinition => { + Self::yul_function_definition.parse(self, input) + } + NonTerminalKind::YulIfStatement => Self::yul_if_statement.parse(self, input), + NonTerminalKind::YulLabel => Self::yul_label.parse(self, input), + NonTerminalKind::YulLeaveStatement => Self::yul_leave_statement.parse(self, input), + NonTerminalKind::YulLiteral => Self::yul_literal.parse(self, input), + NonTerminalKind::YulParameters => Self::yul_parameters.parse(self, input), + NonTerminalKind::YulParametersDeclaration => { Self::yul_parameters_declaration.parse(self, input) } - RuleKind::YulPath => Self::yul_path.parse(self, input), - RuleKind::YulPathComponent => Self::yul_path_component.parse(self, input), - RuleKind::YulPaths => Self::yul_paths.parse(self, input), - RuleKind::YulReturnVariables => Self::yul_return_variables.parse(self, input), - RuleKind::YulReturnsDeclaration => Self::yul_returns_declaration.parse(self, input), - RuleKind::YulStatement => Self::yul_statement.parse(self, input), - RuleKind::YulStatements => Self::yul_statements.parse(self, input), - RuleKind::YulSwitchCase => Self::yul_switch_case.parse(self, input), - RuleKind::YulSwitchCases => Self::yul_switch_cases.parse(self, input), - RuleKind::YulSwitchStatement => Self::yul_switch_statement.parse(self, input), - RuleKind::YulValueCase => Self::yul_value_case.parse(self, input), - RuleKind::YulVariableDeclarationStatement => { + NonTerminalKind::YulPath => Self::yul_path.parse(self, input), + NonTerminalKind::YulPathComponent => Self::yul_path_component.parse(self, input), + NonTerminalKind::YulPaths => Self::yul_paths.parse(self, input), + NonTerminalKind::YulReturnVariables => Self::yul_return_variables.parse(self, input), + NonTerminalKind::YulReturnsDeclaration => { + Self::yul_returns_declaration.parse(self, input) + } + NonTerminalKind::YulStatement => Self::yul_statement.parse(self, input), + NonTerminalKind::YulStatements => Self::yul_statements.parse(self, input), + NonTerminalKind::YulSwitchCase => Self::yul_switch_case.parse(self, input), + NonTerminalKind::YulSwitchCases => Self::yul_switch_cases.parse(self, input), + NonTerminalKind::YulSwitchStatement => Self::yul_switch_statement.parse(self, input), + NonTerminalKind::YulValueCase => Self::yul_value_case.parse(self, input), + NonTerminalKind::YulVariableDeclarationStatement => { Self::yul_variable_declaration_statement.parse(self, input) } - RuleKind::YulVariableDeclarationValue => { + NonTerminalKind::YulVariableDeclarationValue => { Self::yul_variable_declaration_value.parse(self, input) } } @@ -9403,17 +9488,17 @@ impl Lexer for Language { Language::trailing_trivia(self, input) } - fn delimiters() -> &'static [(TokenKind, TokenKind)] { + fn delimiters() -> &'static [(TerminalKind, TerminalKind)] { match LexCtx::value() { LexicalContext::Default => &[ - (TokenKind::OpenBrace, TokenKind::CloseBrace), - (TokenKind::OpenBracket, TokenKind::CloseBracket), - (TokenKind::OpenParen, TokenKind::CloseParen), + (TerminalKind::OpenBrace, TerminalKind::CloseBrace), + (TerminalKind::OpenBracket, TerminalKind::CloseBracket), + (TerminalKind::OpenParen, TerminalKind::CloseParen), ], LexicalContext::Pragma => &[], LexicalContext::Yul => &[ - (TokenKind::OpenBrace, TokenKind::CloseBrace), - (TokenKind::OpenParen, TokenKind::CloseParen), + (TerminalKind::OpenBrace, TerminalKind::CloseBrace), + (TerminalKind::OpenParen, TerminalKind::CloseParen), ], } } @@ -9432,7 +9517,7 @@ impl Lexer for Language { if self.$function(input) && input.position() > furthest_position { furthest_position = input.position(); - longest_token = Some(TokenKind::$kind); + longest_token = Some(TerminalKind::$kind); } input.set_position(save); )* @@ -9443,144 +9528,144 @@ impl Lexer for Language { LexicalContext::Default => { if let Some(kind) = match input.next() { Some('!') => match input.next() { - Some('=') => Some(TokenKind::BangEqual), + Some('=') => Some(TerminalKind::BangEqual), Some(_) => { input.undo(); - Some(TokenKind::Bang) + Some(TerminalKind::Bang) } - None => Some(TokenKind::Bang), + None => Some(TerminalKind::Bang), }, Some('%') => match input.next() { - Some('=') => Some(TokenKind::PercentEqual), + Some('=') => Some(TerminalKind::PercentEqual), Some(_) => { input.undo(); - Some(TokenKind::Percent) + Some(TerminalKind::Percent) } - None => Some(TokenKind::Percent), + None => Some(TerminalKind::Percent), }, Some('&') => match input.next() { - Some('&') => Some(TokenKind::AmpersandAmpersand), - Some('=') => Some(TokenKind::AmpersandEqual), + Some('&') => Some(TerminalKind::AmpersandAmpersand), + Some('=') => Some(TerminalKind::AmpersandEqual), Some(_) => { input.undo(); - Some(TokenKind::Ampersand) + Some(TerminalKind::Ampersand) } - None => Some(TokenKind::Ampersand), + None => Some(TerminalKind::Ampersand), }, - Some('(') => Some(TokenKind::OpenParen), - Some(')') => Some(TokenKind::CloseParen), + Some('(') => Some(TerminalKind::OpenParen), + Some(')') => Some(TerminalKind::CloseParen), Some('*') => match input.next() { - Some('*') => Some(TokenKind::AsteriskAsterisk), - Some('=') => Some(TokenKind::AsteriskEqual), + Some('*') => Some(TerminalKind::AsteriskAsterisk), + Some('=') => Some(TerminalKind::AsteriskEqual), Some(_) => { input.undo(); - Some(TokenKind::Asterisk) + Some(TerminalKind::Asterisk) } - None => Some(TokenKind::Asterisk), + None => Some(TerminalKind::Asterisk), }, Some('+') => match input.next() { - Some('+') => Some(TokenKind::PlusPlus), - Some('=') => Some(TokenKind::PlusEqual), + Some('+') => Some(TerminalKind::PlusPlus), + Some('=') => Some(TerminalKind::PlusEqual), Some(_) => { input.undo(); - Some(TokenKind::Plus) + Some(TerminalKind::Plus) } - None => Some(TokenKind::Plus), + None => Some(TerminalKind::Plus), }, - Some(',') => Some(TokenKind::Comma), + Some(',') => Some(TerminalKind::Comma), Some('-') => match input.next() { - Some('-') => Some(TokenKind::MinusMinus), - Some('=') => Some(TokenKind::MinusEqual), + Some('-') => Some(TerminalKind::MinusMinus), + Some('=') => Some(TerminalKind::MinusEqual), Some(_) => { input.undo(); - Some(TokenKind::Minus) + Some(TerminalKind::Minus) } - None => Some(TokenKind::Minus), + None => Some(TerminalKind::Minus), }, - Some('.') => Some(TokenKind::Period), + Some('.') => Some(TerminalKind::Period), Some('/') => { if scan_chars!(input, '=') { - Some(TokenKind::SlashEqual) + Some(TerminalKind::SlashEqual) } else { None } } - Some(':') => Some(TokenKind::Colon), - Some(';') => Some(TokenKind::Semicolon), + Some(':') => Some(TerminalKind::Colon), + Some(';') => Some(TerminalKind::Semicolon), Some('<') => match input.next() { Some('<') => match input.next() { - Some('=') => Some(TokenKind::LessThanLessThanEqual), + Some('=') => Some(TerminalKind::LessThanLessThanEqual), Some(_) => { input.undo(); - Some(TokenKind::LessThanLessThan) + Some(TerminalKind::LessThanLessThan) } - None => Some(TokenKind::LessThanLessThan), + None => Some(TerminalKind::LessThanLessThan), }, - Some('=') => Some(TokenKind::LessThanEqual), + Some('=') => Some(TerminalKind::LessThanEqual), Some(_) => { input.undo(); - Some(TokenKind::LessThan) + Some(TerminalKind::LessThan) } - None => Some(TokenKind::LessThan), + None => Some(TerminalKind::LessThan), }, Some('=') => match input.next() { - Some('=') => Some(TokenKind::EqualEqual), - Some('>') => Some(TokenKind::EqualGreaterThan), + Some('=') => Some(TerminalKind::EqualEqual), + Some('>') => Some(TerminalKind::EqualGreaterThan), Some(_) => { input.undo(); - Some(TokenKind::Equal) + Some(TerminalKind::Equal) } - None => Some(TokenKind::Equal), + None => Some(TerminalKind::Equal), }, Some('>') => match input.next() { - Some('=') => Some(TokenKind::GreaterThanEqual), + Some('=') => Some(TerminalKind::GreaterThanEqual), Some('>') => match input.next() { - Some('=') => Some(TokenKind::GreaterThanGreaterThanEqual), + Some('=') => Some(TerminalKind::GreaterThanGreaterThanEqual), Some('>') => match input.next() { Some('=') => { - Some(TokenKind::GreaterThanGreaterThanGreaterThanEqual) + Some(TerminalKind::GreaterThanGreaterThanGreaterThanEqual) } Some(_) => { input.undo(); - Some(TokenKind::GreaterThanGreaterThanGreaterThan) + Some(TerminalKind::GreaterThanGreaterThanGreaterThan) } - None => Some(TokenKind::GreaterThanGreaterThanGreaterThan), + None => Some(TerminalKind::GreaterThanGreaterThanGreaterThan), }, Some(_) => { input.undo(); - Some(TokenKind::GreaterThanGreaterThan) + Some(TerminalKind::GreaterThanGreaterThan) } - None => Some(TokenKind::GreaterThanGreaterThan), + None => Some(TerminalKind::GreaterThanGreaterThan), }, Some(_) => { input.undo(); - Some(TokenKind::GreaterThan) + Some(TerminalKind::GreaterThan) } - None => Some(TokenKind::GreaterThan), + None => Some(TerminalKind::GreaterThan), }, - Some('?') => Some(TokenKind::QuestionMark), - Some('[') => Some(TokenKind::OpenBracket), - Some(']') => Some(TokenKind::CloseBracket), + Some('?') => Some(TerminalKind::QuestionMark), + Some('[') => Some(TerminalKind::OpenBracket), + Some(']') => Some(TerminalKind::CloseBracket), Some('^') => match input.next() { - Some('=') => Some(TokenKind::CaretEqual), + Some('=') => Some(TerminalKind::CaretEqual), Some(_) => { input.undo(); - Some(TokenKind::Caret) + Some(TerminalKind::Caret) } - None => Some(TokenKind::Caret), + None => Some(TerminalKind::Caret), }, - Some('{') => Some(TokenKind::OpenBrace), + Some('{') => Some(TerminalKind::OpenBrace), Some('|') => match input.next() { - Some('=') => Some(TokenKind::BarEqual), - Some('|') => Some(TokenKind::BarBar), + Some('=') => Some(TerminalKind::BarEqual), + Some('|') => Some(TerminalKind::BarBar), Some(_) => { input.undo(); - Some(TokenKind::Bar) + Some(TerminalKind::Bar) } - None => Some(TokenKind::Bar), + None => Some(TerminalKind::Bar), }, - Some('}') => Some(TokenKind::CloseBrace), - Some('~') => Some(TokenKind::Tilde), + Some('}') => Some(TerminalKind::CloseBrace), + Some('~') => Some(TerminalKind::Tilde), Some(_) => { input.undo(); None @@ -9616,27 +9701,27 @@ impl Lexer for Language { // We have an identifier; we need to check if it's a keyword if let Some(identifier) = - longest_token.filter(|tok| [TokenKind::Identifier].contains(tok)) + longest_token.filter(|tok| [TerminalKind::Identifier].contains(tok)) { let kw_scan = match input.next() { Some('a') => match input.next() { Some('b') => { if scan_chars!(input, 's', 't', 'r', 'a', 'c', 't') { - KeywordScan::Reserved(TokenKind::AbstractKeyword) + KeywordScan::Reserved(TerminalKind::AbstractKeyword) } else { KeywordScan::Absent } } Some('d') => { if scan_chars!(input, 'd', 'r', 'e', 's', 's') { - KeywordScan::Reserved(TokenKind::AddressKeyword) + KeywordScan::Reserved(TerminalKind::AddressKeyword) } else { KeywordScan::Absent } } Some('f') => { if scan_chars!(input, 't', 'e', 'r') { - KeywordScan::Reserved(TokenKind::AfterKeyword) + KeywordScan::Reserved(TerminalKind::AfterKeyword) } else { KeywordScan::Absent } @@ -9644,7 +9729,7 @@ impl Lexer for Language { Some('l') => { if scan_chars!(input, 'i', 'a', 's') { if self.version_is_at_least_0_5_0 { - KeywordScan::Reserved(TokenKind::AliasKeyword) + KeywordScan::Reserved(TerminalKind::AliasKeyword) } else { KeywordScan::Absent } @@ -9654,7 +9739,7 @@ impl Lexer for Language { } Some('n') => { if scan_chars!(input, 'o', 'n', 'y', 'm', 'o', 'u', 's') { - KeywordScan::Reserved(TokenKind::AnonymousKeyword) + KeywordScan::Reserved(TerminalKind::AnonymousKeyword) } else { KeywordScan::Absent } @@ -9662,7 +9747,7 @@ impl Lexer for Language { Some('p') => { if scan_chars!(input, 'p', 'l', 'y') { if self.version_is_at_least_0_5_0 { - KeywordScan::Reserved(TokenKind::ApplyKeyword) + KeywordScan::Reserved(TerminalKind::ApplyKeyword) } else { KeywordScan::Absent } @@ -9673,21 +9758,21 @@ impl Lexer for Language { Some('s') => match input.next() { Some('s') => { if scan_chars!(input, 'e', 'm', 'b', 'l', 'y') { - KeywordScan::Reserved(TokenKind::AssemblyKeyword) + KeywordScan::Reserved(TerminalKind::AssemblyKeyword) } else { KeywordScan::Absent } } Some(_) => { input.undo(); - KeywordScan::Reserved(TokenKind::AsKeyword) + KeywordScan::Reserved(TerminalKind::AsKeyword) } - None => KeywordScan::Reserved(TokenKind::AsKeyword), + None => KeywordScan::Reserved(TerminalKind::AsKeyword), }, Some('u') => { if scan_chars!(input, 't', 'o') { if self.version_is_at_least_0_5_0 { - KeywordScan::Reserved(TokenKind::AutoKeyword) + KeywordScan::Reserved(TerminalKind::AutoKeyword) } else { KeywordScan::Absent } @@ -9704,21 +9789,21 @@ impl Lexer for Language { Some('b') => match input.next() { Some('o') => { if scan_chars!(input, 'o', 'l') { - KeywordScan::Reserved(TokenKind::BoolKeyword) + KeywordScan::Reserved(TerminalKind::BoolKeyword) } else { KeywordScan::Absent } } Some('r') => { if scan_chars!(input, 'e', 'a', 'k') { - KeywordScan::Reserved(TokenKind::BreakKeyword) + KeywordScan::Reserved(TerminalKind::BreakKeyword) } else { KeywordScan::Absent } } Some('y') => { if scan_chars!(input, 't', 'e') { - KeywordScan::Reserved(TokenKind::ByteKeyword) + KeywordScan::Reserved(TerminalKind::ByteKeyword) } else { KeywordScan::Absent } @@ -9734,7 +9819,7 @@ impl Lexer for Language { Some('l') => { if scan_chars!(input, 'l', 'd', 'a', 't', 'a') { if self.version_is_at_least_0_5_0 { - KeywordScan::Reserved(TokenKind::CallDataKeyword) + KeywordScan::Reserved(TerminalKind::CallDataKeyword) } else { KeywordScan::Absent } @@ -9744,14 +9829,14 @@ impl Lexer for Language { } Some('s') => { if scan_chars!(input, 'e') { - KeywordScan::Reserved(TokenKind::CaseKeyword) + KeywordScan::Reserved(TerminalKind::CaseKeyword) } else { KeywordScan::Absent } } Some('t') => { if scan_chars!(input, 'c', 'h') { - KeywordScan::Reserved(TokenKind::CatchKeyword) + KeywordScan::Reserved(TerminalKind::CatchKeyword) } else { KeywordScan::Absent } @@ -9770,7 +9855,7 @@ impl Lexer for Language { Some('a') => { if scan_chars!(input, 'n', 't') { KeywordScan::Reserved( - TokenKind::ConstantKeyword, + TerminalKind::ConstantKeyword, ) } else { KeywordScan::Absent @@ -9780,11 +9865,11 @@ impl Lexer for Language { if scan_chars!(input, 'u', 'c', 't', 'o', 'r') { if self.version_is_at_least_0_5_0 { KeywordScan::Reserved( - TokenKind::ConstructorKeyword, + TerminalKind::ConstructorKeyword, ) } else if self.version_is_at_least_0_4_22 { KeywordScan::Present( - TokenKind::ConstructorKeyword, + TerminalKind::ConstructorKeyword, ) } else { KeywordScan::Absent @@ -9806,14 +9891,14 @@ impl Lexer for Language { Some('t') => match input.next() { Some('i') => { if scan_chars!(input, 'n', 'u', 'e') { - KeywordScan::Reserved(TokenKind::ContinueKeyword) + KeywordScan::Reserved(TerminalKind::ContinueKeyword) } else { KeywordScan::Absent } } Some('r') => { if scan_chars!(input, 'a', 'c', 't') { - KeywordScan::Reserved(TokenKind::ContractKeyword) + KeywordScan::Reserved(TerminalKind::ContractKeyword) } else { KeywordScan::Absent } @@ -9833,7 +9918,7 @@ impl Lexer for Language { Some('p') => { if scan_chars!(input, 'y', 'o', 'f') { if self.version_is_at_least_0_5_0 { - KeywordScan::Reserved(TokenKind::CopyOfKeyword) + KeywordScan::Reserved(TerminalKind::CopyOfKeyword) } else { KeywordScan::Absent } @@ -9856,7 +9941,7 @@ impl Lexer for Language { Some('d') => match input.next() { Some('a') => { if scan_chars!(input, 'y', 's') { - KeywordScan::Reserved(TokenKind::DaysKeyword) + KeywordScan::Reserved(TerminalKind::DaysKeyword) } else { KeywordScan::Absent } @@ -9865,7 +9950,7 @@ impl Lexer for Language { Some('f') => match input.next() { Some('a') => { if scan_chars!(input, 'u', 'l', 't') { - KeywordScan::Reserved(TokenKind::DefaultKeyword) + KeywordScan::Reserved(TerminalKind::DefaultKeyword) } else { KeywordScan::Absent } @@ -9873,7 +9958,7 @@ impl Lexer for Language { Some('i') => { if scan_chars!(input, 'n', 'e') { if self.version_is_at_least_0_5_0 { - KeywordScan::Reserved(TokenKind::DefineKeyword) + KeywordScan::Reserved(TerminalKind::DefineKeyword) } else { KeywordScan::Absent } @@ -9889,7 +9974,7 @@ impl Lexer for Language { }, Some('l') => { if scan_chars!(input, 'e', 't', 'e') { - KeywordScan::Reserved(TokenKind::DeleteKeyword) + KeywordScan::Reserved(TerminalKind::DeleteKeyword) } else { KeywordScan::Absent } @@ -9900,7 +9985,7 @@ impl Lexer for Language { } None => KeywordScan::Absent, }, - Some('o') => KeywordScan::Reserved(TokenKind::DoKeyword), + Some('o') => KeywordScan::Reserved(TerminalKind::DoKeyword), Some(_) => { input.undo(); KeywordScan::Absent @@ -9910,7 +9995,7 @@ impl Lexer for Language { Some('e') => match input.next() { Some('l') => { if scan_chars!(input, 's', 'e') { - KeywordScan::Reserved(TokenKind::ElseKeyword) + KeywordScan::Reserved(TerminalKind::ElseKeyword) } else { KeywordScan::Absent } @@ -9918,9 +10003,9 @@ impl Lexer for Language { Some('m') => { if scan_chars!(input, 'i', 't') { if self.version_is_at_least_0_5_0 { - KeywordScan::Reserved(TokenKind::EmitKeyword) + KeywordScan::Reserved(TerminalKind::EmitKeyword) } else if self.version_is_at_least_0_4_21 { - KeywordScan::Present(TokenKind::EmitKeyword) + KeywordScan::Present(TerminalKind::EmitKeyword) } else { KeywordScan::Absent } @@ -9930,7 +10015,7 @@ impl Lexer for Language { } Some('n') => { if scan_chars!(input, 'u', 'm') { - KeywordScan::Reserved(TokenKind::EnumKeyword) + KeywordScan::Reserved(TerminalKind::EnumKeyword) } else { KeywordScan::Absent } @@ -9938,7 +10023,7 @@ impl Lexer for Language { Some('r') => { if scan_chars!(input, 'r', 'o', 'r') { if self.version_is_at_least_0_8_4 { - KeywordScan::Present(TokenKind::ErrorKeyword) + KeywordScan::Present(TerminalKind::ErrorKeyword) } else { KeywordScan::Absent } @@ -9948,21 +10033,21 @@ impl Lexer for Language { } Some('t') => { if scan_chars!(input, 'h', 'e', 'r') { - KeywordScan::Reserved(TokenKind::EtherKeyword) + KeywordScan::Reserved(TerminalKind::EtherKeyword) } else { KeywordScan::Absent } } Some('v') => { if scan_chars!(input, 'e', 'n', 't') { - KeywordScan::Reserved(TokenKind::EventKeyword) + KeywordScan::Reserved(TerminalKind::EventKeyword) } else { KeywordScan::Absent } } Some('x') => { if scan_chars!(input, 't', 'e', 'r', 'n', 'a', 'l') { - KeywordScan::Reserved(TokenKind::ExternalKeyword) + KeywordScan::Reserved(TerminalKind::ExternalKeyword) } else { KeywordScan::Absent } @@ -9981,10 +10066,12 @@ impl Lexer for Language { if scan_chars!(input, 'b', 'a', 'c', 'k') { if self.version_is_at_least_0_6_0 { KeywordScan::Reserved( - TokenKind::FallbackKeyword, + TerminalKind::FallbackKeyword, ) } else { - KeywordScan::Present(TokenKind::FallbackKeyword) + KeywordScan::Present( + TerminalKind::FallbackKeyword, + ) } } else { KeywordScan::Absent @@ -9992,7 +10079,7 @@ impl Lexer for Language { } Some('s') => { if scan_chars!(input, 'e') { - KeywordScan::Reserved(TokenKind::FalseKeyword) + KeywordScan::Reserved(TerminalKind::FalseKeyword) } else { KeywordScan::Absent } @@ -10012,7 +10099,7 @@ impl Lexer for Language { match input.next() { Some('a') => { if scan_chars!(input, 'l') { - KeywordScan::Reserved(TokenKind::FinalKeyword) + KeywordScan::Reserved(TerminalKind::FinalKeyword) } else { KeywordScan::Absent } @@ -10020,7 +10107,9 @@ impl Lexer for Language { Some('n') => { if scan_chars!(input, 'e', 'y') { if !self.version_is_at_least_0_7_0 { - KeywordScan::Reserved(TokenKind::FinneyKeyword) + KeywordScan::Reserved( + TerminalKind::FinneyKeyword, + ) } else { KeywordScan::Absent } @@ -10040,21 +10129,21 @@ impl Lexer for Language { } Some('o') => { if scan_chars!(input, 'r') { - KeywordScan::Reserved(TokenKind::ForKeyword) + KeywordScan::Reserved(TerminalKind::ForKeyword) } else { KeywordScan::Absent } } Some('r') => { if scan_chars!(input, 'o', 'm') { - KeywordScan::Present(TokenKind::FromKeyword) + KeywordScan::Present(TerminalKind::FromKeyword) } else { KeywordScan::Absent } } Some('u') => { if scan_chars!(input, 'n', 'c', 't', 'i', 'o', 'n') { - KeywordScan::Reserved(TokenKind::FunctionKeyword) + KeywordScan::Reserved(TerminalKind::FunctionKeyword) } else { KeywordScan::Absent } @@ -10069,7 +10158,7 @@ impl Lexer for Language { Some('l') => { if scan_chars!(input, 'o', 'b', 'a', 'l') { if self.version_is_at_least_0_8_13 { - KeywordScan::Present(TokenKind::GlobalKeyword) + KeywordScan::Present(TerminalKind::GlobalKeyword) } else { KeywordScan::Absent } @@ -10080,9 +10169,9 @@ impl Lexer for Language { Some('w') => { if scan_chars!(input, 'e', 'i') { if self.version_is_at_least_0_7_0 { - KeywordScan::Reserved(TokenKind::GweiKeyword) + KeywordScan::Reserved(TerminalKind::GweiKeyword) } else if self.version_is_at_least_0_6_11 { - KeywordScan::Present(TokenKind::GweiKeyword) + KeywordScan::Present(TerminalKind::GweiKeyword) } else { KeywordScan::Absent } @@ -10099,14 +10188,14 @@ impl Lexer for Language { Some('h') => match input.next() { Some('e') => { if scan_chars!(input, 'x') { - KeywordScan::Reserved(TokenKind::HexKeyword) + KeywordScan::Reserved(TerminalKind::HexKeyword) } else { KeywordScan::Absent } } Some('o') => { if scan_chars!(input, 'u', 'r', 's') { - KeywordScan::Reserved(TokenKind::HoursKeyword) + KeywordScan::Reserved(TerminalKind::HoursKeyword) } else { KeywordScan::Absent } @@ -10118,14 +10207,14 @@ impl Lexer for Language { None => KeywordScan::Absent, }, Some('i') => match input.next() { - Some('f') => KeywordScan::Reserved(TokenKind::IfKeyword), + Some('f') => KeywordScan::Reserved(TerminalKind::IfKeyword), Some('m') => match input.next() { Some('m') => { if scan_chars!(input, 'u', 't', 'a', 'b', 'l', 'e') { if self.version_is_at_least_0_5_0 { - KeywordScan::Reserved(TokenKind::ImmutableKeyword) + KeywordScan::Reserved(TerminalKind::ImmutableKeyword) } else if self.version_is_at_least_0_6_5 { - KeywordScan::Present(TokenKind::ImmutableKeyword) + KeywordScan::Present(TerminalKind::ImmutableKeyword) } else { KeywordScan::Absent } @@ -10137,7 +10226,9 @@ impl Lexer for Language { Some('l') => { if scan_chars!(input, 'e', 'm', 'e', 'n', 't', 's') { if self.version_is_at_least_0_5_0 { - KeywordScan::Reserved(TokenKind::ImplementsKeyword) + KeywordScan::Reserved( + TerminalKind::ImplementsKeyword, + ) } else { KeywordScan::Absent } @@ -10147,7 +10238,7 @@ impl Lexer for Language { } Some('o') => { if scan_chars!(input, 'r', 't') { - KeywordScan::Reserved(TokenKind::ImportKeyword) + KeywordScan::Reserved(TerminalKind::ImportKeyword) } else { KeywordScan::Absent } @@ -10167,14 +10258,14 @@ impl Lexer for Language { Some('n') => match input.next() { Some('d') => { if scan_chars!(input, 'e', 'x', 'e', 'd') { - KeywordScan::Reserved(TokenKind::IndexedKeyword) + KeywordScan::Reserved(TerminalKind::IndexedKeyword) } else { KeywordScan::Absent } } Some('l') => { if scan_chars!(input, 'i', 'n', 'e') { - KeywordScan::Reserved(TokenKind::InlineKeyword) + KeywordScan::Reserved(TerminalKind::InlineKeyword) } else { KeywordScan::Absent } @@ -10185,7 +10276,7 @@ impl Lexer for Language { Some('f') => { if scan_chars!(input, 'a', 'c', 'e') { KeywordScan::Reserved( - TokenKind::InterfaceKeyword, + TerminalKind::InterfaceKeyword, ) } else { KeywordScan::Absent @@ -10194,7 +10285,7 @@ impl Lexer for Language { Some('n') => { if scan_chars!(input, 'a', 'l') { KeywordScan::Reserved( - TokenKind::InternalKeyword, + TerminalKind::InternalKeyword, ) } else { KeywordScan::Absent @@ -10212,11 +10303,11 @@ impl Lexer for Language { } Some(_) => { input.undo(); - KeywordScan::Reserved(TokenKind::InKeyword) + KeywordScan::Reserved(TerminalKind::InKeyword) } - None => KeywordScan::Reserved(TokenKind::InKeyword), + None => KeywordScan::Reserved(TerminalKind::InKeyword), }, - Some('s') => KeywordScan::Reserved(TokenKind::IsKeyword), + Some('s') => KeywordScan::Reserved(TerminalKind::IsKeyword), Some(_) => { input.undo(); KeywordScan::Absent @@ -10226,14 +10317,14 @@ impl Lexer for Language { Some('l') => match input.next() { Some('e') => { if scan_chars!(input, 't') { - KeywordScan::Reserved(TokenKind::LetKeyword) + KeywordScan::Reserved(TerminalKind::LetKeyword) } else { KeywordScan::Absent } } Some('i') => { if scan_chars!(input, 'b', 'r', 'a', 'r', 'y') { - KeywordScan::Reserved(TokenKind::LibraryKeyword) + KeywordScan::Reserved(TerminalKind::LibraryKeyword) } else { KeywordScan::Absent } @@ -10249,7 +10340,7 @@ impl Lexer for Language { Some('c') => { if scan_chars!(input, 'r', 'o') { if self.version_is_at_least_0_5_0 { - KeywordScan::Reserved(TokenKind::MacroKeyword) + KeywordScan::Reserved(TerminalKind::MacroKeyword) } else { KeywordScan::Absent } @@ -10259,14 +10350,14 @@ impl Lexer for Language { } Some('p') => { if scan_chars!(input, 'p', 'i', 'n', 'g') { - KeywordScan::Reserved(TokenKind::MappingKeyword) + KeywordScan::Reserved(TerminalKind::MappingKeyword) } else { KeywordScan::Absent } } Some('t') => { if scan_chars!(input, 'c', 'h') { - KeywordScan::Reserved(TokenKind::MatchKeyword) + KeywordScan::Reserved(TerminalKind::MatchKeyword) } else { KeywordScan::Absent } @@ -10279,21 +10370,21 @@ impl Lexer for Language { }, Some('e') => { if scan_chars!(input, 'm', 'o', 'r', 'y') { - KeywordScan::Reserved(TokenKind::MemoryKeyword) + KeywordScan::Reserved(TerminalKind::MemoryKeyword) } else { KeywordScan::Absent } } Some('i') => { if scan_chars!(input, 'n', 'u', 't', 'e', 's') { - KeywordScan::Reserved(TokenKind::MinutesKeyword) + KeywordScan::Reserved(TerminalKind::MinutesKeyword) } else { KeywordScan::Absent } } Some('o') => { if scan_chars!(input, 'd', 'i', 'f', 'i', 'e', 'r') { - KeywordScan::Reserved(TokenKind::ModifierKeyword) + KeywordScan::Reserved(TerminalKind::ModifierKeyword) } else { KeywordScan::Absent } @@ -10301,7 +10392,7 @@ impl Lexer for Language { Some('u') => { if scan_chars!(input, 't', 'a', 'b', 'l', 'e') { if self.version_is_at_least_0_5_0 { - KeywordScan::Reserved(TokenKind::MutableKeyword) + KeywordScan::Reserved(TerminalKind::MutableKeyword) } else { KeywordScan::Absent } @@ -10318,14 +10409,14 @@ impl Lexer for Language { Some('n') => match input.next() { Some('e') => { if scan_chars!(input, 'w') { - KeywordScan::Reserved(TokenKind::NewKeyword) + KeywordScan::Reserved(TerminalKind::NewKeyword) } else { KeywordScan::Absent } } Some('u') => { if scan_chars!(input, 'l', 'l') { - KeywordScan::Reserved(TokenKind::NullKeyword) + KeywordScan::Reserved(TerminalKind::NullKeyword) } else { KeywordScan::Absent } @@ -10337,13 +10428,13 @@ impl Lexer for Language { None => KeywordScan::Absent, }, Some('o') => match input.next() { - Some('f') => KeywordScan::Reserved(TokenKind::OfKeyword), + Some('f') => KeywordScan::Reserved(TerminalKind::OfKeyword), Some('v') => { if scan_chars!(input, 'e', 'r', 'r', 'i', 'd', 'e') { if self.version_is_at_least_0_5_0 { - KeywordScan::Reserved(TokenKind::OverrideKeyword) + KeywordScan::Reserved(TerminalKind::OverrideKeyword) } else if self.version_is_at_least_0_6_0 { - KeywordScan::Present(TokenKind::OverrideKeyword) + KeywordScan::Present(TerminalKind::OverrideKeyword) } else { KeywordScan::Absent } @@ -10362,7 +10453,7 @@ impl Lexer for Language { Some('r') => { if scan_chars!(input, 't', 'i', 'a', 'l') { if self.version_is_at_least_0_5_0 { - KeywordScan::Reserved(TokenKind::PartialKeyword) + KeywordScan::Reserved(TerminalKind::PartialKeyword) } else { KeywordScan::Absent } @@ -10372,7 +10463,7 @@ impl Lexer for Language { } Some('y') => { if scan_chars!(input, 'a', 'b', 'l', 'e') { - KeywordScan::Reserved(TokenKind::PayableKeyword) + KeywordScan::Reserved(TerminalKind::PayableKeyword) } else { KeywordScan::Absent } @@ -10386,14 +10477,14 @@ impl Lexer for Language { Some('r') => match input.next() { Some('a') => { if scan_chars!(input, 'g', 'm', 'a') { - KeywordScan::Reserved(TokenKind::PragmaKeyword) + KeywordScan::Reserved(TerminalKind::PragmaKeyword) } else { KeywordScan::Absent } } Some('i') => { if scan_chars!(input, 'v', 'a', 't', 'e') { - KeywordScan::Reserved(TokenKind::PrivateKeyword) + KeywordScan::Reserved(TerminalKind::PrivateKeyword) } else { KeywordScan::Absent } @@ -10401,7 +10492,7 @@ impl Lexer for Language { Some('o') => { if scan_chars!(input, 'm', 'i', 's', 'e') { if self.version_is_at_least_0_5_0 { - KeywordScan::Reserved(TokenKind::PromiseKeyword) + KeywordScan::Reserved(TerminalKind::PromiseKeyword) } else { KeywordScan::Absent } @@ -10418,14 +10509,14 @@ impl Lexer for Language { Some('u') => match input.next() { Some('b') => { if scan_chars!(input, 'l', 'i', 'c') { - KeywordScan::Reserved(TokenKind::PublicKeyword) + KeywordScan::Reserved(TerminalKind::PublicKeyword) } else { KeywordScan::Absent } } Some('r') => { if scan_chars!(input, 'e') { - KeywordScan::Reserved(TokenKind::PureKeyword) + KeywordScan::Reserved(TerminalKind::PureKeyword) } else { KeywordScan::Absent } @@ -10448,9 +10539,9 @@ impl Lexer for Language { Some('c') => { if scan_chars!(input, 'e', 'i', 'v', 'e') { if self.version_is_at_least_0_6_0 { - KeywordScan::Reserved(TokenKind::ReceiveKeyword) + KeywordScan::Reserved(TerminalKind::ReceiveKeyword) } else { - KeywordScan::Present(TokenKind::ReceiveKeyword) + KeywordScan::Present(TerminalKind::ReceiveKeyword) } } else { KeywordScan::Absent @@ -10459,7 +10550,9 @@ impl Lexer for Language { Some('f') => { if scan_chars!(input, 'e', 'r', 'e', 'n', 'c', 'e') { if self.version_is_at_least_0_5_0 { - KeywordScan::Reserved(TokenKind::ReferenceKeyword) + KeywordScan::Reserved( + TerminalKind::ReferenceKeyword, + ) } else { KeywordScan::Absent } @@ -10471,7 +10564,7 @@ impl Lexer for Language { if scan_chars!( input, 'o', 'c', 'a', 't', 'a', 'b', 'l', 'e' ) { - KeywordScan::Reserved(TokenKind::RelocatableKeyword) + KeywordScan::Reserved(TerminalKind::RelocatableKeyword) } else { KeywordScan::Absent } @@ -10479,16 +10572,18 @@ impl Lexer for Language { Some('t') => { if scan_chars!(input, 'u', 'r', 'n') { match input.next() { - Some('s') => { - KeywordScan::Reserved(TokenKind::ReturnsKeyword) - } + Some('s') => KeywordScan::Reserved( + TerminalKind::ReturnsKeyword, + ), Some(_) => { input.undo(); - KeywordScan::Reserved(TokenKind::ReturnKeyword) - } - None => { - KeywordScan::Reserved(TokenKind::ReturnKeyword) + KeywordScan::Reserved( + TerminalKind::ReturnKeyword, + ) } + None => KeywordScan::Reserved( + TerminalKind::ReturnKeyword, + ), } } else { KeywordScan::Absent @@ -10497,7 +10592,7 @@ impl Lexer for Language { Some('v') => { if scan_chars!(input, 'e', 'r', 't') { if self.version_is_at_least_0_8_4 { - KeywordScan::Present(TokenKind::RevertKeyword) + KeywordScan::Present(TerminalKind::RevertKeyword) } else { KeywordScan::Absent } @@ -10520,7 +10615,7 @@ impl Lexer for Language { Some('a') => { if scan_chars!(input, 'l', 'e', 'd') { if self.version_is_at_least_0_5_0 { - KeywordScan::Reserved(TokenKind::SealedKeyword) + KeywordScan::Reserved(TerminalKind::SealedKeyword) } else { KeywordScan::Absent } @@ -10530,7 +10625,7 @@ impl Lexer for Language { } Some('c') => { if scan_chars!(input, 'o', 'n', 'd', 's') { - KeywordScan::Reserved(TokenKind::SecondsKeyword) + KeywordScan::Reserved(TerminalKind::SecondsKeyword) } else { KeywordScan::Absent } @@ -10544,7 +10639,7 @@ impl Lexer for Language { Some('i') => { if scan_chars!(input, 'z', 'e', 'o', 'f') { if self.version_is_at_least_0_5_0 { - KeywordScan::Reserved(TokenKind::SizeOfKeyword) + KeywordScan::Reserved(TerminalKind::SizeOfKeyword) } else { KeywordScan::Absent } @@ -10555,14 +10650,14 @@ impl Lexer for Language { Some('t') => match input.next() { Some('a') => { if scan_chars!(input, 't', 'i', 'c') { - KeywordScan::Reserved(TokenKind::StaticKeyword) + KeywordScan::Reserved(TerminalKind::StaticKeyword) } else { KeywordScan::Absent } } Some('o') => { if scan_chars!(input, 'r', 'a', 'g', 'e') { - KeywordScan::Reserved(TokenKind::StorageKeyword) + KeywordScan::Reserved(TerminalKind::StorageKeyword) } else { KeywordScan::Absent } @@ -10570,14 +10665,14 @@ impl Lexer for Language { Some('r') => match input.next() { Some('i') => { if scan_chars!(input, 'n', 'g') { - KeywordScan::Reserved(TokenKind::StringKeyword) + KeywordScan::Reserved(TerminalKind::StringKeyword) } else { KeywordScan::Absent } } Some('u') => { if scan_chars!(input, 'c', 't') { - KeywordScan::Reserved(TokenKind::StructKeyword) + KeywordScan::Reserved(TerminalKind::StructKeyword) } else { KeywordScan::Absent } @@ -10597,7 +10692,7 @@ impl Lexer for Language { Some('u') => { if scan_chars!(input, 'p', 'p', 'o', 'r', 't', 's') { if self.version_is_at_least_0_5_0 { - KeywordScan::Reserved(TokenKind::SupportsKeyword) + KeywordScan::Reserved(TerminalKind::SupportsKeyword) } else { KeywordScan::Absent } @@ -10607,7 +10702,7 @@ impl Lexer for Language { } Some('w') => { if scan_chars!(input, 'i', 't', 'c', 'h') { - KeywordScan::Reserved(TokenKind::SwitchKeyword) + KeywordScan::Reserved(TerminalKind::SwitchKeyword) } else { KeywordScan::Absent } @@ -10615,7 +10710,7 @@ impl Lexer for Language { Some('z') => { if scan_chars!(input, 'a', 'b', 'o') { if !self.version_is_at_least_0_7_0 { - KeywordScan::Reserved(TokenKind::SzaboKeyword) + KeywordScan::Reserved(TerminalKind::SzaboKeyword) } else { KeywordScan::Absent } @@ -10632,7 +10727,7 @@ impl Lexer for Language { Some('t') => match input.next() { Some('h') => { if scan_chars!(input, 'r', 'o', 'w') { - KeywordScan::Reserved(TokenKind::ThrowKeyword) + KeywordScan::Reserved(TerminalKind::ThrowKeyword) } else { KeywordScan::Absent } @@ -10640,12 +10735,12 @@ impl Lexer for Language { Some('r') => match input.next() { Some('u') => { if scan_chars!(input, 'e') { - KeywordScan::Reserved(TokenKind::TrueKeyword) + KeywordScan::Reserved(TerminalKind::TrueKeyword) } else { KeywordScan::Absent } } - Some('y') => KeywordScan::Reserved(TokenKind::TryKeyword), + Some('y') => KeywordScan::Reserved(TerminalKind::TryKeyword), Some(_) => { input.undo(); KeywordScan::Absent @@ -10658,7 +10753,9 @@ impl Lexer for Language { Some('d') => { if scan_chars!(input, 'e', 'f') { if self.version_is_at_least_0_5_0 { - KeywordScan::Reserved(TokenKind::TypeDefKeyword) + KeywordScan::Reserved( + TerminalKind::TypeDefKeyword, + ) } else { KeywordScan::Absent } @@ -10668,16 +10765,16 @@ impl Lexer for Language { } Some('o') => { if scan_chars!(input, 'f') { - KeywordScan::Reserved(TokenKind::TypeOfKeyword) + KeywordScan::Reserved(TerminalKind::TypeOfKeyword) } else { KeywordScan::Absent } } Some(_) => { input.undo(); - KeywordScan::Reserved(TokenKind::TypeKeyword) + KeywordScan::Reserved(TerminalKind::TypeKeyword) } - None => KeywordScan::Reserved(TokenKind::TypeKeyword), + None => KeywordScan::Reserved(TerminalKind::TypeKeyword), } } else { KeywordScan::Absent @@ -10693,9 +10790,9 @@ impl Lexer for Language { Some('n') => { if scan_chars!(input, 'c', 'h', 'e', 'c', 'k', 'e', 'd') { if self.version_is_at_least_0_5_0 { - KeywordScan::Reserved(TokenKind::UncheckedKeyword) + KeywordScan::Reserved(TerminalKind::UncheckedKeyword) } else if self.version_is_at_least_0_8_0 { - KeywordScan::Present(TokenKind::UncheckedKeyword) + KeywordScan::Present(TerminalKind::UncheckedKeyword) } else { KeywordScan::Absent } @@ -10705,7 +10802,7 @@ impl Lexer for Language { } Some('s') => { if scan_chars!(input, 'i', 'n', 'g') { - KeywordScan::Reserved(TokenKind::UsingKeyword) + KeywordScan::Reserved(TerminalKind::UsingKeyword) } else { KeywordScan::Absent } @@ -10719,7 +10816,7 @@ impl Lexer for Language { Some('v') => match input.next() { Some('a') => { if scan_chars!(input, 'r') { - KeywordScan::Reserved(TokenKind::VarKeyword) + KeywordScan::Reserved(TerminalKind::VarKeyword) } else { KeywordScan::Absent } @@ -10727,7 +10824,7 @@ impl Lexer for Language { Some('i') => match input.next() { Some('e') => { if scan_chars!(input, 'w') { - KeywordScan::Reserved(TokenKind::ViewKeyword) + KeywordScan::Reserved(TerminalKind::ViewKeyword) } else { KeywordScan::Absent } @@ -10735,7 +10832,7 @@ impl Lexer for Language { Some('r') => { if scan_chars!(input, 't', 'u', 'a', 'l') { if self.version_is_at_least_0_6_0 { - KeywordScan::Reserved(TokenKind::VirtualKeyword) + KeywordScan::Reserved(TerminalKind::VirtualKeyword) } else { KeywordScan::Absent } @@ -10759,12 +10856,12 @@ impl Lexer for Language { Some('e') => match input.next() { Some('e') => { if scan_chars!(input, 'k', 's') { - KeywordScan::Reserved(TokenKind::WeeksKeyword) + KeywordScan::Reserved(TerminalKind::WeeksKeyword) } else { KeywordScan::Absent } } - Some('i') => KeywordScan::Reserved(TokenKind::WeiKeyword), + Some('i') => KeywordScan::Reserved(TerminalKind::WeiKeyword), Some(_) => { input.undo(); KeywordScan::Absent @@ -10773,7 +10870,7 @@ impl Lexer for Language { }, Some('h') => { if scan_chars!(input, 'i', 'l', 'e') { - KeywordScan::Reserved(TokenKind::WhileKeyword) + KeywordScan::Reserved(TerminalKind::WhileKeyword) } else { KeywordScan::Absent } @@ -10786,7 +10883,7 @@ impl Lexer for Language { }, Some('y') => { if scan_chars!(input, 'e', 'a', 'r', 's') { - KeywordScan::Reserved(TokenKind::YearsKeyword) + KeywordScan::Reserved(TerminalKind::YearsKeyword) } else { KeywordScan::Absent } @@ -10836,35 +10933,35 @@ impl Lexer for Language { } LexicalContext::Pragma => { if let Some(kind) = match input.next() { - Some('-') => Some(TokenKind::Minus), - Some('.') => Some(TokenKind::Period), - Some(';') => Some(TokenKind::Semicolon), + Some('-') => Some(TerminalKind::Minus), + Some('.') => Some(TerminalKind::Period), + Some(';') => Some(TerminalKind::Semicolon), Some('<') => match input.next() { - Some('=') => Some(TokenKind::LessThanEqual), + Some('=') => Some(TerminalKind::LessThanEqual), Some(_) => { input.undo(); - Some(TokenKind::LessThan) + Some(TerminalKind::LessThan) } - None => Some(TokenKind::LessThan), + None => Some(TerminalKind::LessThan), }, - Some('=') => Some(TokenKind::Equal), + Some('=') => Some(TerminalKind::Equal), Some('>') => match input.next() { - Some('=') => Some(TokenKind::GreaterThanEqual), + Some('=') => Some(TerminalKind::GreaterThanEqual), Some(_) => { input.undo(); - Some(TokenKind::GreaterThan) + Some(TerminalKind::GreaterThan) } - None => Some(TokenKind::GreaterThan), + None => Some(TerminalKind::GreaterThan), }, - Some('^') => Some(TokenKind::Caret), + Some('^') => Some(TerminalKind::Caret), Some('|') => { if scan_chars!(input, '|') { - Some(TokenKind::BarBar) + Some(TerminalKind::BarBar) } else { None } } - Some('~') => Some(TokenKind::Tilde), + Some('~') => Some(TerminalKind::Tilde), Some(_) => { input.undo(); None @@ -10888,12 +10985,12 @@ impl Lexer for Language { // We have an identifier; we need to check if it's a keyword if let Some(identifier) = - longest_token.filter(|tok| [TokenKind::Identifier].contains(tok)) + longest_token.filter(|tok| [TerminalKind::Identifier].contains(tok)) { let kw_scan = match input.next() { Some('a') => { if scan_chars!(input, 'b', 'i', 'c', 'o', 'd', 'e', 'r') { - KeywordScan::Present(TokenKind::AbicoderKeyword) + KeywordScan::Present(TerminalKind::AbicoderKeyword) } else { KeywordScan::Absent } @@ -10902,21 +10999,21 @@ impl Lexer for Language { if scan_chars!( input, 'x', 'p', 'e', 'r', 'i', 'm', 'e', 'n', 't', 'a', 'l' ) { - KeywordScan::Present(TokenKind::ExperimentalKeyword) + KeywordScan::Present(TerminalKind::ExperimentalKeyword) } else { KeywordScan::Absent } } Some('p') => { if scan_chars!(input, 'r', 'a', 'g', 'm', 'a') { - KeywordScan::Reserved(TokenKind::PragmaKeyword) + KeywordScan::Reserved(TerminalKind::PragmaKeyword) } else { KeywordScan::Absent } } Some('s') => { if scan_chars!(input, 'o', 'l', 'i', 'd', 'i', 't', 'y') { - KeywordScan::Present(TokenKind::SolidityKeyword) + KeywordScan::Present(TerminalKind::SolidityKeyword) } else { KeywordScan::Absent } @@ -10942,28 +11039,28 @@ impl Lexer for Language { } LexicalContext::Yul => { if let Some(kind) = match input.next() { - Some('(') => Some(TokenKind::OpenParen), - Some(')') => Some(TokenKind::CloseParen), - Some(',') => Some(TokenKind::Comma), + Some('(') => Some(TerminalKind::OpenParen), + Some(')') => Some(TerminalKind::CloseParen), + Some(',') => Some(TerminalKind::Comma), Some('-') => { if scan_chars!(input, '>') { - Some(TokenKind::MinusGreaterThan) + Some(TerminalKind::MinusGreaterThan) } else { None } } - Some('.') => Some(TokenKind::Period), + Some('.') => Some(TerminalKind::Period), Some(':') => match input.next() { - Some('=') => Some(TokenKind::ColonEqual), + Some('=') => Some(TerminalKind::ColonEqual), Some(_) => { input.undo(); - Some(TokenKind::Colon) + Some(TerminalKind::Colon) } - None => Some(TokenKind::Colon), + None => Some(TerminalKind::Colon), }, - Some('=') => Some(TokenKind::Equal), - Some('{') => Some(TokenKind::OpenBrace), - Some('}') => Some(TokenKind::CloseBrace), + Some('=') => Some(TerminalKind::Equal), + Some('{') => Some(TerminalKind::OpenBrace), + Some('}') => Some(TerminalKind::CloseBrace), Some(_) => { input.undo(); None @@ -10986,14 +11083,14 @@ impl Lexer for Language { // We have an identifier; we need to check if it's a keyword if let Some(identifier) = - longest_token.filter(|tok| [TokenKind::YulIdentifier].contains(tok)) + longest_token.filter(|tok| [TerminalKind::YulIdentifier].contains(tok)) { let kw_scan = match input.next() { Some('a') => match input.next() { Some('b') => { if scan_chars!(input, 's', 't', 'r', 'a', 'c', 't') { if !self.version_is_at_least_0_7_1 { - KeywordScan::Reserved(TokenKind::YulAbstractKeyword) + KeywordScan::Reserved(TerminalKind::YulAbstractKeyword) } else { KeywordScan::Absent } @@ -11006,23 +11103,27 @@ impl Lexer for Language { match input.next() { Some('m') => { if scan_chars!(input, 'o', 'd') { - KeywordScan::Reserved(TokenKind::YulAddModKeyword) + KeywordScan::Reserved( + TerminalKind::YulAddModKeyword, + ) } else { KeywordScan::Absent } } Some('r') => { if scan_chars!(input, 'e', 's', 's') { - KeywordScan::Reserved(TokenKind::YulAddressKeyword) + KeywordScan::Reserved( + TerminalKind::YulAddressKeyword, + ) } else { KeywordScan::Absent } } Some(_) => { input.undo(); - KeywordScan::Reserved(TokenKind::YulAddKeyword) + KeywordScan::Reserved(TerminalKind::YulAddKeyword) } - None => KeywordScan::Reserved(TokenKind::YulAddKeyword), + None => KeywordScan::Reserved(TerminalKind::YulAddKeyword), } } else { KeywordScan::Absent @@ -11031,7 +11132,7 @@ impl Lexer for Language { Some('f') => { if scan_chars!(input, 't', 'e', 'r') { if !self.version_is_at_least_0_7_1 { - KeywordScan::Reserved(TokenKind::YulAfterKeyword) + KeywordScan::Reserved(TerminalKind::YulAfterKeyword) } else { KeywordScan::Absent } @@ -11044,7 +11145,7 @@ impl Lexer for Language { if self.version_is_at_least_0_5_0 && !self.version_is_at_least_0_7_1 { - KeywordScan::Reserved(TokenKind::YulAliasKeyword) + KeywordScan::Reserved(TerminalKind::YulAliasKeyword) } else { KeywordScan::Absent } @@ -11053,11 +11154,11 @@ impl Lexer for Language { } } Some('n') => match input.next() { - Some('d') => KeywordScan::Reserved(TokenKind::YulAndKeyword), + Some('d') => KeywordScan::Reserved(TerminalKind::YulAndKeyword), Some('o') => { if scan_chars!(input, 'n', 'y', 'm', 'o', 'u', 's') { if !self.version_is_at_least_0_7_1 { - KeywordScan::Reserved(TokenKind::YulAnonymousKeyword) + KeywordScan::Reserved(TerminalKind::YulAnonymousKeyword) } else { KeywordScan::Absent } @@ -11076,7 +11177,7 @@ impl Lexer for Language { if self.version_is_at_least_0_5_0 && !self.version_is_at_least_0_7_1 { - KeywordScan::Reserved(TokenKind::YulApplyKeyword) + KeywordScan::Reserved(TerminalKind::YulApplyKeyword) } else { KeywordScan::Absent } @@ -11088,7 +11189,7 @@ impl Lexer for Language { Some('s') => { if scan_chars!(input, 'e', 'm', 'b', 'l', 'y') { if !self.version_is_at_least_0_7_1 { - KeywordScan::Reserved(TokenKind::YulAssemblyKeyword) + KeywordScan::Reserved(TerminalKind::YulAssemblyKeyword) } else { KeywordScan::Absent } @@ -11099,14 +11200,14 @@ impl Lexer for Language { Some(_) => { input.undo(); if !self.version_is_at_least_0_7_1 { - KeywordScan::Reserved(TokenKind::YulAsKeyword) + KeywordScan::Reserved(TerminalKind::YulAsKeyword) } else { KeywordScan::Absent } } None => { if !self.version_is_at_least_0_7_1 { - KeywordScan::Reserved(TokenKind::YulAsKeyword) + KeywordScan::Reserved(TerminalKind::YulAsKeyword) } else { KeywordScan::Absent } @@ -11117,7 +11218,7 @@ impl Lexer for Language { if self.version_is_at_least_0_5_0 && !self.version_is_at_least_0_7_1 { - KeywordScan::Reserved(TokenKind::YulAutoKeyword) + KeywordScan::Reserved(TerminalKind::YulAutoKeyword) } else { KeywordScan::Absent } @@ -11135,7 +11236,7 @@ impl Lexer for Language { Some('a') => match input.next() { Some('l') => { if scan_chars!(input, 'a', 'n', 'c', 'e') { - KeywordScan::Reserved(TokenKind::YulBalanceKeyword) + KeywordScan::Reserved(TerminalKind::YulBalanceKeyword) } else { KeywordScan::Absent } @@ -11143,7 +11244,7 @@ impl Lexer for Language { Some('s') => { if scan_chars!(input, 'e', 'f', 'e', 'e') { if self.version_is_at_least_0_8_7 { - KeywordScan::Reserved(TokenKind::YulBaseFeeKeyword) + KeywordScan::Reserved(TerminalKind::YulBaseFeeKeyword) } else { KeywordScan::Absent } @@ -11166,7 +11267,7 @@ impl Lexer for Language { { if self.version_is_at_least_0_8_24 { KeywordScan::Reserved( - TokenKind::YulBlobBaseFeeKeyword, + TerminalKind::YulBlobBaseFeeKeyword, ) } else { KeywordScan::Absent @@ -11179,7 +11280,7 @@ impl Lexer for Language { if scan_chars!(input, 'a', 's', 'h') { if self.version_is_at_least_0_8_24 { KeywordScan::Reserved( - TokenKind::YulBlobHashKeyword, + TerminalKind::YulBlobHashKeyword, ) } else { KeywordScan::Absent @@ -11197,7 +11298,7 @@ impl Lexer for Language { Some('c') => { if scan_chars!(input, 'k', 'h', 'a', 's', 'h') { KeywordScan::Reserved( - TokenKind::YulBlockHashKeyword, + TerminalKind::YulBlockHashKeyword, ) } else { KeywordScan::Absent @@ -11216,7 +11317,7 @@ impl Lexer for Language { Some('o') => { if scan_chars!(input, 'o', 'l') { if !self.version_is_at_least_0_5_10 { - KeywordScan::Reserved(TokenKind::YulBoolKeyword) + KeywordScan::Reserved(TerminalKind::YulBoolKeyword) } else { KeywordScan::Absent } @@ -11226,14 +11327,14 @@ impl Lexer for Language { } Some('r') => { if scan_chars!(input, 'e', 'a', 'k') { - KeywordScan::Reserved(TokenKind::YulBreakKeyword) + KeywordScan::Reserved(TerminalKind::YulBreakKeyword) } else { KeywordScan::Absent } } Some('y') => { if scan_chars!(input, 't', 'e') { - KeywordScan::Reserved(TokenKind::YulByteKeyword) + KeywordScan::Reserved(TerminalKind::YulByteKeyword) } else { KeywordScan::Absent } @@ -11252,7 +11353,7 @@ impl Lexer for Language { Some('c') => { if scan_chars!(input, 'o', 'd', 'e') { KeywordScan::Reserved( - TokenKind::YulCallCodeKeyword, + TerminalKind::YulCallCodeKeyword, ) } else { KeywordScan::Absent @@ -11263,21 +11364,21 @@ impl Lexer for Language { match input.next() { Some('c') => { if scan_chars!(input, 'o', 'p', 'y') { - KeywordScan :: Reserved (TokenKind :: YulCallDataCopyKeyword) + KeywordScan :: Reserved (TerminalKind :: YulCallDataCopyKeyword) } else { KeywordScan::Absent } } Some('l') => { if scan_chars!(input, 'o', 'a', 'd') { - KeywordScan :: Reserved (TokenKind :: YulCallDataLoadKeyword) + KeywordScan :: Reserved (TerminalKind :: YulCallDataLoadKeyword) } else { KeywordScan::Absent } } Some('s') => { if scan_chars!(input, 'i', 'z', 'e') { - KeywordScan :: Reserved (TokenKind :: YulCallDataSizeKeyword) + KeywordScan :: Reserved (TerminalKind :: YulCallDataSizeKeyword) } else { KeywordScan::Absent } @@ -11287,9 +11388,7 @@ impl Lexer for Language { if self.version_is_at_least_0_5_0 && !self.version_is_at_least_0_7_1 { - KeywordScan::Reserved( - TokenKind::YulCallDataKeyword, - ) + KeywordScan :: Reserved (TerminalKind :: YulCallDataKeyword) } else { KeywordScan::Absent } @@ -11298,9 +11397,7 @@ impl Lexer for Language { if self.version_is_at_least_0_5_0 && !self.version_is_at_least_0_7_1 { - KeywordScan::Reserved( - TokenKind::YulCallDataKeyword, - ) + KeywordScan :: Reserved (TerminalKind :: YulCallDataKeyword) } else { KeywordScan::Absent } @@ -11313,7 +11410,7 @@ impl Lexer for Language { Some('e') => { if scan_chars!(input, 'r') { KeywordScan::Reserved( - TokenKind::YulCallerKeyword, + TerminalKind::YulCallerKeyword, ) } else { KeywordScan::Absent @@ -11322,7 +11419,7 @@ impl Lexer for Language { Some('v') => { if scan_chars!(input, 'a', 'l', 'u', 'e') { KeywordScan::Reserved( - TokenKind::YulCallValueKeyword, + TerminalKind::YulCallValueKeyword, ) } else { KeywordScan::Absent @@ -11330,10 +11427,10 @@ impl Lexer for Language { } Some(_) => { input.undo(); - KeywordScan::Reserved(TokenKind::YulCallKeyword) + KeywordScan::Reserved(TerminalKind::YulCallKeyword) } None => { - KeywordScan::Reserved(TokenKind::YulCallKeyword) + KeywordScan::Reserved(TerminalKind::YulCallKeyword) } } } else { @@ -11342,7 +11439,7 @@ impl Lexer for Language { } Some('s') => { if scan_chars!(input, 'e') { - KeywordScan::Reserved(TokenKind::YulCaseKeyword) + KeywordScan::Reserved(TerminalKind::YulCaseKeyword) } else { KeywordScan::Absent } @@ -11350,7 +11447,7 @@ impl Lexer for Language { Some('t') => { if scan_chars!(input, 'c', 'h') { if !self.version_is_at_least_0_7_1 { - KeywordScan::Reserved(TokenKind::YulCatchKeyword) + KeywordScan::Reserved(TerminalKind::YulCatchKeyword) } else { KeywordScan::Absent } @@ -11367,9 +11464,9 @@ impl Lexer for Language { Some('h') => { if scan_chars!(input, 'a', 'i', 'n', 'i', 'd') { if self.version_is_at_least_0_5_12 { - KeywordScan::Reserved(TokenKind::YulChainIdKeyword) + KeywordScan::Reserved(TerminalKind::YulChainIdKeyword) } else { - KeywordScan::Present(TokenKind::YulChainIdKeyword) + KeywordScan::Present(TerminalKind::YulChainIdKeyword) } } else { KeywordScan::Absent @@ -11378,92 +11475,94 @@ impl Lexer for Language { Some('o') => match input.next() { Some('i') => { if scan_chars!(input, 'n', 'b', 'a', 's', 'e') { - KeywordScan::Reserved(TokenKind::YulCoinBaseKeyword) + KeywordScan::Reserved(TerminalKind::YulCoinBaseKeyword) } else { KeywordScan::Absent } } - Some('n') => match input.next() { - Some('s') => { - if scan_chars!(input, 't') { - match input.next() { - Some('a') => { - if scan_chars!(input, 'n', 't') { - if !self.version_is_at_least_0_7_1 { - KeywordScan::Reserved( - TokenKind::YulConstantKeyword, - ) + Some('n') => { + match input.next() { + Some('s') => { + if scan_chars!(input, 't') { + match input.next() { + Some('a') => { + if scan_chars!(input, 'n', 't') { + if !self.version_is_at_least_0_7_1 { + KeywordScan :: Reserved (TerminalKind :: YulConstantKeyword) + } else { + KeywordScan::Absent + } } else { KeywordScan::Absent } - } else { - KeywordScan::Absent } - } - Some('r') => { - if scan_chars!(input, 'u', 'c', 't', 'o', 'r') { - if self.version_is_at_least_0_5_0 - && !self.version_is_at_least_0_7_1 - { - KeywordScan::Reserved( - TokenKind::YulConstructorKeyword, - ) + Some('r') => { + if scan_chars!( + input, 'u', 'c', 't', 'o', 'r' + ) { + if self.version_is_at_least_0_5_0 + && !self.version_is_at_least_0_7_1 + { + KeywordScan :: Reserved (TerminalKind :: YulConstructorKeyword) + } else { + KeywordScan::Absent + } } else { KeywordScan::Absent } - } else { + } + Some(_) => { + input.undo(); KeywordScan::Absent } + None => KeywordScan::Absent, } - Some(_) => { - input.undo(); - KeywordScan::Absent - } - None => KeywordScan::Absent, - } - } else { - KeywordScan::Absent - } - } - Some('t') => match input.next() { - Some('i') => { - if scan_chars!(input, 'n', 'u', 'e') { - KeywordScan::Reserved(TokenKind::YulContinueKeyword) } else { KeywordScan::Absent } } - Some('r') => { - if scan_chars!(input, 'a', 'c', 't') { - if !self.version_is_at_least_0_7_1 { + Some('t') => match input.next() { + Some('i') => { + if scan_chars!(input, 'n', 'u', 'e') { KeywordScan::Reserved( - TokenKind::YulContractKeyword, + TerminalKind::YulContinueKeyword, ) } else { KeywordScan::Absent } - } else { + } + Some('r') => { + if scan_chars!(input, 'a', 'c', 't') { + if !self.version_is_at_least_0_7_1 { + KeywordScan::Reserved( + TerminalKind::YulContractKeyword, + ) + } else { + KeywordScan::Absent + } + } else { + KeywordScan::Absent + } + } + Some(_) => { + input.undo(); KeywordScan::Absent } - } + None => KeywordScan::Absent, + }, Some(_) => { input.undo(); KeywordScan::Absent } None => KeywordScan::Absent, - }, - Some(_) => { - input.undo(); - KeywordScan::Absent } - None => KeywordScan::Absent, - }, + } Some('p') => { if scan_chars!(input, 'y', 'o', 'f') { if self.version_is_at_least_0_5_0 && !self.version_is_at_least_0_7_1 { - KeywordScan::Reserved(TokenKind::YulCopyOfKeyword) + KeywordScan::Reserved(TerminalKind::YulCopyOfKeyword) } else { KeywordScan::Absent } @@ -11482,16 +11581,20 @@ impl Lexer for Language { match input.next() { Some('2') => { if self.version_is_at_least_0_4_12 { - KeywordScan::Reserved(TokenKind::YulCreate2Keyword) + KeywordScan::Reserved( + TerminalKind::YulCreate2Keyword, + ) } else { KeywordScan::Absent } } Some(_) => { input.undo(); - KeywordScan::Reserved(TokenKind::YulCreateKeyword) + KeywordScan::Reserved(TerminalKind::YulCreateKeyword) + } + None => { + KeywordScan::Reserved(TerminalKind::YulCreateKeyword) } - None => KeywordScan::Reserved(TokenKind::YulCreateKeyword), } } else { KeywordScan::Absent @@ -11507,7 +11610,7 @@ impl Lexer for Language { Some('a') => { if scan_chars!(input, 'y', 's') { if !self.version_is_at_least_0_7_1 { - KeywordScan::Reserved(TokenKind::YulDaysKeyword) + KeywordScan::Reserved(TerminalKind::YulDaysKeyword) } else { KeywordScan::Absent } @@ -11519,7 +11622,7 @@ impl Lexer for Language { Some('f') => match input.next() { Some('a') => { if scan_chars!(input, 'u', 'l', 't') { - KeywordScan::Reserved(TokenKind::YulDefaultKeyword) + KeywordScan::Reserved(TerminalKind::YulDefaultKeyword) } else { KeywordScan::Absent } @@ -11529,7 +11632,9 @@ impl Lexer for Language { if self.version_is_at_least_0_5_0 && !self.version_is_at_least_0_7_1 { - KeywordScan::Reserved(TokenKind::YulDefineKeyword) + KeywordScan::Reserved( + TerminalKind::YulDefineKeyword, + ) } else { KeywordScan::Absent } @@ -11551,7 +11656,7 @@ impl Lexer for Language { input, 'a', 't', 'e', 'c', 'a', 'l', 'l' ) { KeywordScan::Reserved( - TokenKind::YulDelegateCallKeyword, + TerminalKind::YulDelegateCallKeyword, ) } else { KeywordScan::Absent @@ -11561,7 +11666,7 @@ impl Lexer for Language { if scan_chars!(input, 'e') { if !self.version_is_at_least_0_7_1 { KeywordScan::Reserved( - TokenKind::YulDeleteKeyword, + TerminalKind::YulDeleteKeyword, ) } else { KeywordScan::Absent @@ -11589,12 +11694,12 @@ impl Lexer for Language { Some('i') => match input.next() { Some('f') => { if scan_chars!(input, 'f', 'i', 'c', 'u', 'l', 't', 'y') { - KeywordScan::Reserved(TokenKind::YulDifficultyKeyword) + KeywordScan::Reserved(TerminalKind::YulDifficultyKeyword) } else { KeywordScan::Absent } } - Some('v') => KeywordScan::Reserved(TokenKind::YulDivKeyword), + Some('v') => KeywordScan::Reserved(TerminalKind::YulDivKeyword), Some(_) => { input.undo(); KeywordScan::Absent @@ -11603,7 +11708,7 @@ impl Lexer for Language { }, Some('o') => { if !self.version_is_at_least_0_7_1 { - KeywordScan::Reserved(TokenKind::YulDoKeyword) + KeywordScan::Reserved(TerminalKind::YulDoKeyword) } else { KeywordScan::Absent } @@ -11619,7 +11724,7 @@ impl Lexer for Language { Some('l') => { if scan_chars!(input, 's', 'e') { if !self.version_is_at_least_0_7_1 { - KeywordScan::Reserved(TokenKind::YulElseKeyword) + KeywordScan::Reserved(TerminalKind::YulElseKeyword) } else { KeywordScan::Absent } @@ -11632,7 +11737,7 @@ impl Lexer for Language { if self.version_is_at_least_0_5_0 && !self.version_is_at_least_0_7_1 { - KeywordScan::Reserved(TokenKind::YulEmitKeyword) + KeywordScan::Reserved(TerminalKind::YulEmitKeyword) } else { KeywordScan::Absent } @@ -11643,7 +11748,7 @@ impl Lexer for Language { Some('n') => { if scan_chars!(input, 'u', 'm') { if !self.version_is_at_least_0_7_1 { - KeywordScan::Reserved(TokenKind::YulEnumKeyword) + KeywordScan::Reserved(TerminalKind::YulEnumKeyword) } else { KeywordScan::Absent } @@ -11651,11 +11756,11 @@ impl Lexer for Language { KeywordScan::Absent } } - Some('q') => KeywordScan::Reserved(TokenKind::YulEqKeyword), + Some('q') => KeywordScan::Reserved(TerminalKind::YulEqKeyword), Some('t') => { if scan_chars!(input, 'h', 'e', 'r') { if !self.version_is_at_least_0_7_1 { - KeywordScan::Reserved(TokenKind::YulEtherKeyword) + KeywordScan::Reserved(TerminalKind::YulEtherKeyword) } else { KeywordScan::Absent } @@ -11666,7 +11771,7 @@ impl Lexer for Language { Some('v') => { if scan_chars!(input, 'e', 'n', 't') { if !self.version_is_at_least_0_7_1 { - KeywordScan::Reserved(TokenKind::YulEventKeyword) + KeywordScan::Reserved(TerminalKind::YulEventKeyword) } else { KeywordScan::Absent } @@ -11675,7 +11780,7 @@ impl Lexer for Language { } } Some('x') => match input.next() { - Some('p') => KeywordScan::Reserved(TokenKind::YulExpKeyword), + Some('p') => KeywordScan::Reserved(TerminalKind::YulExpKeyword), Some('t') => { match input.next() { Some('c') => { @@ -11683,7 +11788,7 @@ impl Lexer for Language { match input.next() { Some('c') => { if scan_chars!(input, 'o', 'p', 'y') { - KeywordScan :: Reserved (TokenKind :: YulExtCodeCopyKeyword) + KeywordScan :: Reserved (TerminalKind :: YulExtCodeCopyKeyword) } else { KeywordScan::Absent } @@ -11691,7 +11796,7 @@ impl Lexer for Language { Some('h') => { if scan_chars!(input, 'a', 's', 'h') { if self.version_is_at_least_0_5_0 { - KeywordScan :: Reserved (TokenKind :: YulExtCodeHashKeyword) + KeywordScan :: Reserved (TerminalKind :: YulExtCodeHashKeyword) } else { KeywordScan::Absent } @@ -11701,7 +11806,7 @@ impl Lexer for Language { } Some('s') => { if scan_chars!(input, 'i', 'z', 'e') { - KeywordScan :: Reserved (TokenKind :: YulExtCodeSizeKeyword) + KeywordScan :: Reserved (TerminalKind :: YulExtCodeSizeKeyword) } else { KeywordScan::Absent } @@ -11720,7 +11825,7 @@ impl Lexer for Language { if scan_chars!(input, 'r', 'n', 'a', 'l') { if !self.version_is_at_least_0_7_1 { KeywordScan::Reserved( - TokenKind::YulExternalKeyword, + TerminalKind::YulExternalKeyword, ) } else { KeywordScan::Absent @@ -11759,7 +11864,7 @@ impl Lexer for Language { && !self.version_is_at_least_0_7_1 { KeywordScan::Reserved( - TokenKind::YulFallbackKeyword, + TerminalKind::YulFallbackKeyword, ) } else { KeywordScan::Absent @@ -11770,7 +11875,7 @@ impl Lexer for Language { } Some('s') => { if scan_chars!(input, 'e') { - KeywordScan::Reserved(TokenKind::YulFalseKeyword) + KeywordScan::Reserved(TerminalKind::YulFalseKeyword) } else { KeywordScan::Absent } @@ -11792,7 +11897,7 @@ impl Lexer for Language { if scan_chars!(input, 'l') { if !self.version_is_at_least_0_7_1 { KeywordScan::Reserved( - TokenKind::YulFinalKeyword, + TerminalKind::YulFinalKeyword, ) } else { KeywordScan::Absent @@ -11805,7 +11910,7 @@ impl Lexer for Language { if scan_chars!(input, 'e', 'y') { if !self.version_is_at_least_0_7_0 { KeywordScan::Reserved( - TokenKind::YulFinneyKeyword, + TerminalKind::YulFinneyKeyword, ) } else { KeywordScan::Absent @@ -11826,14 +11931,14 @@ impl Lexer for Language { } Some('o') => { if scan_chars!(input, 'r') { - KeywordScan::Reserved(TokenKind::YulForKeyword) + KeywordScan::Reserved(TerminalKind::YulForKeyword) } else { KeywordScan::Absent } } Some('u') => { if scan_chars!(input, 'n', 'c', 't', 'i', 'o', 'n') { - KeywordScan::Reserved(TokenKind::YulFunctionKeyword) + KeywordScan::Reserved(TerminalKind::YulFunctionKeyword) } else { KeywordScan::Absent } @@ -11850,35 +11955,39 @@ impl Lexer for Language { match input.next() { Some('l') => { if scan_chars!(input, 'i', 'm', 'i', 't') { - KeywordScan::Reserved(TokenKind::YulGasLimitKeyword) + KeywordScan::Reserved( + TerminalKind::YulGasLimitKeyword, + ) } else { KeywordScan::Absent } } Some('p') => { if scan_chars!(input, 'r', 'i', 'c', 'e') { - KeywordScan::Reserved(TokenKind::YulGasPriceKeyword) + KeywordScan::Reserved( + TerminalKind::YulGasPriceKeyword, + ) } else { KeywordScan::Absent } } Some(_) => { input.undo(); - KeywordScan::Reserved(TokenKind::YulGasKeyword) + KeywordScan::Reserved(TerminalKind::YulGasKeyword) } - None => KeywordScan::Reserved(TokenKind::YulGasKeyword), + None => KeywordScan::Reserved(TerminalKind::YulGasKeyword), } } else { KeywordScan::Absent } } - Some('t') => KeywordScan::Reserved(TokenKind::YulGtKeyword), + Some('t') => KeywordScan::Reserved(TerminalKind::YulGtKeyword), Some('w') => { if scan_chars!(input, 'e', 'i') { if self.version_is_at_least_0_7_0 && !self.version_is_at_least_0_7_1 { - KeywordScan::Reserved(TokenKind::YulGweiKeyword) + KeywordScan::Reserved(TerminalKind::YulGweiKeyword) } else { KeywordScan::Absent } @@ -11895,7 +12004,7 @@ impl Lexer for Language { Some('h') => match input.next() { Some('e') => { if scan_chars!(input, 'x') { - KeywordScan::Reserved(TokenKind::YulHexKeyword) + KeywordScan::Reserved(TerminalKind::YulHexKeyword) } else { KeywordScan::Absent } @@ -11903,7 +12012,7 @@ impl Lexer for Language { Some('o') => { if scan_chars!(input, 'u', 'r', 's') { if !self.version_is_at_least_0_7_1 { - KeywordScan::Reserved(TokenKind::YulHoursKeyword) + KeywordScan::Reserved(TerminalKind::YulHoursKeyword) } else { KeywordScan::Absent } @@ -11918,14 +12027,14 @@ impl Lexer for Language { None => KeywordScan::Absent, }, Some('i') => match input.next() { - Some('f') => KeywordScan::Reserved(TokenKind::YulIfKeyword), + Some('f') => KeywordScan::Reserved(TerminalKind::YulIfKeyword), Some('m') => match input.next() { Some('m') => { if scan_chars!(input, 'u', 't', 'a', 'b', 'l', 'e') { if self.version_is_at_least_0_5_0 && !self.version_is_at_least_0_7_1 { - KeywordScan::Reserved(TokenKind::YulImmutableKeyword) + KeywordScan::Reserved(TerminalKind::YulImmutableKeyword) } else { KeywordScan::Absent } @@ -11940,7 +12049,7 @@ impl Lexer for Language { && !self.version_is_at_least_0_7_1 { KeywordScan::Reserved( - TokenKind::YulImplementsKeyword, + TerminalKind::YulImplementsKeyword, ) } else { KeywordScan::Absent @@ -11952,7 +12061,9 @@ impl Lexer for Language { Some('o') => { if scan_chars!(input, 'r', 't') { if !self.version_is_at_least_0_7_1 { - KeywordScan::Reserved(TokenKind::YulImportKeyword) + KeywordScan::Reserved( + TerminalKind::YulImportKeyword, + ) } else { KeywordScan::Absent } @@ -11976,7 +12087,7 @@ impl Lexer for Language { Some('d') => { if scan_chars!(input, 'e', 'x', 'e', 'd') { if !self.version_is_at_least_0_7_1 { - KeywordScan::Reserved(TokenKind::YulIndexedKeyword) + KeywordScan::Reserved(TerminalKind::YulIndexedKeyword) } else { KeywordScan::Absent } @@ -11987,7 +12098,7 @@ impl Lexer for Language { Some('l') => { if scan_chars!(input, 'i', 'n', 'e') { if !self.version_is_at_least_0_7_1 { - KeywordScan::Reserved(TokenKind::YulInlineKeyword) + KeywordScan::Reserved(TerminalKind::YulInlineKeyword) } else { KeywordScan::Absent } @@ -12002,7 +12113,7 @@ impl Lexer for Language { if scan_chars!(input, 'a', 'c', 'e') { if !self.version_is_at_least_0_7_1 { KeywordScan::Reserved( - TokenKind::YulInterfaceKeyword, + TerminalKind::YulInterfaceKeyword, ) } else { KeywordScan::Absent @@ -12015,7 +12126,7 @@ impl Lexer for Language { if scan_chars!(input, 'a', 'l') { if !self.version_is_at_least_0_7_1 { KeywordScan::Reserved( - TokenKind::YulInternalKeyword, + TerminalKind::YulInternalKeyword, ) } else { KeywordScan::Absent @@ -12036,7 +12147,7 @@ impl Lexer for Language { } Some('v') => { if scan_chars!(input, 'a', 'l', 'i', 'd') { - KeywordScan::Reserved(TokenKind::YulInvalidKeyword) + KeywordScan::Reserved(TerminalKind::YulInvalidKeyword) } else { KeywordScan::Absent } @@ -12044,14 +12155,14 @@ impl Lexer for Language { Some(_) => { input.undo(); if !self.version_is_at_least_0_6_8 { - KeywordScan::Reserved(TokenKind::YulInKeyword) + KeywordScan::Reserved(TerminalKind::YulInKeyword) } else { KeywordScan::Absent } } None => { if !self.version_is_at_least_0_6_8 { - KeywordScan::Reserved(TokenKind::YulInKeyword) + KeywordScan::Reserved(TerminalKind::YulInKeyword) } else { KeywordScan::Absent } @@ -12060,7 +12171,7 @@ impl Lexer for Language { Some('s') => match input.next() { Some('z') => { if scan_chars!(input, 'e', 'r', 'o') { - KeywordScan::Reserved(TokenKind::YulIsZeroKeyword) + KeywordScan::Reserved(TerminalKind::YulIsZeroKeyword) } else { KeywordScan::Absent } @@ -12068,14 +12179,14 @@ impl Lexer for Language { Some(_) => { input.undo(); if !self.version_is_at_least_0_7_1 { - KeywordScan::Reserved(TokenKind::YulIsKeyword) + KeywordScan::Reserved(TerminalKind::YulIsKeyword) } else { KeywordScan::Absent } } None => { if !self.version_is_at_least_0_7_1 { - KeywordScan::Reserved(TokenKind::YulIsKeyword) + KeywordScan::Reserved(TerminalKind::YulIsKeyword) } else { KeywordScan::Absent } @@ -12090,7 +12201,7 @@ impl Lexer for Language { Some('k') => { if scan_chars!(input, 'e', 'c', 'c', 'a', 'k', '2', '5', '6') { if self.version_is_at_least_0_4_12 { - KeywordScan::Reserved(TokenKind::YulKeccak256Keyword) + KeywordScan::Reserved(TerminalKind::YulKeccak256Keyword) } else { KeywordScan::Absent } @@ -12103,9 +12214,9 @@ impl Lexer for Language { Some('a') => { if scan_chars!(input, 'v', 'e') { if self.version_is_at_least_0_7_1 { - KeywordScan::Reserved(TokenKind::YulLeaveKeyword) + KeywordScan::Reserved(TerminalKind::YulLeaveKeyword) } else if self.version_is_at_least_0_6_0 { - KeywordScan::Present(TokenKind::YulLeaveKeyword) + KeywordScan::Present(TerminalKind::YulLeaveKeyword) } else { KeywordScan::Absent } @@ -12113,7 +12224,7 @@ impl Lexer for Language { KeywordScan::Absent } } - Some('t') => KeywordScan::Reserved(TokenKind::YulLetKeyword), + Some('t') => KeywordScan::Reserved(TerminalKind::YulLetKeyword), Some(_) => { input.undo(); KeywordScan::Absent @@ -12123,7 +12234,7 @@ impl Lexer for Language { Some('i') => { if scan_chars!(input, 'b', 'r', 'a', 'r', 'y') { if !self.version_is_at_least_0_7_1 { - KeywordScan::Reserved(TokenKind::YulLibraryKeyword) + KeywordScan::Reserved(TerminalKind::YulLibraryKeyword) } else { KeywordScan::Absent } @@ -12135,19 +12246,19 @@ impl Lexer for Language { if scan_chars!(input, 'g') { match input.next() { Some('0') => { - KeywordScan::Reserved(TokenKind::YulLog0Keyword) + KeywordScan::Reserved(TerminalKind::YulLog0Keyword) } Some('1') => { - KeywordScan::Reserved(TokenKind::YulLog1Keyword) + KeywordScan::Reserved(TerminalKind::YulLog1Keyword) } Some('2') => { - KeywordScan::Reserved(TokenKind::YulLog2Keyword) + KeywordScan::Reserved(TerminalKind::YulLog2Keyword) } Some('3') => { - KeywordScan::Reserved(TokenKind::YulLog3Keyword) + KeywordScan::Reserved(TerminalKind::YulLog3Keyword) } Some('4') => { - KeywordScan::Reserved(TokenKind::YulLog4Keyword) + KeywordScan::Reserved(TerminalKind::YulLog4Keyword) } Some(_) => { input.undo(); @@ -12159,7 +12270,7 @@ impl Lexer for Language { KeywordScan::Absent } } - Some('t') => KeywordScan::Reserved(TokenKind::YulLtKeyword), + Some('t') => KeywordScan::Reserved(TerminalKind::YulLtKeyword), Some(_) => { input.undo(); KeywordScan::Absent @@ -12173,7 +12284,7 @@ impl Lexer for Language { if self.version_is_at_least_0_5_0 && !self.version_is_at_least_0_7_1 { - KeywordScan::Reserved(TokenKind::YulMacroKeyword) + KeywordScan::Reserved(TerminalKind::YulMacroKeyword) } else { KeywordScan::Absent } @@ -12184,7 +12295,7 @@ impl Lexer for Language { Some('p') => { if scan_chars!(input, 'p', 'i', 'n', 'g') { if !self.version_is_at_least_0_7_1 { - KeywordScan::Reserved(TokenKind::YulMappingKeyword) + KeywordScan::Reserved(TerminalKind::YulMappingKeyword) } else { KeywordScan::Absent } @@ -12195,7 +12306,7 @@ impl Lexer for Language { Some('t') => { if scan_chars!(input, 'c', 'h') { if !self.version_is_at_least_0_7_1 { - KeywordScan::Reserved(TokenKind::YulMatchKeyword) + KeywordScan::Reserved(TerminalKind::YulMatchKeyword) } else { KeywordScan::Absent } @@ -12212,7 +12323,7 @@ impl Lexer for Language { Some('c') => { if scan_chars!(input, 'o', 'p', 'y') { if self.version_is_at_least_0_8_24 { - KeywordScan::Reserved(TokenKind::YulMCopyKeyword) + KeywordScan::Reserved(TerminalKind::YulMCopyKeyword) } else { KeywordScan::Absent } @@ -12223,7 +12334,7 @@ impl Lexer for Language { Some('e') => { if scan_chars!(input, 'm', 'o', 'r', 'y') { if !self.version_is_at_least_0_7_1 { - KeywordScan::Reserved(TokenKind::YulMemoryKeyword) + KeywordScan::Reserved(TerminalKind::YulMemoryKeyword) } else { KeywordScan::Absent } @@ -12234,7 +12345,7 @@ impl Lexer for Language { Some('i') => { if scan_chars!(input, 'n', 'u', 't', 'e', 's') { if !self.version_is_at_least_0_7_1 { - KeywordScan::Reserved(TokenKind::YulMinutesKeyword) + KeywordScan::Reserved(TerminalKind::YulMinutesKeyword) } else { KeywordScan::Absent } @@ -12244,7 +12355,7 @@ impl Lexer for Language { } Some('l') => { if scan_chars!(input, 'o', 'a', 'd') { - KeywordScan::Reserved(TokenKind::YulMLoadKeyword) + KeywordScan::Reserved(TerminalKind::YulMLoadKeyword) } else { KeywordScan::Absent } @@ -12256,7 +12367,7 @@ impl Lexer for Language { if scan_chars!(input, 'f', 'i', 'e', 'r') { if !self.version_is_at_least_0_7_1 { KeywordScan::Reserved( - TokenKind::YulModifierKeyword, + TerminalKind::YulModifierKeyword, ) } else { KeywordScan::Absent @@ -12267,9 +12378,9 @@ impl Lexer for Language { } Some(_) => { input.undo(); - KeywordScan::Reserved(TokenKind::YulModKeyword) + KeywordScan::Reserved(TerminalKind::YulModKeyword) } - None => KeywordScan::Reserved(TokenKind::YulModKeyword), + None => KeywordScan::Reserved(TerminalKind::YulModKeyword), } } else { KeywordScan::Absent @@ -12278,7 +12389,7 @@ impl Lexer for Language { Some('s') => match input.next() { Some('i') => { if scan_chars!(input, 'z', 'e') { - KeywordScan::Reserved(TokenKind::YulMSizeKeyword) + KeywordScan::Reserved(TerminalKind::YulMSizeKeyword) } else { KeywordScan::Absent } @@ -12286,16 +12397,18 @@ impl Lexer for Language { Some('t') => { if scan_chars!(input, 'o', 'r', 'e') { match input.next() { - Some('8') => { - KeywordScan::Reserved(TokenKind::YulMStore8Keyword) - } + Some('8') => KeywordScan::Reserved( + TerminalKind::YulMStore8Keyword, + ), Some(_) => { input.undo(); - KeywordScan::Reserved(TokenKind::YulMStoreKeyword) - } - None => { - KeywordScan::Reserved(TokenKind::YulMStoreKeyword) + KeywordScan::Reserved( + TerminalKind::YulMStoreKeyword, + ) } + None => KeywordScan::Reserved( + TerminalKind::YulMStoreKeyword, + ), } } else { KeywordScan::Absent @@ -12311,23 +12424,23 @@ impl Lexer for Language { Some('l') => match input.next() { Some('m') => { if scan_chars!(input, 'o', 'd') { - KeywordScan::Reserved(TokenKind::YulMulModKeyword) + KeywordScan::Reserved(TerminalKind::YulMulModKeyword) } else { KeywordScan::Absent } } Some(_) => { input.undo(); - KeywordScan::Reserved(TokenKind::YulMulKeyword) + KeywordScan::Reserved(TerminalKind::YulMulKeyword) } - None => KeywordScan::Reserved(TokenKind::YulMulKeyword), + None => KeywordScan::Reserved(TerminalKind::YulMulKeyword), }, Some('t') => { if scan_chars!(input, 'a', 'b', 'l', 'e') { if self.version_is_at_least_0_5_0 && !self.version_is_at_least_0_7_1 { - KeywordScan::Reserved(TokenKind::YulMutableKeyword) + KeywordScan::Reserved(TerminalKind::YulMutableKeyword) } else { KeywordScan::Absent } @@ -12351,7 +12464,7 @@ impl Lexer for Language { Some('e') => { if scan_chars!(input, 'w') { if !self.version_is_at_least_0_7_1 { - KeywordScan::Reserved(TokenKind::YulNewKeyword) + KeywordScan::Reserved(TerminalKind::YulNewKeyword) } else { KeywordScan::Absent } @@ -12361,7 +12474,7 @@ impl Lexer for Language { } Some('o') => { if scan_chars!(input, 't') { - KeywordScan::Reserved(TokenKind::YulNotKeyword) + KeywordScan::Reserved(TerminalKind::YulNotKeyword) } else { KeywordScan::Absent } @@ -12370,7 +12483,7 @@ impl Lexer for Language { Some('l') => { if scan_chars!(input, 'l') { if !self.version_is_at_least_0_7_1 { - KeywordScan::Reserved(TokenKind::YulNullKeyword) + KeywordScan::Reserved(TerminalKind::YulNullKeyword) } else { KeywordScan::Absent } @@ -12380,7 +12493,7 @@ impl Lexer for Language { } Some('m') => { if scan_chars!(input, 'b', 'e', 'r') { - KeywordScan::Reserved(TokenKind::YulNumberKeyword) + KeywordScan::Reserved(TerminalKind::YulNumberKeyword) } else { KeywordScan::Absent } @@ -12400,7 +12513,7 @@ impl Lexer for Language { Some('o') => match input.next() { Some('f') => { if !self.version_is_at_least_0_7_1 { - KeywordScan::Reserved(TokenKind::YulOfKeyword) + KeywordScan::Reserved(TerminalKind::YulOfKeyword) } else { KeywordScan::Absent } @@ -12408,23 +12521,23 @@ impl Lexer for Language { Some('r') => match input.next() { Some('i') => { if scan_chars!(input, 'g', 'i', 'n') { - KeywordScan::Reserved(TokenKind::YulOriginKeyword) + KeywordScan::Reserved(TerminalKind::YulOriginKeyword) } else { KeywordScan::Absent } } Some(_) => { input.undo(); - KeywordScan::Reserved(TokenKind::YulOrKeyword) + KeywordScan::Reserved(TerminalKind::YulOrKeyword) } - None => KeywordScan::Reserved(TokenKind::YulOrKeyword), + None => KeywordScan::Reserved(TerminalKind::YulOrKeyword), }, Some('v') => { if scan_chars!(input, 'e', 'r', 'r', 'i', 'd', 'e') { if self.version_is_at_least_0_5_0 && !self.version_is_at_least_0_7_1 { - KeywordScan::Reserved(TokenKind::YulOverrideKeyword) + KeywordScan::Reserved(TerminalKind::YulOverrideKeyword) } else { KeywordScan::Absent } @@ -12445,7 +12558,7 @@ impl Lexer for Language { if self.version_is_at_least_0_5_0 && !self.version_is_at_least_0_7_1 { - KeywordScan::Reserved(TokenKind::YulPartialKeyword) + KeywordScan::Reserved(TerminalKind::YulPartialKeyword) } else { KeywordScan::Absent } @@ -12456,7 +12569,7 @@ impl Lexer for Language { Some('y') => { if scan_chars!(input, 'a', 'b', 'l', 'e') { if !self.version_is_at_least_0_7_1 { - KeywordScan::Reserved(TokenKind::YulPayableKeyword) + KeywordScan::Reserved(TerminalKind::YulPayableKeyword) } else { KeywordScan::Absent } @@ -12472,7 +12585,7 @@ impl Lexer for Language { }, Some('o') => { if scan_chars!(input, 'p') { - KeywordScan::Reserved(TokenKind::YulPopKeyword) + KeywordScan::Reserved(TerminalKind::YulPopKeyword) } else { KeywordScan::Absent } @@ -12481,7 +12594,7 @@ impl Lexer for Language { Some('a') => { if scan_chars!(input, 'g', 'm', 'a') { if !self.version_is_at_least_0_7_1 { - KeywordScan::Reserved(TokenKind::YulPragmaKeyword) + KeywordScan::Reserved(TerminalKind::YulPragmaKeyword) } else { KeywordScan::Absent } @@ -12492,7 +12605,9 @@ impl Lexer for Language { Some('e') => { if scan_chars!(input, 'v', 'r', 'a', 'n', 'd', 'a', 'o') { if self.version_is_at_least_0_8_18 { - KeywordScan::Reserved(TokenKind::YulPrevRandaoKeyword) + KeywordScan::Reserved( + TerminalKind::YulPrevRandaoKeyword, + ) } else { KeywordScan::Absent } @@ -12503,7 +12618,7 @@ impl Lexer for Language { Some('i') => { if scan_chars!(input, 'v', 'a', 't', 'e') { if !self.version_is_at_least_0_7_1 { - KeywordScan::Reserved(TokenKind::YulPrivateKeyword) + KeywordScan::Reserved(TerminalKind::YulPrivateKeyword) } else { KeywordScan::Absent } @@ -12516,7 +12631,7 @@ impl Lexer for Language { if self.version_is_at_least_0_5_0 && !self.version_is_at_least_0_7_1 { - KeywordScan::Reserved(TokenKind::YulPromiseKeyword) + KeywordScan::Reserved(TerminalKind::YulPromiseKeyword) } else { KeywordScan::Absent } @@ -12534,7 +12649,7 @@ impl Lexer for Language { Some('b') => { if scan_chars!(input, 'l', 'i', 'c') { if !self.version_is_at_least_0_7_1 { - KeywordScan::Reserved(TokenKind::YulPublicKeyword) + KeywordScan::Reserved(TerminalKind::YulPublicKeyword) } else { KeywordScan::Absent } @@ -12545,7 +12660,7 @@ impl Lexer for Language { Some('r') => { if scan_chars!(input, 'e') { if !self.version_is_at_least_0_7_1 { - KeywordScan::Reserved(TokenKind::YulPureKeyword) + KeywordScan::Reserved(TerminalKind::YulPureKeyword) } else { KeywordScan::Absent } @@ -12573,7 +12688,9 @@ impl Lexer for Language { if self.version_is_at_least_0_6_0 && !self.version_is_at_least_0_7_1 { - KeywordScan::Reserved(TokenKind::YulReceiveKeyword) + KeywordScan::Reserved( + TerminalKind::YulReceiveKeyword, + ) } else { KeywordScan::Absent } @@ -12587,7 +12704,7 @@ impl Lexer for Language { && !self.version_is_at_least_0_7_1 { KeywordScan::Reserved( - TokenKind::YulReferenceKeyword, + TerminalKind::YulReferenceKeyword, ) } else { KeywordScan::Absent @@ -12602,7 +12719,7 @@ impl Lexer for Language { ) { if !self.version_is_at_least_0_7_1 { KeywordScan::Reserved( - TokenKind::YulRelocatableKeyword, + TerminalKind::YulRelocatableKeyword, ) } else { KeywordScan::Absent @@ -12623,7 +12740,7 @@ impl Lexer for Language { if self .version_is_at_least_0_4_12 { - KeywordScan :: Reserved (TokenKind :: YulReturnDataCopyKeyword) + KeywordScan :: Reserved (TerminalKind :: YulReturnDataCopyKeyword) } else { KeywordScan::Absent } @@ -12637,7 +12754,7 @@ impl Lexer for Language { if self .version_is_at_least_0_4_12 { - KeywordScan :: Reserved (TokenKind :: YulReturnDataSizeKeyword) + KeywordScan :: Reserved (TerminalKind :: YulReturnDataSizeKeyword) } else { KeywordScan::Absent } @@ -12658,7 +12775,7 @@ impl Lexer for Language { Some('s') => { if !self.version_is_at_least_0_7_1 { KeywordScan::Reserved( - TokenKind::YulReturnsKeyword, + TerminalKind::YulReturnsKeyword, ) } else { KeywordScan::Absent @@ -12667,11 +12784,11 @@ impl Lexer for Language { Some(_) => { input.undo(); KeywordScan::Reserved( - TokenKind::YulReturnKeyword, + TerminalKind::YulReturnKeyword, ) } None => KeywordScan::Reserved( - TokenKind::YulReturnKeyword, + TerminalKind::YulReturnKeyword, ), } } else { @@ -12680,7 +12797,7 @@ impl Lexer for Language { } Some('v') => { if scan_chars!(input, 'e', 'r', 't') { - KeywordScan::Reserved(TokenKind::YulRevertKeyword) + KeywordScan::Reserved(TerminalKind::YulRevertKeyword) } else { KeywordScan::Absent } @@ -12699,9 +12816,9 @@ impl Lexer for Language { Some('a') => { if scan_chars!(input, 'r') { if self.version_is_at_least_0_4_21 { - KeywordScan::Reserved(TokenKind::YulSarKeyword) + KeywordScan::Reserved(TerminalKind::YulSarKeyword) } else { - KeywordScan::Present(TokenKind::YulSarKeyword) + KeywordScan::Present(TerminalKind::YulSarKeyword) } } else { KeywordScan::Absent @@ -12709,7 +12826,7 @@ impl Lexer for Language { } Some('d') => { if scan_chars!(input, 'i', 'v') { - KeywordScan::Reserved(TokenKind::YulSDivKeyword) + KeywordScan::Reserved(TerminalKind::YulSDivKeyword) } else { KeywordScan::Absent } @@ -12720,7 +12837,7 @@ impl Lexer for Language { if self.version_is_at_least_0_5_0 && !self.version_is_at_least_0_7_1 { - KeywordScan::Reserved(TokenKind::YulSealedKeyword) + KeywordScan::Reserved(TerminalKind::YulSealedKeyword) } else { KeywordScan::Absent } @@ -12731,7 +12848,7 @@ impl Lexer for Language { Some('c') => { if scan_chars!(input, 'o', 'n', 'd', 's') { if !self.version_is_at_least_0_7_1 { - KeywordScan::Reserved(TokenKind::YulSecondsKeyword) + KeywordScan::Reserved(TerminalKind::YulSecondsKeyword) } else { KeywordScan::Absent } @@ -12747,11 +12864,11 @@ impl Lexer for Language { { if self.version_is_at_least_0_5_12 { KeywordScan::Reserved( - TokenKind::YulSelfBalanceKeyword, + TerminalKind::YulSelfBalanceKeyword, ) } else { KeywordScan::Present( - TokenKind::YulSelfBalanceKeyword, + TerminalKind::YulSelfBalanceKeyword, ) } } else { @@ -12763,7 +12880,7 @@ impl Lexer for Language { input, 'e', 's', 't', 'r', 'u', 'c', 't' ) { KeywordScan::Reserved( - TokenKind::YulSelfDestructKeyword, + TerminalKind::YulSelfDestructKeyword, ) } else { KeywordScan::Absent @@ -12787,7 +12904,7 @@ impl Lexer for Language { }, Some('g') => { if scan_chars!(input, 't') { - KeywordScan::Reserved(TokenKind::YulSgtKeyword) + KeywordScan::Reserved(TerminalKind::YulSgtKeyword) } else { KeywordScan::Absent } @@ -12796,7 +12913,7 @@ impl Lexer for Language { Some('a') => { if scan_chars!(input, '3') { if !self.version_is_at_least_0_5_0 { - KeywordScan::Reserved(TokenKind::YulSha3Keyword) + KeywordScan::Reserved(TerminalKind::YulSha3Keyword) } else { KeywordScan::Absent } @@ -12806,16 +12923,16 @@ impl Lexer for Language { } Some('l') => { if self.version_is_at_least_0_4_21 { - KeywordScan::Reserved(TokenKind::YulShlKeyword) + KeywordScan::Reserved(TerminalKind::YulShlKeyword) } else { - KeywordScan::Present(TokenKind::YulShlKeyword) + KeywordScan::Present(TerminalKind::YulShlKeyword) } } Some('r') => { if self.version_is_at_least_0_4_21 { - KeywordScan::Reserved(TokenKind::YulShrKeyword) + KeywordScan::Reserved(TerminalKind::YulShrKeyword) } else { - KeywordScan::Present(TokenKind::YulShrKeyword) + KeywordScan::Present(TerminalKind::YulShrKeyword) } } Some(_) => { @@ -12827,7 +12944,7 @@ impl Lexer for Language { Some('i') => match input.next() { Some('g') => { if scan_chars!(input, 'n', 'e', 'x', 't', 'e', 'n', 'd') { - KeywordScan::Reserved(TokenKind::YulSignExtendKeyword) + KeywordScan::Reserved(TerminalKind::YulSignExtendKeyword) } else { KeywordScan::Absent } @@ -12837,7 +12954,7 @@ impl Lexer for Language { if self.version_is_at_least_0_5_0 && !self.version_is_at_least_0_7_1 { - KeywordScan::Reserved(TokenKind::YulSizeOfKeyword) + KeywordScan::Reserved(TerminalKind::YulSizeOfKeyword) } else { KeywordScan::Absent } @@ -12854,12 +12971,12 @@ impl Lexer for Language { Some('l') => match input.next() { Some('o') => { if scan_chars!(input, 'a', 'd') { - KeywordScan::Reserved(TokenKind::YulSLoadKeyword) + KeywordScan::Reserved(TerminalKind::YulSLoadKeyword) } else { KeywordScan::Absent } } - Some('t') => KeywordScan::Reserved(TokenKind::YulSltKeyword), + Some('t') => KeywordScan::Reserved(TerminalKind::YulSltKeyword), Some(_) => { input.undo(); KeywordScan::Absent @@ -12868,14 +12985,14 @@ impl Lexer for Language { }, Some('m') => { if scan_chars!(input, 'o', 'd') { - KeywordScan::Reserved(TokenKind::YulSModKeyword) + KeywordScan::Reserved(TerminalKind::YulSModKeyword) } else { KeywordScan::Absent } } Some('s') => { if scan_chars!(input, 't', 'o', 'r', 'e') { - KeywordScan::Reserved(TokenKind::YulSStoreKeyword) + KeywordScan::Reserved(TerminalKind::YulSStoreKeyword) } else { KeywordScan::Absent } @@ -12888,7 +13005,7 @@ impl Lexer for Language { if scan_chars!(input, 'a', 'l', 'l') { if self.version_is_at_least_0_4_12 { KeywordScan::Reserved( - TokenKind::YulStaticCallKeyword, + TerminalKind::YulStaticCallKeyword, ) } else { KeywordScan::Absent @@ -12901,7 +13018,7 @@ impl Lexer for Language { input.undo(); if !self.version_is_at_least_0_7_1 { KeywordScan::Reserved( - TokenKind::YulStaticKeyword, + TerminalKind::YulStaticKeyword, ) } else { KeywordScan::Absent @@ -12910,7 +13027,7 @@ impl Lexer for Language { None => { if !self.version_is_at_least_0_7_1 { KeywordScan::Reserved( - TokenKind::YulStaticKeyword, + TerminalKind::YulStaticKeyword, ) } else { KeywordScan::Absent @@ -12922,11 +13039,15 @@ impl Lexer for Language { } } Some('o') => match input.next() { - Some('p') => KeywordScan::Reserved(TokenKind::YulStopKeyword), + Some('p') => { + KeywordScan::Reserved(TerminalKind::YulStopKeyword) + } Some('r') => { if scan_chars!(input, 'a', 'g', 'e') { if !self.version_is_at_least_0_7_1 { - KeywordScan::Reserved(TokenKind::YulStorageKeyword) + KeywordScan::Reserved( + TerminalKind::YulStorageKeyword, + ) } else { KeywordScan::Absent } @@ -12944,7 +13065,9 @@ impl Lexer for Language { Some('i') => { if scan_chars!(input, 'n', 'g') { if !self.version_is_at_least_0_7_1 { - KeywordScan::Reserved(TokenKind::YulStringKeyword) + KeywordScan::Reserved( + TerminalKind::YulStringKeyword, + ) } else { KeywordScan::Absent } @@ -12955,7 +13078,9 @@ impl Lexer for Language { Some('u') => { if scan_chars!(input, 'c', 't') { if !self.version_is_at_least_0_7_1 { - KeywordScan::Reserved(TokenKind::YulStructKeyword) + KeywordScan::Reserved( + TerminalKind::YulStructKeyword, + ) } else { KeywordScan::Absent } @@ -12976,11 +13101,11 @@ impl Lexer for Language { None => KeywordScan::Absent, }, Some('u') => match input.next() { - Some('b') => KeywordScan::Reserved(TokenKind::YulSubKeyword), + Some('b') => KeywordScan::Reserved(TerminalKind::YulSubKeyword), Some('i') => { if scan_chars!(input, 'c', 'i', 'd', 'e') { if !self.version_is_at_least_0_5_0 { - KeywordScan::Reserved(TokenKind::YulSuicideKeyword) + KeywordScan::Reserved(TerminalKind::YulSuicideKeyword) } else { KeywordScan::Absent } @@ -12993,7 +13118,7 @@ impl Lexer for Language { if self.version_is_at_least_0_5_0 && !self.version_is_at_least_0_7_1 { - KeywordScan::Reserved(TokenKind::YulSupportsKeyword) + KeywordScan::Reserved(TerminalKind::YulSupportsKeyword) } else { KeywordScan::Absent } @@ -13009,7 +13134,7 @@ impl Lexer for Language { }, Some('w') => { if scan_chars!(input, 'i', 't', 'c', 'h') { - KeywordScan::Reserved(TokenKind::YulSwitchKeyword) + KeywordScan::Reserved(TerminalKind::YulSwitchKeyword) } else { KeywordScan::Absent } @@ -13017,7 +13142,7 @@ impl Lexer for Language { Some('z') => { if scan_chars!(input, 'a', 'b', 'o') { if !self.version_is_at_least_0_7_0 { - KeywordScan::Reserved(TokenKind::YulSzaboKeyword) + KeywordScan::Reserved(TerminalKind::YulSzaboKeyword) } else { KeywordScan::Absent } @@ -13035,7 +13160,7 @@ impl Lexer for Language { Some('h') => { if scan_chars!(input, 'r', 'o', 'w') { if !self.version_is_at_least_0_7_1 { - KeywordScan::Reserved(TokenKind::YulThrowKeyword) + KeywordScan::Reserved(TerminalKind::YulThrowKeyword) } else { KeywordScan::Absent } @@ -13045,7 +13170,7 @@ impl Lexer for Language { } Some('i') => { if scan_chars!(input, 'm', 'e', 's', 't', 'a', 'm', 'p') { - KeywordScan::Reserved(TokenKind::YulTimestampKeyword) + KeywordScan::Reserved(TerminalKind::YulTimestampKeyword) } else { KeywordScan::Absent } @@ -13053,7 +13178,7 @@ impl Lexer for Language { Some('l') => { if scan_chars!(input, 'o', 'a', 'd') { if self.version_is_at_least_0_8_24 { - KeywordScan::Reserved(TokenKind::YulTLoadKeyword) + KeywordScan::Reserved(TerminalKind::YulTLoadKeyword) } else { KeywordScan::Absent } @@ -13064,14 +13189,14 @@ impl Lexer for Language { Some('r') => match input.next() { Some('u') => { if scan_chars!(input, 'e') { - KeywordScan::Reserved(TokenKind::YulTrueKeyword) + KeywordScan::Reserved(TerminalKind::YulTrueKeyword) } else { KeywordScan::Absent } } Some('y') => { if !self.version_is_at_least_0_7_1 { - KeywordScan::Reserved(TokenKind::YulTryKeyword) + KeywordScan::Reserved(TerminalKind::YulTryKeyword) } else { KeywordScan::Absent } @@ -13085,7 +13210,7 @@ impl Lexer for Language { Some('s') => { if scan_chars!(input, 't', 'o', 'r', 'e') { if self.version_is_at_least_0_8_24 { - KeywordScan::Reserved(TokenKind::YulTStoreKeyword) + KeywordScan::Reserved(TerminalKind::YulTStoreKeyword) } else { KeywordScan::Absent } @@ -13102,7 +13227,7 @@ impl Lexer for Language { && !self.version_is_at_least_0_7_1 { KeywordScan::Reserved( - TokenKind::YulTypeDefKeyword, + TerminalKind::YulTypeDefKeyword, ) } else { KeywordScan::Absent @@ -13115,7 +13240,7 @@ impl Lexer for Language { if scan_chars!(input, 'f') { if !self.version_is_at_least_0_7_1 { KeywordScan::Reserved( - TokenKind::YulTypeOfKeyword, + TerminalKind::YulTypeOfKeyword, ) } else { KeywordScan::Absent @@ -13127,14 +13252,14 @@ impl Lexer for Language { Some(_) => { input.undo(); if !self.version_is_at_least_0_7_1 { - KeywordScan::Reserved(TokenKind::YulTypeKeyword) + KeywordScan::Reserved(TerminalKind::YulTypeKeyword) } else { KeywordScan::Absent } } None => { if !self.version_is_at_least_0_7_1 { - KeywordScan::Reserved(TokenKind::YulTypeKeyword) + KeywordScan::Reserved(TerminalKind::YulTypeKeyword) } else { KeywordScan::Absent } @@ -13156,7 +13281,7 @@ impl Lexer for Language { if self.version_is_at_least_0_5_0 && !self.version_is_at_least_0_7_1 { - KeywordScan::Reserved(TokenKind::YulUncheckedKeyword) + KeywordScan::Reserved(TerminalKind::YulUncheckedKeyword) } else { KeywordScan::Absent } @@ -13167,7 +13292,7 @@ impl Lexer for Language { Some('s') => { if scan_chars!(input, 'i', 'n', 'g') { if !self.version_is_at_least_0_7_1 { - KeywordScan::Reserved(TokenKind::YulUsingKeyword) + KeywordScan::Reserved(TerminalKind::YulUsingKeyword) } else { KeywordScan::Absent } @@ -13185,7 +13310,7 @@ impl Lexer for Language { Some('a') => { if scan_chars!(input, 'r') { if !self.version_is_at_least_0_6_5 { - KeywordScan::Reserved(TokenKind::YulVarKeyword) + KeywordScan::Reserved(TerminalKind::YulVarKeyword) } else { KeywordScan::Absent } @@ -13197,7 +13322,7 @@ impl Lexer for Language { Some('e') => { if scan_chars!(input, 'w') { if !self.version_is_at_least_0_7_1 { - KeywordScan::Reserved(TokenKind::YulViewKeyword) + KeywordScan::Reserved(TerminalKind::YulViewKeyword) } else { KeywordScan::Absent } @@ -13210,7 +13335,7 @@ impl Lexer for Language { if self.version_is_at_least_0_6_0 && !self.version_is_at_least_0_7_1 { - KeywordScan::Reserved(TokenKind::YulVirtualKeyword) + KeywordScan::Reserved(TerminalKind::YulVirtualKeyword) } else { KeywordScan::Absent } @@ -13235,7 +13360,7 @@ impl Lexer for Language { Some('e') => { if scan_chars!(input, 'k', 's') { if !self.version_is_at_least_0_7_1 { - KeywordScan::Reserved(TokenKind::YulWeeksKeyword) + KeywordScan::Reserved(TerminalKind::YulWeeksKeyword) } else { KeywordScan::Absent } @@ -13245,7 +13370,7 @@ impl Lexer for Language { } Some('i') => { if !self.version_is_at_least_0_7_1 { - KeywordScan::Reserved(TokenKind::YulWeiKeyword) + KeywordScan::Reserved(TerminalKind::YulWeiKeyword) } else { KeywordScan::Absent } @@ -13259,7 +13384,7 @@ impl Lexer for Language { Some('h') => { if scan_chars!(input, 'i', 'l', 'e') { if !self.version_is_at_least_0_7_1 { - KeywordScan::Reserved(TokenKind::YulWhileKeyword) + KeywordScan::Reserved(TerminalKind::YulWhileKeyword) } else { KeywordScan::Absent } @@ -13275,7 +13400,7 @@ impl Lexer for Language { }, Some('x') => { if scan_chars!(input, 'o', 'r') { - KeywordScan::Reserved(TokenKind::YulXorKeyword) + KeywordScan::Reserved(TerminalKind::YulXorKeyword) } else { KeywordScan::Absent } @@ -13283,7 +13408,7 @@ impl Lexer for Language { Some('y') => { if scan_chars!(input, 'e', 'a', 'r', 's') { if !self.version_is_at_least_0_7_1 { - KeywordScan::Reserved(TokenKind::YulYearsKeyword) + KeywordScan::Reserved(TerminalKind::YulYearsKeyword) } else { KeywordScan::Absent } @@ -13344,7 +13469,7 @@ impl Lexer for Language { // Skip a character if possible and if we didn't recognize a token None if input.peek().is_some() => { let _ = input.next(); - Some(ScannedToken::Single(TokenKind::SKIPPED)) + Some(ScannedToken::Single(TerminalKind::SKIPPED)) } None => None, } @@ -13383,7 +13508,7 @@ impl Language { )] pub fn parse_napi( &self, - #[napi(ts_arg_type = "kinds.RuleKind")] kind: RuleKind, + #[napi(ts_arg_type = "kinds.NonTerminalKind")] kind: NonTerminalKind, input: String, ) -> NAPIParseOutput { self.parse(kind, input.as_str()).into() diff --git a/crates/solidity/outputs/cargo/slang_solidity/src/generated/lexer.rs b/crates/solidity/outputs/cargo/slang_solidity/src/generated/lexer.rs index f11acf2d23..74af1b635f 100644 --- a/crates/solidity/outputs/cargo/slang_solidity/src/generated/lexer.rs +++ b/crates/solidity/outputs/cargo/slang_solidity/src/generated/lexer.rs @@ -1,7 +1,7 @@ // This file is generated automatically by infrastructure scripts. Please don't edit by hand. -use crate::cst::{self, LabeledNode}; -use crate::kinds::{IsLexicalContext, TokenKind}; +use crate::cst::{self, Edge}; +use crate::kinds::{IsLexicalContext, TerminalKind}; use crate::parser_support::{ParserContext, ParserResult}; /// Whether a keyword has been scanned and if so, whether it is reserved (unusable as an identifier) @@ -12,22 +12,22 @@ pub enum KeywordScan { Absent, /// The keyword is present, but is not reserved. #[allow(unused)] - Present(TokenKind), + Present(TerminalKind), /// The keyword is present and is reserved. - Reserved(TokenKind), + Reserved(TerminalKind), } #[derive(Debug, Clone, Copy, PartialEq, Eq)] pub enum ScannedToken { - Single(TokenKind), + Single(TerminalKind), IdentifierOrKeyword { - identifier: TokenKind, + identifier: TerminalKind, kw: KeywordScan, }, } impl ScannedToken { - pub fn accepted_as(self, expected: TokenKind) -> bool { + pub fn accepted_as(self, expected: TerminalKind) -> bool { match self { Self::Single(kind) => kind == expected, Self::IdentifierOrKeyword { identifier, kw } => match kw { @@ -42,7 +42,7 @@ impl ScannedToken { /// /// If the scanned token is an identifier, returns the specific keyword kind if the keyword is reserved, /// otherwise returns the general identifier kind. For other tokens, returns the token kind itself. - pub fn unambiguous(self) -> TokenKind { + pub fn unambiguous(self) -> TerminalKind { match self { Self::Single(kind) => kind, Self::IdentifierOrKeyword { identifier, kw } => match kw { @@ -69,7 +69,7 @@ pub(crate) trait Lexer { fn trailing_trivia(&self, input: &mut ParserContext<'_>) -> ParserResult; #[doc(hidden)] /// Returns valid grouping delimiters in the given lexical context. - fn delimiters() -> &'static [(TokenKind, TokenKind)]; + fn delimiters() -> &'static [(TerminalKind, TerminalKind)]; /// Peeks the next token, including trivia. Does not advance the input. fn peek_token( @@ -100,7 +100,7 @@ pub(crate) trait Lexer { fn parse_token( &self, input: &mut ParserContext<'_>, - kind: TokenKind, + kind: TerminalKind, ) -> ParserResult { let start = input.position(); if !self @@ -113,7 +113,7 @@ pub(crate) trait Lexer { let end = input.position(); ParserResult::r#match( - vec![LabeledNode::anonymous(cst::Node::token( + vec![Edge::anonymous(cst::Node::terminal( kind, input.content(start.utf8..end.utf8), ))], @@ -126,7 +126,7 @@ pub(crate) trait Lexer { fn parse_token_with_trivia( &self, input: &mut ParserContext<'_>, - kind: TokenKind, + kind: TerminalKind, ) -> ParserResult { let mut children = vec![]; @@ -146,7 +146,7 @@ pub(crate) trait Lexer { return ParserResult::no_match(vec![kind]); } let end = input.position(); - children.push(LabeledNode::anonymous(cst::Node::token( + children.push(Edge::anonymous(cst::Node::terminal( kind, input.content(start.utf8..end.utf8), ))); diff --git a/crates/solidity/outputs/cargo/slang_solidity/src/generated/mod.rs b/crates/solidity/outputs/cargo/slang_solidity/src/generated/mod.rs index 93a1bebed4..a1cc11707a 100644 --- a/crates/solidity/outputs/cargo/slang_solidity/src/generated/mod.rs +++ b/crates/solidity/outputs/cargo/slang_solidity/src/generated/mod.rs @@ -30,9 +30,9 @@ mod metaslang_cst { pub enum KindTypes {} impl metaslang_cst::KindTypes for KindTypes { - type NonTerminalKind = crate::kinds::RuleKind; - type TerminalKind = crate::kinds::TokenKind; - type EdgeKind = crate::kinds::NodeLabel; + type NonTerminalKind = crate::kinds::NonTerminalKind; + type TerminalKind = crate::kinds::TerminalKind; + type EdgeLabel = crate::kinds::EdgeLabel; } } @@ -42,9 +42,9 @@ pub mod cst { use super::metaslang_cst::KindTypes; pub type Node = cst::Node; - pub type RuleNode = cst::NonTerminalNode; - pub type TokenNode = cst::TerminalNode; - pub type LabeledNode = cst::LabeledNode; + pub type NonTerminalNode = cst::NonTerminalNode; + pub type TerminalNode = cst::TerminalNode; + pub type Edge = cst::Edge; } pub mod cursor { @@ -53,7 +53,7 @@ pub mod cursor { use super::metaslang_cst::KindTypes; pub type Cursor = cursor::Cursor; - pub type CursorWithLabels = cursor::CursorWithLabels; + pub type CursorWithEdges = cursor::CursorWithEdges; } pub mod query { diff --git a/crates/solidity/outputs/cargo/slang_solidity/src/generated/napi_interface/cst.rs b/crates/solidity/outputs/cargo/slang_solidity/src/generated/napi_interface/cst.rs index f8a79d15a4..acb8369329 100644 --- a/crates/solidity/outputs/cargo/slang_solidity/src/generated/napi_interface/cst.rs +++ b/crates/solidity/outputs/cargo/slang_solidity/src/generated/napi_interface/cst.rs @@ -8,51 +8,51 @@ use napi_derive::napi; use crate::napi_interface::cursor::Cursor; use crate::napi_interface::text_index::TextIndex; use crate::napi_interface::{ - RuleKind, RustNode, RustRuleNode, RustTextIndex, RustTokenNode, TokenKind, + NonTerminalKind, RustNode, RustRuleNode, RustTextIndex, RustTokenNode, TerminalKind, }; #[napi(namespace = "cst", string_enum)] pub enum NodeType { - Rule, - Token, + NonTerminal, + Terminal, } pub trait NAPINodeExtensions { - fn into_js_either_node(self) -> Either; + fn into_js_either_node(self) -> Either; } impl NAPINodeExtensions for RustNode { - /// Converts the node into `napi` wrapper for `RuleNode | TokenNode` JS object. - fn into_js_either_node(self) -> Either { + /// Converts the node into `napi` wrapper for `NonTerminalNode | TerminalNode` JS object. + fn into_js_either_node(self) -> Either { match self { - RustNode::Rule(rule) => Either::A(RuleNode(rule)), - RustNode::Token(token) => Either::B(TokenNode(token)), + RustNode::NonTerminal(nonterminal) => Either::A(NonTerminalNode(nonterminal)), + RustNode::Terminal(terminal) => Either::B(TerminalNode(terminal)), } } } #[derive(Debug)] #[napi(namespace = "cst")] -pub struct RuleNode(pub(crate) Rc); +pub struct NonTerminalNode(pub(crate) Rc); #[derive(Debug)] #[napi(namespace = "cst")] -pub struct TokenNode(pub(crate) Rc); +pub struct TerminalNode(pub(crate) Rc); #[napi(namespace = "cst")] -impl RuleNode { +impl NonTerminalNode { #[napi( getter, js_name = "type", - ts_return_type = "NodeType.Rule", + ts_return_type = "NodeType.NonTerminal", catch_unwind )] pub fn tipe(&self) -> NodeType { - NodeType::Rule + NodeType::NonTerminal } - #[napi(getter, ts_return_type = "kinds.RuleKind", catch_unwind)] - pub fn kind(&self) -> RuleKind { + #[napi(getter, ts_return_type = "kinds.NonTerminalKind", catch_unwind)] + pub fn kind(&self) -> NonTerminalKind { self.0.kind } @@ -67,7 +67,7 @@ impl RuleNode { } #[napi(ts_return_type = "Array", catch_unwind)] - pub fn children(&self) -> Vec> { + pub fn children(&self) -> Vec> { self.0 .children .iter() @@ -80,7 +80,7 @@ impl RuleNode { &self, #[napi(ts_arg_type = "text_index.TextIndex")] text_offset: TextIndex, ) -> Cursor { - RustNode::Rule(Rc::clone(&self.0)) + RustNode::NonTerminal(Rc::clone(&self.0)) .cursor_with_offset(text_offset.into()) .into() } @@ -107,7 +107,7 @@ impl RuleNode { skip_typescript, catch_unwind )] - pub fn __children(&self) -> Vec> { + pub fn __children(&self) -> Vec> { Self::children(self) } @@ -127,19 +127,19 @@ impl RuleNode { } #[napi(namespace = "cst")] -impl TokenNode { +impl TerminalNode { #[napi( getter, js_name = "type", - ts_return_type = "NodeType.Token", + ts_return_type = "NodeType.Terminal", catch_unwind )] pub fn tipe(&self) -> NodeType { - NodeType::Token + NodeType::Terminal } - #[napi(getter, ts_return_type = "kinds.TokenKind", catch_unwind)] - pub fn kind(&self) -> TokenKind { + #[napi(getter, ts_return_type = "kinds.TerminalKind", catch_unwind)] + pub fn kind(&self) -> TerminalKind { self.0.kind } @@ -160,7 +160,7 @@ impl TokenNode { } #[napi(catch_unwind, js_name = "toJSON")] - /// Serialize the token node to JSON. + /// Serialize the terminal node to JSON. /// /// This method is intended for debugging purposes and may not be stable. pub fn to_json(&self) -> String { @@ -172,7 +172,7 @@ impl TokenNode { &self, #[napi(ts_arg_type = "text_index.TextIndex")] text_offset: TextIndex, ) -> Cursor { - RustNode::Token(Rc::clone(&self.0)) + RustNode::Terminal(Rc::clone(&self.0)) .cursor_with_offset(text_offset.into()) .into() } diff --git a/crates/solidity/outputs/cargo/slang_solidity/src/generated/napi_interface/cursor.rs b/crates/solidity/outputs/cargo/slang_solidity/src/generated/napi_interface/cursor.rs index 64356c7921..61da4beac9 100644 --- a/crates/solidity/outputs/cargo/slang_solidity/src/generated/napi_interface/cursor.rs +++ b/crates/solidity/outputs/cargo/slang_solidity/src/generated/napi_interface/cursor.rs @@ -9,8 +9,8 @@ use napi::Either; use napi_derive::napi; use text_index::{TextIndex, TextRange}; -use crate::napi_interface::cst::{self, NAPINodeExtensions, RuleNode, TokenNode}; -use crate::napi_interface::{text_index, NodeLabel, RuleKind, RustCursor, TokenKind}; +use crate::napi_interface::cst::{self, NAPINodeExtensions, NonTerminalNode, TerminalNode}; +use crate::napi_interface::{text_index, EdgeLabel, NonTerminalKind, RustCursor, TerminalKind}; #[napi(namespace = "cursor")] pub struct Cursor(pub(super) RustCursor); @@ -54,12 +54,12 @@ impl Cursor { } #[napi(ts_return_type = "cst.Node", catch_unwind)] - pub fn node(&self) -> Either { + pub fn node(&self) -> Either { self.0.node().into_js_either_node() } - #[napi(getter, ts_return_type = "kinds.NodeLabel", catch_unwind)] - pub fn label(&self) -> Option { + #[napi(getter, ts_return_type = "kinds.EdgeLabel", catch_unwind)] + pub fn label(&self) -> Option { self.0.label() } @@ -79,9 +79,9 @@ impl Cursor { self.0.depth() as u32 } - #[napi(ts_return_type = "Array", catch_unwind)] - pub fn ancestors(&self) -> Vec { - self.0.ancestors().map(cst::RuleNode).collect() + #[napi(ts_return_type = "Array", catch_unwind)] + pub fn ancestors(&self) -> Vec { + self.0.ancestors().map(cst::NonTerminalNode).collect() } #[napi(catch_unwind)] @@ -130,44 +130,44 @@ impl Cursor { } #[napi(catch_unwind)] - pub fn go_to_next_token(&mut self) -> bool { - self.0.go_to_next_token() + pub fn go_to_next_terminal(&mut self) -> bool { + self.0.go_to_next_terminal() } #[napi(catch_unwind)] - pub fn go_to_next_token_with_kind( + pub fn go_to_next_terminal_with_kind( &mut self, - #[napi(ts_arg_type = "kinds.TokenKind")] kind: TokenKind, + #[napi(ts_arg_type = "kinds.TerminalKind")] kind: TerminalKind, ) -> bool { - self.0.go_to_next_token_with_kind(kind) + self.0.go_to_next_terminal_with_kind(kind) } #[napi(catch_unwind)] pub fn go_to_next_token_with_kinds( &mut self, - #[napi(ts_arg_type = "Array")] kinds: Vec, + #[napi(ts_arg_type = "Array")] kinds: Vec, ) -> bool { - self.0.go_to_next_token_with_kinds(&kinds) + self.0.go_to_next_terminal_with_kinds(&kinds) } #[napi(catch_unwind)] - pub fn go_to_next_rule(&mut self) -> bool { - self.0.go_to_next_rule() + pub fn go_to_next_nonterminal(&mut self) -> bool { + self.0.go_to_next_nonterminal() } #[napi(catch_unwind)] - pub fn go_to_next_rule_with_kind( + pub fn go_to_next_nonterminal_with_kind( &mut self, - #[napi(ts_arg_type = "kinds.RuleKind")] kind: RuleKind, + #[napi(ts_arg_type = "kinds.NonTerminalKind")] kind: NonTerminalKind, ) -> bool { - self.0.go_to_next_rule_with_kind(kind) + self.0.go_to_next_nonterminal_with_kind(kind) } #[napi(catch_unwind)] - pub fn go_to_next_rule_with_kinds( + pub fn go_to_next_nonterminal_with_kinds( &mut self, - #[napi(ts_arg_type = "Array")] kinds: Vec, + #[napi(ts_arg_type = "Array")] kinds: Vec, ) -> bool { - self.0.go_to_next_rule_with_kinds(&kinds) + self.0.go_to_next_nonterminal_with_kinds(&kinds) } } diff --git a/crates/solidity/outputs/cargo/slang_solidity/src/generated/napi_interface/generated/ast_selectors.rs b/crates/solidity/outputs/cargo/slang_solidity/src/generated/napi_interface/generated/ast_selectors.rs index e49bb5d10f..38dfe39d20 100644 --- a/crates/solidity/outputs/cargo/slang_solidity/src/generated/napi_interface/generated/ast_selectors.rs +++ b/crates/solidity/outputs/cargo/slang_solidity/src/generated/napi_interface/generated/ast_selectors.rs @@ -7,8 +7,10 @@ use std::rc::Rc; use napi::Either; use napi_derive::napi; -use crate::napi_interface::cst::{NAPINodeExtensions, RuleNode, TokenNode}; -use crate::napi_interface::{RuleKind, RustLabeledNode, RustNode, RustRuleNode, TokenKind}; +use crate::napi_interface::cst::{NAPINodeExtensions, NonTerminalNode, TerminalNode}; +use crate::napi_interface::{ + NonTerminalKind, RustLabeledNode, RustNode, RustRuleNode, TerminalKind, +}; // // Sequences: @@ -20,142 +22,152 @@ use crate::napi_interface::{RuleKind, RustLabeledNode, RustNode, RustRuleNode, T catch_unwind )] pub fn select_sequence( - #[napi(ts_arg_type = "cst.RuleNode")] node: &RuleNode, -) -> Result>>> { + #[napi(ts_arg_type = "cst.NonTerminalNode")] node: &NonTerminalNode, +) -> Result>>> { let mut selector = Selector::new(node); let result = match node.kind() { - RuleKind::SourceUnit => selector.source_unit()?, - RuleKind::PragmaDirective => selector.pragma_directive()?, - RuleKind::ABICoderPragma => selector.abi_coder_pragma()?, - RuleKind::ExperimentalPragma => selector.experimental_pragma()?, - RuleKind::VersionPragma => selector.version_pragma()?, - RuleKind::VersionRange => selector.version_range()?, - RuleKind::VersionComparator => selector.version_comparator()?, - RuleKind::ImportDirective => selector.import_directive()?, - RuleKind::PathImport => selector.path_import()?, - RuleKind::NamedImport => selector.named_import()?, - RuleKind::ImportDeconstruction => selector.import_deconstruction()?, - RuleKind::ImportDeconstructionSymbol => selector.import_deconstruction_symbol()?, - RuleKind::ImportAlias => selector.import_alias()?, - RuleKind::UsingDirective => selector.using_directive()?, - RuleKind::UsingDeconstruction => selector.using_deconstruction()?, - RuleKind::UsingDeconstructionSymbol => selector.using_deconstruction_symbol()?, - RuleKind::UsingAlias => selector.using_alias()?, - RuleKind::ContractDefinition => selector.contract_definition()?, - RuleKind::InheritanceSpecifier => selector.inheritance_specifier()?, - RuleKind::InheritanceType => selector.inheritance_type()?, - RuleKind::InterfaceDefinition => selector.interface_definition()?, - RuleKind::LibraryDefinition => selector.library_definition()?, - RuleKind::StructDefinition => selector.struct_definition()?, - RuleKind::StructMember => selector.struct_member()?, - RuleKind::EnumDefinition => selector.enum_definition()?, - RuleKind::ConstantDefinition => selector.constant_definition()?, - RuleKind::StateVariableDefinition => selector.state_variable_definition()?, - RuleKind::StateVariableDefinitionValue => selector.state_variable_definition_value()?, - RuleKind::FunctionDefinition => selector.function_definition()?, - RuleKind::ParametersDeclaration => selector.parameters_declaration()?, - RuleKind::Parameter => selector.parameter()?, - RuleKind::OverrideSpecifier => selector.override_specifier()?, - RuleKind::OverridePathsDeclaration => selector.override_paths_declaration()?, - RuleKind::ReturnsDeclaration => selector.returns_declaration()?, - RuleKind::ConstructorDefinition => selector.constructor_definition()?, - RuleKind::UnnamedFunctionDefinition => selector.unnamed_function_definition()?, - RuleKind::FallbackFunctionDefinition => selector.fallback_function_definition()?, - RuleKind::ReceiveFunctionDefinition => selector.receive_function_definition()?, - RuleKind::ModifierDefinition => selector.modifier_definition()?, - RuleKind::ModifierInvocation => selector.modifier_invocation()?, - RuleKind::EventDefinition => selector.event_definition()?, - RuleKind::EventParametersDeclaration => selector.event_parameters_declaration()?, - RuleKind::EventParameter => selector.event_parameter()?, - RuleKind::UserDefinedValueTypeDefinition => { + NonTerminalKind::SourceUnit => selector.source_unit()?, + NonTerminalKind::PragmaDirective => selector.pragma_directive()?, + NonTerminalKind::ABICoderPragma => selector.abi_coder_pragma()?, + NonTerminalKind::ExperimentalPragma => selector.experimental_pragma()?, + NonTerminalKind::VersionPragma => selector.version_pragma()?, + NonTerminalKind::VersionRange => selector.version_range()?, + NonTerminalKind::VersionComparator => selector.version_comparator()?, + NonTerminalKind::ImportDirective => selector.import_directive()?, + NonTerminalKind::PathImport => selector.path_import()?, + NonTerminalKind::NamedImport => selector.named_import()?, + NonTerminalKind::ImportDeconstruction => selector.import_deconstruction()?, + NonTerminalKind::ImportDeconstructionSymbol => selector.import_deconstruction_symbol()?, + NonTerminalKind::ImportAlias => selector.import_alias()?, + NonTerminalKind::UsingDirective => selector.using_directive()?, + NonTerminalKind::UsingDeconstruction => selector.using_deconstruction()?, + NonTerminalKind::UsingDeconstructionSymbol => selector.using_deconstruction_symbol()?, + NonTerminalKind::UsingAlias => selector.using_alias()?, + NonTerminalKind::ContractDefinition => selector.contract_definition()?, + NonTerminalKind::InheritanceSpecifier => selector.inheritance_specifier()?, + NonTerminalKind::InheritanceType => selector.inheritance_type()?, + NonTerminalKind::InterfaceDefinition => selector.interface_definition()?, + NonTerminalKind::LibraryDefinition => selector.library_definition()?, + NonTerminalKind::StructDefinition => selector.struct_definition()?, + NonTerminalKind::StructMember => selector.struct_member()?, + NonTerminalKind::EnumDefinition => selector.enum_definition()?, + NonTerminalKind::ConstantDefinition => selector.constant_definition()?, + NonTerminalKind::StateVariableDefinition => selector.state_variable_definition()?, + NonTerminalKind::StateVariableDefinitionValue => { + selector.state_variable_definition_value()? + } + NonTerminalKind::FunctionDefinition => selector.function_definition()?, + NonTerminalKind::ParametersDeclaration => selector.parameters_declaration()?, + NonTerminalKind::Parameter => selector.parameter()?, + NonTerminalKind::OverrideSpecifier => selector.override_specifier()?, + NonTerminalKind::OverridePathsDeclaration => selector.override_paths_declaration()?, + NonTerminalKind::ReturnsDeclaration => selector.returns_declaration()?, + NonTerminalKind::ConstructorDefinition => selector.constructor_definition()?, + NonTerminalKind::UnnamedFunctionDefinition => selector.unnamed_function_definition()?, + NonTerminalKind::FallbackFunctionDefinition => selector.fallback_function_definition()?, + NonTerminalKind::ReceiveFunctionDefinition => selector.receive_function_definition()?, + NonTerminalKind::ModifierDefinition => selector.modifier_definition()?, + NonTerminalKind::ModifierInvocation => selector.modifier_invocation()?, + NonTerminalKind::EventDefinition => selector.event_definition()?, + NonTerminalKind::EventParametersDeclaration => selector.event_parameters_declaration()?, + NonTerminalKind::EventParameter => selector.event_parameter()?, + NonTerminalKind::UserDefinedValueTypeDefinition => { selector.user_defined_value_type_definition()? } - RuleKind::ErrorDefinition => selector.error_definition()?, - RuleKind::ErrorParametersDeclaration => selector.error_parameters_declaration()?, - RuleKind::ErrorParameter => selector.error_parameter()?, - RuleKind::ArrayTypeName => selector.array_type_name()?, - RuleKind::FunctionType => selector.function_type()?, - RuleKind::MappingType => selector.mapping_type()?, - RuleKind::MappingKey => selector.mapping_key()?, - RuleKind::MappingValue => selector.mapping_value()?, - RuleKind::AddressType => selector.address_type()?, - RuleKind::Block => selector.block()?, - RuleKind::UncheckedBlock => selector.unchecked_block()?, - RuleKind::ExpressionStatement => selector.expression_statement()?, - RuleKind::AssemblyStatement => selector.assembly_statement()?, - RuleKind::AssemblyFlagsDeclaration => selector.assembly_flags_declaration()?, - RuleKind::TupleDeconstructionStatement => selector.tuple_deconstruction_statement()?, - RuleKind::TupleDeconstructionElement => selector.tuple_deconstruction_element()?, - RuleKind::TypedTupleMember => selector.typed_tuple_member()?, - RuleKind::UntypedTupleMember => selector.untyped_tuple_member()?, - RuleKind::VariableDeclarationStatement => selector.variable_declaration_statement()?, - RuleKind::VariableDeclarationValue => selector.variable_declaration_value()?, - RuleKind::IfStatement => selector.if_statement()?, - RuleKind::ElseBranch => selector.else_branch()?, - RuleKind::ForStatement => selector.for_statement()?, - RuleKind::WhileStatement => selector.while_statement()?, - RuleKind::DoWhileStatement => selector.do_while_statement()?, - RuleKind::ContinueStatement => selector.continue_statement()?, - RuleKind::BreakStatement => selector.break_statement()?, - RuleKind::ReturnStatement => selector.return_statement()?, - RuleKind::EmitStatement => selector.emit_statement()?, - RuleKind::TryStatement => selector.try_statement()?, - RuleKind::CatchClause => selector.catch_clause()?, - RuleKind::CatchClauseError => selector.catch_clause_error()?, - RuleKind::RevertStatement => selector.revert_statement()?, - RuleKind::ThrowStatement => selector.throw_statement()?, - RuleKind::AssignmentExpression => selector.assignment_expression()?, - RuleKind::ConditionalExpression => selector.conditional_expression()?, - RuleKind::OrExpression => selector.or_expression()?, - RuleKind::AndExpression => selector.and_expression()?, - RuleKind::EqualityExpression => selector.equality_expression()?, - RuleKind::ComparisonExpression => selector.comparison_expression()?, - RuleKind::BitwiseOrExpression => selector.bitwise_or_expression()?, - RuleKind::BitwiseXorExpression => selector.bitwise_xor_expression()?, - RuleKind::BitwiseAndExpression => selector.bitwise_and_expression()?, - RuleKind::ShiftExpression => selector.shift_expression()?, - RuleKind::AdditiveExpression => selector.additive_expression()?, - RuleKind::MultiplicativeExpression => selector.multiplicative_expression()?, - RuleKind::ExponentiationExpression => selector.exponentiation_expression()?, - RuleKind::PostfixExpression => selector.postfix_expression()?, - RuleKind::PrefixExpression => selector.prefix_expression()?, - RuleKind::FunctionCallExpression => selector.function_call_expression()?, - RuleKind::CallOptionsExpression => selector.call_options_expression()?, - RuleKind::MemberAccessExpression => selector.member_access_expression()?, - RuleKind::IndexAccessExpression => selector.index_access_expression()?, - RuleKind::IndexAccessEnd => selector.index_access_end()?, - RuleKind::PositionalArgumentsDeclaration => selector.positional_arguments_declaration()?, - RuleKind::NamedArgumentsDeclaration => selector.named_arguments_declaration()?, - RuleKind::NamedArgumentGroup => selector.named_argument_group()?, - RuleKind::NamedArgument => selector.named_argument()?, - RuleKind::TypeExpression => selector.type_expression()?, - RuleKind::NewExpression => selector.new_expression()?, - RuleKind::TupleExpression => selector.tuple_expression()?, - RuleKind::TupleValue => selector.tuple_value()?, - RuleKind::ArrayExpression => selector.array_expression()?, - RuleKind::HexNumberExpression => selector.hex_number_expression()?, - RuleKind::DecimalNumberExpression => selector.decimal_number_expression()?, - RuleKind::YulBlock => selector.yul_block()?, - RuleKind::YulFunctionDefinition => selector.yul_function_definition()?, - RuleKind::YulParametersDeclaration => selector.yul_parameters_declaration()?, - RuleKind::YulReturnsDeclaration => selector.yul_returns_declaration()?, - RuleKind::YulVariableDeclarationStatement => { + NonTerminalKind::ErrorDefinition => selector.error_definition()?, + NonTerminalKind::ErrorParametersDeclaration => selector.error_parameters_declaration()?, + NonTerminalKind::ErrorParameter => selector.error_parameter()?, + NonTerminalKind::ArrayTypeName => selector.array_type_name()?, + NonTerminalKind::FunctionType => selector.function_type()?, + NonTerminalKind::MappingType => selector.mapping_type()?, + NonTerminalKind::MappingKey => selector.mapping_key()?, + NonTerminalKind::MappingValue => selector.mapping_value()?, + NonTerminalKind::AddressType => selector.address_type()?, + NonTerminalKind::Block => selector.block()?, + NonTerminalKind::UncheckedBlock => selector.unchecked_block()?, + NonTerminalKind::ExpressionStatement => selector.expression_statement()?, + NonTerminalKind::AssemblyStatement => selector.assembly_statement()?, + NonTerminalKind::AssemblyFlagsDeclaration => selector.assembly_flags_declaration()?, + NonTerminalKind::TupleDeconstructionStatement => { + selector.tuple_deconstruction_statement()? + } + NonTerminalKind::TupleDeconstructionElement => selector.tuple_deconstruction_element()?, + NonTerminalKind::TypedTupleMember => selector.typed_tuple_member()?, + NonTerminalKind::UntypedTupleMember => selector.untyped_tuple_member()?, + NonTerminalKind::VariableDeclarationStatement => { + selector.variable_declaration_statement()? + } + NonTerminalKind::VariableDeclarationValue => selector.variable_declaration_value()?, + NonTerminalKind::IfStatement => selector.if_statement()?, + NonTerminalKind::ElseBranch => selector.else_branch()?, + NonTerminalKind::ForStatement => selector.for_statement()?, + NonTerminalKind::WhileStatement => selector.while_statement()?, + NonTerminalKind::DoWhileStatement => selector.do_while_statement()?, + NonTerminalKind::ContinueStatement => selector.continue_statement()?, + NonTerminalKind::BreakStatement => selector.break_statement()?, + NonTerminalKind::ReturnStatement => selector.return_statement()?, + NonTerminalKind::EmitStatement => selector.emit_statement()?, + NonTerminalKind::TryStatement => selector.try_statement()?, + NonTerminalKind::CatchClause => selector.catch_clause()?, + NonTerminalKind::CatchClauseError => selector.catch_clause_error()?, + NonTerminalKind::RevertStatement => selector.revert_statement()?, + NonTerminalKind::ThrowStatement => selector.throw_statement()?, + NonTerminalKind::AssignmentExpression => selector.assignment_expression()?, + NonTerminalKind::ConditionalExpression => selector.conditional_expression()?, + NonTerminalKind::OrExpression => selector.or_expression()?, + NonTerminalKind::AndExpression => selector.and_expression()?, + NonTerminalKind::EqualityExpression => selector.equality_expression()?, + NonTerminalKind::ComparisonExpression => selector.comparison_expression()?, + NonTerminalKind::BitwiseOrExpression => selector.bitwise_or_expression()?, + NonTerminalKind::BitwiseXorExpression => selector.bitwise_xor_expression()?, + NonTerminalKind::BitwiseAndExpression => selector.bitwise_and_expression()?, + NonTerminalKind::ShiftExpression => selector.shift_expression()?, + NonTerminalKind::AdditiveExpression => selector.additive_expression()?, + NonTerminalKind::MultiplicativeExpression => selector.multiplicative_expression()?, + NonTerminalKind::ExponentiationExpression => selector.exponentiation_expression()?, + NonTerminalKind::PostfixExpression => selector.postfix_expression()?, + NonTerminalKind::PrefixExpression => selector.prefix_expression()?, + NonTerminalKind::FunctionCallExpression => selector.function_call_expression()?, + NonTerminalKind::CallOptionsExpression => selector.call_options_expression()?, + NonTerminalKind::MemberAccessExpression => selector.member_access_expression()?, + NonTerminalKind::IndexAccessExpression => selector.index_access_expression()?, + NonTerminalKind::IndexAccessEnd => selector.index_access_end()?, + NonTerminalKind::PositionalArgumentsDeclaration => { + selector.positional_arguments_declaration()? + } + NonTerminalKind::NamedArgumentsDeclaration => selector.named_arguments_declaration()?, + NonTerminalKind::NamedArgumentGroup => selector.named_argument_group()?, + NonTerminalKind::NamedArgument => selector.named_argument()?, + NonTerminalKind::TypeExpression => selector.type_expression()?, + NonTerminalKind::NewExpression => selector.new_expression()?, + NonTerminalKind::TupleExpression => selector.tuple_expression()?, + NonTerminalKind::TupleValue => selector.tuple_value()?, + NonTerminalKind::ArrayExpression => selector.array_expression()?, + NonTerminalKind::HexNumberExpression => selector.hex_number_expression()?, + NonTerminalKind::DecimalNumberExpression => selector.decimal_number_expression()?, + NonTerminalKind::YulBlock => selector.yul_block()?, + NonTerminalKind::YulFunctionDefinition => selector.yul_function_definition()?, + NonTerminalKind::YulParametersDeclaration => selector.yul_parameters_declaration()?, + NonTerminalKind::YulReturnsDeclaration => selector.yul_returns_declaration()?, + NonTerminalKind::YulVariableDeclarationStatement => { selector.yul_variable_declaration_statement()? } - RuleKind::YulVariableDeclarationValue => selector.yul_variable_declaration_value()?, - RuleKind::YulAssignmentStatement => selector.yul_assignment_statement()?, - RuleKind::YulColonAndEqual => selector.yul_colon_and_equal()?, - RuleKind::YulIfStatement => selector.yul_if_statement()?, - RuleKind::YulForStatement => selector.yul_for_statement()?, - RuleKind::YulSwitchStatement => selector.yul_switch_statement()?, - RuleKind::YulDefaultCase => selector.yul_default_case()?, - RuleKind::YulValueCase => selector.yul_value_case()?, - RuleKind::YulLeaveStatement => selector.yul_leave_statement()?, - RuleKind::YulBreakStatement => selector.yul_break_statement()?, - RuleKind::YulContinueStatement => selector.yul_continue_statement()?, - RuleKind::YulLabel => selector.yul_label()?, - RuleKind::YulFunctionCallExpression => selector.yul_function_call_expression()?, + NonTerminalKind::YulVariableDeclarationValue => { + selector.yul_variable_declaration_value()? + } + NonTerminalKind::YulAssignmentStatement => selector.yul_assignment_statement()?, + NonTerminalKind::YulColonAndEqual => selector.yul_colon_and_equal()?, + NonTerminalKind::YulIfStatement => selector.yul_if_statement()?, + NonTerminalKind::YulForStatement => selector.yul_for_statement()?, + NonTerminalKind::YulSwitchStatement => selector.yul_switch_statement()?, + NonTerminalKind::YulDefaultCase => selector.yul_default_case()?, + NonTerminalKind::YulValueCase => selector.yul_value_case()?, + NonTerminalKind::YulLeaveStatement => selector.yul_leave_statement()?, + NonTerminalKind::YulBreakStatement => selector.yul_break_statement()?, + NonTerminalKind::YulContinueStatement => selector.yul_continue_statement()?, + NonTerminalKind::YulLabel => selector.yul_label()?, + NonTerminalKind::YulFunctionCallExpression => selector.yul_function_call_expression()?, _ => { return Error::UnexpectedParent(node.kind()).into(); } @@ -165,284 +177,356 @@ pub fn select_sequence( Ok(result) } impl Selector { - fn source_unit(&mut self) -> Result>>> { + fn source_unit(&mut self) -> Result>>> { Ok(vec![Some(self.select(|node| { - node.is_rule_with_kind(RuleKind::SourceUnitMembers) + node.is_nonterminal_with_kind(NonTerminalKind::SourceUnitMembers) })?)]) } } impl Selector { - fn pragma_directive(&mut self) -> Result>>> { + fn pragma_directive(&mut self) -> Result>>> { Ok(vec![ - Some(self.select(|node| node.is_token_with_kind(TokenKind::PragmaKeyword))?), - Some(self.select(|node| node.is_rule_with_kind(RuleKind::Pragma))?), - Some(self.select(|node| node.is_token_with_kind(TokenKind::Semicolon))?), + Some(self.select(|node| node.is_terminal_with_kind(TerminalKind::PragmaKeyword))?), + Some(self.select(|node| node.is_nonterminal_with_kind(NonTerminalKind::Pragma))?), + Some(self.select(|node| node.is_terminal_with_kind(TerminalKind::Semicolon))?), ]) } } impl Selector { - fn abi_coder_pragma(&mut self) -> Result>>> { + fn abi_coder_pragma(&mut self) -> Result>>> { Ok(vec![ - Some(self.select(|node| node.is_token_with_kind(TokenKind::AbicoderKeyword))?), - Some(self.select(|node| node.is_token_with_kind(TokenKind::Identifier))?), + Some(self.select(|node| node.is_terminal_with_kind(TerminalKind::AbicoderKeyword))?), + Some(self.select(|node| node.is_terminal_with_kind(TerminalKind::Identifier))?), ]) } } impl Selector { - fn experimental_pragma(&mut self) -> Result>>> { + fn experimental_pragma( + &mut self, + ) -> Result>>> { Ok(vec![ - Some(self.select(|node| node.is_token_with_kind(TokenKind::ExperimentalKeyword))?), - Some(self.select(|node| node.is_rule_with_kind(RuleKind::ExperimentalFeature))?), + Some( + self.select(|node| node.is_terminal_with_kind(TerminalKind::ExperimentalKeyword))?, + ), + Some(self.select(|node| { + node.is_nonterminal_with_kind(NonTerminalKind::ExperimentalFeature) + })?), ]) } } impl Selector { - fn version_pragma(&mut self) -> Result>>> { + fn version_pragma(&mut self) -> Result>>> { Ok(vec![ - Some(self.select(|node| node.is_token_with_kind(TokenKind::SolidityKeyword))?), - Some(self.select(|node| node.is_rule_with_kind(RuleKind::VersionExpressionSets))?), + Some(self.select(|node| node.is_terminal_with_kind(TerminalKind::SolidityKeyword))?), + Some(self.select(|node| { + node.is_nonterminal_with_kind(NonTerminalKind::VersionExpressionSets) + })?), ]) } } impl Selector { - fn version_range(&mut self) -> Result>>> { + fn version_range(&mut self) -> Result>>> { Ok(vec![ - Some(self.select(|node| node.is_rule_with_kind(RuleKind::VersionExpression))?), - Some(self.select(|node| node.is_token_with_kind(TokenKind::Minus))?), - Some(self.select(|node| node.is_rule_with_kind(RuleKind::VersionExpression))?), + Some(self.select(|node| { + node.is_nonterminal_with_kind(NonTerminalKind::VersionExpression) + })?), + Some(self.select(|node| node.is_terminal_with_kind(TerminalKind::Minus))?), + Some(self.select(|node| { + node.is_nonterminal_with_kind(NonTerminalKind::VersionExpression) + })?), ]) } } impl Selector { - fn version_comparator(&mut self) -> Result>>> { + fn version_comparator(&mut self) -> Result>>> { Ok(vec![ - Some(self.select(|node| node.is_token_with_kind(TokenKind::Caret))?), - Some(self.select(|node| node.is_rule_with_kind(RuleKind::VersionExpression))?), + Some(self.select(|node| node.is_terminal_with_kind(TerminalKind::Caret))?), + Some(self.select(|node| { + node.is_nonterminal_with_kind(NonTerminalKind::VersionExpression) + })?), ]) } } impl Selector { - fn import_directive(&mut self) -> Result>>> { + fn import_directive(&mut self) -> Result>>> { Ok(vec![ - Some(self.select(|node| node.is_token_with_kind(TokenKind::ImportKeyword))?), - Some(self.select(|node| node.is_rule_with_kind(RuleKind::ImportClause))?), - Some(self.select(|node| node.is_token_with_kind(TokenKind::Semicolon))?), + Some(self.select(|node| node.is_terminal_with_kind(TerminalKind::ImportKeyword))?), + Some(self.select(|node| node.is_nonterminal_with_kind(NonTerminalKind::ImportClause))?), + Some(self.select(|node| node.is_terminal_with_kind(TerminalKind::Semicolon))?), ]) } } impl Selector { - fn path_import(&mut self) -> Result>>> { + fn path_import(&mut self) -> Result>>> { Ok(vec![ - Some(self.select(|node| node.is_rule_with_kind(RuleKind::StringLiteral))?), - self.try_select(|node| node.is_rule_with_kind(RuleKind::ImportAlias))?, + Some( + self.select(|node| node.is_nonterminal_with_kind(NonTerminalKind::StringLiteral))?, + ), + self.try_select(|node| node.is_nonterminal_with_kind(NonTerminalKind::ImportAlias))?, ]) } } impl Selector { - fn named_import(&mut self) -> Result>>> { + fn named_import(&mut self) -> Result>>> { Ok(vec![ - Some(self.select(|node| node.is_token_with_kind(TokenKind::Asterisk))?), - Some(self.select(|node| node.is_rule_with_kind(RuleKind::ImportAlias))?), - Some(self.select(|node| node.is_token_with_kind(TokenKind::FromKeyword))?), - Some(self.select(|node| node.is_rule_with_kind(RuleKind::StringLiteral))?), + Some(self.select(|node| node.is_terminal_with_kind(TerminalKind::Asterisk))?), + Some(self.select(|node| node.is_nonterminal_with_kind(NonTerminalKind::ImportAlias))?), + Some(self.select(|node| node.is_terminal_with_kind(TerminalKind::FromKeyword))?), + Some( + self.select(|node| node.is_nonterminal_with_kind(NonTerminalKind::StringLiteral))?, + ), ]) } } impl Selector { - fn import_deconstruction(&mut self) -> Result>>> { - Ok(vec![ - Some(self.select(|node| node.is_token_with_kind(TokenKind::OpenBrace))?), + fn import_deconstruction( + &mut self, + ) -> Result>>> { + Ok(vec![ + Some(self.select(|node| node.is_terminal_with_kind(TerminalKind::OpenBrace))?), + Some(self.select(|node| { + node.is_nonterminal_with_kind(NonTerminalKind::ImportDeconstructionSymbols) + })?), + Some(self.select(|node| node.is_terminal_with_kind(TerminalKind::CloseBrace))?), + Some(self.select(|node| node.is_terminal_with_kind(TerminalKind::FromKeyword))?), Some( - self.select(|node| node.is_rule_with_kind(RuleKind::ImportDeconstructionSymbols))?, + self.select(|node| node.is_nonterminal_with_kind(NonTerminalKind::StringLiteral))?, ), - Some(self.select(|node| node.is_token_with_kind(TokenKind::CloseBrace))?), - Some(self.select(|node| node.is_token_with_kind(TokenKind::FromKeyword))?), - Some(self.select(|node| node.is_rule_with_kind(RuleKind::StringLiteral))?), ]) } } impl Selector { - fn import_deconstruction_symbol(&mut self) -> Result>>> { + fn import_deconstruction_symbol( + &mut self, + ) -> Result>>> { Ok(vec![ - Some(self.select(|node| node.is_token_with_kind(TokenKind::Identifier))?), - self.try_select(|node| node.is_rule_with_kind(RuleKind::ImportAlias))?, + Some(self.select(|node| node.is_terminal_with_kind(TerminalKind::Identifier))?), + self.try_select(|node| node.is_nonterminal_with_kind(NonTerminalKind::ImportAlias))?, ]) } } impl Selector { - fn import_alias(&mut self) -> Result>>> { + fn import_alias(&mut self) -> Result>>> { Ok(vec![ - Some(self.select(|node| node.is_token_with_kind(TokenKind::AsKeyword))?), - Some(self.select(|node| node.is_token_with_kind(TokenKind::Identifier))?), + Some(self.select(|node| node.is_terminal_with_kind(TerminalKind::AsKeyword))?), + Some(self.select(|node| node.is_terminal_with_kind(TerminalKind::Identifier))?), ]) } } impl Selector { - fn using_directive(&mut self) -> Result>>> { + fn using_directive(&mut self) -> Result>>> { Ok(vec![ - Some(self.select(|node| node.is_token_with_kind(TokenKind::UsingKeyword))?), - Some(self.select(|node| node.is_rule_with_kind(RuleKind::UsingClause))?), - Some(self.select(|node| node.is_token_with_kind(TokenKind::ForKeyword))?), - Some(self.select(|node| node.is_rule_with_kind(RuleKind::UsingTarget))?), - self.try_select(|node| node.is_token_with_kind(TokenKind::GlobalKeyword))?, - Some(self.select(|node| node.is_token_with_kind(TokenKind::Semicolon))?), + Some(self.select(|node| node.is_terminal_with_kind(TerminalKind::UsingKeyword))?), + Some(self.select(|node| node.is_nonterminal_with_kind(NonTerminalKind::UsingClause))?), + Some(self.select(|node| node.is_terminal_with_kind(TerminalKind::ForKeyword))?), + Some(self.select(|node| node.is_nonterminal_with_kind(NonTerminalKind::UsingTarget))?), + self.try_select(|node| node.is_terminal_with_kind(TerminalKind::GlobalKeyword))?, + Some(self.select(|node| node.is_terminal_with_kind(TerminalKind::Semicolon))?), ]) } } impl Selector { - fn using_deconstruction(&mut self) -> Result>>> { + fn using_deconstruction( + &mut self, + ) -> Result>>> { Ok(vec![ - Some(self.select(|node| node.is_token_with_kind(TokenKind::OpenBrace))?), - Some(self.select(|node| node.is_rule_with_kind(RuleKind::UsingDeconstructionSymbols))?), - Some(self.select(|node| node.is_token_with_kind(TokenKind::CloseBrace))?), + Some(self.select(|node| node.is_terminal_with_kind(TerminalKind::OpenBrace))?), + Some(self.select(|node| { + node.is_nonterminal_with_kind(NonTerminalKind::UsingDeconstructionSymbols) + })?), + Some(self.select(|node| node.is_terminal_with_kind(TerminalKind::CloseBrace))?), ]) } } impl Selector { - fn using_deconstruction_symbol(&mut self) -> Result>>> { + fn using_deconstruction_symbol( + &mut self, + ) -> Result>>> { Ok(vec![ - Some(self.select(|node| node.is_rule_with_kind(RuleKind::IdentifierPath))?), - self.try_select(|node| node.is_rule_with_kind(RuleKind::UsingAlias))?, + Some( + self.select(|node| node.is_nonterminal_with_kind(NonTerminalKind::IdentifierPath))?, + ), + self.try_select(|node| node.is_nonterminal_with_kind(NonTerminalKind::UsingAlias))?, ]) } } impl Selector { - fn using_alias(&mut self) -> Result>>> { + fn using_alias(&mut self) -> Result>>> { Ok(vec![ - Some(self.select(|node| node.is_token_with_kind(TokenKind::AsKeyword))?), - Some(self.select(|node| node.is_rule_with_kind(RuleKind::UsingOperator))?), + Some(self.select(|node| node.is_terminal_with_kind(TerminalKind::AsKeyword))?), + Some( + self.select(|node| node.is_nonterminal_with_kind(NonTerminalKind::UsingOperator))?, + ), ]) } } impl Selector { - fn contract_definition(&mut self) -> Result>>> { - Ok(vec![ - self.try_select(|node| node.is_token_with_kind(TokenKind::AbstractKeyword))?, - Some(self.select(|node| node.is_token_with_kind(TokenKind::ContractKeyword))?), - Some(self.select(|node| node.is_token_with_kind(TokenKind::Identifier))?), - self.try_select(|node| node.is_rule_with_kind(RuleKind::InheritanceSpecifier))?, - Some(self.select(|node| node.is_token_with_kind(TokenKind::OpenBrace))?), - Some(self.select(|node| node.is_rule_with_kind(RuleKind::ContractMembers))?), - Some(self.select(|node| node.is_token_with_kind(TokenKind::CloseBrace))?), + fn contract_definition( + &mut self, + ) -> Result>>> { + Ok(vec![ + self.try_select(|node| node.is_terminal_with_kind(TerminalKind::AbstractKeyword))?, + Some(self.select(|node| node.is_terminal_with_kind(TerminalKind::ContractKeyword))?), + Some(self.select(|node| node.is_terminal_with_kind(TerminalKind::Identifier))?), + self.try_select(|node| { + node.is_nonterminal_with_kind(NonTerminalKind::InheritanceSpecifier) + })?, + Some(self.select(|node| node.is_terminal_with_kind(TerminalKind::OpenBrace))?), + Some( + self.select(|node| { + node.is_nonterminal_with_kind(NonTerminalKind::ContractMembers) + })?, + ), + Some(self.select(|node| node.is_terminal_with_kind(TerminalKind::CloseBrace))?), ]) } } impl Selector { - fn inheritance_specifier(&mut self) -> Result>>> { + fn inheritance_specifier( + &mut self, + ) -> Result>>> { Ok(vec![ - Some(self.select(|node| node.is_token_with_kind(TokenKind::IsKeyword))?), - Some(self.select(|node| node.is_rule_with_kind(RuleKind::InheritanceTypes))?), + Some(self.select(|node| node.is_terminal_with_kind(TerminalKind::IsKeyword))?), + Some( + self.select(|node| { + node.is_nonterminal_with_kind(NonTerminalKind::InheritanceTypes) + })?, + ), ]) } } impl Selector { - fn inheritance_type(&mut self) -> Result>>> { + fn inheritance_type(&mut self) -> Result>>> { Ok(vec![ - Some(self.select(|node| node.is_rule_with_kind(RuleKind::IdentifierPath))?), - self.try_select(|node| node.is_rule_with_kind(RuleKind::ArgumentsDeclaration))?, + Some( + self.select(|node| node.is_nonterminal_with_kind(NonTerminalKind::IdentifierPath))?, + ), + self.try_select(|node| { + node.is_nonterminal_with_kind(NonTerminalKind::ArgumentsDeclaration) + })?, ]) } } impl Selector { - fn interface_definition(&mut self) -> Result>>> { - Ok(vec![ - Some(self.select(|node| node.is_token_with_kind(TokenKind::InterfaceKeyword))?), - Some(self.select(|node| node.is_token_with_kind(TokenKind::Identifier))?), - self.try_select(|node| node.is_rule_with_kind(RuleKind::InheritanceSpecifier))?, - Some(self.select(|node| node.is_token_with_kind(TokenKind::OpenBrace))?), - Some(self.select(|node| node.is_rule_with_kind(RuleKind::InterfaceMembers))?), - Some(self.select(|node| node.is_token_with_kind(TokenKind::CloseBrace))?), + fn interface_definition( + &mut self, + ) -> Result>>> { + Ok(vec![ + Some(self.select(|node| node.is_terminal_with_kind(TerminalKind::InterfaceKeyword))?), + Some(self.select(|node| node.is_terminal_with_kind(TerminalKind::Identifier))?), + self.try_select(|node| { + node.is_nonterminal_with_kind(NonTerminalKind::InheritanceSpecifier) + })?, + Some(self.select(|node| node.is_terminal_with_kind(TerminalKind::OpenBrace))?), + Some( + self.select(|node| { + node.is_nonterminal_with_kind(NonTerminalKind::InterfaceMembers) + })?, + ), + Some(self.select(|node| node.is_terminal_with_kind(TerminalKind::CloseBrace))?), ]) } } impl Selector { - fn library_definition(&mut self) -> Result>>> { + fn library_definition(&mut self) -> Result>>> { Ok(vec![ - Some(self.select(|node| node.is_token_with_kind(TokenKind::LibraryKeyword))?), - Some(self.select(|node| node.is_token_with_kind(TokenKind::Identifier))?), - Some(self.select(|node| node.is_token_with_kind(TokenKind::OpenBrace))?), - Some(self.select(|node| node.is_rule_with_kind(RuleKind::LibraryMembers))?), - Some(self.select(|node| node.is_token_with_kind(TokenKind::CloseBrace))?), + Some(self.select(|node| node.is_terminal_with_kind(TerminalKind::LibraryKeyword))?), + Some(self.select(|node| node.is_terminal_with_kind(TerminalKind::Identifier))?), + Some(self.select(|node| node.is_terminal_with_kind(TerminalKind::OpenBrace))?), + Some( + self.select(|node| node.is_nonterminal_with_kind(NonTerminalKind::LibraryMembers))?, + ), + Some(self.select(|node| node.is_terminal_with_kind(TerminalKind::CloseBrace))?), ]) } } impl Selector { - fn struct_definition(&mut self) -> Result>>> { + fn struct_definition(&mut self) -> Result>>> { Ok(vec![ - Some(self.select(|node| node.is_token_with_kind(TokenKind::StructKeyword))?), - Some(self.select(|node| node.is_token_with_kind(TokenKind::Identifier))?), - Some(self.select(|node| node.is_token_with_kind(TokenKind::OpenBrace))?), - Some(self.select(|node| node.is_rule_with_kind(RuleKind::StructMembers))?), - Some(self.select(|node| node.is_token_with_kind(TokenKind::CloseBrace))?), + Some(self.select(|node| node.is_terminal_with_kind(TerminalKind::StructKeyword))?), + Some(self.select(|node| node.is_terminal_with_kind(TerminalKind::Identifier))?), + Some(self.select(|node| node.is_terminal_with_kind(TerminalKind::OpenBrace))?), + Some( + self.select(|node| node.is_nonterminal_with_kind(NonTerminalKind::StructMembers))?, + ), + Some(self.select(|node| node.is_terminal_with_kind(TerminalKind::CloseBrace))?), ]) } } impl Selector { - fn struct_member(&mut self) -> Result>>> { + fn struct_member(&mut self) -> Result>>> { Ok(vec![ - Some(self.select(|node| node.is_rule_with_kind(RuleKind::TypeName))?), - Some(self.select(|node| node.is_token_with_kind(TokenKind::Identifier))?), - Some(self.select(|node| node.is_token_with_kind(TokenKind::Semicolon))?), + Some(self.select(|node| node.is_nonterminal_with_kind(NonTerminalKind::TypeName))?), + Some(self.select(|node| node.is_terminal_with_kind(TerminalKind::Identifier))?), + Some(self.select(|node| node.is_terminal_with_kind(TerminalKind::Semicolon))?), ]) } } impl Selector { - fn enum_definition(&mut self) -> Result>>> { + fn enum_definition(&mut self) -> Result>>> { Ok(vec![ - Some(self.select(|node| node.is_token_with_kind(TokenKind::EnumKeyword))?), - Some(self.select(|node| node.is_token_with_kind(TokenKind::Identifier))?), - Some(self.select(|node| node.is_token_with_kind(TokenKind::OpenBrace))?), - Some(self.select(|node| node.is_rule_with_kind(RuleKind::EnumMembers))?), - Some(self.select(|node| node.is_token_with_kind(TokenKind::CloseBrace))?), + Some(self.select(|node| node.is_terminal_with_kind(TerminalKind::EnumKeyword))?), + Some(self.select(|node| node.is_terminal_with_kind(TerminalKind::Identifier))?), + Some(self.select(|node| node.is_terminal_with_kind(TerminalKind::OpenBrace))?), + Some(self.select(|node| node.is_nonterminal_with_kind(NonTerminalKind::EnumMembers))?), + Some(self.select(|node| node.is_terminal_with_kind(TerminalKind::CloseBrace))?), ]) } } impl Selector { - fn constant_definition(&mut self) -> Result>>> { + fn constant_definition( + &mut self, + ) -> Result>>> { Ok(vec![ - Some(self.select(|node| node.is_rule_with_kind(RuleKind::TypeName))?), - Some(self.select(|node| node.is_token_with_kind(TokenKind::ConstantKeyword))?), - Some(self.select(|node| node.is_token_with_kind(TokenKind::Identifier))?), - Some(self.select(|node| node.is_token_with_kind(TokenKind::Equal))?), - Some(self.select(|node| node.is_rule_with_kind(RuleKind::Expression))?), - Some(self.select(|node| node.is_token_with_kind(TokenKind::Semicolon))?), + Some(self.select(|node| node.is_nonterminal_with_kind(NonTerminalKind::TypeName))?), + Some(self.select(|node| node.is_terminal_with_kind(TerminalKind::ConstantKeyword))?), + Some(self.select(|node| node.is_terminal_with_kind(TerminalKind::Identifier))?), + Some(self.select(|node| node.is_terminal_with_kind(TerminalKind::Equal))?), + Some(self.select(|node| node.is_nonterminal_with_kind(NonTerminalKind::Expression))?), + Some(self.select(|node| node.is_terminal_with_kind(TerminalKind::Semicolon))?), ]) } } impl Selector { - fn state_variable_definition(&mut self) -> Result>>> { + fn state_variable_definition( + &mut self, + ) -> Result>>> { Ok(vec![ - Some(self.select(|node| node.is_rule_with_kind(RuleKind::TypeName))?), - Some(self.select(|node| node.is_rule_with_kind(RuleKind::StateVariableAttributes))?), - Some(self.select(|node| node.is_token_with_kind(TokenKind::Identifier))?), - self.try_select(|node| node.is_rule_with_kind(RuleKind::StateVariableDefinitionValue))?, - Some(self.select(|node| node.is_token_with_kind(TokenKind::Semicolon))?), + Some(self.select(|node| node.is_nonterminal_with_kind(NonTerminalKind::TypeName))?), + Some(self.select(|node| { + node.is_nonterminal_with_kind(NonTerminalKind::StateVariableAttributes) + })?), + Some(self.select(|node| node.is_terminal_with_kind(TerminalKind::Identifier))?), + self.try_select(|node| { + node.is_nonterminal_with_kind(NonTerminalKind::StateVariableDefinitionValue) + })?, + Some(self.select(|node| node.is_terminal_with_kind(TerminalKind::Semicolon))?), ]) } } @@ -450,169 +534,237 @@ impl Selector { impl Selector { fn state_variable_definition_value( &mut self, - ) -> Result>>> { + ) -> Result>>> { Ok(vec![ - Some(self.select(|node| node.is_token_with_kind(TokenKind::Equal))?), - Some(self.select(|node| node.is_rule_with_kind(RuleKind::Expression))?), + Some(self.select(|node| node.is_terminal_with_kind(TerminalKind::Equal))?), + Some(self.select(|node| node.is_nonterminal_with_kind(NonTerminalKind::Expression))?), ]) } } impl Selector { - fn function_definition(&mut self) -> Result>>> { + fn function_definition( + &mut self, + ) -> Result>>> { Ok(vec![ - Some(self.select(|node| node.is_token_with_kind(TokenKind::FunctionKeyword))?), - Some(self.select(|node| node.is_rule_with_kind(RuleKind::FunctionName))?), - Some(self.select(|node| node.is_rule_with_kind(RuleKind::ParametersDeclaration))?), - Some(self.select(|node| node.is_rule_with_kind(RuleKind::FunctionAttributes))?), - self.try_select(|node| node.is_rule_with_kind(RuleKind::ReturnsDeclaration))?, - Some(self.select(|node| node.is_rule_with_kind(RuleKind::FunctionBody))?), + Some(self.select(|node| node.is_terminal_with_kind(TerminalKind::FunctionKeyword))?), + Some(self.select(|node| node.is_nonterminal_with_kind(NonTerminalKind::FunctionName))?), + Some(self.select(|node| { + node.is_nonterminal_with_kind(NonTerminalKind::ParametersDeclaration) + })?), + Some(self.select(|node| { + node.is_nonterminal_with_kind(NonTerminalKind::FunctionAttributes) + })?), + self.try_select(|node| { + node.is_nonterminal_with_kind(NonTerminalKind::ReturnsDeclaration) + })?, + Some(self.select(|node| node.is_nonterminal_with_kind(NonTerminalKind::FunctionBody))?), ]) } } impl Selector { - fn parameters_declaration(&mut self) -> Result>>> { + fn parameters_declaration( + &mut self, + ) -> Result>>> { Ok(vec![ - Some(self.select(|node| node.is_token_with_kind(TokenKind::OpenParen))?), - Some(self.select(|node| node.is_rule_with_kind(RuleKind::Parameters))?), - Some(self.select(|node| node.is_token_with_kind(TokenKind::CloseParen))?), + Some(self.select(|node| node.is_terminal_with_kind(TerminalKind::OpenParen))?), + Some(self.select(|node| node.is_nonterminal_with_kind(NonTerminalKind::Parameters))?), + Some(self.select(|node| node.is_terminal_with_kind(TerminalKind::CloseParen))?), ]) } } impl Selector { - fn parameter(&mut self) -> Result>>> { + fn parameter(&mut self) -> Result>>> { Ok(vec![ - Some(self.select(|node| node.is_rule_with_kind(RuleKind::TypeName))?), - self.try_select(|node| node.is_rule_with_kind(RuleKind::StorageLocation))?, - self.try_select(|node| node.is_token_with_kind(TokenKind::Identifier))?, + Some(self.select(|node| node.is_nonterminal_with_kind(NonTerminalKind::TypeName))?), + self.try_select(|node| { + node.is_nonterminal_with_kind(NonTerminalKind::StorageLocation) + })?, + self.try_select(|node| node.is_terminal_with_kind(TerminalKind::Identifier))?, ]) } } impl Selector { - fn override_specifier(&mut self) -> Result>>> { + fn override_specifier(&mut self) -> Result>>> { Ok(vec![ - Some(self.select(|node| node.is_token_with_kind(TokenKind::OverrideKeyword))?), - self.try_select(|node| node.is_rule_with_kind(RuleKind::OverridePathsDeclaration))?, + Some(self.select(|node| node.is_terminal_with_kind(TerminalKind::OverrideKeyword))?), + self.try_select(|node| { + node.is_nonterminal_with_kind(NonTerminalKind::OverridePathsDeclaration) + })?, ]) } } impl Selector { - fn override_paths_declaration(&mut self) -> Result>>> { + fn override_paths_declaration( + &mut self, + ) -> Result>>> { Ok(vec![ - Some(self.select(|node| node.is_token_with_kind(TokenKind::OpenParen))?), - Some(self.select(|node| node.is_rule_with_kind(RuleKind::OverridePaths))?), - Some(self.select(|node| node.is_token_with_kind(TokenKind::CloseParen))?), + Some(self.select(|node| node.is_terminal_with_kind(TerminalKind::OpenParen))?), + Some( + self.select(|node| node.is_nonterminal_with_kind(NonTerminalKind::OverridePaths))?, + ), + Some(self.select(|node| node.is_terminal_with_kind(TerminalKind::CloseParen))?), ]) } } impl Selector { - fn returns_declaration(&mut self) -> Result>>> { + fn returns_declaration( + &mut self, + ) -> Result>>> { Ok(vec![ - Some(self.select(|node| node.is_token_with_kind(TokenKind::ReturnsKeyword))?), - Some(self.select(|node| node.is_rule_with_kind(RuleKind::ParametersDeclaration))?), + Some(self.select(|node| node.is_terminal_with_kind(TerminalKind::ReturnsKeyword))?), + Some(self.select(|node| { + node.is_nonterminal_with_kind(NonTerminalKind::ParametersDeclaration) + })?), ]) } } impl Selector { - fn constructor_definition(&mut self) -> Result>>> { + fn constructor_definition( + &mut self, + ) -> Result>>> { Ok(vec![ - Some(self.select(|node| node.is_token_with_kind(TokenKind::ConstructorKeyword))?), - Some(self.select(|node| node.is_rule_with_kind(RuleKind::ParametersDeclaration))?), - Some(self.select(|node| node.is_rule_with_kind(RuleKind::ConstructorAttributes))?), - Some(self.select(|node| node.is_rule_with_kind(RuleKind::Block))?), + Some(self.select(|node| node.is_terminal_with_kind(TerminalKind::ConstructorKeyword))?), + Some(self.select(|node| { + node.is_nonterminal_with_kind(NonTerminalKind::ParametersDeclaration) + })?), + Some(self.select(|node| { + node.is_nonterminal_with_kind(NonTerminalKind::ConstructorAttributes) + })?), + Some(self.select(|node| node.is_nonterminal_with_kind(NonTerminalKind::Block))?), ]) } } impl Selector { - fn unnamed_function_definition(&mut self) -> Result>>> { + fn unnamed_function_definition( + &mut self, + ) -> Result>>> { Ok(vec![ - Some(self.select(|node| node.is_token_with_kind(TokenKind::FunctionKeyword))?), - Some(self.select(|node| node.is_rule_with_kind(RuleKind::ParametersDeclaration))?), - Some(self.select(|node| node.is_rule_with_kind(RuleKind::UnnamedFunctionAttributes))?), - Some(self.select(|node| node.is_rule_with_kind(RuleKind::FunctionBody))?), + Some(self.select(|node| node.is_terminal_with_kind(TerminalKind::FunctionKeyword))?), + Some(self.select(|node| { + node.is_nonterminal_with_kind(NonTerminalKind::ParametersDeclaration) + })?), + Some(self.select(|node| { + node.is_nonterminal_with_kind(NonTerminalKind::UnnamedFunctionAttributes) + })?), + Some(self.select(|node| node.is_nonterminal_with_kind(NonTerminalKind::FunctionBody))?), ]) } } impl Selector { - fn fallback_function_definition(&mut self) -> Result>>> { + fn fallback_function_definition( + &mut self, + ) -> Result>>> { Ok(vec![ - Some(self.select(|node| node.is_token_with_kind(TokenKind::FallbackKeyword))?), - Some(self.select(|node| node.is_rule_with_kind(RuleKind::ParametersDeclaration))?), - Some(self.select(|node| node.is_rule_with_kind(RuleKind::FallbackFunctionAttributes))?), - self.try_select(|node| node.is_rule_with_kind(RuleKind::ReturnsDeclaration))?, - Some(self.select(|node| node.is_rule_with_kind(RuleKind::FunctionBody))?), + Some(self.select(|node| node.is_terminal_with_kind(TerminalKind::FallbackKeyword))?), + Some(self.select(|node| { + node.is_nonterminal_with_kind(NonTerminalKind::ParametersDeclaration) + })?), + Some(self.select(|node| { + node.is_nonterminal_with_kind(NonTerminalKind::FallbackFunctionAttributes) + })?), + self.try_select(|node| { + node.is_nonterminal_with_kind(NonTerminalKind::ReturnsDeclaration) + })?, + Some(self.select(|node| node.is_nonterminal_with_kind(NonTerminalKind::FunctionBody))?), ]) } } impl Selector { - fn receive_function_definition(&mut self) -> Result>>> { + fn receive_function_definition( + &mut self, + ) -> Result>>> { Ok(vec![ - Some(self.select(|node| node.is_token_with_kind(TokenKind::ReceiveKeyword))?), - Some(self.select(|node| node.is_rule_with_kind(RuleKind::ParametersDeclaration))?), - Some(self.select(|node| node.is_rule_with_kind(RuleKind::ReceiveFunctionAttributes))?), - Some(self.select(|node| node.is_rule_with_kind(RuleKind::FunctionBody))?), + Some(self.select(|node| node.is_terminal_with_kind(TerminalKind::ReceiveKeyword))?), + Some(self.select(|node| { + node.is_nonterminal_with_kind(NonTerminalKind::ParametersDeclaration) + })?), + Some(self.select(|node| { + node.is_nonterminal_with_kind(NonTerminalKind::ReceiveFunctionAttributes) + })?), + Some(self.select(|node| node.is_nonterminal_with_kind(NonTerminalKind::FunctionBody))?), ]) } } impl Selector { - fn modifier_definition(&mut self) -> Result>>> { + fn modifier_definition( + &mut self, + ) -> Result>>> { Ok(vec![ - Some(self.select(|node| node.is_token_with_kind(TokenKind::ModifierKeyword))?), - Some(self.select(|node| node.is_token_with_kind(TokenKind::Identifier))?), - self.try_select(|node| node.is_rule_with_kind(RuleKind::ParametersDeclaration))?, - Some(self.select(|node| node.is_rule_with_kind(RuleKind::ModifierAttributes))?), - Some(self.select(|node| node.is_rule_with_kind(RuleKind::FunctionBody))?), + Some(self.select(|node| node.is_terminal_with_kind(TerminalKind::ModifierKeyword))?), + Some(self.select(|node| node.is_terminal_with_kind(TerminalKind::Identifier))?), + self.try_select(|node| { + node.is_nonterminal_with_kind(NonTerminalKind::ParametersDeclaration) + })?, + Some(self.select(|node| { + node.is_nonterminal_with_kind(NonTerminalKind::ModifierAttributes) + })?), + Some(self.select(|node| node.is_nonterminal_with_kind(NonTerminalKind::FunctionBody))?), ]) } } impl Selector { - fn modifier_invocation(&mut self) -> Result>>> { + fn modifier_invocation( + &mut self, + ) -> Result>>> { Ok(vec![ - Some(self.select(|node| node.is_rule_with_kind(RuleKind::IdentifierPath))?), - self.try_select(|node| node.is_rule_with_kind(RuleKind::ArgumentsDeclaration))?, + Some( + self.select(|node| node.is_nonterminal_with_kind(NonTerminalKind::IdentifierPath))?, + ), + self.try_select(|node| { + node.is_nonterminal_with_kind(NonTerminalKind::ArgumentsDeclaration) + })?, ]) } } impl Selector { - fn event_definition(&mut self) -> Result>>> { + fn event_definition(&mut self) -> Result>>> { Ok(vec![ - Some(self.select(|node| node.is_token_with_kind(TokenKind::EventKeyword))?), - Some(self.select(|node| node.is_token_with_kind(TokenKind::Identifier))?), - Some(self.select(|node| node.is_rule_with_kind(RuleKind::EventParametersDeclaration))?), - self.try_select(|node| node.is_token_with_kind(TokenKind::AnonymousKeyword))?, - Some(self.select(|node| node.is_token_with_kind(TokenKind::Semicolon))?), + Some(self.select(|node| node.is_terminal_with_kind(TerminalKind::EventKeyword))?), + Some(self.select(|node| node.is_terminal_with_kind(TerminalKind::Identifier))?), + Some(self.select(|node| { + node.is_nonterminal_with_kind(NonTerminalKind::EventParametersDeclaration) + })?), + self.try_select(|node| node.is_terminal_with_kind(TerminalKind::AnonymousKeyword))?, + Some(self.select(|node| node.is_terminal_with_kind(TerminalKind::Semicolon))?), ]) } } impl Selector { - fn event_parameters_declaration(&mut self) -> Result>>> { + fn event_parameters_declaration( + &mut self, + ) -> Result>>> { Ok(vec![ - Some(self.select(|node| node.is_token_with_kind(TokenKind::OpenParen))?), - Some(self.select(|node| node.is_rule_with_kind(RuleKind::EventParameters))?), - Some(self.select(|node| node.is_token_with_kind(TokenKind::CloseParen))?), + Some(self.select(|node| node.is_terminal_with_kind(TerminalKind::OpenParen))?), + Some( + self.select(|node| { + node.is_nonterminal_with_kind(NonTerminalKind::EventParameters) + })?, + ), + Some(self.select(|node| node.is_terminal_with_kind(TerminalKind::CloseParen))?), ]) } } impl Selector { - fn event_parameter(&mut self) -> Result>>> { + fn event_parameter(&mut self) -> Result>>> { Ok(vec![ - Some(self.select(|node| node.is_rule_with_kind(RuleKind::TypeName))?), - self.try_select(|node| node.is_token_with_kind(TokenKind::IndexedKeyword))?, - self.try_select(|node| node.is_token_with_kind(TokenKind::Identifier))?, + Some(self.select(|node| node.is_nonterminal_with_kind(NonTerminalKind::TypeName))?), + self.try_select(|node| node.is_terminal_with_kind(TerminalKind::IndexedKeyword))?, + self.try_select(|node| node.is_terminal_with_kind(TerminalKind::Identifier))?, ]) } } @@ -620,154 +772,180 @@ impl Selector { impl Selector { fn user_defined_value_type_definition( &mut self, - ) -> Result>>> { + ) -> Result>>> { Ok(vec![ - Some(self.select(|node| node.is_token_with_kind(TokenKind::TypeKeyword))?), - Some(self.select(|node| node.is_token_with_kind(TokenKind::Identifier))?), - Some(self.select(|node| node.is_token_with_kind(TokenKind::IsKeyword))?), - Some(self.select(|node| node.is_rule_with_kind(RuleKind::ElementaryType))?), - Some(self.select(|node| node.is_token_with_kind(TokenKind::Semicolon))?), + Some(self.select(|node| node.is_terminal_with_kind(TerminalKind::TypeKeyword))?), + Some(self.select(|node| node.is_terminal_with_kind(TerminalKind::Identifier))?), + Some(self.select(|node| node.is_terminal_with_kind(TerminalKind::IsKeyword))?), + Some( + self.select(|node| node.is_nonterminal_with_kind(NonTerminalKind::ElementaryType))?, + ), + Some(self.select(|node| node.is_terminal_with_kind(TerminalKind::Semicolon))?), ]) } } impl Selector { - fn error_definition(&mut self) -> Result>>> { + fn error_definition(&mut self) -> Result>>> { Ok(vec![ - Some(self.select(|node| node.is_token_with_kind(TokenKind::ErrorKeyword))?), - Some(self.select(|node| node.is_token_with_kind(TokenKind::Identifier))?), - Some(self.select(|node| node.is_rule_with_kind(RuleKind::ErrorParametersDeclaration))?), - Some(self.select(|node| node.is_token_with_kind(TokenKind::Semicolon))?), + Some(self.select(|node| node.is_terminal_with_kind(TerminalKind::ErrorKeyword))?), + Some(self.select(|node| node.is_terminal_with_kind(TerminalKind::Identifier))?), + Some(self.select(|node| { + node.is_nonterminal_with_kind(NonTerminalKind::ErrorParametersDeclaration) + })?), + Some(self.select(|node| node.is_terminal_with_kind(TerminalKind::Semicolon))?), ]) } } impl Selector { - fn error_parameters_declaration(&mut self) -> Result>>> { + fn error_parameters_declaration( + &mut self, + ) -> Result>>> { Ok(vec![ - Some(self.select(|node| node.is_token_with_kind(TokenKind::OpenParen))?), - Some(self.select(|node| node.is_rule_with_kind(RuleKind::ErrorParameters))?), - Some(self.select(|node| node.is_token_with_kind(TokenKind::CloseParen))?), + Some(self.select(|node| node.is_terminal_with_kind(TerminalKind::OpenParen))?), + Some( + self.select(|node| { + node.is_nonterminal_with_kind(NonTerminalKind::ErrorParameters) + })?, + ), + Some(self.select(|node| node.is_terminal_with_kind(TerminalKind::CloseParen))?), ]) } } impl Selector { - fn error_parameter(&mut self) -> Result>>> { + fn error_parameter(&mut self) -> Result>>> { Ok(vec![ - Some(self.select(|node| node.is_rule_with_kind(RuleKind::TypeName))?), - self.try_select(|node| node.is_token_with_kind(TokenKind::Identifier))?, + Some(self.select(|node| node.is_nonterminal_with_kind(NonTerminalKind::TypeName))?), + self.try_select(|node| node.is_terminal_with_kind(TerminalKind::Identifier))?, ]) } } impl Selector { - fn array_type_name(&mut self) -> Result>>> { + fn array_type_name(&mut self) -> Result>>> { Ok(vec![ - Some(self.select(|node| node.is_rule_with_kind(RuleKind::TypeName))?), - Some(self.select(|node| node.is_token_with_kind(TokenKind::OpenBracket))?), - self.try_select(|node| node.is_rule_with_kind(RuleKind::Expression))?, - Some(self.select(|node| node.is_token_with_kind(TokenKind::CloseBracket))?), + Some(self.select(|node| node.is_nonterminal_with_kind(NonTerminalKind::TypeName))?), + Some(self.select(|node| node.is_terminal_with_kind(TerminalKind::OpenBracket))?), + self.try_select(|node| node.is_nonterminal_with_kind(NonTerminalKind::Expression))?, + Some(self.select(|node| node.is_terminal_with_kind(TerminalKind::CloseBracket))?), ]) } } impl Selector { - fn function_type(&mut self) -> Result>>> { + fn function_type(&mut self) -> Result>>> { Ok(vec![ - Some(self.select(|node| node.is_token_with_kind(TokenKind::FunctionKeyword))?), - Some(self.select(|node| node.is_rule_with_kind(RuleKind::ParametersDeclaration))?), - Some(self.select(|node| node.is_rule_with_kind(RuleKind::FunctionTypeAttributes))?), - self.try_select(|node| node.is_rule_with_kind(RuleKind::ReturnsDeclaration))?, + Some(self.select(|node| node.is_terminal_with_kind(TerminalKind::FunctionKeyword))?), + Some(self.select(|node| { + node.is_nonterminal_with_kind(NonTerminalKind::ParametersDeclaration) + })?), + Some(self.select(|node| { + node.is_nonterminal_with_kind(NonTerminalKind::FunctionTypeAttributes) + })?), + self.try_select(|node| { + node.is_nonterminal_with_kind(NonTerminalKind::ReturnsDeclaration) + })?, ]) } } impl Selector { - fn mapping_type(&mut self) -> Result>>> { + fn mapping_type(&mut self) -> Result>>> { Ok(vec![ - Some(self.select(|node| node.is_token_with_kind(TokenKind::MappingKeyword))?), - Some(self.select(|node| node.is_token_with_kind(TokenKind::OpenParen))?), - Some(self.select(|node| node.is_rule_with_kind(RuleKind::MappingKey))?), - Some(self.select(|node| node.is_token_with_kind(TokenKind::EqualGreaterThan))?), - Some(self.select(|node| node.is_rule_with_kind(RuleKind::MappingValue))?), - Some(self.select(|node| node.is_token_with_kind(TokenKind::CloseParen))?), + Some(self.select(|node| node.is_terminal_with_kind(TerminalKind::MappingKeyword))?), + Some(self.select(|node| node.is_terminal_with_kind(TerminalKind::OpenParen))?), + Some(self.select(|node| node.is_nonterminal_with_kind(NonTerminalKind::MappingKey))?), + Some(self.select(|node| node.is_terminal_with_kind(TerminalKind::EqualGreaterThan))?), + Some(self.select(|node| node.is_nonterminal_with_kind(NonTerminalKind::MappingValue))?), + Some(self.select(|node| node.is_terminal_with_kind(TerminalKind::CloseParen))?), ]) } } impl Selector { - fn mapping_key(&mut self) -> Result>>> { + fn mapping_key(&mut self) -> Result>>> { Ok(vec![ - Some(self.select(|node| node.is_rule_with_kind(RuleKind::MappingKeyType))?), - self.try_select(|node| node.is_token_with_kind(TokenKind::Identifier))?, + Some( + self.select(|node| node.is_nonterminal_with_kind(NonTerminalKind::MappingKeyType))?, + ), + self.try_select(|node| node.is_terminal_with_kind(TerminalKind::Identifier))?, ]) } } impl Selector { - fn mapping_value(&mut self) -> Result>>> { + fn mapping_value(&mut self) -> Result>>> { Ok(vec![ - Some(self.select(|node| node.is_rule_with_kind(RuleKind::TypeName))?), - self.try_select(|node| node.is_token_with_kind(TokenKind::Identifier))?, + Some(self.select(|node| node.is_nonterminal_with_kind(NonTerminalKind::TypeName))?), + self.try_select(|node| node.is_terminal_with_kind(TerminalKind::Identifier))?, ]) } } impl Selector { - fn address_type(&mut self) -> Result>>> { + fn address_type(&mut self) -> Result>>> { Ok(vec![ - Some(self.select(|node| node.is_token_with_kind(TokenKind::AddressKeyword))?), - self.try_select(|node| node.is_token_with_kind(TokenKind::PayableKeyword))?, + Some(self.select(|node| node.is_terminal_with_kind(TerminalKind::AddressKeyword))?), + self.try_select(|node| node.is_terminal_with_kind(TerminalKind::PayableKeyword))?, ]) } } impl Selector { - fn block(&mut self) -> Result>>> { + fn block(&mut self) -> Result>>> { Ok(vec![ - Some(self.select(|node| node.is_token_with_kind(TokenKind::OpenBrace))?), - Some(self.select(|node| node.is_rule_with_kind(RuleKind::Statements))?), - Some(self.select(|node| node.is_token_with_kind(TokenKind::CloseBrace))?), + Some(self.select(|node| node.is_terminal_with_kind(TerminalKind::OpenBrace))?), + Some(self.select(|node| node.is_nonterminal_with_kind(NonTerminalKind::Statements))?), + Some(self.select(|node| node.is_terminal_with_kind(TerminalKind::CloseBrace))?), ]) } } impl Selector { - fn unchecked_block(&mut self) -> Result>>> { + fn unchecked_block(&mut self) -> Result>>> { Ok(vec![ - Some(self.select(|node| node.is_token_with_kind(TokenKind::UncheckedKeyword))?), - Some(self.select(|node| node.is_rule_with_kind(RuleKind::Block))?), + Some(self.select(|node| node.is_terminal_with_kind(TerminalKind::UncheckedKeyword))?), + Some(self.select(|node| node.is_nonterminal_with_kind(NonTerminalKind::Block))?), ]) } } impl Selector { - fn expression_statement(&mut self) -> Result>>> { + fn expression_statement( + &mut self, + ) -> Result>>> { Ok(vec![ - Some(self.select(|node| node.is_rule_with_kind(RuleKind::Expression))?), - Some(self.select(|node| node.is_token_with_kind(TokenKind::Semicolon))?), + Some(self.select(|node| node.is_nonterminal_with_kind(NonTerminalKind::Expression))?), + Some(self.select(|node| node.is_terminal_with_kind(TerminalKind::Semicolon))?), ]) } } impl Selector { - fn assembly_statement(&mut self) -> Result>>> { + fn assembly_statement(&mut self) -> Result>>> { Ok(vec![ - Some(self.select(|node| node.is_token_with_kind(TokenKind::AssemblyKeyword))?), - self.try_select(|node| node.is_rule_with_kind(RuleKind::StringLiteral))?, - self.try_select(|node| node.is_rule_with_kind(RuleKind::AssemblyFlagsDeclaration))?, - Some(self.select(|node| node.is_rule_with_kind(RuleKind::YulBlock))?), + Some(self.select(|node| node.is_terminal_with_kind(TerminalKind::AssemblyKeyword))?), + self.try_select(|node| node.is_nonterminal_with_kind(NonTerminalKind::StringLiteral))?, + self.try_select(|node| { + node.is_nonterminal_with_kind(NonTerminalKind::AssemblyFlagsDeclaration) + })?, + Some(self.select(|node| node.is_nonterminal_with_kind(NonTerminalKind::YulBlock))?), ]) } } impl Selector { - fn assembly_flags_declaration(&mut self) -> Result>>> { + fn assembly_flags_declaration( + &mut self, + ) -> Result>>> { Ok(vec![ - Some(self.select(|node| node.is_token_with_kind(TokenKind::OpenParen))?), - Some(self.select(|node| node.is_rule_with_kind(RuleKind::AssemblyFlags))?), - Some(self.select(|node| node.is_token_with_kind(TokenKind::CloseParen))?), + Some(self.select(|node| node.is_terminal_with_kind(TerminalKind::OpenParen))?), + Some( + self.select(|node| node.is_nonterminal_with_kind(NonTerminalKind::AssemblyFlags))?, + ), + Some(self.select(|node| node.is_terminal_with_kind(TerminalKind::CloseParen))?), ]) } } @@ -775,44 +953,52 @@ impl Selector { impl Selector { fn tuple_deconstruction_statement( &mut self, - ) -> Result>>> { + ) -> Result>>> { Ok(vec![ - self.try_select(|node| node.is_token_with_kind(TokenKind::VarKeyword))?, - Some(self.select(|node| node.is_token_with_kind(TokenKind::OpenParen))?), - Some( - self.select(|node| node.is_rule_with_kind(RuleKind::TupleDeconstructionElements))?, - ), - Some(self.select(|node| node.is_token_with_kind(TokenKind::CloseParen))?), - Some(self.select(|node| node.is_token_with_kind(TokenKind::Equal))?), - Some(self.select(|node| node.is_rule_with_kind(RuleKind::Expression))?), - Some(self.select(|node| node.is_token_with_kind(TokenKind::Semicolon))?), + self.try_select(|node| node.is_terminal_with_kind(TerminalKind::VarKeyword))?, + Some(self.select(|node| node.is_terminal_with_kind(TerminalKind::OpenParen))?), + Some(self.select(|node| { + node.is_nonterminal_with_kind(NonTerminalKind::TupleDeconstructionElements) + })?), + Some(self.select(|node| node.is_terminal_with_kind(TerminalKind::CloseParen))?), + Some(self.select(|node| node.is_terminal_with_kind(TerminalKind::Equal))?), + Some(self.select(|node| node.is_nonterminal_with_kind(NonTerminalKind::Expression))?), + Some(self.select(|node| node.is_terminal_with_kind(TerminalKind::Semicolon))?), ]) } } impl Selector { - fn tuple_deconstruction_element(&mut self) -> Result>>> { + fn tuple_deconstruction_element( + &mut self, + ) -> Result>>> { Ok(vec![self.try_select(|node| { - node.is_rule_with_kind(RuleKind::TupleMember) + node.is_nonterminal_with_kind(NonTerminalKind::TupleMember) })?]) } } impl Selector { - fn typed_tuple_member(&mut self) -> Result>>> { + fn typed_tuple_member(&mut self) -> Result>>> { Ok(vec![ - Some(self.select(|node| node.is_rule_with_kind(RuleKind::TypeName))?), - self.try_select(|node| node.is_rule_with_kind(RuleKind::StorageLocation))?, - Some(self.select(|node| node.is_token_with_kind(TokenKind::Identifier))?), + Some(self.select(|node| node.is_nonterminal_with_kind(NonTerminalKind::TypeName))?), + self.try_select(|node| { + node.is_nonterminal_with_kind(NonTerminalKind::StorageLocation) + })?, + Some(self.select(|node| node.is_terminal_with_kind(TerminalKind::Identifier))?), ]) } } impl Selector { - fn untyped_tuple_member(&mut self) -> Result>>> { + fn untyped_tuple_member( + &mut self, + ) -> Result>>> { Ok(vec![ - self.try_select(|node| node.is_rule_with_kind(RuleKind::StorageLocation))?, - Some(self.select(|node| node.is_token_with_kind(TokenKind::Identifier))?), + self.try_select(|node| { + node.is_nonterminal_with_kind(NonTerminalKind::StorageLocation) + })?, + Some(self.select(|node| node.is_terminal_with_kind(TerminalKind::Identifier))?), ]) } } @@ -820,375 +1006,429 @@ impl Selector { impl Selector { fn variable_declaration_statement( &mut self, - ) -> Result>>> { + ) -> Result>>> { Ok(vec![ - Some(self.select(|node| node.is_rule_with_kind(RuleKind::VariableDeclarationType))?), - self.try_select(|node| node.is_rule_with_kind(RuleKind::StorageLocation))?, - Some(self.select(|node| node.is_token_with_kind(TokenKind::Identifier))?), - self.try_select(|node| node.is_rule_with_kind(RuleKind::VariableDeclarationValue))?, - Some(self.select(|node| node.is_token_with_kind(TokenKind::Semicolon))?), + Some(self.select(|node| { + node.is_nonterminal_with_kind(NonTerminalKind::VariableDeclarationType) + })?), + self.try_select(|node| { + node.is_nonterminal_with_kind(NonTerminalKind::StorageLocation) + })?, + Some(self.select(|node| node.is_terminal_with_kind(TerminalKind::Identifier))?), + self.try_select(|node| { + node.is_nonterminal_with_kind(NonTerminalKind::VariableDeclarationValue) + })?, + Some(self.select(|node| node.is_terminal_with_kind(TerminalKind::Semicolon))?), ]) } } impl Selector { - fn variable_declaration_value(&mut self) -> Result>>> { + fn variable_declaration_value( + &mut self, + ) -> Result>>> { Ok(vec![ - Some(self.select(|node| node.is_token_with_kind(TokenKind::Equal))?), - Some(self.select(|node| node.is_rule_with_kind(RuleKind::Expression))?), + Some(self.select(|node| node.is_terminal_with_kind(TerminalKind::Equal))?), + Some(self.select(|node| node.is_nonterminal_with_kind(NonTerminalKind::Expression))?), ]) } } impl Selector { - fn if_statement(&mut self) -> Result>>> { + fn if_statement(&mut self) -> Result>>> { Ok(vec![ - Some(self.select(|node| node.is_token_with_kind(TokenKind::IfKeyword))?), - Some(self.select(|node| node.is_token_with_kind(TokenKind::OpenParen))?), - Some(self.select(|node| node.is_rule_with_kind(RuleKind::Expression))?), - Some(self.select(|node| node.is_token_with_kind(TokenKind::CloseParen))?), - Some(self.select(|node| node.is_rule_with_kind(RuleKind::Statement))?), - self.try_select(|node| node.is_rule_with_kind(RuleKind::ElseBranch))?, + Some(self.select(|node| node.is_terminal_with_kind(TerminalKind::IfKeyword))?), + Some(self.select(|node| node.is_terminal_with_kind(TerminalKind::OpenParen))?), + Some(self.select(|node| node.is_nonterminal_with_kind(NonTerminalKind::Expression))?), + Some(self.select(|node| node.is_terminal_with_kind(TerminalKind::CloseParen))?), + Some(self.select(|node| node.is_nonterminal_with_kind(NonTerminalKind::Statement))?), + self.try_select(|node| node.is_nonterminal_with_kind(NonTerminalKind::ElseBranch))?, ]) } } impl Selector { - fn else_branch(&mut self) -> Result>>> { + fn else_branch(&mut self) -> Result>>> { Ok(vec![ - Some(self.select(|node| node.is_token_with_kind(TokenKind::ElseKeyword))?), - Some(self.select(|node| node.is_rule_with_kind(RuleKind::Statement))?), + Some(self.select(|node| node.is_terminal_with_kind(TerminalKind::ElseKeyword))?), + Some(self.select(|node| node.is_nonterminal_with_kind(NonTerminalKind::Statement))?), ]) } } impl Selector { - fn for_statement(&mut self) -> Result>>> { + fn for_statement(&mut self) -> Result>>> { Ok(vec![ - Some(self.select(|node| node.is_token_with_kind(TokenKind::ForKeyword))?), - Some(self.select(|node| node.is_token_with_kind(TokenKind::OpenParen))?), - Some(self.select(|node| node.is_rule_with_kind(RuleKind::ForStatementInitialization))?), - Some(self.select(|node| node.is_rule_with_kind(RuleKind::ForStatementCondition))?), - self.try_select(|node| node.is_rule_with_kind(RuleKind::Expression))?, - Some(self.select(|node| node.is_token_with_kind(TokenKind::CloseParen))?), - Some(self.select(|node| node.is_rule_with_kind(RuleKind::Statement))?), + Some(self.select(|node| node.is_terminal_with_kind(TerminalKind::ForKeyword))?), + Some(self.select(|node| node.is_terminal_with_kind(TerminalKind::OpenParen))?), + Some(self.select(|node| { + node.is_nonterminal_with_kind(NonTerminalKind::ForStatementInitialization) + })?), + Some(self.select(|node| { + node.is_nonterminal_with_kind(NonTerminalKind::ForStatementCondition) + })?), + self.try_select(|node| node.is_nonterminal_with_kind(NonTerminalKind::Expression))?, + Some(self.select(|node| node.is_terminal_with_kind(TerminalKind::CloseParen))?), + Some(self.select(|node| node.is_nonterminal_with_kind(NonTerminalKind::Statement))?), ]) } } impl Selector { - fn while_statement(&mut self) -> Result>>> { + fn while_statement(&mut self) -> Result>>> { Ok(vec![ - Some(self.select(|node| node.is_token_with_kind(TokenKind::WhileKeyword))?), - Some(self.select(|node| node.is_token_with_kind(TokenKind::OpenParen))?), - Some(self.select(|node| node.is_rule_with_kind(RuleKind::Expression))?), - Some(self.select(|node| node.is_token_with_kind(TokenKind::CloseParen))?), - Some(self.select(|node| node.is_rule_with_kind(RuleKind::Statement))?), + Some(self.select(|node| node.is_terminal_with_kind(TerminalKind::WhileKeyword))?), + Some(self.select(|node| node.is_terminal_with_kind(TerminalKind::OpenParen))?), + Some(self.select(|node| node.is_nonterminal_with_kind(NonTerminalKind::Expression))?), + Some(self.select(|node| node.is_terminal_with_kind(TerminalKind::CloseParen))?), + Some(self.select(|node| node.is_nonterminal_with_kind(NonTerminalKind::Statement))?), ]) } } impl Selector { - fn do_while_statement(&mut self) -> Result>>> { + fn do_while_statement(&mut self) -> Result>>> { Ok(vec![ - Some(self.select(|node| node.is_token_with_kind(TokenKind::DoKeyword))?), - Some(self.select(|node| node.is_rule_with_kind(RuleKind::Statement))?), - Some(self.select(|node| node.is_token_with_kind(TokenKind::WhileKeyword))?), - Some(self.select(|node| node.is_token_with_kind(TokenKind::OpenParen))?), - Some(self.select(|node| node.is_rule_with_kind(RuleKind::Expression))?), - Some(self.select(|node| node.is_token_with_kind(TokenKind::CloseParen))?), - Some(self.select(|node| node.is_token_with_kind(TokenKind::Semicolon))?), + Some(self.select(|node| node.is_terminal_with_kind(TerminalKind::DoKeyword))?), + Some(self.select(|node| node.is_nonterminal_with_kind(NonTerminalKind::Statement))?), + Some(self.select(|node| node.is_terminal_with_kind(TerminalKind::WhileKeyword))?), + Some(self.select(|node| node.is_terminal_with_kind(TerminalKind::OpenParen))?), + Some(self.select(|node| node.is_nonterminal_with_kind(NonTerminalKind::Expression))?), + Some(self.select(|node| node.is_terminal_with_kind(TerminalKind::CloseParen))?), + Some(self.select(|node| node.is_terminal_with_kind(TerminalKind::Semicolon))?), ]) } } impl Selector { - fn continue_statement(&mut self) -> Result>>> { + fn continue_statement(&mut self) -> Result>>> { Ok(vec![ - Some(self.select(|node| node.is_token_with_kind(TokenKind::ContinueKeyword))?), - Some(self.select(|node| node.is_token_with_kind(TokenKind::Semicolon))?), + Some(self.select(|node| node.is_terminal_with_kind(TerminalKind::ContinueKeyword))?), + Some(self.select(|node| node.is_terminal_with_kind(TerminalKind::Semicolon))?), ]) } } impl Selector { - fn break_statement(&mut self) -> Result>>> { + fn break_statement(&mut self) -> Result>>> { Ok(vec![ - Some(self.select(|node| node.is_token_with_kind(TokenKind::BreakKeyword))?), - Some(self.select(|node| node.is_token_with_kind(TokenKind::Semicolon))?), + Some(self.select(|node| node.is_terminal_with_kind(TerminalKind::BreakKeyword))?), + Some(self.select(|node| node.is_terminal_with_kind(TerminalKind::Semicolon))?), ]) } } impl Selector { - fn return_statement(&mut self) -> Result>>> { + fn return_statement(&mut self) -> Result>>> { Ok(vec![ - Some(self.select(|node| node.is_token_with_kind(TokenKind::ReturnKeyword))?), - self.try_select(|node| node.is_rule_with_kind(RuleKind::Expression))?, - Some(self.select(|node| node.is_token_with_kind(TokenKind::Semicolon))?), + Some(self.select(|node| node.is_terminal_with_kind(TerminalKind::ReturnKeyword))?), + self.try_select(|node| node.is_nonterminal_with_kind(NonTerminalKind::Expression))?, + Some(self.select(|node| node.is_terminal_with_kind(TerminalKind::Semicolon))?), ]) } } impl Selector { - fn emit_statement(&mut self) -> Result>>> { + fn emit_statement(&mut self) -> Result>>> { Ok(vec![ - Some(self.select(|node| node.is_token_with_kind(TokenKind::EmitKeyword))?), - Some(self.select(|node| node.is_rule_with_kind(RuleKind::IdentifierPath))?), - Some(self.select(|node| node.is_rule_with_kind(RuleKind::ArgumentsDeclaration))?), - Some(self.select(|node| node.is_token_with_kind(TokenKind::Semicolon))?), + Some(self.select(|node| node.is_terminal_with_kind(TerminalKind::EmitKeyword))?), + Some( + self.select(|node| node.is_nonterminal_with_kind(NonTerminalKind::IdentifierPath))?, + ), + Some(self.select(|node| { + node.is_nonterminal_with_kind(NonTerminalKind::ArgumentsDeclaration) + })?), + Some(self.select(|node| node.is_terminal_with_kind(TerminalKind::Semicolon))?), ]) } } impl Selector { - fn try_statement(&mut self) -> Result>>> { + fn try_statement(&mut self) -> Result>>> { Ok(vec![ - Some(self.select(|node| node.is_token_with_kind(TokenKind::TryKeyword))?), - Some(self.select(|node| node.is_rule_with_kind(RuleKind::Expression))?), - self.try_select(|node| node.is_rule_with_kind(RuleKind::ReturnsDeclaration))?, - Some(self.select(|node| node.is_rule_with_kind(RuleKind::Block))?), - Some(self.select(|node| node.is_rule_with_kind(RuleKind::CatchClauses))?), + Some(self.select(|node| node.is_terminal_with_kind(TerminalKind::TryKeyword))?), + Some(self.select(|node| node.is_nonterminal_with_kind(NonTerminalKind::Expression))?), + self.try_select(|node| { + node.is_nonterminal_with_kind(NonTerminalKind::ReturnsDeclaration) + })?, + Some(self.select(|node| node.is_nonterminal_with_kind(NonTerminalKind::Block))?), + Some(self.select(|node| node.is_nonterminal_with_kind(NonTerminalKind::CatchClauses))?), ]) } } impl Selector { - fn catch_clause(&mut self) -> Result>>> { + fn catch_clause(&mut self) -> Result>>> { Ok(vec![ - Some(self.select(|node| node.is_token_with_kind(TokenKind::CatchKeyword))?), - self.try_select(|node| node.is_rule_with_kind(RuleKind::CatchClauseError))?, - Some(self.select(|node| node.is_rule_with_kind(RuleKind::Block))?), + Some(self.select(|node| node.is_terminal_with_kind(TerminalKind::CatchKeyword))?), + self.try_select(|node| { + node.is_nonterminal_with_kind(NonTerminalKind::CatchClauseError) + })?, + Some(self.select(|node| node.is_nonterminal_with_kind(NonTerminalKind::Block))?), ]) } } impl Selector { - fn catch_clause_error(&mut self) -> Result>>> { + fn catch_clause_error(&mut self) -> Result>>> { Ok(vec![ - self.try_select(|node| node.is_token_with_kind(TokenKind::Identifier))?, - Some(self.select(|node| node.is_rule_with_kind(RuleKind::ParametersDeclaration))?), + self.try_select(|node| node.is_terminal_with_kind(TerminalKind::Identifier))?, + Some(self.select(|node| { + node.is_nonterminal_with_kind(NonTerminalKind::ParametersDeclaration) + })?), ]) } } impl Selector { - fn revert_statement(&mut self) -> Result>>> { + fn revert_statement(&mut self) -> Result>>> { Ok(vec![ - Some(self.select(|node| node.is_token_with_kind(TokenKind::RevertKeyword))?), - self.try_select(|node| node.is_rule_with_kind(RuleKind::IdentifierPath))?, - Some(self.select(|node| node.is_rule_with_kind(RuleKind::ArgumentsDeclaration))?), - Some(self.select(|node| node.is_token_with_kind(TokenKind::Semicolon))?), + Some(self.select(|node| node.is_terminal_with_kind(TerminalKind::RevertKeyword))?), + self.try_select(|node| node.is_nonterminal_with_kind(NonTerminalKind::IdentifierPath))?, + Some(self.select(|node| { + node.is_nonterminal_with_kind(NonTerminalKind::ArgumentsDeclaration) + })?), + Some(self.select(|node| node.is_terminal_with_kind(TerminalKind::Semicolon))?), ]) } } impl Selector { - fn throw_statement(&mut self) -> Result>>> { + fn throw_statement(&mut self) -> Result>>> { Ok(vec![ - Some(self.select(|node| node.is_token_with_kind(TokenKind::ThrowKeyword))?), - Some(self.select(|node| node.is_token_with_kind(TokenKind::Semicolon))?), + Some(self.select(|node| node.is_terminal_with_kind(TerminalKind::ThrowKeyword))?), + Some(self.select(|node| node.is_terminal_with_kind(TerminalKind::Semicolon))?), ]) } } impl Selector { - fn assignment_expression(&mut self) -> Result>>> { + fn assignment_expression( + &mut self, + ) -> Result>>> { Ok(vec![ - Some(self.select(|node| node.is_rule_with_kind(RuleKind::Expression))?), - Some(self.select(|node| node.is_token_with_kind(TokenKind::Equal))?), - Some(self.select(|node| node.is_rule_with_kind(RuleKind::Expression))?), + Some(self.select(|node| node.is_nonterminal_with_kind(NonTerminalKind::Expression))?), + Some(self.select(|node| node.is_terminal_with_kind(TerminalKind::Equal))?), + Some(self.select(|node| node.is_nonterminal_with_kind(NonTerminalKind::Expression))?), ]) } } impl Selector { - fn conditional_expression(&mut self) -> Result>>> { + fn conditional_expression( + &mut self, + ) -> Result>>> { Ok(vec![ - Some(self.select(|node| node.is_rule_with_kind(RuleKind::Expression))?), - Some(self.select(|node| node.is_token_with_kind(TokenKind::QuestionMark))?), - Some(self.select(|node| node.is_rule_with_kind(RuleKind::Expression))?), - Some(self.select(|node| node.is_token_with_kind(TokenKind::Colon))?), - Some(self.select(|node| node.is_rule_with_kind(RuleKind::Expression))?), + Some(self.select(|node| node.is_nonterminal_with_kind(NonTerminalKind::Expression))?), + Some(self.select(|node| node.is_terminal_with_kind(TerminalKind::QuestionMark))?), + Some(self.select(|node| node.is_nonterminal_with_kind(NonTerminalKind::Expression))?), + Some(self.select(|node| node.is_terminal_with_kind(TerminalKind::Colon))?), + Some(self.select(|node| node.is_nonterminal_with_kind(NonTerminalKind::Expression))?), ]) } } impl Selector { - fn or_expression(&mut self) -> Result>>> { + fn or_expression(&mut self) -> Result>>> { Ok(vec![ - Some(self.select(|node| node.is_rule_with_kind(RuleKind::Expression))?), - Some(self.select(|node| node.is_token_with_kind(TokenKind::BarBar))?), - Some(self.select(|node| node.is_rule_with_kind(RuleKind::Expression))?), + Some(self.select(|node| node.is_nonterminal_with_kind(NonTerminalKind::Expression))?), + Some(self.select(|node| node.is_terminal_with_kind(TerminalKind::BarBar))?), + Some(self.select(|node| node.is_nonterminal_with_kind(NonTerminalKind::Expression))?), ]) } } impl Selector { - fn and_expression(&mut self) -> Result>>> { + fn and_expression(&mut self) -> Result>>> { Ok(vec![ - Some(self.select(|node| node.is_rule_with_kind(RuleKind::Expression))?), - Some(self.select(|node| node.is_token_with_kind(TokenKind::AmpersandAmpersand))?), - Some(self.select(|node| node.is_rule_with_kind(RuleKind::Expression))?), + Some(self.select(|node| node.is_nonterminal_with_kind(NonTerminalKind::Expression))?), + Some(self.select(|node| node.is_terminal_with_kind(TerminalKind::AmpersandAmpersand))?), + Some(self.select(|node| node.is_nonterminal_with_kind(NonTerminalKind::Expression))?), ]) } } impl Selector { - fn equality_expression(&mut self) -> Result>>> { + fn equality_expression( + &mut self, + ) -> Result>>> { Ok(vec![ - Some(self.select(|node| node.is_rule_with_kind(RuleKind::Expression))?), - Some(self.select(|node| node.is_token_with_kind(TokenKind::EqualEqual))?), - Some(self.select(|node| node.is_rule_with_kind(RuleKind::Expression))?), + Some(self.select(|node| node.is_nonterminal_with_kind(NonTerminalKind::Expression))?), + Some(self.select(|node| node.is_terminal_with_kind(TerminalKind::EqualEqual))?), + Some(self.select(|node| node.is_nonterminal_with_kind(NonTerminalKind::Expression))?), ]) } } impl Selector { - fn comparison_expression(&mut self) -> Result>>> { + fn comparison_expression( + &mut self, + ) -> Result>>> { Ok(vec![ - Some(self.select(|node| node.is_rule_with_kind(RuleKind::Expression))?), - Some(self.select(|node| node.is_token_with_kind(TokenKind::LessThan))?), - Some(self.select(|node| node.is_rule_with_kind(RuleKind::Expression))?), + Some(self.select(|node| node.is_nonterminal_with_kind(NonTerminalKind::Expression))?), + Some(self.select(|node| node.is_terminal_with_kind(TerminalKind::LessThan))?), + Some(self.select(|node| node.is_nonterminal_with_kind(NonTerminalKind::Expression))?), ]) } } impl Selector { - fn bitwise_or_expression(&mut self) -> Result>>> { + fn bitwise_or_expression( + &mut self, + ) -> Result>>> { Ok(vec![ - Some(self.select(|node| node.is_rule_with_kind(RuleKind::Expression))?), - Some(self.select(|node| node.is_token_with_kind(TokenKind::Bar))?), - Some(self.select(|node| node.is_rule_with_kind(RuleKind::Expression))?), + Some(self.select(|node| node.is_nonterminal_with_kind(NonTerminalKind::Expression))?), + Some(self.select(|node| node.is_terminal_with_kind(TerminalKind::Bar))?), + Some(self.select(|node| node.is_nonterminal_with_kind(NonTerminalKind::Expression))?), ]) } } impl Selector { - fn bitwise_xor_expression(&mut self) -> Result>>> { + fn bitwise_xor_expression( + &mut self, + ) -> Result>>> { Ok(vec![ - Some(self.select(|node| node.is_rule_with_kind(RuleKind::Expression))?), - Some(self.select(|node| node.is_token_with_kind(TokenKind::Caret))?), - Some(self.select(|node| node.is_rule_with_kind(RuleKind::Expression))?), + Some(self.select(|node| node.is_nonterminal_with_kind(NonTerminalKind::Expression))?), + Some(self.select(|node| node.is_terminal_with_kind(TerminalKind::Caret))?), + Some(self.select(|node| node.is_nonterminal_with_kind(NonTerminalKind::Expression))?), ]) } } impl Selector { - fn bitwise_and_expression(&mut self) -> Result>>> { + fn bitwise_and_expression( + &mut self, + ) -> Result>>> { Ok(vec![ - Some(self.select(|node| node.is_rule_with_kind(RuleKind::Expression))?), - Some(self.select(|node| node.is_token_with_kind(TokenKind::Ampersand))?), - Some(self.select(|node| node.is_rule_with_kind(RuleKind::Expression))?), + Some(self.select(|node| node.is_nonterminal_with_kind(NonTerminalKind::Expression))?), + Some(self.select(|node| node.is_terminal_with_kind(TerminalKind::Ampersand))?), + Some(self.select(|node| node.is_nonterminal_with_kind(NonTerminalKind::Expression))?), ]) } } impl Selector { - fn shift_expression(&mut self) -> Result>>> { + fn shift_expression(&mut self) -> Result>>> { Ok(vec![ - Some(self.select(|node| node.is_rule_with_kind(RuleKind::Expression))?), - Some(self.select(|node| node.is_token_with_kind(TokenKind::LessThanLessThan))?), - Some(self.select(|node| node.is_rule_with_kind(RuleKind::Expression))?), + Some(self.select(|node| node.is_nonterminal_with_kind(NonTerminalKind::Expression))?), + Some(self.select(|node| node.is_terminal_with_kind(TerminalKind::LessThanLessThan))?), + Some(self.select(|node| node.is_nonterminal_with_kind(NonTerminalKind::Expression))?), ]) } } impl Selector { - fn additive_expression(&mut self) -> Result>>> { + fn additive_expression( + &mut self, + ) -> Result>>> { Ok(vec![ - Some(self.select(|node| node.is_rule_with_kind(RuleKind::Expression))?), - Some(self.select(|node| node.is_token_with_kind(TokenKind::Plus))?), - Some(self.select(|node| node.is_rule_with_kind(RuleKind::Expression))?), + Some(self.select(|node| node.is_nonterminal_with_kind(NonTerminalKind::Expression))?), + Some(self.select(|node| node.is_terminal_with_kind(TerminalKind::Plus))?), + Some(self.select(|node| node.is_nonterminal_with_kind(NonTerminalKind::Expression))?), ]) } } impl Selector { - fn multiplicative_expression(&mut self) -> Result>>> { + fn multiplicative_expression( + &mut self, + ) -> Result>>> { Ok(vec![ - Some(self.select(|node| node.is_rule_with_kind(RuleKind::Expression))?), - Some(self.select(|node| node.is_token_with_kind(TokenKind::Asterisk))?), - Some(self.select(|node| node.is_rule_with_kind(RuleKind::Expression))?), + Some(self.select(|node| node.is_nonterminal_with_kind(NonTerminalKind::Expression))?), + Some(self.select(|node| node.is_terminal_with_kind(TerminalKind::Asterisk))?), + Some(self.select(|node| node.is_nonterminal_with_kind(NonTerminalKind::Expression))?), ]) } } impl Selector { - fn exponentiation_expression(&mut self) -> Result>>> { + fn exponentiation_expression( + &mut self, + ) -> Result>>> { Ok(vec![ - Some(self.select(|node| node.is_rule_with_kind(RuleKind::Expression))?), - Some(self.select(|node| node.is_token_with_kind(TokenKind::AsteriskAsterisk))?), - Some(self.select(|node| node.is_rule_with_kind(RuleKind::Expression))?), + Some(self.select(|node| node.is_nonterminal_with_kind(NonTerminalKind::Expression))?), + Some(self.select(|node| node.is_terminal_with_kind(TerminalKind::AsteriskAsterisk))?), + Some(self.select(|node| node.is_nonterminal_with_kind(NonTerminalKind::Expression))?), ]) } } impl Selector { - fn postfix_expression(&mut self) -> Result>>> { + fn postfix_expression(&mut self) -> Result>>> { Ok(vec![ - Some(self.select(|node| node.is_rule_with_kind(RuleKind::Expression))?), - Some(self.select(|node| node.is_token_with_kind(TokenKind::PlusPlus))?), + Some(self.select(|node| node.is_nonterminal_with_kind(NonTerminalKind::Expression))?), + Some(self.select(|node| node.is_terminal_with_kind(TerminalKind::PlusPlus))?), ]) } } impl Selector { - fn prefix_expression(&mut self) -> Result>>> { + fn prefix_expression(&mut self) -> Result>>> { Ok(vec![ - Some(self.select(|node| node.is_token_with_kind(TokenKind::PlusPlus))?), - Some(self.select(|node| node.is_rule_with_kind(RuleKind::Expression))?), + Some(self.select(|node| node.is_terminal_with_kind(TerminalKind::PlusPlus))?), + Some(self.select(|node| node.is_nonterminal_with_kind(NonTerminalKind::Expression))?), ]) } } impl Selector { - fn function_call_expression(&mut self) -> Result>>> { + fn function_call_expression( + &mut self, + ) -> Result>>> { Ok(vec![ - Some(self.select(|node| node.is_rule_with_kind(RuleKind::Expression))?), - Some(self.select(|node| node.is_rule_with_kind(RuleKind::ArgumentsDeclaration))?), + Some(self.select(|node| node.is_nonterminal_with_kind(NonTerminalKind::Expression))?), + Some(self.select(|node| { + node.is_nonterminal_with_kind(NonTerminalKind::ArgumentsDeclaration) + })?), ]) } } impl Selector { - fn call_options_expression(&mut self) -> Result>>> { + fn call_options_expression( + &mut self, + ) -> Result>>> { Ok(vec![ - Some(self.select(|node| node.is_rule_with_kind(RuleKind::Expression))?), - Some(self.select(|node| node.is_token_with_kind(TokenKind::OpenBrace))?), - Some(self.select(|node| node.is_rule_with_kind(RuleKind::CallOptions))?), - Some(self.select(|node| node.is_token_with_kind(TokenKind::CloseBrace))?), + Some(self.select(|node| node.is_nonterminal_with_kind(NonTerminalKind::Expression))?), + Some(self.select(|node| node.is_terminal_with_kind(TerminalKind::OpenBrace))?), + Some(self.select(|node| node.is_nonterminal_with_kind(NonTerminalKind::CallOptions))?), + Some(self.select(|node| node.is_terminal_with_kind(TerminalKind::CloseBrace))?), ]) } } impl Selector { - fn member_access_expression(&mut self) -> Result>>> { + fn member_access_expression( + &mut self, + ) -> Result>>> { Ok(vec![ - Some(self.select(|node| node.is_rule_with_kind(RuleKind::Expression))?), - Some(self.select(|node| node.is_token_with_kind(TokenKind::Period))?), - Some(self.select(|node| node.is_rule_with_kind(RuleKind::MemberAccess))?), + Some(self.select(|node| node.is_nonterminal_with_kind(NonTerminalKind::Expression))?), + Some(self.select(|node| node.is_terminal_with_kind(TerminalKind::Period))?), + Some(self.select(|node| node.is_nonterminal_with_kind(NonTerminalKind::MemberAccess))?), ]) } } impl Selector { - fn index_access_expression(&mut self) -> Result>>> { + fn index_access_expression( + &mut self, + ) -> Result>>> { Ok(vec![ - Some(self.select(|node| node.is_rule_with_kind(RuleKind::Expression))?), - Some(self.select(|node| node.is_token_with_kind(TokenKind::OpenBracket))?), - self.try_select(|node| node.is_rule_with_kind(RuleKind::Expression))?, - self.try_select(|node| node.is_rule_with_kind(RuleKind::IndexAccessEnd))?, - Some(self.select(|node| node.is_token_with_kind(TokenKind::CloseBracket))?), + Some(self.select(|node| node.is_nonterminal_with_kind(NonTerminalKind::Expression))?), + Some(self.select(|node| node.is_terminal_with_kind(TerminalKind::OpenBracket))?), + self.try_select(|node| node.is_nonterminal_with_kind(NonTerminalKind::Expression))?, + self.try_select(|node| node.is_nonterminal_with_kind(NonTerminalKind::IndexAccessEnd))?, + Some(self.select(|node| node.is_terminal_with_kind(TerminalKind::CloseBracket))?), ]) } } impl Selector { - fn index_access_end(&mut self) -> Result>>> { + fn index_access_end(&mut self) -> Result>>> { Ok(vec![ - Some(self.select(|node| node.is_token_with_kind(TokenKind::Colon))?), - self.try_select(|node| node.is_rule_with_kind(RuleKind::Expression))?, + Some(self.select(|node| node.is_terminal_with_kind(TerminalKind::Colon))?), + self.try_select(|node| node.is_nonterminal_with_kind(NonTerminalKind::Expression))?, ]) } } @@ -1196,148 +1436,178 @@ impl Selector { impl Selector { fn positional_arguments_declaration( &mut self, - ) -> Result>>> { + ) -> Result>>> { Ok(vec![ - Some(self.select(|node| node.is_token_with_kind(TokenKind::OpenParen))?), - Some(self.select(|node| node.is_rule_with_kind(RuleKind::PositionalArguments))?), - Some(self.select(|node| node.is_token_with_kind(TokenKind::CloseParen))?), + Some(self.select(|node| node.is_terminal_with_kind(TerminalKind::OpenParen))?), + Some(self.select(|node| { + node.is_nonterminal_with_kind(NonTerminalKind::PositionalArguments) + })?), + Some(self.select(|node| node.is_terminal_with_kind(TerminalKind::CloseParen))?), ]) } } impl Selector { - fn named_arguments_declaration(&mut self) -> Result>>> { + fn named_arguments_declaration( + &mut self, + ) -> Result>>> { Ok(vec![ - Some(self.select(|node| node.is_token_with_kind(TokenKind::OpenParen))?), - self.try_select(|node| node.is_rule_with_kind(RuleKind::NamedArgumentGroup))?, - Some(self.select(|node| node.is_token_with_kind(TokenKind::CloseParen))?), + Some(self.select(|node| node.is_terminal_with_kind(TerminalKind::OpenParen))?), + self.try_select(|node| { + node.is_nonterminal_with_kind(NonTerminalKind::NamedArgumentGroup) + })?, + Some(self.select(|node| node.is_terminal_with_kind(TerminalKind::CloseParen))?), ]) } } impl Selector { - fn named_argument_group(&mut self) -> Result>>> { + fn named_argument_group( + &mut self, + ) -> Result>>> { Ok(vec![ - Some(self.select(|node| node.is_token_with_kind(TokenKind::OpenBrace))?), - Some(self.select(|node| node.is_rule_with_kind(RuleKind::NamedArguments))?), - Some(self.select(|node| node.is_token_with_kind(TokenKind::CloseBrace))?), + Some(self.select(|node| node.is_terminal_with_kind(TerminalKind::OpenBrace))?), + Some( + self.select(|node| node.is_nonterminal_with_kind(NonTerminalKind::NamedArguments))?, + ), + Some(self.select(|node| node.is_terminal_with_kind(TerminalKind::CloseBrace))?), ]) } } impl Selector { - fn named_argument(&mut self) -> Result>>> { + fn named_argument(&mut self) -> Result>>> { Ok(vec![ - Some(self.select(|node| node.is_token_with_kind(TokenKind::Identifier))?), - Some(self.select(|node| node.is_token_with_kind(TokenKind::Colon))?), - Some(self.select(|node| node.is_rule_with_kind(RuleKind::Expression))?), + Some(self.select(|node| node.is_terminal_with_kind(TerminalKind::Identifier))?), + Some(self.select(|node| node.is_terminal_with_kind(TerminalKind::Colon))?), + Some(self.select(|node| node.is_nonterminal_with_kind(NonTerminalKind::Expression))?), ]) } } impl Selector { - fn type_expression(&mut self) -> Result>>> { + fn type_expression(&mut self) -> Result>>> { Ok(vec![ - Some(self.select(|node| node.is_token_with_kind(TokenKind::TypeKeyword))?), - Some(self.select(|node| node.is_token_with_kind(TokenKind::OpenParen))?), - Some(self.select(|node| node.is_rule_with_kind(RuleKind::TypeName))?), - Some(self.select(|node| node.is_token_with_kind(TokenKind::CloseParen))?), + Some(self.select(|node| node.is_terminal_with_kind(TerminalKind::TypeKeyword))?), + Some(self.select(|node| node.is_terminal_with_kind(TerminalKind::OpenParen))?), + Some(self.select(|node| node.is_nonterminal_with_kind(NonTerminalKind::TypeName))?), + Some(self.select(|node| node.is_terminal_with_kind(TerminalKind::CloseParen))?), ]) } } impl Selector { - fn new_expression(&mut self) -> Result>>> { + fn new_expression(&mut self) -> Result>>> { Ok(vec![ - Some(self.select(|node| node.is_token_with_kind(TokenKind::NewKeyword))?), - Some(self.select(|node| node.is_rule_with_kind(RuleKind::TypeName))?), + Some(self.select(|node| node.is_terminal_with_kind(TerminalKind::NewKeyword))?), + Some(self.select(|node| node.is_nonterminal_with_kind(NonTerminalKind::TypeName))?), ]) } } impl Selector { - fn tuple_expression(&mut self) -> Result>>> { + fn tuple_expression(&mut self) -> Result>>> { Ok(vec![ - Some(self.select(|node| node.is_token_with_kind(TokenKind::OpenParen))?), - Some(self.select(|node| node.is_rule_with_kind(RuleKind::TupleValues))?), - Some(self.select(|node| node.is_token_with_kind(TokenKind::CloseParen))?), + Some(self.select(|node| node.is_terminal_with_kind(TerminalKind::OpenParen))?), + Some(self.select(|node| node.is_nonterminal_with_kind(NonTerminalKind::TupleValues))?), + Some(self.select(|node| node.is_terminal_with_kind(TerminalKind::CloseParen))?), ]) } } impl Selector { - fn tuple_value(&mut self) -> Result>>> { + fn tuple_value(&mut self) -> Result>>> { Ok(vec![self.try_select(|node| { - node.is_rule_with_kind(RuleKind::Expression) + node.is_nonterminal_with_kind(NonTerminalKind::Expression) })?]) } } impl Selector { - fn array_expression(&mut self) -> Result>>> { + fn array_expression(&mut self) -> Result>>> { Ok(vec![ - Some(self.select(|node| node.is_token_with_kind(TokenKind::OpenBracket))?), - Some(self.select(|node| node.is_rule_with_kind(RuleKind::ArrayValues))?), - Some(self.select(|node| node.is_token_with_kind(TokenKind::CloseBracket))?), + Some(self.select(|node| node.is_terminal_with_kind(TerminalKind::OpenBracket))?), + Some(self.select(|node| node.is_nonterminal_with_kind(NonTerminalKind::ArrayValues))?), + Some(self.select(|node| node.is_terminal_with_kind(TerminalKind::CloseBracket))?), ]) } } impl Selector { - fn hex_number_expression(&mut self) -> Result>>> { + fn hex_number_expression( + &mut self, + ) -> Result>>> { Ok(vec![ - Some(self.select(|node| node.is_token_with_kind(TokenKind::HexLiteral))?), - self.try_select(|node| node.is_rule_with_kind(RuleKind::NumberUnit))?, + Some(self.select(|node| node.is_terminal_with_kind(TerminalKind::HexLiteral))?), + self.try_select(|node| node.is_nonterminal_with_kind(NonTerminalKind::NumberUnit))?, ]) } } impl Selector { - fn decimal_number_expression(&mut self) -> Result>>> { + fn decimal_number_expression( + &mut self, + ) -> Result>>> { Ok(vec![ - Some(self.select(|node| node.is_token_with_kind(TokenKind::DecimalLiteral))?), - self.try_select(|node| node.is_rule_with_kind(RuleKind::NumberUnit))?, + Some(self.select(|node| node.is_terminal_with_kind(TerminalKind::DecimalLiteral))?), + self.try_select(|node| node.is_nonterminal_with_kind(NonTerminalKind::NumberUnit))?, ]) } } impl Selector { - fn yul_block(&mut self) -> Result>>> { + fn yul_block(&mut self) -> Result>>> { Ok(vec![ - Some(self.select(|node| node.is_token_with_kind(TokenKind::OpenBrace))?), - Some(self.select(|node| node.is_rule_with_kind(RuleKind::YulStatements))?), - Some(self.select(|node| node.is_token_with_kind(TokenKind::CloseBrace))?), + Some(self.select(|node| node.is_terminal_with_kind(TerminalKind::OpenBrace))?), + Some( + self.select(|node| node.is_nonterminal_with_kind(NonTerminalKind::YulStatements))?, + ), + Some(self.select(|node| node.is_terminal_with_kind(TerminalKind::CloseBrace))?), ]) } } impl Selector { - fn yul_function_definition(&mut self) -> Result>>> { + fn yul_function_definition( + &mut self, + ) -> Result>>> { Ok(vec![ - Some(self.select(|node| node.is_token_with_kind(TokenKind::YulFunctionKeyword))?), - Some(self.select(|node| node.is_token_with_kind(TokenKind::YulIdentifier))?), - Some(self.select(|node| node.is_rule_with_kind(RuleKind::YulParametersDeclaration))?), - self.try_select(|node| node.is_rule_with_kind(RuleKind::YulReturnsDeclaration))?, - Some(self.select(|node| node.is_rule_with_kind(RuleKind::YulBlock))?), + Some(self.select(|node| node.is_terminal_with_kind(TerminalKind::YulFunctionKeyword))?), + Some(self.select(|node| node.is_terminal_with_kind(TerminalKind::YulIdentifier))?), + Some(self.select(|node| { + node.is_nonterminal_with_kind(NonTerminalKind::YulParametersDeclaration) + })?), + self.try_select(|node| { + node.is_nonterminal_with_kind(NonTerminalKind::YulReturnsDeclaration) + })?, + Some(self.select(|node| node.is_nonterminal_with_kind(NonTerminalKind::YulBlock))?), ]) } } impl Selector { - fn yul_parameters_declaration(&mut self) -> Result>>> { + fn yul_parameters_declaration( + &mut self, + ) -> Result>>> { Ok(vec![ - Some(self.select(|node| node.is_token_with_kind(TokenKind::OpenParen))?), - Some(self.select(|node| node.is_rule_with_kind(RuleKind::YulParameters))?), - Some(self.select(|node| node.is_token_with_kind(TokenKind::CloseParen))?), + Some(self.select(|node| node.is_terminal_with_kind(TerminalKind::OpenParen))?), + Some( + self.select(|node| node.is_nonterminal_with_kind(NonTerminalKind::YulParameters))?, + ), + Some(self.select(|node| node.is_terminal_with_kind(TerminalKind::CloseParen))?), ]) } } impl Selector { - fn yul_returns_declaration(&mut self) -> Result>>> { + fn yul_returns_declaration( + &mut self, + ) -> Result>>> { Ok(vec![ - Some(self.select(|node| node.is_token_with_kind(TokenKind::MinusGreaterThan))?), - Some(self.select(|node| node.is_rule_with_kind(RuleKind::YulReturnVariables))?), + Some(self.select(|node| node.is_terminal_with_kind(TerminalKind::MinusGreaterThan))?), + Some(self.select(|node| { + node.is_nonterminal_with_kind(NonTerminalKind::YulReturnVariables) + })?), ]) } } @@ -1345,11 +1615,13 @@ impl Selector { impl Selector { fn yul_variable_declaration_statement( &mut self, - ) -> Result>>> { + ) -> Result>>> { Ok(vec![ - Some(self.select(|node| node.is_token_with_kind(TokenKind::YulLetKeyword))?), - Some(self.select(|node| node.is_token_with_kind(TokenKind::YulIdentifier))?), - self.try_select(|node| node.is_rule_with_kind(RuleKind::YulVariableDeclarationValue))?, + Some(self.select(|node| node.is_terminal_with_kind(TerminalKind::YulLetKeyword))?), + Some(self.select(|node| node.is_terminal_with_kind(TerminalKind::YulIdentifier))?), + self.try_select(|node| { + node.is_nonterminal_with_kind(NonTerminalKind::YulVariableDeclarationValue) + })?, ]) } } @@ -1357,124 +1629,156 @@ impl Selector { impl Selector { fn yul_variable_declaration_value( &mut self, - ) -> Result>>> { + ) -> Result>>> { Ok(vec![ - Some(self.select(|node| node.is_rule_with_kind(RuleKind::YulAssignmentOperator))?), - Some(self.select(|node| node.is_rule_with_kind(RuleKind::YulExpression))?), + Some(self.select(|node| { + node.is_nonterminal_with_kind(NonTerminalKind::YulAssignmentOperator) + })?), + Some( + self.select(|node| node.is_nonterminal_with_kind(NonTerminalKind::YulExpression))?, + ), ]) } } impl Selector { - fn yul_assignment_statement(&mut self) -> Result>>> { + fn yul_assignment_statement( + &mut self, + ) -> Result>>> { Ok(vec![ - Some(self.select(|node| node.is_rule_with_kind(RuleKind::YulPaths))?), - Some(self.select(|node| node.is_rule_with_kind(RuleKind::YulAssignmentOperator))?), - Some(self.select(|node| node.is_rule_with_kind(RuleKind::YulExpression))?), + Some(self.select(|node| node.is_nonterminal_with_kind(NonTerminalKind::YulPaths))?), + Some(self.select(|node| { + node.is_nonterminal_with_kind(NonTerminalKind::YulAssignmentOperator) + })?), + Some( + self.select(|node| node.is_nonterminal_with_kind(NonTerminalKind::YulExpression))?, + ), ]) } } impl Selector { - fn yul_colon_and_equal(&mut self) -> Result>>> { + fn yul_colon_and_equal( + &mut self, + ) -> Result>>> { Ok(vec![ - Some(self.select(|node| node.is_token_with_kind(TokenKind::Colon))?), - Some(self.select(|node| node.is_token_with_kind(TokenKind::Equal))?), + Some(self.select(|node| node.is_terminal_with_kind(TerminalKind::Colon))?), + Some(self.select(|node| node.is_terminal_with_kind(TerminalKind::Equal))?), ]) } } impl Selector { - fn yul_if_statement(&mut self) -> Result>>> { + fn yul_if_statement(&mut self) -> Result>>> { Ok(vec![ - Some(self.select(|node| node.is_token_with_kind(TokenKind::YulIfKeyword))?), - Some(self.select(|node| node.is_rule_with_kind(RuleKind::YulExpression))?), - Some(self.select(|node| node.is_rule_with_kind(RuleKind::YulBlock))?), + Some(self.select(|node| node.is_terminal_with_kind(TerminalKind::YulIfKeyword))?), + Some( + self.select(|node| node.is_nonterminal_with_kind(NonTerminalKind::YulExpression))?, + ), + Some(self.select(|node| node.is_nonterminal_with_kind(NonTerminalKind::YulBlock))?), ]) } } impl Selector { - fn yul_for_statement(&mut self) -> Result>>> { + fn yul_for_statement(&mut self) -> Result>>> { Ok(vec![ - Some(self.select(|node| node.is_token_with_kind(TokenKind::YulForKeyword))?), - Some(self.select(|node| node.is_rule_with_kind(RuleKind::YulBlock))?), - Some(self.select(|node| node.is_rule_with_kind(RuleKind::YulExpression))?), - Some(self.select(|node| node.is_rule_with_kind(RuleKind::YulBlock))?), - Some(self.select(|node| node.is_rule_with_kind(RuleKind::YulBlock))?), + Some(self.select(|node| node.is_terminal_with_kind(TerminalKind::YulForKeyword))?), + Some(self.select(|node| node.is_nonterminal_with_kind(NonTerminalKind::YulBlock))?), + Some( + self.select(|node| node.is_nonterminal_with_kind(NonTerminalKind::YulExpression))?, + ), + Some(self.select(|node| node.is_nonterminal_with_kind(NonTerminalKind::YulBlock))?), + Some(self.select(|node| node.is_nonterminal_with_kind(NonTerminalKind::YulBlock))?), ]) } } impl Selector { - fn yul_switch_statement(&mut self) -> Result>>> { + fn yul_switch_statement( + &mut self, + ) -> Result>>> { Ok(vec![ - Some(self.select(|node| node.is_token_with_kind(TokenKind::YulSwitchKeyword))?), - Some(self.select(|node| node.is_rule_with_kind(RuleKind::YulExpression))?), - Some(self.select(|node| node.is_rule_with_kind(RuleKind::YulSwitchCases))?), + Some(self.select(|node| node.is_terminal_with_kind(TerminalKind::YulSwitchKeyword))?), + Some( + self.select(|node| node.is_nonterminal_with_kind(NonTerminalKind::YulExpression))?, + ), + Some( + self.select(|node| node.is_nonterminal_with_kind(NonTerminalKind::YulSwitchCases))?, + ), ]) } } impl Selector { - fn yul_default_case(&mut self) -> Result>>> { + fn yul_default_case(&mut self) -> Result>>> { Ok(vec![ - Some(self.select(|node| node.is_token_with_kind(TokenKind::YulDefaultKeyword))?), - Some(self.select(|node| node.is_rule_with_kind(RuleKind::YulBlock))?), + Some(self.select(|node| node.is_terminal_with_kind(TerminalKind::YulDefaultKeyword))?), + Some(self.select(|node| node.is_nonterminal_with_kind(NonTerminalKind::YulBlock))?), ]) } } impl Selector { - fn yul_value_case(&mut self) -> Result>>> { + fn yul_value_case(&mut self) -> Result>>> { Ok(vec![ - Some(self.select(|node| node.is_token_with_kind(TokenKind::YulCaseKeyword))?), - Some(self.select(|node| node.is_rule_with_kind(RuleKind::YulLiteral))?), - Some(self.select(|node| node.is_rule_with_kind(RuleKind::YulBlock))?), + Some(self.select(|node| node.is_terminal_with_kind(TerminalKind::YulCaseKeyword))?), + Some(self.select(|node| node.is_nonterminal_with_kind(NonTerminalKind::YulLiteral))?), + Some(self.select(|node| node.is_nonterminal_with_kind(NonTerminalKind::YulBlock))?), ]) } } impl Selector { - fn yul_leave_statement(&mut self) -> Result>>> { + fn yul_leave_statement( + &mut self, + ) -> Result>>> { Ok(vec![Some(self.select(|node| { - node.is_token_with_kind(TokenKind::YulLeaveKeyword) + node.is_terminal_with_kind(TerminalKind::YulLeaveKeyword) })?)]) } } impl Selector { - fn yul_break_statement(&mut self) -> Result>>> { + fn yul_break_statement( + &mut self, + ) -> Result>>> { Ok(vec![Some(self.select(|node| { - node.is_token_with_kind(TokenKind::YulBreakKeyword) + node.is_terminal_with_kind(TerminalKind::YulBreakKeyword) })?)]) } } impl Selector { - fn yul_continue_statement(&mut self) -> Result>>> { + fn yul_continue_statement( + &mut self, + ) -> Result>>> { Ok(vec![Some(self.select(|node| { - node.is_token_with_kind(TokenKind::YulContinueKeyword) + node.is_terminal_with_kind(TerminalKind::YulContinueKeyword) })?)]) } } impl Selector { - fn yul_label(&mut self) -> Result>>> { + fn yul_label(&mut self) -> Result>>> { Ok(vec![ - Some(self.select(|node| node.is_token_with_kind(TokenKind::YulIdentifier))?), - Some(self.select(|node| node.is_token_with_kind(TokenKind::Colon))?), + Some(self.select(|node| node.is_terminal_with_kind(TerminalKind::YulIdentifier))?), + Some(self.select(|node| node.is_terminal_with_kind(TerminalKind::Colon))?), ]) } } impl Selector { - fn yul_function_call_expression(&mut self) -> Result>>> { + fn yul_function_call_expression( + &mut self, + ) -> Result>>> { Ok(vec![ - Some(self.select(|node| node.is_rule_with_kind(RuleKind::YulExpression))?), - Some(self.select(|node| node.is_token_with_kind(TokenKind::OpenParen))?), - Some(self.select(|node| node.is_rule_with_kind(RuleKind::YulArguments))?), - Some(self.select(|node| node.is_token_with_kind(TokenKind::CloseParen))?), + Some( + self.select(|node| node.is_nonterminal_with_kind(NonTerminalKind::YulExpression))?, + ), + Some(self.select(|node| node.is_terminal_with_kind(TerminalKind::OpenParen))?), + Some(self.select(|node| node.is_nonterminal_with_kind(NonTerminalKind::YulArguments))?), + Some(self.select(|node| node.is_terminal_with_kind(TerminalKind::CloseParen))?), ]) } } @@ -1484,54 +1788,54 @@ impl Selector { #[napi(namespace = "ast_internal", ts_return_type = "cst.Node", catch_unwind)] pub fn select_choice( - #[napi(ts_arg_type = "cst.RuleNode")] node: &RuleNode, -) -> Result> { + #[napi(ts_arg_type = "cst.NonTerminalNode")] node: &NonTerminalNode, +) -> Result> { let mut selector = Selector::new(node); let result = match node.kind() { - RuleKind::SourceUnitMember => selector.source_unit_member()?, - RuleKind::Pragma => selector.pragma()?, - RuleKind::ExperimentalFeature => selector.experimental_feature()?, - RuleKind::VersionExpression => selector.version_expression()?, - RuleKind::ImportClause => selector.import_clause()?, - RuleKind::UsingClause => selector.using_clause()?, - RuleKind::UsingOperator => selector.using_operator()?, - RuleKind::UsingTarget => selector.using_target()?, - RuleKind::ContractMember => selector.contract_member()?, - RuleKind::StateVariableAttribute => selector.state_variable_attribute()?, - RuleKind::FunctionName => selector.function_name()?, - RuleKind::FunctionAttribute => selector.function_attribute()?, - RuleKind::FunctionBody => selector.function_body()?, - RuleKind::ConstructorAttribute => selector.constructor_attribute()?, - RuleKind::UnnamedFunctionAttribute => selector.unnamed_function_attribute()?, - RuleKind::FallbackFunctionAttribute => selector.fallback_function_attribute()?, - RuleKind::ReceiveFunctionAttribute => selector.receive_function_attribute()?, - RuleKind::ModifierAttribute => selector.modifier_attribute()?, - RuleKind::TypeName => selector.type_name()?, - RuleKind::FunctionTypeAttribute => selector.function_type_attribute()?, - RuleKind::MappingKeyType => selector.mapping_key_type()?, - RuleKind::ElementaryType => selector.elementary_type()?, - RuleKind::Statement => selector.statement()?, - RuleKind::TupleMember => selector.tuple_member()?, - RuleKind::VariableDeclarationType => selector.variable_declaration_type()?, - RuleKind::StorageLocation => selector.storage_location()?, - RuleKind::ForStatementInitialization => selector.for_statement_initialization()?, - RuleKind::ForStatementCondition => selector.for_statement_condition()?, - RuleKind::Expression => selector.expression()?, - RuleKind::MemberAccess => selector.member_access()?, - RuleKind::ArgumentsDeclaration => selector.arguments_declaration()?, - RuleKind::NumberUnit => selector.number_unit()?, - RuleKind::StringExpression => selector.string_expression()?, - RuleKind::StringLiteral => selector.string_literal()?, - RuleKind::HexStringLiteral => selector.hex_string_literal()?, - RuleKind::UnicodeStringLiteral => selector.unicode_string_literal()?, - RuleKind::YulStatement => selector.yul_statement()?, - RuleKind::YulAssignmentOperator => selector.yul_assignment_operator()?, - RuleKind::YulSwitchCase => selector.yul_switch_case()?, - RuleKind::YulExpression => selector.yul_expression()?, - RuleKind::YulPathComponent => selector.yul_path_component()?, - RuleKind::YulBuiltInFunction => selector.yul_built_in_function()?, - RuleKind::YulLiteral => selector.yul_literal()?, + NonTerminalKind::SourceUnitMember => selector.source_unit_member()?, + NonTerminalKind::Pragma => selector.pragma()?, + NonTerminalKind::ExperimentalFeature => selector.experimental_feature()?, + NonTerminalKind::VersionExpression => selector.version_expression()?, + NonTerminalKind::ImportClause => selector.import_clause()?, + NonTerminalKind::UsingClause => selector.using_clause()?, + NonTerminalKind::UsingOperator => selector.using_operator()?, + NonTerminalKind::UsingTarget => selector.using_target()?, + NonTerminalKind::ContractMember => selector.contract_member()?, + NonTerminalKind::StateVariableAttribute => selector.state_variable_attribute()?, + NonTerminalKind::FunctionName => selector.function_name()?, + NonTerminalKind::FunctionAttribute => selector.function_attribute()?, + NonTerminalKind::FunctionBody => selector.function_body()?, + NonTerminalKind::ConstructorAttribute => selector.constructor_attribute()?, + NonTerminalKind::UnnamedFunctionAttribute => selector.unnamed_function_attribute()?, + NonTerminalKind::FallbackFunctionAttribute => selector.fallback_function_attribute()?, + NonTerminalKind::ReceiveFunctionAttribute => selector.receive_function_attribute()?, + NonTerminalKind::ModifierAttribute => selector.modifier_attribute()?, + NonTerminalKind::TypeName => selector.type_name()?, + NonTerminalKind::FunctionTypeAttribute => selector.function_type_attribute()?, + NonTerminalKind::MappingKeyType => selector.mapping_key_type()?, + NonTerminalKind::ElementaryType => selector.elementary_type()?, + NonTerminalKind::Statement => selector.statement()?, + NonTerminalKind::TupleMember => selector.tuple_member()?, + NonTerminalKind::VariableDeclarationType => selector.variable_declaration_type()?, + NonTerminalKind::StorageLocation => selector.storage_location()?, + NonTerminalKind::ForStatementInitialization => selector.for_statement_initialization()?, + NonTerminalKind::ForStatementCondition => selector.for_statement_condition()?, + NonTerminalKind::Expression => selector.expression()?, + NonTerminalKind::MemberAccess => selector.member_access()?, + NonTerminalKind::ArgumentsDeclaration => selector.arguments_declaration()?, + NonTerminalKind::NumberUnit => selector.number_unit()?, + NonTerminalKind::StringExpression => selector.string_expression()?, + NonTerminalKind::StringLiteral => selector.string_literal()?, + NonTerminalKind::HexStringLiteral => selector.hex_string_literal()?, + NonTerminalKind::UnicodeStringLiteral => selector.unicode_string_literal()?, + NonTerminalKind::YulStatement => selector.yul_statement()?, + NonTerminalKind::YulAssignmentOperator => selector.yul_assignment_operator()?, + NonTerminalKind::YulSwitchCase => selector.yul_switch_case()?, + NonTerminalKind::YulExpression => selector.yul_expression()?, + NonTerminalKind::YulPathComponent => selector.yul_path_component()?, + NonTerminalKind::YulBuiltInFunction => selector.yul_built_in_function()?, + NonTerminalKind::YulLiteral => selector.yul_literal()?, _ => { return Error::UnexpectedParent(node.kind()).into(); } @@ -1542,681 +1846,705 @@ pub fn select_choice( } impl Selector { - fn source_unit_member(&mut self) -> Result> { + fn source_unit_member(&mut self) -> Result> { self.select(|node| { - node.is_rule_with_kinds(&[ - RuleKind::PragmaDirective, - RuleKind::ImportDirective, - RuleKind::ContractDefinition, - RuleKind::InterfaceDefinition, - RuleKind::LibraryDefinition, - RuleKind::StructDefinition, - RuleKind::EnumDefinition, - RuleKind::FunctionDefinition, - RuleKind::ConstantDefinition, - RuleKind::ErrorDefinition, - RuleKind::UserDefinedValueTypeDefinition, - RuleKind::UsingDirective, - RuleKind::EventDefinition, + node.is_nonterminal_with_kinds(&[ + NonTerminalKind::PragmaDirective, + NonTerminalKind::ImportDirective, + NonTerminalKind::ContractDefinition, + NonTerminalKind::InterfaceDefinition, + NonTerminalKind::LibraryDefinition, + NonTerminalKind::StructDefinition, + NonTerminalKind::EnumDefinition, + NonTerminalKind::FunctionDefinition, + NonTerminalKind::ConstantDefinition, + NonTerminalKind::ErrorDefinition, + NonTerminalKind::UserDefinedValueTypeDefinition, + NonTerminalKind::UsingDirective, + NonTerminalKind::EventDefinition, ]) }) } } impl Selector { - fn pragma(&mut self) -> Result> { + fn pragma(&mut self) -> Result> { self.select(|node| { - node.is_rule_with_kinds(&[ - RuleKind::ABICoderPragma, - RuleKind::ExperimentalPragma, - RuleKind::VersionPragma, + node.is_nonterminal_with_kinds(&[ + NonTerminalKind::ABICoderPragma, + NonTerminalKind::ExperimentalPragma, + NonTerminalKind::VersionPragma, ]) }) } } impl Selector { - fn experimental_feature(&mut self) -> Result> { + fn experimental_feature(&mut self) -> Result> { self.select(|node| { - node.is_rule_with_kind(RuleKind::StringLiteral) - || node.is_token_with_kind(TokenKind::Identifier) + node.is_nonterminal_with_kind(NonTerminalKind::StringLiteral) + || node.is_terminal_with_kind(TerminalKind::Identifier) }) } } impl Selector { - fn version_expression(&mut self) -> Result> { + fn version_expression(&mut self) -> Result> { self.select(|node| { - node.is_rule_with_kinds(&[ - RuleKind::VersionRange, - RuleKind::VersionComparator, - RuleKind::VersionSpecifiers, - ]) || node.is_token_with_kinds(&[ - TokenKind::SingleQuotedVersionLiteral, - TokenKind::DoubleQuotedVersionLiteral, + node.is_nonterminal_with_kinds(&[ + NonTerminalKind::VersionRange, + NonTerminalKind::VersionComparator, + NonTerminalKind::VersionSpecifiers, + ]) || node.is_terminal_with_kinds(&[ + TerminalKind::SingleQuotedVersionLiteral, + TerminalKind::DoubleQuotedVersionLiteral, ]) }) } } impl Selector { - fn import_clause(&mut self) -> Result> { + fn import_clause(&mut self) -> Result> { self.select(|node| { - node.is_rule_with_kinds(&[ - RuleKind::PathImport, - RuleKind::NamedImport, - RuleKind::ImportDeconstruction, + node.is_nonterminal_with_kinds(&[ + NonTerminalKind::PathImport, + NonTerminalKind::NamedImport, + NonTerminalKind::ImportDeconstruction, ]) }) } } impl Selector { - fn using_clause(&mut self) -> Result> { + fn using_clause(&mut self) -> Result> { self.select(|node| { - node.is_rule_with_kinds(&[RuleKind::IdentifierPath, RuleKind::UsingDeconstruction]) + node.is_nonterminal_with_kinds(&[ + NonTerminalKind::IdentifierPath, + NonTerminalKind::UsingDeconstruction, + ]) }) } } impl Selector { - fn using_operator(&mut self) -> Result> { + fn using_operator(&mut self) -> Result> { self.select(|node| { - node.is_token_with_kinds(&[ - TokenKind::Ampersand, - TokenKind::Asterisk, - TokenKind::BangEqual, - TokenKind::Bar, - TokenKind::Caret, - TokenKind::EqualEqual, - TokenKind::GreaterThan, - TokenKind::GreaterThanEqual, - TokenKind::LessThan, - TokenKind::LessThanEqual, - TokenKind::Minus, - TokenKind::Percent, - TokenKind::Plus, - TokenKind::Slash, - TokenKind::Tilde, + node.is_terminal_with_kinds(&[ + TerminalKind::Ampersand, + TerminalKind::Asterisk, + TerminalKind::BangEqual, + TerminalKind::Bar, + TerminalKind::Caret, + TerminalKind::EqualEqual, + TerminalKind::GreaterThan, + TerminalKind::GreaterThanEqual, + TerminalKind::LessThan, + TerminalKind::LessThanEqual, + TerminalKind::Minus, + TerminalKind::Percent, + TerminalKind::Plus, + TerminalKind::Slash, + TerminalKind::Tilde, ]) }) } } impl Selector { - fn using_target(&mut self) -> Result> { + fn using_target(&mut self) -> Result> { self.select(|node| { - node.is_rule_with_kind(RuleKind::TypeName) - || node.is_token_with_kind(TokenKind::Asterisk) + node.is_nonterminal_with_kind(NonTerminalKind::TypeName) + || node.is_terminal_with_kind(TerminalKind::Asterisk) }) } } impl Selector { - fn contract_member(&mut self) -> Result> { + fn contract_member(&mut self) -> Result> { self.select(|node| { - node.is_rule_with_kinds(&[ - RuleKind::UsingDirective, - RuleKind::FunctionDefinition, - RuleKind::ConstructorDefinition, - RuleKind::ReceiveFunctionDefinition, - RuleKind::FallbackFunctionDefinition, - RuleKind::UnnamedFunctionDefinition, - RuleKind::ModifierDefinition, - RuleKind::StructDefinition, - RuleKind::EnumDefinition, - RuleKind::EventDefinition, - RuleKind::StateVariableDefinition, - RuleKind::ErrorDefinition, - RuleKind::UserDefinedValueTypeDefinition, + node.is_nonterminal_with_kinds(&[ + NonTerminalKind::UsingDirective, + NonTerminalKind::FunctionDefinition, + NonTerminalKind::ConstructorDefinition, + NonTerminalKind::ReceiveFunctionDefinition, + NonTerminalKind::FallbackFunctionDefinition, + NonTerminalKind::UnnamedFunctionDefinition, + NonTerminalKind::ModifierDefinition, + NonTerminalKind::StructDefinition, + NonTerminalKind::EnumDefinition, + NonTerminalKind::EventDefinition, + NonTerminalKind::StateVariableDefinition, + NonTerminalKind::ErrorDefinition, + NonTerminalKind::UserDefinedValueTypeDefinition, ]) }) } } impl Selector { - fn state_variable_attribute(&mut self) -> Result> { + fn state_variable_attribute(&mut self) -> Result> { self.select(|node| { - node.is_rule_with_kind(RuleKind::OverrideSpecifier) - || node.is_token_with_kinds(&[ - TokenKind::ConstantKeyword, - TokenKind::InternalKeyword, - TokenKind::PrivateKeyword, - TokenKind::PublicKeyword, - TokenKind::ImmutableKeyword, + node.is_nonterminal_with_kind(NonTerminalKind::OverrideSpecifier) + || node.is_terminal_with_kinds(&[ + TerminalKind::ConstantKeyword, + TerminalKind::InternalKeyword, + TerminalKind::PrivateKeyword, + TerminalKind::PublicKeyword, + TerminalKind::ImmutableKeyword, ]) }) } } impl Selector { - fn function_name(&mut self) -> Result> { + fn function_name(&mut self) -> Result> { self.select(|node| { - node.is_token_with_kinds(&[ - TokenKind::Identifier, - TokenKind::FallbackKeyword, - TokenKind::ReceiveKeyword, + node.is_terminal_with_kinds(&[ + TerminalKind::Identifier, + TerminalKind::FallbackKeyword, + TerminalKind::ReceiveKeyword, ]) }) } } impl Selector { - fn function_attribute(&mut self) -> Result> { + fn function_attribute(&mut self) -> Result> { self.select(|node| { - node.is_rule_with_kinds(&[RuleKind::ModifierInvocation, RuleKind::OverrideSpecifier]) - || node.is_token_with_kinds(&[ - TokenKind::ConstantKeyword, - TokenKind::ExternalKeyword, - TokenKind::InternalKeyword, - TokenKind::PayableKeyword, - TokenKind::PrivateKeyword, - TokenKind::PublicKeyword, - TokenKind::PureKeyword, - TokenKind::ViewKeyword, - TokenKind::VirtualKeyword, - ]) + node.is_nonterminal_with_kinds(&[ + NonTerminalKind::ModifierInvocation, + NonTerminalKind::OverrideSpecifier, + ]) || node.is_terminal_with_kinds(&[ + TerminalKind::ConstantKeyword, + TerminalKind::ExternalKeyword, + TerminalKind::InternalKeyword, + TerminalKind::PayableKeyword, + TerminalKind::PrivateKeyword, + TerminalKind::PublicKeyword, + TerminalKind::PureKeyword, + TerminalKind::ViewKeyword, + TerminalKind::VirtualKeyword, + ]) }) } } impl Selector { - fn function_body(&mut self) -> Result> { + fn function_body(&mut self) -> Result> { self.select(|node| { - node.is_rule_with_kind(RuleKind::Block) || node.is_token_with_kind(TokenKind::Semicolon) + node.is_nonterminal_with_kind(NonTerminalKind::Block) + || node.is_terminal_with_kind(TerminalKind::Semicolon) }) } } impl Selector { - fn constructor_attribute(&mut self) -> Result> { + fn constructor_attribute(&mut self) -> Result> { self.select(|node| { - node.is_rule_with_kind(RuleKind::ModifierInvocation) - || node.is_token_with_kinds(&[ - TokenKind::InternalKeyword, - TokenKind::OverrideKeyword, - TokenKind::PayableKeyword, - TokenKind::PublicKeyword, - TokenKind::VirtualKeyword, + node.is_nonterminal_with_kind(NonTerminalKind::ModifierInvocation) + || node.is_terminal_with_kinds(&[ + TerminalKind::InternalKeyword, + TerminalKind::OverrideKeyword, + TerminalKind::PayableKeyword, + TerminalKind::PublicKeyword, + TerminalKind::VirtualKeyword, ]) }) } } impl Selector { - fn unnamed_function_attribute(&mut self) -> Result> { + fn unnamed_function_attribute(&mut self) -> Result> { self.select(|node| { - node.is_rule_with_kind(RuleKind::ModifierInvocation) - || node.is_token_with_kinds(&[ - TokenKind::ConstantKeyword, - TokenKind::ExternalKeyword, - TokenKind::InternalKeyword, - TokenKind::PayableKeyword, - TokenKind::PrivateKeyword, - TokenKind::PublicKeyword, - TokenKind::PureKeyword, - TokenKind::ViewKeyword, + node.is_nonterminal_with_kind(NonTerminalKind::ModifierInvocation) + || node.is_terminal_with_kinds(&[ + TerminalKind::ConstantKeyword, + TerminalKind::ExternalKeyword, + TerminalKind::InternalKeyword, + TerminalKind::PayableKeyword, + TerminalKind::PrivateKeyword, + TerminalKind::PublicKeyword, + TerminalKind::PureKeyword, + TerminalKind::ViewKeyword, ]) }) } } impl Selector { - fn fallback_function_attribute(&mut self) -> Result> { + fn fallback_function_attribute(&mut self) -> Result> { self.select(|node| { - node.is_rule_with_kinds(&[RuleKind::ModifierInvocation, RuleKind::OverrideSpecifier]) - || node.is_token_with_kinds(&[ - TokenKind::ExternalKeyword, - TokenKind::PayableKeyword, - TokenKind::PureKeyword, - TokenKind::ViewKeyword, - TokenKind::VirtualKeyword, - ]) + node.is_nonterminal_with_kinds(&[ + NonTerminalKind::ModifierInvocation, + NonTerminalKind::OverrideSpecifier, + ]) || node.is_terminal_with_kinds(&[ + TerminalKind::ExternalKeyword, + TerminalKind::PayableKeyword, + TerminalKind::PureKeyword, + TerminalKind::ViewKeyword, + TerminalKind::VirtualKeyword, + ]) }) } } impl Selector { - fn receive_function_attribute(&mut self) -> Result> { + fn receive_function_attribute(&mut self) -> Result> { self.select(|node| { - node.is_rule_with_kinds(&[RuleKind::ModifierInvocation, RuleKind::OverrideSpecifier]) - || node.is_token_with_kinds(&[ - TokenKind::ExternalKeyword, - TokenKind::PayableKeyword, - TokenKind::VirtualKeyword, - ]) + node.is_nonterminal_with_kinds(&[ + NonTerminalKind::ModifierInvocation, + NonTerminalKind::OverrideSpecifier, + ]) || node.is_terminal_with_kinds(&[ + TerminalKind::ExternalKeyword, + TerminalKind::PayableKeyword, + TerminalKind::VirtualKeyword, + ]) }) } } impl Selector { - fn modifier_attribute(&mut self) -> Result> { + fn modifier_attribute(&mut self) -> Result> { self.select(|node| { - node.is_rule_with_kind(RuleKind::OverrideSpecifier) - || node.is_token_with_kind(TokenKind::VirtualKeyword) + node.is_nonterminal_with_kind(NonTerminalKind::OverrideSpecifier) + || node.is_terminal_with_kind(TerminalKind::VirtualKeyword) }) } } impl Selector { - fn type_name(&mut self) -> Result> { + fn type_name(&mut self) -> Result> { self.select(|node| { - node.is_rule_with_kinds(&[ - RuleKind::ArrayTypeName, - RuleKind::FunctionType, - RuleKind::MappingType, - RuleKind::ElementaryType, - RuleKind::IdentifierPath, + node.is_nonterminal_with_kinds(&[ + NonTerminalKind::ArrayTypeName, + NonTerminalKind::FunctionType, + NonTerminalKind::MappingType, + NonTerminalKind::ElementaryType, + NonTerminalKind::IdentifierPath, ]) }) } } impl Selector { - fn function_type_attribute(&mut self) -> Result> { + fn function_type_attribute(&mut self) -> Result> { self.select(|node| { - node.is_token_with_kinds(&[ - TokenKind::InternalKeyword, - TokenKind::ExternalKeyword, - TokenKind::PrivateKeyword, - TokenKind::PublicKeyword, - TokenKind::ConstantKeyword, - TokenKind::PureKeyword, - TokenKind::ViewKeyword, - TokenKind::PayableKeyword, + node.is_terminal_with_kinds(&[ + TerminalKind::InternalKeyword, + TerminalKind::ExternalKeyword, + TerminalKind::PrivateKeyword, + TerminalKind::PublicKeyword, + TerminalKind::ConstantKeyword, + TerminalKind::PureKeyword, + TerminalKind::ViewKeyword, + TerminalKind::PayableKeyword, ]) }) } } impl Selector { - fn mapping_key_type(&mut self) -> Result> { + fn mapping_key_type(&mut self) -> Result> { self.select(|node| { - node.is_rule_with_kinds(&[RuleKind::ElementaryType, RuleKind::IdentifierPath]) + node.is_nonterminal_with_kinds(&[ + NonTerminalKind::ElementaryType, + NonTerminalKind::IdentifierPath, + ]) }) } } impl Selector { - fn elementary_type(&mut self) -> Result> { + fn elementary_type(&mut self) -> Result> { self.select(|node| { - node.is_rule_with_kind(RuleKind::AddressType) - || node.is_token_with_kinds(&[ - TokenKind::BoolKeyword, - TokenKind::ByteKeyword, - TokenKind::StringKeyword, - TokenKind::BytesKeyword, - TokenKind::IntKeyword, - TokenKind::UintKeyword, - TokenKind::FixedKeyword, - TokenKind::UfixedKeyword, + node.is_nonterminal_with_kind(NonTerminalKind::AddressType) + || node.is_terminal_with_kinds(&[ + TerminalKind::BoolKeyword, + TerminalKind::ByteKeyword, + TerminalKind::StringKeyword, + TerminalKind::BytesKeyword, + TerminalKind::IntKeyword, + TerminalKind::UintKeyword, + TerminalKind::FixedKeyword, + TerminalKind::UfixedKeyword, ]) }) } } impl Selector { - fn statement(&mut self) -> Result> { + fn statement(&mut self) -> Result> { self.select(|node| { - node.is_rule_with_kinds(&[ - RuleKind::ExpressionStatement, - RuleKind::VariableDeclarationStatement, - RuleKind::TupleDeconstructionStatement, - RuleKind::IfStatement, - RuleKind::ForStatement, - RuleKind::WhileStatement, - RuleKind::DoWhileStatement, - RuleKind::ContinueStatement, - RuleKind::BreakStatement, - RuleKind::ReturnStatement, - RuleKind::ThrowStatement, - RuleKind::EmitStatement, - RuleKind::TryStatement, - RuleKind::RevertStatement, - RuleKind::AssemblyStatement, - RuleKind::Block, - RuleKind::UncheckedBlock, + node.is_nonterminal_with_kinds(&[ + NonTerminalKind::ExpressionStatement, + NonTerminalKind::VariableDeclarationStatement, + NonTerminalKind::TupleDeconstructionStatement, + NonTerminalKind::IfStatement, + NonTerminalKind::ForStatement, + NonTerminalKind::WhileStatement, + NonTerminalKind::DoWhileStatement, + NonTerminalKind::ContinueStatement, + NonTerminalKind::BreakStatement, + NonTerminalKind::ReturnStatement, + NonTerminalKind::ThrowStatement, + NonTerminalKind::EmitStatement, + NonTerminalKind::TryStatement, + NonTerminalKind::RevertStatement, + NonTerminalKind::AssemblyStatement, + NonTerminalKind::Block, + NonTerminalKind::UncheckedBlock, ]) }) } } impl Selector { - fn tuple_member(&mut self) -> Result> { + fn tuple_member(&mut self) -> Result> { self.select(|node| { - node.is_rule_with_kinds(&[RuleKind::TypedTupleMember, RuleKind::UntypedTupleMember]) + node.is_nonterminal_with_kinds(&[ + NonTerminalKind::TypedTupleMember, + NonTerminalKind::UntypedTupleMember, + ]) }) } } impl Selector { - fn variable_declaration_type(&mut self) -> Result> { + fn variable_declaration_type(&mut self) -> Result> { self.select(|node| { - node.is_rule_with_kind(RuleKind::TypeName) - || node.is_token_with_kind(TokenKind::VarKeyword) + node.is_nonterminal_with_kind(NonTerminalKind::TypeName) + || node.is_terminal_with_kind(TerminalKind::VarKeyword) }) } } impl Selector { - fn storage_location(&mut self) -> Result> { + fn storage_location(&mut self) -> Result> { self.select(|node| { - node.is_token_with_kinds(&[ - TokenKind::MemoryKeyword, - TokenKind::StorageKeyword, - TokenKind::CallDataKeyword, + node.is_terminal_with_kinds(&[ + TerminalKind::MemoryKeyword, + TerminalKind::StorageKeyword, + TerminalKind::CallDataKeyword, ]) }) } } impl Selector { - fn for_statement_initialization(&mut self) -> Result> { + fn for_statement_initialization(&mut self) -> Result> { self.select(|node| { - node.is_rule_with_kinds(&[ - RuleKind::ExpressionStatement, - RuleKind::VariableDeclarationStatement, - RuleKind::TupleDeconstructionStatement, - ]) || node.is_token_with_kind(TokenKind::Semicolon) + node.is_nonterminal_with_kinds(&[ + NonTerminalKind::ExpressionStatement, + NonTerminalKind::VariableDeclarationStatement, + NonTerminalKind::TupleDeconstructionStatement, + ]) || node.is_terminal_with_kind(TerminalKind::Semicolon) }) } } impl Selector { - fn for_statement_condition(&mut self) -> Result> { + fn for_statement_condition(&mut self) -> Result> { self.select(|node| { - node.is_rule_with_kind(RuleKind::ExpressionStatement) - || node.is_token_with_kind(TokenKind::Semicolon) + node.is_nonterminal_with_kind(NonTerminalKind::ExpressionStatement) + || node.is_terminal_with_kind(TerminalKind::Semicolon) }) } } impl Selector { - fn expression(&mut self) -> Result> { + fn expression(&mut self) -> Result> { self.select(|node| { - node.is_rule_with_kinds(&[ - RuleKind::AssignmentExpression, - RuleKind::ConditionalExpression, - RuleKind::OrExpression, - RuleKind::AndExpression, - RuleKind::EqualityExpression, - RuleKind::ComparisonExpression, - RuleKind::BitwiseOrExpression, - RuleKind::BitwiseXorExpression, - RuleKind::BitwiseAndExpression, - RuleKind::ShiftExpression, - RuleKind::AdditiveExpression, - RuleKind::MultiplicativeExpression, - RuleKind::ExponentiationExpression, - RuleKind::PostfixExpression, - RuleKind::PrefixExpression, - RuleKind::FunctionCallExpression, - RuleKind::CallOptionsExpression, - RuleKind::MemberAccessExpression, - RuleKind::IndexAccessExpression, - RuleKind::NewExpression, - RuleKind::TupleExpression, - RuleKind::TypeExpression, - RuleKind::ArrayExpression, - RuleKind::HexNumberExpression, - RuleKind::DecimalNumberExpression, - RuleKind::StringExpression, - RuleKind::ElementaryType, - ]) || node.is_token_with_kinds(&[ - TokenKind::PayableKeyword, - TokenKind::TrueKeyword, - TokenKind::FalseKeyword, - TokenKind::Identifier, + node.is_nonterminal_with_kinds(&[ + NonTerminalKind::AssignmentExpression, + NonTerminalKind::ConditionalExpression, + NonTerminalKind::OrExpression, + NonTerminalKind::AndExpression, + NonTerminalKind::EqualityExpression, + NonTerminalKind::ComparisonExpression, + NonTerminalKind::BitwiseOrExpression, + NonTerminalKind::BitwiseXorExpression, + NonTerminalKind::BitwiseAndExpression, + NonTerminalKind::ShiftExpression, + NonTerminalKind::AdditiveExpression, + NonTerminalKind::MultiplicativeExpression, + NonTerminalKind::ExponentiationExpression, + NonTerminalKind::PostfixExpression, + NonTerminalKind::PrefixExpression, + NonTerminalKind::FunctionCallExpression, + NonTerminalKind::CallOptionsExpression, + NonTerminalKind::MemberAccessExpression, + NonTerminalKind::IndexAccessExpression, + NonTerminalKind::NewExpression, + NonTerminalKind::TupleExpression, + NonTerminalKind::TypeExpression, + NonTerminalKind::ArrayExpression, + NonTerminalKind::HexNumberExpression, + NonTerminalKind::DecimalNumberExpression, + NonTerminalKind::StringExpression, + NonTerminalKind::ElementaryType, + ]) || node.is_terminal_with_kinds(&[ + TerminalKind::PayableKeyword, + TerminalKind::TrueKeyword, + TerminalKind::FalseKeyword, + TerminalKind::Identifier, ]) }) } } impl Selector { - fn member_access(&mut self) -> Result> { + fn member_access(&mut self) -> Result> { self.select(|node| { - node.is_token_with_kinds(&[TokenKind::Identifier, TokenKind::AddressKeyword]) + node.is_terminal_with_kinds(&[TerminalKind::Identifier, TerminalKind::AddressKeyword]) }) } } impl Selector { - fn arguments_declaration(&mut self) -> Result> { + fn arguments_declaration(&mut self) -> Result> { self.select(|node| { - node.is_rule_with_kinds(&[ - RuleKind::PositionalArgumentsDeclaration, - RuleKind::NamedArgumentsDeclaration, + node.is_nonterminal_with_kinds(&[ + NonTerminalKind::PositionalArgumentsDeclaration, + NonTerminalKind::NamedArgumentsDeclaration, ]) }) } } impl Selector { - fn number_unit(&mut self) -> Result> { + fn number_unit(&mut self) -> Result> { self.select(|node| { - node.is_token_with_kinds(&[ - TokenKind::WeiKeyword, - TokenKind::GweiKeyword, - TokenKind::SzaboKeyword, - TokenKind::FinneyKeyword, - TokenKind::EtherKeyword, - TokenKind::SecondsKeyword, - TokenKind::MinutesKeyword, - TokenKind::HoursKeyword, - TokenKind::DaysKeyword, - TokenKind::WeeksKeyword, - TokenKind::YearsKeyword, + node.is_terminal_with_kinds(&[ + TerminalKind::WeiKeyword, + TerminalKind::GweiKeyword, + TerminalKind::SzaboKeyword, + TerminalKind::FinneyKeyword, + TerminalKind::EtherKeyword, + TerminalKind::SecondsKeyword, + TerminalKind::MinutesKeyword, + TerminalKind::HoursKeyword, + TerminalKind::DaysKeyword, + TerminalKind::WeeksKeyword, + TerminalKind::YearsKeyword, ]) }) } } impl Selector { - fn string_expression(&mut self) -> Result> { + fn string_expression(&mut self) -> Result> { self.select(|node| { - node.is_rule_with_kinds(&[ - RuleKind::StringLiteral, - RuleKind::StringLiterals, - RuleKind::HexStringLiteral, - RuleKind::HexStringLiterals, - RuleKind::UnicodeStringLiterals, + node.is_nonterminal_with_kinds(&[ + NonTerminalKind::StringLiteral, + NonTerminalKind::StringLiterals, + NonTerminalKind::HexStringLiteral, + NonTerminalKind::HexStringLiterals, + NonTerminalKind::UnicodeStringLiterals, ]) }) } } impl Selector { - fn string_literal(&mut self) -> Result> { + fn string_literal(&mut self) -> Result> { self.select(|node| { - node.is_token_with_kinds(&[ - TokenKind::SingleQuotedStringLiteral, - TokenKind::DoubleQuotedStringLiteral, + node.is_terminal_with_kinds(&[ + TerminalKind::SingleQuotedStringLiteral, + TerminalKind::DoubleQuotedStringLiteral, ]) }) } } impl Selector { - fn hex_string_literal(&mut self) -> Result> { + fn hex_string_literal(&mut self) -> Result> { self.select(|node| { - node.is_token_with_kinds(&[ - TokenKind::SingleQuotedHexStringLiteral, - TokenKind::DoubleQuotedHexStringLiteral, + node.is_terminal_with_kinds(&[ + TerminalKind::SingleQuotedHexStringLiteral, + TerminalKind::DoubleQuotedHexStringLiteral, ]) }) } } impl Selector { - fn unicode_string_literal(&mut self) -> Result> { + fn unicode_string_literal(&mut self) -> Result> { self.select(|node| { - node.is_token_with_kinds(&[ - TokenKind::SingleQuotedUnicodeStringLiteral, - TokenKind::DoubleQuotedUnicodeStringLiteral, + node.is_terminal_with_kinds(&[ + TerminalKind::SingleQuotedUnicodeStringLiteral, + TerminalKind::DoubleQuotedUnicodeStringLiteral, ]) }) } } impl Selector { - fn yul_statement(&mut self) -> Result> { + fn yul_statement(&mut self) -> Result> { self.select(|node| { - node.is_rule_with_kinds(&[ - RuleKind::YulBlock, - RuleKind::YulFunctionDefinition, - RuleKind::YulVariableDeclarationStatement, - RuleKind::YulAssignmentStatement, - RuleKind::YulIfStatement, - RuleKind::YulForStatement, - RuleKind::YulSwitchStatement, - RuleKind::YulLeaveStatement, - RuleKind::YulBreakStatement, - RuleKind::YulContinueStatement, - RuleKind::YulLabel, - RuleKind::YulExpression, + node.is_nonterminal_with_kinds(&[ + NonTerminalKind::YulBlock, + NonTerminalKind::YulFunctionDefinition, + NonTerminalKind::YulVariableDeclarationStatement, + NonTerminalKind::YulAssignmentStatement, + NonTerminalKind::YulIfStatement, + NonTerminalKind::YulForStatement, + NonTerminalKind::YulSwitchStatement, + NonTerminalKind::YulLeaveStatement, + NonTerminalKind::YulBreakStatement, + NonTerminalKind::YulContinueStatement, + NonTerminalKind::YulLabel, + NonTerminalKind::YulExpression, ]) }) } } impl Selector { - fn yul_assignment_operator(&mut self) -> Result> { + fn yul_assignment_operator(&mut self) -> Result> { self.select(|node| { - node.is_rule_with_kind(RuleKind::YulColonAndEqual) - || node.is_token_with_kind(TokenKind::ColonEqual) + node.is_nonterminal_with_kind(NonTerminalKind::YulColonAndEqual) + || node.is_terminal_with_kind(TerminalKind::ColonEqual) }) } } impl Selector { - fn yul_switch_case(&mut self) -> Result> { + fn yul_switch_case(&mut self) -> Result> { self.select(|node| { - node.is_rule_with_kinds(&[RuleKind::YulDefaultCase, RuleKind::YulValueCase]) + node.is_nonterminal_with_kinds(&[ + NonTerminalKind::YulDefaultCase, + NonTerminalKind::YulValueCase, + ]) }) } } impl Selector { - fn yul_expression(&mut self) -> Result> { + fn yul_expression(&mut self) -> Result> { self.select(|node| { - node.is_rule_with_kinds(&[ - RuleKind::YulFunctionCallExpression, - RuleKind::YulLiteral, - RuleKind::YulBuiltInFunction, - RuleKind::YulPath, + node.is_nonterminal_with_kinds(&[ + NonTerminalKind::YulFunctionCallExpression, + NonTerminalKind::YulLiteral, + NonTerminalKind::YulBuiltInFunction, + NonTerminalKind::YulPath, ]) }) } } impl Selector { - fn yul_path_component(&mut self) -> Result> { + fn yul_path_component(&mut self) -> Result> { self.select(|node| { - node.is_token_with_kinds(&[TokenKind::YulIdentifier, TokenKind::YulAddressKeyword]) + node.is_terminal_with_kinds(&[ + TerminalKind::YulIdentifier, + TerminalKind::YulAddressKeyword, + ]) }) } } impl Selector { - fn yul_built_in_function(&mut self) -> Result> { + fn yul_built_in_function(&mut self) -> Result> { self.select(|node| { - node.is_token_with_kinds(&[ - TokenKind::YulAddKeyword, - TokenKind::YulAddModKeyword, - TokenKind::YulAddressKeyword, - TokenKind::YulAndKeyword, - TokenKind::YulBalanceKeyword, - TokenKind::YulBlockHashKeyword, - TokenKind::YulByteKeyword, - TokenKind::YulCallCodeKeyword, - TokenKind::YulCallDataCopyKeyword, - TokenKind::YulCallDataLoadKeyword, - TokenKind::YulCallDataSizeKeyword, - TokenKind::YulCallerKeyword, - TokenKind::YulCallKeyword, - TokenKind::YulCallValueKeyword, - TokenKind::YulCoinBaseKeyword, - TokenKind::YulCreateKeyword, - TokenKind::YulDelegateCallKeyword, - TokenKind::YulDivKeyword, - TokenKind::YulEqKeyword, - TokenKind::YulExpKeyword, - TokenKind::YulExtCodeCopyKeyword, - TokenKind::YulExtCodeSizeKeyword, - TokenKind::YulGasKeyword, - TokenKind::YulGasLimitKeyword, - TokenKind::YulGasPriceKeyword, - TokenKind::YulGtKeyword, - TokenKind::YulInvalidKeyword, - TokenKind::YulIsZeroKeyword, - TokenKind::YulLog0Keyword, - TokenKind::YulLog1Keyword, - TokenKind::YulLog2Keyword, - TokenKind::YulLog3Keyword, - TokenKind::YulLog4Keyword, - TokenKind::YulLtKeyword, - TokenKind::YulMLoadKeyword, - TokenKind::YulModKeyword, - TokenKind::YulMSizeKeyword, - TokenKind::YulMStore8Keyword, - TokenKind::YulMStoreKeyword, - TokenKind::YulMulKeyword, - TokenKind::YulMulModKeyword, - TokenKind::YulNotKeyword, - TokenKind::YulNumberKeyword, - TokenKind::YulOriginKeyword, - TokenKind::YulOrKeyword, - TokenKind::YulPopKeyword, - TokenKind::YulReturnKeyword, - TokenKind::YulRevertKeyword, - TokenKind::YulSDivKeyword, - TokenKind::YulSelfDestructKeyword, - TokenKind::YulSgtKeyword, - TokenKind::YulSignExtendKeyword, - TokenKind::YulSLoadKeyword, - TokenKind::YulSltKeyword, - TokenKind::YulSModKeyword, - TokenKind::YulSStoreKeyword, - TokenKind::YulStopKeyword, - TokenKind::YulSubKeyword, - TokenKind::YulTimestampKeyword, - TokenKind::YulXorKeyword, - TokenKind::YulKeccak256Keyword, - TokenKind::YulSha3Keyword, - TokenKind::YulSuicideKeyword, - TokenKind::YulReturnDataCopyKeyword, - TokenKind::YulReturnDataSizeKeyword, - TokenKind::YulStaticCallKeyword, - TokenKind::YulCreate2Keyword, - TokenKind::YulExtCodeHashKeyword, - TokenKind::YulSarKeyword, - TokenKind::YulShlKeyword, - TokenKind::YulShrKeyword, - TokenKind::YulChainIdKeyword, - TokenKind::YulSelfBalanceKeyword, - TokenKind::YulBaseFeeKeyword, - TokenKind::YulDifficultyKeyword, - TokenKind::YulPrevRandaoKeyword, - TokenKind::YulBlobBaseFeeKeyword, - TokenKind::YulBlobHashKeyword, - TokenKind::YulTLoadKeyword, - TokenKind::YulTStoreKeyword, - TokenKind::YulMCopyKeyword, + node.is_terminal_with_kinds(&[ + TerminalKind::YulAddKeyword, + TerminalKind::YulAddModKeyword, + TerminalKind::YulAddressKeyword, + TerminalKind::YulAndKeyword, + TerminalKind::YulBalanceKeyword, + TerminalKind::YulBlockHashKeyword, + TerminalKind::YulByteKeyword, + TerminalKind::YulCallCodeKeyword, + TerminalKind::YulCallDataCopyKeyword, + TerminalKind::YulCallDataLoadKeyword, + TerminalKind::YulCallDataSizeKeyword, + TerminalKind::YulCallerKeyword, + TerminalKind::YulCallKeyword, + TerminalKind::YulCallValueKeyword, + TerminalKind::YulCoinBaseKeyword, + TerminalKind::YulCreateKeyword, + TerminalKind::YulDelegateCallKeyword, + TerminalKind::YulDivKeyword, + TerminalKind::YulEqKeyword, + TerminalKind::YulExpKeyword, + TerminalKind::YulExtCodeCopyKeyword, + TerminalKind::YulExtCodeSizeKeyword, + TerminalKind::YulGasKeyword, + TerminalKind::YulGasLimitKeyword, + TerminalKind::YulGasPriceKeyword, + TerminalKind::YulGtKeyword, + TerminalKind::YulInvalidKeyword, + TerminalKind::YulIsZeroKeyword, + TerminalKind::YulLog0Keyword, + TerminalKind::YulLog1Keyword, + TerminalKind::YulLog2Keyword, + TerminalKind::YulLog3Keyword, + TerminalKind::YulLog4Keyword, + TerminalKind::YulLtKeyword, + TerminalKind::YulMLoadKeyword, + TerminalKind::YulModKeyword, + TerminalKind::YulMSizeKeyword, + TerminalKind::YulMStore8Keyword, + TerminalKind::YulMStoreKeyword, + TerminalKind::YulMulKeyword, + TerminalKind::YulMulModKeyword, + TerminalKind::YulNotKeyword, + TerminalKind::YulNumberKeyword, + TerminalKind::YulOriginKeyword, + TerminalKind::YulOrKeyword, + TerminalKind::YulPopKeyword, + TerminalKind::YulReturnKeyword, + TerminalKind::YulRevertKeyword, + TerminalKind::YulSDivKeyword, + TerminalKind::YulSelfDestructKeyword, + TerminalKind::YulSgtKeyword, + TerminalKind::YulSignExtendKeyword, + TerminalKind::YulSLoadKeyword, + TerminalKind::YulSltKeyword, + TerminalKind::YulSModKeyword, + TerminalKind::YulSStoreKeyword, + TerminalKind::YulStopKeyword, + TerminalKind::YulSubKeyword, + TerminalKind::YulTimestampKeyword, + TerminalKind::YulXorKeyword, + TerminalKind::YulKeccak256Keyword, + TerminalKind::YulSha3Keyword, + TerminalKind::YulSuicideKeyword, + TerminalKind::YulReturnDataCopyKeyword, + TerminalKind::YulReturnDataSizeKeyword, + TerminalKind::YulStaticCallKeyword, + TerminalKind::YulCreate2Keyword, + TerminalKind::YulExtCodeHashKeyword, + TerminalKind::YulSarKeyword, + TerminalKind::YulShlKeyword, + TerminalKind::YulShrKeyword, + TerminalKind::YulChainIdKeyword, + TerminalKind::YulSelfBalanceKeyword, + TerminalKind::YulBaseFeeKeyword, + TerminalKind::YulDifficultyKeyword, + TerminalKind::YulPrevRandaoKeyword, + TerminalKind::YulBlobBaseFeeKeyword, + TerminalKind::YulBlobHashKeyword, + TerminalKind::YulTLoadKeyword, + TerminalKind::YulTStoreKeyword, + TerminalKind::YulMCopyKeyword, ]) }) } } impl Selector { - fn yul_literal(&mut self) -> Result> { + fn yul_literal(&mut self) -> Result> { self.select(|node| { - node.is_rule_with_kinds(&[RuleKind::HexStringLiteral, RuleKind::StringLiteral]) - || node.is_token_with_kinds(&[ - TokenKind::YulTrueKeyword, - TokenKind::YulFalseKeyword, - TokenKind::YulDecimalLiteral, - TokenKind::YulHexLiteral, - ]) + node.is_nonterminal_with_kinds(&[ + NonTerminalKind::HexStringLiteral, + NonTerminalKind::StringLiteral, + ]) || node.is_terminal_with_kinds(&[ + TerminalKind::YulTrueKeyword, + TerminalKind::YulFalseKeyword, + TerminalKind::YulDecimalLiteral, + TerminalKind::YulHexLiteral, + ]) }) } } @@ -2231,32 +2559,32 @@ impl Selector { catch_unwind )] pub fn select_repeated( - #[napi(ts_arg_type = "cst.RuleNode")] node: &RuleNode, -) -> Result>> { + #[napi(ts_arg_type = "cst.NonTerminalNode")] node: &NonTerminalNode, +) -> Result>> { let mut selector = Selector::new(node); let result = match node.kind() { - RuleKind::SourceUnitMembers => selector.source_unit_members()?, - RuleKind::VersionExpressionSet => selector.version_expression_set()?, - RuleKind::ContractMembers => selector.contract_members()?, - RuleKind::InterfaceMembers => selector.interface_members()?, - RuleKind::LibraryMembers => selector.library_members()?, - RuleKind::StructMembers => selector.struct_members()?, - RuleKind::StateVariableAttributes => selector.state_variable_attributes()?, - RuleKind::FunctionAttributes => selector.function_attributes()?, - RuleKind::ConstructorAttributes => selector.constructor_attributes()?, - RuleKind::UnnamedFunctionAttributes => selector.unnamed_function_attributes()?, - RuleKind::FallbackFunctionAttributes => selector.fallback_function_attributes()?, - RuleKind::ReceiveFunctionAttributes => selector.receive_function_attributes()?, - RuleKind::ModifierAttributes => selector.modifier_attributes()?, - RuleKind::FunctionTypeAttributes => selector.function_type_attributes()?, - RuleKind::Statements => selector.statements()?, - RuleKind::CatchClauses => selector.catch_clauses()?, - RuleKind::StringLiterals => selector.string_literals()?, - RuleKind::HexStringLiterals => selector.hex_string_literals()?, - RuleKind::UnicodeStringLiterals => selector.unicode_string_literals()?, - RuleKind::YulStatements => selector.yul_statements()?, - RuleKind::YulSwitchCases => selector.yul_switch_cases()?, + NonTerminalKind::SourceUnitMembers => selector.source_unit_members()?, + NonTerminalKind::VersionExpressionSet => selector.version_expression_set()?, + NonTerminalKind::ContractMembers => selector.contract_members()?, + NonTerminalKind::InterfaceMembers => selector.interface_members()?, + NonTerminalKind::LibraryMembers => selector.library_members()?, + NonTerminalKind::StructMembers => selector.struct_members()?, + NonTerminalKind::StateVariableAttributes => selector.state_variable_attributes()?, + NonTerminalKind::FunctionAttributes => selector.function_attributes()?, + NonTerminalKind::ConstructorAttributes => selector.constructor_attributes()?, + NonTerminalKind::UnnamedFunctionAttributes => selector.unnamed_function_attributes()?, + NonTerminalKind::FallbackFunctionAttributes => selector.fallback_function_attributes()?, + NonTerminalKind::ReceiveFunctionAttributes => selector.receive_function_attributes()?, + NonTerminalKind::ModifierAttributes => selector.modifier_attributes()?, + NonTerminalKind::FunctionTypeAttributes => selector.function_type_attributes()?, + NonTerminalKind::Statements => selector.statements()?, + NonTerminalKind::CatchClauses => selector.catch_clauses()?, + NonTerminalKind::StringLiterals => selector.string_literals()?, + NonTerminalKind::HexStringLiterals => selector.hex_string_literals()?, + NonTerminalKind::UnicodeStringLiterals => selector.unicode_string_literals()?, + NonTerminalKind::YulStatements => selector.yul_statements()?, + NonTerminalKind::YulSwitchCases => selector.yul_switch_cases()?, _ => { return Error::UnexpectedParent(node.kind()).into(); } @@ -2267,11 +2595,11 @@ pub fn select_repeated( } impl Selector { - fn source_unit_members(&mut self) -> Result>> { + fn source_unit_members(&mut self) -> Result>> { let mut items = vec![]; - while let Some(item) = - self.try_select(|node| node.is_rule_with_kind(RuleKind::SourceUnitMember))? + while let Some(item) = self + .try_select(|node| node.is_nonterminal_with_kind(NonTerminalKind::SourceUnitMember))? { items.push(item); } @@ -2281,11 +2609,11 @@ impl Selector { } impl Selector { - fn version_expression_set(&mut self) -> Result>> { + fn version_expression_set(&mut self) -> Result>> { let mut items = vec![]; - while let Some(item) = - self.try_select(|node| node.is_rule_with_kind(RuleKind::VersionExpression))? + while let Some(item) = self + .try_select(|node| node.is_nonterminal_with_kind(NonTerminalKind::VersionExpression))? { items.push(item); } @@ -2295,11 +2623,11 @@ impl Selector { } impl Selector { - fn contract_members(&mut self) -> Result>> { + fn contract_members(&mut self) -> Result>> { let mut items = vec![]; while let Some(item) = - self.try_select(|node| node.is_rule_with_kind(RuleKind::ContractMember))? + self.try_select(|node| node.is_nonterminal_with_kind(NonTerminalKind::ContractMember))? { items.push(item); } @@ -2309,11 +2637,11 @@ impl Selector { } impl Selector { - fn interface_members(&mut self) -> Result>> { + fn interface_members(&mut self) -> Result>> { let mut items = vec![]; while let Some(item) = - self.try_select(|node| node.is_rule_with_kind(RuleKind::ContractMember))? + self.try_select(|node| node.is_nonterminal_with_kind(NonTerminalKind::ContractMember))? { items.push(item); } @@ -2323,11 +2651,11 @@ impl Selector { } impl Selector { - fn library_members(&mut self) -> Result>> { + fn library_members(&mut self) -> Result>> { let mut items = vec![]; while let Some(item) = - self.try_select(|node| node.is_rule_with_kind(RuleKind::ContractMember))? + self.try_select(|node| node.is_nonterminal_with_kind(NonTerminalKind::ContractMember))? { items.push(item); } @@ -2337,11 +2665,11 @@ impl Selector { } impl Selector { - fn struct_members(&mut self) -> Result>> { + fn struct_members(&mut self) -> Result>> { let mut items = vec![]; while let Some(item) = - self.try_select(|node| node.is_rule_with_kind(RuleKind::StructMember))? + self.try_select(|node| node.is_nonterminal_with_kind(NonTerminalKind::StructMember))? { items.push(item); } @@ -2351,12 +2679,12 @@ impl Selector { } impl Selector { - fn state_variable_attributes(&mut self) -> Result>> { + fn state_variable_attributes(&mut self) -> Result>> { let mut items = vec![]; - while let Some(item) = - self.try_select(|node| node.is_rule_with_kind(RuleKind::StateVariableAttribute))? - { + while let Some(item) = self.try_select(|node| { + node.is_nonterminal_with_kind(NonTerminalKind::StateVariableAttribute) + })? { items.push(item); } @@ -2365,11 +2693,11 @@ impl Selector { } impl Selector { - fn function_attributes(&mut self) -> Result>> { + fn function_attributes(&mut self) -> Result>> { let mut items = vec![]; - while let Some(item) = - self.try_select(|node| node.is_rule_with_kind(RuleKind::FunctionAttribute))? + while let Some(item) = self + .try_select(|node| node.is_nonterminal_with_kind(NonTerminalKind::FunctionAttribute))? { items.push(item); } @@ -2379,12 +2707,12 @@ impl Selector { } impl Selector { - fn constructor_attributes(&mut self) -> Result>> { + fn constructor_attributes(&mut self) -> Result>> { let mut items = vec![]; - while let Some(item) = - self.try_select(|node| node.is_rule_with_kind(RuleKind::ConstructorAttribute))? - { + while let Some(item) = self.try_select(|node| { + node.is_nonterminal_with_kind(NonTerminalKind::ConstructorAttribute) + })? { items.push(item); } @@ -2393,12 +2721,14 @@ impl Selector { } impl Selector { - fn unnamed_function_attributes(&mut self) -> Result>> { + fn unnamed_function_attributes( + &mut self, + ) -> Result>> { let mut items = vec![]; - while let Some(item) = - self.try_select(|node| node.is_rule_with_kind(RuleKind::UnnamedFunctionAttribute))? - { + while let Some(item) = self.try_select(|node| { + node.is_nonterminal_with_kind(NonTerminalKind::UnnamedFunctionAttribute) + })? { items.push(item); } @@ -2407,12 +2737,14 @@ impl Selector { } impl Selector { - fn fallback_function_attributes(&mut self) -> Result>> { + fn fallback_function_attributes( + &mut self, + ) -> Result>> { let mut items = vec![]; - while let Some(item) = - self.try_select(|node| node.is_rule_with_kind(RuleKind::FallbackFunctionAttribute))? - { + while let Some(item) = self.try_select(|node| { + node.is_nonterminal_with_kind(NonTerminalKind::FallbackFunctionAttribute) + })? { items.push(item); } @@ -2421,12 +2753,14 @@ impl Selector { } impl Selector { - fn receive_function_attributes(&mut self) -> Result>> { + fn receive_function_attributes( + &mut self, + ) -> Result>> { let mut items = vec![]; - while let Some(item) = - self.try_select(|node| node.is_rule_with_kind(RuleKind::ReceiveFunctionAttribute))? - { + while let Some(item) = self.try_select(|node| { + node.is_nonterminal_with_kind(NonTerminalKind::ReceiveFunctionAttribute) + })? { items.push(item); } @@ -2435,11 +2769,11 @@ impl Selector { } impl Selector { - fn modifier_attributes(&mut self) -> Result>> { + fn modifier_attributes(&mut self) -> Result>> { let mut items = vec![]; - while let Some(item) = - self.try_select(|node| node.is_rule_with_kind(RuleKind::ModifierAttribute))? + while let Some(item) = self + .try_select(|node| node.is_nonterminal_with_kind(NonTerminalKind::ModifierAttribute))? { items.push(item); } @@ -2449,12 +2783,12 @@ impl Selector { } impl Selector { - fn function_type_attributes(&mut self) -> Result>> { + fn function_type_attributes(&mut self) -> Result>> { let mut items = vec![]; - while let Some(item) = - self.try_select(|node| node.is_rule_with_kind(RuleKind::FunctionTypeAttribute))? - { + while let Some(item) = self.try_select(|node| { + node.is_nonterminal_with_kind(NonTerminalKind::FunctionTypeAttribute) + })? { items.push(item); } @@ -2463,11 +2797,11 @@ impl Selector { } impl Selector { - fn statements(&mut self) -> Result>> { + fn statements(&mut self) -> Result>> { let mut items = vec![]; while let Some(item) = - self.try_select(|node| node.is_rule_with_kind(RuleKind::Statement))? + self.try_select(|node| node.is_nonterminal_with_kind(NonTerminalKind::Statement))? { items.push(item); } @@ -2477,11 +2811,11 @@ impl Selector { } impl Selector { - fn catch_clauses(&mut self) -> Result>> { + fn catch_clauses(&mut self) -> Result>> { let mut items = vec![]; while let Some(item) = - self.try_select(|node| node.is_rule_with_kind(RuleKind::CatchClause))? + self.try_select(|node| node.is_nonterminal_with_kind(NonTerminalKind::CatchClause))? { items.push(item); } @@ -2491,11 +2825,11 @@ impl Selector { } impl Selector { - fn string_literals(&mut self) -> Result>> { + fn string_literals(&mut self) -> Result>> { let mut items = vec![]; while let Some(item) = - self.try_select(|node| node.is_rule_with_kind(RuleKind::StringLiteral))? + self.try_select(|node| node.is_nonterminal_with_kind(NonTerminalKind::StringLiteral))? { items.push(item); } @@ -2505,11 +2839,11 @@ impl Selector { } impl Selector { - fn hex_string_literals(&mut self) -> Result>> { + fn hex_string_literals(&mut self) -> Result>> { let mut items = vec![]; - while let Some(item) = - self.try_select(|node| node.is_rule_with_kind(RuleKind::HexStringLiteral))? + while let Some(item) = self + .try_select(|node| node.is_nonterminal_with_kind(NonTerminalKind::HexStringLiteral))? { items.push(item); } @@ -2519,12 +2853,12 @@ impl Selector { } impl Selector { - fn unicode_string_literals(&mut self) -> Result>> { + fn unicode_string_literals(&mut self) -> Result>> { let mut items = vec![]; - while let Some(item) = - self.try_select(|node| node.is_rule_with_kind(RuleKind::UnicodeStringLiteral))? - { + while let Some(item) = self.try_select(|node| { + node.is_nonterminal_with_kind(NonTerminalKind::UnicodeStringLiteral) + })? { items.push(item); } @@ -2533,11 +2867,11 @@ impl Selector { } impl Selector { - fn yul_statements(&mut self) -> Result>> { + fn yul_statements(&mut self) -> Result>> { let mut items = vec![]; while let Some(item) = - self.try_select(|node| node.is_rule_with_kind(RuleKind::YulStatement))? + self.try_select(|node| node.is_nonterminal_with_kind(NonTerminalKind::YulStatement))? { items.push(item); } @@ -2547,11 +2881,11 @@ impl Selector { } impl Selector { - fn yul_switch_cases(&mut self) -> Result>> { + fn yul_switch_cases(&mut self) -> Result>> { let mut items = vec![]; while let Some(item) = - self.try_select(|node| node.is_rule_with_kind(RuleKind::YulSwitchCase))? + self.try_select(|node| node.is_nonterminal_with_kind(NonTerminalKind::YulSwitchCase))? { items.push(item); } @@ -2570,34 +2904,34 @@ impl Selector { catch_unwind )] pub fn select_separated( - #[napi(ts_arg_type = "cst.RuleNode")] node: &RuleNode, -) -> Result>>> { + #[napi(ts_arg_type = "cst.NonTerminalNode")] node: &NonTerminalNode, +) -> Result>>> { let mut selector = Selector::new(node); let result = match node.kind() { - RuleKind::VersionExpressionSets => selector.version_expression_sets()?, - RuleKind::VersionSpecifiers => selector.version_specifiers()?, - RuleKind::ImportDeconstructionSymbols => selector.import_deconstruction_symbols()?, - RuleKind::UsingDeconstructionSymbols => selector.using_deconstruction_symbols()?, - RuleKind::InheritanceTypes => selector.inheritance_types()?, - RuleKind::EnumMembers => selector.enum_members()?, - RuleKind::Parameters => selector.parameters()?, - RuleKind::OverridePaths => selector.override_paths()?, - RuleKind::EventParameters => selector.event_parameters()?, - RuleKind::ErrorParameters => selector.error_parameters()?, - RuleKind::AssemblyFlags => selector.assembly_flags()?, - RuleKind::TupleDeconstructionElements => selector.tuple_deconstruction_elements()?, - RuleKind::PositionalArguments => selector.positional_arguments()?, - RuleKind::NamedArguments => selector.named_arguments()?, - RuleKind::CallOptions => selector.call_options()?, - RuleKind::TupleValues => selector.tuple_values()?, - RuleKind::ArrayValues => selector.array_values()?, - RuleKind::IdentifierPath => selector.identifier_path()?, - RuleKind::YulParameters => selector.yul_parameters()?, - RuleKind::YulReturnVariables => selector.yul_return_variables()?, - RuleKind::YulArguments => selector.yul_arguments()?, - RuleKind::YulPaths => selector.yul_paths()?, - RuleKind::YulPath => selector.yul_path()?, + NonTerminalKind::VersionExpressionSets => selector.version_expression_sets()?, + NonTerminalKind::VersionSpecifiers => selector.version_specifiers()?, + NonTerminalKind::ImportDeconstructionSymbols => selector.import_deconstruction_symbols()?, + NonTerminalKind::UsingDeconstructionSymbols => selector.using_deconstruction_symbols()?, + NonTerminalKind::InheritanceTypes => selector.inheritance_types()?, + NonTerminalKind::EnumMembers => selector.enum_members()?, + NonTerminalKind::Parameters => selector.parameters()?, + NonTerminalKind::OverridePaths => selector.override_paths()?, + NonTerminalKind::EventParameters => selector.event_parameters()?, + NonTerminalKind::ErrorParameters => selector.error_parameters()?, + NonTerminalKind::AssemblyFlags => selector.assembly_flags()?, + NonTerminalKind::TupleDeconstructionElements => selector.tuple_deconstruction_elements()?, + NonTerminalKind::PositionalArguments => selector.positional_arguments()?, + NonTerminalKind::NamedArguments => selector.named_arguments()?, + NonTerminalKind::CallOptions => selector.call_options()?, + NonTerminalKind::TupleValues => selector.tuple_values()?, + NonTerminalKind::ArrayValues => selector.array_values()?, + NonTerminalKind::IdentifierPath => selector.identifier_path()?, + NonTerminalKind::YulParameters => selector.yul_parameters()?, + NonTerminalKind::YulReturnVariables => selector.yul_return_variables()?, + NonTerminalKind::YulArguments => selector.yul_arguments()?, + NonTerminalKind::YulPaths => selector.yul_paths()?, + NonTerminalKind::YulPath => selector.yul_path()?, _ => { return Error::UnexpectedParent(node.kind()).into(); } @@ -2608,23 +2942,25 @@ pub fn select_separated( } impl Selector { - fn version_expression_sets(&mut self) -> Result>>> { + fn version_expression_sets( + &mut self, + ) -> Result>>> { let mut separated = vec![]; let mut separators = vec![]; - if let Some(first) = - self.try_select(|node| node.is_rule_with_kind(RuleKind::VersionExpressionSet))? - { + if let Some(first) = self.try_select(|node| { + node.is_nonterminal_with_kind(NonTerminalKind::VersionExpressionSet) + })? { separated.push(first); while let Some(separator) = - self.try_select(|node| node.is_token_with_kind(TokenKind::BarBar))? + self.try_select(|node| node.is_terminal_with_kind(TerminalKind::BarBar))? { separators.push(separator); - separated.push( - self.select(|node| node.is_rule_with_kind(RuleKind::VersionExpressionSet))?, - ); + separated.push(self.select(|node| { + node.is_nonterminal_with_kind(NonTerminalKind::VersionExpressionSet) + })?); } } @@ -2633,22 +2969,22 @@ impl Selector { } impl Selector { - fn version_specifiers(&mut self) -> Result>>> { + fn version_specifiers(&mut self) -> Result>>> { let mut separated = vec![]; let mut separators = vec![]; if let Some(first) = - self.try_select(|node| node.is_token_with_kind(TokenKind::VersionSpecifier))? + self.try_select(|node| node.is_terminal_with_kind(TerminalKind::VersionSpecifier))? { separated.push(first); while let Some(separator) = - self.try_select(|node| node.is_token_with_kind(TokenKind::Period))? + self.try_select(|node| node.is_terminal_with_kind(TerminalKind::Period))? { separators.push(separator); separated.push( - self.select(|node| node.is_token_with_kind(TokenKind::VersionSpecifier))?, + self.select(|node| node.is_terminal_with_kind(TerminalKind::VersionSpecifier))?, ); } } @@ -2658,25 +2994,25 @@ impl Selector { } impl Selector { - fn import_deconstruction_symbols(&mut self) -> Result>>> { + fn import_deconstruction_symbols( + &mut self, + ) -> Result>>> { let mut separated = vec![]; let mut separators = vec![]; - if let Some(first) = - self.try_select(|node| node.is_rule_with_kind(RuleKind::ImportDeconstructionSymbol))? - { + if let Some(first) = self.try_select(|node| { + node.is_nonterminal_with_kind(NonTerminalKind::ImportDeconstructionSymbol) + })? { separated.push(first); while let Some(separator) = - self.try_select(|node| node.is_token_with_kind(TokenKind::Comma))? + self.try_select(|node| node.is_terminal_with_kind(TerminalKind::Comma))? { separators.push(separator); - separated.push( - self.select(|node| { - node.is_rule_with_kind(RuleKind::ImportDeconstructionSymbol) - })?, - ); + separated.push(self.select(|node| { + node.is_nonterminal_with_kind(NonTerminalKind::ImportDeconstructionSymbol) + })?); } } @@ -2685,25 +3021,25 @@ impl Selector { } impl Selector { - fn using_deconstruction_symbols(&mut self) -> Result>>> { + fn using_deconstruction_symbols( + &mut self, + ) -> Result>>> { let mut separated = vec![]; let mut separators = vec![]; - if let Some(first) = - self.try_select(|node| node.is_rule_with_kind(RuleKind::UsingDeconstructionSymbol))? - { + if let Some(first) = self.try_select(|node| { + node.is_nonterminal_with_kind(NonTerminalKind::UsingDeconstructionSymbol) + })? { separated.push(first); while let Some(separator) = - self.try_select(|node| node.is_token_with_kind(TokenKind::Comma))? + self.try_select(|node| node.is_terminal_with_kind(TerminalKind::Comma))? { separators.push(separator); - separated.push( - self.select(|node| { - node.is_rule_with_kind(RuleKind::UsingDeconstructionSymbol) - })?, - ); + separated.push(self.select(|node| { + node.is_nonterminal_with_kind(NonTerminalKind::UsingDeconstructionSymbol) + })?); } } @@ -2712,22 +3048,23 @@ impl Selector { } impl Selector { - fn inheritance_types(&mut self) -> Result>>> { + fn inheritance_types(&mut self) -> Result>>> { let mut separated = vec![]; let mut separators = vec![]; if let Some(first) = - self.try_select(|node| node.is_rule_with_kind(RuleKind::InheritanceType))? + self.try_select(|node| node.is_nonterminal_with_kind(NonTerminalKind::InheritanceType))? { separated.push(first); while let Some(separator) = - self.try_select(|node| node.is_token_with_kind(TokenKind::Comma))? + self.try_select(|node| node.is_terminal_with_kind(TerminalKind::Comma))? { separators.push(separator); - separated - .push(self.select(|node| node.is_rule_with_kind(RuleKind::InheritanceType))?); + separated.push(self.select(|node| { + node.is_nonterminal_with_kind(NonTerminalKind::InheritanceType) + })?); } } @@ -2736,21 +3073,23 @@ impl Selector { } impl Selector { - fn enum_members(&mut self) -> Result>>> { + fn enum_members(&mut self) -> Result>>> { let mut separated = vec![]; let mut separators = vec![]; if let Some(first) = - self.try_select(|node| node.is_token_with_kind(TokenKind::Identifier))? + self.try_select(|node| node.is_terminal_with_kind(TerminalKind::Identifier))? { separated.push(first); while let Some(separator) = - self.try_select(|node| node.is_token_with_kind(TokenKind::Comma))? + self.try_select(|node| node.is_terminal_with_kind(TerminalKind::Comma))? { separators.push(separator); - separated.push(self.select(|node| node.is_token_with_kind(TokenKind::Identifier))?); + separated.push( + self.select(|node| node.is_terminal_with_kind(TerminalKind::Identifier))?, + ); } } @@ -2759,19 +3098,23 @@ impl Selector { } impl Selector { - fn parameters(&mut self) -> Result>>> { + fn parameters(&mut self) -> Result>>> { let mut separated = vec![]; let mut separators = vec![]; - if let Some(first) = self.try_select(|node| node.is_rule_with_kind(RuleKind::Parameter))? { + if let Some(first) = + self.try_select(|node| node.is_nonterminal_with_kind(NonTerminalKind::Parameter))? + { separated.push(first); while let Some(separator) = - self.try_select(|node| node.is_token_with_kind(TokenKind::Comma))? + self.try_select(|node| node.is_terminal_with_kind(TerminalKind::Comma))? { separators.push(separator); - separated.push(self.select(|node| node.is_rule_with_kind(RuleKind::Parameter))?); + separated.push( + self.select(|node| node.is_nonterminal_with_kind(NonTerminalKind::Parameter))?, + ); } } @@ -2780,22 +3123,23 @@ impl Selector { } impl Selector { - fn override_paths(&mut self) -> Result>>> { + fn override_paths(&mut self) -> Result>>> { let mut separated = vec![]; let mut separators = vec![]; if let Some(first) = - self.try_select(|node| node.is_rule_with_kind(RuleKind::IdentifierPath))? + self.try_select(|node| node.is_nonterminal_with_kind(NonTerminalKind::IdentifierPath))? { separated.push(first); while let Some(separator) = - self.try_select(|node| node.is_token_with_kind(TokenKind::Comma))? + self.try_select(|node| node.is_terminal_with_kind(TerminalKind::Comma))? { separators.push(separator); - separated - .push(self.select(|node| node.is_rule_with_kind(RuleKind::IdentifierPath))?); + separated.push(self.select(|node| { + node.is_nonterminal_with_kind(NonTerminalKind::IdentifierPath) + })?); } } @@ -2804,22 +3148,23 @@ impl Selector { } impl Selector { - fn event_parameters(&mut self) -> Result>>> { + fn event_parameters(&mut self) -> Result>>> { let mut separated = vec![]; let mut separators = vec![]; if let Some(first) = - self.try_select(|node| node.is_rule_with_kind(RuleKind::EventParameter))? + self.try_select(|node| node.is_nonterminal_with_kind(NonTerminalKind::EventParameter))? { separated.push(first); while let Some(separator) = - self.try_select(|node| node.is_token_with_kind(TokenKind::Comma))? + self.try_select(|node| node.is_terminal_with_kind(TerminalKind::Comma))? { separators.push(separator); - separated - .push(self.select(|node| node.is_rule_with_kind(RuleKind::EventParameter))?); + separated.push(self.select(|node| { + node.is_nonterminal_with_kind(NonTerminalKind::EventParameter) + })?); } } @@ -2828,22 +3173,23 @@ impl Selector { } impl Selector { - fn error_parameters(&mut self) -> Result>>> { + fn error_parameters(&mut self) -> Result>>> { let mut separated = vec![]; let mut separators = vec![]; if let Some(first) = - self.try_select(|node| node.is_rule_with_kind(RuleKind::ErrorParameter))? + self.try_select(|node| node.is_nonterminal_with_kind(NonTerminalKind::ErrorParameter))? { separated.push(first); while let Some(separator) = - self.try_select(|node| node.is_token_with_kind(TokenKind::Comma))? + self.try_select(|node| node.is_terminal_with_kind(TerminalKind::Comma))? { separators.push(separator); - separated - .push(self.select(|node| node.is_rule_with_kind(RuleKind::ErrorParameter))?); + separated.push(self.select(|node| { + node.is_nonterminal_with_kind(NonTerminalKind::ErrorParameter) + })?); } } @@ -2852,22 +3198,23 @@ impl Selector { } impl Selector { - fn assembly_flags(&mut self) -> Result>>> { + fn assembly_flags(&mut self) -> Result>>> { let mut separated = vec![]; let mut separators = vec![]; if let Some(first) = - self.try_select(|node| node.is_rule_with_kind(RuleKind::StringLiteral))? + self.try_select(|node| node.is_nonterminal_with_kind(NonTerminalKind::StringLiteral))? { separated.push(first); while let Some(separator) = - self.try_select(|node| node.is_token_with_kind(TokenKind::Comma))? + self.try_select(|node| node.is_terminal_with_kind(TerminalKind::Comma))? { separators.push(separator); - separated - .push(self.select(|node| node.is_rule_with_kind(RuleKind::StringLiteral))?); + separated.push(self.select(|node| { + node.is_nonterminal_with_kind(NonTerminalKind::StringLiteral) + })?); } } @@ -2876,25 +3223,25 @@ impl Selector { } impl Selector { - fn tuple_deconstruction_elements(&mut self) -> Result>>> { + fn tuple_deconstruction_elements( + &mut self, + ) -> Result>>> { let mut separated = vec![]; let mut separators = vec![]; - if let Some(first) = - self.try_select(|node| node.is_rule_with_kind(RuleKind::TupleDeconstructionElement))? - { + if let Some(first) = self.try_select(|node| { + node.is_nonterminal_with_kind(NonTerminalKind::TupleDeconstructionElement) + })? { separated.push(first); while let Some(separator) = - self.try_select(|node| node.is_token_with_kind(TokenKind::Comma))? + self.try_select(|node| node.is_terminal_with_kind(TerminalKind::Comma))? { separators.push(separator); - separated.push( - self.select(|node| { - node.is_rule_with_kind(RuleKind::TupleDeconstructionElement) - })?, - ); + separated.push(self.select(|node| { + node.is_nonterminal_with_kind(NonTerminalKind::TupleDeconstructionElement) + })?); } } @@ -2903,19 +3250,23 @@ impl Selector { } impl Selector { - fn positional_arguments(&mut self) -> Result>>> { + fn positional_arguments(&mut self) -> Result>>> { let mut separated = vec![]; let mut separators = vec![]; - if let Some(first) = self.try_select(|node| node.is_rule_with_kind(RuleKind::Expression))? { + if let Some(first) = + self.try_select(|node| node.is_nonterminal_with_kind(NonTerminalKind::Expression))? + { separated.push(first); while let Some(separator) = - self.try_select(|node| node.is_token_with_kind(TokenKind::Comma))? + self.try_select(|node| node.is_terminal_with_kind(TerminalKind::Comma))? { separators.push(separator); - separated.push(self.select(|node| node.is_rule_with_kind(RuleKind::Expression))?); + separated.push( + self.select(|node| node.is_nonterminal_with_kind(NonTerminalKind::Expression))?, + ); } } @@ -2924,22 +3275,23 @@ impl Selector { } impl Selector { - fn named_arguments(&mut self) -> Result>>> { + fn named_arguments(&mut self) -> Result>>> { let mut separated = vec![]; let mut separators = vec![]; if let Some(first) = - self.try_select(|node| node.is_rule_with_kind(RuleKind::NamedArgument))? + self.try_select(|node| node.is_nonterminal_with_kind(NonTerminalKind::NamedArgument))? { separated.push(first); while let Some(separator) = - self.try_select(|node| node.is_token_with_kind(TokenKind::Comma))? + self.try_select(|node| node.is_terminal_with_kind(TerminalKind::Comma))? { separators.push(separator); - separated - .push(self.select(|node| node.is_rule_with_kind(RuleKind::NamedArgument))?); + separated.push(self.select(|node| { + node.is_nonterminal_with_kind(NonTerminalKind::NamedArgument) + })?); } } @@ -2948,22 +3300,23 @@ impl Selector { } impl Selector { - fn call_options(&mut self) -> Result>>> { + fn call_options(&mut self) -> Result>>> { let mut separated = vec![]; let mut separators = vec![]; if let Some(first) = - self.try_select(|node| node.is_rule_with_kind(RuleKind::NamedArgument))? + self.try_select(|node| node.is_nonterminal_with_kind(NonTerminalKind::NamedArgument))? { separated.push(first); while let Some(separator) = - self.try_select(|node| node.is_token_with_kind(TokenKind::Comma))? + self.try_select(|node| node.is_terminal_with_kind(TerminalKind::Comma))? { separators.push(separator); - separated - .push(self.select(|node| node.is_rule_with_kind(RuleKind::NamedArgument))?); + separated.push(self.select(|node| { + node.is_nonterminal_with_kind(NonTerminalKind::NamedArgument) + })?); } } @@ -2972,19 +3325,23 @@ impl Selector { } impl Selector { - fn tuple_values(&mut self) -> Result>>> { + fn tuple_values(&mut self) -> Result>>> { let mut separated = vec![]; let mut separators = vec![]; - if let Some(first) = self.try_select(|node| node.is_rule_with_kind(RuleKind::TupleValue))? { + if let Some(first) = + self.try_select(|node| node.is_nonterminal_with_kind(NonTerminalKind::TupleValue))? + { separated.push(first); while let Some(separator) = - self.try_select(|node| node.is_token_with_kind(TokenKind::Comma))? + self.try_select(|node| node.is_terminal_with_kind(TerminalKind::Comma))? { separators.push(separator); - separated.push(self.select(|node| node.is_rule_with_kind(RuleKind::TupleValue))?); + separated.push( + self.select(|node| node.is_nonterminal_with_kind(NonTerminalKind::TupleValue))?, + ); } } @@ -2993,19 +3350,23 @@ impl Selector { } impl Selector { - fn array_values(&mut self) -> Result>>> { + fn array_values(&mut self) -> Result>>> { let mut separated = vec![]; let mut separators = vec![]; - if let Some(first) = self.try_select(|node| node.is_rule_with_kind(RuleKind::Expression))? { + if let Some(first) = + self.try_select(|node| node.is_nonterminal_with_kind(NonTerminalKind::Expression))? + { separated.push(first); while let Some(separator) = - self.try_select(|node| node.is_token_with_kind(TokenKind::Comma))? + self.try_select(|node| node.is_terminal_with_kind(TerminalKind::Comma))? { separators.push(separator); - separated.push(self.select(|node| node.is_rule_with_kind(RuleKind::Expression))?); + separated.push( + self.select(|node| node.is_nonterminal_with_kind(NonTerminalKind::Expression))?, + ); } } @@ -3014,21 +3375,23 @@ impl Selector { } impl Selector { - fn identifier_path(&mut self) -> Result>>> { + fn identifier_path(&mut self) -> Result>>> { let mut separated = vec![]; let mut separators = vec![]; if let Some(first) = - self.try_select(|node| node.is_token_with_kind(TokenKind::Identifier))? + self.try_select(|node| node.is_terminal_with_kind(TerminalKind::Identifier))? { separated.push(first); while let Some(separator) = - self.try_select(|node| node.is_token_with_kind(TokenKind::Period))? + self.try_select(|node| node.is_terminal_with_kind(TerminalKind::Period))? { separators.push(separator); - separated.push(self.select(|node| node.is_token_with_kind(TokenKind::Identifier))?); + separated.push( + self.select(|node| node.is_terminal_with_kind(TerminalKind::Identifier))?, + ); } } @@ -3037,22 +3400,23 @@ impl Selector { } impl Selector { - fn yul_parameters(&mut self) -> Result>>> { + fn yul_parameters(&mut self) -> Result>>> { let mut separated = vec![]; let mut separators = vec![]; if let Some(first) = - self.try_select(|node| node.is_token_with_kind(TokenKind::YulIdentifier))? + self.try_select(|node| node.is_terminal_with_kind(TerminalKind::YulIdentifier))? { separated.push(first); while let Some(separator) = - self.try_select(|node| node.is_token_with_kind(TokenKind::Comma))? + self.try_select(|node| node.is_terminal_with_kind(TerminalKind::Comma))? { separators.push(separator); - separated - .push(self.select(|node| node.is_token_with_kind(TokenKind::YulIdentifier))?); + separated.push( + self.select(|node| node.is_terminal_with_kind(TerminalKind::YulIdentifier))?, + ); } } @@ -3061,22 +3425,23 @@ impl Selector { } impl Selector { - fn yul_return_variables(&mut self) -> Result>>> { + fn yul_return_variables(&mut self) -> Result>>> { let mut separated = vec![]; let mut separators = vec![]; if let Some(first) = - self.try_select(|node| node.is_token_with_kind(TokenKind::YulIdentifier))? + self.try_select(|node| node.is_terminal_with_kind(TerminalKind::YulIdentifier))? { separated.push(first); while let Some(separator) = - self.try_select(|node| node.is_token_with_kind(TokenKind::Comma))? + self.try_select(|node| node.is_terminal_with_kind(TerminalKind::Comma))? { separators.push(separator); - separated - .push(self.select(|node| node.is_token_with_kind(TokenKind::YulIdentifier))?); + separated.push( + self.select(|node| node.is_terminal_with_kind(TerminalKind::YulIdentifier))?, + ); } } @@ -3085,22 +3450,23 @@ impl Selector { } impl Selector { - fn yul_arguments(&mut self) -> Result>>> { + fn yul_arguments(&mut self) -> Result>>> { let mut separated = vec![]; let mut separators = vec![]; if let Some(first) = - self.try_select(|node| node.is_rule_with_kind(RuleKind::YulExpression))? + self.try_select(|node| node.is_nonterminal_with_kind(NonTerminalKind::YulExpression))? { separated.push(first); while let Some(separator) = - self.try_select(|node| node.is_token_with_kind(TokenKind::Comma))? + self.try_select(|node| node.is_terminal_with_kind(TerminalKind::Comma))? { separators.push(separator); - separated - .push(self.select(|node| node.is_rule_with_kind(RuleKind::YulExpression))?); + separated.push(self.select(|node| { + node.is_nonterminal_with_kind(NonTerminalKind::YulExpression) + })?); } } @@ -3109,19 +3475,23 @@ impl Selector { } impl Selector { - fn yul_paths(&mut self) -> Result>>> { + fn yul_paths(&mut self) -> Result>>> { let mut separated = vec![]; let mut separators = vec![]; - if let Some(first) = self.try_select(|node| node.is_rule_with_kind(RuleKind::YulPath))? { + if let Some(first) = + self.try_select(|node| node.is_nonterminal_with_kind(NonTerminalKind::YulPath))? + { separated.push(first); while let Some(separator) = - self.try_select(|node| node.is_token_with_kind(TokenKind::Comma))? + self.try_select(|node| node.is_terminal_with_kind(TerminalKind::Comma))? { separators.push(separator); - separated.push(self.select(|node| node.is_rule_with_kind(RuleKind::YulPath))?); + separated.push( + self.select(|node| node.is_nonterminal_with_kind(NonTerminalKind::YulPath))?, + ); } } @@ -3130,22 +3500,23 @@ impl Selector { } impl Selector { - fn yul_path(&mut self) -> Result>>> { + fn yul_path(&mut self) -> Result>>> { let mut separated = vec![]; let mut separators = vec![]; - if let Some(first) = - self.try_select(|node| node.is_rule_with_kind(RuleKind::YulPathComponent))? + if let Some(first) = self + .try_select(|node| node.is_nonterminal_with_kind(NonTerminalKind::YulPathComponent))? { separated.push(first); while let Some(separator) = - self.try_select(|node| node.is_token_with_kind(TokenKind::Period))? + self.try_select(|node| node.is_terminal_with_kind(TerminalKind::Period))? { separators.push(separator); - separated - .push(self.select(|node| node.is_rule_with_kind(RuleKind::YulPathComponent))?); + separated.push(self.select(|node| { + node.is_nonterminal_with_kind(NonTerminalKind::YulPathComponent) + })?); } } @@ -3163,7 +3534,7 @@ struct Selector { } impl Selector { - fn new(node: &RuleNode) -> Self { + fn new(node: &NonTerminalNode) -> Self { Self { node: Rc::clone(&node.0), index: 0, @@ -3173,7 +3544,7 @@ impl Selector { fn select( &mut self, filter: impl FnOnce(&RustNode) -> bool, - ) -> Result> { + ) -> Result> { match self.try_select(filter)? { Some(node) => Ok(node), None => Error::MissingChild(self.index).into(), @@ -3183,7 +3554,7 @@ impl Selector { fn try_select( &mut self, filter: impl FnOnce(&RustNode) -> bool, - ) -> Result>> { + ) -> Result>> { while let Some(child) = self.node.children.get(self.index) { match child { node if node.is_trivia() => { @@ -3192,9 +3563,9 @@ impl Selector { continue; } RustLabeledNode { - label: _, - node: RustNode::Token(token), - } if matches!(token.kind, TokenKind::SKIPPED) => { + node: RustNode::Terminal(terminal), + .. + } if matches!(terminal.kind, TerminalKind::SKIPPED) => { return Error::SkippedToken(self.index).into(); } labeled if filter(labeled) => { @@ -3224,8 +3595,8 @@ type Result = std::result::Result; #[derive(Debug, thiserror::Error)] enum Error { // Should not theoretically happen, since we're only called from our own generated AST types. - #[error("Unexpected parent node with RuleKind '{0}'.")] - UnexpectedParent(RuleKind), + #[error("Unexpected parent node with NonTerminalKind '{0}'.")] + UnexpectedParent(NonTerminalKind), // Should not theoretically happen, since we're only called from our own generated AST types. #[error("Unexpected trailing children at index '{0}'.")] diff --git a/crates/solidity/outputs/cargo/slang_solidity/src/generated/napi_interface/mod.rs b/crates/solidity/outputs/cargo/slang_solidity/src/generated/napi_interface/mod.rs index 2035b95f64..d2ab8551a8 100644 --- a/crates/solidity/outputs/cargo/slang_solidity/src/generated/napi_interface/mod.rs +++ b/crates/solidity/outputs/cargo/slang_solidity/src/generated/napi_interface/mod.rs @@ -11,18 +11,18 @@ pub mod text_index; pub mod ast_selectors; type RustCursor = crate::cursor::Cursor; -type RustLabeledNode = crate::cst::LabeledNode; +type RustLabeledNode = crate::cst::Edge; type RustNode = crate::cst::Node; type RustParseError = crate::parse_error::ParseError; type RustParseOutput = crate::parse_output::ParseOutput; type RustQuery = crate::query::Query; type RustQueryResult = crate::query::QueryResult; type RustQueryResultIterator = crate::query::QueryResultIterator; -type RustRuleNode = crate::cst::RuleNode; +type RustRuleNode = crate::cst::NonTerminalNode; type RustTextIndex = crate::text_index::TextIndex; type RustTextRange = crate::text_index::TextRange; -type RustTokenNode = crate::cst::TokenNode; +type RustTokenNode = crate::cst::TerminalNode; -type RuleKind = crate::kinds::RuleKind; -type TokenKind = crate::kinds::TokenKind; -type NodeLabel = crate::kinds::NodeLabel; +type NonTerminalKind = crate::kinds::NonTerminalKind; +type TerminalKind = crate::kinds::TerminalKind; +type EdgeLabel = crate::kinds::EdgeLabel; diff --git a/crates/solidity/outputs/cargo/slang_solidity/src/generated/napi_interface/parse_output.rs b/crates/solidity/outputs/cargo/slang_solidity/src/generated/napi_interface/parse_output.rs index dd162e213b..573b75ab1f 100644 --- a/crates/solidity/outputs/cargo/slang_solidity/src/generated/napi_interface/parse_output.rs +++ b/crates/solidity/outputs/cargo/slang_solidity/src/generated/napi_interface/parse_output.rs @@ -3,7 +3,7 @@ use napi::Either; use napi_derive::napi; -use crate::napi_interface::cst::{NAPINodeExtensions, RuleNode, TokenNode}; +use crate::napi_interface::cst::{NAPINodeExtensions, NonTerminalNode, TerminalNode}; use crate::napi_interface::{cursor, parse_error, RustParseOutput}; #[napi(namespace = "parse_output")] @@ -18,7 +18,7 @@ impl From for ParseOutput { #[napi(namespace = "parse_output")] impl ParseOutput { #[napi(ts_return_type = "cst.Node", catch_unwind)] - pub fn tree(&self) -> Either { + pub fn tree(&self) -> Either { self.0.tree().into_js_either_node() } diff --git a/crates/solidity/outputs/cargo/slang_solidity/src/generated/parse_error.rs b/crates/solidity/outputs/cargo/slang_solidity/src/generated/parse_error.rs index f6c3d9b52c..4553de4e78 100644 --- a/crates/solidity/outputs/cargo/slang_solidity/src/generated/parse_error.rs +++ b/crates/solidity/outputs/cargo/slang_solidity/src/generated/parse_error.rs @@ -2,13 +2,13 @@ use std::collections::BTreeSet; -use crate::kinds::TokenKind; +use crate::kinds::TerminalKind; use crate::text_index::{TextRange, TextRangeExtensions}; #[derive(Debug, PartialEq, Eq, Clone)] pub struct ParseError { pub(crate) text_range: TextRange, - pub(crate) tokens_that_would_have_allowed_more_progress: Vec, + pub(crate) tokens_that_would_have_allowed_more_progress: Vec, } impl ParseError { @@ -24,7 +24,7 @@ impl ParseError { tokens_that_would_have_allowed_more_progress .into_iter() - .map(TokenKind::to_string) + .map(TerminalKind::to_string) .collect() } @@ -36,7 +36,7 @@ impl ParseError { impl ParseError { pub(crate) fn new( text_range: TextRange, - tokens_that_would_have_allowed_more_progress: Vec, + tokens_that_would_have_allowed_more_progress: Vec, ) -> Self { Self { text_range, diff --git a/crates/solidity/outputs/cargo/slang_solidity/src/generated/parser_support/choice_helper.rs b/crates/solidity/outputs/cargo/slang_solidity/src/generated/parser_support/choice_helper.rs index e24443c826..9efafc325e 100644 --- a/crates/solidity/outputs/cargo/slang_solidity/src/generated/parser_support/choice_helper.rs +++ b/crates/solidity/outputs/cargo/slang_solidity/src/generated/parser_support/choice_helper.rs @@ -4,7 +4,7 @@ use std::mem; use std::ops::ControlFlow; use crate::cst; -use crate::kinds::TokenKind; +use crate::kinds::TerminalKind; use crate::parse_error::ParseError; use crate::parser_support::context::{Marker, ParserContext}; use crate::parser_support::ParserResult; @@ -139,7 +139,9 @@ pub fn total_not_skipped_span(result: &ParserResult) -> usize { .iter() .flat_map(|child| child.cursor_with_offset(TextIndex::ZERO)) .filter_map(|node| match node { - cst::Node::Token(token) if token.kind != TokenKind::SKIPPED => Some(token.text.len()), + cst::Node::Terminal(terminal) if terminal.kind != TerminalKind::SKIPPED => { + Some(terminal.text.len()) + } _ => None, }) .sum() diff --git a/crates/solidity/outputs/cargo/slang_solidity/src/generated/parser_support/context.rs b/crates/solidity/outputs/cargo/slang_solidity/src/generated/parser_support/context.rs index 51a32d1632..6752a6f422 100644 --- a/crates/solidity/outputs/cargo/slang_solidity/src/generated/parser_support/context.rs +++ b/crates/solidity/outputs/cargo/slang_solidity/src/generated/parser_support/context.rs @@ -3,7 +3,7 @@ use std::mem; use std::ops::Range; -use crate::kinds::TokenKind; +use crate::kinds::TerminalKind; use crate::parse_error::ParseError; use crate::text_index::TextIndex; @@ -13,7 +13,7 @@ pub struct ParserContext<'s> { position: TextIndex, undo_position: Option, errors: Vec, - closing_delimiters: Vec, + closing_delimiters: Vec, } #[derive(Copy, Clone)] @@ -63,7 +63,10 @@ impl<'s> ParserContext<'s> { } /// Creates a RAII guard that will pop the closing delimiter when dropped. - pub(crate) fn open_delim<'a>(&'a mut self, closing_delim: TokenKind) -> DelimiterGuard<'a, 's> { + pub(crate) fn open_delim<'a>( + &'a mut self, + closing_delim: TerminalKind, + ) -> DelimiterGuard<'a, 's> { self.closing_delimiters.push(closing_delim); DelimiterGuard { @@ -72,7 +75,7 @@ impl<'s> ParserContext<'s> { } } - pub fn closing_delimiters(&self) -> &[TokenKind] { + pub fn closing_delimiters(&self) -> &[TerminalKind] { &self.closing_delimiters } @@ -114,7 +117,7 @@ impl<'s> ParserContext<'s> { pub(crate) struct DelimiterGuard<'a, 's> { pub(crate) input: &'a mut ParserContext<'s>, - closing_delim: TokenKind, + closing_delim: TerminalKind, } impl Drop for DelimiterGuard<'_, '_> { diff --git a/crates/solidity/outputs/cargo/slang_solidity/src/generated/parser_support/parser_function.rs b/crates/solidity/outputs/cargo/slang_solidity/src/generated/parser_support/parser_function.rs index c38482610d..4721491788 100644 --- a/crates/solidity/outputs/cargo/slang_solidity/src/generated/parser_support/parser_function.rs +++ b/crates/solidity/outputs/cargo/slang_solidity/src/generated/parser_support/parser_function.rs @@ -2,8 +2,8 @@ use std::rc::Rc; -use crate::cst::{self, LabeledNode}; -use crate::kinds::TokenKind; +use crate::cst::{self, Edge}; +use crate::kinds::TerminalKind; use crate::lexer::Lexer; use crate::parse_error::ParseError; use crate::parse_output::ParseOutput; @@ -42,11 +42,13 @@ where _ => None, }; - if let (cst::Node::Rule(rule), Some(eof_trivia)) = (&mut topmost.node, eof_trivia) { - let mut new_children = rule.children.clone(); + if let (cst::Node::NonTerminal(nonterminal), Some(eof_trivia)) = + (&mut topmost.node, eof_trivia) + { + let mut new_children = nonterminal.children.clone(); new_children.extend(eof_trivia); - topmost.node = cst::Node::rule(rule.kind, new_children); + topmost.node = cst::Node::nonterminal(nonterminal.kind, new_children); } } @@ -57,7 +59,7 @@ where ParserResult::PrattOperatorMatch(..) => unreachable!("PrattOperatorMatch is internal"), ParserResult::NoMatch(no_match) => ParseOutput { - parse_tree: cst::Node::token(TokenKind::SKIPPED, input.to_string()), + parse_tree: cst::Node::terminal(TerminalKind::SKIPPED, input.to_string()), errors: vec![ParseError::new( TextIndex::ZERO..input.into(), no_match.expected_tokens, @@ -82,8 +84,8 @@ where }) => (nodes, vec![expected]), }; - let topmost_rule = match &nodes[..] { - [LabeledNode { node: cst::Node::Rule(rule), ..} ] => Rc::clone(rule), + let topmost_node = match &nodes[..] { + [Edge { node: cst::Node::NonTerminal(nonterminal), ..} ] => Rc::clone(nonterminal), [_] => unreachable!( "(Incomplete)Match at the top level of a parser is not a Rule node" ), @@ -99,24 +101,24 @@ where // so needs a separate check here. if start.utf8 < input.len() || is_incomplete || is_recovering { let start = if is_recovering { - topmost_rule.text_len + topmost_node.text_len } else { start }; let skipped_node = - cst::Node::token(TokenKind::SKIPPED, input[start.utf8..].to_string()); - let mut new_children = topmost_rule.children.clone(); - new_children.push(LabeledNode::anonymous(skipped_node)); + cst::Node::terminal(TerminalKind::SKIPPED, input[start.utf8..].to_string()); + let mut new_children = topmost_node.children.clone(); + new_children.push(Edge::anonymous(skipped_node)); let mut errors = stream.into_errors(); errors.push(ParseError::new(start..input.into(), expected_tokens)); ParseOutput { - parse_tree: cst::Node::rule(topmost_rule.kind, new_children), + parse_tree: cst::Node::nonterminal(topmost_node.kind, new_children), errors, } } else { - let parse_tree = cst::Node::Rule(topmost_rule); + let parse_tree = cst::Node::NonTerminal(topmost_node); let errors = stream.into_errors(); // Sanity check: Make sure that succesful parse is equivalent to not having any SKIPPED nodes @@ -124,7 +126,9 @@ where errors.is_empty(), parse_tree .cursor_with_offset(TextIndex::ZERO) - .all(|node| node.as_token_with_kind(TokenKind::SKIPPED).is_none()) + .all(|node| node + .as_terminal_with_kind(TerminalKind::SKIPPED) + .is_none()) ); ParseOutput { parse_tree, errors } diff --git a/crates/solidity/outputs/cargo/slang_solidity/src/generated/parser_support/parser_result.rs b/crates/solidity/outputs/cargo/slang_solidity/src/generated/parser_support/parser_result.rs index f86d384932..f9a192912e 100644 --- a/crates/solidity/outputs/cargo/slang_solidity/src/generated/parser_support/parser_result.rs +++ b/crates/solidity/outputs/cargo/slang_solidity/src/generated/parser_support/parser_result.rs @@ -2,10 +2,10 @@ use std::ops::ControlFlow; -use metaslang_cst::TerminalKind; +use metaslang_cst::TerminalKind as _; -use crate::cst::{self, LabeledNode, Node}; -use crate::kinds::{NodeLabel, RuleKind, TokenKind}; +use crate::cst::{self, Edge, Node}; +use crate::kinds::{EdgeLabel, NonTerminalKind, TerminalKind}; use crate::text_index::TextIndex; #[derive(PartialEq, Eq, Clone, Debug)] @@ -26,7 +26,7 @@ impl Default for ParserResult { } impl ParserResult { - pub fn r#match(nodes: Vec, expected_tokens: Vec) -> Self { + pub fn r#match(nodes: Vec, expected_tokens: Vec) -> Self { ParserResult::Match(Match::new(nodes, expected_tokens)) } @@ -34,7 +34,7 @@ impl ParserResult { ParserResult::PrattOperatorMatch(PrattOperatorMatch::new(elements)) } - pub fn incomplete_match(nodes: Vec, expected_tokens: Vec) -> Self { + pub fn incomplete_match(nodes: Vec, expected_tokens: Vec) -> Self { ParserResult::IncompleteMatch(IncompleteMatch::new(nodes, expected_tokens)) } @@ -43,29 +43,29 @@ impl ParserResult { Self::no_match(vec![]) } - pub fn no_match(expected_tokens: Vec) -> Self { + pub fn no_match(expected_tokens: Vec) -> Self { ParserResult::NoMatch(NoMatch::new(expected_tokens)) } #[must_use] - pub fn with_kind(self, new_kind: RuleKind) -> ParserResult { + pub fn with_kind(self, new_kind: NonTerminalKind) -> ParserResult { match self { ParserResult::Match(r#match) => ParserResult::r#match( - vec![LabeledNode::anonymous(cst::Node::rule( + vec![Edge::anonymous(cst::Node::nonterminal( new_kind, r#match.nodes, ))], r#match.expected_tokens, ), ParserResult::IncompleteMatch(incomplete_match) => ParserResult::incomplete_match( - vec![LabeledNode::anonymous(cst::Node::rule( + vec![Edge::anonymous(cst::Node::nonterminal( new_kind, incomplete_match.nodes, ))], incomplete_match.expected_tokens, ), ParserResult::SkippedUntil(skipped) => ParserResult::SkippedUntil(SkippedUntil { - nodes: vec![LabeledNode::anonymous(cst::Node::rule( + nodes: vec![Edge::anonymous(cst::Node::nonterminal( new_kind, skipped.nodes, ))], @@ -73,14 +73,14 @@ impl ParserResult { }), ParserResult::NoMatch(_) => self, ParserResult::PrattOperatorMatch(_) => { - unreachable!("PrattOperatorMatch cannot be converted to a rule") + unreachable!("PrattOperatorMatch cannot be converted to a nonterminal") } } } #[must_use] - pub fn with_label(mut self, label: NodeLabel) -> ParserResult { - if let Some(LabeledNode { + pub fn with_label(mut self, label: EdgeLabel) -> ParserResult { + if let Some(Edge { label: prev_label, .. }) = self.significant_node_mut() { @@ -89,7 +89,7 @@ impl ParserResult { // Also allow to name a single trivia token node else if let ParserResult::Match(Match { nodes, .. }) = &mut self { if let [node] = nodes.as_mut_slice() { - if node.as_token().is_some_and(|tok| tok.kind.is_trivia()) { + if node.as_terminal().is_some_and(|tok| tok.kind.is_trivia()) { node.label = Some(label); } } @@ -99,7 +99,7 @@ impl ParserResult { } /// Returns a significant (non-trivia) node if there is exactly one. - pub(crate) fn significant_node_mut(&mut self) -> Option<&mut cst::LabeledNode> { + pub(crate) fn significant_node_mut(&mut self) -> Option<&mut cst::Edge> { let nodes = match self { ParserResult::Match(r#match) => &mut r#match.nodes[..], ParserResult::IncompleteMatch(incomplete_match) => &mut incomplete_match.nodes[..], @@ -123,13 +123,13 @@ impl ParserResult { #[derive(PartialEq, Eq, Clone, Debug)] pub struct Match { - pub nodes: Vec, + pub nodes: Vec, /// Tokens that would have allowed for more progress. Collected for the purposes of error reporting. - pub expected_tokens: Vec, + pub expected_tokens: Vec, } impl Match { - pub fn new(nodes: Vec, expected_tokens: Vec) -> Self { + pub fn new(nodes: Vec, expected_tokens: Vec) -> Self { Self { nodes, expected_tokens, @@ -140,41 +140,41 @@ impl Match { self.nodes .iter() .flat_map(|node| node.cursor_with_offset(TextIndex::ZERO)) - .all(|node| node.as_token_with_kind(TokenKind::SKIPPED).is_none()) + .all(|node| node.as_terminal_with_kind(TerminalKind::SKIPPED).is_none()) } } #[derive(PartialEq, Eq, Clone, Debug)] pub enum PrattElement { Expression { - nodes: Vec, + nodes: Vec, }, Prefix { - kind: RuleKind, - nodes: Vec, + kind: NonTerminalKind, + nodes: Vec, right: u8, }, Binary { - kind: RuleKind, - nodes: Vec, + kind: NonTerminalKind, + nodes: Vec, left: u8, right: u8, }, Postfix { - kind: RuleKind, - nodes: Vec, + kind: NonTerminalKind, + nodes: Vec, left: u8, }, } impl PrattElement { - pub fn into_nodes(self) -> Vec { + pub fn into_nodes(self) -> Vec { match self { Self::Expression { nodes } => nodes, Self::Binary { kind, nodes, .. } | Self::Prefix { kind, nodes, .. } | Self::Postfix { kind, nodes, .. } => { - vec![LabeledNode::anonymous(cst::Node::rule(kind, nodes))] + vec![Edge::anonymous(cst::Node::nonterminal(kind, nodes))] } } } @@ -193,13 +193,13 @@ impl PrattOperatorMatch { #[derive(PartialEq, Eq, Clone, Debug)] pub struct IncompleteMatch { - pub nodes: Vec, + pub nodes: Vec, /// Tokens that would have allowed for more progress. Collected for the purposes of error reporting. - pub expected_tokens: Vec, + pub expected_tokens: Vec, } impl IncompleteMatch { - pub fn new(nodes: Vec, expected_tokens: Vec) -> Self { + pub fn new(nodes: Vec, expected_tokens: Vec) -> Self { Self { nodes, expected_tokens, @@ -214,7 +214,9 @@ impl IncompleteMatch { .flat_map(|node| node.cursor_with_offset(TextIndex::ZERO)) .try_fold(0u8, |mut acc, node| { match node { - Node::Token(tok) if tok.kind != TokenKind::SKIPPED && !tok.kind.is_trivia() => { + Node::Terminal(tok) + if tok.kind != TerminalKind::SKIPPED && !tok.kind.is_trivia() => + { acc += 1; } _ => {} @@ -237,22 +239,22 @@ impl IncompleteMatch { #[derive(PartialEq, Eq, Clone, Debug)] pub struct NoMatch { /// Tokens that would have allowed for more progress. Collected for the purposes of error reporting. - pub expected_tokens: Vec, + pub expected_tokens: Vec, } impl NoMatch { - pub fn new(expected_tokens: Vec) -> Self { + pub fn new(expected_tokens: Vec) -> Self { Self { expected_tokens } } } #[derive(PartialEq, Eq, Clone, Debug)] pub struct SkippedUntil { - pub nodes: Vec, + pub nodes: Vec, /// Skipped text following the last node pub skipped: String, /// At which token was the stream pointing at when we bailed - pub found: TokenKind, + pub found: TerminalKind, /// Token we expected to skip until - pub expected: TokenKind, + pub expected: TerminalKind, } diff --git a/crates/solidity/outputs/cargo/slang_solidity/src/generated/parser_support/precedence_helper.rs b/crates/solidity/outputs/cargo/slang_solidity/src/generated/parser_support/precedence_helper.rs index eee625e583..7d307a1c0d 100644 --- a/crates/solidity/outputs/cargo/slang_solidity/src/generated/parser_support/precedence_helper.rs +++ b/crates/solidity/outputs/cargo/slang_solidity/src/generated/parser_support/precedence_helper.rs @@ -1,7 +1,7 @@ // This file is generated automatically by infrastructure scripts. Please don't edit by hand. -use crate::cst::{self, LabeledNode}; -use crate::kinds::{NodeLabel, RuleKind}; +use crate::cst::{self, Edge}; +use crate::kinds::{EdgeLabel, NonTerminalKind}; use crate::parser_support::parser_result::PrattElement::{ self, Binary, Expression, Postfix, Prefix, }; @@ -10,7 +10,11 @@ use crate::parser_support::parser_result::{ParserResult, PrattOperatorMatch}; pub struct PrecedenceHelper; impl PrecedenceHelper { - pub fn to_prefix_operator(kind: RuleKind, right: u8, result: ParserResult) -> ParserResult { + pub fn to_prefix_operator( + kind: NonTerminalKind, + right: u8, + result: ParserResult, + ) -> ParserResult { match result { ParserResult::Match(r#match) => ParserResult::pratt_operator_match(vec![Prefix { nodes: r#match.nodes, @@ -24,7 +28,11 @@ impl PrecedenceHelper { } } - pub fn to_postfix_operator(kind: RuleKind, left: u8, result: ParserResult) -> ParserResult { + pub fn to_postfix_operator( + kind: NonTerminalKind, + left: u8, + result: ParserResult, + ) -> ParserResult { match result { ParserResult::Match(r#match) => ParserResult::pratt_operator_match(vec![Postfix { nodes: r#match.nodes, @@ -39,7 +47,7 @@ impl PrecedenceHelper { } pub fn to_binary_operator( - kind: RuleKind, + kind: NonTerminalKind, left: u8, right: u8, result: ParserResult, @@ -59,7 +67,10 @@ impl PrecedenceHelper { } #[allow(clippy::too_many_lines, clippy::redundant_else)] // Explicit on purpose, see below. - pub fn reduce_precedence_result(child_kind: RuleKind, result: ParserResult) -> ParserResult { + pub fn reduce_precedence_result( + child_kind: NonTerminalKind, + result: ParserResult, + ) -> ParserResult { // This requires some careful thinking. It could be more compact, // but I'm favouring obviousness here. That is also why there are // so many `unreachable!` - not only should they never be reached, @@ -151,23 +162,23 @@ impl PrecedenceHelper { // 2. Reduce the operator and it's child expressions to a new expression let make_expression = |left: Option, - kind: RuleKind, - nodes: Vec, + kind: NonTerminalKind, + nodes: Vec, right: Option| { assert!(left.is_some() || right.is_some()); let left_label = right .as_ref() - .map_or(NodeLabel::Operand, |_| NodeLabel::LeftOperand); + .map_or(EdgeLabel::Operand, |_| EdgeLabel::LeftOperand); let right_label = left .as_ref() - .map_or(NodeLabel::Operand, |_| NodeLabel::RightOperand); + .map_or(EdgeLabel::Operand, |_| EdgeLabel::RightOperand); let left_nodes = match left { Some(Expression { nodes }) => { - vec![LabeledNode { + vec![Edge { label: Some(left_label), - node: cst::Node::rule(child_kind, nodes), + node: cst::Node::nonterminal(child_kind, nodes), }] } None => vec![], @@ -176,9 +187,9 @@ impl PrecedenceHelper { let right_nodes = match right { Some(Expression { nodes }) => { - vec![LabeledNode { + vec![Edge { label: Some(right_label), - node: cst::Node::rule(child_kind, nodes), + node: cst::Node::nonterminal(child_kind, nodes), }] } None => vec![], @@ -188,9 +199,9 @@ impl PrecedenceHelper { let children = [left_nodes, nodes, right_nodes].concat(); Expression { - nodes: vec![LabeledNode { - label: Some(NodeLabel::Variant), - node: cst::Node::rule(kind, children), + nodes: vec![Edge { + label: Some(EdgeLabel::Variant), + node: cst::Node::nonterminal(kind, children), }], } }; diff --git a/crates/solidity/outputs/cargo/slang_solidity/src/generated/parser_support/recovery.rs b/crates/solidity/outputs/cargo/slang_solidity/src/generated/parser_support/recovery.rs index 76eed0ef80..7fceddc3ae 100644 --- a/crates/solidity/outputs/cargo/slang_solidity/src/generated/parser_support/recovery.rs +++ b/crates/solidity/outputs/cargo/slang_solidity/src/generated/parser_support/recovery.rs @@ -1,7 +1,7 @@ // This file is generated automatically by infrastructure scripts. Please don't edit by hand. use crate::cst; -use crate::kinds::{IsLexicalContext, TokenKind}; +use crate::kinds::{IsLexicalContext, TerminalKind}; use crate::lexer::{Lexer, ScannedToken}; use crate::parse_error::ParseError; use crate::parser_support::context::ParserContext; @@ -18,7 +18,7 @@ pub(crate) struct TokenAcceptanceThreshold(pub(crate) u8); fn opt_parse( input: &mut ParserContext<'_>, parse: impl Fn(&mut ParserContext<'_>) -> ParserResult, -) -> Vec { +) -> Vec { let start = input.position(); if let ParserResult::Match(r#match) = parse(input) { r#match.nodes @@ -40,7 +40,7 @@ impl ParserResult { self, input: &mut ParserContext<'_>, lexer: &L, - expected: TokenKind, + expected: TerminalKind, acceptance_threshold: TokenAcceptanceThreshold, ) -> ParserResult { enum ParseResultKind { @@ -122,8 +122,8 @@ impl ParserResult { pub(crate) fn skip_until_with_nested_delims( input: &mut ParserContext<'_>, lexer: &L, - until: TokenKind, -) -> Option<(TokenKind, TextRange)> { + until: TerminalKind, +) -> Option<(TerminalKind, TextRange)> { let delims = L::delimiters::(); let start = input.position(); diff --git a/crates/solidity/outputs/cargo/slang_solidity/src/generated/parser_support/separated_helper.rs b/crates/solidity/outputs/cargo/slang_solidity/src/generated/parser_support/separated_helper.rs index f107fd0cef..0c87c6aea2 100644 --- a/crates/solidity/outputs/cargo/slang_solidity/src/generated/parser_support/separated_helper.rs +++ b/crates/solidity/outputs/cargo/slang_solidity/src/generated/parser_support/separated_helper.rs @@ -1,7 +1,7 @@ // This file is generated automatically by infrastructure scripts. Please don't edit by hand. -use crate::cst::{self, LabeledNode}; -use crate::kinds::{IsLexicalContext, NodeLabel, TokenKind}; +use crate::cst::{self, Edge}; +use crate::kinds::{EdgeLabel, IsLexicalContext, TerminalKind}; use crate::lexer::Lexer; use crate::parse_error::ParseError; use crate::parser_support::parser_result::{ParserResult, SkippedUntil}; @@ -16,8 +16,8 @@ impl SeparatedHelper { input: &mut ParserContext<'_>, lexer: &L, body_parser: impl Fn(&mut ParserContext<'_>) -> ParserResult, - separator: TokenKind, - separator_label: NodeLabel, + separator: TerminalKind, + separator_label: EdgeLabel, ) -> ParserResult { let mut accum = vec![]; loop { @@ -55,8 +55,8 @@ impl SeparatedHelper { match skip_until_with_nested_delims::<_, LexCtx>(input, lexer, separator) { // A separator was found, so we can recover the incomplete match Some((found, skipped_range)) if found == separator => { - accum.push(LabeledNode::anonymous(cst::Node::token( - TokenKind::SKIPPED, + accum.push(Edge::anonymous(cst::Node::terminal( + TerminalKind::SKIPPED, input.content(skipped_range.utf8()), ))); input.emit(ParseError { diff --git a/crates/solidity/outputs/cargo/slang_solidity/src/generated/parser_support/sequence_helper.rs b/crates/solidity/outputs/cargo/slang_solidity/src/generated/parser_support/sequence_helper.rs index cecb10b5de..cd455cfcab 100644 --- a/crates/solidity/outputs/cargo/slang_solidity/src/generated/parser_support/sequence_helper.rs +++ b/crates/solidity/outputs/cargo/slang_solidity/src/generated/parser_support/sequence_helper.rs @@ -2,10 +2,10 @@ use std::ops::ControlFlow; -use metaslang_cst::TerminalKind; +use metaslang_cst::TerminalKind as _; -use crate::cst::{self, LabeledNode}; -use crate::kinds::{NodeLabel, TokenKind}; +use crate::cst::{self, Edge}; +use crate::kinds::{EdgeLabel, TerminalKind}; use crate::parser_support::parser_result::{Match, ParserResult, PrattElement, SkippedUntil}; /// Keeps accumulating parses sequentially until it hits an incomplete or no match. @@ -131,8 +131,8 @@ impl SequenceHelper { // Sanity check that we are recovering to the expected one. let next_token = next.nodes.iter().try_fold(None, |acc, node| { match &**node { - cst::Node::Token(token) if token.kind.is_trivia() => Ok(acc), - cst::Node::Token(token) => { + cst::Node::Terminal(token) if token.kind.is_trivia() => Ok(acc), + cst::Node::Terminal(token) => { match acc { None => Ok(Some(token.kind)), Some(..) => { @@ -141,16 +141,16 @@ impl SequenceHelper { } } } - cst::Node::Rule(rule) => { - debug_assert!(false, "Recovery skipped to a rule: {rule:?}"); + cst::Node::NonTerminal(node) => { + debug_assert!(false, "Recovery skipped to a nonterminal: {node:?}"); Err(()) } } }); debug_assert_eq!(next_token, Ok(Some(running.found))); - running.nodes.push(LabeledNode::anonymous(cst::Node::token( - TokenKind::SKIPPED, + running.nodes.push(Edge::anonymous(cst::Node::terminal( + TerminalKind::SKIPPED, std::mem::take(&mut running.skipped), ))); running.nodes.extend(next.nodes); @@ -199,7 +199,7 @@ impl SequenceHelper { /// Shorthand for `self.elem(value.with_label(label))`. pub fn elem_labeled( &mut self, - label: NodeLabel, + label: EdgeLabel, value: ParserResult, ) -> ControlFlow { self.elem(value.with_label(label)) diff --git a/crates/solidity/outputs/cargo/slang_solidity/src/main.rs b/crates/solidity/outputs/cargo/slang_solidity/src/main.rs index 22d295cc03..f7c60a4469 100644 --- a/crates/solidity/outputs/cargo/slang_solidity/src/main.rs +++ b/crates/solidity/outputs/cargo/slang_solidity/src/main.rs @@ -5,7 +5,7 @@ use std::process::ExitCode; use anyhow::{Context, Result}; use clap::{Parser as ClapParser, Subcommand}; use semver::Version; -use slang_solidity::kinds::RuleKind; +use slang_solidity::kinds::NonTerminalKind; use slang_solidity::language::Language; // Below are dependencies used by the API `lib.rs`, but not the CLI "main.rs". @@ -60,7 +60,7 @@ fn execute_parse_command(file_path_string: &str, version: Version, json: bool) - let input = fs::read_to_string(file_path)?; let language = Language::new(version)?; - let output = language.parse(RuleKind::SourceUnit, &input); + let output = language.parse(NonTerminalKind::SourceUnit, &input); let errors = output.errors(); for error in errors { diff --git a/crates/solidity/outputs/cargo/tests/src/cst_output/renderer.rs b/crates/solidity/outputs/cargo/tests/src/cst_output/renderer.rs index 2349e74fc3..9ee153be92 100644 --- a/crates/solidity/outputs/cargo/tests/src/cst_output/renderer.rs +++ b/crates/solidity/outputs/cargo/tests/src/cst_output/renderer.rs @@ -8,12 +8,12 @@ use codegen_language_definition::model::Item; use inflector::Inflector; use once_cell::sync::Lazy; use slang_solidity::cst::Node; -use slang_solidity::cursor::CursorWithLabels; -use slang_solidity::kinds::RuleKind; +use slang_solidity::cursor::CursorWithEdges; +use slang_solidity::kinds::NonTerminalKind; use slang_solidity::text_index::TextRangeExtensions; use solidity_language::SolidityDefinition; -pub fn render(source: &str, errors: &Vec, cursor: CursorWithLabels) -> Result { +pub fn render(source: &str, errors: &Vec, cursor: CursorWithEdges) -> Result { let mut w = String::new(); write_source(&mut w, source)?; @@ -88,7 +88,7 @@ fn write_errors(w: &mut String, errors: &Vec) -> Result<()> { Ok(()) } -fn write_tree(w: &mut String, mut cursor: CursorWithLabels, source: &str) -> Result<()> { +fn write_tree(w: &mut String, mut cursor: CursorWithEdges, source: &str) -> Result<()> { writeln!(w, "Tree:")?; write_node(w, &mut cursor, source, 0)?; @@ -98,7 +98,7 @@ fn write_tree(w: &mut String, mut cursor: CursorWithLabels, source: &str) -> Res fn write_node( w: &mut String, - cursor: &mut CursorWithLabels, + cursor: &mut CursorWithEdges, source: &str, depth: usize, ) -> Result<()> { @@ -109,7 +109,7 @@ fn write_node( write!(w, "{key}", key = render_key(cursor))?; // If it is a parent wih a single child, inline them on the same line: - if matches!(cursor.node(), Node::Rule(rule) if rule.children.len() == 1 && !NON_INLINABLE.contains(&rule.kind)) + if matches!(cursor.node(), Node::NonTerminal(rule) if rule.children.len() == 1 && !NON_INLINABLE.contains(&rule.kind)) { let parent_range = cursor.text_range(); assert!(cursor.go_to_next()); @@ -134,10 +134,10 @@ fn write_node( Ok(()) } -fn render_key(cursor: &mut CursorWithLabels) -> String { +fn render_key(cursor: &mut CursorWithEdges) -> String { let kind = match cursor.node() { - Node::Rule(rule) => rule.kind.to_string(), - Node::Token(token) => token.kind.to_string(), + Node::NonTerminal(nonterminal) => nonterminal.kind.to_string(), + Node::Terminal(terminal) => terminal.kind.to_string(), }; if let Some(label) = cursor.label() { @@ -147,15 +147,15 @@ fn render_key(cursor: &mut CursorWithLabels) -> String { } } -fn render_value(cursor: &mut CursorWithLabels, source: &str) -> String { +fn render_value(cursor: &mut CursorWithEdges, source: &str) -> String { let utf8_range = cursor.text_range().utf8(); let char_range = cursor.text_range().char(); let preview = render_preview(source, &char_range); match cursor.node() { - Node::Rule(rule) if rule.children.is_empty() => format!("[] # ({utf8_range:?})"), - Node::Rule(_) => format!("# {preview} ({utf8_range:?})"), - Node::Token(_) => format!("{preview} # ({utf8_range:?})"), + Node::NonTerminal(rule) if rule.children.is_empty() => format!("[] # ({utf8_range:?})"), + Node::NonTerminal(_) => format!("# {preview} ({utf8_range:?})"), + Node::Terminal(_) => format!("{preview} # ({utf8_range:?})"), } } @@ -191,7 +191,7 @@ fn render_preview(source: &str, char_range: &Range) -> String { } } -static NON_INLINABLE: Lazy> = Lazy::new(|| { +static NON_INLINABLE: Lazy> = Lazy::new(|| { let mut kinds = HashSet::new(); for item in SolidityDefinition::create().items() { diff --git a/crates/solidity/outputs/cargo/tests/src/cst_output/runner.rs b/crates/solidity/outputs/cargo/tests/src/cst_output/runner.rs index a182aecac5..42ce5dedde 100644 --- a/crates/solidity/outputs/cargo/tests/src/cst_output/runner.rs +++ b/crates/solidity/outputs/cargo/tests/src/cst_output/runner.rs @@ -4,7 +4,7 @@ use anyhow::Result; use infra_utils::cargo::CargoWorkspace; use infra_utils::codegen::CodegenFileSystem; use infra_utils::paths::PathExtensions; -use slang_solidity::kinds::RuleKind; +use slang_solidity::kinds::NonTerminalKind; use slang_solidity::language::Language; use strum_macros::Display; @@ -34,7 +34,7 @@ pub fn run(parser_name: &str, test_name: &str) -> Result<()> { let mut last_output = None; for version in VERSION_BREAKS { - let tested_rule_kind = RuleKind::from_str(parser_name) + let tested_rule_kind = NonTerminalKind::from_str(parser_name) .unwrap_or_else(|_| panic!("No such parser: {parser_name}")); let output = Language::new(version.clone())?.parse(tested_rule_kind, &source); @@ -52,7 +52,7 @@ pub fn run(parser_name: &str, test_name: &str) -> Result<()> { .map(|error| error.to_error_report(source_id, &source, /* with_color */ false)) .collect(); - let cursor = output.create_tree_cursor().with_labels(); + let cursor = output.create_tree_cursor().with_edges(); let status = if output.is_valid() { TestStatus::Success diff --git a/crates/solidity/outputs/cargo/tests/src/doc_examples/tree_query_language.rs b/crates/solidity/outputs/cargo/tests/src/doc_examples/tree_query_language.rs index e265a16131..a8c4a2f317 100644 --- a/crates/solidity/outputs/cargo/tests/src/doc_examples/tree_query_language.rs +++ b/crates/solidity/outputs/cargo/tests/src/doc_examples/tree_query_language.rs @@ -1,7 +1,7 @@ use once_cell::sync::Lazy; use regex::Regex; use semver::Version; -use slang_solidity::kinds::RuleKind; +use slang_solidity::kinds::NonTerminalKind; use slang_solidity::language::Language; use slang_solidity::query::{Query, QueryResultIterator}; @@ -19,7 +19,7 @@ impl RemoveMkdocSnippetMarkers for &str { } } -fn assert_matches(query: &Query, kind: RuleKind, source: &str) -> QueryResultIterator { +fn assert_matches(query: &Query, kind: NonTerminalKind, source: &str) -> QueryResultIterator { let language = Language::new(Version::new(0, 8, 12)).unwrap(); let cursor = language.parse(kind, source).create_tree_cursor(); @@ -44,7 +44,7 @@ fn query_syntax() { ) .unwrap(); - assert_matches(&query, RuleKind::MultiplicativeExpression, "1*2"); + assert_matches(&query, NonTerminalKind::MultiplicativeExpression, "1*2"); let query = Query::parse( &" @@ -56,7 +56,7 @@ fn query_syntax() { ) .unwrap(); - assert_matches(&query, RuleKind::MultiplicativeExpression, "1*2"); + assert_matches(&query, NonTerminalKind::MultiplicativeExpression, "1*2"); let query = Query::parse( &r#" @@ -68,7 +68,7 @@ fn query_syntax() { ) .unwrap(); - assert_matches(&query, RuleKind::MultiplicativeExpression, "1*2"); + assert_matches(&query, NonTerminalKind::MultiplicativeExpression, "1*2"); let query = Query::parse( &" @@ -79,7 +79,7 @@ fn query_syntax() { .remove_mkdoc_snippet_markers(), ) .unwrap(); - assert_matches(&query, RuleKind::MultiplicativeExpression, "1*2"); + assert_matches(&query, NonTerminalKind::MultiplicativeExpression, "1*2"); let query = Query::parse( &" @@ -90,8 +90,16 @@ fn query_syntax() { .remove_mkdoc_snippet_markers(), ) .unwrap(); - assert_matches(&query, RuleKind::MultiplicativeExpression, "1 * 'abc'"); - assert_matches(&query, RuleKind::MultiplicativeExpression, "'abc' * 1"); + assert_matches( + &query, + NonTerminalKind::MultiplicativeExpression, + "1 * 'abc'", + ); + assert_matches( + &query, + NonTerminalKind::MultiplicativeExpression, + "'abc' * 1", + ); } #[test] @@ -106,7 +114,7 @@ fn capturing_nodes() { ) .unwrap(); - assert_matches(&query, RuleKind::StructDefinition, "struct Abc {}"); + assert_matches(&query, NonTerminalKind::StructDefinition, "struct Abc {}"); let query = Query::parse( &" @@ -136,7 +144,7 @@ fn capturing_nodes() { assert_matches( &query, - RuleKind::ContractDefinition, + NonTerminalKind::ContractDefinition, "contract A { event A(); }", ); } @@ -155,7 +163,7 @@ fn quantification() { assert_matches( &query, - RuleKind::SourceUnit, + NonTerminalKind::SourceUnit, "// comment 1\n// comment 2\n/* comment 3 */", ); @@ -177,7 +185,7 @@ fn quantification() { assert_matches( &query, - RuleKind::SourceUnit, + NonTerminalKind::SourceUnit, " /// A doc comment contract A {} @@ -211,7 +219,7 @@ fn quantification() { let iter = assert_matches( &query, - RuleKind::FunctionCallExpression, + NonTerminalKind::FunctionCallExpression, " call(1, 'abc', 3) ", @@ -241,10 +249,10 @@ fn alternations() { .unwrap(); let results: Vec<_> = - assert_matches(&query, RuleKind::FunctionCallExpression, "call(1)").collect(); + assert_matches(&query, NonTerminalKind::FunctionCallExpression, "call(1)").collect(); results.first().unwrap().bindings.get("function").unwrap(); let results: Vec<_> = - assert_matches(&query, RuleKind::FunctionCallExpression, "a.call(1)").collect(); + assert_matches(&query, NonTerminalKind::FunctionCallExpression, "a.call(1)").collect(); results.first().unwrap().bindings.get("method").unwrap(); let query = Query::parse( @@ -267,7 +275,7 @@ fn alternations() { ) .unwrap(); - let iter = assert_matches(&query, RuleKind::IfStatement, "if (true) { break; }"); + let iter = assert_matches(&query, NonTerminalKind::IfStatement, "if (true) { break; }"); let results: Vec<_> = iter.collect(); assert_eq!(results.len(), 2); diff --git a/crates/solidity/outputs/cargo/tests/src/doc_examples/using_queries.rs b/crates/solidity/outputs/cargo/tests/src/doc_examples/using_queries.rs index dc5a0e4dd8..1d32298b80 100644 --- a/crates/solidity/outputs/cargo/tests/src/doc_examples/using_queries.rs +++ b/crates/solidity/outputs/cargo/tests/src/doc_examples/using_queries.rs @@ -3,7 +3,7 @@ use std::path::Path; use anyhow::Result; use infra_utils::paths::PathExtensions; use semver::Version; -use slang_solidity::kinds::RuleKind; +use slang_solidity::kinds::NonTerminalKind; use slang_solidity::language::Language; use slang_solidity::parse_output::ParseOutput; use slang_solidity::query::{Query, QueryResultIterator}; @@ -15,7 +15,7 @@ fn parse_doc_input_file>(path: T) -> Result { let language = Language::new(Version::new(0, 8, 0))?; - Ok(language.parse(RuleKind::SourceUnit, source.trim())) + Ok(language.parse(NonTerminalKind::SourceUnit, source.trim())) } #[test] diff --git a/crates/solidity/outputs/cargo/tests/src/doc_examples/using_the_cursor.rs b/crates/solidity/outputs/cargo/tests/src/doc_examples/using_the_cursor.rs index 1b34ea8d69..2df2309df9 100644 --- a/crates/solidity/outputs/cargo/tests/src/doc_examples/using_the_cursor.rs +++ b/crates/solidity/outputs/cargo/tests/src/doc_examples/using_the_cursor.rs @@ -8,7 +8,7 @@ use infra_utils::paths::PathExtensions; fn using_the_cursor() -> Result<()> { // --8<-- [start:imports] use semver::Version; - use slang_solidity::kinds::{NodeLabel, RuleKind, TokenKind}; + use slang_solidity::kinds::{EdgeLabel, NonTerminalKind, TerminalKind}; use slang_solidity::language::Language; use slang_solidity::text_index::TextRangeExtensions; // --8<-- [end:imports] @@ -22,7 +22,7 @@ fn using_the_cursor() -> Result<()> { // --8<-- [start:parse-input] let language = Language::new(Version::parse("0.8.0")?)?; - let parse_output = language.parse(RuleKind::SourceUnit, source); + let parse_output = language.parse(NonTerminalKind::SourceUnit, source); // --8<-- [end:parse-input] { @@ -31,12 +31,12 @@ fn using_the_cursor() -> Result<()> { let mut cursor = parse_output.create_tree_cursor(); - while cursor.go_to_next_rule_with_kind(RuleKind::ContractDefinition) { + while cursor.go_to_next_nonterminal_with_kind(NonTerminalKind::ContractDefinition) { assert!(cursor.go_to_first_child()); - assert!(cursor.go_to_next_token_with_kind(TokenKind::Identifier)); + assert!(cursor.go_to_next_terminal_with_kind(TerminalKind::Identifier)); let token_node = cursor.node(); - contracts.push(token_node.as_token().unwrap().text.clone()); + contracts.push(token_node.as_terminal().unwrap().text.clone()); // You have to make sure you return the cursor to its original position: assert!(cursor.go_to_parent()); @@ -52,12 +52,12 @@ fn using_the_cursor() -> Result<()> { let mut cursor = parse_output.create_tree_cursor(); - while cursor.go_to_next_rule_with_kind(RuleKind::ContractDefinition) { + while cursor.go_to_next_nonterminal_with_kind(NonTerminalKind::ContractDefinition) { let mut child_cursor = cursor.spawn(); - assert!(child_cursor.go_to_next_token_with_kind(TokenKind::Identifier)); + assert!(child_cursor.go_to_next_terminal_with_kind(TerminalKind::Identifier)); let token_node = child_cursor.node(); - contracts.push(token_node.as_token().unwrap().text.clone()); + contracts.push(token_node.as_terminal().unwrap().text.clone()); } assert_eq!(contracts, &["Foo", "Bar", "Baz"]); @@ -70,9 +70,9 @@ fn using_the_cursor() -> Result<()> { let mut cursor = parse_output.create_tree_cursor(); - while cursor.go_to_next_rule_with_kind(RuleKind::ContractDefinition) { + while cursor.go_to_next_nonterminal_with_kind(NonTerminalKind::ContractDefinition) { let range = cursor.text_range().utf8(); - let text = Rc::clone(cursor.node().as_rule().unwrap()).unparse(); + let text = Rc::clone(cursor.node().as_nonterminal().unwrap()).unparse(); contracts.push((range, text.trim().to_owned())); } @@ -93,7 +93,10 @@ fn using_the_cursor() -> Result<()> { let cursor = parse_output.create_tree_cursor(); let identifiers: Vec<_> = cursor - .filter_map(|node| node.as_token_with_kind(TokenKind::Identifier).cloned()) + .filter_map(|node| { + node.as_terminal_with_kind(TerminalKind::Identifier) + .cloned() + }) .map(|identifier| identifier.text.clone()) .collect(); @@ -106,9 +109,12 @@ fn using_the_cursor() -> Result<()> { let cursor = parse_output.create_tree_cursor(); let identifiers: Vec<_> = cursor - .with_labels() - .filter(|node| node.label == Some(NodeLabel::Name)) - .filter_map(|node| node.as_token_with_kind(TokenKind::Identifier).cloned()) + .with_edges() + .filter(|node| node.label == Some(EdgeLabel::Name)) + .filter_map(|node| { + node.as_terminal_with_kind(TerminalKind::Identifier) + .cloned() + }) .map(|identifier| identifier.text.clone()) .collect(); diff --git a/crates/solidity/outputs/cargo/tests/src/doc_examples/using_the_parser.rs b/crates/solidity/outputs/cargo/tests/src/doc_examples/using_the_parser.rs index 72c0b5faef..16e9ece4ae 100644 --- a/crates/solidity/outputs/cargo/tests/src/doc_examples/using_the_parser.rs +++ b/crates/solidity/outputs/cargo/tests/src/doc_examples/using_the_parser.rs @@ -9,7 +9,7 @@ fn using_the_parser() -> Result<()> { // --8<-- [start:imports] use semver::Version; use slang_solidity::cst::Node; - use slang_solidity::kinds::{RuleKind, TokenKind}; + use slang_solidity::kinds::{NonTerminalKind, TerminalKind}; use slang_solidity::language::Language; // --8<-- [end:imports] @@ -22,7 +22,7 @@ fn using_the_parser() -> Result<()> { // --8<-- [start:parse-input] let language = Language::new(Version::parse("0.8.0")?)?; - let parse_output = language.parse(RuleKind::ContractDefinition, source); + let parse_output = language.parse(NonTerminalKind::ContractDefinition, source); // --8<-- [end:parse-input] // --8<-- [start:print-errors] @@ -38,18 +38,22 @@ fn using_the_parser() -> Result<()> { // --8<-- [start:inspect-tree] let parse_tree = parse_output.tree(); - let contract = parse_tree.as_rule().unwrap(); - assert_eq!(contract.kind, RuleKind::ContractDefinition); + let contract = parse_tree.as_nonterminal().unwrap(); + assert_eq!(contract.kind, NonTerminalKind::ContractDefinition); assert_eq!(contract.children.len(), 7); let children = &contract.children; - assert!(matches!(&children[0].node, Node::Token(t) if t.kind == TokenKind::ContractKeyword)); - assert!(matches!(&children[1].node, Node::Token(t) if t.kind == TokenKind::Whitespace)); - assert!(matches!(&children[2].node, Node::Token(t) if t.kind == TokenKind::Identifier)); - assert!(matches!(&children[3].node, Node::Token(t) if t.kind == TokenKind::Whitespace)); - assert!(matches!(&children[4].node, Node::Token(t) if t.kind == TokenKind::OpenBrace)); - assert!(matches!(&children[5].node, Node::Rule(r) if r.kind == RuleKind::ContractMembers)); - assert!(matches!(&children[6].node, Node::Token(t) if t.kind == TokenKind::CloseBrace)); + assert!( + matches!(&children[0].node, Node::Terminal(t) if t.kind == TerminalKind::ContractKeyword) + ); + assert!(matches!(&children[1].node, Node::Terminal(t) if t.kind == TerminalKind::Whitespace)); + assert!(matches!(&children[2].node, Node::Terminal(t) if t.kind == TerminalKind::Identifier)); + assert!(matches!(&children[3].node, Node::Terminal(t) if t.kind == TerminalKind::Whitespace)); + assert!(matches!(&children[4].node, Node::Terminal(t) if t.kind == TerminalKind::OpenBrace)); + assert!( + matches!(&children[5].node, Node::NonTerminal(r) if r.kind == NonTerminalKind::ContractMembers) + ); + assert!(matches!(&children[6].node, Node::Terminal(t) if t.kind == TerminalKind::CloseBrace)); // --8<-- [end:inspect-tree] // --8<-- [start:unparse-node] diff --git a/crates/solidity/outputs/cargo/tests/src/trivia.rs b/crates/solidity/outputs/cargo/tests/src/trivia.rs index d8486fa4a0..02ce1dc2d5 100644 --- a/crates/solidity/outputs/cargo/tests/src/trivia.rs +++ b/crates/solidity/outputs/cargo/tests/src/trivia.rs @@ -1,7 +1,7 @@ use anyhow::Result; use semver::Version; use slang_solidity::cst::Node; -use slang_solidity::kinds::{RuleKind, TokenKind}; +use slang_solidity::kinds::{NonTerminalKind, TerminalKind}; use slang_solidity::language::Language; #[test] @@ -25,16 +25,16 @@ fn compare_end_of_lines(input: &str, expected: &[&str]) -> Result<()> { let version = Version::parse("0.8.0")?; let language = &Language::new(version)?; - let output = language.parse(RuleKind::SourceUnit, input); + let output = language.parse(NonTerminalKind::SourceUnit, input); assert!(output.is_valid()); let actual = output .create_tree_cursor() .filter_map(|node| match node { - Node::Rule(_) => None, + Node::NonTerminal(_) => None, - Node::Token(token) => { - assert_eq!(token.kind, TokenKind::EndOfLine); + Node::Terminal(token) => { + assert_eq!(token.kind, TerminalKind::EndOfLine); Some(token.text.clone()) } }) diff --git a/crates/solidity/outputs/npm/package/src/generated/ast/generated/ast_types.ts b/crates/solidity/outputs/npm/package/src/generated/ast/generated/ast_types.ts index 00790e80bd..cd61b8d60a 100644 --- a/crates/solidity/outputs/npm/package/src/generated/ast/generated/ast_types.ts +++ b/crates/solidity/outputs/npm/package/src/generated/ast/generated/ast_types.ts @@ -2,8 +2,8 @@ import * as assert from "node:assert"; import { ast_internal } from "../../napi-bindings/generated"; -import { RuleNode, TokenNode } from "../../cst"; -import { RuleKind, TokenKind } from "../../kinds"; +import { NonTerminalNode, TerminalNode } from "../../cst"; +import { NonTerminalKind, TerminalKind } from "../../kinds"; /* * Sequences: @@ -14,12 +14,12 @@ export class SourceUnit { const [$members] = ast_internal.selectSequence(this.cst); return { - members: new SourceUnitMembers($members as RuleNode), + members: new SourceUnitMembers($members as NonTerminalNode), }; }); - public constructor(public readonly cst: RuleNode) { - assertKind(this.cst.kind, RuleKind.SourceUnit); + public constructor(public readonly cst: NonTerminalNode) { + assertKind(this.cst.kind, NonTerminalKind.SourceUnit); } public get members(): SourceUnitMembers { @@ -32,17 +32,17 @@ export class PragmaDirective { const [$pragmaKeyword, $pragma, $semicolon] = ast_internal.selectSequence(this.cst); return { - pragmaKeyword: $pragmaKeyword as TokenNode, - pragma: new Pragma($pragma as RuleNode), - semicolon: $semicolon as TokenNode, + pragmaKeyword: $pragmaKeyword as TerminalNode, + pragma: new Pragma($pragma as NonTerminalNode), + semicolon: $semicolon as TerminalNode, }; }); - public constructor(public readonly cst: RuleNode) { - assertKind(this.cst.kind, RuleKind.PragmaDirective); + public constructor(public readonly cst: NonTerminalNode) { + assertKind(this.cst.kind, NonTerminalKind.PragmaDirective); } - public get pragmaKeyword(): TokenNode { + public get pragmaKeyword(): TerminalNode { return this.fetch().pragmaKeyword; } @@ -50,7 +50,7 @@ export class PragmaDirective { return this.fetch().pragma; } - public get semicolon(): TokenNode { + public get semicolon(): TerminalNode { return this.fetch().semicolon; } } @@ -60,20 +60,20 @@ export class ABICoderPragma { const [$abicoderKeyword, $version] = ast_internal.selectSequence(this.cst); return { - abicoderKeyword: $abicoderKeyword as TokenNode, - version: $version as TokenNode, + abicoderKeyword: $abicoderKeyword as TerminalNode, + version: $version as TerminalNode, }; }); - public constructor(public readonly cst: RuleNode) { - assertKind(this.cst.kind, RuleKind.ABICoderPragma); + public constructor(public readonly cst: NonTerminalNode) { + assertKind(this.cst.kind, NonTerminalKind.ABICoderPragma); } - public get abicoderKeyword(): TokenNode { + public get abicoderKeyword(): TerminalNode { return this.fetch().abicoderKeyword; } - public get version(): TokenNode { + public get version(): TerminalNode { return this.fetch().version; } } @@ -83,16 +83,16 @@ export class ExperimentalPragma { const [$experimentalKeyword, $feature] = ast_internal.selectSequence(this.cst); return { - experimentalKeyword: $experimentalKeyword as TokenNode, - feature: new ExperimentalFeature($feature as RuleNode), + experimentalKeyword: $experimentalKeyword as TerminalNode, + feature: new ExperimentalFeature($feature as NonTerminalNode), }; }); - public constructor(public readonly cst: RuleNode) { - assertKind(this.cst.kind, RuleKind.ExperimentalPragma); + public constructor(public readonly cst: NonTerminalNode) { + assertKind(this.cst.kind, NonTerminalKind.ExperimentalPragma); } - public get experimentalKeyword(): TokenNode { + public get experimentalKeyword(): TerminalNode { return this.fetch().experimentalKeyword; } @@ -106,16 +106,16 @@ export class VersionPragma { const [$solidityKeyword, $sets] = ast_internal.selectSequence(this.cst); return { - solidityKeyword: $solidityKeyword as TokenNode, - sets: new VersionExpressionSets($sets as RuleNode), + solidityKeyword: $solidityKeyword as TerminalNode, + sets: new VersionExpressionSets($sets as NonTerminalNode), }; }); - public constructor(public readonly cst: RuleNode) { - assertKind(this.cst.kind, RuleKind.VersionPragma); + public constructor(public readonly cst: NonTerminalNode) { + assertKind(this.cst.kind, NonTerminalKind.VersionPragma); } - public get solidityKeyword(): TokenNode { + public get solidityKeyword(): TerminalNode { return this.fetch().solidityKeyword; } @@ -129,21 +129,21 @@ export class VersionRange { const [$leftOperand, $operator, $rightOperand] = ast_internal.selectSequence(this.cst); return { - leftOperand: new VersionExpression($leftOperand as RuleNode), - operator: $operator as TokenNode, - rightOperand: new VersionExpression($rightOperand as RuleNode), + leftOperand: new VersionExpression($leftOperand as NonTerminalNode), + operator: $operator as TerminalNode, + rightOperand: new VersionExpression($rightOperand as NonTerminalNode), }; }); - public constructor(public readonly cst: RuleNode) { - assertKind(this.cst.kind, RuleKind.VersionRange); + public constructor(public readonly cst: NonTerminalNode) { + assertKind(this.cst.kind, NonTerminalKind.VersionRange); } public get leftOperand(): VersionExpression { return this.fetch().leftOperand; } - public get operator(): TokenNode { + public get operator(): TerminalNode { return this.fetch().operator; } @@ -157,16 +157,16 @@ export class VersionComparator { const [$operator, $operand] = ast_internal.selectSequence(this.cst); return { - operator: $operator as TokenNode, - operand: new VersionExpression($operand as RuleNode), + operator: $operator as TerminalNode, + operand: new VersionExpression($operand as NonTerminalNode), }; }); - public constructor(public readonly cst: RuleNode) { - assertKind(this.cst.kind, RuleKind.VersionComparator); + public constructor(public readonly cst: NonTerminalNode) { + assertKind(this.cst.kind, NonTerminalKind.VersionComparator); } - public get operator(): TokenNode { + public get operator(): TerminalNode { return this.fetch().operator; } @@ -180,17 +180,17 @@ export class ImportDirective { const [$importKeyword, $clause, $semicolon] = ast_internal.selectSequence(this.cst); return { - importKeyword: $importKeyword as TokenNode, - clause: new ImportClause($clause as RuleNode), - semicolon: $semicolon as TokenNode, + importKeyword: $importKeyword as TerminalNode, + clause: new ImportClause($clause as NonTerminalNode), + semicolon: $semicolon as TerminalNode, }; }); - public constructor(public readonly cst: RuleNode) { - assertKind(this.cst.kind, RuleKind.ImportDirective); + public constructor(public readonly cst: NonTerminalNode) { + assertKind(this.cst.kind, NonTerminalKind.ImportDirective); } - public get importKeyword(): TokenNode { + public get importKeyword(): TerminalNode { return this.fetch().importKeyword; } @@ -198,7 +198,7 @@ export class ImportDirective { return this.fetch().clause; } - public get semicolon(): TokenNode { + public get semicolon(): TerminalNode { return this.fetch().semicolon; } } @@ -208,13 +208,13 @@ export class PathImport { const [$path, $alias] = ast_internal.selectSequence(this.cst); return { - path: new StringLiteral($path as RuleNode), - alias: $alias === null ? undefined : new ImportAlias($alias as RuleNode), + path: new StringLiteral($path as NonTerminalNode), + alias: $alias === null ? undefined : new ImportAlias($alias as NonTerminalNode), }; }); - public constructor(public readonly cst: RuleNode) { - assertKind(this.cst.kind, RuleKind.PathImport); + public constructor(public readonly cst: NonTerminalNode) { + assertKind(this.cst.kind, NonTerminalKind.PathImport); } public get path(): StringLiteral { @@ -231,18 +231,18 @@ export class NamedImport { const [$asterisk, $alias, $fromKeyword, $path] = ast_internal.selectSequence(this.cst); return { - asterisk: $asterisk as TokenNode, - alias: new ImportAlias($alias as RuleNode), - fromKeyword: $fromKeyword as TokenNode, - path: new StringLiteral($path as RuleNode), + asterisk: $asterisk as TerminalNode, + alias: new ImportAlias($alias as NonTerminalNode), + fromKeyword: $fromKeyword as TerminalNode, + path: new StringLiteral($path as NonTerminalNode), }; }); - public constructor(public readonly cst: RuleNode) { - assertKind(this.cst.kind, RuleKind.NamedImport); + public constructor(public readonly cst: NonTerminalNode) { + assertKind(this.cst.kind, NonTerminalKind.NamedImport); } - public get asterisk(): TokenNode { + public get asterisk(): TerminalNode { return this.fetch().asterisk; } @@ -250,7 +250,7 @@ export class NamedImport { return this.fetch().alias; } - public get fromKeyword(): TokenNode { + public get fromKeyword(): TerminalNode { return this.fetch().fromKeyword; } @@ -264,19 +264,19 @@ export class ImportDeconstruction { const [$openBrace, $symbols, $closeBrace, $fromKeyword, $path] = ast_internal.selectSequence(this.cst); return { - openBrace: $openBrace as TokenNode, - symbols: new ImportDeconstructionSymbols($symbols as RuleNode), - closeBrace: $closeBrace as TokenNode, - fromKeyword: $fromKeyword as TokenNode, - path: new StringLiteral($path as RuleNode), + openBrace: $openBrace as TerminalNode, + symbols: new ImportDeconstructionSymbols($symbols as NonTerminalNode), + closeBrace: $closeBrace as TerminalNode, + fromKeyword: $fromKeyword as TerminalNode, + path: new StringLiteral($path as NonTerminalNode), }; }); - public constructor(public readonly cst: RuleNode) { - assertKind(this.cst.kind, RuleKind.ImportDeconstruction); + public constructor(public readonly cst: NonTerminalNode) { + assertKind(this.cst.kind, NonTerminalKind.ImportDeconstruction); } - public get openBrace(): TokenNode { + public get openBrace(): TerminalNode { return this.fetch().openBrace; } @@ -284,11 +284,11 @@ export class ImportDeconstruction { return this.fetch().symbols; } - public get closeBrace(): TokenNode { + public get closeBrace(): TerminalNode { return this.fetch().closeBrace; } - public get fromKeyword(): TokenNode { + public get fromKeyword(): TerminalNode { return this.fetch().fromKeyword; } @@ -302,16 +302,16 @@ export class ImportDeconstructionSymbol { const [$name, $alias] = ast_internal.selectSequence(this.cst); return { - name: $name as TokenNode, - alias: $alias === null ? undefined : new ImportAlias($alias as RuleNode), + name: $name as TerminalNode, + alias: $alias === null ? undefined : new ImportAlias($alias as NonTerminalNode), }; }); - public constructor(public readonly cst: RuleNode) { - assertKind(this.cst.kind, RuleKind.ImportDeconstructionSymbol); + public constructor(public readonly cst: NonTerminalNode) { + assertKind(this.cst.kind, NonTerminalKind.ImportDeconstructionSymbol); } - public get name(): TokenNode { + public get name(): TerminalNode { return this.fetch().name; } @@ -325,20 +325,20 @@ export class ImportAlias { const [$asKeyword, $identifier] = ast_internal.selectSequence(this.cst); return { - asKeyword: $asKeyword as TokenNode, - identifier: $identifier as TokenNode, + asKeyword: $asKeyword as TerminalNode, + identifier: $identifier as TerminalNode, }; }); - public constructor(public readonly cst: RuleNode) { - assertKind(this.cst.kind, RuleKind.ImportAlias); + public constructor(public readonly cst: NonTerminalNode) { + assertKind(this.cst.kind, NonTerminalKind.ImportAlias); } - public get asKeyword(): TokenNode { + public get asKeyword(): TerminalNode { return this.fetch().asKeyword; } - public get identifier(): TokenNode { + public get identifier(): TerminalNode { return this.fetch().identifier; } } @@ -350,20 +350,20 @@ export class UsingDirective { ); return { - usingKeyword: $usingKeyword as TokenNode, - clause: new UsingClause($clause as RuleNode), - forKeyword: $forKeyword as TokenNode, - target: new UsingTarget($target as RuleNode), - globalKeyword: $globalKeyword === null ? undefined : ($globalKeyword as TokenNode), - semicolon: $semicolon as TokenNode, + usingKeyword: $usingKeyword as TerminalNode, + clause: new UsingClause($clause as NonTerminalNode), + forKeyword: $forKeyword as TerminalNode, + target: new UsingTarget($target as NonTerminalNode), + globalKeyword: $globalKeyword === null ? undefined : ($globalKeyword as TerminalNode), + semicolon: $semicolon as TerminalNode, }; }); - public constructor(public readonly cst: RuleNode) { - assertKind(this.cst.kind, RuleKind.UsingDirective); + public constructor(public readonly cst: NonTerminalNode) { + assertKind(this.cst.kind, NonTerminalKind.UsingDirective); } - public get usingKeyword(): TokenNode { + public get usingKeyword(): TerminalNode { return this.fetch().usingKeyword; } @@ -371,7 +371,7 @@ export class UsingDirective { return this.fetch().clause; } - public get forKeyword(): TokenNode { + public get forKeyword(): TerminalNode { return this.fetch().forKeyword; } @@ -379,11 +379,11 @@ export class UsingDirective { return this.fetch().target; } - public get globalKeyword(): TokenNode | undefined { + public get globalKeyword(): TerminalNode | undefined { return this.fetch().globalKeyword; } - public get semicolon(): TokenNode { + public get semicolon(): TerminalNode { return this.fetch().semicolon; } } @@ -393,17 +393,17 @@ export class UsingDeconstruction { const [$openBrace, $symbols, $closeBrace] = ast_internal.selectSequence(this.cst); return { - openBrace: $openBrace as TokenNode, - symbols: new UsingDeconstructionSymbols($symbols as RuleNode), - closeBrace: $closeBrace as TokenNode, + openBrace: $openBrace as TerminalNode, + symbols: new UsingDeconstructionSymbols($symbols as NonTerminalNode), + closeBrace: $closeBrace as TerminalNode, }; }); - public constructor(public readonly cst: RuleNode) { - assertKind(this.cst.kind, RuleKind.UsingDeconstruction); + public constructor(public readonly cst: NonTerminalNode) { + assertKind(this.cst.kind, NonTerminalKind.UsingDeconstruction); } - public get openBrace(): TokenNode { + public get openBrace(): TerminalNode { return this.fetch().openBrace; } @@ -411,7 +411,7 @@ export class UsingDeconstruction { return this.fetch().symbols; } - public get closeBrace(): TokenNode { + public get closeBrace(): TerminalNode { return this.fetch().closeBrace; } } @@ -421,13 +421,13 @@ export class UsingDeconstructionSymbol { const [$name, $alias] = ast_internal.selectSequence(this.cst); return { - name: new IdentifierPath($name as RuleNode), - alias: $alias === null ? undefined : new UsingAlias($alias as RuleNode), + name: new IdentifierPath($name as NonTerminalNode), + alias: $alias === null ? undefined : new UsingAlias($alias as NonTerminalNode), }; }); - public constructor(public readonly cst: RuleNode) { - assertKind(this.cst.kind, RuleKind.UsingDeconstructionSymbol); + public constructor(public readonly cst: NonTerminalNode) { + assertKind(this.cst.kind, NonTerminalKind.UsingDeconstructionSymbol); } public get name(): IdentifierPath { @@ -444,16 +444,16 @@ export class UsingAlias { const [$asKeyword, $operator] = ast_internal.selectSequence(this.cst); return { - asKeyword: $asKeyword as TokenNode, - operator: new UsingOperator($operator as RuleNode), + asKeyword: $asKeyword as TerminalNode, + operator: new UsingOperator($operator as NonTerminalNode), }; }); - public constructor(public readonly cst: RuleNode) { - assertKind(this.cst.kind, RuleKind.UsingAlias); + public constructor(public readonly cst: NonTerminalNode) { + assertKind(this.cst.kind, NonTerminalKind.UsingAlias); } - public get asKeyword(): TokenNode { + public get asKeyword(): TerminalNode { return this.fetch().asKeyword; } @@ -468,29 +468,29 @@ export class ContractDefinition { ast_internal.selectSequence(this.cst); return { - abstractKeyword: $abstractKeyword === null ? undefined : ($abstractKeyword as TokenNode), - contractKeyword: $contractKeyword as TokenNode, - name: $name as TokenNode, - inheritence: $inheritence === null ? undefined : new InheritanceSpecifier($inheritence as RuleNode), - openBrace: $openBrace as TokenNode, - members: new ContractMembers($members as RuleNode), - closeBrace: $closeBrace as TokenNode, + abstractKeyword: $abstractKeyword === null ? undefined : ($abstractKeyword as TerminalNode), + contractKeyword: $contractKeyword as TerminalNode, + name: $name as TerminalNode, + inheritence: $inheritence === null ? undefined : new InheritanceSpecifier($inheritence as NonTerminalNode), + openBrace: $openBrace as TerminalNode, + members: new ContractMembers($members as NonTerminalNode), + closeBrace: $closeBrace as TerminalNode, }; }); - public constructor(public readonly cst: RuleNode) { - assertKind(this.cst.kind, RuleKind.ContractDefinition); + public constructor(public readonly cst: NonTerminalNode) { + assertKind(this.cst.kind, NonTerminalKind.ContractDefinition); } - public get abstractKeyword(): TokenNode | undefined { + public get abstractKeyword(): TerminalNode | undefined { return this.fetch().abstractKeyword; } - public get contractKeyword(): TokenNode { + public get contractKeyword(): TerminalNode { return this.fetch().contractKeyword; } - public get name(): TokenNode { + public get name(): TerminalNode { return this.fetch().name; } @@ -498,7 +498,7 @@ export class ContractDefinition { return this.fetch().inheritence; } - public get openBrace(): TokenNode { + public get openBrace(): TerminalNode { return this.fetch().openBrace; } @@ -506,7 +506,7 @@ export class ContractDefinition { return this.fetch().members; } - public get closeBrace(): TokenNode { + public get closeBrace(): TerminalNode { return this.fetch().closeBrace; } } @@ -516,16 +516,16 @@ export class InheritanceSpecifier { const [$isKeyword, $types] = ast_internal.selectSequence(this.cst); return { - isKeyword: $isKeyword as TokenNode, - types: new InheritanceTypes($types as RuleNode), + isKeyword: $isKeyword as TerminalNode, + types: new InheritanceTypes($types as NonTerminalNode), }; }); - public constructor(public readonly cst: RuleNode) { - assertKind(this.cst.kind, RuleKind.InheritanceSpecifier); + public constructor(public readonly cst: NonTerminalNode) { + assertKind(this.cst.kind, NonTerminalKind.InheritanceSpecifier); } - public get isKeyword(): TokenNode { + public get isKeyword(): TerminalNode { return this.fetch().isKeyword; } @@ -539,13 +539,13 @@ export class InheritanceType { const [$typeName, $arguments] = ast_internal.selectSequence(this.cst); return { - typeName: new IdentifierPath($typeName as RuleNode), - arguments: $arguments === null ? undefined : new ArgumentsDeclaration($arguments as RuleNode), + typeName: new IdentifierPath($typeName as NonTerminalNode), + arguments: $arguments === null ? undefined : new ArgumentsDeclaration($arguments as NonTerminalNode), }; }); - public constructor(public readonly cst: RuleNode) { - assertKind(this.cst.kind, RuleKind.InheritanceType); + public constructor(public readonly cst: NonTerminalNode) { + assertKind(this.cst.kind, NonTerminalKind.InheritanceType); } public get typeName(): IdentifierPath { @@ -564,24 +564,24 @@ export class InterfaceDefinition { ); return { - interfaceKeyword: $interfaceKeyword as TokenNode, - name: $name as TokenNode, - inheritence: $inheritence === null ? undefined : new InheritanceSpecifier($inheritence as RuleNode), - openBrace: $openBrace as TokenNode, - members: new InterfaceMembers($members as RuleNode), - closeBrace: $closeBrace as TokenNode, + interfaceKeyword: $interfaceKeyword as TerminalNode, + name: $name as TerminalNode, + inheritence: $inheritence === null ? undefined : new InheritanceSpecifier($inheritence as NonTerminalNode), + openBrace: $openBrace as TerminalNode, + members: new InterfaceMembers($members as NonTerminalNode), + closeBrace: $closeBrace as TerminalNode, }; }); - public constructor(public readonly cst: RuleNode) { - assertKind(this.cst.kind, RuleKind.InterfaceDefinition); + public constructor(public readonly cst: NonTerminalNode) { + assertKind(this.cst.kind, NonTerminalKind.InterfaceDefinition); } - public get interfaceKeyword(): TokenNode { + public get interfaceKeyword(): TerminalNode { return this.fetch().interfaceKeyword; } - public get name(): TokenNode { + public get name(): TerminalNode { return this.fetch().name; } @@ -589,7 +589,7 @@ export class InterfaceDefinition { return this.fetch().inheritence; } - public get openBrace(): TokenNode { + public get openBrace(): TerminalNode { return this.fetch().openBrace; } @@ -597,7 +597,7 @@ export class InterfaceDefinition { return this.fetch().members; } - public get closeBrace(): TokenNode { + public get closeBrace(): TerminalNode { return this.fetch().closeBrace; } } @@ -607,27 +607,27 @@ export class LibraryDefinition { const [$libraryKeyword, $name, $openBrace, $members, $closeBrace] = ast_internal.selectSequence(this.cst); return { - libraryKeyword: $libraryKeyword as TokenNode, - name: $name as TokenNode, - openBrace: $openBrace as TokenNode, - members: new LibraryMembers($members as RuleNode), - closeBrace: $closeBrace as TokenNode, + libraryKeyword: $libraryKeyword as TerminalNode, + name: $name as TerminalNode, + openBrace: $openBrace as TerminalNode, + members: new LibraryMembers($members as NonTerminalNode), + closeBrace: $closeBrace as TerminalNode, }; }); - public constructor(public readonly cst: RuleNode) { - assertKind(this.cst.kind, RuleKind.LibraryDefinition); + public constructor(public readonly cst: NonTerminalNode) { + assertKind(this.cst.kind, NonTerminalKind.LibraryDefinition); } - public get libraryKeyword(): TokenNode { + public get libraryKeyword(): TerminalNode { return this.fetch().libraryKeyword; } - public get name(): TokenNode { + public get name(): TerminalNode { return this.fetch().name; } - public get openBrace(): TokenNode { + public get openBrace(): TerminalNode { return this.fetch().openBrace; } @@ -635,7 +635,7 @@ export class LibraryDefinition { return this.fetch().members; } - public get closeBrace(): TokenNode { + public get closeBrace(): TerminalNode { return this.fetch().closeBrace; } } @@ -645,27 +645,27 @@ export class StructDefinition { const [$structKeyword, $name, $openBrace, $members, $closeBrace] = ast_internal.selectSequence(this.cst); return { - structKeyword: $structKeyword as TokenNode, - name: $name as TokenNode, - openBrace: $openBrace as TokenNode, - members: new StructMembers($members as RuleNode), - closeBrace: $closeBrace as TokenNode, + structKeyword: $structKeyword as TerminalNode, + name: $name as TerminalNode, + openBrace: $openBrace as TerminalNode, + members: new StructMembers($members as NonTerminalNode), + closeBrace: $closeBrace as TerminalNode, }; }); - public constructor(public readonly cst: RuleNode) { - assertKind(this.cst.kind, RuleKind.StructDefinition); + public constructor(public readonly cst: NonTerminalNode) { + assertKind(this.cst.kind, NonTerminalKind.StructDefinition); } - public get structKeyword(): TokenNode { + public get structKeyword(): TerminalNode { return this.fetch().structKeyword; } - public get name(): TokenNode { + public get name(): TerminalNode { return this.fetch().name; } - public get openBrace(): TokenNode { + public get openBrace(): TerminalNode { return this.fetch().openBrace; } @@ -673,7 +673,7 @@ export class StructDefinition { return this.fetch().members; } - public get closeBrace(): TokenNode { + public get closeBrace(): TerminalNode { return this.fetch().closeBrace; } } @@ -683,25 +683,25 @@ export class StructMember { const [$typeName, $name, $semicolon] = ast_internal.selectSequence(this.cst); return { - typeName: new TypeName($typeName as RuleNode), - name: $name as TokenNode, - semicolon: $semicolon as TokenNode, + typeName: new TypeName($typeName as NonTerminalNode), + name: $name as TerminalNode, + semicolon: $semicolon as TerminalNode, }; }); - public constructor(public readonly cst: RuleNode) { - assertKind(this.cst.kind, RuleKind.StructMember); + public constructor(public readonly cst: NonTerminalNode) { + assertKind(this.cst.kind, NonTerminalKind.StructMember); } public get typeName(): TypeName { return this.fetch().typeName; } - public get name(): TokenNode { + public get name(): TerminalNode { return this.fetch().name; } - public get semicolon(): TokenNode { + public get semicolon(): TerminalNode { return this.fetch().semicolon; } } @@ -711,27 +711,27 @@ export class EnumDefinition { const [$enumKeyword, $name, $openBrace, $members, $closeBrace] = ast_internal.selectSequence(this.cst); return { - enumKeyword: $enumKeyword as TokenNode, - name: $name as TokenNode, - openBrace: $openBrace as TokenNode, - members: new EnumMembers($members as RuleNode), - closeBrace: $closeBrace as TokenNode, + enumKeyword: $enumKeyword as TerminalNode, + name: $name as TerminalNode, + openBrace: $openBrace as TerminalNode, + members: new EnumMembers($members as NonTerminalNode), + closeBrace: $closeBrace as TerminalNode, }; }); - public constructor(public readonly cst: RuleNode) { - assertKind(this.cst.kind, RuleKind.EnumDefinition); + public constructor(public readonly cst: NonTerminalNode) { + assertKind(this.cst.kind, NonTerminalKind.EnumDefinition); } - public get enumKeyword(): TokenNode { + public get enumKeyword(): TerminalNode { return this.fetch().enumKeyword; } - public get name(): TokenNode { + public get name(): TerminalNode { return this.fetch().name; } - public get openBrace(): TokenNode { + public get openBrace(): TerminalNode { return this.fetch().openBrace; } @@ -739,7 +739,7 @@ export class EnumDefinition { return this.fetch().members; } - public get closeBrace(): TokenNode { + public get closeBrace(): TerminalNode { return this.fetch().closeBrace; } } @@ -749,32 +749,32 @@ export class ConstantDefinition { const [$typeName, $constantKeyword, $name, $equal, $value, $semicolon] = ast_internal.selectSequence(this.cst); return { - typeName: new TypeName($typeName as RuleNode), - constantKeyword: $constantKeyword as TokenNode, - name: $name as TokenNode, - equal: $equal as TokenNode, - value: new Expression($value as RuleNode), - semicolon: $semicolon as TokenNode, + typeName: new TypeName($typeName as NonTerminalNode), + constantKeyword: $constantKeyword as TerminalNode, + name: $name as TerminalNode, + equal: $equal as TerminalNode, + value: new Expression($value as NonTerminalNode), + semicolon: $semicolon as TerminalNode, }; }); - public constructor(public readonly cst: RuleNode) { - assertKind(this.cst.kind, RuleKind.ConstantDefinition); + public constructor(public readonly cst: NonTerminalNode) { + assertKind(this.cst.kind, NonTerminalKind.ConstantDefinition); } public get typeName(): TypeName { return this.fetch().typeName; } - public get constantKeyword(): TokenNode { + public get constantKeyword(): TerminalNode { return this.fetch().constantKeyword; } - public get name(): TokenNode { + public get name(): TerminalNode { return this.fetch().name; } - public get equal(): TokenNode { + public get equal(): TerminalNode { return this.fetch().equal; } @@ -782,7 +782,7 @@ export class ConstantDefinition { return this.fetch().value; } - public get semicolon(): TokenNode { + public get semicolon(): TerminalNode { return this.fetch().semicolon; } } @@ -792,16 +792,16 @@ export class StateVariableDefinition { const [$typeName, $attributes, $name, $value, $semicolon] = ast_internal.selectSequence(this.cst); return { - typeName: new TypeName($typeName as RuleNode), - attributes: new StateVariableAttributes($attributes as RuleNode), - name: $name as TokenNode, - value: $value === null ? undefined : new StateVariableDefinitionValue($value as RuleNode), - semicolon: $semicolon as TokenNode, + typeName: new TypeName($typeName as NonTerminalNode), + attributes: new StateVariableAttributes($attributes as NonTerminalNode), + name: $name as TerminalNode, + value: $value === null ? undefined : new StateVariableDefinitionValue($value as NonTerminalNode), + semicolon: $semicolon as TerminalNode, }; }); - public constructor(public readonly cst: RuleNode) { - assertKind(this.cst.kind, RuleKind.StateVariableDefinition); + public constructor(public readonly cst: NonTerminalNode) { + assertKind(this.cst.kind, NonTerminalKind.StateVariableDefinition); } public get typeName(): TypeName { @@ -812,7 +812,7 @@ export class StateVariableDefinition { return this.fetch().attributes; } - public get name(): TokenNode { + public get name(): TerminalNode { return this.fetch().name; } @@ -820,7 +820,7 @@ export class StateVariableDefinition { return this.fetch().value; } - public get semicolon(): TokenNode { + public get semicolon(): TerminalNode { return this.fetch().semicolon; } } @@ -830,16 +830,16 @@ export class StateVariableDefinitionValue { const [$equal, $value] = ast_internal.selectSequence(this.cst); return { - equal: $equal as TokenNode, - value: new Expression($value as RuleNode), + equal: $equal as TerminalNode, + value: new Expression($value as NonTerminalNode), }; }); - public constructor(public readonly cst: RuleNode) { - assertKind(this.cst.kind, RuleKind.StateVariableDefinitionValue); + public constructor(public readonly cst: NonTerminalNode) { + assertKind(this.cst.kind, NonTerminalKind.StateVariableDefinitionValue); } - public get equal(): TokenNode { + public get equal(): TerminalNode { return this.fetch().equal; } @@ -853,20 +853,20 @@ export class FunctionDefinition { const [$functionKeyword, $name, $parameters, $attributes, $returns, $body] = ast_internal.selectSequence(this.cst); return { - functionKeyword: $functionKeyword as TokenNode, - name: new FunctionName($name as RuleNode), - parameters: new ParametersDeclaration($parameters as RuleNode), - attributes: new FunctionAttributes($attributes as RuleNode), - returns: $returns === null ? undefined : new ReturnsDeclaration($returns as RuleNode), - body: new FunctionBody($body as RuleNode), + functionKeyword: $functionKeyword as TerminalNode, + name: new FunctionName($name as NonTerminalNode), + parameters: new ParametersDeclaration($parameters as NonTerminalNode), + attributes: new FunctionAttributes($attributes as NonTerminalNode), + returns: $returns === null ? undefined : new ReturnsDeclaration($returns as NonTerminalNode), + body: new FunctionBody($body as NonTerminalNode), }; }); - public constructor(public readonly cst: RuleNode) { - assertKind(this.cst.kind, RuleKind.FunctionDefinition); + public constructor(public readonly cst: NonTerminalNode) { + assertKind(this.cst.kind, NonTerminalKind.FunctionDefinition); } - public get functionKeyword(): TokenNode { + public get functionKeyword(): TerminalNode { return this.fetch().functionKeyword; } @@ -896,17 +896,17 @@ export class ParametersDeclaration { const [$openParen, $parameters, $closeParen] = ast_internal.selectSequence(this.cst); return { - openParen: $openParen as TokenNode, - parameters: new Parameters($parameters as RuleNode), - closeParen: $closeParen as TokenNode, + openParen: $openParen as TerminalNode, + parameters: new Parameters($parameters as NonTerminalNode), + closeParen: $closeParen as TerminalNode, }; }); - public constructor(public readonly cst: RuleNode) { - assertKind(this.cst.kind, RuleKind.ParametersDeclaration); + public constructor(public readonly cst: NonTerminalNode) { + assertKind(this.cst.kind, NonTerminalKind.ParametersDeclaration); } - public get openParen(): TokenNode { + public get openParen(): TerminalNode { return this.fetch().openParen; } @@ -914,7 +914,7 @@ export class ParametersDeclaration { return this.fetch().parameters; } - public get closeParen(): TokenNode { + public get closeParen(): TerminalNode { return this.fetch().closeParen; } } @@ -924,14 +924,14 @@ export class Parameter { const [$typeName, $storageLocation, $name] = ast_internal.selectSequence(this.cst); return { - typeName: new TypeName($typeName as RuleNode), - storageLocation: $storageLocation === null ? undefined : new StorageLocation($storageLocation as RuleNode), - name: $name === null ? undefined : ($name as TokenNode), + typeName: new TypeName($typeName as NonTerminalNode), + storageLocation: $storageLocation === null ? undefined : new StorageLocation($storageLocation as NonTerminalNode), + name: $name === null ? undefined : ($name as TerminalNode), }; }); - public constructor(public readonly cst: RuleNode) { - assertKind(this.cst.kind, RuleKind.Parameter); + public constructor(public readonly cst: NonTerminalNode) { + assertKind(this.cst.kind, NonTerminalKind.Parameter); } public get typeName(): TypeName { @@ -942,7 +942,7 @@ export class Parameter { return this.fetch().storageLocation; } - public get name(): TokenNode | undefined { + public get name(): TerminalNode | undefined { return this.fetch().name; } } @@ -952,16 +952,16 @@ export class OverrideSpecifier { const [$overrideKeyword, $overridden] = ast_internal.selectSequence(this.cst); return { - overrideKeyword: $overrideKeyword as TokenNode, - overridden: $overridden === null ? undefined : new OverridePathsDeclaration($overridden as RuleNode), + overrideKeyword: $overrideKeyword as TerminalNode, + overridden: $overridden === null ? undefined : new OverridePathsDeclaration($overridden as NonTerminalNode), }; }); - public constructor(public readonly cst: RuleNode) { - assertKind(this.cst.kind, RuleKind.OverrideSpecifier); + public constructor(public readonly cst: NonTerminalNode) { + assertKind(this.cst.kind, NonTerminalKind.OverrideSpecifier); } - public get overrideKeyword(): TokenNode { + public get overrideKeyword(): TerminalNode { return this.fetch().overrideKeyword; } @@ -975,17 +975,17 @@ export class OverridePathsDeclaration { const [$openParen, $paths, $closeParen] = ast_internal.selectSequence(this.cst); return { - openParen: $openParen as TokenNode, - paths: new OverridePaths($paths as RuleNode), - closeParen: $closeParen as TokenNode, + openParen: $openParen as TerminalNode, + paths: new OverridePaths($paths as NonTerminalNode), + closeParen: $closeParen as TerminalNode, }; }); - public constructor(public readonly cst: RuleNode) { - assertKind(this.cst.kind, RuleKind.OverridePathsDeclaration); + public constructor(public readonly cst: NonTerminalNode) { + assertKind(this.cst.kind, NonTerminalKind.OverridePathsDeclaration); } - public get openParen(): TokenNode { + public get openParen(): TerminalNode { return this.fetch().openParen; } @@ -993,7 +993,7 @@ export class OverridePathsDeclaration { return this.fetch().paths; } - public get closeParen(): TokenNode { + public get closeParen(): TerminalNode { return this.fetch().closeParen; } } @@ -1003,16 +1003,16 @@ export class ReturnsDeclaration { const [$returnsKeyword, $variables] = ast_internal.selectSequence(this.cst); return { - returnsKeyword: $returnsKeyword as TokenNode, - variables: new ParametersDeclaration($variables as RuleNode), + returnsKeyword: $returnsKeyword as TerminalNode, + variables: new ParametersDeclaration($variables as NonTerminalNode), }; }); - public constructor(public readonly cst: RuleNode) { - assertKind(this.cst.kind, RuleKind.ReturnsDeclaration); + public constructor(public readonly cst: NonTerminalNode) { + assertKind(this.cst.kind, NonTerminalKind.ReturnsDeclaration); } - public get returnsKeyword(): TokenNode { + public get returnsKeyword(): TerminalNode { return this.fetch().returnsKeyword; } @@ -1026,18 +1026,18 @@ export class ConstructorDefinition { const [$constructorKeyword, $parameters, $attributes, $body] = ast_internal.selectSequence(this.cst); return { - constructorKeyword: $constructorKeyword as TokenNode, - parameters: new ParametersDeclaration($parameters as RuleNode), - attributes: new ConstructorAttributes($attributes as RuleNode), - body: new Block($body as RuleNode), + constructorKeyword: $constructorKeyword as TerminalNode, + parameters: new ParametersDeclaration($parameters as NonTerminalNode), + attributes: new ConstructorAttributes($attributes as NonTerminalNode), + body: new Block($body as NonTerminalNode), }; }); - public constructor(public readonly cst: RuleNode) { - assertKind(this.cst.kind, RuleKind.ConstructorDefinition); + public constructor(public readonly cst: NonTerminalNode) { + assertKind(this.cst.kind, NonTerminalKind.ConstructorDefinition); } - public get constructorKeyword(): TokenNode { + public get constructorKeyword(): TerminalNode { return this.fetch().constructorKeyword; } @@ -1059,18 +1059,18 @@ export class UnnamedFunctionDefinition { const [$functionKeyword, $parameters, $attributes, $body] = ast_internal.selectSequence(this.cst); return { - functionKeyword: $functionKeyword as TokenNode, - parameters: new ParametersDeclaration($parameters as RuleNode), - attributes: new UnnamedFunctionAttributes($attributes as RuleNode), - body: new FunctionBody($body as RuleNode), + functionKeyword: $functionKeyword as TerminalNode, + parameters: new ParametersDeclaration($parameters as NonTerminalNode), + attributes: new UnnamedFunctionAttributes($attributes as NonTerminalNode), + body: new FunctionBody($body as NonTerminalNode), }; }); - public constructor(public readonly cst: RuleNode) { - assertKind(this.cst.kind, RuleKind.UnnamedFunctionDefinition); + public constructor(public readonly cst: NonTerminalNode) { + assertKind(this.cst.kind, NonTerminalKind.UnnamedFunctionDefinition); } - public get functionKeyword(): TokenNode { + public get functionKeyword(): TerminalNode { return this.fetch().functionKeyword; } @@ -1092,19 +1092,19 @@ export class FallbackFunctionDefinition { const [$fallbackKeyword, $parameters, $attributes, $returns, $body] = ast_internal.selectSequence(this.cst); return { - fallbackKeyword: $fallbackKeyword as TokenNode, - parameters: new ParametersDeclaration($parameters as RuleNode), - attributes: new FallbackFunctionAttributes($attributes as RuleNode), - returns: $returns === null ? undefined : new ReturnsDeclaration($returns as RuleNode), - body: new FunctionBody($body as RuleNode), + fallbackKeyword: $fallbackKeyword as TerminalNode, + parameters: new ParametersDeclaration($parameters as NonTerminalNode), + attributes: new FallbackFunctionAttributes($attributes as NonTerminalNode), + returns: $returns === null ? undefined : new ReturnsDeclaration($returns as NonTerminalNode), + body: new FunctionBody($body as NonTerminalNode), }; }); - public constructor(public readonly cst: RuleNode) { - assertKind(this.cst.kind, RuleKind.FallbackFunctionDefinition); + public constructor(public readonly cst: NonTerminalNode) { + assertKind(this.cst.kind, NonTerminalKind.FallbackFunctionDefinition); } - public get fallbackKeyword(): TokenNode { + public get fallbackKeyword(): TerminalNode { return this.fetch().fallbackKeyword; } @@ -1130,18 +1130,18 @@ export class ReceiveFunctionDefinition { const [$receiveKeyword, $parameters, $attributes, $body] = ast_internal.selectSequence(this.cst); return { - receiveKeyword: $receiveKeyword as TokenNode, - parameters: new ParametersDeclaration($parameters as RuleNode), - attributes: new ReceiveFunctionAttributes($attributes as RuleNode), - body: new FunctionBody($body as RuleNode), + receiveKeyword: $receiveKeyword as TerminalNode, + parameters: new ParametersDeclaration($parameters as NonTerminalNode), + attributes: new ReceiveFunctionAttributes($attributes as NonTerminalNode), + body: new FunctionBody($body as NonTerminalNode), }; }); - public constructor(public readonly cst: RuleNode) { - assertKind(this.cst.kind, RuleKind.ReceiveFunctionDefinition); + public constructor(public readonly cst: NonTerminalNode) { + assertKind(this.cst.kind, NonTerminalKind.ReceiveFunctionDefinition); } - public get receiveKeyword(): TokenNode { + public get receiveKeyword(): TerminalNode { return this.fetch().receiveKeyword; } @@ -1163,23 +1163,23 @@ export class ModifierDefinition { const [$modifierKeyword, $name, $parameters, $attributes, $body] = ast_internal.selectSequence(this.cst); return { - modifierKeyword: $modifierKeyword as TokenNode, - name: $name as TokenNode, - parameters: $parameters === null ? undefined : new ParametersDeclaration($parameters as RuleNode), - attributes: new ModifierAttributes($attributes as RuleNode), - body: new FunctionBody($body as RuleNode), + modifierKeyword: $modifierKeyword as TerminalNode, + name: $name as TerminalNode, + parameters: $parameters === null ? undefined : new ParametersDeclaration($parameters as NonTerminalNode), + attributes: new ModifierAttributes($attributes as NonTerminalNode), + body: new FunctionBody($body as NonTerminalNode), }; }); - public constructor(public readonly cst: RuleNode) { - assertKind(this.cst.kind, RuleKind.ModifierDefinition); + public constructor(public readonly cst: NonTerminalNode) { + assertKind(this.cst.kind, NonTerminalKind.ModifierDefinition); } - public get modifierKeyword(): TokenNode { + public get modifierKeyword(): TerminalNode { return this.fetch().modifierKeyword; } - public get name(): TokenNode { + public get name(): TerminalNode { return this.fetch().name; } @@ -1201,13 +1201,13 @@ export class ModifierInvocation { const [$name, $arguments] = ast_internal.selectSequence(this.cst); return { - name: new IdentifierPath($name as RuleNode), - arguments: $arguments === null ? undefined : new ArgumentsDeclaration($arguments as RuleNode), + name: new IdentifierPath($name as NonTerminalNode), + arguments: $arguments === null ? undefined : new ArgumentsDeclaration($arguments as NonTerminalNode), }; }); - public constructor(public readonly cst: RuleNode) { - assertKind(this.cst.kind, RuleKind.ModifierInvocation); + public constructor(public readonly cst: NonTerminalNode) { + assertKind(this.cst.kind, NonTerminalKind.ModifierInvocation); } public get name(): IdentifierPath { @@ -1224,23 +1224,23 @@ export class EventDefinition { const [$eventKeyword, $name, $parameters, $anonymousKeyword, $semicolon] = ast_internal.selectSequence(this.cst); return { - eventKeyword: $eventKeyword as TokenNode, - name: $name as TokenNode, - parameters: new EventParametersDeclaration($parameters as RuleNode), - anonymousKeyword: $anonymousKeyword === null ? undefined : ($anonymousKeyword as TokenNode), - semicolon: $semicolon as TokenNode, + eventKeyword: $eventKeyword as TerminalNode, + name: $name as TerminalNode, + parameters: new EventParametersDeclaration($parameters as NonTerminalNode), + anonymousKeyword: $anonymousKeyword === null ? undefined : ($anonymousKeyword as TerminalNode), + semicolon: $semicolon as TerminalNode, }; }); - public constructor(public readonly cst: RuleNode) { - assertKind(this.cst.kind, RuleKind.EventDefinition); + public constructor(public readonly cst: NonTerminalNode) { + assertKind(this.cst.kind, NonTerminalKind.EventDefinition); } - public get eventKeyword(): TokenNode { + public get eventKeyword(): TerminalNode { return this.fetch().eventKeyword; } - public get name(): TokenNode { + public get name(): TerminalNode { return this.fetch().name; } @@ -1248,11 +1248,11 @@ export class EventDefinition { return this.fetch().parameters; } - public get anonymousKeyword(): TokenNode | undefined { + public get anonymousKeyword(): TerminalNode | undefined { return this.fetch().anonymousKeyword; } - public get semicolon(): TokenNode { + public get semicolon(): TerminalNode { return this.fetch().semicolon; } } @@ -1262,17 +1262,17 @@ export class EventParametersDeclaration { const [$openParen, $parameters, $closeParen] = ast_internal.selectSequence(this.cst); return { - openParen: $openParen as TokenNode, - parameters: new EventParameters($parameters as RuleNode), - closeParen: $closeParen as TokenNode, + openParen: $openParen as TerminalNode, + parameters: new EventParameters($parameters as NonTerminalNode), + closeParen: $closeParen as TerminalNode, }; }); - public constructor(public readonly cst: RuleNode) { - assertKind(this.cst.kind, RuleKind.EventParametersDeclaration); + public constructor(public readonly cst: NonTerminalNode) { + assertKind(this.cst.kind, NonTerminalKind.EventParametersDeclaration); } - public get openParen(): TokenNode { + public get openParen(): TerminalNode { return this.fetch().openParen; } @@ -1280,7 +1280,7 @@ export class EventParametersDeclaration { return this.fetch().parameters; } - public get closeParen(): TokenNode { + public get closeParen(): TerminalNode { return this.fetch().closeParen; } } @@ -1290,25 +1290,25 @@ export class EventParameter { const [$typeName, $indexedKeyword, $name] = ast_internal.selectSequence(this.cst); return { - typeName: new TypeName($typeName as RuleNode), - indexedKeyword: $indexedKeyword === null ? undefined : ($indexedKeyword as TokenNode), - name: $name === null ? undefined : ($name as TokenNode), + typeName: new TypeName($typeName as NonTerminalNode), + indexedKeyword: $indexedKeyword === null ? undefined : ($indexedKeyword as TerminalNode), + name: $name === null ? undefined : ($name as TerminalNode), }; }); - public constructor(public readonly cst: RuleNode) { - assertKind(this.cst.kind, RuleKind.EventParameter); + public constructor(public readonly cst: NonTerminalNode) { + assertKind(this.cst.kind, NonTerminalKind.EventParameter); } public get typeName(): TypeName { return this.fetch().typeName; } - public get indexedKeyword(): TokenNode | undefined { + public get indexedKeyword(): TerminalNode | undefined { return this.fetch().indexedKeyword; } - public get name(): TokenNode | undefined { + public get name(): TerminalNode | undefined { return this.fetch().name; } } @@ -1318,27 +1318,27 @@ export class UserDefinedValueTypeDefinition { const [$typeKeyword, $name, $isKeyword, $valueType, $semicolon] = ast_internal.selectSequence(this.cst); return { - typeKeyword: $typeKeyword as TokenNode, - name: $name as TokenNode, - isKeyword: $isKeyword as TokenNode, - valueType: new ElementaryType($valueType as RuleNode), - semicolon: $semicolon as TokenNode, + typeKeyword: $typeKeyword as TerminalNode, + name: $name as TerminalNode, + isKeyword: $isKeyword as TerminalNode, + valueType: new ElementaryType($valueType as NonTerminalNode), + semicolon: $semicolon as TerminalNode, }; }); - public constructor(public readonly cst: RuleNode) { - assertKind(this.cst.kind, RuleKind.UserDefinedValueTypeDefinition); + public constructor(public readonly cst: NonTerminalNode) { + assertKind(this.cst.kind, NonTerminalKind.UserDefinedValueTypeDefinition); } - public get typeKeyword(): TokenNode { + public get typeKeyword(): TerminalNode { return this.fetch().typeKeyword; } - public get name(): TokenNode { + public get name(): TerminalNode { return this.fetch().name; } - public get isKeyword(): TokenNode { + public get isKeyword(): TerminalNode { return this.fetch().isKeyword; } @@ -1346,7 +1346,7 @@ export class UserDefinedValueTypeDefinition { return this.fetch().valueType; } - public get semicolon(): TokenNode { + public get semicolon(): TerminalNode { return this.fetch().semicolon; } } @@ -1356,22 +1356,22 @@ export class ErrorDefinition { const [$errorKeyword, $name, $members, $semicolon] = ast_internal.selectSequence(this.cst); return { - errorKeyword: $errorKeyword as TokenNode, - name: $name as TokenNode, - members: new ErrorParametersDeclaration($members as RuleNode), - semicolon: $semicolon as TokenNode, + errorKeyword: $errorKeyword as TerminalNode, + name: $name as TerminalNode, + members: new ErrorParametersDeclaration($members as NonTerminalNode), + semicolon: $semicolon as TerminalNode, }; }); - public constructor(public readonly cst: RuleNode) { - assertKind(this.cst.kind, RuleKind.ErrorDefinition); + public constructor(public readonly cst: NonTerminalNode) { + assertKind(this.cst.kind, NonTerminalKind.ErrorDefinition); } - public get errorKeyword(): TokenNode { + public get errorKeyword(): TerminalNode { return this.fetch().errorKeyword; } - public get name(): TokenNode { + public get name(): TerminalNode { return this.fetch().name; } @@ -1379,7 +1379,7 @@ export class ErrorDefinition { return this.fetch().members; } - public get semicolon(): TokenNode { + public get semicolon(): TerminalNode { return this.fetch().semicolon; } } @@ -1389,17 +1389,17 @@ export class ErrorParametersDeclaration { const [$openParen, $parameters, $closeParen] = ast_internal.selectSequence(this.cst); return { - openParen: $openParen as TokenNode, - parameters: new ErrorParameters($parameters as RuleNode), - closeParen: $closeParen as TokenNode, + openParen: $openParen as TerminalNode, + parameters: new ErrorParameters($parameters as NonTerminalNode), + closeParen: $closeParen as TerminalNode, }; }); - public constructor(public readonly cst: RuleNode) { - assertKind(this.cst.kind, RuleKind.ErrorParametersDeclaration); + public constructor(public readonly cst: NonTerminalNode) { + assertKind(this.cst.kind, NonTerminalKind.ErrorParametersDeclaration); } - public get openParen(): TokenNode { + public get openParen(): TerminalNode { return this.fetch().openParen; } @@ -1407,7 +1407,7 @@ export class ErrorParametersDeclaration { return this.fetch().parameters; } - public get closeParen(): TokenNode { + public get closeParen(): TerminalNode { return this.fetch().closeParen; } } @@ -1417,20 +1417,20 @@ export class ErrorParameter { const [$typeName, $name] = ast_internal.selectSequence(this.cst); return { - typeName: new TypeName($typeName as RuleNode), - name: $name === null ? undefined : ($name as TokenNode), + typeName: new TypeName($typeName as NonTerminalNode), + name: $name === null ? undefined : ($name as TerminalNode), }; }); - public constructor(public readonly cst: RuleNode) { - assertKind(this.cst.kind, RuleKind.ErrorParameter); + public constructor(public readonly cst: NonTerminalNode) { + assertKind(this.cst.kind, NonTerminalKind.ErrorParameter); } public get typeName(): TypeName { return this.fetch().typeName; } - public get name(): TokenNode | undefined { + public get name(): TerminalNode | undefined { return this.fetch().name; } } @@ -1440,22 +1440,22 @@ export class ArrayTypeName { const [$operand, $openBracket, $index, $closeBracket] = ast_internal.selectSequence(this.cst); return { - operand: new TypeName($operand as RuleNode), - openBracket: $openBracket as TokenNode, - index: $index === null ? undefined : new Expression($index as RuleNode), - closeBracket: $closeBracket as TokenNode, + operand: new TypeName($operand as NonTerminalNode), + openBracket: $openBracket as TerminalNode, + index: $index === null ? undefined : new Expression($index as NonTerminalNode), + closeBracket: $closeBracket as TerminalNode, }; }); - public constructor(public readonly cst: RuleNode) { - assertKind(this.cst.kind, RuleKind.ArrayTypeName); + public constructor(public readonly cst: NonTerminalNode) { + assertKind(this.cst.kind, NonTerminalKind.ArrayTypeName); } public get operand(): TypeName { return this.fetch().operand; } - public get openBracket(): TokenNode { + public get openBracket(): TerminalNode { return this.fetch().openBracket; } @@ -1463,7 +1463,7 @@ export class ArrayTypeName { return this.fetch().index; } - public get closeBracket(): TokenNode { + public get closeBracket(): TerminalNode { return this.fetch().closeBracket; } } @@ -1473,18 +1473,18 @@ export class FunctionType { const [$functionKeyword, $parameters, $attributes, $returns] = ast_internal.selectSequence(this.cst); return { - functionKeyword: $functionKeyword as TokenNode, - parameters: new ParametersDeclaration($parameters as RuleNode), - attributes: new FunctionTypeAttributes($attributes as RuleNode), - returns: $returns === null ? undefined : new ReturnsDeclaration($returns as RuleNode), + functionKeyword: $functionKeyword as TerminalNode, + parameters: new ParametersDeclaration($parameters as NonTerminalNode), + attributes: new FunctionTypeAttributes($attributes as NonTerminalNode), + returns: $returns === null ? undefined : new ReturnsDeclaration($returns as NonTerminalNode), }; }); - public constructor(public readonly cst: RuleNode) { - assertKind(this.cst.kind, RuleKind.FunctionType); + public constructor(public readonly cst: NonTerminalNode) { + assertKind(this.cst.kind, NonTerminalKind.FunctionType); } - public get functionKeyword(): TokenNode { + public get functionKeyword(): TerminalNode { return this.fetch().functionKeyword; } @@ -1507,24 +1507,24 @@ export class MappingType { ast_internal.selectSequence(this.cst); return { - mappingKeyword: $mappingKeyword as TokenNode, - openParen: $openParen as TokenNode, - keyType: new MappingKey($keyType as RuleNode), - equalGreaterThan: $equalGreaterThan as TokenNode, - valueType: new MappingValue($valueType as RuleNode), - closeParen: $closeParen as TokenNode, + mappingKeyword: $mappingKeyword as TerminalNode, + openParen: $openParen as TerminalNode, + keyType: new MappingKey($keyType as NonTerminalNode), + equalGreaterThan: $equalGreaterThan as TerminalNode, + valueType: new MappingValue($valueType as NonTerminalNode), + closeParen: $closeParen as TerminalNode, }; }); - public constructor(public readonly cst: RuleNode) { - assertKind(this.cst.kind, RuleKind.MappingType); + public constructor(public readonly cst: NonTerminalNode) { + assertKind(this.cst.kind, NonTerminalKind.MappingType); } - public get mappingKeyword(): TokenNode { + public get mappingKeyword(): TerminalNode { return this.fetch().mappingKeyword; } - public get openParen(): TokenNode { + public get openParen(): TerminalNode { return this.fetch().openParen; } @@ -1532,7 +1532,7 @@ export class MappingType { return this.fetch().keyType; } - public get equalGreaterThan(): TokenNode { + public get equalGreaterThan(): TerminalNode { return this.fetch().equalGreaterThan; } @@ -1540,7 +1540,7 @@ export class MappingType { return this.fetch().valueType; } - public get closeParen(): TokenNode { + public get closeParen(): TerminalNode { return this.fetch().closeParen; } } @@ -1550,20 +1550,20 @@ export class MappingKey { const [$keyType, $name] = ast_internal.selectSequence(this.cst); return { - keyType: new MappingKeyType($keyType as RuleNode), - name: $name === null ? undefined : ($name as TokenNode), + keyType: new MappingKeyType($keyType as NonTerminalNode), + name: $name === null ? undefined : ($name as TerminalNode), }; }); - public constructor(public readonly cst: RuleNode) { - assertKind(this.cst.kind, RuleKind.MappingKey); + public constructor(public readonly cst: NonTerminalNode) { + assertKind(this.cst.kind, NonTerminalKind.MappingKey); } public get keyType(): MappingKeyType { return this.fetch().keyType; } - public get name(): TokenNode | undefined { + public get name(): TerminalNode | undefined { return this.fetch().name; } } @@ -1573,20 +1573,20 @@ export class MappingValue { const [$typeName, $name] = ast_internal.selectSequence(this.cst); return { - typeName: new TypeName($typeName as RuleNode), - name: $name === null ? undefined : ($name as TokenNode), + typeName: new TypeName($typeName as NonTerminalNode), + name: $name === null ? undefined : ($name as TerminalNode), }; }); - public constructor(public readonly cst: RuleNode) { - assertKind(this.cst.kind, RuleKind.MappingValue); + public constructor(public readonly cst: NonTerminalNode) { + assertKind(this.cst.kind, NonTerminalKind.MappingValue); } public get typeName(): TypeName { return this.fetch().typeName; } - public get name(): TokenNode | undefined { + public get name(): TerminalNode | undefined { return this.fetch().name; } } @@ -1596,20 +1596,20 @@ export class AddressType { const [$addressKeyword, $payableKeyword] = ast_internal.selectSequence(this.cst); return { - addressKeyword: $addressKeyword as TokenNode, - payableKeyword: $payableKeyword === null ? undefined : ($payableKeyword as TokenNode), + addressKeyword: $addressKeyword as TerminalNode, + payableKeyword: $payableKeyword === null ? undefined : ($payableKeyword as TerminalNode), }; }); - public constructor(public readonly cst: RuleNode) { - assertKind(this.cst.kind, RuleKind.AddressType); + public constructor(public readonly cst: NonTerminalNode) { + assertKind(this.cst.kind, NonTerminalKind.AddressType); } - public get addressKeyword(): TokenNode { + public get addressKeyword(): TerminalNode { return this.fetch().addressKeyword; } - public get payableKeyword(): TokenNode | undefined { + public get payableKeyword(): TerminalNode | undefined { return this.fetch().payableKeyword; } } @@ -1619,17 +1619,17 @@ export class Block { const [$openBrace, $statements, $closeBrace] = ast_internal.selectSequence(this.cst); return { - openBrace: $openBrace as TokenNode, - statements: new Statements($statements as RuleNode), - closeBrace: $closeBrace as TokenNode, + openBrace: $openBrace as TerminalNode, + statements: new Statements($statements as NonTerminalNode), + closeBrace: $closeBrace as TerminalNode, }; }); - public constructor(public readonly cst: RuleNode) { - assertKind(this.cst.kind, RuleKind.Block); + public constructor(public readonly cst: NonTerminalNode) { + assertKind(this.cst.kind, NonTerminalKind.Block); } - public get openBrace(): TokenNode { + public get openBrace(): TerminalNode { return this.fetch().openBrace; } @@ -1637,7 +1637,7 @@ export class Block { return this.fetch().statements; } - public get closeBrace(): TokenNode { + public get closeBrace(): TerminalNode { return this.fetch().closeBrace; } } @@ -1647,16 +1647,16 @@ export class UncheckedBlock { const [$uncheckedKeyword, $block] = ast_internal.selectSequence(this.cst); return { - uncheckedKeyword: $uncheckedKeyword as TokenNode, - block: new Block($block as RuleNode), + uncheckedKeyword: $uncheckedKeyword as TerminalNode, + block: new Block($block as NonTerminalNode), }; }); - public constructor(public readonly cst: RuleNode) { - assertKind(this.cst.kind, RuleKind.UncheckedBlock); + public constructor(public readonly cst: NonTerminalNode) { + assertKind(this.cst.kind, NonTerminalKind.UncheckedBlock); } - public get uncheckedKeyword(): TokenNode { + public get uncheckedKeyword(): TerminalNode { return this.fetch().uncheckedKeyword; } @@ -1670,20 +1670,20 @@ export class ExpressionStatement { const [$expression, $semicolon] = ast_internal.selectSequence(this.cst); return { - expression: new Expression($expression as RuleNode), - semicolon: $semicolon as TokenNode, + expression: new Expression($expression as NonTerminalNode), + semicolon: $semicolon as TerminalNode, }; }); - public constructor(public readonly cst: RuleNode) { - assertKind(this.cst.kind, RuleKind.ExpressionStatement); + public constructor(public readonly cst: NonTerminalNode) { + assertKind(this.cst.kind, NonTerminalKind.ExpressionStatement); } public get expression(): Expression { return this.fetch().expression; } - public get semicolon(): TokenNode { + public get semicolon(): TerminalNode { return this.fetch().semicolon; } } @@ -1693,18 +1693,18 @@ export class AssemblyStatement { const [$assemblyKeyword, $label, $flags, $body] = ast_internal.selectSequence(this.cst); return { - assemblyKeyword: $assemblyKeyword as TokenNode, - label: $label === null ? undefined : new StringLiteral($label as RuleNode), - flags: $flags === null ? undefined : new AssemblyFlagsDeclaration($flags as RuleNode), - body: new YulBlock($body as RuleNode), + assemblyKeyword: $assemblyKeyword as TerminalNode, + label: $label === null ? undefined : new StringLiteral($label as NonTerminalNode), + flags: $flags === null ? undefined : new AssemblyFlagsDeclaration($flags as NonTerminalNode), + body: new YulBlock($body as NonTerminalNode), }; }); - public constructor(public readonly cst: RuleNode) { - assertKind(this.cst.kind, RuleKind.AssemblyStatement); + public constructor(public readonly cst: NonTerminalNode) { + assertKind(this.cst.kind, NonTerminalKind.AssemblyStatement); } - public get assemblyKeyword(): TokenNode { + public get assemblyKeyword(): TerminalNode { return this.fetch().assemblyKeyword; } @@ -1726,17 +1726,17 @@ export class AssemblyFlagsDeclaration { const [$openParen, $flags, $closeParen] = ast_internal.selectSequence(this.cst); return { - openParen: $openParen as TokenNode, - flags: new AssemblyFlags($flags as RuleNode), - closeParen: $closeParen as TokenNode, + openParen: $openParen as TerminalNode, + flags: new AssemblyFlags($flags as NonTerminalNode), + closeParen: $closeParen as TerminalNode, }; }); - public constructor(public readonly cst: RuleNode) { - assertKind(this.cst.kind, RuleKind.AssemblyFlagsDeclaration); + public constructor(public readonly cst: NonTerminalNode) { + assertKind(this.cst.kind, NonTerminalKind.AssemblyFlagsDeclaration); } - public get openParen(): TokenNode { + public get openParen(): TerminalNode { return this.fetch().openParen; } @@ -1744,7 +1744,7 @@ export class AssemblyFlagsDeclaration { return this.fetch().flags; } - public get closeParen(): TokenNode { + public get closeParen(): TerminalNode { return this.fetch().closeParen; } } @@ -1755,25 +1755,25 @@ export class TupleDeconstructionStatement { ast_internal.selectSequence(this.cst); return { - varKeyword: $varKeyword === null ? undefined : ($varKeyword as TokenNode), - openParen: $openParen as TokenNode, - elements: new TupleDeconstructionElements($elements as RuleNode), - closeParen: $closeParen as TokenNode, - equal: $equal as TokenNode, - expression: new Expression($expression as RuleNode), - semicolon: $semicolon as TokenNode, + varKeyword: $varKeyword === null ? undefined : ($varKeyword as TerminalNode), + openParen: $openParen as TerminalNode, + elements: new TupleDeconstructionElements($elements as NonTerminalNode), + closeParen: $closeParen as TerminalNode, + equal: $equal as TerminalNode, + expression: new Expression($expression as NonTerminalNode), + semicolon: $semicolon as TerminalNode, }; }); - public constructor(public readonly cst: RuleNode) { - assertKind(this.cst.kind, RuleKind.TupleDeconstructionStatement); + public constructor(public readonly cst: NonTerminalNode) { + assertKind(this.cst.kind, NonTerminalKind.TupleDeconstructionStatement); } - public get varKeyword(): TokenNode | undefined { + public get varKeyword(): TerminalNode | undefined { return this.fetch().varKeyword; } - public get openParen(): TokenNode { + public get openParen(): TerminalNode { return this.fetch().openParen; } @@ -1781,11 +1781,11 @@ export class TupleDeconstructionStatement { return this.fetch().elements; } - public get closeParen(): TokenNode { + public get closeParen(): TerminalNode { return this.fetch().closeParen; } - public get equal(): TokenNode { + public get equal(): TerminalNode { return this.fetch().equal; } @@ -1793,7 +1793,7 @@ export class TupleDeconstructionStatement { return this.fetch().expression; } - public get semicolon(): TokenNode { + public get semicolon(): TerminalNode { return this.fetch().semicolon; } } @@ -1803,12 +1803,12 @@ export class TupleDeconstructionElement { const [$member] = ast_internal.selectSequence(this.cst); return { - member: $member === null ? undefined : new TupleMember($member as RuleNode), + member: $member === null ? undefined : new TupleMember($member as NonTerminalNode), }; }); - public constructor(public readonly cst: RuleNode) { - assertKind(this.cst.kind, RuleKind.TupleDeconstructionElement); + public constructor(public readonly cst: NonTerminalNode) { + assertKind(this.cst.kind, NonTerminalKind.TupleDeconstructionElement); } public get member(): TupleMember | undefined { @@ -1821,14 +1821,14 @@ export class TypedTupleMember { const [$typeName, $storageLocation, $name] = ast_internal.selectSequence(this.cst); return { - typeName: new TypeName($typeName as RuleNode), - storageLocation: $storageLocation === null ? undefined : new StorageLocation($storageLocation as RuleNode), - name: $name as TokenNode, + typeName: new TypeName($typeName as NonTerminalNode), + storageLocation: $storageLocation === null ? undefined : new StorageLocation($storageLocation as NonTerminalNode), + name: $name as TerminalNode, }; }); - public constructor(public readonly cst: RuleNode) { - assertKind(this.cst.kind, RuleKind.TypedTupleMember); + public constructor(public readonly cst: NonTerminalNode) { + assertKind(this.cst.kind, NonTerminalKind.TypedTupleMember); } public get typeName(): TypeName { @@ -1839,7 +1839,7 @@ export class TypedTupleMember { return this.fetch().storageLocation; } - public get name(): TokenNode { + public get name(): TerminalNode { return this.fetch().name; } } @@ -1849,20 +1849,20 @@ export class UntypedTupleMember { const [$storageLocation, $name] = ast_internal.selectSequence(this.cst); return { - storageLocation: $storageLocation === null ? undefined : new StorageLocation($storageLocation as RuleNode), - name: $name as TokenNode, + storageLocation: $storageLocation === null ? undefined : new StorageLocation($storageLocation as NonTerminalNode), + name: $name as TerminalNode, }; }); - public constructor(public readonly cst: RuleNode) { - assertKind(this.cst.kind, RuleKind.UntypedTupleMember); + public constructor(public readonly cst: NonTerminalNode) { + assertKind(this.cst.kind, NonTerminalKind.UntypedTupleMember); } public get storageLocation(): StorageLocation | undefined { return this.fetch().storageLocation; } - public get name(): TokenNode { + public get name(): TerminalNode { return this.fetch().name; } } @@ -1872,16 +1872,16 @@ export class VariableDeclarationStatement { const [$variableType, $storageLocation, $name, $value, $semicolon] = ast_internal.selectSequence(this.cst); return { - variableType: new VariableDeclarationType($variableType as RuleNode), - storageLocation: $storageLocation === null ? undefined : new StorageLocation($storageLocation as RuleNode), - name: $name as TokenNode, - value: $value === null ? undefined : new VariableDeclarationValue($value as RuleNode), - semicolon: $semicolon as TokenNode, + variableType: new VariableDeclarationType($variableType as NonTerminalNode), + storageLocation: $storageLocation === null ? undefined : new StorageLocation($storageLocation as NonTerminalNode), + name: $name as TerminalNode, + value: $value === null ? undefined : new VariableDeclarationValue($value as NonTerminalNode), + semicolon: $semicolon as TerminalNode, }; }); - public constructor(public readonly cst: RuleNode) { - assertKind(this.cst.kind, RuleKind.VariableDeclarationStatement); + public constructor(public readonly cst: NonTerminalNode) { + assertKind(this.cst.kind, NonTerminalKind.VariableDeclarationStatement); } public get variableType(): VariableDeclarationType { @@ -1892,7 +1892,7 @@ export class VariableDeclarationStatement { return this.fetch().storageLocation; } - public get name(): TokenNode { + public get name(): TerminalNode { return this.fetch().name; } @@ -1900,7 +1900,7 @@ export class VariableDeclarationStatement { return this.fetch().value; } - public get semicolon(): TokenNode { + public get semicolon(): TerminalNode { return this.fetch().semicolon; } } @@ -1910,16 +1910,16 @@ export class VariableDeclarationValue { const [$equal, $expression] = ast_internal.selectSequence(this.cst); return { - equal: $equal as TokenNode, - expression: new Expression($expression as RuleNode), + equal: $equal as TerminalNode, + expression: new Expression($expression as NonTerminalNode), }; }); - public constructor(public readonly cst: RuleNode) { - assertKind(this.cst.kind, RuleKind.VariableDeclarationValue); + public constructor(public readonly cst: NonTerminalNode) { + assertKind(this.cst.kind, NonTerminalKind.VariableDeclarationValue); } - public get equal(): TokenNode { + public get equal(): TerminalNode { return this.fetch().equal; } @@ -1933,24 +1933,24 @@ export class IfStatement { const [$ifKeyword, $openParen, $condition, $closeParen, $body, $elseBranch] = ast_internal.selectSequence(this.cst); return { - ifKeyword: $ifKeyword as TokenNode, - openParen: $openParen as TokenNode, - condition: new Expression($condition as RuleNode), - closeParen: $closeParen as TokenNode, - body: new Statement($body as RuleNode), - elseBranch: $elseBranch === null ? undefined : new ElseBranch($elseBranch as RuleNode), + ifKeyword: $ifKeyword as TerminalNode, + openParen: $openParen as TerminalNode, + condition: new Expression($condition as NonTerminalNode), + closeParen: $closeParen as TerminalNode, + body: new Statement($body as NonTerminalNode), + elseBranch: $elseBranch === null ? undefined : new ElseBranch($elseBranch as NonTerminalNode), }; }); - public constructor(public readonly cst: RuleNode) { - assertKind(this.cst.kind, RuleKind.IfStatement); + public constructor(public readonly cst: NonTerminalNode) { + assertKind(this.cst.kind, NonTerminalKind.IfStatement); } - public get ifKeyword(): TokenNode { + public get ifKeyword(): TerminalNode { return this.fetch().ifKeyword; } - public get openParen(): TokenNode { + public get openParen(): TerminalNode { return this.fetch().openParen; } @@ -1958,7 +1958,7 @@ export class IfStatement { return this.fetch().condition; } - public get closeParen(): TokenNode { + public get closeParen(): TerminalNode { return this.fetch().closeParen; } @@ -1976,16 +1976,16 @@ export class ElseBranch { const [$elseKeyword, $body] = ast_internal.selectSequence(this.cst); return { - elseKeyword: $elseKeyword as TokenNode, - body: new Statement($body as RuleNode), + elseKeyword: $elseKeyword as TerminalNode, + body: new Statement($body as NonTerminalNode), }; }); - public constructor(public readonly cst: RuleNode) { - assertKind(this.cst.kind, RuleKind.ElseBranch); + public constructor(public readonly cst: NonTerminalNode) { + assertKind(this.cst.kind, NonTerminalKind.ElseBranch); } - public get elseKeyword(): TokenNode { + public get elseKeyword(): TerminalNode { return this.fetch().elseKeyword; } @@ -2000,25 +2000,25 @@ export class ForStatement { ast_internal.selectSequence(this.cst); return { - forKeyword: $forKeyword as TokenNode, - openParen: $openParen as TokenNode, - initialization: new ForStatementInitialization($initialization as RuleNode), - condition: new ForStatementCondition($condition as RuleNode), - iterator: $iterator === null ? undefined : new Expression($iterator as RuleNode), - closeParen: $closeParen as TokenNode, - body: new Statement($body as RuleNode), + forKeyword: $forKeyword as TerminalNode, + openParen: $openParen as TerminalNode, + initialization: new ForStatementInitialization($initialization as NonTerminalNode), + condition: new ForStatementCondition($condition as NonTerminalNode), + iterator: $iterator === null ? undefined : new Expression($iterator as NonTerminalNode), + closeParen: $closeParen as TerminalNode, + body: new Statement($body as NonTerminalNode), }; }); - public constructor(public readonly cst: RuleNode) { - assertKind(this.cst.kind, RuleKind.ForStatement); + public constructor(public readonly cst: NonTerminalNode) { + assertKind(this.cst.kind, NonTerminalKind.ForStatement); } - public get forKeyword(): TokenNode { + public get forKeyword(): TerminalNode { return this.fetch().forKeyword; } - public get openParen(): TokenNode { + public get openParen(): TerminalNode { return this.fetch().openParen; } @@ -2034,7 +2034,7 @@ export class ForStatement { return this.fetch().iterator; } - public get closeParen(): TokenNode { + public get closeParen(): TerminalNode { return this.fetch().closeParen; } @@ -2048,23 +2048,23 @@ export class WhileStatement { const [$whileKeyword, $openParen, $condition, $closeParen, $body] = ast_internal.selectSequence(this.cst); return { - whileKeyword: $whileKeyword as TokenNode, - openParen: $openParen as TokenNode, - condition: new Expression($condition as RuleNode), - closeParen: $closeParen as TokenNode, - body: new Statement($body as RuleNode), + whileKeyword: $whileKeyword as TerminalNode, + openParen: $openParen as TerminalNode, + condition: new Expression($condition as NonTerminalNode), + closeParen: $closeParen as TerminalNode, + body: new Statement($body as NonTerminalNode), }; }); - public constructor(public readonly cst: RuleNode) { - assertKind(this.cst.kind, RuleKind.WhileStatement); + public constructor(public readonly cst: NonTerminalNode) { + assertKind(this.cst.kind, NonTerminalKind.WhileStatement); } - public get whileKeyword(): TokenNode { + public get whileKeyword(): TerminalNode { return this.fetch().whileKeyword; } - public get openParen(): TokenNode { + public get openParen(): TerminalNode { return this.fetch().openParen; } @@ -2072,7 +2072,7 @@ export class WhileStatement { return this.fetch().condition; } - public get closeParen(): TokenNode { + public get closeParen(): TerminalNode { return this.fetch().closeParen; } @@ -2087,21 +2087,21 @@ export class DoWhileStatement { ast_internal.selectSequence(this.cst); return { - doKeyword: $doKeyword as TokenNode, - body: new Statement($body as RuleNode), - whileKeyword: $whileKeyword as TokenNode, - openParen: $openParen as TokenNode, - condition: new Expression($condition as RuleNode), - closeParen: $closeParen as TokenNode, - semicolon: $semicolon as TokenNode, + doKeyword: $doKeyword as TerminalNode, + body: new Statement($body as NonTerminalNode), + whileKeyword: $whileKeyword as TerminalNode, + openParen: $openParen as TerminalNode, + condition: new Expression($condition as NonTerminalNode), + closeParen: $closeParen as TerminalNode, + semicolon: $semicolon as TerminalNode, }; }); - public constructor(public readonly cst: RuleNode) { - assertKind(this.cst.kind, RuleKind.DoWhileStatement); + public constructor(public readonly cst: NonTerminalNode) { + assertKind(this.cst.kind, NonTerminalKind.DoWhileStatement); } - public get doKeyword(): TokenNode { + public get doKeyword(): TerminalNode { return this.fetch().doKeyword; } @@ -2109,11 +2109,11 @@ export class DoWhileStatement { return this.fetch().body; } - public get whileKeyword(): TokenNode { + public get whileKeyword(): TerminalNode { return this.fetch().whileKeyword; } - public get openParen(): TokenNode { + public get openParen(): TerminalNode { return this.fetch().openParen; } @@ -2121,11 +2121,11 @@ export class DoWhileStatement { return this.fetch().condition; } - public get closeParen(): TokenNode { + public get closeParen(): TerminalNode { return this.fetch().closeParen; } - public get semicolon(): TokenNode { + public get semicolon(): TerminalNode { return this.fetch().semicolon; } } @@ -2135,20 +2135,20 @@ export class ContinueStatement { const [$continueKeyword, $semicolon] = ast_internal.selectSequence(this.cst); return { - continueKeyword: $continueKeyword as TokenNode, - semicolon: $semicolon as TokenNode, + continueKeyword: $continueKeyword as TerminalNode, + semicolon: $semicolon as TerminalNode, }; }); - public constructor(public readonly cst: RuleNode) { - assertKind(this.cst.kind, RuleKind.ContinueStatement); + public constructor(public readonly cst: NonTerminalNode) { + assertKind(this.cst.kind, NonTerminalKind.ContinueStatement); } - public get continueKeyword(): TokenNode { + public get continueKeyword(): TerminalNode { return this.fetch().continueKeyword; } - public get semicolon(): TokenNode { + public get semicolon(): TerminalNode { return this.fetch().semicolon; } } @@ -2158,20 +2158,20 @@ export class BreakStatement { const [$breakKeyword, $semicolon] = ast_internal.selectSequence(this.cst); return { - breakKeyword: $breakKeyword as TokenNode, - semicolon: $semicolon as TokenNode, + breakKeyword: $breakKeyword as TerminalNode, + semicolon: $semicolon as TerminalNode, }; }); - public constructor(public readonly cst: RuleNode) { - assertKind(this.cst.kind, RuleKind.BreakStatement); + public constructor(public readonly cst: NonTerminalNode) { + assertKind(this.cst.kind, NonTerminalKind.BreakStatement); } - public get breakKeyword(): TokenNode { + public get breakKeyword(): TerminalNode { return this.fetch().breakKeyword; } - public get semicolon(): TokenNode { + public get semicolon(): TerminalNode { return this.fetch().semicolon; } } @@ -2181,17 +2181,17 @@ export class ReturnStatement { const [$returnKeyword, $expression, $semicolon] = ast_internal.selectSequence(this.cst); return { - returnKeyword: $returnKeyword as TokenNode, - expression: $expression === null ? undefined : new Expression($expression as RuleNode), - semicolon: $semicolon as TokenNode, + returnKeyword: $returnKeyword as TerminalNode, + expression: $expression === null ? undefined : new Expression($expression as NonTerminalNode), + semicolon: $semicolon as TerminalNode, }; }); - public constructor(public readonly cst: RuleNode) { - assertKind(this.cst.kind, RuleKind.ReturnStatement); + public constructor(public readonly cst: NonTerminalNode) { + assertKind(this.cst.kind, NonTerminalKind.ReturnStatement); } - public get returnKeyword(): TokenNode { + public get returnKeyword(): TerminalNode { return this.fetch().returnKeyword; } @@ -2199,7 +2199,7 @@ export class ReturnStatement { return this.fetch().expression; } - public get semicolon(): TokenNode { + public get semicolon(): TerminalNode { return this.fetch().semicolon; } } @@ -2209,18 +2209,18 @@ export class EmitStatement { const [$emitKeyword, $event, $arguments, $semicolon] = ast_internal.selectSequence(this.cst); return { - emitKeyword: $emitKeyword as TokenNode, - event: new IdentifierPath($event as RuleNode), - arguments: new ArgumentsDeclaration($arguments as RuleNode), - semicolon: $semicolon as TokenNode, + emitKeyword: $emitKeyword as TerminalNode, + event: new IdentifierPath($event as NonTerminalNode), + arguments: new ArgumentsDeclaration($arguments as NonTerminalNode), + semicolon: $semicolon as TerminalNode, }; }); - public constructor(public readonly cst: RuleNode) { - assertKind(this.cst.kind, RuleKind.EmitStatement); + public constructor(public readonly cst: NonTerminalNode) { + assertKind(this.cst.kind, NonTerminalKind.EmitStatement); } - public get emitKeyword(): TokenNode { + public get emitKeyword(): TerminalNode { return this.fetch().emitKeyword; } @@ -2232,7 +2232,7 @@ export class EmitStatement { return this.fetch().arguments; } - public get semicolon(): TokenNode { + public get semicolon(): TerminalNode { return this.fetch().semicolon; } } @@ -2242,19 +2242,19 @@ export class TryStatement { const [$tryKeyword, $expression, $returns, $body, $catchClauses] = ast_internal.selectSequence(this.cst); return { - tryKeyword: $tryKeyword as TokenNode, - expression: new Expression($expression as RuleNode), - returns: $returns === null ? undefined : new ReturnsDeclaration($returns as RuleNode), - body: new Block($body as RuleNode), - catchClauses: new CatchClauses($catchClauses as RuleNode), + tryKeyword: $tryKeyword as TerminalNode, + expression: new Expression($expression as NonTerminalNode), + returns: $returns === null ? undefined : new ReturnsDeclaration($returns as NonTerminalNode), + body: new Block($body as NonTerminalNode), + catchClauses: new CatchClauses($catchClauses as NonTerminalNode), }; }); - public constructor(public readonly cst: RuleNode) { - assertKind(this.cst.kind, RuleKind.TryStatement); + public constructor(public readonly cst: NonTerminalNode) { + assertKind(this.cst.kind, NonTerminalKind.TryStatement); } - public get tryKeyword(): TokenNode { + public get tryKeyword(): TerminalNode { return this.fetch().tryKeyword; } @@ -2280,17 +2280,17 @@ export class CatchClause { const [$catchKeyword, $error, $body] = ast_internal.selectSequence(this.cst); return { - catchKeyword: $catchKeyword as TokenNode, - error: $error === null ? undefined : new CatchClauseError($error as RuleNode), - body: new Block($body as RuleNode), + catchKeyword: $catchKeyword as TerminalNode, + error: $error === null ? undefined : new CatchClauseError($error as NonTerminalNode), + body: new Block($body as NonTerminalNode), }; }); - public constructor(public readonly cst: RuleNode) { - assertKind(this.cst.kind, RuleKind.CatchClause); + public constructor(public readonly cst: NonTerminalNode) { + assertKind(this.cst.kind, NonTerminalKind.CatchClause); } - public get catchKeyword(): TokenNode { + public get catchKeyword(): TerminalNode { return this.fetch().catchKeyword; } @@ -2308,16 +2308,16 @@ export class CatchClauseError { const [$name, $parameters] = ast_internal.selectSequence(this.cst); return { - name: $name === null ? undefined : ($name as TokenNode), - parameters: new ParametersDeclaration($parameters as RuleNode), + name: $name === null ? undefined : ($name as TerminalNode), + parameters: new ParametersDeclaration($parameters as NonTerminalNode), }; }); - public constructor(public readonly cst: RuleNode) { - assertKind(this.cst.kind, RuleKind.CatchClauseError); + public constructor(public readonly cst: NonTerminalNode) { + assertKind(this.cst.kind, NonTerminalKind.CatchClauseError); } - public get name(): TokenNode | undefined { + public get name(): TerminalNode | undefined { return this.fetch().name; } @@ -2331,18 +2331,18 @@ export class RevertStatement { const [$revertKeyword, $error, $arguments, $semicolon] = ast_internal.selectSequence(this.cst); return { - revertKeyword: $revertKeyword as TokenNode, - error: $error === null ? undefined : new IdentifierPath($error as RuleNode), - arguments: new ArgumentsDeclaration($arguments as RuleNode), - semicolon: $semicolon as TokenNode, + revertKeyword: $revertKeyword as TerminalNode, + error: $error === null ? undefined : new IdentifierPath($error as NonTerminalNode), + arguments: new ArgumentsDeclaration($arguments as NonTerminalNode), + semicolon: $semicolon as TerminalNode, }; }); - public constructor(public readonly cst: RuleNode) { - assertKind(this.cst.kind, RuleKind.RevertStatement); + public constructor(public readonly cst: NonTerminalNode) { + assertKind(this.cst.kind, NonTerminalKind.RevertStatement); } - public get revertKeyword(): TokenNode { + public get revertKeyword(): TerminalNode { return this.fetch().revertKeyword; } @@ -2354,7 +2354,7 @@ export class RevertStatement { return this.fetch().arguments; } - public get semicolon(): TokenNode { + public get semicolon(): TerminalNode { return this.fetch().semicolon; } } @@ -2364,20 +2364,20 @@ export class ThrowStatement { const [$throwKeyword, $semicolon] = ast_internal.selectSequence(this.cst); return { - throwKeyword: $throwKeyword as TokenNode, - semicolon: $semicolon as TokenNode, + throwKeyword: $throwKeyword as TerminalNode, + semicolon: $semicolon as TerminalNode, }; }); - public constructor(public readonly cst: RuleNode) { - assertKind(this.cst.kind, RuleKind.ThrowStatement); + public constructor(public readonly cst: NonTerminalNode) { + assertKind(this.cst.kind, NonTerminalKind.ThrowStatement); } - public get throwKeyword(): TokenNode { + public get throwKeyword(): TerminalNode { return this.fetch().throwKeyword; } - public get semicolon(): TokenNode { + public get semicolon(): TerminalNode { return this.fetch().semicolon; } } @@ -2387,21 +2387,21 @@ export class AssignmentExpression { const [$leftOperand, $operator, $rightOperand] = ast_internal.selectSequence(this.cst); return { - leftOperand: new Expression($leftOperand as RuleNode), - operator: $operator as TokenNode, - rightOperand: new Expression($rightOperand as RuleNode), + leftOperand: new Expression($leftOperand as NonTerminalNode), + operator: $operator as TerminalNode, + rightOperand: new Expression($rightOperand as NonTerminalNode), }; }); - public constructor(public readonly cst: RuleNode) { - assertKind(this.cst.kind, RuleKind.AssignmentExpression); + public constructor(public readonly cst: NonTerminalNode) { + assertKind(this.cst.kind, NonTerminalKind.AssignmentExpression); } public get leftOperand(): Expression { return this.fetch().leftOperand; } - public get operator(): TokenNode { + public get operator(): TerminalNode { return this.fetch().operator; } @@ -2415,23 +2415,23 @@ export class ConditionalExpression { const [$operand, $questionMark, $trueExpression, $colon, $falseExpression] = ast_internal.selectSequence(this.cst); return { - operand: new Expression($operand as RuleNode), - questionMark: $questionMark as TokenNode, - trueExpression: new Expression($trueExpression as RuleNode), - colon: $colon as TokenNode, - falseExpression: new Expression($falseExpression as RuleNode), + operand: new Expression($operand as NonTerminalNode), + questionMark: $questionMark as TerminalNode, + trueExpression: new Expression($trueExpression as NonTerminalNode), + colon: $colon as TerminalNode, + falseExpression: new Expression($falseExpression as NonTerminalNode), }; }); - public constructor(public readonly cst: RuleNode) { - assertKind(this.cst.kind, RuleKind.ConditionalExpression); + public constructor(public readonly cst: NonTerminalNode) { + assertKind(this.cst.kind, NonTerminalKind.ConditionalExpression); } public get operand(): Expression { return this.fetch().operand; } - public get questionMark(): TokenNode { + public get questionMark(): TerminalNode { return this.fetch().questionMark; } @@ -2439,7 +2439,7 @@ export class ConditionalExpression { return this.fetch().trueExpression; } - public get colon(): TokenNode { + public get colon(): TerminalNode { return this.fetch().colon; } @@ -2453,21 +2453,21 @@ export class OrExpression { const [$leftOperand, $operator, $rightOperand] = ast_internal.selectSequence(this.cst); return { - leftOperand: new Expression($leftOperand as RuleNode), - operator: $operator as TokenNode, - rightOperand: new Expression($rightOperand as RuleNode), + leftOperand: new Expression($leftOperand as NonTerminalNode), + operator: $operator as TerminalNode, + rightOperand: new Expression($rightOperand as NonTerminalNode), }; }); - public constructor(public readonly cst: RuleNode) { - assertKind(this.cst.kind, RuleKind.OrExpression); + public constructor(public readonly cst: NonTerminalNode) { + assertKind(this.cst.kind, NonTerminalKind.OrExpression); } public get leftOperand(): Expression { return this.fetch().leftOperand; } - public get operator(): TokenNode { + public get operator(): TerminalNode { return this.fetch().operator; } @@ -2481,21 +2481,21 @@ export class AndExpression { const [$leftOperand, $operator, $rightOperand] = ast_internal.selectSequence(this.cst); return { - leftOperand: new Expression($leftOperand as RuleNode), - operator: $operator as TokenNode, - rightOperand: new Expression($rightOperand as RuleNode), + leftOperand: new Expression($leftOperand as NonTerminalNode), + operator: $operator as TerminalNode, + rightOperand: new Expression($rightOperand as NonTerminalNode), }; }); - public constructor(public readonly cst: RuleNode) { - assertKind(this.cst.kind, RuleKind.AndExpression); + public constructor(public readonly cst: NonTerminalNode) { + assertKind(this.cst.kind, NonTerminalKind.AndExpression); } public get leftOperand(): Expression { return this.fetch().leftOperand; } - public get operator(): TokenNode { + public get operator(): TerminalNode { return this.fetch().operator; } @@ -2509,21 +2509,21 @@ export class EqualityExpression { const [$leftOperand, $operator, $rightOperand] = ast_internal.selectSequence(this.cst); return { - leftOperand: new Expression($leftOperand as RuleNode), - operator: $operator as TokenNode, - rightOperand: new Expression($rightOperand as RuleNode), + leftOperand: new Expression($leftOperand as NonTerminalNode), + operator: $operator as TerminalNode, + rightOperand: new Expression($rightOperand as NonTerminalNode), }; }); - public constructor(public readonly cst: RuleNode) { - assertKind(this.cst.kind, RuleKind.EqualityExpression); + public constructor(public readonly cst: NonTerminalNode) { + assertKind(this.cst.kind, NonTerminalKind.EqualityExpression); } public get leftOperand(): Expression { return this.fetch().leftOperand; } - public get operator(): TokenNode { + public get operator(): TerminalNode { return this.fetch().operator; } @@ -2537,21 +2537,21 @@ export class ComparisonExpression { const [$leftOperand, $operator, $rightOperand] = ast_internal.selectSequence(this.cst); return { - leftOperand: new Expression($leftOperand as RuleNode), - operator: $operator as TokenNode, - rightOperand: new Expression($rightOperand as RuleNode), + leftOperand: new Expression($leftOperand as NonTerminalNode), + operator: $operator as TerminalNode, + rightOperand: new Expression($rightOperand as NonTerminalNode), }; }); - public constructor(public readonly cst: RuleNode) { - assertKind(this.cst.kind, RuleKind.ComparisonExpression); + public constructor(public readonly cst: NonTerminalNode) { + assertKind(this.cst.kind, NonTerminalKind.ComparisonExpression); } public get leftOperand(): Expression { return this.fetch().leftOperand; } - public get operator(): TokenNode { + public get operator(): TerminalNode { return this.fetch().operator; } @@ -2565,21 +2565,21 @@ export class BitwiseOrExpression { const [$leftOperand, $operator, $rightOperand] = ast_internal.selectSequence(this.cst); return { - leftOperand: new Expression($leftOperand as RuleNode), - operator: $operator as TokenNode, - rightOperand: new Expression($rightOperand as RuleNode), + leftOperand: new Expression($leftOperand as NonTerminalNode), + operator: $operator as TerminalNode, + rightOperand: new Expression($rightOperand as NonTerminalNode), }; }); - public constructor(public readonly cst: RuleNode) { - assertKind(this.cst.kind, RuleKind.BitwiseOrExpression); + public constructor(public readonly cst: NonTerminalNode) { + assertKind(this.cst.kind, NonTerminalKind.BitwiseOrExpression); } public get leftOperand(): Expression { return this.fetch().leftOperand; } - public get operator(): TokenNode { + public get operator(): TerminalNode { return this.fetch().operator; } @@ -2593,21 +2593,21 @@ export class BitwiseXorExpression { const [$leftOperand, $operator, $rightOperand] = ast_internal.selectSequence(this.cst); return { - leftOperand: new Expression($leftOperand as RuleNode), - operator: $operator as TokenNode, - rightOperand: new Expression($rightOperand as RuleNode), + leftOperand: new Expression($leftOperand as NonTerminalNode), + operator: $operator as TerminalNode, + rightOperand: new Expression($rightOperand as NonTerminalNode), }; }); - public constructor(public readonly cst: RuleNode) { - assertKind(this.cst.kind, RuleKind.BitwiseXorExpression); + public constructor(public readonly cst: NonTerminalNode) { + assertKind(this.cst.kind, NonTerminalKind.BitwiseXorExpression); } public get leftOperand(): Expression { return this.fetch().leftOperand; } - public get operator(): TokenNode { + public get operator(): TerminalNode { return this.fetch().operator; } @@ -2621,21 +2621,21 @@ export class BitwiseAndExpression { const [$leftOperand, $operator, $rightOperand] = ast_internal.selectSequence(this.cst); return { - leftOperand: new Expression($leftOperand as RuleNode), - operator: $operator as TokenNode, - rightOperand: new Expression($rightOperand as RuleNode), + leftOperand: new Expression($leftOperand as NonTerminalNode), + operator: $operator as TerminalNode, + rightOperand: new Expression($rightOperand as NonTerminalNode), }; }); - public constructor(public readonly cst: RuleNode) { - assertKind(this.cst.kind, RuleKind.BitwiseAndExpression); + public constructor(public readonly cst: NonTerminalNode) { + assertKind(this.cst.kind, NonTerminalKind.BitwiseAndExpression); } public get leftOperand(): Expression { return this.fetch().leftOperand; } - public get operator(): TokenNode { + public get operator(): TerminalNode { return this.fetch().operator; } @@ -2649,21 +2649,21 @@ export class ShiftExpression { const [$leftOperand, $operator, $rightOperand] = ast_internal.selectSequence(this.cst); return { - leftOperand: new Expression($leftOperand as RuleNode), - operator: $operator as TokenNode, - rightOperand: new Expression($rightOperand as RuleNode), + leftOperand: new Expression($leftOperand as NonTerminalNode), + operator: $operator as TerminalNode, + rightOperand: new Expression($rightOperand as NonTerminalNode), }; }); - public constructor(public readonly cst: RuleNode) { - assertKind(this.cst.kind, RuleKind.ShiftExpression); + public constructor(public readonly cst: NonTerminalNode) { + assertKind(this.cst.kind, NonTerminalKind.ShiftExpression); } public get leftOperand(): Expression { return this.fetch().leftOperand; } - public get operator(): TokenNode { + public get operator(): TerminalNode { return this.fetch().operator; } @@ -2677,21 +2677,21 @@ export class AdditiveExpression { const [$leftOperand, $operator, $rightOperand] = ast_internal.selectSequence(this.cst); return { - leftOperand: new Expression($leftOperand as RuleNode), - operator: $operator as TokenNode, - rightOperand: new Expression($rightOperand as RuleNode), + leftOperand: new Expression($leftOperand as NonTerminalNode), + operator: $operator as TerminalNode, + rightOperand: new Expression($rightOperand as NonTerminalNode), }; }); - public constructor(public readonly cst: RuleNode) { - assertKind(this.cst.kind, RuleKind.AdditiveExpression); + public constructor(public readonly cst: NonTerminalNode) { + assertKind(this.cst.kind, NonTerminalKind.AdditiveExpression); } public get leftOperand(): Expression { return this.fetch().leftOperand; } - public get operator(): TokenNode { + public get operator(): TerminalNode { return this.fetch().operator; } @@ -2705,21 +2705,21 @@ export class MultiplicativeExpression { const [$leftOperand, $operator, $rightOperand] = ast_internal.selectSequence(this.cst); return { - leftOperand: new Expression($leftOperand as RuleNode), - operator: $operator as TokenNode, - rightOperand: new Expression($rightOperand as RuleNode), + leftOperand: new Expression($leftOperand as NonTerminalNode), + operator: $operator as TerminalNode, + rightOperand: new Expression($rightOperand as NonTerminalNode), }; }); - public constructor(public readonly cst: RuleNode) { - assertKind(this.cst.kind, RuleKind.MultiplicativeExpression); + public constructor(public readonly cst: NonTerminalNode) { + assertKind(this.cst.kind, NonTerminalKind.MultiplicativeExpression); } public get leftOperand(): Expression { return this.fetch().leftOperand; } - public get operator(): TokenNode { + public get operator(): TerminalNode { return this.fetch().operator; } @@ -2733,21 +2733,21 @@ export class ExponentiationExpression { const [$leftOperand, $operator, $rightOperand] = ast_internal.selectSequence(this.cst); return { - leftOperand: new Expression($leftOperand as RuleNode), - operator: $operator as TokenNode, - rightOperand: new Expression($rightOperand as RuleNode), + leftOperand: new Expression($leftOperand as NonTerminalNode), + operator: $operator as TerminalNode, + rightOperand: new Expression($rightOperand as NonTerminalNode), }; }); - public constructor(public readonly cst: RuleNode) { - assertKind(this.cst.kind, RuleKind.ExponentiationExpression); + public constructor(public readonly cst: NonTerminalNode) { + assertKind(this.cst.kind, NonTerminalKind.ExponentiationExpression); } public get leftOperand(): Expression { return this.fetch().leftOperand; } - public get operator(): TokenNode { + public get operator(): TerminalNode { return this.fetch().operator; } @@ -2761,20 +2761,20 @@ export class PostfixExpression { const [$operand, $operator] = ast_internal.selectSequence(this.cst); return { - operand: new Expression($operand as RuleNode), - operator: $operator as TokenNode, + operand: new Expression($operand as NonTerminalNode), + operator: $operator as TerminalNode, }; }); - public constructor(public readonly cst: RuleNode) { - assertKind(this.cst.kind, RuleKind.PostfixExpression); + public constructor(public readonly cst: NonTerminalNode) { + assertKind(this.cst.kind, NonTerminalKind.PostfixExpression); } public get operand(): Expression { return this.fetch().operand; } - public get operator(): TokenNode { + public get operator(): TerminalNode { return this.fetch().operator; } } @@ -2784,16 +2784,16 @@ export class PrefixExpression { const [$operator, $operand] = ast_internal.selectSequence(this.cst); return { - operator: $operator as TokenNode, - operand: new Expression($operand as RuleNode), + operator: $operator as TerminalNode, + operand: new Expression($operand as NonTerminalNode), }; }); - public constructor(public readonly cst: RuleNode) { - assertKind(this.cst.kind, RuleKind.PrefixExpression); + public constructor(public readonly cst: NonTerminalNode) { + assertKind(this.cst.kind, NonTerminalKind.PrefixExpression); } - public get operator(): TokenNode { + public get operator(): TerminalNode { return this.fetch().operator; } @@ -2807,13 +2807,13 @@ export class FunctionCallExpression { const [$operand, $arguments] = ast_internal.selectSequence(this.cst); return { - operand: new Expression($operand as RuleNode), - arguments: new ArgumentsDeclaration($arguments as RuleNode), + operand: new Expression($operand as NonTerminalNode), + arguments: new ArgumentsDeclaration($arguments as NonTerminalNode), }; }); - public constructor(public readonly cst: RuleNode) { - assertKind(this.cst.kind, RuleKind.FunctionCallExpression); + public constructor(public readonly cst: NonTerminalNode) { + assertKind(this.cst.kind, NonTerminalKind.FunctionCallExpression); } public get operand(): Expression { @@ -2830,22 +2830,22 @@ export class CallOptionsExpression { const [$operand, $openBrace, $options, $closeBrace] = ast_internal.selectSequence(this.cst); return { - operand: new Expression($operand as RuleNode), - openBrace: $openBrace as TokenNode, - options: new CallOptions($options as RuleNode), - closeBrace: $closeBrace as TokenNode, + operand: new Expression($operand as NonTerminalNode), + openBrace: $openBrace as TerminalNode, + options: new CallOptions($options as NonTerminalNode), + closeBrace: $closeBrace as TerminalNode, }; }); - public constructor(public readonly cst: RuleNode) { - assertKind(this.cst.kind, RuleKind.CallOptionsExpression); + public constructor(public readonly cst: NonTerminalNode) { + assertKind(this.cst.kind, NonTerminalKind.CallOptionsExpression); } public get operand(): Expression { return this.fetch().operand; } - public get openBrace(): TokenNode { + public get openBrace(): TerminalNode { return this.fetch().openBrace; } @@ -2853,7 +2853,7 @@ export class CallOptionsExpression { return this.fetch().options; } - public get closeBrace(): TokenNode { + public get closeBrace(): TerminalNode { return this.fetch().closeBrace; } } @@ -2863,21 +2863,21 @@ export class MemberAccessExpression { const [$operand, $period, $member] = ast_internal.selectSequence(this.cst); return { - operand: new Expression($operand as RuleNode), - period: $period as TokenNode, - member: new MemberAccess($member as RuleNode), + operand: new Expression($operand as NonTerminalNode), + period: $period as TerminalNode, + member: new MemberAccess($member as NonTerminalNode), }; }); - public constructor(public readonly cst: RuleNode) { - assertKind(this.cst.kind, RuleKind.MemberAccessExpression); + public constructor(public readonly cst: NonTerminalNode) { + assertKind(this.cst.kind, NonTerminalKind.MemberAccessExpression); } public get operand(): Expression { return this.fetch().operand; } - public get period(): TokenNode { + public get period(): TerminalNode { return this.fetch().period; } @@ -2891,23 +2891,23 @@ export class IndexAccessExpression { const [$operand, $openBracket, $start, $end, $closeBracket] = ast_internal.selectSequence(this.cst); return { - operand: new Expression($operand as RuleNode), - openBracket: $openBracket as TokenNode, - start: $start === null ? undefined : new Expression($start as RuleNode), - end: $end === null ? undefined : new IndexAccessEnd($end as RuleNode), - closeBracket: $closeBracket as TokenNode, + operand: new Expression($operand as NonTerminalNode), + openBracket: $openBracket as TerminalNode, + start: $start === null ? undefined : new Expression($start as NonTerminalNode), + end: $end === null ? undefined : new IndexAccessEnd($end as NonTerminalNode), + closeBracket: $closeBracket as TerminalNode, }; }); - public constructor(public readonly cst: RuleNode) { - assertKind(this.cst.kind, RuleKind.IndexAccessExpression); + public constructor(public readonly cst: NonTerminalNode) { + assertKind(this.cst.kind, NonTerminalKind.IndexAccessExpression); } public get operand(): Expression { return this.fetch().operand; } - public get openBracket(): TokenNode { + public get openBracket(): TerminalNode { return this.fetch().openBracket; } @@ -2919,7 +2919,7 @@ export class IndexAccessExpression { return this.fetch().end; } - public get closeBracket(): TokenNode { + public get closeBracket(): TerminalNode { return this.fetch().closeBracket; } } @@ -2929,16 +2929,16 @@ export class IndexAccessEnd { const [$colon, $end] = ast_internal.selectSequence(this.cst); return { - colon: $colon as TokenNode, - end: $end === null ? undefined : new Expression($end as RuleNode), + colon: $colon as TerminalNode, + end: $end === null ? undefined : new Expression($end as NonTerminalNode), }; }); - public constructor(public readonly cst: RuleNode) { - assertKind(this.cst.kind, RuleKind.IndexAccessEnd); + public constructor(public readonly cst: NonTerminalNode) { + assertKind(this.cst.kind, NonTerminalKind.IndexAccessEnd); } - public get colon(): TokenNode { + public get colon(): TerminalNode { return this.fetch().colon; } @@ -2952,17 +2952,17 @@ export class PositionalArgumentsDeclaration { const [$openParen, $arguments, $closeParen] = ast_internal.selectSequence(this.cst); return { - openParen: $openParen as TokenNode, - arguments: new PositionalArguments($arguments as RuleNode), - closeParen: $closeParen as TokenNode, + openParen: $openParen as TerminalNode, + arguments: new PositionalArguments($arguments as NonTerminalNode), + closeParen: $closeParen as TerminalNode, }; }); - public constructor(public readonly cst: RuleNode) { - assertKind(this.cst.kind, RuleKind.PositionalArgumentsDeclaration); + public constructor(public readonly cst: NonTerminalNode) { + assertKind(this.cst.kind, NonTerminalKind.PositionalArgumentsDeclaration); } - public get openParen(): TokenNode { + public get openParen(): TerminalNode { return this.fetch().openParen; } @@ -2970,7 +2970,7 @@ export class PositionalArgumentsDeclaration { return this.fetch().arguments; } - public get closeParen(): TokenNode { + public get closeParen(): TerminalNode { return this.fetch().closeParen; } } @@ -2980,17 +2980,17 @@ export class NamedArgumentsDeclaration { const [$openParen, $arguments, $closeParen] = ast_internal.selectSequence(this.cst); return { - openParen: $openParen as TokenNode, - arguments: $arguments === null ? undefined : new NamedArgumentGroup($arguments as RuleNode), - closeParen: $closeParen as TokenNode, + openParen: $openParen as TerminalNode, + arguments: $arguments === null ? undefined : new NamedArgumentGroup($arguments as NonTerminalNode), + closeParen: $closeParen as TerminalNode, }; }); - public constructor(public readonly cst: RuleNode) { - assertKind(this.cst.kind, RuleKind.NamedArgumentsDeclaration); + public constructor(public readonly cst: NonTerminalNode) { + assertKind(this.cst.kind, NonTerminalKind.NamedArgumentsDeclaration); } - public get openParen(): TokenNode { + public get openParen(): TerminalNode { return this.fetch().openParen; } @@ -2998,7 +2998,7 @@ export class NamedArgumentsDeclaration { return this.fetch().arguments; } - public get closeParen(): TokenNode { + public get closeParen(): TerminalNode { return this.fetch().closeParen; } } @@ -3008,17 +3008,17 @@ export class NamedArgumentGroup { const [$openBrace, $arguments, $closeBrace] = ast_internal.selectSequence(this.cst); return { - openBrace: $openBrace as TokenNode, - arguments: new NamedArguments($arguments as RuleNode), - closeBrace: $closeBrace as TokenNode, + openBrace: $openBrace as TerminalNode, + arguments: new NamedArguments($arguments as NonTerminalNode), + closeBrace: $closeBrace as TerminalNode, }; }); - public constructor(public readonly cst: RuleNode) { - assertKind(this.cst.kind, RuleKind.NamedArgumentGroup); + public constructor(public readonly cst: NonTerminalNode) { + assertKind(this.cst.kind, NonTerminalKind.NamedArgumentGroup); } - public get openBrace(): TokenNode { + public get openBrace(): TerminalNode { return this.fetch().openBrace; } @@ -3026,7 +3026,7 @@ export class NamedArgumentGroup { return this.fetch().arguments; } - public get closeBrace(): TokenNode { + public get closeBrace(): TerminalNode { return this.fetch().closeBrace; } } @@ -3036,21 +3036,21 @@ export class NamedArgument { const [$name, $colon, $value] = ast_internal.selectSequence(this.cst); return { - name: $name as TokenNode, - colon: $colon as TokenNode, - value: new Expression($value as RuleNode), + name: $name as TerminalNode, + colon: $colon as TerminalNode, + value: new Expression($value as NonTerminalNode), }; }); - public constructor(public readonly cst: RuleNode) { - assertKind(this.cst.kind, RuleKind.NamedArgument); + public constructor(public readonly cst: NonTerminalNode) { + assertKind(this.cst.kind, NonTerminalKind.NamedArgument); } - public get name(): TokenNode { + public get name(): TerminalNode { return this.fetch().name; } - public get colon(): TokenNode { + public get colon(): TerminalNode { return this.fetch().colon; } @@ -3064,22 +3064,22 @@ export class TypeExpression { const [$typeKeyword, $openParen, $typeName, $closeParen] = ast_internal.selectSequence(this.cst); return { - typeKeyword: $typeKeyword as TokenNode, - openParen: $openParen as TokenNode, - typeName: new TypeName($typeName as RuleNode), - closeParen: $closeParen as TokenNode, + typeKeyword: $typeKeyword as TerminalNode, + openParen: $openParen as TerminalNode, + typeName: new TypeName($typeName as NonTerminalNode), + closeParen: $closeParen as TerminalNode, }; }); - public constructor(public readonly cst: RuleNode) { - assertKind(this.cst.kind, RuleKind.TypeExpression); + public constructor(public readonly cst: NonTerminalNode) { + assertKind(this.cst.kind, NonTerminalKind.TypeExpression); } - public get typeKeyword(): TokenNode { + public get typeKeyword(): TerminalNode { return this.fetch().typeKeyword; } - public get openParen(): TokenNode { + public get openParen(): TerminalNode { return this.fetch().openParen; } @@ -3087,7 +3087,7 @@ export class TypeExpression { return this.fetch().typeName; } - public get closeParen(): TokenNode { + public get closeParen(): TerminalNode { return this.fetch().closeParen; } } @@ -3097,16 +3097,16 @@ export class NewExpression { const [$newKeyword, $typeName] = ast_internal.selectSequence(this.cst); return { - newKeyword: $newKeyword as TokenNode, - typeName: new TypeName($typeName as RuleNode), + newKeyword: $newKeyword as TerminalNode, + typeName: new TypeName($typeName as NonTerminalNode), }; }); - public constructor(public readonly cst: RuleNode) { - assertKind(this.cst.kind, RuleKind.NewExpression); + public constructor(public readonly cst: NonTerminalNode) { + assertKind(this.cst.kind, NonTerminalKind.NewExpression); } - public get newKeyword(): TokenNode { + public get newKeyword(): TerminalNode { return this.fetch().newKeyword; } @@ -3120,17 +3120,17 @@ export class TupleExpression { const [$openParen, $items, $closeParen] = ast_internal.selectSequence(this.cst); return { - openParen: $openParen as TokenNode, - items: new TupleValues($items as RuleNode), - closeParen: $closeParen as TokenNode, + openParen: $openParen as TerminalNode, + items: new TupleValues($items as NonTerminalNode), + closeParen: $closeParen as TerminalNode, }; }); - public constructor(public readonly cst: RuleNode) { - assertKind(this.cst.kind, RuleKind.TupleExpression); + public constructor(public readonly cst: NonTerminalNode) { + assertKind(this.cst.kind, NonTerminalKind.TupleExpression); } - public get openParen(): TokenNode { + public get openParen(): TerminalNode { return this.fetch().openParen; } @@ -3138,7 +3138,7 @@ export class TupleExpression { return this.fetch().items; } - public get closeParen(): TokenNode { + public get closeParen(): TerminalNode { return this.fetch().closeParen; } } @@ -3148,12 +3148,12 @@ export class TupleValue { const [$expression] = ast_internal.selectSequence(this.cst); return { - expression: $expression === null ? undefined : new Expression($expression as RuleNode), + expression: $expression === null ? undefined : new Expression($expression as NonTerminalNode), }; }); - public constructor(public readonly cst: RuleNode) { - assertKind(this.cst.kind, RuleKind.TupleValue); + public constructor(public readonly cst: NonTerminalNode) { + assertKind(this.cst.kind, NonTerminalKind.TupleValue); } public get expression(): Expression | undefined { @@ -3166,17 +3166,17 @@ export class ArrayExpression { const [$openBracket, $items, $closeBracket] = ast_internal.selectSequence(this.cst); return { - openBracket: $openBracket as TokenNode, - items: new ArrayValues($items as RuleNode), - closeBracket: $closeBracket as TokenNode, + openBracket: $openBracket as TerminalNode, + items: new ArrayValues($items as NonTerminalNode), + closeBracket: $closeBracket as TerminalNode, }; }); - public constructor(public readonly cst: RuleNode) { - assertKind(this.cst.kind, RuleKind.ArrayExpression); + public constructor(public readonly cst: NonTerminalNode) { + assertKind(this.cst.kind, NonTerminalKind.ArrayExpression); } - public get openBracket(): TokenNode { + public get openBracket(): TerminalNode { return this.fetch().openBracket; } @@ -3184,7 +3184,7 @@ export class ArrayExpression { return this.fetch().items; } - public get closeBracket(): TokenNode { + public get closeBracket(): TerminalNode { return this.fetch().closeBracket; } } @@ -3194,16 +3194,16 @@ export class HexNumberExpression { const [$literal, $unit] = ast_internal.selectSequence(this.cst); return { - literal: $literal as TokenNode, - unit: $unit === null ? undefined : new NumberUnit($unit as RuleNode), + literal: $literal as TerminalNode, + unit: $unit === null ? undefined : new NumberUnit($unit as NonTerminalNode), }; }); - public constructor(public readonly cst: RuleNode) { - assertKind(this.cst.kind, RuleKind.HexNumberExpression); + public constructor(public readonly cst: NonTerminalNode) { + assertKind(this.cst.kind, NonTerminalKind.HexNumberExpression); } - public get literal(): TokenNode { + public get literal(): TerminalNode { return this.fetch().literal; } @@ -3217,16 +3217,16 @@ export class DecimalNumberExpression { const [$literal, $unit] = ast_internal.selectSequence(this.cst); return { - literal: $literal as TokenNode, - unit: $unit === null ? undefined : new NumberUnit($unit as RuleNode), + literal: $literal as TerminalNode, + unit: $unit === null ? undefined : new NumberUnit($unit as NonTerminalNode), }; }); - public constructor(public readonly cst: RuleNode) { - assertKind(this.cst.kind, RuleKind.DecimalNumberExpression); + public constructor(public readonly cst: NonTerminalNode) { + assertKind(this.cst.kind, NonTerminalKind.DecimalNumberExpression); } - public get literal(): TokenNode { + public get literal(): TerminalNode { return this.fetch().literal; } @@ -3240,17 +3240,17 @@ export class YulBlock { const [$openBrace, $statements, $closeBrace] = ast_internal.selectSequence(this.cst); return { - openBrace: $openBrace as TokenNode, - statements: new YulStatements($statements as RuleNode), - closeBrace: $closeBrace as TokenNode, + openBrace: $openBrace as TerminalNode, + statements: new YulStatements($statements as NonTerminalNode), + closeBrace: $closeBrace as TerminalNode, }; }); - public constructor(public readonly cst: RuleNode) { - assertKind(this.cst.kind, RuleKind.YulBlock); + public constructor(public readonly cst: NonTerminalNode) { + assertKind(this.cst.kind, NonTerminalKind.YulBlock); } - public get openBrace(): TokenNode { + public get openBrace(): TerminalNode { return this.fetch().openBrace; } @@ -3258,7 +3258,7 @@ export class YulBlock { return this.fetch().statements; } - public get closeBrace(): TokenNode { + public get closeBrace(): TerminalNode { return this.fetch().closeBrace; } } @@ -3268,23 +3268,23 @@ export class YulFunctionDefinition { const [$functionKeyword, $name, $parameters, $returns, $body] = ast_internal.selectSequence(this.cst); return { - functionKeyword: $functionKeyword as TokenNode, - name: $name as TokenNode, - parameters: new YulParametersDeclaration($parameters as RuleNode), - returns: $returns === null ? undefined : new YulReturnsDeclaration($returns as RuleNode), - body: new YulBlock($body as RuleNode), + functionKeyword: $functionKeyword as TerminalNode, + name: $name as TerminalNode, + parameters: new YulParametersDeclaration($parameters as NonTerminalNode), + returns: $returns === null ? undefined : new YulReturnsDeclaration($returns as NonTerminalNode), + body: new YulBlock($body as NonTerminalNode), }; }); - public constructor(public readonly cst: RuleNode) { - assertKind(this.cst.kind, RuleKind.YulFunctionDefinition); + public constructor(public readonly cst: NonTerminalNode) { + assertKind(this.cst.kind, NonTerminalKind.YulFunctionDefinition); } - public get functionKeyword(): TokenNode { + public get functionKeyword(): TerminalNode { return this.fetch().functionKeyword; } - public get name(): TokenNode { + public get name(): TerminalNode { return this.fetch().name; } @@ -3306,17 +3306,17 @@ export class YulParametersDeclaration { const [$openParen, $parameters, $closeParen] = ast_internal.selectSequence(this.cst); return { - openParen: $openParen as TokenNode, - parameters: new YulParameters($parameters as RuleNode), - closeParen: $closeParen as TokenNode, + openParen: $openParen as TerminalNode, + parameters: new YulParameters($parameters as NonTerminalNode), + closeParen: $closeParen as TerminalNode, }; }); - public constructor(public readonly cst: RuleNode) { - assertKind(this.cst.kind, RuleKind.YulParametersDeclaration); + public constructor(public readonly cst: NonTerminalNode) { + assertKind(this.cst.kind, NonTerminalKind.YulParametersDeclaration); } - public get openParen(): TokenNode { + public get openParen(): TerminalNode { return this.fetch().openParen; } @@ -3324,7 +3324,7 @@ export class YulParametersDeclaration { return this.fetch().parameters; } - public get closeParen(): TokenNode { + public get closeParen(): TerminalNode { return this.fetch().closeParen; } } @@ -3334,16 +3334,16 @@ export class YulReturnsDeclaration { const [$minusGreaterThan, $variables] = ast_internal.selectSequence(this.cst); return { - minusGreaterThan: $minusGreaterThan as TokenNode, - variables: new YulReturnVariables($variables as RuleNode), + minusGreaterThan: $minusGreaterThan as TerminalNode, + variables: new YulReturnVariables($variables as NonTerminalNode), }; }); - public constructor(public readonly cst: RuleNode) { - assertKind(this.cst.kind, RuleKind.YulReturnsDeclaration); + public constructor(public readonly cst: NonTerminalNode) { + assertKind(this.cst.kind, NonTerminalKind.YulReturnsDeclaration); } - public get minusGreaterThan(): TokenNode { + public get minusGreaterThan(): TerminalNode { return this.fetch().minusGreaterThan; } @@ -3357,21 +3357,21 @@ export class YulVariableDeclarationStatement { const [$letKeyword, $names, $value] = ast_internal.selectSequence(this.cst); return { - letKeyword: $letKeyword as TokenNode, - names: $names as TokenNode, - value: $value === null ? undefined : new YulVariableDeclarationValue($value as RuleNode), + letKeyword: $letKeyword as TerminalNode, + names: $names as TerminalNode, + value: $value === null ? undefined : new YulVariableDeclarationValue($value as NonTerminalNode), }; }); - public constructor(public readonly cst: RuleNode) { - assertKind(this.cst.kind, RuleKind.YulVariableDeclarationStatement); + public constructor(public readonly cst: NonTerminalNode) { + assertKind(this.cst.kind, NonTerminalKind.YulVariableDeclarationStatement); } - public get letKeyword(): TokenNode { + public get letKeyword(): TerminalNode { return this.fetch().letKeyword; } - public get names(): TokenNode { + public get names(): TerminalNode { return this.fetch().names; } @@ -3385,13 +3385,13 @@ export class YulVariableDeclarationValue { const [$assignment, $expression] = ast_internal.selectSequence(this.cst); return { - assignment: new YulAssignmentOperator($assignment as RuleNode), - expression: new YulExpression($expression as RuleNode), + assignment: new YulAssignmentOperator($assignment as NonTerminalNode), + expression: new YulExpression($expression as NonTerminalNode), }; }); - public constructor(public readonly cst: RuleNode) { - assertKind(this.cst.kind, RuleKind.YulVariableDeclarationValue); + public constructor(public readonly cst: NonTerminalNode) { + assertKind(this.cst.kind, NonTerminalKind.YulVariableDeclarationValue); } public get assignment(): YulAssignmentOperator { @@ -3408,14 +3408,14 @@ export class YulAssignmentStatement { const [$names, $assignment, $expression] = ast_internal.selectSequence(this.cst); return { - names: new YulPaths($names as RuleNode), - assignment: new YulAssignmentOperator($assignment as RuleNode), - expression: new YulExpression($expression as RuleNode), + names: new YulPaths($names as NonTerminalNode), + assignment: new YulAssignmentOperator($assignment as NonTerminalNode), + expression: new YulExpression($expression as NonTerminalNode), }; }); - public constructor(public readonly cst: RuleNode) { - assertKind(this.cst.kind, RuleKind.YulAssignmentStatement); + public constructor(public readonly cst: NonTerminalNode) { + assertKind(this.cst.kind, NonTerminalKind.YulAssignmentStatement); } public get names(): YulPaths { @@ -3436,20 +3436,20 @@ export class YulColonAndEqual { const [$colon, $equal] = ast_internal.selectSequence(this.cst); return { - colon: $colon as TokenNode, - equal: $equal as TokenNode, + colon: $colon as TerminalNode, + equal: $equal as TerminalNode, }; }); - public constructor(public readonly cst: RuleNode) { - assertKind(this.cst.kind, RuleKind.YulColonAndEqual); + public constructor(public readonly cst: NonTerminalNode) { + assertKind(this.cst.kind, NonTerminalKind.YulColonAndEqual); } - public get colon(): TokenNode { + public get colon(): TerminalNode { return this.fetch().colon; } - public get equal(): TokenNode { + public get equal(): TerminalNode { return this.fetch().equal; } } @@ -3459,17 +3459,17 @@ export class YulIfStatement { const [$ifKeyword, $condition, $body] = ast_internal.selectSequence(this.cst); return { - ifKeyword: $ifKeyword as TokenNode, - condition: new YulExpression($condition as RuleNode), - body: new YulBlock($body as RuleNode), + ifKeyword: $ifKeyword as TerminalNode, + condition: new YulExpression($condition as NonTerminalNode), + body: new YulBlock($body as NonTerminalNode), }; }); - public constructor(public readonly cst: RuleNode) { - assertKind(this.cst.kind, RuleKind.YulIfStatement); + public constructor(public readonly cst: NonTerminalNode) { + assertKind(this.cst.kind, NonTerminalKind.YulIfStatement); } - public get ifKeyword(): TokenNode { + public get ifKeyword(): TerminalNode { return this.fetch().ifKeyword; } @@ -3487,19 +3487,19 @@ export class YulForStatement { const [$forKeyword, $initialization, $condition, $iterator, $body] = ast_internal.selectSequence(this.cst); return { - forKeyword: $forKeyword as TokenNode, - initialization: new YulBlock($initialization as RuleNode), - condition: new YulExpression($condition as RuleNode), - iterator: new YulBlock($iterator as RuleNode), - body: new YulBlock($body as RuleNode), + forKeyword: $forKeyword as TerminalNode, + initialization: new YulBlock($initialization as NonTerminalNode), + condition: new YulExpression($condition as NonTerminalNode), + iterator: new YulBlock($iterator as NonTerminalNode), + body: new YulBlock($body as NonTerminalNode), }; }); - public constructor(public readonly cst: RuleNode) { - assertKind(this.cst.kind, RuleKind.YulForStatement); + public constructor(public readonly cst: NonTerminalNode) { + assertKind(this.cst.kind, NonTerminalKind.YulForStatement); } - public get forKeyword(): TokenNode { + public get forKeyword(): TerminalNode { return this.fetch().forKeyword; } @@ -3525,17 +3525,17 @@ export class YulSwitchStatement { const [$switchKeyword, $expression, $cases] = ast_internal.selectSequence(this.cst); return { - switchKeyword: $switchKeyword as TokenNode, - expression: new YulExpression($expression as RuleNode), - cases: new YulSwitchCases($cases as RuleNode), + switchKeyword: $switchKeyword as TerminalNode, + expression: new YulExpression($expression as NonTerminalNode), + cases: new YulSwitchCases($cases as NonTerminalNode), }; }); - public constructor(public readonly cst: RuleNode) { - assertKind(this.cst.kind, RuleKind.YulSwitchStatement); + public constructor(public readonly cst: NonTerminalNode) { + assertKind(this.cst.kind, NonTerminalKind.YulSwitchStatement); } - public get switchKeyword(): TokenNode { + public get switchKeyword(): TerminalNode { return this.fetch().switchKeyword; } @@ -3553,16 +3553,16 @@ export class YulDefaultCase { const [$defaultKeyword, $body] = ast_internal.selectSequence(this.cst); return { - defaultKeyword: $defaultKeyword as TokenNode, - body: new YulBlock($body as RuleNode), + defaultKeyword: $defaultKeyword as TerminalNode, + body: new YulBlock($body as NonTerminalNode), }; }); - public constructor(public readonly cst: RuleNode) { - assertKind(this.cst.kind, RuleKind.YulDefaultCase); + public constructor(public readonly cst: NonTerminalNode) { + assertKind(this.cst.kind, NonTerminalKind.YulDefaultCase); } - public get defaultKeyword(): TokenNode { + public get defaultKeyword(): TerminalNode { return this.fetch().defaultKeyword; } @@ -3576,17 +3576,17 @@ export class YulValueCase { const [$caseKeyword, $value, $body] = ast_internal.selectSequence(this.cst); return { - caseKeyword: $caseKeyword as TokenNode, - value: new YulLiteral($value as RuleNode), - body: new YulBlock($body as RuleNode), + caseKeyword: $caseKeyword as TerminalNode, + value: new YulLiteral($value as NonTerminalNode), + body: new YulBlock($body as NonTerminalNode), }; }); - public constructor(public readonly cst: RuleNode) { - assertKind(this.cst.kind, RuleKind.YulValueCase); + public constructor(public readonly cst: NonTerminalNode) { + assertKind(this.cst.kind, NonTerminalKind.YulValueCase); } - public get caseKeyword(): TokenNode { + public get caseKeyword(): TerminalNode { return this.fetch().caseKeyword; } @@ -3604,15 +3604,15 @@ export class YulLeaveStatement { const [$leaveKeyword] = ast_internal.selectSequence(this.cst); return { - leaveKeyword: $leaveKeyword as TokenNode, + leaveKeyword: $leaveKeyword as TerminalNode, }; }); - public constructor(public readonly cst: RuleNode) { - assertKind(this.cst.kind, RuleKind.YulLeaveStatement); + public constructor(public readonly cst: NonTerminalNode) { + assertKind(this.cst.kind, NonTerminalKind.YulLeaveStatement); } - public get leaveKeyword(): TokenNode { + public get leaveKeyword(): TerminalNode { return this.fetch().leaveKeyword; } } @@ -3622,15 +3622,15 @@ export class YulBreakStatement { const [$breakKeyword] = ast_internal.selectSequence(this.cst); return { - breakKeyword: $breakKeyword as TokenNode, + breakKeyword: $breakKeyword as TerminalNode, }; }); - public constructor(public readonly cst: RuleNode) { - assertKind(this.cst.kind, RuleKind.YulBreakStatement); + public constructor(public readonly cst: NonTerminalNode) { + assertKind(this.cst.kind, NonTerminalKind.YulBreakStatement); } - public get breakKeyword(): TokenNode { + public get breakKeyword(): TerminalNode { return this.fetch().breakKeyword; } } @@ -3640,15 +3640,15 @@ export class YulContinueStatement { const [$continueKeyword] = ast_internal.selectSequence(this.cst); return { - continueKeyword: $continueKeyword as TokenNode, + continueKeyword: $continueKeyword as TerminalNode, }; }); - public constructor(public readonly cst: RuleNode) { - assertKind(this.cst.kind, RuleKind.YulContinueStatement); + public constructor(public readonly cst: NonTerminalNode) { + assertKind(this.cst.kind, NonTerminalKind.YulContinueStatement); } - public get continueKeyword(): TokenNode { + public get continueKeyword(): TerminalNode { return this.fetch().continueKeyword; } } @@ -3658,20 +3658,20 @@ export class YulLabel { const [$label, $colon] = ast_internal.selectSequence(this.cst); return { - label: $label as TokenNode, - colon: $colon as TokenNode, + label: $label as TerminalNode, + colon: $colon as TerminalNode, }; }); - public constructor(public readonly cst: RuleNode) { - assertKind(this.cst.kind, RuleKind.YulLabel); + public constructor(public readonly cst: NonTerminalNode) { + assertKind(this.cst.kind, NonTerminalKind.YulLabel); } - public get label(): TokenNode { + public get label(): TerminalNode { return this.fetch().label; } - public get colon(): TokenNode { + public get colon(): TerminalNode { return this.fetch().colon; } } @@ -3681,22 +3681,22 @@ export class YulFunctionCallExpression { const [$operand, $openParen, $arguments, $closeParen] = ast_internal.selectSequence(this.cst); return { - operand: new YulExpression($operand as RuleNode), - openParen: $openParen as TokenNode, - arguments: new YulArguments($arguments as RuleNode), - closeParen: $closeParen as TokenNode, + operand: new YulExpression($operand as NonTerminalNode), + openParen: $openParen as TerminalNode, + arguments: new YulArguments($arguments as NonTerminalNode), + closeParen: $closeParen as TerminalNode, }; }); - public constructor(public readonly cst: RuleNode) { - assertKind(this.cst.kind, RuleKind.YulFunctionCallExpression); + public constructor(public readonly cst: NonTerminalNode) { + assertKind(this.cst.kind, NonTerminalKind.YulFunctionCallExpression); } public get operand(): YulExpression { return this.fetch().operand; } - public get openParen(): TokenNode { + public get openParen(): TerminalNode { return this.fetch().openParen; } @@ -3704,7 +3704,7 @@ export class YulFunctionCallExpression { return this.fetch().arguments; } - public get closeParen(): TokenNode { + public get closeParen(): TerminalNode { return this.fetch().closeParen; } } @@ -3731,40 +3731,40 @@ export class SourceUnitMember { const variant = ast_internal.selectChoice(this.cst); switch (variant.kind) { - case RuleKind.PragmaDirective: - return new PragmaDirective(variant as RuleNode); - case RuleKind.ImportDirective: - return new ImportDirective(variant as RuleNode); - case RuleKind.ContractDefinition: - return new ContractDefinition(variant as RuleNode); - case RuleKind.InterfaceDefinition: - return new InterfaceDefinition(variant as RuleNode); - case RuleKind.LibraryDefinition: - return new LibraryDefinition(variant as RuleNode); - case RuleKind.StructDefinition: - return new StructDefinition(variant as RuleNode); - case RuleKind.EnumDefinition: - return new EnumDefinition(variant as RuleNode); - case RuleKind.FunctionDefinition: - return new FunctionDefinition(variant as RuleNode); - case RuleKind.ConstantDefinition: - return new ConstantDefinition(variant as RuleNode); - case RuleKind.ErrorDefinition: - return new ErrorDefinition(variant as RuleNode); - case RuleKind.UserDefinedValueTypeDefinition: - return new UserDefinedValueTypeDefinition(variant as RuleNode); - case RuleKind.UsingDirective: - return new UsingDirective(variant as RuleNode); - case RuleKind.EventDefinition: - return new EventDefinition(variant as RuleNode); + case NonTerminalKind.PragmaDirective: + return new PragmaDirective(variant as NonTerminalNode); + case NonTerminalKind.ImportDirective: + return new ImportDirective(variant as NonTerminalNode); + case NonTerminalKind.ContractDefinition: + return new ContractDefinition(variant as NonTerminalNode); + case NonTerminalKind.InterfaceDefinition: + return new InterfaceDefinition(variant as NonTerminalNode); + case NonTerminalKind.LibraryDefinition: + return new LibraryDefinition(variant as NonTerminalNode); + case NonTerminalKind.StructDefinition: + return new StructDefinition(variant as NonTerminalNode); + case NonTerminalKind.EnumDefinition: + return new EnumDefinition(variant as NonTerminalNode); + case NonTerminalKind.FunctionDefinition: + return new FunctionDefinition(variant as NonTerminalNode); + case NonTerminalKind.ConstantDefinition: + return new ConstantDefinition(variant as NonTerminalNode); + case NonTerminalKind.ErrorDefinition: + return new ErrorDefinition(variant as NonTerminalNode); + case NonTerminalKind.UserDefinedValueTypeDefinition: + return new UserDefinedValueTypeDefinition(variant as NonTerminalNode); + case NonTerminalKind.UsingDirective: + return new UsingDirective(variant as NonTerminalNode); + case NonTerminalKind.EventDefinition: + return new EventDefinition(variant as NonTerminalNode); default: assert.fail(`Unexpected variant: ${variant.kind}`); } }); - public constructor(public readonly cst: RuleNode) { - assertKind(this.cst.kind, RuleKind.SourceUnitMember); + public constructor(public readonly cst: NonTerminalNode) { + assertKind(this.cst.kind, NonTerminalKind.SourceUnitMember); } public get variant(): @@ -3790,20 +3790,20 @@ export class Pragma { const variant = ast_internal.selectChoice(this.cst); switch (variant.kind) { - case RuleKind.ABICoderPragma: - return new ABICoderPragma(variant as RuleNode); - case RuleKind.ExperimentalPragma: - return new ExperimentalPragma(variant as RuleNode); - case RuleKind.VersionPragma: - return new VersionPragma(variant as RuleNode); + case NonTerminalKind.ABICoderPragma: + return new ABICoderPragma(variant as NonTerminalNode); + case NonTerminalKind.ExperimentalPragma: + return new ExperimentalPragma(variant as NonTerminalNode); + case NonTerminalKind.VersionPragma: + return new VersionPragma(variant as NonTerminalNode); default: assert.fail(`Unexpected variant: ${variant.kind}`); } }); - public constructor(public readonly cst: RuleNode) { - assertKind(this.cst.kind, RuleKind.Pragma); + public constructor(public readonly cst: NonTerminalNode) { + assertKind(this.cst.kind, NonTerminalKind.Pragma); } public get variant(): ABICoderPragma | ExperimentalPragma | VersionPragma { @@ -3812,56 +3812,56 @@ export class Pragma { } export class ExperimentalFeature { - private readonly fetch: () => StringLiteral | TokenNode = once(() => { + private readonly fetch: () => StringLiteral | TerminalNode = once(() => { const variant = ast_internal.selectChoice(this.cst); switch (variant.kind) { - case RuleKind.StringLiteral: - return new StringLiteral(variant as RuleNode); + case NonTerminalKind.StringLiteral: + return new StringLiteral(variant as NonTerminalNode); - case TokenKind.Identifier: - return variant as TokenNode; + case TerminalKind.Identifier: + return variant as TerminalNode; default: assert.fail(`Unexpected variant: ${variant.kind}`); } }); - public constructor(public readonly cst: RuleNode) { - assertKind(this.cst.kind, RuleKind.ExperimentalFeature); + public constructor(public readonly cst: NonTerminalNode) { + assertKind(this.cst.kind, NonTerminalKind.ExperimentalFeature); } - public get variant(): StringLiteral | TokenNode { + public get variant(): StringLiteral | TerminalNode { return this.fetch(); } } export class VersionExpression { - private readonly fetch: () => VersionRange | VersionComparator | VersionSpecifiers | TokenNode = once(() => { + private readonly fetch: () => VersionRange | VersionComparator | VersionSpecifiers | TerminalNode = once(() => { const variant = ast_internal.selectChoice(this.cst); switch (variant.kind) { - case RuleKind.VersionRange: - return new VersionRange(variant as RuleNode); - case RuleKind.VersionComparator: - return new VersionComparator(variant as RuleNode); - case RuleKind.VersionSpecifiers: - return new VersionSpecifiers(variant as RuleNode); + case NonTerminalKind.VersionRange: + return new VersionRange(variant as NonTerminalNode); + case NonTerminalKind.VersionComparator: + return new VersionComparator(variant as NonTerminalNode); + case NonTerminalKind.VersionSpecifiers: + return new VersionSpecifiers(variant as NonTerminalNode); - case TokenKind.SingleQuotedVersionLiteral: - case TokenKind.DoubleQuotedVersionLiteral: - return variant as TokenNode; + case TerminalKind.SingleQuotedVersionLiteral: + case TerminalKind.DoubleQuotedVersionLiteral: + return variant as TerminalNode; default: assert.fail(`Unexpected variant: ${variant.kind}`); } }); - public constructor(public readonly cst: RuleNode) { - assertKind(this.cst.kind, RuleKind.VersionExpression); + public constructor(public readonly cst: NonTerminalNode) { + assertKind(this.cst.kind, NonTerminalKind.VersionExpression); } - public get variant(): VersionRange | VersionComparator | VersionSpecifiers | TokenNode { + public get variant(): VersionRange | VersionComparator | VersionSpecifiers | TerminalNode { return this.fetch(); } } @@ -3871,20 +3871,20 @@ export class ImportClause { const variant = ast_internal.selectChoice(this.cst); switch (variant.kind) { - case RuleKind.PathImport: - return new PathImport(variant as RuleNode); - case RuleKind.NamedImport: - return new NamedImport(variant as RuleNode); - case RuleKind.ImportDeconstruction: - return new ImportDeconstruction(variant as RuleNode); + case NonTerminalKind.PathImport: + return new PathImport(variant as NonTerminalNode); + case NonTerminalKind.NamedImport: + return new NamedImport(variant as NonTerminalNode); + case NonTerminalKind.ImportDeconstruction: + return new ImportDeconstruction(variant as NonTerminalNode); default: assert.fail(`Unexpected variant: ${variant.kind}`); } }); - public constructor(public readonly cst: RuleNode) { - assertKind(this.cst.kind, RuleKind.ImportClause); + public constructor(public readonly cst: NonTerminalNode) { + assertKind(this.cst.kind, NonTerminalKind.ImportClause); } public get variant(): PathImport | NamedImport | ImportDeconstruction { @@ -3897,18 +3897,18 @@ export class UsingClause { const variant = ast_internal.selectChoice(this.cst); switch (variant.kind) { - case RuleKind.IdentifierPath: - return new IdentifierPath(variant as RuleNode); - case RuleKind.UsingDeconstruction: - return new UsingDeconstruction(variant as RuleNode); + case NonTerminalKind.IdentifierPath: + return new IdentifierPath(variant as NonTerminalNode); + case NonTerminalKind.UsingDeconstruction: + return new UsingDeconstruction(variant as NonTerminalNode); default: assert.fail(`Unexpected variant: ${variant.kind}`); } }); - public constructor(public readonly cst: RuleNode) { - assertKind(this.cst.kind, RuleKind.UsingClause); + public constructor(public readonly cst: NonTerminalNode) { + assertKind(this.cst.kind, NonTerminalKind.UsingClause); } public get variant(): IdentifierPath | UsingDeconstruction { @@ -3917,62 +3917,62 @@ export class UsingClause { } export class UsingOperator { - private readonly fetch: () => TokenNode = once(() => { + private readonly fetch: () => TerminalNode = once(() => { const variant = ast_internal.selectChoice(this.cst); switch (variant.kind) { - case TokenKind.Ampersand: - case TokenKind.Asterisk: - case TokenKind.BangEqual: - case TokenKind.Bar: - case TokenKind.Caret: - case TokenKind.EqualEqual: - case TokenKind.GreaterThan: - case TokenKind.GreaterThanEqual: - case TokenKind.LessThan: - case TokenKind.LessThanEqual: - case TokenKind.Minus: - case TokenKind.Percent: - case TokenKind.Plus: - case TokenKind.Slash: - case TokenKind.Tilde: - return variant as TokenNode; + case TerminalKind.Ampersand: + case TerminalKind.Asterisk: + case TerminalKind.BangEqual: + case TerminalKind.Bar: + case TerminalKind.Caret: + case TerminalKind.EqualEqual: + case TerminalKind.GreaterThan: + case TerminalKind.GreaterThanEqual: + case TerminalKind.LessThan: + case TerminalKind.LessThanEqual: + case TerminalKind.Minus: + case TerminalKind.Percent: + case TerminalKind.Plus: + case TerminalKind.Slash: + case TerminalKind.Tilde: + return variant as TerminalNode; default: assert.fail(`Unexpected variant: ${variant.kind}`); } }); - public constructor(public readonly cst: RuleNode) { - assertKind(this.cst.kind, RuleKind.UsingOperator); + public constructor(public readonly cst: NonTerminalNode) { + assertKind(this.cst.kind, NonTerminalKind.UsingOperator); } - public get variant(): TokenNode { + public get variant(): TerminalNode { return this.fetch(); } } export class UsingTarget { - private readonly fetch: () => TypeName | TokenNode = once(() => { + private readonly fetch: () => TypeName | TerminalNode = once(() => { const variant = ast_internal.selectChoice(this.cst); switch (variant.kind) { - case RuleKind.TypeName: - return new TypeName(variant as RuleNode); + case NonTerminalKind.TypeName: + return new TypeName(variant as NonTerminalNode); - case TokenKind.Asterisk: - return variant as TokenNode; + case TerminalKind.Asterisk: + return variant as TerminalNode; default: assert.fail(`Unexpected variant: ${variant.kind}`); } }); - public constructor(public readonly cst: RuleNode) { - assertKind(this.cst.kind, RuleKind.UsingTarget); + public constructor(public readonly cst: NonTerminalNode) { + assertKind(this.cst.kind, NonTerminalKind.UsingTarget); } - public get variant(): TypeName | TokenNode { + public get variant(): TypeName | TerminalNode { return this.fetch(); } } @@ -3995,40 +3995,40 @@ export class ContractMember { const variant = ast_internal.selectChoice(this.cst); switch (variant.kind) { - case RuleKind.UsingDirective: - return new UsingDirective(variant as RuleNode); - case RuleKind.FunctionDefinition: - return new FunctionDefinition(variant as RuleNode); - case RuleKind.ConstructorDefinition: - return new ConstructorDefinition(variant as RuleNode); - case RuleKind.ReceiveFunctionDefinition: - return new ReceiveFunctionDefinition(variant as RuleNode); - case RuleKind.FallbackFunctionDefinition: - return new FallbackFunctionDefinition(variant as RuleNode); - case RuleKind.UnnamedFunctionDefinition: - return new UnnamedFunctionDefinition(variant as RuleNode); - case RuleKind.ModifierDefinition: - return new ModifierDefinition(variant as RuleNode); - case RuleKind.StructDefinition: - return new StructDefinition(variant as RuleNode); - case RuleKind.EnumDefinition: - return new EnumDefinition(variant as RuleNode); - case RuleKind.EventDefinition: - return new EventDefinition(variant as RuleNode); - case RuleKind.StateVariableDefinition: - return new StateVariableDefinition(variant as RuleNode); - case RuleKind.ErrorDefinition: - return new ErrorDefinition(variant as RuleNode); - case RuleKind.UserDefinedValueTypeDefinition: - return new UserDefinedValueTypeDefinition(variant as RuleNode); + case NonTerminalKind.UsingDirective: + return new UsingDirective(variant as NonTerminalNode); + case NonTerminalKind.FunctionDefinition: + return new FunctionDefinition(variant as NonTerminalNode); + case NonTerminalKind.ConstructorDefinition: + return new ConstructorDefinition(variant as NonTerminalNode); + case NonTerminalKind.ReceiveFunctionDefinition: + return new ReceiveFunctionDefinition(variant as NonTerminalNode); + case NonTerminalKind.FallbackFunctionDefinition: + return new FallbackFunctionDefinition(variant as NonTerminalNode); + case NonTerminalKind.UnnamedFunctionDefinition: + return new UnnamedFunctionDefinition(variant as NonTerminalNode); + case NonTerminalKind.ModifierDefinition: + return new ModifierDefinition(variant as NonTerminalNode); + case NonTerminalKind.StructDefinition: + return new StructDefinition(variant as NonTerminalNode); + case NonTerminalKind.EnumDefinition: + return new EnumDefinition(variant as NonTerminalNode); + case NonTerminalKind.EventDefinition: + return new EventDefinition(variant as NonTerminalNode); + case NonTerminalKind.StateVariableDefinition: + return new StateVariableDefinition(variant as NonTerminalNode); + case NonTerminalKind.ErrorDefinition: + return new ErrorDefinition(variant as NonTerminalNode); + case NonTerminalKind.UserDefinedValueTypeDefinition: + return new UserDefinedValueTypeDefinition(variant as NonTerminalNode); default: assert.fail(`Unexpected variant: ${variant.kind}`); } }); - public constructor(public readonly cst: RuleNode) { - assertKind(this.cst.kind, RuleKind.ContractMember); + public constructor(public readonly cst: NonTerminalNode) { + assertKind(this.cst.kind, NonTerminalKind.ContractMember); } public get variant(): @@ -4050,260 +4050,260 @@ export class ContractMember { } export class StateVariableAttribute { - private readonly fetch: () => OverrideSpecifier | TokenNode = once(() => { + private readonly fetch: () => OverrideSpecifier | TerminalNode = once(() => { const variant = ast_internal.selectChoice(this.cst); switch (variant.kind) { - case RuleKind.OverrideSpecifier: - return new OverrideSpecifier(variant as RuleNode); + case NonTerminalKind.OverrideSpecifier: + return new OverrideSpecifier(variant as NonTerminalNode); - case TokenKind.ConstantKeyword: - case TokenKind.InternalKeyword: - case TokenKind.PrivateKeyword: - case TokenKind.PublicKeyword: - case TokenKind.ImmutableKeyword: - return variant as TokenNode; + case TerminalKind.ConstantKeyword: + case TerminalKind.InternalKeyword: + case TerminalKind.PrivateKeyword: + case TerminalKind.PublicKeyword: + case TerminalKind.ImmutableKeyword: + return variant as TerminalNode; default: assert.fail(`Unexpected variant: ${variant.kind}`); } }); - public constructor(public readonly cst: RuleNode) { - assertKind(this.cst.kind, RuleKind.StateVariableAttribute); + public constructor(public readonly cst: NonTerminalNode) { + assertKind(this.cst.kind, NonTerminalKind.StateVariableAttribute); } - public get variant(): OverrideSpecifier | TokenNode { + public get variant(): OverrideSpecifier | TerminalNode { return this.fetch(); } } export class FunctionName { - private readonly fetch: () => TokenNode = once(() => { + private readonly fetch: () => TerminalNode = once(() => { const variant = ast_internal.selectChoice(this.cst); switch (variant.kind) { - case TokenKind.Identifier: - case TokenKind.FallbackKeyword: - case TokenKind.ReceiveKeyword: - return variant as TokenNode; + case TerminalKind.Identifier: + case TerminalKind.FallbackKeyword: + case TerminalKind.ReceiveKeyword: + return variant as TerminalNode; default: assert.fail(`Unexpected variant: ${variant.kind}`); } }); - public constructor(public readonly cst: RuleNode) { - assertKind(this.cst.kind, RuleKind.FunctionName); + public constructor(public readonly cst: NonTerminalNode) { + assertKind(this.cst.kind, NonTerminalKind.FunctionName); } - public get variant(): TokenNode { + public get variant(): TerminalNode { return this.fetch(); } } export class FunctionAttribute { - private readonly fetch: () => ModifierInvocation | OverrideSpecifier | TokenNode = once(() => { + private readonly fetch: () => ModifierInvocation | OverrideSpecifier | TerminalNode = once(() => { const variant = ast_internal.selectChoice(this.cst); switch (variant.kind) { - case RuleKind.ModifierInvocation: - return new ModifierInvocation(variant as RuleNode); - case RuleKind.OverrideSpecifier: - return new OverrideSpecifier(variant as RuleNode); - - case TokenKind.ConstantKeyword: - case TokenKind.ExternalKeyword: - case TokenKind.InternalKeyword: - case TokenKind.PayableKeyword: - case TokenKind.PrivateKeyword: - case TokenKind.PublicKeyword: - case TokenKind.PureKeyword: - case TokenKind.ViewKeyword: - case TokenKind.VirtualKeyword: - return variant as TokenNode; + case NonTerminalKind.ModifierInvocation: + return new ModifierInvocation(variant as NonTerminalNode); + case NonTerminalKind.OverrideSpecifier: + return new OverrideSpecifier(variant as NonTerminalNode); + + case TerminalKind.ConstantKeyword: + case TerminalKind.ExternalKeyword: + case TerminalKind.InternalKeyword: + case TerminalKind.PayableKeyword: + case TerminalKind.PrivateKeyword: + case TerminalKind.PublicKeyword: + case TerminalKind.PureKeyword: + case TerminalKind.ViewKeyword: + case TerminalKind.VirtualKeyword: + return variant as TerminalNode; default: assert.fail(`Unexpected variant: ${variant.kind}`); } }); - public constructor(public readonly cst: RuleNode) { - assertKind(this.cst.kind, RuleKind.FunctionAttribute); + public constructor(public readonly cst: NonTerminalNode) { + assertKind(this.cst.kind, NonTerminalKind.FunctionAttribute); } - public get variant(): ModifierInvocation | OverrideSpecifier | TokenNode { + public get variant(): ModifierInvocation | OverrideSpecifier | TerminalNode { return this.fetch(); } } export class FunctionBody { - private readonly fetch: () => Block | TokenNode = once(() => { + private readonly fetch: () => Block | TerminalNode = once(() => { const variant = ast_internal.selectChoice(this.cst); switch (variant.kind) { - case RuleKind.Block: - return new Block(variant as RuleNode); + case NonTerminalKind.Block: + return new Block(variant as NonTerminalNode); - case TokenKind.Semicolon: - return variant as TokenNode; + case TerminalKind.Semicolon: + return variant as TerminalNode; default: assert.fail(`Unexpected variant: ${variant.kind}`); } }); - public constructor(public readonly cst: RuleNode) { - assertKind(this.cst.kind, RuleKind.FunctionBody); + public constructor(public readonly cst: NonTerminalNode) { + assertKind(this.cst.kind, NonTerminalKind.FunctionBody); } - public get variant(): Block | TokenNode { + public get variant(): Block | TerminalNode { return this.fetch(); } } export class ConstructorAttribute { - private readonly fetch: () => ModifierInvocation | TokenNode = once(() => { + private readonly fetch: () => ModifierInvocation | TerminalNode = once(() => { const variant = ast_internal.selectChoice(this.cst); switch (variant.kind) { - case RuleKind.ModifierInvocation: - return new ModifierInvocation(variant as RuleNode); + case NonTerminalKind.ModifierInvocation: + return new ModifierInvocation(variant as NonTerminalNode); - case TokenKind.InternalKeyword: - case TokenKind.OverrideKeyword: - case TokenKind.PayableKeyword: - case TokenKind.PublicKeyword: - case TokenKind.VirtualKeyword: - return variant as TokenNode; + case TerminalKind.InternalKeyword: + case TerminalKind.OverrideKeyword: + case TerminalKind.PayableKeyword: + case TerminalKind.PublicKeyword: + case TerminalKind.VirtualKeyword: + return variant as TerminalNode; default: assert.fail(`Unexpected variant: ${variant.kind}`); } }); - public constructor(public readonly cst: RuleNode) { - assertKind(this.cst.kind, RuleKind.ConstructorAttribute); + public constructor(public readonly cst: NonTerminalNode) { + assertKind(this.cst.kind, NonTerminalKind.ConstructorAttribute); } - public get variant(): ModifierInvocation | TokenNode { + public get variant(): ModifierInvocation | TerminalNode { return this.fetch(); } } export class UnnamedFunctionAttribute { - private readonly fetch: () => ModifierInvocation | TokenNode = once(() => { + private readonly fetch: () => ModifierInvocation | TerminalNode = once(() => { const variant = ast_internal.selectChoice(this.cst); switch (variant.kind) { - case RuleKind.ModifierInvocation: - return new ModifierInvocation(variant as RuleNode); - - case TokenKind.ConstantKeyword: - case TokenKind.ExternalKeyword: - case TokenKind.InternalKeyword: - case TokenKind.PayableKeyword: - case TokenKind.PrivateKeyword: - case TokenKind.PublicKeyword: - case TokenKind.PureKeyword: - case TokenKind.ViewKeyword: - return variant as TokenNode; + case NonTerminalKind.ModifierInvocation: + return new ModifierInvocation(variant as NonTerminalNode); + + case TerminalKind.ConstantKeyword: + case TerminalKind.ExternalKeyword: + case TerminalKind.InternalKeyword: + case TerminalKind.PayableKeyword: + case TerminalKind.PrivateKeyword: + case TerminalKind.PublicKeyword: + case TerminalKind.PureKeyword: + case TerminalKind.ViewKeyword: + return variant as TerminalNode; default: assert.fail(`Unexpected variant: ${variant.kind}`); } }); - public constructor(public readonly cst: RuleNode) { - assertKind(this.cst.kind, RuleKind.UnnamedFunctionAttribute); + public constructor(public readonly cst: NonTerminalNode) { + assertKind(this.cst.kind, NonTerminalKind.UnnamedFunctionAttribute); } - public get variant(): ModifierInvocation | TokenNode { + public get variant(): ModifierInvocation | TerminalNode { return this.fetch(); } } export class FallbackFunctionAttribute { - private readonly fetch: () => ModifierInvocation | OverrideSpecifier | TokenNode = once(() => { + private readonly fetch: () => ModifierInvocation | OverrideSpecifier | TerminalNode = once(() => { const variant = ast_internal.selectChoice(this.cst); switch (variant.kind) { - case RuleKind.ModifierInvocation: - return new ModifierInvocation(variant as RuleNode); - case RuleKind.OverrideSpecifier: - return new OverrideSpecifier(variant as RuleNode); - - case TokenKind.ExternalKeyword: - case TokenKind.PayableKeyword: - case TokenKind.PureKeyword: - case TokenKind.ViewKeyword: - case TokenKind.VirtualKeyword: - return variant as TokenNode; + case NonTerminalKind.ModifierInvocation: + return new ModifierInvocation(variant as NonTerminalNode); + case NonTerminalKind.OverrideSpecifier: + return new OverrideSpecifier(variant as NonTerminalNode); + + case TerminalKind.ExternalKeyword: + case TerminalKind.PayableKeyword: + case TerminalKind.PureKeyword: + case TerminalKind.ViewKeyword: + case TerminalKind.VirtualKeyword: + return variant as TerminalNode; default: assert.fail(`Unexpected variant: ${variant.kind}`); } }); - public constructor(public readonly cst: RuleNode) { - assertKind(this.cst.kind, RuleKind.FallbackFunctionAttribute); + public constructor(public readonly cst: NonTerminalNode) { + assertKind(this.cst.kind, NonTerminalKind.FallbackFunctionAttribute); } - public get variant(): ModifierInvocation | OverrideSpecifier | TokenNode { + public get variant(): ModifierInvocation | OverrideSpecifier | TerminalNode { return this.fetch(); } } export class ReceiveFunctionAttribute { - private readonly fetch: () => ModifierInvocation | OverrideSpecifier | TokenNode = once(() => { + private readonly fetch: () => ModifierInvocation | OverrideSpecifier | TerminalNode = once(() => { const variant = ast_internal.selectChoice(this.cst); switch (variant.kind) { - case RuleKind.ModifierInvocation: - return new ModifierInvocation(variant as RuleNode); - case RuleKind.OverrideSpecifier: - return new OverrideSpecifier(variant as RuleNode); + case NonTerminalKind.ModifierInvocation: + return new ModifierInvocation(variant as NonTerminalNode); + case NonTerminalKind.OverrideSpecifier: + return new OverrideSpecifier(variant as NonTerminalNode); - case TokenKind.ExternalKeyword: - case TokenKind.PayableKeyword: - case TokenKind.VirtualKeyword: - return variant as TokenNode; + case TerminalKind.ExternalKeyword: + case TerminalKind.PayableKeyword: + case TerminalKind.VirtualKeyword: + return variant as TerminalNode; default: assert.fail(`Unexpected variant: ${variant.kind}`); } }); - public constructor(public readonly cst: RuleNode) { - assertKind(this.cst.kind, RuleKind.ReceiveFunctionAttribute); + public constructor(public readonly cst: NonTerminalNode) { + assertKind(this.cst.kind, NonTerminalKind.ReceiveFunctionAttribute); } - public get variant(): ModifierInvocation | OverrideSpecifier | TokenNode { + public get variant(): ModifierInvocation | OverrideSpecifier | TerminalNode { return this.fetch(); } } export class ModifierAttribute { - private readonly fetch: () => OverrideSpecifier | TokenNode = once(() => { + private readonly fetch: () => OverrideSpecifier | TerminalNode = once(() => { const variant = ast_internal.selectChoice(this.cst); switch (variant.kind) { - case RuleKind.OverrideSpecifier: - return new OverrideSpecifier(variant as RuleNode); + case NonTerminalKind.OverrideSpecifier: + return new OverrideSpecifier(variant as NonTerminalNode); - case TokenKind.VirtualKeyword: - return variant as TokenNode; + case TerminalKind.VirtualKeyword: + return variant as TerminalNode; default: assert.fail(`Unexpected variant: ${variant.kind}`); } }); - public constructor(public readonly cst: RuleNode) { - assertKind(this.cst.kind, RuleKind.ModifierAttribute); + public constructor(public readonly cst: NonTerminalNode) { + assertKind(this.cst.kind, NonTerminalKind.ModifierAttribute); } - public get variant(): OverrideSpecifier | TokenNode { + public get variant(): OverrideSpecifier | TerminalNode { return this.fetch(); } } @@ -4314,16 +4314,16 @@ export class TypeName { const variant = ast_internal.selectChoice(this.cst); switch (variant.kind) { - case RuleKind.ArrayTypeName: - return new ArrayTypeName(variant as RuleNode); - case RuleKind.FunctionType: - return new FunctionType(variant as RuleNode); - case RuleKind.MappingType: - return new MappingType(variant as RuleNode); - case RuleKind.ElementaryType: - return new ElementaryType(variant as RuleNode); - case RuleKind.IdentifierPath: - return new IdentifierPath(variant as RuleNode); + case NonTerminalKind.ArrayTypeName: + return new ArrayTypeName(variant as NonTerminalNode); + case NonTerminalKind.FunctionType: + return new FunctionType(variant as NonTerminalNode); + case NonTerminalKind.MappingType: + return new MappingType(variant as NonTerminalNode); + case NonTerminalKind.ElementaryType: + return new ElementaryType(variant as NonTerminalNode); + case NonTerminalKind.IdentifierPath: + return new IdentifierPath(variant as NonTerminalNode); default: assert.fail(`Unexpected variant: ${variant.kind}`); @@ -4331,8 +4331,8 @@ export class TypeName { }, ); - public constructor(public readonly cst: RuleNode) { - assertKind(this.cst.kind, RuleKind.TypeName); + public constructor(public readonly cst: NonTerminalNode) { + assertKind(this.cst.kind, NonTerminalKind.TypeName); } public get variant(): ArrayTypeName | FunctionType | MappingType | ElementaryType | IdentifierPath { @@ -4341,30 +4341,30 @@ export class TypeName { } export class FunctionTypeAttribute { - private readonly fetch: () => TokenNode = once(() => { + private readonly fetch: () => TerminalNode = once(() => { const variant = ast_internal.selectChoice(this.cst); switch (variant.kind) { - case TokenKind.InternalKeyword: - case TokenKind.ExternalKeyword: - case TokenKind.PrivateKeyword: - case TokenKind.PublicKeyword: - case TokenKind.ConstantKeyword: - case TokenKind.PureKeyword: - case TokenKind.ViewKeyword: - case TokenKind.PayableKeyword: - return variant as TokenNode; + case TerminalKind.InternalKeyword: + case TerminalKind.ExternalKeyword: + case TerminalKind.PrivateKeyword: + case TerminalKind.PublicKeyword: + case TerminalKind.ConstantKeyword: + case TerminalKind.PureKeyword: + case TerminalKind.ViewKeyword: + case TerminalKind.PayableKeyword: + return variant as TerminalNode; default: assert.fail(`Unexpected variant: ${variant.kind}`); } }); - public constructor(public readonly cst: RuleNode) { - assertKind(this.cst.kind, RuleKind.FunctionTypeAttribute); + public constructor(public readonly cst: NonTerminalNode) { + assertKind(this.cst.kind, NonTerminalKind.FunctionTypeAttribute); } - public get variant(): TokenNode { + public get variant(): TerminalNode { return this.fetch(); } } @@ -4374,18 +4374,18 @@ export class MappingKeyType { const variant = ast_internal.selectChoice(this.cst); switch (variant.kind) { - case RuleKind.ElementaryType: - return new ElementaryType(variant as RuleNode); - case RuleKind.IdentifierPath: - return new IdentifierPath(variant as RuleNode); + case NonTerminalKind.ElementaryType: + return new ElementaryType(variant as NonTerminalNode); + case NonTerminalKind.IdentifierPath: + return new IdentifierPath(variant as NonTerminalNode); default: assert.fail(`Unexpected variant: ${variant.kind}`); } }); - public constructor(public readonly cst: RuleNode) { - assertKind(this.cst.kind, RuleKind.MappingKeyType); + public constructor(public readonly cst: NonTerminalNode) { + assertKind(this.cst.kind, NonTerminalKind.MappingKeyType); } public get variant(): ElementaryType | IdentifierPath { @@ -4394,33 +4394,33 @@ export class MappingKeyType { } export class ElementaryType { - private readonly fetch: () => AddressType | TokenNode = once(() => { + private readonly fetch: () => AddressType | TerminalNode = once(() => { const variant = ast_internal.selectChoice(this.cst); switch (variant.kind) { - case RuleKind.AddressType: - return new AddressType(variant as RuleNode); - - case TokenKind.BoolKeyword: - case TokenKind.ByteKeyword: - case TokenKind.StringKeyword: - case TokenKind.BytesKeyword: - case TokenKind.IntKeyword: - case TokenKind.UintKeyword: - case TokenKind.FixedKeyword: - case TokenKind.UfixedKeyword: - return variant as TokenNode; + case NonTerminalKind.AddressType: + return new AddressType(variant as NonTerminalNode); + + case TerminalKind.BoolKeyword: + case TerminalKind.ByteKeyword: + case TerminalKind.StringKeyword: + case TerminalKind.BytesKeyword: + case TerminalKind.IntKeyword: + case TerminalKind.UintKeyword: + case TerminalKind.FixedKeyword: + case TerminalKind.UfixedKeyword: + return variant as TerminalNode; default: assert.fail(`Unexpected variant: ${variant.kind}`); } }); - public constructor(public readonly cst: RuleNode) { - assertKind(this.cst.kind, RuleKind.ElementaryType); + public constructor(public readonly cst: NonTerminalNode) { + assertKind(this.cst.kind, NonTerminalKind.ElementaryType); } - public get variant(): AddressType | TokenNode { + public get variant(): AddressType | TerminalNode { return this.fetch(); } } @@ -4447,48 +4447,48 @@ export class Statement { const variant = ast_internal.selectChoice(this.cst); switch (variant.kind) { - case RuleKind.ExpressionStatement: - return new ExpressionStatement(variant as RuleNode); - case RuleKind.VariableDeclarationStatement: - return new VariableDeclarationStatement(variant as RuleNode); - case RuleKind.TupleDeconstructionStatement: - return new TupleDeconstructionStatement(variant as RuleNode); - case RuleKind.IfStatement: - return new IfStatement(variant as RuleNode); - case RuleKind.ForStatement: - return new ForStatement(variant as RuleNode); - case RuleKind.WhileStatement: - return new WhileStatement(variant as RuleNode); - case RuleKind.DoWhileStatement: - return new DoWhileStatement(variant as RuleNode); - case RuleKind.ContinueStatement: - return new ContinueStatement(variant as RuleNode); - case RuleKind.BreakStatement: - return new BreakStatement(variant as RuleNode); - case RuleKind.ReturnStatement: - return new ReturnStatement(variant as RuleNode); - case RuleKind.ThrowStatement: - return new ThrowStatement(variant as RuleNode); - case RuleKind.EmitStatement: - return new EmitStatement(variant as RuleNode); - case RuleKind.TryStatement: - return new TryStatement(variant as RuleNode); - case RuleKind.RevertStatement: - return new RevertStatement(variant as RuleNode); - case RuleKind.AssemblyStatement: - return new AssemblyStatement(variant as RuleNode); - case RuleKind.Block: - return new Block(variant as RuleNode); - case RuleKind.UncheckedBlock: - return new UncheckedBlock(variant as RuleNode); + case NonTerminalKind.ExpressionStatement: + return new ExpressionStatement(variant as NonTerminalNode); + case NonTerminalKind.VariableDeclarationStatement: + return new VariableDeclarationStatement(variant as NonTerminalNode); + case NonTerminalKind.TupleDeconstructionStatement: + return new TupleDeconstructionStatement(variant as NonTerminalNode); + case NonTerminalKind.IfStatement: + return new IfStatement(variant as NonTerminalNode); + case NonTerminalKind.ForStatement: + return new ForStatement(variant as NonTerminalNode); + case NonTerminalKind.WhileStatement: + return new WhileStatement(variant as NonTerminalNode); + case NonTerminalKind.DoWhileStatement: + return new DoWhileStatement(variant as NonTerminalNode); + case NonTerminalKind.ContinueStatement: + return new ContinueStatement(variant as NonTerminalNode); + case NonTerminalKind.BreakStatement: + return new BreakStatement(variant as NonTerminalNode); + case NonTerminalKind.ReturnStatement: + return new ReturnStatement(variant as NonTerminalNode); + case NonTerminalKind.ThrowStatement: + return new ThrowStatement(variant as NonTerminalNode); + case NonTerminalKind.EmitStatement: + return new EmitStatement(variant as NonTerminalNode); + case NonTerminalKind.TryStatement: + return new TryStatement(variant as NonTerminalNode); + case NonTerminalKind.RevertStatement: + return new RevertStatement(variant as NonTerminalNode); + case NonTerminalKind.AssemblyStatement: + return new AssemblyStatement(variant as NonTerminalNode); + case NonTerminalKind.Block: + return new Block(variant as NonTerminalNode); + case NonTerminalKind.UncheckedBlock: + return new UncheckedBlock(variant as NonTerminalNode); default: assert.fail(`Unexpected variant: ${variant.kind}`); } }); - public constructor(public readonly cst: RuleNode) { - assertKind(this.cst.kind, RuleKind.Statement); + public constructor(public readonly cst: NonTerminalNode) { + assertKind(this.cst.kind, NonTerminalKind.Statement); } public get variant(): @@ -4518,18 +4518,18 @@ export class TupleMember { const variant = ast_internal.selectChoice(this.cst); switch (variant.kind) { - case RuleKind.TypedTupleMember: - return new TypedTupleMember(variant as RuleNode); - case RuleKind.UntypedTupleMember: - return new UntypedTupleMember(variant as RuleNode); + case NonTerminalKind.TypedTupleMember: + return new TypedTupleMember(variant as NonTerminalNode); + case NonTerminalKind.UntypedTupleMember: + return new UntypedTupleMember(variant as NonTerminalNode); default: assert.fail(`Unexpected variant: ${variant.kind}`); } }); - public constructor(public readonly cst: RuleNode) { - assertKind(this.cst.kind, RuleKind.TupleMember); + public constructor(public readonly cst: NonTerminalNode) { + assertKind(this.cst.kind, NonTerminalKind.TupleMember); } public get variant(): TypedTupleMember | UntypedTupleMember { @@ -4538,50 +4538,50 @@ export class TupleMember { } export class VariableDeclarationType { - private readonly fetch: () => TypeName | TokenNode = once(() => { + private readonly fetch: () => TypeName | TerminalNode = once(() => { const variant = ast_internal.selectChoice(this.cst); switch (variant.kind) { - case RuleKind.TypeName: - return new TypeName(variant as RuleNode); + case NonTerminalKind.TypeName: + return new TypeName(variant as NonTerminalNode); - case TokenKind.VarKeyword: - return variant as TokenNode; + case TerminalKind.VarKeyword: + return variant as TerminalNode; default: assert.fail(`Unexpected variant: ${variant.kind}`); } }); - public constructor(public readonly cst: RuleNode) { - assertKind(this.cst.kind, RuleKind.VariableDeclarationType); + public constructor(public readonly cst: NonTerminalNode) { + assertKind(this.cst.kind, NonTerminalKind.VariableDeclarationType); } - public get variant(): TypeName | TokenNode { + public get variant(): TypeName | TerminalNode { return this.fetch(); } } export class StorageLocation { - private readonly fetch: () => TokenNode = once(() => { + private readonly fetch: () => TerminalNode = once(() => { const variant = ast_internal.selectChoice(this.cst); switch (variant.kind) { - case TokenKind.MemoryKeyword: - case TokenKind.StorageKeyword: - case TokenKind.CallDataKeyword: - return variant as TokenNode; + case TerminalKind.MemoryKeyword: + case TerminalKind.StorageKeyword: + case TerminalKind.CallDataKeyword: + return variant as TerminalNode; default: assert.fail(`Unexpected variant: ${variant.kind}`); } }); - public constructor(public readonly cst: RuleNode) { - assertKind(this.cst.kind, RuleKind.StorageLocation); + public constructor(public readonly cst: NonTerminalNode) { + assertKind(this.cst.kind, NonTerminalKind.StorageLocation); } - public get variant(): TokenNode { + public get variant(): TerminalNode { return this.fetch(); } } @@ -4591,55 +4591,59 @@ export class ForStatementInitialization { | ExpressionStatement | VariableDeclarationStatement | TupleDeconstructionStatement - | TokenNode = once(() => { + | TerminalNode = once(() => { const variant = ast_internal.selectChoice(this.cst); switch (variant.kind) { - case RuleKind.ExpressionStatement: - return new ExpressionStatement(variant as RuleNode); - case RuleKind.VariableDeclarationStatement: - return new VariableDeclarationStatement(variant as RuleNode); - case RuleKind.TupleDeconstructionStatement: - return new TupleDeconstructionStatement(variant as RuleNode); + case NonTerminalKind.ExpressionStatement: + return new ExpressionStatement(variant as NonTerminalNode); + case NonTerminalKind.VariableDeclarationStatement: + return new VariableDeclarationStatement(variant as NonTerminalNode); + case NonTerminalKind.TupleDeconstructionStatement: + return new TupleDeconstructionStatement(variant as NonTerminalNode); - case TokenKind.Semicolon: - return variant as TokenNode; + case TerminalKind.Semicolon: + return variant as TerminalNode; default: assert.fail(`Unexpected variant: ${variant.kind}`); } }); - public constructor(public readonly cst: RuleNode) { - assertKind(this.cst.kind, RuleKind.ForStatementInitialization); + public constructor(public readonly cst: NonTerminalNode) { + assertKind(this.cst.kind, NonTerminalKind.ForStatementInitialization); } - public get variant(): ExpressionStatement | VariableDeclarationStatement | TupleDeconstructionStatement | TokenNode { + public get variant(): + | ExpressionStatement + | VariableDeclarationStatement + | TupleDeconstructionStatement + | TerminalNode { return this.fetch(); } } export class ForStatementCondition { - private readonly fetch: () => ExpressionStatement | TokenNode = once(() => { + private readonly fetch: () => ExpressionStatement | TerminalNode = once(() => { const variant = ast_internal.selectChoice(this.cst); switch (variant.kind) { - case RuleKind.ExpressionStatement: - return new ExpressionStatement(variant as RuleNode); + case NonTerminalKind.ExpressionStatement: + return new ExpressionStatement(variant as NonTerminalNode); - case TokenKind.Semicolon: - return variant as TokenNode; + case TerminalKind.Semicolon: + return variant as TerminalNode; default: assert.fail(`Unexpected variant: ${variant.kind}`); } }); - public constructor(public readonly cst: RuleNode) { - assertKind(this.cst.kind, RuleKind.ForStatementCondition); + public constructor(public readonly cst: NonTerminalNode) { + assertKind(this.cst.kind, NonTerminalKind.ForStatementCondition); } - public get variant(): ExpressionStatement | TokenNode { + public get variant(): ExpressionStatement | TerminalNode { return this.fetch(); } } @@ -4673,78 +4677,78 @@ export class Expression { | DecimalNumberExpression | StringExpression | ElementaryType - | TokenNode = once(() => { + | TerminalNode = once(() => { const variant = ast_internal.selectChoice(this.cst); switch (variant.kind) { - case RuleKind.AssignmentExpression: - return new AssignmentExpression(variant as RuleNode); - case RuleKind.ConditionalExpression: - return new ConditionalExpression(variant as RuleNode); - case RuleKind.OrExpression: - return new OrExpression(variant as RuleNode); - case RuleKind.AndExpression: - return new AndExpression(variant as RuleNode); - case RuleKind.EqualityExpression: - return new EqualityExpression(variant as RuleNode); - case RuleKind.ComparisonExpression: - return new ComparisonExpression(variant as RuleNode); - case RuleKind.BitwiseOrExpression: - return new BitwiseOrExpression(variant as RuleNode); - case RuleKind.BitwiseXorExpression: - return new BitwiseXorExpression(variant as RuleNode); - case RuleKind.BitwiseAndExpression: - return new BitwiseAndExpression(variant as RuleNode); - case RuleKind.ShiftExpression: - return new ShiftExpression(variant as RuleNode); - case RuleKind.AdditiveExpression: - return new AdditiveExpression(variant as RuleNode); - case RuleKind.MultiplicativeExpression: - return new MultiplicativeExpression(variant as RuleNode); - case RuleKind.ExponentiationExpression: - return new ExponentiationExpression(variant as RuleNode); - case RuleKind.PostfixExpression: - return new PostfixExpression(variant as RuleNode); - case RuleKind.PrefixExpression: - return new PrefixExpression(variant as RuleNode); - case RuleKind.FunctionCallExpression: - return new FunctionCallExpression(variant as RuleNode); - case RuleKind.CallOptionsExpression: - return new CallOptionsExpression(variant as RuleNode); - case RuleKind.MemberAccessExpression: - return new MemberAccessExpression(variant as RuleNode); - case RuleKind.IndexAccessExpression: - return new IndexAccessExpression(variant as RuleNode); - case RuleKind.NewExpression: - return new NewExpression(variant as RuleNode); - case RuleKind.TupleExpression: - return new TupleExpression(variant as RuleNode); - case RuleKind.TypeExpression: - return new TypeExpression(variant as RuleNode); - case RuleKind.ArrayExpression: - return new ArrayExpression(variant as RuleNode); - case RuleKind.HexNumberExpression: - return new HexNumberExpression(variant as RuleNode); - case RuleKind.DecimalNumberExpression: - return new DecimalNumberExpression(variant as RuleNode); - case RuleKind.StringExpression: - return new StringExpression(variant as RuleNode); - case RuleKind.ElementaryType: - return new ElementaryType(variant as RuleNode); - - case TokenKind.PayableKeyword: - case TokenKind.TrueKeyword: - case TokenKind.FalseKeyword: - case TokenKind.Identifier: - return variant as TokenNode; + case NonTerminalKind.AssignmentExpression: + return new AssignmentExpression(variant as NonTerminalNode); + case NonTerminalKind.ConditionalExpression: + return new ConditionalExpression(variant as NonTerminalNode); + case NonTerminalKind.OrExpression: + return new OrExpression(variant as NonTerminalNode); + case NonTerminalKind.AndExpression: + return new AndExpression(variant as NonTerminalNode); + case NonTerminalKind.EqualityExpression: + return new EqualityExpression(variant as NonTerminalNode); + case NonTerminalKind.ComparisonExpression: + return new ComparisonExpression(variant as NonTerminalNode); + case NonTerminalKind.BitwiseOrExpression: + return new BitwiseOrExpression(variant as NonTerminalNode); + case NonTerminalKind.BitwiseXorExpression: + return new BitwiseXorExpression(variant as NonTerminalNode); + case NonTerminalKind.BitwiseAndExpression: + return new BitwiseAndExpression(variant as NonTerminalNode); + case NonTerminalKind.ShiftExpression: + return new ShiftExpression(variant as NonTerminalNode); + case NonTerminalKind.AdditiveExpression: + return new AdditiveExpression(variant as NonTerminalNode); + case NonTerminalKind.MultiplicativeExpression: + return new MultiplicativeExpression(variant as NonTerminalNode); + case NonTerminalKind.ExponentiationExpression: + return new ExponentiationExpression(variant as NonTerminalNode); + case NonTerminalKind.PostfixExpression: + return new PostfixExpression(variant as NonTerminalNode); + case NonTerminalKind.PrefixExpression: + return new PrefixExpression(variant as NonTerminalNode); + case NonTerminalKind.FunctionCallExpression: + return new FunctionCallExpression(variant as NonTerminalNode); + case NonTerminalKind.CallOptionsExpression: + return new CallOptionsExpression(variant as NonTerminalNode); + case NonTerminalKind.MemberAccessExpression: + return new MemberAccessExpression(variant as NonTerminalNode); + case NonTerminalKind.IndexAccessExpression: + return new IndexAccessExpression(variant as NonTerminalNode); + case NonTerminalKind.NewExpression: + return new NewExpression(variant as NonTerminalNode); + case NonTerminalKind.TupleExpression: + return new TupleExpression(variant as NonTerminalNode); + case NonTerminalKind.TypeExpression: + return new TypeExpression(variant as NonTerminalNode); + case NonTerminalKind.ArrayExpression: + return new ArrayExpression(variant as NonTerminalNode); + case NonTerminalKind.HexNumberExpression: + return new HexNumberExpression(variant as NonTerminalNode); + case NonTerminalKind.DecimalNumberExpression: + return new DecimalNumberExpression(variant as NonTerminalNode); + case NonTerminalKind.StringExpression: + return new StringExpression(variant as NonTerminalNode); + case NonTerminalKind.ElementaryType: + return new ElementaryType(variant as NonTerminalNode); + + case TerminalKind.PayableKeyword: + case TerminalKind.TrueKeyword: + case TerminalKind.FalseKeyword: + case TerminalKind.Identifier: + return variant as TerminalNode; default: assert.fail(`Unexpected variant: ${variant.kind}`); } }); - public constructor(public readonly cst: RuleNode) { - assertKind(this.cst.kind, RuleKind.Expression); + public constructor(public readonly cst: NonTerminalNode) { + assertKind(this.cst.kind, NonTerminalKind.Expression); } public get variant(): @@ -4775,30 +4779,30 @@ export class Expression { | DecimalNumberExpression | StringExpression | ElementaryType - | TokenNode { + | TerminalNode { return this.fetch(); } } export class MemberAccess { - private readonly fetch: () => TokenNode = once(() => { + private readonly fetch: () => TerminalNode = once(() => { const variant = ast_internal.selectChoice(this.cst); switch (variant.kind) { - case TokenKind.Identifier: - case TokenKind.AddressKeyword: - return variant as TokenNode; + case TerminalKind.Identifier: + case TerminalKind.AddressKeyword: + return variant as TerminalNode; default: assert.fail(`Unexpected variant: ${variant.kind}`); } }); - public constructor(public readonly cst: RuleNode) { - assertKind(this.cst.kind, RuleKind.MemberAccess); + public constructor(public readonly cst: NonTerminalNode) { + assertKind(this.cst.kind, NonTerminalKind.MemberAccess); } - public get variant(): TokenNode { + public get variant(): TerminalNode { return this.fetch(); } } @@ -4808,18 +4812,18 @@ export class ArgumentsDeclaration { const variant = ast_internal.selectChoice(this.cst); switch (variant.kind) { - case RuleKind.PositionalArgumentsDeclaration: - return new PositionalArgumentsDeclaration(variant as RuleNode); - case RuleKind.NamedArgumentsDeclaration: - return new NamedArgumentsDeclaration(variant as RuleNode); + case NonTerminalKind.PositionalArgumentsDeclaration: + return new PositionalArgumentsDeclaration(variant as NonTerminalNode); + case NonTerminalKind.NamedArgumentsDeclaration: + return new NamedArgumentsDeclaration(variant as NonTerminalNode); default: assert.fail(`Unexpected variant: ${variant.kind}`); } }); - public constructor(public readonly cst: RuleNode) { - assertKind(this.cst.kind, RuleKind.ArgumentsDeclaration); + public constructor(public readonly cst: NonTerminalNode) { + assertKind(this.cst.kind, NonTerminalKind.ArgumentsDeclaration); } public get variant(): PositionalArgumentsDeclaration | NamedArgumentsDeclaration { @@ -4828,33 +4832,33 @@ export class ArgumentsDeclaration { } export class NumberUnit { - private readonly fetch: () => TokenNode = once(() => { + private readonly fetch: () => TerminalNode = once(() => { const variant = ast_internal.selectChoice(this.cst); switch (variant.kind) { - case TokenKind.WeiKeyword: - case TokenKind.GweiKeyword: - case TokenKind.SzaboKeyword: - case TokenKind.FinneyKeyword: - case TokenKind.EtherKeyword: - case TokenKind.SecondsKeyword: - case TokenKind.MinutesKeyword: - case TokenKind.HoursKeyword: - case TokenKind.DaysKeyword: - case TokenKind.WeeksKeyword: - case TokenKind.YearsKeyword: - return variant as TokenNode; + case TerminalKind.WeiKeyword: + case TerminalKind.GweiKeyword: + case TerminalKind.SzaboKeyword: + case TerminalKind.FinneyKeyword: + case TerminalKind.EtherKeyword: + case TerminalKind.SecondsKeyword: + case TerminalKind.MinutesKeyword: + case TerminalKind.HoursKeyword: + case TerminalKind.DaysKeyword: + case TerminalKind.WeeksKeyword: + case TerminalKind.YearsKeyword: + return variant as TerminalNode; default: assert.fail(`Unexpected variant: ${variant.kind}`); } }); - public constructor(public readonly cst: RuleNode) { - assertKind(this.cst.kind, RuleKind.NumberUnit); + public constructor(public readonly cst: NonTerminalNode) { + assertKind(this.cst.kind, NonTerminalKind.NumberUnit); } - public get variant(): TokenNode { + public get variant(): TerminalNode { return this.fetch(); } } @@ -4869,24 +4873,24 @@ export class StringExpression { const variant = ast_internal.selectChoice(this.cst); switch (variant.kind) { - case RuleKind.StringLiteral: - return new StringLiteral(variant as RuleNode); - case RuleKind.StringLiterals: - return new StringLiterals(variant as RuleNode); - case RuleKind.HexStringLiteral: - return new HexStringLiteral(variant as RuleNode); - case RuleKind.HexStringLiterals: - return new HexStringLiterals(variant as RuleNode); - case RuleKind.UnicodeStringLiterals: - return new UnicodeStringLiterals(variant as RuleNode); + case NonTerminalKind.StringLiteral: + return new StringLiteral(variant as NonTerminalNode); + case NonTerminalKind.StringLiterals: + return new StringLiterals(variant as NonTerminalNode); + case NonTerminalKind.HexStringLiteral: + return new HexStringLiteral(variant as NonTerminalNode); + case NonTerminalKind.HexStringLiterals: + return new HexStringLiterals(variant as NonTerminalNode); + case NonTerminalKind.UnicodeStringLiterals: + return new UnicodeStringLiterals(variant as NonTerminalNode); default: assert.fail(`Unexpected variant: ${variant.kind}`); } }); - public constructor(public readonly cst: RuleNode) { - assertKind(this.cst.kind, RuleKind.StringExpression); + public constructor(public readonly cst: NonTerminalNode) { + assertKind(this.cst.kind, NonTerminalKind.StringExpression); } public get variant(): StringLiteral | StringLiterals | HexStringLiteral | HexStringLiterals | UnicodeStringLiterals { @@ -4895,70 +4899,70 @@ export class StringExpression { } export class StringLiteral { - private readonly fetch: () => TokenNode = once(() => { + private readonly fetch: () => TerminalNode = once(() => { const variant = ast_internal.selectChoice(this.cst); switch (variant.kind) { - case TokenKind.SingleQuotedStringLiteral: - case TokenKind.DoubleQuotedStringLiteral: - return variant as TokenNode; + case TerminalKind.SingleQuotedStringLiteral: + case TerminalKind.DoubleQuotedStringLiteral: + return variant as TerminalNode; default: assert.fail(`Unexpected variant: ${variant.kind}`); } }); - public constructor(public readonly cst: RuleNode) { - assertKind(this.cst.kind, RuleKind.StringLiteral); + public constructor(public readonly cst: NonTerminalNode) { + assertKind(this.cst.kind, NonTerminalKind.StringLiteral); } - public get variant(): TokenNode { + public get variant(): TerminalNode { return this.fetch(); } } export class HexStringLiteral { - private readonly fetch: () => TokenNode = once(() => { + private readonly fetch: () => TerminalNode = once(() => { const variant = ast_internal.selectChoice(this.cst); switch (variant.kind) { - case TokenKind.SingleQuotedHexStringLiteral: - case TokenKind.DoubleQuotedHexStringLiteral: - return variant as TokenNode; + case TerminalKind.SingleQuotedHexStringLiteral: + case TerminalKind.DoubleQuotedHexStringLiteral: + return variant as TerminalNode; default: assert.fail(`Unexpected variant: ${variant.kind}`); } }); - public constructor(public readonly cst: RuleNode) { - assertKind(this.cst.kind, RuleKind.HexStringLiteral); + public constructor(public readonly cst: NonTerminalNode) { + assertKind(this.cst.kind, NonTerminalKind.HexStringLiteral); } - public get variant(): TokenNode { + public get variant(): TerminalNode { return this.fetch(); } } export class UnicodeStringLiteral { - private readonly fetch: () => TokenNode = once(() => { + private readonly fetch: () => TerminalNode = once(() => { const variant = ast_internal.selectChoice(this.cst); switch (variant.kind) { - case TokenKind.SingleQuotedUnicodeStringLiteral: - case TokenKind.DoubleQuotedUnicodeStringLiteral: - return variant as TokenNode; + case TerminalKind.SingleQuotedUnicodeStringLiteral: + case TerminalKind.DoubleQuotedUnicodeStringLiteral: + return variant as TerminalNode; default: assert.fail(`Unexpected variant: ${variant.kind}`); } }); - public constructor(public readonly cst: RuleNode) { - assertKind(this.cst.kind, RuleKind.UnicodeStringLiteral); + public constructor(public readonly cst: NonTerminalNode) { + assertKind(this.cst.kind, NonTerminalKind.UnicodeStringLiteral); } - public get variant(): TokenNode { + public get variant(): TerminalNode { return this.fetch(); } } @@ -4980,38 +4984,38 @@ export class YulStatement { const variant = ast_internal.selectChoice(this.cst); switch (variant.kind) { - case RuleKind.YulBlock: - return new YulBlock(variant as RuleNode); - case RuleKind.YulFunctionDefinition: - return new YulFunctionDefinition(variant as RuleNode); - case RuleKind.YulVariableDeclarationStatement: - return new YulVariableDeclarationStatement(variant as RuleNode); - case RuleKind.YulAssignmentStatement: - return new YulAssignmentStatement(variant as RuleNode); - case RuleKind.YulIfStatement: - return new YulIfStatement(variant as RuleNode); - case RuleKind.YulForStatement: - return new YulForStatement(variant as RuleNode); - case RuleKind.YulSwitchStatement: - return new YulSwitchStatement(variant as RuleNode); - case RuleKind.YulLeaveStatement: - return new YulLeaveStatement(variant as RuleNode); - case RuleKind.YulBreakStatement: - return new YulBreakStatement(variant as RuleNode); - case RuleKind.YulContinueStatement: - return new YulContinueStatement(variant as RuleNode); - case RuleKind.YulLabel: - return new YulLabel(variant as RuleNode); - case RuleKind.YulExpression: - return new YulExpression(variant as RuleNode); + case NonTerminalKind.YulBlock: + return new YulBlock(variant as NonTerminalNode); + case NonTerminalKind.YulFunctionDefinition: + return new YulFunctionDefinition(variant as NonTerminalNode); + case NonTerminalKind.YulVariableDeclarationStatement: + return new YulVariableDeclarationStatement(variant as NonTerminalNode); + case NonTerminalKind.YulAssignmentStatement: + return new YulAssignmentStatement(variant as NonTerminalNode); + case NonTerminalKind.YulIfStatement: + return new YulIfStatement(variant as NonTerminalNode); + case NonTerminalKind.YulForStatement: + return new YulForStatement(variant as NonTerminalNode); + case NonTerminalKind.YulSwitchStatement: + return new YulSwitchStatement(variant as NonTerminalNode); + case NonTerminalKind.YulLeaveStatement: + return new YulLeaveStatement(variant as NonTerminalNode); + case NonTerminalKind.YulBreakStatement: + return new YulBreakStatement(variant as NonTerminalNode); + case NonTerminalKind.YulContinueStatement: + return new YulContinueStatement(variant as NonTerminalNode); + case NonTerminalKind.YulLabel: + return new YulLabel(variant as NonTerminalNode); + case NonTerminalKind.YulExpression: + return new YulExpression(variant as NonTerminalNode); default: assert.fail(`Unexpected variant: ${variant.kind}`); } }); - public constructor(public readonly cst: RuleNode) { - assertKind(this.cst.kind, RuleKind.YulStatement); + public constructor(public readonly cst: NonTerminalNode) { + assertKind(this.cst.kind, NonTerminalKind.YulStatement); } public get variant(): @@ -5032,26 +5036,26 @@ export class YulStatement { } export class YulAssignmentOperator { - private readonly fetch: () => YulColonAndEqual | TokenNode = once(() => { + private readonly fetch: () => YulColonAndEqual | TerminalNode = once(() => { const variant = ast_internal.selectChoice(this.cst); switch (variant.kind) { - case RuleKind.YulColonAndEqual: - return new YulColonAndEqual(variant as RuleNode); + case NonTerminalKind.YulColonAndEqual: + return new YulColonAndEqual(variant as NonTerminalNode); - case TokenKind.ColonEqual: - return variant as TokenNode; + case TerminalKind.ColonEqual: + return variant as TerminalNode; default: assert.fail(`Unexpected variant: ${variant.kind}`); } }); - public constructor(public readonly cst: RuleNode) { - assertKind(this.cst.kind, RuleKind.YulAssignmentOperator); + public constructor(public readonly cst: NonTerminalNode) { + assertKind(this.cst.kind, NonTerminalKind.YulAssignmentOperator); } - public get variant(): YulColonAndEqual | TokenNode { + public get variant(): YulColonAndEqual | TerminalNode { return this.fetch(); } } @@ -5061,18 +5065,18 @@ export class YulSwitchCase { const variant = ast_internal.selectChoice(this.cst); switch (variant.kind) { - case RuleKind.YulDefaultCase: - return new YulDefaultCase(variant as RuleNode); - case RuleKind.YulValueCase: - return new YulValueCase(variant as RuleNode); + case NonTerminalKind.YulDefaultCase: + return new YulDefaultCase(variant as NonTerminalNode); + case NonTerminalKind.YulValueCase: + return new YulValueCase(variant as NonTerminalNode); default: assert.fail(`Unexpected variant: ${variant.kind}`); } }); - public constructor(public readonly cst: RuleNode) { - assertKind(this.cst.kind, RuleKind.YulSwitchCase); + public constructor(public readonly cst: NonTerminalNode) { + assertKind(this.cst.kind, NonTerminalKind.YulSwitchCase); } public get variant(): YulDefaultCase | YulValueCase { @@ -5085,22 +5089,22 @@ export class YulExpression { const variant = ast_internal.selectChoice(this.cst); switch (variant.kind) { - case RuleKind.YulFunctionCallExpression: - return new YulFunctionCallExpression(variant as RuleNode); - case RuleKind.YulLiteral: - return new YulLiteral(variant as RuleNode); - case RuleKind.YulBuiltInFunction: - return new YulBuiltInFunction(variant as RuleNode); - case RuleKind.YulPath: - return new YulPath(variant as RuleNode); + case NonTerminalKind.YulFunctionCallExpression: + return new YulFunctionCallExpression(variant as NonTerminalNode); + case NonTerminalKind.YulLiteral: + return new YulLiteral(variant as NonTerminalNode); + case NonTerminalKind.YulBuiltInFunction: + return new YulBuiltInFunction(variant as NonTerminalNode); + case NonTerminalKind.YulPath: + return new YulPath(variant as NonTerminalNode); default: assert.fail(`Unexpected variant: ${variant.kind}`); } }); - public constructor(public readonly cst: RuleNode) { - assertKind(this.cst.kind, RuleKind.YulExpression); + public constructor(public readonly cst: NonTerminalNode) { + assertKind(this.cst.kind, NonTerminalKind.YulExpression); } public get variant(): YulFunctionCallExpression | YulLiteral | YulBuiltInFunction | YulPath { @@ -5109,156 +5113,156 @@ export class YulExpression { } export class YulPathComponent { - private readonly fetch: () => TokenNode = once(() => { + private readonly fetch: () => TerminalNode = once(() => { const variant = ast_internal.selectChoice(this.cst); switch (variant.kind) { - case TokenKind.YulIdentifier: - case TokenKind.YulAddressKeyword: - return variant as TokenNode; + case TerminalKind.YulIdentifier: + case TerminalKind.YulAddressKeyword: + return variant as TerminalNode; default: assert.fail(`Unexpected variant: ${variant.kind}`); } }); - public constructor(public readonly cst: RuleNode) { - assertKind(this.cst.kind, RuleKind.YulPathComponent); + public constructor(public readonly cst: NonTerminalNode) { + assertKind(this.cst.kind, NonTerminalKind.YulPathComponent); } - public get variant(): TokenNode { + public get variant(): TerminalNode { return this.fetch(); } } export class YulBuiltInFunction { - private readonly fetch: () => TokenNode = once(() => { + private readonly fetch: () => TerminalNode = once(() => { const variant = ast_internal.selectChoice(this.cst); switch (variant.kind) { - case TokenKind.YulAddKeyword: - case TokenKind.YulAddModKeyword: - case TokenKind.YulAddressKeyword: - case TokenKind.YulAndKeyword: - case TokenKind.YulBalanceKeyword: - case TokenKind.YulBlockHashKeyword: - case TokenKind.YulByteKeyword: - case TokenKind.YulCallCodeKeyword: - case TokenKind.YulCallDataCopyKeyword: - case TokenKind.YulCallDataLoadKeyword: - case TokenKind.YulCallDataSizeKeyword: - case TokenKind.YulCallerKeyword: - case TokenKind.YulCallKeyword: - case TokenKind.YulCallValueKeyword: - case TokenKind.YulCoinBaseKeyword: - case TokenKind.YulCreateKeyword: - case TokenKind.YulDelegateCallKeyword: - case TokenKind.YulDivKeyword: - case TokenKind.YulEqKeyword: - case TokenKind.YulExpKeyword: - case TokenKind.YulExtCodeCopyKeyword: - case TokenKind.YulExtCodeSizeKeyword: - case TokenKind.YulGasKeyword: - case TokenKind.YulGasLimitKeyword: - case TokenKind.YulGasPriceKeyword: - case TokenKind.YulGtKeyword: - case TokenKind.YulInvalidKeyword: - case TokenKind.YulIsZeroKeyword: - case TokenKind.YulLog0Keyword: - case TokenKind.YulLog1Keyword: - case TokenKind.YulLog2Keyword: - case TokenKind.YulLog3Keyword: - case TokenKind.YulLog4Keyword: - case TokenKind.YulLtKeyword: - case TokenKind.YulMLoadKeyword: - case TokenKind.YulModKeyword: - case TokenKind.YulMSizeKeyword: - case TokenKind.YulMStore8Keyword: - case TokenKind.YulMStoreKeyword: - case TokenKind.YulMulKeyword: - case TokenKind.YulMulModKeyword: - case TokenKind.YulNotKeyword: - case TokenKind.YulNumberKeyword: - case TokenKind.YulOriginKeyword: - case TokenKind.YulOrKeyword: - case TokenKind.YulPopKeyword: - case TokenKind.YulReturnKeyword: - case TokenKind.YulRevertKeyword: - case TokenKind.YulSDivKeyword: - case TokenKind.YulSelfDestructKeyword: - case TokenKind.YulSgtKeyword: - case TokenKind.YulSignExtendKeyword: - case TokenKind.YulSLoadKeyword: - case TokenKind.YulSltKeyword: - case TokenKind.YulSModKeyword: - case TokenKind.YulSStoreKeyword: - case TokenKind.YulStopKeyword: - case TokenKind.YulSubKeyword: - case TokenKind.YulTimestampKeyword: - case TokenKind.YulXorKeyword: - case TokenKind.YulKeccak256Keyword: - case TokenKind.YulSha3Keyword: - case TokenKind.YulSuicideKeyword: - case TokenKind.YulReturnDataCopyKeyword: - case TokenKind.YulReturnDataSizeKeyword: - case TokenKind.YulStaticCallKeyword: - case TokenKind.YulCreate2Keyword: - case TokenKind.YulExtCodeHashKeyword: - case TokenKind.YulSarKeyword: - case TokenKind.YulShlKeyword: - case TokenKind.YulShrKeyword: - case TokenKind.YulChainIdKeyword: - case TokenKind.YulSelfBalanceKeyword: - case TokenKind.YulBaseFeeKeyword: - case TokenKind.YulDifficultyKeyword: - case TokenKind.YulPrevRandaoKeyword: - case TokenKind.YulBlobBaseFeeKeyword: - case TokenKind.YulBlobHashKeyword: - case TokenKind.YulTLoadKeyword: - case TokenKind.YulTStoreKeyword: - case TokenKind.YulMCopyKeyword: - return variant as TokenNode; + case TerminalKind.YulAddKeyword: + case TerminalKind.YulAddModKeyword: + case TerminalKind.YulAddressKeyword: + case TerminalKind.YulAndKeyword: + case TerminalKind.YulBalanceKeyword: + case TerminalKind.YulBlockHashKeyword: + case TerminalKind.YulByteKeyword: + case TerminalKind.YulCallCodeKeyword: + case TerminalKind.YulCallDataCopyKeyword: + case TerminalKind.YulCallDataLoadKeyword: + case TerminalKind.YulCallDataSizeKeyword: + case TerminalKind.YulCallerKeyword: + case TerminalKind.YulCallKeyword: + case TerminalKind.YulCallValueKeyword: + case TerminalKind.YulCoinBaseKeyword: + case TerminalKind.YulCreateKeyword: + case TerminalKind.YulDelegateCallKeyword: + case TerminalKind.YulDivKeyword: + case TerminalKind.YulEqKeyword: + case TerminalKind.YulExpKeyword: + case TerminalKind.YulExtCodeCopyKeyword: + case TerminalKind.YulExtCodeSizeKeyword: + case TerminalKind.YulGasKeyword: + case TerminalKind.YulGasLimitKeyword: + case TerminalKind.YulGasPriceKeyword: + case TerminalKind.YulGtKeyword: + case TerminalKind.YulInvalidKeyword: + case TerminalKind.YulIsZeroKeyword: + case TerminalKind.YulLog0Keyword: + case TerminalKind.YulLog1Keyword: + case TerminalKind.YulLog2Keyword: + case TerminalKind.YulLog3Keyword: + case TerminalKind.YulLog4Keyword: + case TerminalKind.YulLtKeyword: + case TerminalKind.YulMLoadKeyword: + case TerminalKind.YulModKeyword: + case TerminalKind.YulMSizeKeyword: + case TerminalKind.YulMStore8Keyword: + case TerminalKind.YulMStoreKeyword: + case TerminalKind.YulMulKeyword: + case TerminalKind.YulMulModKeyword: + case TerminalKind.YulNotKeyword: + case TerminalKind.YulNumberKeyword: + case TerminalKind.YulOriginKeyword: + case TerminalKind.YulOrKeyword: + case TerminalKind.YulPopKeyword: + case TerminalKind.YulReturnKeyword: + case TerminalKind.YulRevertKeyword: + case TerminalKind.YulSDivKeyword: + case TerminalKind.YulSelfDestructKeyword: + case TerminalKind.YulSgtKeyword: + case TerminalKind.YulSignExtendKeyword: + case TerminalKind.YulSLoadKeyword: + case TerminalKind.YulSltKeyword: + case TerminalKind.YulSModKeyword: + case TerminalKind.YulSStoreKeyword: + case TerminalKind.YulStopKeyword: + case TerminalKind.YulSubKeyword: + case TerminalKind.YulTimestampKeyword: + case TerminalKind.YulXorKeyword: + case TerminalKind.YulKeccak256Keyword: + case TerminalKind.YulSha3Keyword: + case TerminalKind.YulSuicideKeyword: + case TerminalKind.YulReturnDataCopyKeyword: + case TerminalKind.YulReturnDataSizeKeyword: + case TerminalKind.YulStaticCallKeyword: + case TerminalKind.YulCreate2Keyword: + case TerminalKind.YulExtCodeHashKeyword: + case TerminalKind.YulSarKeyword: + case TerminalKind.YulShlKeyword: + case TerminalKind.YulShrKeyword: + case TerminalKind.YulChainIdKeyword: + case TerminalKind.YulSelfBalanceKeyword: + case TerminalKind.YulBaseFeeKeyword: + case TerminalKind.YulDifficultyKeyword: + case TerminalKind.YulPrevRandaoKeyword: + case TerminalKind.YulBlobBaseFeeKeyword: + case TerminalKind.YulBlobHashKeyword: + case TerminalKind.YulTLoadKeyword: + case TerminalKind.YulTStoreKeyword: + case TerminalKind.YulMCopyKeyword: + return variant as TerminalNode; default: assert.fail(`Unexpected variant: ${variant.kind}`); } }); - public constructor(public readonly cst: RuleNode) { - assertKind(this.cst.kind, RuleKind.YulBuiltInFunction); + public constructor(public readonly cst: NonTerminalNode) { + assertKind(this.cst.kind, NonTerminalKind.YulBuiltInFunction); } - public get variant(): TokenNode { + public get variant(): TerminalNode { return this.fetch(); } } export class YulLiteral { - private readonly fetch: () => HexStringLiteral | StringLiteral | TokenNode = once(() => { + private readonly fetch: () => HexStringLiteral | StringLiteral | TerminalNode = once(() => { const variant = ast_internal.selectChoice(this.cst); switch (variant.kind) { - case RuleKind.HexStringLiteral: - return new HexStringLiteral(variant as RuleNode); - case RuleKind.StringLiteral: - return new StringLiteral(variant as RuleNode); + case NonTerminalKind.HexStringLiteral: + return new HexStringLiteral(variant as NonTerminalNode); + case NonTerminalKind.StringLiteral: + return new StringLiteral(variant as NonTerminalNode); - case TokenKind.YulTrueKeyword: - case TokenKind.YulFalseKeyword: - case TokenKind.YulDecimalLiteral: - case TokenKind.YulHexLiteral: - return variant as TokenNode; + case TerminalKind.YulTrueKeyword: + case TerminalKind.YulFalseKeyword: + case TerminalKind.YulDecimalLiteral: + case TerminalKind.YulHexLiteral: + return variant as TerminalNode; default: assert.fail(`Unexpected variant: ${variant.kind}`); } }); - public constructor(public readonly cst: RuleNode) { - assertKind(this.cst.kind, RuleKind.YulLiteral); + public constructor(public readonly cst: NonTerminalNode) { + assertKind(this.cst.kind, NonTerminalKind.YulLiteral); } - public get variant(): HexStringLiteral | StringLiteral | TokenNode { + public get variant(): HexStringLiteral | StringLiteral | TerminalNode { return this.fetch(); } } @@ -5270,11 +5274,11 @@ export class YulLiteral { export class SourceUnitMembers { private readonly fetch = once(() => { const items = ast_internal.selectRepeated(this.cst); - return items.map((item) => new SourceUnitMember(item as RuleNode)); + return items.map((item) => new SourceUnitMember(item as NonTerminalNode)); }); - public constructor(public readonly cst: RuleNode) { - assertKind(this.cst.kind, RuleKind.SourceUnitMembers); + public constructor(public readonly cst: NonTerminalNode) { + assertKind(this.cst.kind, NonTerminalKind.SourceUnitMembers); } public get items(): readonly SourceUnitMember[] { @@ -5285,11 +5289,11 @@ export class SourceUnitMembers { export class VersionExpressionSet { private readonly fetch = once(() => { const items = ast_internal.selectRepeated(this.cst); - return items.map((item) => new VersionExpression(item as RuleNode)); + return items.map((item) => new VersionExpression(item as NonTerminalNode)); }); - public constructor(public readonly cst: RuleNode) { - assertKind(this.cst.kind, RuleKind.VersionExpressionSet); + public constructor(public readonly cst: NonTerminalNode) { + assertKind(this.cst.kind, NonTerminalKind.VersionExpressionSet); } public get items(): readonly VersionExpression[] { @@ -5300,11 +5304,11 @@ export class VersionExpressionSet { export class ContractMembers { private readonly fetch = once(() => { const items = ast_internal.selectRepeated(this.cst); - return items.map((item) => new ContractMember(item as RuleNode)); + return items.map((item) => new ContractMember(item as NonTerminalNode)); }); - public constructor(public readonly cst: RuleNode) { - assertKind(this.cst.kind, RuleKind.ContractMembers); + public constructor(public readonly cst: NonTerminalNode) { + assertKind(this.cst.kind, NonTerminalKind.ContractMembers); } public get items(): readonly ContractMember[] { @@ -5315,11 +5319,11 @@ export class ContractMembers { export class InterfaceMembers { private readonly fetch = once(() => { const items = ast_internal.selectRepeated(this.cst); - return items.map((item) => new ContractMember(item as RuleNode)); + return items.map((item) => new ContractMember(item as NonTerminalNode)); }); - public constructor(public readonly cst: RuleNode) { - assertKind(this.cst.kind, RuleKind.InterfaceMembers); + public constructor(public readonly cst: NonTerminalNode) { + assertKind(this.cst.kind, NonTerminalKind.InterfaceMembers); } public get items(): readonly ContractMember[] { @@ -5330,11 +5334,11 @@ export class InterfaceMembers { export class LibraryMembers { private readonly fetch = once(() => { const items = ast_internal.selectRepeated(this.cst); - return items.map((item) => new ContractMember(item as RuleNode)); + return items.map((item) => new ContractMember(item as NonTerminalNode)); }); - public constructor(public readonly cst: RuleNode) { - assertKind(this.cst.kind, RuleKind.LibraryMembers); + public constructor(public readonly cst: NonTerminalNode) { + assertKind(this.cst.kind, NonTerminalKind.LibraryMembers); } public get items(): readonly ContractMember[] { @@ -5345,11 +5349,11 @@ export class LibraryMembers { export class StructMembers { private readonly fetch = once(() => { const items = ast_internal.selectRepeated(this.cst); - return items.map((item) => new StructMember(item as RuleNode)); + return items.map((item) => new StructMember(item as NonTerminalNode)); }); - public constructor(public readonly cst: RuleNode) { - assertKind(this.cst.kind, RuleKind.StructMembers); + public constructor(public readonly cst: NonTerminalNode) { + assertKind(this.cst.kind, NonTerminalKind.StructMembers); } public get items(): readonly StructMember[] { @@ -5360,11 +5364,11 @@ export class StructMembers { export class StateVariableAttributes { private readonly fetch = once(() => { const items = ast_internal.selectRepeated(this.cst); - return items.map((item) => new StateVariableAttribute(item as RuleNode)); + return items.map((item) => new StateVariableAttribute(item as NonTerminalNode)); }); - public constructor(public readonly cst: RuleNode) { - assertKind(this.cst.kind, RuleKind.StateVariableAttributes); + public constructor(public readonly cst: NonTerminalNode) { + assertKind(this.cst.kind, NonTerminalKind.StateVariableAttributes); } public get items(): readonly StateVariableAttribute[] { @@ -5375,11 +5379,11 @@ export class StateVariableAttributes { export class FunctionAttributes { private readonly fetch = once(() => { const items = ast_internal.selectRepeated(this.cst); - return items.map((item) => new FunctionAttribute(item as RuleNode)); + return items.map((item) => new FunctionAttribute(item as NonTerminalNode)); }); - public constructor(public readonly cst: RuleNode) { - assertKind(this.cst.kind, RuleKind.FunctionAttributes); + public constructor(public readonly cst: NonTerminalNode) { + assertKind(this.cst.kind, NonTerminalKind.FunctionAttributes); } public get items(): readonly FunctionAttribute[] { @@ -5390,11 +5394,11 @@ export class FunctionAttributes { export class ConstructorAttributes { private readonly fetch = once(() => { const items = ast_internal.selectRepeated(this.cst); - return items.map((item) => new ConstructorAttribute(item as RuleNode)); + return items.map((item) => new ConstructorAttribute(item as NonTerminalNode)); }); - public constructor(public readonly cst: RuleNode) { - assertKind(this.cst.kind, RuleKind.ConstructorAttributes); + public constructor(public readonly cst: NonTerminalNode) { + assertKind(this.cst.kind, NonTerminalKind.ConstructorAttributes); } public get items(): readonly ConstructorAttribute[] { @@ -5405,11 +5409,11 @@ export class ConstructorAttributes { export class UnnamedFunctionAttributes { private readonly fetch = once(() => { const items = ast_internal.selectRepeated(this.cst); - return items.map((item) => new UnnamedFunctionAttribute(item as RuleNode)); + return items.map((item) => new UnnamedFunctionAttribute(item as NonTerminalNode)); }); - public constructor(public readonly cst: RuleNode) { - assertKind(this.cst.kind, RuleKind.UnnamedFunctionAttributes); + public constructor(public readonly cst: NonTerminalNode) { + assertKind(this.cst.kind, NonTerminalKind.UnnamedFunctionAttributes); } public get items(): readonly UnnamedFunctionAttribute[] { @@ -5420,11 +5424,11 @@ export class UnnamedFunctionAttributes { export class FallbackFunctionAttributes { private readonly fetch = once(() => { const items = ast_internal.selectRepeated(this.cst); - return items.map((item) => new FallbackFunctionAttribute(item as RuleNode)); + return items.map((item) => new FallbackFunctionAttribute(item as NonTerminalNode)); }); - public constructor(public readonly cst: RuleNode) { - assertKind(this.cst.kind, RuleKind.FallbackFunctionAttributes); + public constructor(public readonly cst: NonTerminalNode) { + assertKind(this.cst.kind, NonTerminalKind.FallbackFunctionAttributes); } public get items(): readonly FallbackFunctionAttribute[] { @@ -5435,11 +5439,11 @@ export class FallbackFunctionAttributes { export class ReceiveFunctionAttributes { private readonly fetch = once(() => { const items = ast_internal.selectRepeated(this.cst); - return items.map((item) => new ReceiveFunctionAttribute(item as RuleNode)); + return items.map((item) => new ReceiveFunctionAttribute(item as NonTerminalNode)); }); - public constructor(public readonly cst: RuleNode) { - assertKind(this.cst.kind, RuleKind.ReceiveFunctionAttributes); + public constructor(public readonly cst: NonTerminalNode) { + assertKind(this.cst.kind, NonTerminalKind.ReceiveFunctionAttributes); } public get items(): readonly ReceiveFunctionAttribute[] { @@ -5450,11 +5454,11 @@ export class ReceiveFunctionAttributes { export class ModifierAttributes { private readonly fetch = once(() => { const items = ast_internal.selectRepeated(this.cst); - return items.map((item) => new ModifierAttribute(item as RuleNode)); + return items.map((item) => new ModifierAttribute(item as NonTerminalNode)); }); - public constructor(public readonly cst: RuleNode) { - assertKind(this.cst.kind, RuleKind.ModifierAttributes); + public constructor(public readonly cst: NonTerminalNode) { + assertKind(this.cst.kind, NonTerminalKind.ModifierAttributes); } public get items(): readonly ModifierAttribute[] { @@ -5465,11 +5469,11 @@ export class ModifierAttributes { export class FunctionTypeAttributes { private readonly fetch = once(() => { const items = ast_internal.selectRepeated(this.cst); - return items.map((item) => new FunctionTypeAttribute(item as RuleNode)); + return items.map((item) => new FunctionTypeAttribute(item as NonTerminalNode)); }); - public constructor(public readonly cst: RuleNode) { - assertKind(this.cst.kind, RuleKind.FunctionTypeAttributes); + public constructor(public readonly cst: NonTerminalNode) { + assertKind(this.cst.kind, NonTerminalKind.FunctionTypeAttributes); } public get items(): readonly FunctionTypeAttribute[] { @@ -5480,11 +5484,11 @@ export class FunctionTypeAttributes { export class Statements { private readonly fetch = once(() => { const items = ast_internal.selectRepeated(this.cst); - return items.map((item) => new Statement(item as RuleNode)); + return items.map((item) => new Statement(item as NonTerminalNode)); }); - public constructor(public readonly cst: RuleNode) { - assertKind(this.cst.kind, RuleKind.Statements); + public constructor(public readonly cst: NonTerminalNode) { + assertKind(this.cst.kind, NonTerminalKind.Statements); } public get items(): readonly Statement[] { @@ -5495,11 +5499,11 @@ export class Statements { export class CatchClauses { private readonly fetch = once(() => { const items = ast_internal.selectRepeated(this.cst); - return items.map((item) => new CatchClause(item as RuleNode)); + return items.map((item) => new CatchClause(item as NonTerminalNode)); }); - public constructor(public readonly cst: RuleNode) { - assertKind(this.cst.kind, RuleKind.CatchClauses); + public constructor(public readonly cst: NonTerminalNode) { + assertKind(this.cst.kind, NonTerminalKind.CatchClauses); } public get items(): readonly CatchClause[] { @@ -5510,11 +5514,11 @@ export class CatchClauses { export class StringLiterals { private readonly fetch = once(() => { const items = ast_internal.selectRepeated(this.cst); - return items.map((item) => new StringLiteral(item as RuleNode)); + return items.map((item) => new StringLiteral(item as NonTerminalNode)); }); - public constructor(public readonly cst: RuleNode) { - assertKind(this.cst.kind, RuleKind.StringLiterals); + public constructor(public readonly cst: NonTerminalNode) { + assertKind(this.cst.kind, NonTerminalKind.StringLiterals); } public get items(): readonly StringLiteral[] { @@ -5525,11 +5529,11 @@ export class StringLiterals { export class HexStringLiterals { private readonly fetch = once(() => { const items = ast_internal.selectRepeated(this.cst); - return items.map((item) => new HexStringLiteral(item as RuleNode)); + return items.map((item) => new HexStringLiteral(item as NonTerminalNode)); }); - public constructor(public readonly cst: RuleNode) { - assertKind(this.cst.kind, RuleKind.HexStringLiterals); + public constructor(public readonly cst: NonTerminalNode) { + assertKind(this.cst.kind, NonTerminalKind.HexStringLiterals); } public get items(): readonly HexStringLiteral[] { @@ -5540,11 +5544,11 @@ export class HexStringLiterals { export class UnicodeStringLiterals { private readonly fetch = once(() => { const items = ast_internal.selectRepeated(this.cst); - return items.map((item) => new UnicodeStringLiteral(item as RuleNode)); + return items.map((item) => new UnicodeStringLiteral(item as NonTerminalNode)); }); - public constructor(public readonly cst: RuleNode) { - assertKind(this.cst.kind, RuleKind.UnicodeStringLiterals); + public constructor(public readonly cst: NonTerminalNode) { + assertKind(this.cst.kind, NonTerminalKind.UnicodeStringLiterals); } public get items(): readonly UnicodeStringLiteral[] { @@ -5555,11 +5559,11 @@ export class UnicodeStringLiterals { export class YulStatements { private readonly fetch = once(() => { const items = ast_internal.selectRepeated(this.cst); - return items.map((item) => new YulStatement(item as RuleNode)); + return items.map((item) => new YulStatement(item as NonTerminalNode)); }); - public constructor(public readonly cst: RuleNode) { - assertKind(this.cst.kind, RuleKind.YulStatements); + public constructor(public readonly cst: NonTerminalNode) { + assertKind(this.cst.kind, NonTerminalKind.YulStatements); } public get items(): readonly YulStatement[] { @@ -5570,11 +5574,11 @@ export class YulStatements { export class YulSwitchCases { private readonly fetch = once(() => { const items = ast_internal.selectRepeated(this.cst); - return items.map((item) => new YulSwitchCase(item as RuleNode)); + return items.map((item) => new YulSwitchCase(item as NonTerminalNode)); }); - public constructor(public readonly cst: RuleNode) { - assertKind(this.cst.kind, RuleKind.YulSwitchCases); + public constructor(public readonly cst: NonTerminalNode) { + assertKind(this.cst.kind, NonTerminalKind.YulSwitchCases); } public get items(): readonly YulSwitchCase[] { @@ -5591,20 +5595,20 @@ export class VersionExpressionSets { const [items, separators] = ast_internal.selectSeparated(this.cst); return { - items: items.map((item) => new VersionExpressionSet(item as RuleNode)), - separators: separators as TokenNode[], + items: items.map((item) => new VersionExpressionSet(item as NonTerminalNode)), + separators: separators as TerminalNode[], }; }); - public constructor(public readonly cst: RuleNode) { - assertKind(this.cst.kind, RuleKind.VersionExpressionSets); + public constructor(public readonly cst: NonTerminalNode) { + assertKind(this.cst.kind, NonTerminalKind.VersionExpressionSets); } public get items(): readonly VersionExpressionSet[] { return this.fetch().items; } - public get separators(): readonly TokenNode[] { + public get separators(): readonly TerminalNode[] { return this.fetch().separators; } } @@ -5613,18 +5617,18 @@ export class VersionSpecifiers { private readonly fetch = once(() => { const [items, separators] = ast_internal.selectSeparated(this.cst); - return { items: items as TokenNode[], separators: separators as TokenNode[] }; + return { items: items as TerminalNode[], separators: separators as TerminalNode[] }; }); - public constructor(public readonly cst: RuleNode) { - assertKind(this.cst.kind, RuleKind.VersionSpecifiers); + public constructor(public readonly cst: NonTerminalNode) { + assertKind(this.cst.kind, NonTerminalKind.VersionSpecifiers); } - public get items(): readonly TokenNode[] { + public get items(): readonly TerminalNode[] { return this.fetch().items; } - public get separators(): readonly TokenNode[] { + public get separators(): readonly TerminalNode[] { return this.fetch().separators; } } @@ -5634,20 +5638,20 @@ export class ImportDeconstructionSymbols { const [items, separators] = ast_internal.selectSeparated(this.cst); return { - items: items.map((item) => new ImportDeconstructionSymbol(item as RuleNode)), - separators: separators as TokenNode[], + items: items.map((item) => new ImportDeconstructionSymbol(item as NonTerminalNode)), + separators: separators as TerminalNode[], }; }); - public constructor(public readonly cst: RuleNode) { - assertKind(this.cst.kind, RuleKind.ImportDeconstructionSymbols); + public constructor(public readonly cst: NonTerminalNode) { + assertKind(this.cst.kind, NonTerminalKind.ImportDeconstructionSymbols); } public get items(): readonly ImportDeconstructionSymbol[] { return this.fetch().items; } - public get separators(): readonly TokenNode[] { + public get separators(): readonly TerminalNode[] { return this.fetch().separators; } } @@ -5657,20 +5661,20 @@ export class UsingDeconstructionSymbols { const [items, separators] = ast_internal.selectSeparated(this.cst); return { - items: items.map((item) => new UsingDeconstructionSymbol(item as RuleNode)), - separators: separators as TokenNode[], + items: items.map((item) => new UsingDeconstructionSymbol(item as NonTerminalNode)), + separators: separators as TerminalNode[], }; }); - public constructor(public readonly cst: RuleNode) { - assertKind(this.cst.kind, RuleKind.UsingDeconstructionSymbols); + public constructor(public readonly cst: NonTerminalNode) { + assertKind(this.cst.kind, NonTerminalKind.UsingDeconstructionSymbols); } public get items(): readonly UsingDeconstructionSymbol[] { return this.fetch().items; } - public get separators(): readonly TokenNode[] { + public get separators(): readonly TerminalNode[] { return this.fetch().separators; } } @@ -5679,18 +5683,21 @@ export class InheritanceTypes { private readonly fetch = once(() => { const [items, separators] = ast_internal.selectSeparated(this.cst); - return { items: items.map((item) => new InheritanceType(item as RuleNode)), separators: separators as TokenNode[] }; + return { + items: items.map((item) => new InheritanceType(item as NonTerminalNode)), + separators: separators as TerminalNode[], + }; }); - public constructor(public readonly cst: RuleNode) { - assertKind(this.cst.kind, RuleKind.InheritanceTypes); + public constructor(public readonly cst: NonTerminalNode) { + assertKind(this.cst.kind, NonTerminalKind.InheritanceTypes); } public get items(): readonly InheritanceType[] { return this.fetch().items; } - public get separators(): readonly TokenNode[] { + public get separators(): readonly TerminalNode[] { return this.fetch().separators; } } @@ -5699,18 +5706,18 @@ export class EnumMembers { private readonly fetch = once(() => { const [items, separators] = ast_internal.selectSeparated(this.cst); - return { items: items as TokenNode[], separators: separators as TokenNode[] }; + return { items: items as TerminalNode[], separators: separators as TerminalNode[] }; }); - public constructor(public readonly cst: RuleNode) { - assertKind(this.cst.kind, RuleKind.EnumMembers); + public constructor(public readonly cst: NonTerminalNode) { + assertKind(this.cst.kind, NonTerminalKind.EnumMembers); } - public get items(): readonly TokenNode[] { + public get items(): readonly TerminalNode[] { return this.fetch().items; } - public get separators(): readonly TokenNode[] { + public get separators(): readonly TerminalNode[] { return this.fetch().separators; } } @@ -5719,18 +5726,21 @@ export class Parameters { private readonly fetch = once(() => { const [items, separators] = ast_internal.selectSeparated(this.cst); - return { items: items.map((item) => new Parameter(item as RuleNode)), separators: separators as TokenNode[] }; + return { + items: items.map((item) => new Parameter(item as NonTerminalNode)), + separators: separators as TerminalNode[], + }; }); - public constructor(public readonly cst: RuleNode) { - assertKind(this.cst.kind, RuleKind.Parameters); + public constructor(public readonly cst: NonTerminalNode) { + assertKind(this.cst.kind, NonTerminalKind.Parameters); } public get items(): readonly Parameter[] { return this.fetch().items; } - public get separators(): readonly TokenNode[] { + public get separators(): readonly TerminalNode[] { return this.fetch().separators; } } @@ -5739,18 +5749,21 @@ export class OverridePaths { private readonly fetch = once(() => { const [items, separators] = ast_internal.selectSeparated(this.cst); - return { items: items.map((item) => new IdentifierPath(item as RuleNode)), separators: separators as TokenNode[] }; + return { + items: items.map((item) => new IdentifierPath(item as NonTerminalNode)), + separators: separators as TerminalNode[], + }; }); - public constructor(public readonly cst: RuleNode) { - assertKind(this.cst.kind, RuleKind.OverridePaths); + public constructor(public readonly cst: NonTerminalNode) { + assertKind(this.cst.kind, NonTerminalKind.OverridePaths); } public get items(): readonly IdentifierPath[] { return this.fetch().items; } - public get separators(): readonly TokenNode[] { + public get separators(): readonly TerminalNode[] { return this.fetch().separators; } } @@ -5759,18 +5772,21 @@ export class EventParameters { private readonly fetch = once(() => { const [items, separators] = ast_internal.selectSeparated(this.cst); - return { items: items.map((item) => new EventParameter(item as RuleNode)), separators: separators as TokenNode[] }; + return { + items: items.map((item) => new EventParameter(item as NonTerminalNode)), + separators: separators as TerminalNode[], + }; }); - public constructor(public readonly cst: RuleNode) { - assertKind(this.cst.kind, RuleKind.EventParameters); + public constructor(public readonly cst: NonTerminalNode) { + assertKind(this.cst.kind, NonTerminalKind.EventParameters); } public get items(): readonly EventParameter[] { return this.fetch().items; } - public get separators(): readonly TokenNode[] { + public get separators(): readonly TerminalNode[] { return this.fetch().separators; } } @@ -5779,18 +5795,21 @@ export class ErrorParameters { private readonly fetch = once(() => { const [items, separators] = ast_internal.selectSeparated(this.cst); - return { items: items.map((item) => new ErrorParameter(item as RuleNode)), separators: separators as TokenNode[] }; + return { + items: items.map((item) => new ErrorParameter(item as NonTerminalNode)), + separators: separators as TerminalNode[], + }; }); - public constructor(public readonly cst: RuleNode) { - assertKind(this.cst.kind, RuleKind.ErrorParameters); + public constructor(public readonly cst: NonTerminalNode) { + assertKind(this.cst.kind, NonTerminalKind.ErrorParameters); } public get items(): readonly ErrorParameter[] { return this.fetch().items; } - public get separators(): readonly TokenNode[] { + public get separators(): readonly TerminalNode[] { return this.fetch().separators; } } @@ -5799,18 +5818,21 @@ export class AssemblyFlags { private readonly fetch = once(() => { const [items, separators] = ast_internal.selectSeparated(this.cst); - return { items: items.map((item) => new StringLiteral(item as RuleNode)), separators: separators as TokenNode[] }; + return { + items: items.map((item) => new StringLiteral(item as NonTerminalNode)), + separators: separators as TerminalNode[], + }; }); - public constructor(public readonly cst: RuleNode) { - assertKind(this.cst.kind, RuleKind.AssemblyFlags); + public constructor(public readonly cst: NonTerminalNode) { + assertKind(this.cst.kind, NonTerminalKind.AssemblyFlags); } public get items(): readonly StringLiteral[] { return this.fetch().items; } - public get separators(): readonly TokenNode[] { + public get separators(): readonly TerminalNode[] { return this.fetch().separators; } } @@ -5820,20 +5842,20 @@ export class TupleDeconstructionElements { const [items, separators] = ast_internal.selectSeparated(this.cst); return { - items: items.map((item) => new TupleDeconstructionElement(item as RuleNode)), - separators: separators as TokenNode[], + items: items.map((item) => new TupleDeconstructionElement(item as NonTerminalNode)), + separators: separators as TerminalNode[], }; }); - public constructor(public readonly cst: RuleNode) { - assertKind(this.cst.kind, RuleKind.TupleDeconstructionElements); + public constructor(public readonly cst: NonTerminalNode) { + assertKind(this.cst.kind, NonTerminalKind.TupleDeconstructionElements); } public get items(): readonly TupleDeconstructionElement[] { return this.fetch().items; } - public get separators(): readonly TokenNode[] { + public get separators(): readonly TerminalNode[] { return this.fetch().separators; } } @@ -5842,18 +5864,21 @@ export class PositionalArguments { private readonly fetch = once(() => { const [items, separators] = ast_internal.selectSeparated(this.cst); - return { items: items.map((item) => new Expression(item as RuleNode)), separators: separators as TokenNode[] }; + return { + items: items.map((item) => new Expression(item as NonTerminalNode)), + separators: separators as TerminalNode[], + }; }); - public constructor(public readonly cst: RuleNode) { - assertKind(this.cst.kind, RuleKind.PositionalArguments); + public constructor(public readonly cst: NonTerminalNode) { + assertKind(this.cst.kind, NonTerminalKind.PositionalArguments); } public get items(): readonly Expression[] { return this.fetch().items; } - public get separators(): readonly TokenNode[] { + public get separators(): readonly TerminalNode[] { return this.fetch().separators; } } @@ -5862,18 +5887,21 @@ export class NamedArguments { private readonly fetch = once(() => { const [items, separators] = ast_internal.selectSeparated(this.cst); - return { items: items.map((item) => new NamedArgument(item as RuleNode)), separators: separators as TokenNode[] }; + return { + items: items.map((item) => new NamedArgument(item as NonTerminalNode)), + separators: separators as TerminalNode[], + }; }); - public constructor(public readonly cst: RuleNode) { - assertKind(this.cst.kind, RuleKind.NamedArguments); + public constructor(public readonly cst: NonTerminalNode) { + assertKind(this.cst.kind, NonTerminalKind.NamedArguments); } public get items(): readonly NamedArgument[] { return this.fetch().items; } - public get separators(): readonly TokenNode[] { + public get separators(): readonly TerminalNode[] { return this.fetch().separators; } } @@ -5882,18 +5910,21 @@ export class CallOptions { private readonly fetch = once(() => { const [items, separators] = ast_internal.selectSeparated(this.cst); - return { items: items.map((item) => new NamedArgument(item as RuleNode)), separators: separators as TokenNode[] }; + return { + items: items.map((item) => new NamedArgument(item as NonTerminalNode)), + separators: separators as TerminalNode[], + }; }); - public constructor(public readonly cst: RuleNode) { - assertKind(this.cst.kind, RuleKind.CallOptions); + public constructor(public readonly cst: NonTerminalNode) { + assertKind(this.cst.kind, NonTerminalKind.CallOptions); } public get items(): readonly NamedArgument[] { return this.fetch().items; } - public get separators(): readonly TokenNode[] { + public get separators(): readonly TerminalNode[] { return this.fetch().separators; } } @@ -5902,18 +5933,21 @@ export class TupleValues { private readonly fetch = once(() => { const [items, separators] = ast_internal.selectSeparated(this.cst); - return { items: items.map((item) => new TupleValue(item as RuleNode)), separators: separators as TokenNode[] }; + return { + items: items.map((item) => new TupleValue(item as NonTerminalNode)), + separators: separators as TerminalNode[], + }; }); - public constructor(public readonly cst: RuleNode) { - assertKind(this.cst.kind, RuleKind.TupleValues); + public constructor(public readonly cst: NonTerminalNode) { + assertKind(this.cst.kind, NonTerminalKind.TupleValues); } public get items(): readonly TupleValue[] { return this.fetch().items; } - public get separators(): readonly TokenNode[] { + public get separators(): readonly TerminalNode[] { return this.fetch().separators; } } @@ -5922,18 +5956,21 @@ export class ArrayValues { private readonly fetch = once(() => { const [items, separators] = ast_internal.selectSeparated(this.cst); - return { items: items.map((item) => new Expression(item as RuleNode)), separators: separators as TokenNode[] }; + return { + items: items.map((item) => new Expression(item as NonTerminalNode)), + separators: separators as TerminalNode[], + }; }); - public constructor(public readonly cst: RuleNode) { - assertKind(this.cst.kind, RuleKind.ArrayValues); + public constructor(public readonly cst: NonTerminalNode) { + assertKind(this.cst.kind, NonTerminalKind.ArrayValues); } public get items(): readonly Expression[] { return this.fetch().items; } - public get separators(): readonly TokenNode[] { + public get separators(): readonly TerminalNode[] { return this.fetch().separators; } } @@ -5942,18 +5979,18 @@ export class IdentifierPath { private readonly fetch = once(() => { const [items, separators] = ast_internal.selectSeparated(this.cst); - return { items: items as TokenNode[], separators: separators as TokenNode[] }; + return { items: items as TerminalNode[], separators: separators as TerminalNode[] }; }); - public constructor(public readonly cst: RuleNode) { - assertKind(this.cst.kind, RuleKind.IdentifierPath); + public constructor(public readonly cst: NonTerminalNode) { + assertKind(this.cst.kind, NonTerminalKind.IdentifierPath); } - public get items(): readonly TokenNode[] { + public get items(): readonly TerminalNode[] { return this.fetch().items; } - public get separators(): readonly TokenNode[] { + public get separators(): readonly TerminalNode[] { return this.fetch().separators; } } @@ -5962,18 +5999,18 @@ export class YulParameters { private readonly fetch = once(() => { const [items, separators] = ast_internal.selectSeparated(this.cst); - return { items: items as TokenNode[], separators: separators as TokenNode[] }; + return { items: items as TerminalNode[], separators: separators as TerminalNode[] }; }); - public constructor(public readonly cst: RuleNode) { - assertKind(this.cst.kind, RuleKind.YulParameters); + public constructor(public readonly cst: NonTerminalNode) { + assertKind(this.cst.kind, NonTerminalKind.YulParameters); } - public get items(): readonly TokenNode[] { + public get items(): readonly TerminalNode[] { return this.fetch().items; } - public get separators(): readonly TokenNode[] { + public get separators(): readonly TerminalNode[] { return this.fetch().separators; } } @@ -5982,18 +6019,18 @@ export class YulReturnVariables { private readonly fetch = once(() => { const [items, separators] = ast_internal.selectSeparated(this.cst); - return { items: items as TokenNode[], separators: separators as TokenNode[] }; + return { items: items as TerminalNode[], separators: separators as TerminalNode[] }; }); - public constructor(public readonly cst: RuleNode) { - assertKind(this.cst.kind, RuleKind.YulReturnVariables); + public constructor(public readonly cst: NonTerminalNode) { + assertKind(this.cst.kind, NonTerminalKind.YulReturnVariables); } - public get items(): readonly TokenNode[] { + public get items(): readonly TerminalNode[] { return this.fetch().items; } - public get separators(): readonly TokenNode[] { + public get separators(): readonly TerminalNode[] { return this.fetch().separators; } } @@ -6002,18 +6039,21 @@ export class YulArguments { private readonly fetch = once(() => { const [items, separators] = ast_internal.selectSeparated(this.cst); - return { items: items.map((item) => new YulExpression(item as RuleNode)), separators: separators as TokenNode[] }; + return { + items: items.map((item) => new YulExpression(item as NonTerminalNode)), + separators: separators as TerminalNode[], + }; }); - public constructor(public readonly cst: RuleNode) { - assertKind(this.cst.kind, RuleKind.YulArguments); + public constructor(public readonly cst: NonTerminalNode) { + assertKind(this.cst.kind, NonTerminalKind.YulArguments); } public get items(): readonly YulExpression[] { return this.fetch().items; } - public get separators(): readonly TokenNode[] { + public get separators(): readonly TerminalNode[] { return this.fetch().separators; } } @@ -6022,18 +6062,21 @@ export class YulPaths { private readonly fetch = once(() => { const [items, separators] = ast_internal.selectSeparated(this.cst); - return { items: items.map((item) => new YulPath(item as RuleNode)), separators: separators as TokenNode[] }; + return { + items: items.map((item) => new YulPath(item as NonTerminalNode)), + separators: separators as TerminalNode[], + }; }); - public constructor(public readonly cst: RuleNode) { - assertKind(this.cst.kind, RuleKind.YulPaths); + public constructor(public readonly cst: NonTerminalNode) { + assertKind(this.cst.kind, NonTerminalKind.YulPaths); } public get items(): readonly YulPath[] { return this.fetch().items; } - public get separators(): readonly TokenNode[] { + public get separators(): readonly TerminalNode[] { return this.fetch().separators; } } @@ -6043,20 +6086,20 @@ export class YulPath { const [items, separators] = ast_internal.selectSeparated(this.cst); return { - items: items.map((item) => new YulPathComponent(item as RuleNode)), - separators: separators as TokenNode[], + items: items.map((item) => new YulPathComponent(item as NonTerminalNode)), + separators: separators as TerminalNode[], }; }); - public constructor(public readonly cst: RuleNode) { - assertKind(this.cst.kind, RuleKind.YulPath); + public constructor(public readonly cst: NonTerminalNode) { + assertKind(this.cst.kind, NonTerminalKind.YulPath); } public get items(): readonly YulPathComponent[] { return this.fetch().items; } - public get separators(): readonly TokenNode[] { + public get separators(): readonly TerminalNode[] { return this.fetch().separators; } } @@ -6075,6 +6118,6 @@ function once(factory: () => T): () => T { }; } -function assertKind(actual: RuleKind, expected: RuleKind): void { +function assertKind(actual: NonTerminalKind, expected: NonTerminalKind): void { assert.equal(actual, expected, `${expected} can only be initialized with a CST node of the same kind.`); } diff --git a/crates/solidity/outputs/npm/package/src/generated/cst/index.ts b/crates/solidity/outputs/npm/package/src/generated/cst/index.ts index f44ac9563b..bc3e1ec87d 100644 --- a/crates/solidity/outputs/npm/package/src/generated/cst/index.ts +++ b/crates/solidity/outputs/npm/package/src/generated/cst/index.ts @@ -7,8 +7,8 @@ export type Node = generated.cst.Node; export const NodeType = generated.cst.NodeType; export type NodeType = generated.cst.NodeType; -export const RuleNode = generated.cst.RuleNode; -export type RuleNode = generated.cst.RuleNode; +export const NonTerminalNode = generated.cst.NonTerminalNode; +export type NonTerminalNode = generated.cst.NonTerminalNode; -export const TokenNode = generated.cst.TokenNode; -export type TokenNode = generated.cst.TokenNode; +export const TerminalNode = generated.cst.TerminalNode; +export type TerminalNode = generated.cst.TerminalNode; diff --git a/crates/solidity/outputs/npm/package/src/generated/kinds/index.ts b/crates/solidity/outputs/npm/package/src/generated/kinds/index.ts index 5828a42091..b094f4488b 100644 --- a/crates/solidity/outputs/npm/package/src/generated/kinds/index.ts +++ b/crates/solidity/outputs/npm/package/src/generated/kinds/index.ts @@ -2,11 +2,11 @@ import * as generated from "../napi-bindings/generated"; -export const RuleKind = generated.kinds.RuleKind; -export type RuleKind = generated.kinds.RuleKind; +export const NonTerminalKind = generated.kinds.NonTerminalKind; +export type NonTerminalKind = generated.kinds.NonTerminalKind; -export const TokenKind = generated.kinds.TokenKind; -export type TokenKind = generated.kinds.TokenKind; +export const TerminalKind = generated.kinds.TerminalKind; +export type TerminalKind = generated.kinds.TerminalKind; -export const NodeLabel = generated.kinds.NodeLabel; -export type NodeLabel = generated.kinds.NodeLabel; +export const EdgeLabel = generated.kinds.EdgeLabel; +export type EdgeLabel = generated.kinds.EdgeLabel; diff --git a/crates/solidity/outputs/npm/package/src/generated/napi-bindings/generated/index.d.ts b/crates/solidity/outputs/npm/package/src/generated/napi-bindings/generated/index.d.ts index acc7333fb8..d8f81cdfc3 100644 --- a/crates/solidity/outputs/npm/package/src/generated/napi-bindings/generated/index.d.ts +++ b/crates/solidity/outputs/npm/package/src/generated/napi-bindings/generated/index.d.ts @@ -9,7 +9,7 @@ /* auto-generated by NAPI-RS */ export namespace kinds { - export enum RuleKind { + export enum NonTerminalKind { ABICoderPragma = "ABICoderPragma", AdditiveExpression = "AdditiveExpression", AddressType = "AddressType", @@ -225,7 +225,7 @@ export namespace kinds { YulVariableDeclarationStatement = "YulVariableDeclarationStatement", YulVariableDeclarationValue = "YulVariableDeclarationValue", } - export enum NodeLabel { + export enum EdgeLabel { Item = "Item", Variant = "Variant", Separator = "Separator", @@ -358,7 +358,7 @@ export namespace kinds { Version = "Version", WhileKeyword = "WhileKeyword", } - export enum TokenKind { + export enum TerminalKind { SKIPPED = "SKIPPED", AbicoderKeyword = "AbicoderKeyword", AbstractKeyword = "AbstractKeyword", @@ -734,17 +734,17 @@ export namespace language { constructor(version: string); get version(): string; static supportedVersions(): Array; - parse(kind: kinds.RuleKind, input: string): parse_output.ParseOutput; + parse(kind: kinds.NonTerminalKind, input: string): parse_output.ParseOutput; } } export namespace cst { export enum NodeType { - Rule = "Rule", - Token = "Token", + NonTerminal = "NonTerminal", + Terminal = "Terminal", } - export class RuleNode { - get type(): NodeType.Rule; - get kind(): kinds.RuleKind; + export class NonTerminalNode { + get type(): NodeType.NonTerminal; + get kind(): kinds.NonTerminalKind; get textLength(): text_index.TextIndex; children(): Array; createCursor(textOffset: text_index.TextIndex): cursor.Cursor; @@ -752,13 +752,13 @@ export namespace cst { toJSON(): string; unparse(): string; } - export class TokenNode { - get type(): NodeType.Token; - get kind(): kinds.TokenKind; + export class TerminalNode { + get type(): NodeType.Terminal; + get kind(): kinds.TerminalKind; get textLength(): text_index.TextIndex; get text(): string; /** - * Serialize the token node to JSON. + * Serialize the terminal node to JSON. * * This method is intended for debugging purposes and may not be stable. */ @@ -774,11 +774,11 @@ export namespace cursor { spawn(): Cursor; get isCompleted(): boolean; node(): cst.Node; - get label(): kinds.NodeLabel; + get label(): kinds.EdgeLabel; get textOffset(): text_index.TextIndex; get textRange(): text_index.TextRange; get depth(): number; - ancestors(): Array; + ancestors(): Array; goToNext(): boolean; goToNextNonDescendent(): boolean; goToPrevious(): boolean; @@ -788,12 +788,12 @@ export namespace cursor { goToNthChild(childNumber: number): boolean; goToNextSibling(): boolean; goToPreviousSibling(): boolean; - goToNextToken(): boolean; - goToNextTokenWithKind(kind: kinds.TokenKind): boolean; - goToNextTokenWithKinds(kinds: Array): boolean; - goToNextRule(): boolean; - goToNextRuleWithKind(kind: kinds.RuleKind): boolean; - goToNextRuleWithKinds(kinds: Array): boolean; + goToNextTerminal(): boolean; + goToNextTerminalWithKind(kind: kinds.TerminalKind): boolean; + goToNextTokenWithKinds(kinds: Array): boolean; + goToNextNonterminal(): boolean; + goToNextNonterminalWithKind(kind: kinds.NonTerminalKind): boolean; + goToNextNonterminalWithKinds(kinds: Array): boolean; query(queries: Array): query.QueryResultIterator; } } @@ -836,12 +836,12 @@ export namespace text_index { } } export namespace ast_internal { - export function selectSequence(node: cst.RuleNode): Array; - export function selectChoice(node: cst.RuleNode): cst.Node; - export function selectRepeated(node: cst.RuleNode): Array; - export function selectSeparated(node: cst.RuleNode): [Array, Array]; + export function selectSequence(node: cst.NonTerminalNode): Array; + export function selectChoice(node: cst.NonTerminalNode): cst.Node; + export function selectRepeated(node: cst.NonTerminalNode): Array; + export function selectSeparated(node: cst.NonTerminalNode): [Array, Array]; } export namespace cst { - export type Node = RuleNode | TokenNode; + export type Node = TerminalNode | NonTerminalNode; } diff --git a/crates/solidity/outputs/npm/tests/src/doc-examples/using-queries.ts b/crates/solidity/outputs/npm/tests/src/doc-examples/using-queries.ts index 1bb0b1b66b..2a6b22bf14 100644 --- a/crates/solidity/outputs/npm/tests/src/doc-examples/using-queries.ts +++ b/crates/solidity/outputs/npm/tests/src/doc-examples/using-queries.ts @@ -4,15 +4,15 @@ import assert from "node:assert"; import fs from "node:fs/promises"; import { Language } from "@nomicfoundation/slang/language"; -import { RuleKind } from "@nomicfoundation/slang/kinds"; +import { NonTerminalKind } from "@nomicfoundation/slang/kinds"; import { Query, QueryResultIterator } from "@nomicfoundation/slang/query"; -import { RuleNode, TokenNode } from "@nomicfoundation/slang/cst"; +import { NonTerminalNode, TerminalNode } from "@nomicfoundation/slang/cst"; async function parseDocInputFile(filePath: string) { const inputPath = path.join(repoPath("documentation/public/user-guide/inputs"), filePath); const source = await fs.readFile(inputPath, "utf8").then((source) => source.trim()); const language = new Language("0.8.0"); - return language.parse(RuleKind.SourceUnit, source); + return language.parse(NonTerminalKind.SourceUnit, source); } test("using queries", async () => { @@ -43,7 +43,7 @@ test("using queries", async () => { const bindings = result.bindings; const cursors = bindings["contract"]; - const cursor = cursors?.[0]?.node() as RuleNode; + const cursor = cursors?.[0]?.node() as NonTerminalNode; found.push(cursor.unparse().trim()); } @@ -70,7 +70,7 @@ test("using queries", async () => { const cursor = cursors?.[0]; - names.push([index, (cursor?.node() as TokenNode).text]); + names.push([index, (cursor?.node() as TerminalNode).text]); } assert.deepStrictEqual(names, [ @@ -99,7 +99,7 @@ test("using queries", async () => { const cursor = cursors?.[0]; - names.push((cursor?.node() as RuleNode).unparse()); + names.push((cursor?.node() as NonTerminalNode).unparse()); } assert.deepStrictEqual(names, ["uint", " uint16", " uint64", " uint256"]); @@ -124,7 +124,7 @@ test("using queries", async () => { const cursor = cursors?.[0]; - names.push((cursor?.node() as TokenNode).text); + names.push((cursor?.node() as TerminalNode).text); } assert.deepStrictEqual(names, ["uint"]); @@ -161,7 +161,7 @@ test("using queries", async () => { const cursor = cursors?.[0]; - found.push([cursor?.textOffset.utf8, (cursor?.node() as RuleNode).unparse()]); + found.push([cursor?.textOffset.utf8, (cursor?.node() as NonTerminalNode).unparse()]); } assert.deepStrictEqual(found, [[375, "tx.origin"]]); diff --git a/crates/solidity/outputs/npm/tests/src/doc-examples/using-the-ast.ts b/crates/solidity/outputs/npm/tests/src/doc-examples/using-the-ast.ts index c8b290864f..5054b69813 100644 --- a/crates/solidity/outputs/npm/tests/src/doc-examples/using-the-ast.ts +++ b/crates/solidity/outputs/npm/tests/src/doc-examples/using-the-ast.ts @@ -4,8 +4,8 @@ import fs from "node:fs/promises"; // --8<-- [start:imports] import assert from "node:assert"; import { Language } from "@nomicfoundation/slang/language"; -import { RuleKind } from "@nomicfoundation/slang/kinds"; -import { RuleNode } from "@nomicfoundation/slang/cst"; +import { NonTerminalKind } from "@nomicfoundation/slang/kinds"; +import { NonTerminalNode } from "@nomicfoundation/slang/cst"; import { FunctionDefinition } from "@nomicfoundation/slang/ast"; // --8<-- [end:imports] @@ -16,11 +16,11 @@ test("using the ast", async () => { // --8<-- [start:parse-input] const language = new Language("0.8.0"); - const parseOutput = language.parse(RuleKind.FunctionDefinition, source); + const parseOutput = language.parse(NonTerminalKind.FunctionDefinition, source); // --8<-- [end:parse-input] // --8<-- [start:create-node] - const $function = new FunctionDefinition(parseOutput.tree() as RuleNode); + const $function = new FunctionDefinition(parseOutput.tree() as NonTerminalNode); assert.equal($function.name.variant.text, "add"); // --8<-- [end:create-node] diff --git a/crates/solidity/outputs/npm/tests/src/doc-examples/using-the-cursor.ts b/crates/solidity/outputs/npm/tests/src/doc-examples/using-the-cursor.ts index 936f01ba60..7827086a6f 100644 --- a/crates/solidity/outputs/npm/tests/src/doc-examples/using-the-cursor.ts +++ b/crates/solidity/outputs/npm/tests/src/doc-examples/using-the-cursor.ts @@ -4,8 +4,8 @@ import fs from "node:fs/promises"; // --8<-- [start:imports] import assert from "node:assert"; import { Language } from "@nomicfoundation/slang/language"; -import { RuleKind, TokenKind } from "@nomicfoundation/slang/kinds"; -import { RuleNode, TokenNode } from "@nomicfoundation/slang/cst"; +import { NonTerminalKind, TerminalKind } from "@nomicfoundation/slang/kinds"; +import { NonTerminalNode, TerminalNode } from "@nomicfoundation/slang/cst"; // --8<-- [end:imports] test("using the cursor", async () => { @@ -15,7 +15,7 @@ test("using the cursor", async () => { // --8<-- [start:parse-input] const language = new Language("0.8.0"); - const parseOutput = language.parse(RuleKind.SourceUnit, source); + const parseOutput = language.parse(NonTerminalKind.SourceUnit, source); // --8<-- [end:parse-input] { @@ -24,12 +24,12 @@ test("using the cursor", async () => { const cursor = parseOutput.createTreeCursor(); - while (cursor.goToNextRuleWithKind(RuleKind.ContractDefinition)) { + while (cursor.goToNextNonterminalWithKind(NonTerminalKind.ContractDefinition)) { assert(cursor.goToFirstChild()); - assert(cursor.goToNextTokenWithKind(TokenKind.Identifier)); + assert(cursor.goToNextTerminalWithKind(TerminalKind.Identifier)); const tokenNode = cursor.node(); - assert(tokenNode instanceof TokenNode); + assert(tokenNode instanceof TerminalNode); contracts.push(tokenNode.text); assert(cursor.goToParent()); @@ -45,12 +45,12 @@ test("using the cursor", async () => { const cursor = parseOutput.createTreeCursor(); - while (cursor.goToNextRuleWithKind(RuleKind.ContractDefinition)) { + while (cursor.goToNextNonterminalWithKind(NonTerminalKind.ContractDefinition)) { const childCursor = cursor.spawn(); - assert(childCursor.goToNextTokenWithKind(TokenKind.Identifier)); + assert(childCursor.goToNextTerminalWithKind(TerminalKind.Identifier)); const tokenNode = childCursor.node(); - assert(tokenNode instanceof TokenNode); + assert(tokenNode instanceof TerminalNode); contracts.push(tokenNode.text); } @@ -64,11 +64,11 @@ test("using the cursor", async () => { const cursor = parseOutput.createTreeCursor(); - while (cursor.goToNextRuleWithKind(RuleKind.ContractDefinition)) { + while (cursor.goToNextNonterminalWithKind(NonTerminalKind.ContractDefinition)) { const range = cursor.textRange; const contractNode = cursor.node(); - assert(contractNode instanceof RuleNode); + assert(contractNode instanceof NonTerminalNode); contracts.push([range.start.char, range.end.char, contractNode.unparse().trim()]); } diff --git a/crates/solidity/outputs/npm/tests/src/doc-examples/using-the-parser.ts b/crates/solidity/outputs/npm/tests/src/doc-examples/using-the-parser.ts index 115511460a..a1081ea025 100644 --- a/crates/solidity/outputs/npm/tests/src/doc-examples/using-the-parser.ts +++ b/crates/solidity/outputs/npm/tests/src/doc-examples/using-the-parser.ts @@ -4,8 +4,8 @@ import fs from "node:fs/promises"; // --8<-- [start:imports] import assert from "node:assert"; import { Language } from "@nomicfoundation/slang/language"; -import { RuleKind, TokenKind } from "@nomicfoundation/slang/kinds"; -import { RuleNode } from "@nomicfoundation/slang/cst"; +import { NonTerminalKind, TerminalKind } from "@nomicfoundation/slang/kinds"; +import { NonTerminalNode } from "@nomicfoundation/slang/cst"; // --8<-- [end:imports] test("using the parser", async () => { @@ -15,7 +15,7 @@ test("using the parser", async () => { // --8<-- [start:parse-input] const language = new Language("0.8.0"); - const parseOutput = language.parse(RuleKind.ContractDefinition, source); + const parseOutput = language.parse(NonTerminalKind.ContractDefinition, source); // --8<-- [end:parse-input] // --8<-- [start:print-errors] @@ -30,21 +30,21 @@ test("using the parser", async () => { // --8<-- [start:inspect-tree] const contract = parseOutput.tree(); - assert(contract instanceof RuleNode); - assert.equal(contract.kind, RuleKind.ContractDefinition); + assert(contract instanceof NonTerminalNode); + assert.equal(contract.kind, NonTerminalKind.ContractDefinition); const contractChildren = contract.children(); assert.equal(contractChildren.length, 7); const [contractKeyword, firstSpace, contractName, secondSpace, openBrace, members, closeBrace] = contractChildren; - assert.equal(contractKeyword?.kind, TokenKind.ContractKeyword); - assert.equal(firstSpace?.kind, TokenKind.Whitespace); - assert.equal(contractName?.kind, TokenKind.Identifier); - assert.equal(secondSpace?.kind, TokenKind.Whitespace); - assert.equal(openBrace?.kind, TokenKind.OpenBrace); - assert.equal(members?.kind, RuleKind.ContractMembers); - assert.equal(closeBrace?.kind, TokenKind.CloseBrace); + assert.equal(contractKeyword?.kind, TerminalKind.ContractKeyword); + assert.equal(firstSpace?.kind, TerminalKind.Whitespace); + assert.equal(contractName?.kind, TerminalKind.Identifier); + assert.equal(secondSpace?.kind, TerminalKind.Whitespace); + assert.equal(openBrace?.kind, TerminalKind.OpenBrace); + assert.equal(members?.kind, NonTerminalKind.ContractMembers); + assert.equal(closeBrace?.kind, TerminalKind.CloseBrace); // --8<-- [end:inspect-tree] // --8<-- [start:unparse-node] diff --git a/crates/solidity/testing/sanctuary/src/tests.rs b/crates/solidity/testing/sanctuary/src/tests.rs index 773c847a82..3ac093982a 100644 --- a/crates/solidity/testing/sanctuary/src/tests.rs +++ b/crates/solidity/testing/sanctuary/src/tests.rs @@ -5,7 +5,7 @@ use anyhow::Result; use infra_utils::paths::PathExtensions; use itertools::Itertools; use semver::Version; -use slang_solidity::kinds::RuleKind; +use slang_solidity::kinds::NonTerminalKind; use slang_solidity::language::Language; use crate::datasets::{DataSet, SourceFile}; @@ -99,7 +99,7 @@ pub fn run_test(file: &SourceFile, events: &Events) -> Result<()> { .replace("'", "\""); let language = Language::new(version.clone())?; - let output = language.parse(RuleKind::SourceUnit, &source); + let output = language.parse(NonTerminalKind::SourceUnit, &source); if output.is_valid() { events.test(TestOutcome::Passed); diff --git a/crates/testlang/outputs/cargo/slang_testlang/src/generated/generated/kinds.rs b/crates/testlang/outputs/cargo/slang_testlang/src/generated/generated/kinds.rs index 166db5216d..c0442298a1 100644 --- a/crates/testlang/outputs/cargo/slang_testlang/src/generated/generated/kinds.rs +++ b/crates/testlang/outputs/cargo/slang_testlang/src/generated/generated/kinds.rs @@ -17,7 +17,7 @@ use napi_derive::napi; )] #[cfg_attr(feature = "slang_napi_interfaces", /* derives `Clone` and `Copy` */ napi(string_enum, namespace = "kinds"))] #[cfg_attr(not(feature = "slang_napi_interfaces"), derive(Clone, Copy))] -pub enum RuleKind { +pub enum NonTerminalKind { AdditionExpression, Expression, Literal, @@ -33,7 +33,7 @@ pub enum RuleKind { TreeNodeChildren, } -impl metaslang_cst::NonTerminalKind for RuleKind {} +impl metaslang_cst::NonTerminalKind for NonTerminalKind {} #[derive( Debug, @@ -50,7 +50,7 @@ impl metaslang_cst::NonTerminalKind for RuleKind {} #[strum(serialize_all = "snake_case")] #[cfg_attr(feature = "slang_napi_interfaces", /* derives `Clone` and `Copy` */ napi(string_enum, namespace = "kinds"))] #[cfg_attr(not(feature = "slang_napi_interfaces"), derive(Clone, Copy))] -pub enum NodeLabel { +pub enum EdgeLabel { // Built-in: Item, Variant, @@ -74,7 +74,7 @@ pub enum NodeLabel { Semicolon, } -impl metaslang_cst::EdgeKind for NodeLabel {} +impl metaslang_cst::EdgeLabel for EdgeLabel {} #[derive( Debug, @@ -90,7 +90,7 @@ impl metaslang_cst::EdgeKind for NodeLabel {} )] #[cfg_attr(feature = "slang_napi_interfaces", /* derives `Clone` and `Copy` */ napi(string_enum, namespace = "kinds"))] #[cfg_attr(not(feature = "slang_napi_interfaces"), derive(Clone, Copy))] -pub enum TokenKind { +pub enum TerminalKind { // Built-in: SKIPPED, @@ -111,7 +111,7 @@ pub enum TokenKind { Whitespace, } -impl metaslang_cst::TerminalKind for TokenKind { +impl metaslang_cst::TerminalKind for TerminalKind { fn is_trivia(&self) -> bool { matches!(self, |Self::EndOfLine| Self::MultiLineComment | Self::SingleLineComment diff --git a/crates/testlang/outputs/cargo/slang_testlang/src/generated/generated/language.rs b/crates/testlang/outputs/cargo/slang_testlang/src/generated/generated/language.rs index 702b3705b9..7bc17689a9 100644 --- a/crates/testlang/outputs/cargo/slang_testlang/src/generated/generated/language.rs +++ b/crates/testlang/outputs/cargo/slang_testlang/src/generated/generated/language.rs @@ -16,7 +16,7 @@ use semver::Version; use crate::cst; use crate::kinds::{ - IsLexicalContext, LexicalContext, LexicalContextType, NodeLabel, RuleKind, TokenKind, + EdgeLabel, IsLexicalContext, LexicalContext, LexicalContextType, NonTerminalKind, TerminalKind, }; use crate::lexer::{KeywordScan, Lexer, ScannedToken}; #[cfg(feature = "slang_napi_interfaces")] @@ -83,14 +83,14 @@ impl Language { return result; }; match &r#match.nodes[..] { - [cst::LabeledNode { - label: _, - node: cst::Node::Rule(node), - }] if node.kind == RuleKind::Expression => match &node.children[..] { - [inner @ cst::LabeledNode { - label: _, - node: cst::Node::Rule(rule), - }] if rule.kind == RuleKind::AdditionExpression => { + [cst::Edge { + node: cst::Node::NonTerminal(node), + .. + }] if node.kind == NonTerminalKind::Expression => match &node.children[..] { + [inner @ cst::Edge { + node: cst::Node::NonTerminal(node), + .. + }] if node.kind == NonTerminalKind::AdditionExpression => { ParserResult::r#match(vec![inner.clone()], r#match.expected_tokens.clone()) } _ => ParserResult::no_match(vec![]), @@ -103,38 +103,44 @@ impl Language { fn expression(&self, input: &mut ParserContext<'_>) -> ParserResult { let parse_left_addition_expression = |input: &mut ParserContext<'_>| { PrecedenceHelper::to_binary_operator( - RuleKind::AdditionExpression, + NonTerminalKind::AdditionExpression, 1u8, 1u8 + 1, - self.parse_token_with_trivia::(input, TokenKind::Plus) - .with_label(NodeLabel::Operator), + self.parse_token_with_trivia::( + input, + TerminalKind::Plus, + ) + .with_label(EdgeLabel::Operator), ) }; let parse_prefix_negation_expression = |input: &mut ParserContext<'_>| { PrecedenceHelper::to_prefix_operator( - RuleKind::NegationExpression, + NonTerminalKind::NegationExpression, 3u8, - self.parse_token_with_trivia::(input, TokenKind::Bang) - .with_label(NodeLabel::Operator), + self.parse_token_with_trivia::( + input, + TerminalKind::Bang, + ) + .with_label(EdgeLabel::Operator), ) }; let parse_postfix_member_access_expression = |input: &mut ParserContext<'_>| { PrecedenceHelper::to_postfix_operator( - RuleKind::MemberAccessExpression, + NonTerminalKind::MemberAccessExpression, 5u8, SequenceHelper::run(|mut seq| { seq.elem_labeled( - NodeLabel::Period, + EdgeLabel::Period, self.parse_token_with_trivia::( input, - TokenKind::Period, + TerminalKind::Period, ), )?; seq.elem_labeled( - NodeLabel::Member, + EdgeLabel::Member, self.parse_token_with_trivia::( input, - TokenKind::Identifier, + TerminalKind::Identifier, ), )?; seq.finish() @@ -152,17 +158,17 @@ impl Language { ChoiceHelper::run(input, |mut choice, input| { let result = self.parse_token_with_trivia::( input, - TokenKind::StringLiteral, + TerminalKind::StringLiteral, ); choice.consider(input, result)?; let result = self.parse_token_with_trivia::( input, - TokenKind::Identifier, + TerminalKind::Identifier, ); choice.consider(input, result)?; choice.finish(input) }) - .with_label(NodeLabel::Variant) + .with_label(EdgeLabel::Variant) }; let postfix_operator_parser = |input: &mut ParserContext<'_>| { ChoiceHelper::run(input, |mut choice, input| { @@ -200,10 +206,10 @@ impl Language { }) }; PrecedenceHelper::reduce_precedence_result( - RuleKind::Expression, + NonTerminalKind::Expression, linear_expression_parser(input), ) - .with_kind(RuleKind::Expression) + .with_kind(NonTerminalKind::Expression) } #[allow(unused_assignments, unused_parens)] @@ -211,13 +217,13 @@ impl Language { ChoiceHelper::run(input, |mut choice, input| { let result = self.parse_token_with_trivia::( input, - TokenKind::StringLiteral, + TerminalKind::StringLiteral, ); choice.consider(input, result)?; choice.finish(input) }) - .with_label(NodeLabel::Variant) - .with_kind(RuleKind::Literal) + .with_label(EdgeLabel::Variant) + .with_kind(NonTerminalKind::Literal) } #[allow(unused_assignments, unused_parens)] @@ -227,14 +233,14 @@ impl Language { return result; }; match &r#match.nodes[..] { - [cst::LabeledNode { - label: _, - node: cst::Node::Rule(node), - }] if node.kind == RuleKind::Expression => match &node.children[..] { - [inner @ cst::LabeledNode { - label: _, - node: cst::Node::Rule(rule), - }] if rule.kind == RuleKind::MemberAccessExpression => { + [cst::Edge { + node: cst::Node::NonTerminal(node), + .. + }] if node.kind == NonTerminalKind::Expression => match &node.children[..] { + [inner @ cst::Edge { + node: cst::Node::NonTerminal(node), + .. + }] if node.kind == NonTerminalKind::MemberAccessExpression => { ParserResult::r#match(vec![inner.clone()], r#match.expected_tokens.clone()) } _ => ParserResult::no_match(vec![]), @@ -250,14 +256,14 @@ impl Language { return result; }; match &r#match.nodes[..] { - [cst::LabeledNode { - label: _, - node: cst::Node::Rule(node), - }] if node.kind == RuleKind::Expression => match &node.children[..] { - [inner @ cst::LabeledNode { - label: _, - node: cst::Node::Rule(rule), - }] if rule.kind == RuleKind::NegationExpression => { + [cst::Edge { + node: cst::Node::NonTerminal(node), + .. + }] if node.kind == NonTerminalKind::Expression => match &node.children[..] { + [inner @ cst::Edge { + node: cst::Node::NonTerminal(node), + .. + }] if node.kind == NonTerminalKind::NegationExpression => { ParserResult::r#match(vec![inner.clone()], r#match.expected_tokens.clone()) } _ => ParserResult::no_match(vec![]), @@ -275,24 +281,24 @@ impl Language { |input| { self.parse_token_with_trivia::( input, - TokenKind::Identifier, + TerminalKind::Identifier, ) - .with_label(NodeLabel::Item) + .with_label(EdgeLabel::Item) }, - TokenKind::Period, - NodeLabel::Separator, + TerminalKind::Period, + EdgeLabel::Separator, ) } else { ParserResult::disabled() } - .with_kind(RuleKind::SeparatedIdentifiers) + .with_kind(NonTerminalKind::SeparatedIdentifiers) } #[allow(unused_assignments, unused_parens)] fn source_unit(&self, input: &mut ParserContext<'_>) -> ParserResult { self.source_unit_members(input) - .with_label(NodeLabel::Members) - .with_kind(RuleKind::SourceUnit) + .with_label(EdgeLabel::Members) + .with_kind(NonTerminalKind::SourceUnit) } #[allow(unused_assignments, unused_parens)] @@ -308,16 +314,16 @@ impl Language { choice.consider(input, result)?; choice.finish(input) }) - .with_label(NodeLabel::Variant) - .with_kind(RuleKind::SourceUnitMember) + .with_label(EdgeLabel::Variant) + .with_kind(NonTerminalKind::SourceUnitMember) } #[allow(unused_assignments, unused_parens)] fn source_unit_members(&self, input: &mut ParserContext<'_>) -> ParserResult { OneOrMoreHelper::run(input, |input| { - self.source_unit_member(input).with_label(NodeLabel::Item) + self.source_unit_member(input).with_label(EdgeLabel::Item) }) - .with_kind(RuleKind::SourceUnitMembers) + .with_kind(NonTerminalKind::SourceUnitMembers) } #[allow(unused_assignments, unused_parens)] @@ -326,75 +332,75 @@ impl Language { seq.elem( SequenceHelper::run(|mut seq| { seq.elem_labeled( - NodeLabel::Keyword, + EdgeLabel::Keyword, self.parse_token_with_trivia::( input, - TokenKind::TreeKeyword, + TerminalKind::TreeKeyword, ), )?; seq.elem_labeled( - NodeLabel::Name, + EdgeLabel::Name, OptionalHelper::transform( self.parse_token_with_trivia::( input, - TokenKind::Identifier, + TerminalKind::Identifier, ), ), )?; - seq.elem_labeled(NodeLabel::Node, self.tree_node(input))?; + seq.elem_labeled(EdgeLabel::Node, self.tree_node(input))?; seq.finish() }) .recover_until_with_nested_delims::<_, LexicalContextType::Tree>( input, self, - TokenKind::Semicolon, + TerminalKind::Semicolon, TokenAcceptanceThreshold(1u8), ), )?; seq.elem_labeled( - NodeLabel::Semicolon, + EdgeLabel::Semicolon, self.parse_token_with_trivia::( input, - TokenKind::Semicolon, + TerminalKind::Semicolon, ), )?; seq.finish() }) - .with_kind(RuleKind::Tree) + .with_kind(NonTerminalKind::Tree) } #[allow(unused_assignments, unused_parens)] fn tree_node(&self, input: &mut ParserContext<'_>) -> ParserResult { SequenceHelper::run(|mut seq| { - let mut delim_guard = input.open_delim(TokenKind::CloseBracket); + let mut delim_guard = input.open_delim(TerminalKind::CloseBracket); let input = delim_guard.ctx(); seq.elem_labeled( - NodeLabel::OpenBracket, + EdgeLabel::OpenBracket, self.parse_token_with_trivia::( input, - TokenKind::OpenBracket, + TerminalKind::OpenBracket, ), )?; seq.elem( self.tree_node_children(input) - .with_label(NodeLabel::Members) + .with_label(EdgeLabel::Members) .recover_until_with_nested_delims::<_, LexicalContextType::Tree>( input, self, - TokenKind::CloseBracket, + TerminalKind::CloseBracket, TokenAcceptanceThreshold(0u8), ), )?; seq.elem_labeled( - NodeLabel::CloseBracket, + EdgeLabel::CloseBracket, self.parse_token_with_trivia::( input, - TokenKind::CloseBracket, + TerminalKind::CloseBracket, ), )?; seq.finish() }) - .with_kind(RuleKind::TreeNode) + .with_kind(NonTerminalKind::TreeNode) } #[allow(unused_assignments, unused_parens)] @@ -404,21 +410,21 @@ impl Language { choice.consider(input, result)?; let result = self.parse_token_with_trivia::( input, - TokenKind::DelimitedIdentifier, + TerminalKind::DelimitedIdentifier, ); choice.consider(input, result)?; choice.finish(input) }) - .with_label(NodeLabel::Variant) - .with_kind(RuleKind::TreeNodeChild) + .with_label(EdgeLabel::Variant) + .with_kind(NonTerminalKind::TreeNodeChild) } #[allow(unused_assignments, unused_parens)] fn tree_node_children(&self, input: &mut ParserContext<'_>) -> ParserResult { OneOrMoreHelper::run(input, |input| { - self.tree_node_child(input).with_label(NodeLabel::Item) + self.tree_node_child(input).with_label(EdgeLabel::Item) }) - .with_kind(RuleKind::TreeNodeChildren) + .with_kind(NonTerminalKind::TreeNodeChildren) } #[allow(unused_assignments, unused_parens)] @@ -426,20 +432,26 @@ impl Language { OneOrMoreHelper::run(input, |input| { ChoiceHelper::run(input, |mut choice, input| { let result = self - .parse_token::(input, TokenKind::Whitespace) - .with_label(NodeLabel::LeadingTrivia); + .parse_token::(input, TerminalKind::Whitespace) + .with_label(EdgeLabel::LeadingTrivia); choice.consider(input, result)?; let result = self - .parse_token::(input, TokenKind::EndOfLine) - .with_label(NodeLabel::LeadingTrivia); + .parse_token::(input, TerminalKind::EndOfLine) + .with_label(EdgeLabel::LeadingTrivia); choice.consider(input, result)?; let result = self - .parse_token::(input, TokenKind::SingleLineComment) - .with_label(NodeLabel::LeadingTrivia); + .parse_token::( + input, + TerminalKind::SingleLineComment, + ) + .with_label(EdgeLabel::LeadingTrivia); choice.consider(input, result)?; let result = self - .parse_token::(input, TokenKind::MultiLineComment) - .with_label(NodeLabel::LeadingTrivia); + .parse_token::( + input, + TerminalKind::MultiLineComment, + ) + .with_label(EdgeLabel::LeadingTrivia); choice.consider(input, result)?; choice.finish(input) }) @@ -450,19 +462,19 @@ impl Language { fn trailing_trivia(&self, input: &mut ParserContext<'_>) -> ParserResult { SequenceHelper::run(|mut seq| { seq.elem(OptionalHelper::transform( - self.parse_token::(input, TokenKind::Whitespace) - .with_label(NodeLabel::TrailingTrivia), + self.parse_token::(input, TerminalKind::Whitespace) + .with_label(EdgeLabel::TrailingTrivia), ))?; seq.elem(OptionalHelper::transform( self.parse_token::( input, - TokenKind::SingleLineComment, + TerminalKind::SingleLineComment, ) - .with_label(NodeLabel::TrailingTrivia), + .with_label(EdgeLabel::TrailingTrivia), ))?; seq.elem( - self.parse_token::(input, TokenKind::EndOfLine) - .with_label(NodeLabel::TrailingTrivia), + self.parse_token::(input, TerminalKind::EndOfLine) + .with_label(EdgeLabel::TrailingTrivia), )?; seq.finish() }) @@ -642,21 +654,23 @@ impl Language { ) } - pub fn parse(&self, kind: RuleKind, input: &str) -> ParseOutput { + pub fn parse(&self, kind: NonTerminalKind, input: &str) -> ParseOutput { match kind { - RuleKind::AdditionExpression => Self::addition_expression.parse(self, input), - RuleKind::Expression => Self::expression.parse(self, input), - RuleKind::Literal => Self::literal.parse(self, input), - RuleKind::MemberAccessExpression => Self::member_access_expression.parse(self, input), - RuleKind::NegationExpression => Self::negation_expression.parse(self, input), - RuleKind::SeparatedIdentifiers => Self::separated_identifiers.parse(self, input), - RuleKind::SourceUnit => Self::source_unit.parse(self, input), - RuleKind::SourceUnitMember => Self::source_unit_member.parse(self, input), - RuleKind::SourceUnitMembers => Self::source_unit_members.parse(self, input), - RuleKind::Tree => Self::tree.parse(self, input), - RuleKind::TreeNode => Self::tree_node.parse(self, input), - RuleKind::TreeNodeChild => Self::tree_node_child.parse(self, input), - RuleKind::TreeNodeChildren => Self::tree_node_children.parse(self, input), + NonTerminalKind::AdditionExpression => Self::addition_expression.parse(self, input), + NonTerminalKind::Expression => Self::expression.parse(self, input), + NonTerminalKind::Literal => Self::literal.parse(self, input), + NonTerminalKind::MemberAccessExpression => { + Self::member_access_expression.parse(self, input) + } + NonTerminalKind::NegationExpression => Self::negation_expression.parse(self, input), + NonTerminalKind::SeparatedIdentifiers => Self::separated_identifiers.parse(self, input), + NonTerminalKind::SourceUnit => Self::source_unit.parse(self, input), + NonTerminalKind::SourceUnitMember => Self::source_unit_member.parse(self, input), + NonTerminalKind::SourceUnitMembers => Self::source_unit_members.parse(self, input), + NonTerminalKind::Tree => Self::tree.parse(self, input), + NonTerminalKind::TreeNode => Self::tree_node.parse(self, input), + NonTerminalKind::TreeNodeChild => Self::tree_node_child.parse(self, input), + NonTerminalKind::TreeNodeChildren => Self::tree_node_children.parse(self, input), } } } @@ -670,10 +684,10 @@ impl Lexer for Language { Language::trailing_trivia(self, input) } - fn delimiters() -> &'static [(TokenKind, TokenKind)] { + fn delimiters() -> &'static [(TerminalKind, TerminalKind)] { match LexCtx::value() { LexicalContext::Default => &[], - LexicalContext::Tree => &[(TokenKind::OpenBracket, TokenKind::CloseBracket)], + LexicalContext::Tree => &[(TerminalKind::OpenBracket, TerminalKind::CloseBracket)], } } @@ -691,7 +705,7 @@ impl Lexer for Language { if self.$function(input) && input.position() > furthest_position { furthest_position = input.position(); - longest_token = Some(TokenKind::$kind); + longest_token = Some(TerminalKind::$kind); } input.set_position(save); )* @@ -701,9 +715,9 @@ impl Lexer for Language { match LexCtx::value() { LexicalContext::Default => { if let Some(kind) = match input.next() { - Some('!') => Some(TokenKind::Bang), - Some('+') => Some(TokenKind::Plus), - Some('.') => Some(TokenKind::Period), + Some('!') => Some(TerminalKind::Bang), + Some('+') => Some(TerminalKind::Plus), + Some('.') => Some(TerminalKind::Period), Some(_) => { input.undo(); None @@ -744,9 +758,9 @@ impl Lexer for Language { } LexicalContext::Tree => { if let Some(kind) = match input.next() { - Some(';') => Some(TokenKind::Semicolon), - Some('[') => Some(TokenKind::OpenBracket), - Some(']') => Some(TokenKind::CloseBracket), + Some(';') => Some(TerminalKind::Semicolon), + Some('[') => Some(TerminalKind::OpenBracket), + Some(']') => Some(TerminalKind::CloseBracket), Some(_) => { input.undo(); None @@ -768,10 +782,10 @@ impl Lexer for Language { // We have an identifier; we need to check if it's a keyword if let Some(identifier) = - longest_token.filter(|tok| [TokenKind::Identifier].contains(tok)) + longest_token.filter(|tok| [TerminalKind::Identifier].contains(tok)) { let kw_scan = if scan_chars!(input, 't', 'r', 'e', 'e') { - KeywordScan::Reserved(TokenKind::TreeKeyword) + KeywordScan::Reserved(TerminalKind::TreeKeyword) } else { KeywordScan::Absent }; @@ -798,7 +812,7 @@ impl Lexer for Language { // Skip a character if possible and if we didn't recognize a token None if input.peek().is_some() => { let _ = input.next(); - Some(ScannedToken::Single(TokenKind::SKIPPED)) + Some(ScannedToken::Single(TerminalKind::SKIPPED)) } None => None, } @@ -837,7 +851,7 @@ impl Language { )] pub fn parse_napi( &self, - #[napi(ts_arg_type = "kinds.RuleKind")] kind: RuleKind, + #[napi(ts_arg_type = "kinds.NonTerminalKind")] kind: NonTerminalKind, input: String, ) -> NAPIParseOutput { self.parse(kind, input.as_str()).into() diff --git a/crates/testlang/outputs/cargo/slang_testlang/src/generated/lexer.rs b/crates/testlang/outputs/cargo/slang_testlang/src/generated/lexer.rs index f11acf2d23..74af1b635f 100644 --- a/crates/testlang/outputs/cargo/slang_testlang/src/generated/lexer.rs +++ b/crates/testlang/outputs/cargo/slang_testlang/src/generated/lexer.rs @@ -1,7 +1,7 @@ // This file is generated automatically by infrastructure scripts. Please don't edit by hand. -use crate::cst::{self, LabeledNode}; -use crate::kinds::{IsLexicalContext, TokenKind}; +use crate::cst::{self, Edge}; +use crate::kinds::{IsLexicalContext, TerminalKind}; use crate::parser_support::{ParserContext, ParserResult}; /// Whether a keyword has been scanned and if so, whether it is reserved (unusable as an identifier) @@ -12,22 +12,22 @@ pub enum KeywordScan { Absent, /// The keyword is present, but is not reserved. #[allow(unused)] - Present(TokenKind), + Present(TerminalKind), /// The keyword is present and is reserved. - Reserved(TokenKind), + Reserved(TerminalKind), } #[derive(Debug, Clone, Copy, PartialEq, Eq)] pub enum ScannedToken { - Single(TokenKind), + Single(TerminalKind), IdentifierOrKeyword { - identifier: TokenKind, + identifier: TerminalKind, kw: KeywordScan, }, } impl ScannedToken { - pub fn accepted_as(self, expected: TokenKind) -> bool { + pub fn accepted_as(self, expected: TerminalKind) -> bool { match self { Self::Single(kind) => kind == expected, Self::IdentifierOrKeyword { identifier, kw } => match kw { @@ -42,7 +42,7 @@ impl ScannedToken { /// /// If the scanned token is an identifier, returns the specific keyword kind if the keyword is reserved, /// otherwise returns the general identifier kind. For other tokens, returns the token kind itself. - pub fn unambiguous(self) -> TokenKind { + pub fn unambiguous(self) -> TerminalKind { match self { Self::Single(kind) => kind, Self::IdentifierOrKeyword { identifier, kw } => match kw { @@ -69,7 +69,7 @@ pub(crate) trait Lexer { fn trailing_trivia(&self, input: &mut ParserContext<'_>) -> ParserResult; #[doc(hidden)] /// Returns valid grouping delimiters in the given lexical context. - fn delimiters() -> &'static [(TokenKind, TokenKind)]; + fn delimiters() -> &'static [(TerminalKind, TerminalKind)]; /// Peeks the next token, including trivia. Does not advance the input. fn peek_token( @@ -100,7 +100,7 @@ pub(crate) trait Lexer { fn parse_token( &self, input: &mut ParserContext<'_>, - kind: TokenKind, + kind: TerminalKind, ) -> ParserResult { let start = input.position(); if !self @@ -113,7 +113,7 @@ pub(crate) trait Lexer { let end = input.position(); ParserResult::r#match( - vec![LabeledNode::anonymous(cst::Node::token( + vec![Edge::anonymous(cst::Node::terminal( kind, input.content(start.utf8..end.utf8), ))], @@ -126,7 +126,7 @@ pub(crate) trait Lexer { fn parse_token_with_trivia( &self, input: &mut ParserContext<'_>, - kind: TokenKind, + kind: TerminalKind, ) -> ParserResult { let mut children = vec![]; @@ -146,7 +146,7 @@ pub(crate) trait Lexer { return ParserResult::no_match(vec![kind]); } let end = input.position(); - children.push(LabeledNode::anonymous(cst::Node::token( + children.push(Edge::anonymous(cst::Node::terminal( kind, input.content(start.utf8..end.utf8), ))); diff --git a/crates/testlang/outputs/cargo/slang_testlang/src/generated/mod.rs b/crates/testlang/outputs/cargo/slang_testlang/src/generated/mod.rs index 93a1bebed4..a1cc11707a 100644 --- a/crates/testlang/outputs/cargo/slang_testlang/src/generated/mod.rs +++ b/crates/testlang/outputs/cargo/slang_testlang/src/generated/mod.rs @@ -30,9 +30,9 @@ mod metaslang_cst { pub enum KindTypes {} impl metaslang_cst::KindTypes for KindTypes { - type NonTerminalKind = crate::kinds::RuleKind; - type TerminalKind = crate::kinds::TokenKind; - type EdgeKind = crate::kinds::NodeLabel; + type NonTerminalKind = crate::kinds::NonTerminalKind; + type TerminalKind = crate::kinds::TerminalKind; + type EdgeLabel = crate::kinds::EdgeLabel; } } @@ -42,9 +42,9 @@ pub mod cst { use super::metaslang_cst::KindTypes; pub type Node = cst::Node; - pub type RuleNode = cst::NonTerminalNode; - pub type TokenNode = cst::TerminalNode; - pub type LabeledNode = cst::LabeledNode; + pub type NonTerminalNode = cst::NonTerminalNode; + pub type TerminalNode = cst::TerminalNode; + pub type Edge = cst::Edge; } pub mod cursor { @@ -53,7 +53,7 @@ pub mod cursor { use super::metaslang_cst::KindTypes; pub type Cursor = cursor::Cursor; - pub type CursorWithLabels = cursor::CursorWithLabels; + pub type CursorWithEdges = cursor::CursorWithEdges; } pub mod query { diff --git a/crates/testlang/outputs/cargo/slang_testlang/src/generated/napi_interface/cst.rs b/crates/testlang/outputs/cargo/slang_testlang/src/generated/napi_interface/cst.rs index f8a79d15a4..acb8369329 100644 --- a/crates/testlang/outputs/cargo/slang_testlang/src/generated/napi_interface/cst.rs +++ b/crates/testlang/outputs/cargo/slang_testlang/src/generated/napi_interface/cst.rs @@ -8,51 +8,51 @@ use napi_derive::napi; use crate::napi_interface::cursor::Cursor; use crate::napi_interface::text_index::TextIndex; use crate::napi_interface::{ - RuleKind, RustNode, RustRuleNode, RustTextIndex, RustTokenNode, TokenKind, + NonTerminalKind, RustNode, RustRuleNode, RustTextIndex, RustTokenNode, TerminalKind, }; #[napi(namespace = "cst", string_enum)] pub enum NodeType { - Rule, - Token, + NonTerminal, + Terminal, } pub trait NAPINodeExtensions { - fn into_js_either_node(self) -> Either; + fn into_js_either_node(self) -> Either; } impl NAPINodeExtensions for RustNode { - /// Converts the node into `napi` wrapper for `RuleNode | TokenNode` JS object. - fn into_js_either_node(self) -> Either { + /// Converts the node into `napi` wrapper for `NonTerminalNode | TerminalNode` JS object. + fn into_js_either_node(self) -> Either { match self { - RustNode::Rule(rule) => Either::A(RuleNode(rule)), - RustNode::Token(token) => Either::B(TokenNode(token)), + RustNode::NonTerminal(nonterminal) => Either::A(NonTerminalNode(nonterminal)), + RustNode::Terminal(terminal) => Either::B(TerminalNode(terminal)), } } } #[derive(Debug)] #[napi(namespace = "cst")] -pub struct RuleNode(pub(crate) Rc); +pub struct NonTerminalNode(pub(crate) Rc); #[derive(Debug)] #[napi(namespace = "cst")] -pub struct TokenNode(pub(crate) Rc); +pub struct TerminalNode(pub(crate) Rc); #[napi(namespace = "cst")] -impl RuleNode { +impl NonTerminalNode { #[napi( getter, js_name = "type", - ts_return_type = "NodeType.Rule", + ts_return_type = "NodeType.NonTerminal", catch_unwind )] pub fn tipe(&self) -> NodeType { - NodeType::Rule + NodeType::NonTerminal } - #[napi(getter, ts_return_type = "kinds.RuleKind", catch_unwind)] - pub fn kind(&self) -> RuleKind { + #[napi(getter, ts_return_type = "kinds.NonTerminalKind", catch_unwind)] + pub fn kind(&self) -> NonTerminalKind { self.0.kind } @@ -67,7 +67,7 @@ impl RuleNode { } #[napi(ts_return_type = "Array", catch_unwind)] - pub fn children(&self) -> Vec> { + pub fn children(&self) -> Vec> { self.0 .children .iter() @@ -80,7 +80,7 @@ impl RuleNode { &self, #[napi(ts_arg_type = "text_index.TextIndex")] text_offset: TextIndex, ) -> Cursor { - RustNode::Rule(Rc::clone(&self.0)) + RustNode::NonTerminal(Rc::clone(&self.0)) .cursor_with_offset(text_offset.into()) .into() } @@ -107,7 +107,7 @@ impl RuleNode { skip_typescript, catch_unwind )] - pub fn __children(&self) -> Vec> { + pub fn __children(&self) -> Vec> { Self::children(self) } @@ -127,19 +127,19 @@ impl RuleNode { } #[napi(namespace = "cst")] -impl TokenNode { +impl TerminalNode { #[napi( getter, js_name = "type", - ts_return_type = "NodeType.Token", + ts_return_type = "NodeType.Terminal", catch_unwind )] pub fn tipe(&self) -> NodeType { - NodeType::Token + NodeType::Terminal } - #[napi(getter, ts_return_type = "kinds.TokenKind", catch_unwind)] - pub fn kind(&self) -> TokenKind { + #[napi(getter, ts_return_type = "kinds.TerminalKind", catch_unwind)] + pub fn kind(&self) -> TerminalKind { self.0.kind } @@ -160,7 +160,7 @@ impl TokenNode { } #[napi(catch_unwind, js_name = "toJSON")] - /// Serialize the token node to JSON. + /// Serialize the terminal node to JSON. /// /// This method is intended for debugging purposes and may not be stable. pub fn to_json(&self) -> String { @@ -172,7 +172,7 @@ impl TokenNode { &self, #[napi(ts_arg_type = "text_index.TextIndex")] text_offset: TextIndex, ) -> Cursor { - RustNode::Token(Rc::clone(&self.0)) + RustNode::Terminal(Rc::clone(&self.0)) .cursor_with_offset(text_offset.into()) .into() } diff --git a/crates/testlang/outputs/cargo/slang_testlang/src/generated/napi_interface/cursor.rs b/crates/testlang/outputs/cargo/slang_testlang/src/generated/napi_interface/cursor.rs index 64356c7921..61da4beac9 100644 --- a/crates/testlang/outputs/cargo/slang_testlang/src/generated/napi_interface/cursor.rs +++ b/crates/testlang/outputs/cargo/slang_testlang/src/generated/napi_interface/cursor.rs @@ -9,8 +9,8 @@ use napi::Either; use napi_derive::napi; use text_index::{TextIndex, TextRange}; -use crate::napi_interface::cst::{self, NAPINodeExtensions, RuleNode, TokenNode}; -use crate::napi_interface::{text_index, NodeLabel, RuleKind, RustCursor, TokenKind}; +use crate::napi_interface::cst::{self, NAPINodeExtensions, NonTerminalNode, TerminalNode}; +use crate::napi_interface::{text_index, EdgeLabel, NonTerminalKind, RustCursor, TerminalKind}; #[napi(namespace = "cursor")] pub struct Cursor(pub(super) RustCursor); @@ -54,12 +54,12 @@ impl Cursor { } #[napi(ts_return_type = "cst.Node", catch_unwind)] - pub fn node(&self) -> Either { + pub fn node(&self) -> Either { self.0.node().into_js_either_node() } - #[napi(getter, ts_return_type = "kinds.NodeLabel", catch_unwind)] - pub fn label(&self) -> Option { + #[napi(getter, ts_return_type = "kinds.EdgeLabel", catch_unwind)] + pub fn label(&self) -> Option { self.0.label() } @@ -79,9 +79,9 @@ impl Cursor { self.0.depth() as u32 } - #[napi(ts_return_type = "Array", catch_unwind)] - pub fn ancestors(&self) -> Vec { - self.0.ancestors().map(cst::RuleNode).collect() + #[napi(ts_return_type = "Array", catch_unwind)] + pub fn ancestors(&self) -> Vec { + self.0.ancestors().map(cst::NonTerminalNode).collect() } #[napi(catch_unwind)] @@ -130,44 +130,44 @@ impl Cursor { } #[napi(catch_unwind)] - pub fn go_to_next_token(&mut self) -> bool { - self.0.go_to_next_token() + pub fn go_to_next_terminal(&mut self) -> bool { + self.0.go_to_next_terminal() } #[napi(catch_unwind)] - pub fn go_to_next_token_with_kind( + pub fn go_to_next_terminal_with_kind( &mut self, - #[napi(ts_arg_type = "kinds.TokenKind")] kind: TokenKind, + #[napi(ts_arg_type = "kinds.TerminalKind")] kind: TerminalKind, ) -> bool { - self.0.go_to_next_token_with_kind(kind) + self.0.go_to_next_terminal_with_kind(kind) } #[napi(catch_unwind)] pub fn go_to_next_token_with_kinds( &mut self, - #[napi(ts_arg_type = "Array")] kinds: Vec, + #[napi(ts_arg_type = "Array")] kinds: Vec, ) -> bool { - self.0.go_to_next_token_with_kinds(&kinds) + self.0.go_to_next_terminal_with_kinds(&kinds) } #[napi(catch_unwind)] - pub fn go_to_next_rule(&mut self) -> bool { - self.0.go_to_next_rule() + pub fn go_to_next_nonterminal(&mut self) -> bool { + self.0.go_to_next_nonterminal() } #[napi(catch_unwind)] - pub fn go_to_next_rule_with_kind( + pub fn go_to_next_nonterminal_with_kind( &mut self, - #[napi(ts_arg_type = "kinds.RuleKind")] kind: RuleKind, + #[napi(ts_arg_type = "kinds.NonTerminalKind")] kind: NonTerminalKind, ) -> bool { - self.0.go_to_next_rule_with_kind(kind) + self.0.go_to_next_nonterminal_with_kind(kind) } #[napi(catch_unwind)] - pub fn go_to_next_rule_with_kinds( + pub fn go_to_next_nonterminal_with_kinds( &mut self, - #[napi(ts_arg_type = "Array")] kinds: Vec, + #[napi(ts_arg_type = "Array")] kinds: Vec, ) -> bool { - self.0.go_to_next_rule_with_kinds(&kinds) + self.0.go_to_next_nonterminal_with_kinds(&kinds) } } diff --git a/crates/testlang/outputs/cargo/slang_testlang/src/generated/napi_interface/generated/ast_selectors.rs b/crates/testlang/outputs/cargo/slang_testlang/src/generated/napi_interface/generated/ast_selectors.rs index 3e0afe63b6..4d4aa3040a 100644 --- a/crates/testlang/outputs/cargo/slang_testlang/src/generated/napi_interface/generated/ast_selectors.rs +++ b/crates/testlang/outputs/cargo/slang_testlang/src/generated/napi_interface/generated/ast_selectors.rs @@ -7,8 +7,10 @@ use std::rc::Rc; use napi::Either; use napi_derive::napi; -use crate::napi_interface::cst::{NAPINodeExtensions, RuleNode, TokenNode}; -use crate::napi_interface::{RuleKind, RustLabeledNode, RustNode, RustRuleNode, TokenKind}; +use crate::napi_interface::cst::{NAPINodeExtensions, NonTerminalNode, TerminalNode}; +use crate::napi_interface::{ + NonTerminalKind, RustLabeledNode, RustNode, RustRuleNode, TerminalKind, +}; // // Sequences: @@ -20,17 +22,17 @@ use crate::napi_interface::{RuleKind, RustLabeledNode, RustNode, RustRuleNode, T catch_unwind )] pub fn select_sequence( - #[napi(ts_arg_type = "cst.RuleNode")] node: &RuleNode, -) -> Result>>> { + #[napi(ts_arg_type = "cst.NonTerminalNode")] node: &NonTerminalNode, +) -> Result>>> { let mut selector = Selector::new(node); let result = match node.kind() { - RuleKind::SourceUnit => selector.source_unit()?, - RuleKind::Tree => selector.tree()?, - RuleKind::TreeNode => selector.tree_node()?, - RuleKind::AdditionExpression => selector.addition_expression()?, - RuleKind::NegationExpression => selector.negation_expression()?, - RuleKind::MemberAccessExpression => selector.member_access_expression()?, + NonTerminalKind::SourceUnit => selector.source_unit()?, + NonTerminalKind::Tree => selector.tree()?, + NonTerminalKind::TreeNode => selector.tree_node()?, + NonTerminalKind::AdditionExpression => selector.addition_expression()?, + NonTerminalKind::NegationExpression => selector.negation_expression()?, + NonTerminalKind::MemberAccessExpression => selector.member_access_expression()?, _ => { return Error::UnexpectedParent(node.kind()).into(); } @@ -40,59 +42,69 @@ pub fn select_sequence( Ok(result) } impl Selector { - fn source_unit(&mut self) -> Result>>> { + fn source_unit(&mut self) -> Result>>> { Ok(vec![Some(self.select(|node| { - node.is_rule_with_kind(RuleKind::SourceUnitMembers) + node.is_nonterminal_with_kind(NonTerminalKind::SourceUnitMembers) })?)]) } } impl Selector { - fn tree(&mut self) -> Result>>> { + fn tree(&mut self) -> Result>>> { Ok(vec![ - Some(self.select(|node| node.is_token_with_kind(TokenKind::TreeKeyword))?), - self.try_select(|node| node.is_token_with_kind(TokenKind::Identifier))?, - Some(self.select(|node| node.is_rule_with_kind(RuleKind::TreeNode))?), - Some(self.select(|node| node.is_token_with_kind(TokenKind::Semicolon))?), + Some(self.select(|node| node.is_terminal_with_kind(TerminalKind::TreeKeyword))?), + self.try_select(|node| node.is_terminal_with_kind(TerminalKind::Identifier))?, + Some(self.select(|node| node.is_nonterminal_with_kind(NonTerminalKind::TreeNode))?), + Some(self.select(|node| node.is_terminal_with_kind(TerminalKind::Semicolon))?), ]) } } impl Selector { - fn tree_node(&mut self) -> Result>>> { + fn tree_node(&mut self) -> Result>>> { Ok(vec![ - Some(self.select(|node| node.is_token_with_kind(TokenKind::OpenBracket))?), - Some(self.select(|node| node.is_rule_with_kind(RuleKind::TreeNodeChildren))?), - Some(self.select(|node| node.is_token_with_kind(TokenKind::CloseBracket))?), + Some(self.select(|node| node.is_terminal_with_kind(TerminalKind::OpenBracket))?), + Some( + self.select(|node| { + node.is_nonterminal_with_kind(NonTerminalKind::TreeNodeChildren) + })?, + ), + Some(self.select(|node| node.is_terminal_with_kind(TerminalKind::CloseBracket))?), ]) } } impl Selector { - fn addition_expression(&mut self) -> Result>>> { + fn addition_expression( + &mut self, + ) -> Result>>> { Ok(vec![ - Some(self.select(|node| node.is_rule_with_kind(RuleKind::Expression))?), - Some(self.select(|node| node.is_token_with_kind(TokenKind::Plus))?), - Some(self.select(|node| node.is_rule_with_kind(RuleKind::Expression))?), + Some(self.select(|node| node.is_nonterminal_with_kind(NonTerminalKind::Expression))?), + Some(self.select(|node| node.is_terminal_with_kind(TerminalKind::Plus))?), + Some(self.select(|node| node.is_nonterminal_with_kind(NonTerminalKind::Expression))?), ]) } } impl Selector { - fn negation_expression(&mut self) -> Result>>> { + fn negation_expression( + &mut self, + ) -> Result>>> { Ok(vec![ - Some(self.select(|node| node.is_token_with_kind(TokenKind::Bang))?), - Some(self.select(|node| node.is_rule_with_kind(RuleKind::Expression))?), + Some(self.select(|node| node.is_terminal_with_kind(TerminalKind::Bang))?), + Some(self.select(|node| node.is_nonterminal_with_kind(NonTerminalKind::Expression))?), ]) } } impl Selector { - fn member_access_expression(&mut self) -> Result>>> { + fn member_access_expression( + &mut self, + ) -> Result>>> { Ok(vec![ - Some(self.select(|node| node.is_rule_with_kind(RuleKind::Expression))?), - Some(self.select(|node| node.is_token_with_kind(TokenKind::Period))?), - Some(self.select(|node| node.is_token_with_kind(TokenKind::Identifier))?), + Some(self.select(|node| node.is_nonterminal_with_kind(NonTerminalKind::Expression))?), + Some(self.select(|node| node.is_terminal_with_kind(TerminalKind::Period))?), + Some(self.select(|node| node.is_terminal_with_kind(TerminalKind::Identifier))?), ]) } } @@ -102,15 +114,15 @@ impl Selector { #[napi(namespace = "ast_internal", ts_return_type = "cst.Node", catch_unwind)] pub fn select_choice( - #[napi(ts_arg_type = "cst.RuleNode")] node: &RuleNode, -) -> Result> { + #[napi(ts_arg_type = "cst.NonTerminalNode")] node: &NonTerminalNode, +) -> Result> { let mut selector = Selector::new(node); let result = match node.kind() { - RuleKind::SourceUnitMember => selector.source_unit_member()?, - RuleKind::TreeNodeChild => selector.tree_node_child()?, - RuleKind::Expression => selector.expression()?, - RuleKind::Literal => selector.literal()?, + NonTerminalKind::SourceUnitMember => selector.source_unit_member()?, + NonTerminalKind::TreeNodeChild => selector.tree_node_child()?, + NonTerminalKind::Expression => selector.expression()?, + NonTerminalKind::Literal => selector.literal()?, _ => { return Error::UnexpectedParent(node.kind()).into(); } @@ -121,42 +133,43 @@ pub fn select_choice( } impl Selector { - fn source_unit_member(&mut self) -> Result> { + fn source_unit_member(&mut self) -> Result> { self.select(|node| { - node.is_rule_with_kinds(&[ - RuleKind::Tree, - RuleKind::Expression, - RuleKind::SeparatedIdentifiers, - RuleKind::Literal, + node.is_nonterminal_with_kinds(&[ + NonTerminalKind::Tree, + NonTerminalKind::Expression, + NonTerminalKind::SeparatedIdentifiers, + NonTerminalKind::Literal, ]) }) } } impl Selector { - fn tree_node_child(&mut self) -> Result> { + fn tree_node_child(&mut self) -> Result> { self.select(|node| { - node.is_rule_with_kind(RuleKind::TreeNode) - || node.is_token_with_kind(TokenKind::DelimitedIdentifier) + node.is_nonterminal_with_kind(NonTerminalKind::TreeNode) + || node.is_terminal_with_kind(TerminalKind::DelimitedIdentifier) }) } } impl Selector { - fn expression(&mut self) -> Result> { + fn expression(&mut self) -> Result> { self.select(|node| { - node.is_rule_with_kinds(&[ - RuleKind::AdditionExpression, - RuleKind::NegationExpression, - RuleKind::MemberAccessExpression, - ]) || node.is_token_with_kinds(&[TokenKind::StringLiteral, TokenKind::Identifier]) + node.is_nonterminal_with_kinds(&[ + NonTerminalKind::AdditionExpression, + NonTerminalKind::NegationExpression, + NonTerminalKind::MemberAccessExpression, + ]) || node + .is_terminal_with_kinds(&[TerminalKind::StringLiteral, TerminalKind::Identifier]) }) } } impl Selector { - fn literal(&mut self) -> Result> { - self.select(|node| node.is_token_with_kind(TokenKind::StringLiteral)) + fn literal(&mut self) -> Result> { + self.select(|node| node.is_terminal_with_kind(TerminalKind::StringLiteral)) } } @@ -170,13 +183,13 @@ impl Selector { catch_unwind )] pub fn select_repeated( - #[napi(ts_arg_type = "cst.RuleNode")] node: &RuleNode, -) -> Result>> { + #[napi(ts_arg_type = "cst.NonTerminalNode")] node: &NonTerminalNode, +) -> Result>> { let mut selector = Selector::new(node); let result = match node.kind() { - RuleKind::SourceUnitMembers => selector.source_unit_members()?, - RuleKind::TreeNodeChildren => selector.tree_node_children()?, + NonTerminalKind::SourceUnitMembers => selector.source_unit_members()?, + NonTerminalKind::TreeNodeChildren => selector.tree_node_children()?, _ => { return Error::UnexpectedParent(node.kind()).into(); } @@ -187,11 +200,11 @@ pub fn select_repeated( } impl Selector { - fn source_unit_members(&mut self) -> Result>> { + fn source_unit_members(&mut self) -> Result>> { let mut items = vec![]; - while let Some(item) = - self.try_select(|node| node.is_rule_with_kind(RuleKind::SourceUnitMember))? + while let Some(item) = self + .try_select(|node| node.is_nonterminal_with_kind(NonTerminalKind::SourceUnitMember))? { items.push(item); } @@ -201,11 +214,11 @@ impl Selector { } impl Selector { - fn tree_node_children(&mut self) -> Result>> { + fn tree_node_children(&mut self) -> Result>> { let mut items = vec![]; while let Some(item) = - self.try_select(|node| node.is_rule_with_kind(RuleKind::TreeNodeChild))? + self.try_select(|node| node.is_nonterminal_with_kind(NonTerminalKind::TreeNodeChild))? { items.push(item); } @@ -224,12 +237,12 @@ impl Selector { catch_unwind )] pub fn select_separated( - #[napi(ts_arg_type = "cst.RuleNode")] node: &RuleNode, -) -> Result>>> { + #[napi(ts_arg_type = "cst.NonTerminalNode")] node: &NonTerminalNode, +) -> Result>>> { let mut selector = Selector::new(node); let result = match node.kind() { - RuleKind::SeparatedIdentifiers => selector.separated_identifiers()?, + NonTerminalKind::SeparatedIdentifiers => selector.separated_identifiers()?, _ => { return Error::UnexpectedParent(node.kind()).into(); } @@ -240,21 +253,23 @@ pub fn select_separated( } impl Selector { - fn separated_identifiers(&mut self) -> Result>>> { + fn separated_identifiers(&mut self) -> Result>>> { let mut separated = vec![]; let mut separators = vec![]; if let Some(first) = - self.try_select(|node| node.is_token_with_kind(TokenKind::Identifier))? + self.try_select(|node| node.is_terminal_with_kind(TerminalKind::Identifier))? { separated.push(first); while let Some(separator) = - self.try_select(|node| node.is_token_with_kind(TokenKind::Period))? + self.try_select(|node| node.is_terminal_with_kind(TerminalKind::Period))? { separators.push(separator); - separated.push(self.select(|node| node.is_token_with_kind(TokenKind::Identifier))?); + separated.push( + self.select(|node| node.is_terminal_with_kind(TerminalKind::Identifier))?, + ); } } @@ -272,7 +287,7 @@ struct Selector { } impl Selector { - fn new(node: &RuleNode) -> Self { + fn new(node: &NonTerminalNode) -> Self { Self { node: Rc::clone(&node.0), index: 0, @@ -282,7 +297,7 @@ impl Selector { fn select( &mut self, filter: impl FnOnce(&RustNode) -> bool, - ) -> Result> { + ) -> Result> { match self.try_select(filter)? { Some(node) => Ok(node), None => Error::MissingChild(self.index).into(), @@ -292,7 +307,7 @@ impl Selector { fn try_select( &mut self, filter: impl FnOnce(&RustNode) -> bool, - ) -> Result>> { + ) -> Result>> { while let Some(child) = self.node.children.get(self.index) { match child { node if node.is_trivia() => { @@ -301,9 +316,9 @@ impl Selector { continue; } RustLabeledNode { - label: _, - node: RustNode::Token(token), - } if matches!(token.kind, TokenKind::SKIPPED) => { + node: RustNode::Terminal(terminal), + .. + } if matches!(terminal.kind, TerminalKind::SKIPPED) => { return Error::SkippedToken(self.index).into(); } labeled if filter(labeled) => { @@ -333,8 +348,8 @@ type Result = std::result::Result; #[derive(Debug, thiserror::Error)] enum Error { // Should not theoretically happen, since we're only called from our own generated AST types. - #[error("Unexpected parent node with RuleKind '{0}'.")] - UnexpectedParent(RuleKind), + #[error("Unexpected parent node with NonTerminalKind '{0}'.")] + UnexpectedParent(NonTerminalKind), // Should not theoretically happen, since we're only called from our own generated AST types. #[error("Unexpected trailing children at index '{0}'.")] diff --git a/crates/testlang/outputs/cargo/slang_testlang/src/generated/napi_interface/mod.rs b/crates/testlang/outputs/cargo/slang_testlang/src/generated/napi_interface/mod.rs index 2035b95f64..d2ab8551a8 100644 --- a/crates/testlang/outputs/cargo/slang_testlang/src/generated/napi_interface/mod.rs +++ b/crates/testlang/outputs/cargo/slang_testlang/src/generated/napi_interface/mod.rs @@ -11,18 +11,18 @@ pub mod text_index; pub mod ast_selectors; type RustCursor = crate::cursor::Cursor; -type RustLabeledNode = crate::cst::LabeledNode; +type RustLabeledNode = crate::cst::Edge; type RustNode = crate::cst::Node; type RustParseError = crate::parse_error::ParseError; type RustParseOutput = crate::parse_output::ParseOutput; type RustQuery = crate::query::Query; type RustQueryResult = crate::query::QueryResult; type RustQueryResultIterator = crate::query::QueryResultIterator; -type RustRuleNode = crate::cst::RuleNode; +type RustRuleNode = crate::cst::NonTerminalNode; type RustTextIndex = crate::text_index::TextIndex; type RustTextRange = crate::text_index::TextRange; -type RustTokenNode = crate::cst::TokenNode; +type RustTokenNode = crate::cst::TerminalNode; -type RuleKind = crate::kinds::RuleKind; -type TokenKind = crate::kinds::TokenKind; -type NodeLabel = crate::kinds::NodeLabel; +type NonTerminalKind = crate::kinds::NonTerminalKind; +type TerminalKind = crate::kinds::TerminalKind; +type EdgeLabel = crate::kinds::EdgeLabel; diff --git a/crates/testlang/outputs/cargo/slang_testlang/src/generated/napi_interface/parse_output.rs b/crates/testlang/outputs/cargo/slang_testlang/src/generated/napi_interface/parse_output.rs index dd162e213b..573b75ab1f 100644 --- a/crates/testlang/outputs/cargo/slang_testlang/src/generated/napi_interface/parse_output.rs +++ b/crates/testlang/outputs/cargo/slang_testlang/src/generated/napi_interface/parse_output.rs @@ -3,7 +3,7 @@ use napi::Either; use napi_derive::napi; -use crate::napi_interface::cst::{NAPINodeExtensions, RuleNode, TokenNode}; +use crate::napi_interface::cst::{NAPINodeExtensions, NonTerminalNode, TerminalNode}; use crate::napi_interface::{cursor, parse_error, RustParseOutput}; #[napi(namespace = "parse_output")] @@ -18,7 +18,7 @@ impl From for ParseOutput { #[napi(namespace = "parse_output")] impl ParseOutput { #[napi(ts_return_type = "cst.Node", catch_unwind)] - pub fn tree(&self) -> Either { + pub fn tree(&self) -> Either { self.0.tree().into_js_either_node() } diff --git a/crates/testlang/outputs/cargo/slang_testlang/src/generated/parse_error.rs b/crates/testlang/outputs/cargo/slang_testlang/src/generated/parse_error.rs index f6c3d9b52c..4553de4e78 100644 --- a/crates/testlang/outputs/cargo/slang_testlang/src/generated/parse_error.rs +++ b/crates/testlang/outputs/cargo/slang_testlang/src/generated/parse_error.rs @@ -2,13 +2,13 @@ use std::collections::BTreeSet; -use crate::kinds::TokenKind; +use crate::kinds::TerminalKind; use crate::text_index::{TextRange, TextRangeExtensions}; #[derive(Debug, PartialEq, Eq, Clone)] pub struct ParseError { pub(crate) text_range: TextRange, - pub(crate) tokens_that_would_have_allowed_more_progress: Vec, + pub(crate) tokens_that_would_have_allowed_more_progress: Vec, } impl ParseError { @@ -24,7 +24,7 @@ impl ParseError { tokens_that_would_have_allowed_more_progress .into_iter() - .map(TokenKind::to_string) + .map(TerminalKind::to_string) .collect() } @@ -36,7 +36,7 @@ impl ParseError { impl ParseError { pub(crate) fn new( text_range: TextRange, - tokens_that_would_have_allowed_more_progress: Vec, + tokens_that_would_have_allowed_more_progress: Vec, ) -> Self { Self { text_range, diff --git a/crates/testlang/outputs/cargo/slang_testlang/src/generated/parser_support/choice_helper.rs b/crates/testlang/outputs/cargo/slang_testlang/src/generated/parser_support/choice_helper.rs index e24443c826..9efafc325e 100644 --- a/crates/testlang/outputs/cargo/slang_testlang/src/generated/parser_support/choice_helper.rs +++ b/crates/testlang/outputs/cargo/slang_testlang/src/generated/parser_support/choice_helper.rs @@ -4,7 +4,7 @@ use std::mem; use std::ops::ControlFlow; use crate::cst; -use crate::kinds::TokenKind; +use crate::kinds::TerminalKind; use crate::parse_error::ParseError; use crate::parser_support::context::{Marker, ParserContext}; use crate::parser_support::ParserResult; @@ -139,7 +139,9 @@ pub fn total_not_skipped_span(result: &ParserResult) -> usize { .iter() .flat_map(|child| child.cursor_with_offset(TextIndex::ZERO)) .filter_map(|node| match node { - cst::Node::Token(token) if token.kind != TokenKind::SKIPPED => Some(token.text.len()), + cst::Node::Terminal(terminal) if terminal.kind != TerminalKind::SKIPPED => { + Some(terminal.text.len()) + } _ => None, }) .sum() diff --git a/crates/testlang/outputs/cargo/slang_testlang/src/generated/parser_support/context.rs b/crates/testlang/outputs/cargo/slang_testlang/src/generated/parser_support/context.rs index 51a32d1632..6752a6f422 100644 --- a/crates/testlang/outputs/cargo/slang_testlang/src/generated/parser_support/context.rs +++ b/crates/testlang/outputs/cargo/slang_testlang/src/generated/parser_support/context.rs @@ -3,7 +3,7 @@ use std::mem; use std::ops::Range; -use crate::kinds::TokenKind; +use crate::kinds::TerminalKind; use crate::parse_error::ParseError; use crate::text_index::TextIndex; @@ -13,7 +13,7 @@ pub struct ParserContext<'s> { position: TextIndex, undo_position: Option, errors: Vec, - closing_delimiters: Vec, + closing_delimiters: Vec, } #[derive(Copy, Clone)] @@ -63,7 +63,10 @@ impl<'s> ParserContext<'s> { } /// Creates a RAII guard that will pop the closing delimiter when dropped. - pub(crate) fn open_delim<'a>(&'a mut self, closing_delim: TokenKind) -> DelimiterGuard<'a, 's> { + pub(crate) fn open_delim<'a>( + &'a mut self, + closing_delim: TerminalKind, + ) -> DelimiterGuard<'a, 's> { self.closing_delimiters.push(closing_delim); DelimiterGuard { @@ -72,7 +75,7 @@ impl<'s> ParserContext<'s> { } } - pub fn closing_delimiters(&self) -> &[TokenKind] { + pub fn closing_delimiters(&self) -> &[TerminalKind] { &self.closing_delimiters } @@ -114,7 +117,7 @@ impl<'s> ParserContext<'s> { pub(crate) struct DelimiterGuard<'a, 's> { pub(crate) input: &'a mut ParserContext<'s>, - closing_delim: TokenKind, + closing_delim: TerminalKind, } impl Drop for DelimiterGuard<'_, '_> { diff --git a/crates/testlang/outputs/cargo/slang_testlang/src/generated/parser_support/parser_function.rs b/crates/testlang/outputs/cargo/slang_testlang/src/generated/parser_support/parser_function.rs index c38482610d..4721491788 100644 --- a/crates/testlang/outputs/cargo/slang_testlang/src/generated/parser_support/parser_function.rs +++ b/crates/testlang/outputs/cargo/slang_testlang/src/generated/parser_support/parser_function.rs @@ -2,8 +2,8 @@ use std::rc::Rc; -use crate::cst::{self, LabeledNode}; -use crate::kinds::TokenKind; +use crate::cst::{self, Edge}; +use crate::kinds::TerminalKind; use crate::lexer::Lexer; use crate::parse_error::ParseError; use crate::parse_output::ParseOutput; @@ -42,11 +42,13 @@ where _ => None, }; - if let (cst::Node::Rule(rule), Some(eof_trivia)) = (&mut topmost.node, eof_trivia) { - let mut new_children = rule.children.clone(); + if let (cst::Node::NonTerminal(nonterminal), Some(eof_trivia)) = + (&mut topmost.node, eof_trivia) + { + let mut new_children = nonterminal.children.clone(); new_children.extend(eof_trivia); - topmost.node = cst::Node::rule(rule.kind, new_children); + topmost.node = cst::Node::nonterminal(nonterminal.kind, new_children); } } @@ -57,7 +59,7 @@ where ParserResult::PrattOperatorMatch(..) => unreachable!("PrattOperatorMatch is internal"), ParserResult::NoMatch(no_match) => ParseOutput { - parse_tree: cst::Node::token(TokenKind::SKIPPED, input.to_string()), + parse_tree: cst::Node::terminal(TerminalKind::SKIPPED, input.to_string()), errors: vec![ParseError::new( TextIndex::ZERO..input.into(), no_match.expected_tokens, @@ -82,8 +84,8 @@ where }) => (nodes, vec![expected]), }; - let topmost_rule = match &nodes[..] { - [LabeledNode { node: cst::Node::Rule(rule), ..} ] => Rc::clone(rule), + let topmost_node = match &nodes[..] { + [Edge { node: cst::Node::NonTerminal(nonterminal), ..} ] => Rc::clone(nonterminal), [_] => unreachable!( "(Incomplete)Match at the top level of a parser is not a Rule node" ), @@ -99,24 +101,24 @@ where // so needs a separate check here. if start.utf8 < input.len() || is_incomplete || is_recovering { let start = if is_recovering { - topmost_rule.text_len + topmost_node.text_len } else { start }; let skipped_node = - cst::Node::token(TokenKind::SKIPPED, input[start.utf8..].to_string()); - let mut new_children = topmost_rule.children.clone(); - new_children.push(LabeledNode::anonymous(skipped_node)); + cst::Node::terminal(TerminalKind::SKIPPED, input[start.utf8..].to_string()); + let mut new_children = topmost_node.children.clone(); + new_children.push(Edge::anonymous(skipped_node)); let mut errors = stream.into_errors(); errors.push(ParseError::new(start..input.into(), expected_tokens)); ParseOutput { - parse_tree: cst::Node::rule(topmost_rule.kind, new_children), + parse_tree: cst::Node::nonterminal(topmost_node.kind, new_children), errors, } } else { - let parse_tree = cst::Node::Rule(topmost_rule); + let parse_tree = cst::Node::NonTerminal(topmost_node); let errors = stream.into_errors(); // Sanity check: Make sure that succesful parse is equivalent to not having any SKIPPED nodes @@ -124,7 +126,9 @@ where errors.is_empty(), parse_tree .cursor_with_offset(TextIndex::ZERO) - .all(|node| node.as_token_with_kind(TokenKind::SKIPPED).is_none()) + .all(|node| node + .as_terminal_with_kind(TerminalKind::SKIPPED) + .is_none()) ); ParseOutput { parse_tree, errors } diff --git a/crates/testlang/outputs/cargo/slang_testlang/src/generated/parser_support/parser_result.rs b/crates/testlang/outputs/cargo/slang_testlang/src/generated/parser_support/parser_result.rs index f86d384932..f9a192912e 100644 --- a/crates/testlang/outputs/cargo/slang_testlang/src/generated/parser_support/parser_result.rs +++ b/crates/testlang/outputs/cargo/slang_testlang/src/generated/parser_support/parser_result.rs @@ -2,10 +2,10 @@ use std::ops::ControlFlow; -use metaslang_cst::TerminalKind; +use metaslang_cst::TerminalKind as _; -use crate::cst::{self, LabeledNode, Node}; -use crate::kinds::{NodeLabel, RuleKind, TokenKind}; +use crate::cst::{self, Edge, Node}; +use crate::kinds::{EdgeLabel, NonTerminalKind, TerminalKind}; use crate::text_index::TextIndex; #[derive(PartialEq, Eq, Clone, Debug)] @@ -26,7 +26,7 @@ impl Default for ParserResult { } impl ParserResult { - pub fn r#match(nodes: Vec, expected_tokens: Vec) -> Self { + pub fn r#match(nodes: Vec, expected_tokens: Vec) -> Self { ParserResult::Match(Match::new(nodes, expected_tokens)) } @@ -34,7 +34,7 @@ impl ParserResult { ParserResult::PrattOperatorMatch(PrattOperatorMatch::new(elements)) } - pub fn incomplete_match(nodes: Vec, expected_tokens: Vec) -> Self { + pub fn incomplete_match(nodes: Vec, expected_tokens: Vec) -> Self { ParserResult::IncompleteMatch(IncompleteMatch::new(nodes, expected_tokens)) } @@ -43,29 +43,29 @@ impl ParserResult { Self::no_match(vec![]) } - pub fn no_match(expected_tokens: Vec) -> Self { + pub fn no_match(expected_tokens: Vec) -> Self { ParserResult::NoMatch(NoMatch::new(expected_tokens)) } #[must_use] - pub fn with_kind(self, new_kind: RuleKind) -> ParserResult { + pub fn with_kind(self, new_kind: NonTerminalKind) -> ParserResult { match self { ParserResult::Match(r#match) => ParserResult::r#match( - vec![LabeledNode::anonymous(cst::Node::rule( + vec![Edge::anonymous(cst::Node::nonterminal( new_kind, r#match.nodes, ))], r#match.expected_tokens, ), ParserResult::IncompleteMatch(incomplete_match) => ParserResult::incomplete_match( - vec![LabeledNode::anonymous(cst::Node::rule( + vec![Edge::anonymous(cst::Node::nonterminal( new_kind, incomplete_match.nodes, ))], incomplete_match.expected_tokens, ), ParserResult::SkippedUntil(skipped) => ParserResult::SkippedUntil(SkippedUntil { - nodes: vec![LabeledNode::anonymous(cst::Node::rule( + nodes: vec![Edge::anonymous(cst::Node::nonterminal( new_kind, skipped.nodes, ))], @@ -73,14 +73,14 @@ impl ParserResult { }), ParserResult::NoMatch(_) => self, ParserResult::PrattOperatorMatch(_) => { - unreachable!("PrattOperatorMatch cannot be converted to a rule") + unreachable!("PrattOperatorMatch cannot be converted to a nonterminal") } } } #[must_use] - pub fn with_label(mut self, label: NodeLabel) -> ParserResult { - if let Some(LabeledNode { + pub fn with_label(mut self, label: EdgeLabel) -> ParserResult { + if let Some(Edge { label: prev_label, .. }) = self.significant_node_mut() { @@ -89,7 +89,7 @@ impl ParserResult { // Also allow to name a single trivia token node else if let ParserResult::Match(Match { nodes, .. }) = &mut self { if let [node] = nodes.as_mut_slice() { - if node.as_token().is_some_and(|tok| tok.kind.is_trivia()) { + if node.as_terminal().is_some_and(|tok| tok.kind.is_trivia()) { node.label = Some(label); } } @@ -99,7 +99,7 @@ impl ParserResult { } /// Returns a significant (non-trivia) node if there is exactly one. - pub(crate) fn significant_node_mut(&mut self) -> Option<&mut cst::LabeledNode> { + pub(crate) fn significant_node_mut(&mut self) -> Option<&mut cst::Edge> { let nodes = match self { ParserResult::Match(r#match) => &mut r#match.nodes[..], ParserResult::IncompleteMatch(incomplete_match) => &mut incomplete_match.nodes[..], @@ -123,13 +123,13 @@ impl ParserResult { #[derive(PartialEq, Eq, Clone, Debug)] pub struct Match { - pub nodes: Vec, + pub nodes: Vec, /// Tokens that would have allowed for more progress. Collected for the purposes of error reporting. - pub expected_tokens: Vec, + pub expected_tokens: Vec, } impl Match { - pub fn new(nodes: Vec, expected_tokens: Vec) -> Self { + pub fn new(nodes: Vec, expected_tokens: Vec) -> Self { Self { nodes, expected_tokens, @@ -140,41 +140,41 @@ impl Match { self.nodes .iter() .flat_map(|node| node.cursor_with_offset(TextIndex::ZERO)) - .all(|node| node.as_token_with_kind(TokenKind::SKIPPED).is_none()) + .all(|node| node.as_terminal_with_kind(TerminalKind::SKIPPED).is_none()) } } #[derive(PartialEq, Eq, Clone, Debug)] pub enum PrattElement { Expression { - nodes: Vec, + nodes: Vec, }, Prefix { - kind: RuleKind, - nodes: Vec, + kind: NonTerminalKind, + nodes: Vec, right: u8, }, Binary { - kind: RuleKind, - nodes: Vec, + kind: NonTerminalKind, + nodes: Vec, left: u8, right: u8, }, Postfix { - kind: RuleKind, - nodes: Vec, + kind: NonTerminalKind, + nodes: Vec, left: u8, }, } impl PrattElement { - pub fn into_nodes(self) -> Vec { + pub fn into_nodes(self) -> Vec { match self { Self::Expression { nodes } => nodes, Self::Binary { kind, nodes, .. } | Self::Prefix { kind, nodes, .. } | Self::Postfix { kind, nodes, .. } => { - vec![LabeledNode::anonymous(cst::Node::rule(kind, nodes))] + vec![Edge::anonymous(cst::Node::nonterminal(kind, nodes))] } } } @@ -193,13 +193,13 @@ impl PrattOperatorMatch { #[derive(PartialEq, Eq, Clone, Debug)] pub struct IncompleteMatch { - pub nodes: Vec, + pub nodes: Vec, /// Tokens that would have allowed for more progress. Collected for the purposes of error reporting. - pub expected_tokens: Vec, + pub expected_tokens: Vec, } impl IncompleteMatch { - pub fn new(nodes: Vec, expected_tokens: Vec) -> Self { + pub fn new(nodes: Vec, expected_tokens: Vec) -> Self { Self { nodes, expected_tokens, @@ -214,7 +214,9 @@ impl IncompleteMatch { .flat_map(|node| node.cursor_with_offset(TextIndex::ZERO)) .try_fold(0u8, |mut acc, node| { match node { - Node::Token(tok) if tok.kind != TokenKind::SKIPPED && !tok.kind.is_trivia() => { + Node::Terminal(tok) + if tok.kind != TerminalKind::SKIPPED && !tok.kind.is_trivia() => + { acc += 1; } _ => {} @@ -237,22 +239,22 @@ impl IncompleteMatch { #[derive(PartialEq, Eq, Clone, Debug)] pub struct NoMatch { /// Tokens that would have allowed for more progress. Collected for the purposes of error reporting. - pub expected_tokens: Vec, + pub expected_tokens: Vec, } impl NoMatch { - pub fn new(expected_tokens: Vec) -> Self { + pub fn new(expected_tokens: Vec) -> Self { Self { expected_tokens } } } #[derive(PartialEq, Eq, Clone, Debug)] pub struct SkippedUntil { - pub nodes: Vec, + pub nodes: Vec, /// Skipped text following the last node pub skipped: String, /// At which token was the stream pointing at when we bailed - pub found: TokenKind, + pub found: TerminalKind, /// Token we expected to skip until - pub expected: TokenKind, + pub expected: TerminalKind, } diff --git a/crates/testlang/outputs/cargo/slang_testlang/src/generated/parser_support/precedence_helper.rs b/crates/testlang/outputs/cargo/slang_testlang/src/generated/parser_support/precedence_helper.rs index eee625e583..7d307a1c0d 100644 --- a/crates/testlang/outputs/cargo/slang_testlang/src/generated/parser_support/precedence_helper.rs +++ b/crates/testlang/outputs/cargo/slang_testlang/src/generated/parser_support/precedence_helper.rs @@ -1,7 +1,7 @@ // This file is generated automatically by infrastructure scripts. Please don't edit by hand. -use crate::cst::{self, LabeledNode}; -use crate::kinds::{NodeLabel, RuleKind}; +use crate::cst::{self, Edge}; +use crate::kinds::{EdgeLabel, NonTerminalKind}; use crate::parser_support::parser_result::PrattElement::{ self, Binary, Expression, Postfix, Prefix, }; @@ -10,7 +10,11 @@ use crate::parser_support::parser_result::{ParserResult, PrattOperatorMatch}; pub struct PrecedenceHelper; impl PrecedenceHelper { - pub fn to_prefix_operator(kind: RuleKind, right: u8, result: ParserResult) -> ParserResult { + pub fn to_prefix_operator( + kind: NonTerminalKind, + right: u8, + result: ParserResult, + ) -> ParserResult { match result { ParserResult::Match(r#match) => ParserResult::pratt_operator_match(vec![Prefix { nodes: r#match.nodes, @@ -24,7 +28,11 @@ impl PrecedenceHelper { } } - pub fn to_postfix_operator(kind: RuleKind, left: u8, result: ParserResult) -> ParserResult { + pub fn to_postfix_operator( + kind: NonTerminalKind, + left: u8, + result: ParserResult, + ) -> ParserResult { match result { ParserResult::Match(r#match) => ParserResult::pratt_operator_match(vec![Postfix { nodes: r#match.nodes, @@ -39,7 +47,7 @@ impl PrecedenceHelper { } pub fn to_binary_operator( - kind: RuleKind, + kind: NonTerminalKind, left: u8, right: u8, result: ParserResult, @@ -59,7 +67,10 @@ impl PrecedenceHelper { } #[allow(clippy::too_many_lines, clippy::redundant_else)] // Explicit on purpose, see below. - pub fn reduce_precedence_result(child_kind: RuleKind, result: ParserResult) -> ParserResult { + pub fn reduce_precedence_result( + child_kind: NonTerminalKind, + result: ParserResult, + ) -> ParserResult { // This requires some careful thinking. It could be more compact, // but I'm favouring obviousness here. That is also why there are // so many `unreachable!` - not only should they never be reached, @@ -151,23 +162,23 @@ impl PrecedenceHelper { // 2. Reduce the operator and it's child expressions to a new expression let make_expression = |left: Option, - kind: RuleKind, - nodes: Vec, + kind: NonTerminalKind, + nodes: Vec, right: Option| { assert!(left.is_some() || right.is_some()); let left_label = right .as_ref() - .map_or(NodeLabel::Operand, |_| NodeLabel::LeftOperand); + .map_or(EdgeLabel::Operand, |_| EdgeLabel::LeftOperand); let right_label = left .as_ref() - .map_or(NodeLabel::Operand, |_| NodeLabel::RightOperand); + .map_or(EdgeLabel::Operand, |_| EdgeLabel::RightOperand); let left_nodes = match left { Some(Expression { nodes }) => { - vec![LabeledNode { + vec![Edge { label: Some(left_label), - node: cst::Node::rule(child_kind, nodes), + node: cst::Node::nonterminal(child_kind, nodes), }] } None => vec![], @@ -176,9 +187,9 @@ impl PrecedenceHelper { let right_nodes = match right { Some(Expression { nodes }) => { - vec![LabeledNode { + vec![Edge { label: Some(right_label), - node: cst::Node::rule(child_kind, nodes), + node: cst::Node::nonterminal(child_kind, nodes), }] } None => vec![], @@ -188,9 +199,9 @@ impl PrecedenceHelper { let children = [left_nodes, nodes, right_nodes].concat(); Expression { - nodes: vec![LabeledNode { - label: Some(NodeLabel::Variant), - node: cst::Node::rule(kind, children), + nodes: vec![Edge { + label: Some(EdgeLabel::Variant), + node: cst::Node::nonterminal(kind, children), }], } }; diff --git a/crates/testlang/outputs/cargo/slang_testlang/src/generated/parser_support/recovery.rs b/crates/testlang/outputs/cargo/slang_testlang/src/generated/parser_support/recovery.rs index 76eed0ef80..7fceddc3ae 100644 --- a/crates/testlang/outputs/cargo/slang_testlang/src/generated/parser_support/recovery.rs +++ b/crates/testlang/outputs/cargo/slang_testlang/src/generated/parser_support/recovery.rs @@ -1,7 +1,7 @@ // This file is generated automatically by infrastructure scripts. Please don't edit by hand. use crate::cst; -use crate::kinds::{IsLexicalContext, TokenKind}; +use crate::kinds::{IsLexicalContext, TerminalKind}; use crate::lexer::{Lexer, ScannedToken}; use crate::parse_error::ParseError; use crate::parser_support::context::ParserContext; @@ -18,7 +18,7 @@ pub(crate) struct TokenAcceptanceThreshold(pub(crate) u8); fn opt_parse( input: &mut ParserContext<'_>, parse: impl Fn(&mut ParserContext<'_>) -> ParserResult, -) -> Vec { +) -> Vec { let start = input.position(); if let ParserResult::Match(r#match) = parse(input) { r#match.nodes @@ -40,7 +40,7 @@ impl ParserResult { self, input: &mut ParserContext<'_>, lexer: &L, - expected: TokenKind, + expected: TerminalKind, acceptance_threshold: TokenAcceptanceThreshold, ) -> ParserResult { enum ParseResultKind { @@ -122,8 +122,8 @@ impl ParserResult { pub(crate) fn skip_until_with_nested_delims( input: &mut ParserContext<'_>, lexer: &L, - until: TokenKind, -) -> Option<(TokenKind, TextRange)> { + until: TerminalKind, +) -> Option<(TerminalKind, TextRange)> { let delims = L::delimiters::(); let start = input.position(); diff --git a/crates/testlang/outputs/cargo/slang_testlang/src/generated/parser_support/separated_helper.rs b/crates/testlang/outputs/cargo/slang_testlang/src/generated/parser_support/separated_helper.rs index f107fd0cef..0c87c6aea2 100644 --- a/crates/testlang/outputs/cargo/slang_testlang/src/generated/parser_support/separated_helper.rs +++ b/crates/testlang/outputs/cargo/slang_testlang/src/generated/parser_support/separated_helper.rs @@ -1,7 +1,7 @@ // This file is generated automatically by infrastructure scripts. Please don't edit by hand. -use crate::cst::{self, LabeledNode}; -use crate::kinds::{IsLexicalContext, NodeLabel, TokenKind}; +use crate::cst::{self, Edge}; +use crate::kinds::{EdgeLabel, IsLexicalContext, TerminalKind}; use crate::lexer::Lexer; use crate::parse_error::ParseError; use crate::parser_support::parser_result::{ParserResult, SkippedUntil}; @@ -16,8 +16,8 @@ impl SeparatedHelper { input: &mut ParserContext<'_>, lexer: &L, body_parser: impl Fn(&mut ParserContext<'_>) -> ParserResult, - separator: TokenKind, - separator_label: NodeLabel, + separator: TerminalKind, + separator_label: EdgeLabel, ) -> ParserResult { let mut accum = vec![]; loop { @@ -55,8 +55,8 @@ impl SeparatedHelper { match skip_until_with_nested_delims::<_, LexCtx>(input, lexer, separator) { // A separator was found, so we can recover the incomplete match Some((found, skipped_range)) if found == separator => { - accum.push(LabeledNode::anonymous(cst::Node::token( - TokenKind::SKIPPED, + accum.push(Edge::anonymous(cst::Node::terminal( + TerminalKind::SKIPPED, input.content(skipped_range.utf8()), ))); input.emit(ParseError { diff --git a/crates/testlang/outputs/cargo/slang_testlang/src/generated/parser_support/sequence_helper.rs b/crates/testlang/outputs/cargo/slang_testlang/src/generated/parser_support/sequence_helper.rs index cecb10b5de..cd455cfcab 100644 --- a/crates/testlang/outputs/cargo/slang_testlang/src/generated/parser_support/sequence_helper.rs +++ b/crates/testlang/outputs/cargo/slang_testlang/src/generated/parser_support/sequence_helper.rs @@ -2,10 +2,10 @@ use std::ops::ControlFlow; -use metaslang_cst::TerminalKind; +use metaslang_cst::TerminalKind as _; -use crate::cst::{self, LabeledNode}; -use crate::kinds::{NodeLabel, TokenKind}; +use crate::cst::{self, Edge}; +use crate::kinds::{EdgeLabel, TerminalKind}; use crate::parser_support::parser_result::{Match, ParserResult, PrattElement, SkippedUntil}; /// Keeps accumulating parses sequentially until it hits an incomplete or no match. @@ -131,8 +131,8 @@ impl SequenceHelper { // Sanity check that we are recovering to the expected one. let next_token = next.nodes.iter().try_fold(None, |acc, node| { match &**node { - cst::Node::Token(token) if token.kind.is_trivia() => Ok(acc), - cst::Node::Token(token) => { + cst::Node::Terminal(token) if token.kind.is_trivia() => Ok(acc), + cst::Node::Terminal(token) => { match acc { None => Ok(Some(token.kind)), Some(..) => { @@ -141,16 +141,16 @@ impl SequenceHelper { } } } - cst::Node::Rule(rule) => { - debug_assert!(false, "Recovery skipped to a rule: {rule:?}"); + cst::Node::NonTerminal(node) => { + debug_assert!(false, "Recovery skipped to a nonterminal: {node:?}"); Err(()) } } }); debug_assert_eq!(next_token, Ok(Some(running.found))); - running.nodes.push(LabeledNode::anonymous(cst::Node::token( - TokenKind::SKIPPED, + running.nodes.push(Edge::anonymous(cst::Node::terminal( + TerminalKind::SKIPPED, std::mem::take(&mut running.skipped), ))); running.nodes.extend(next.nodes); @@ -199,7 +199,7 @@ impl SequenceHelper { /// Shorthand for `self.elem(value.with_label(label))`. pub fn elem_labeled( &mut self, - label: NodeLabel, + label: EdgeLabel, value: ParserResult, ) -> ControlFlow { self.elem(value.with_label(label)) diff --git a/crates/testlang/outputs/cargo/tests/src/query/engine_tests.rs b/crates/testlang/outputs/cargo/tests/src/query/engine_tests.rs index 7ef5fad059..01d0d9d691 100644 --- a/crates/testlang/outputs/cargo/tests/src/query/engine_tests.rs +++ b/crates/testlang/outputs/cargo/tests/src/query/engine_tests.rs @@ -1,26 +1,26 @@ use std::collections::{BTreeMap, HashMap}; -use slang_testlang::cst::{LabeledNode, Node}; +use slang_testlang::cst::{Edge, Node}; use slang_testlang::cursor::Cursor; -use slang_testlang::kinds::{NodeLabel, RuleKind, TokenKind}; +use slang_testlang::kinds::{EdgeLabel, NonTerminalKind, TerminalKind}; use slang_testlang::query::{Query, QueryResult}; use slang_testlang::text_index::TextIndex; -fn token(label: Option, kind: TokenKind, text: &str) -> LabeledNode { - LabeledNode { +fn terminal(label: Option, kind: TerminalKind, text: &str) -> Edge { + Edge { label, - node: Node::token(kind, text.to_string()), + node: Node::terminal(kind, text.to_string()), } } -fn rule( - label: Option, - kind: RuleKind, - children: [LabeledNode; N], -) -> LabeledNode { - LabeledNode { +fn nonterminal( + label: Option, + kind: NonTerminalKind, + children: [Edge; N], +) -> Edge { + Edge { label, - node: Node::rule(kind, children.into_iter().collect()), + node: Node::nonterminal(kind, children.into_iter().collect()), } } @@ -46,28 +46,28 @@ macro_rules! cst_tree { ( @inner [ $($child:expr)* ]) => { [ $($child),* ] }; ( @inner [ $($child:expr)* ] $label:ident : $token_kind:ident $text:literal $(, $($rest:tt)*)? ) => { - cst_tree!(@inner [ $($child)* token(Some(NodeLabel::$label), TokenKind::$token_kind, $text) ] $($($rest)*)?) + cst_tree!(@inner [ $($child)* terminal(Some(EdgeLabel::$label), TerminalKind::$token_kind, $text) ] $($($rest)*)?) }; ( @inner [ $($child:expr)* ] $token_kind:ident $text:literal $(, $($rest:tt)*)? ) => { - cst_tree!(@inner [ $($child)* token(None, TokenKind::$token_kind, $text) ] $($($rest)*)?) + cst_tree!(@inner [ $($child)* terminal(None, TerminalKind::$token_kind, $text) ] $($($rest)*)?) }; ( @inner [ $($child:expr)* ] $label:ident : $rule_kind:ident [ $($children:tt)* ] $(, $($rest:tt)*)? ) => { - cst_tree!(@inner [ $($child)* rule(Some(NodeLabel::$label), RuleKind::$rule_kind, cst_tree!(@inner [] $($children)*)) ] $($($rest)*)?) + cst_tree!(@inner [ $($child)* nonterminal(Some(NodeLabel::$label), NonTerminalKind::$rule_kind, cst_tree!(@inner [] $($children)*)) ] $($($rest)*)?) }; ( @inner [ $($child:expr)* ] $rule_kind:ident [ $($children:tt)* ] $(, $($rest:tt)*)? ) => { - cst_tree!(@inner [ $($child)* rule(None, RuleKind::$rule_kind, cst_tree!(@inner [] $($children)*)) ] $($($rest)*)?) + cst_tree!(@inner [ $($child)* nonterminal(None, NonTerminalKind::$rule_kind, cst_tree!(@inner [] $($children)*)) ] $($($rest)*)?) }; - // Start with a rule + // Start with a nonterminal ( $label:ident : $rule_kind:ident [ $($children:tt)* ] ) => { - rule(Some(NodeLabel::$label), RuleKind::$rule_kind, cst_tree!(@inner [] $($children)*)) + nonterminal(Some(NodeLabel::$label), NonTerminalKind::$rule_kind, cst_tree!(@inner [] $($children)*)) }; ( $rule_kind:ident [ $($children:tt)* ] ) => { - rule(None, RuleKind::$rule_kind, cst_tree!(@inner [] $($children)*)) + nonterminal(None, NonTerminalKind::$rule_kind, cst_tree!(@inner [] $($children)*)) }; } @@ -84,7 +84,7 @@ macro_rules! query_results { } -fn run_query_test(tree: &LabeledNode, query: &str, results: Vec>>) { +fn run_query_test(tree: &Edge, query: &str, results: Vec>>) { let cursor = tree.cursor_with_offset(TextIndex::ZERO); let query = vec![Query::parse(query).unwrap()]; let mut results = results.into_iter(); @@ -101,7 +101,7 @@ fn run_query_test(tree: &LabeledNode, query: &str, results: Vec LabeledNode { +fn common_test_tree() -> Edge { cst_tree!( TreeNode [ Node: DelimitedIdentifier "A", diff --git a/crates/testlang/outputs/npm/package/src/generated/ast/generated/ast_types.ts b/crates/testlang/outputs/npm/package/src/generated/ast/generated/ast_types.ts index 10f5945367..2df496e427 100644 --- a/crates/testlang/outputs/npm/package/src/generated/ast/generated/ast_types.ts +++ b/crates/testlang/outputs/npm/package/src/generated/ast/generated/ast_types.ts @@ -2,8 +2,8 @@ import * as assert from "node:assert"; import { ast_internal } from "../../napi-bindings/generated"; -import { RuleNode, TokenNode } from "../../cst"; -import { RuleKind, TokenKind } from "../../kinds"; +import { NonTerminalNode, TerminalNode } from "../../cst"; +import { NonTerminalKind, TerminalKind } from "../../kinds"; /* * Sequences: @@ -14,12 +14,12 @@ export class SourceUnit { const [$members] = ast_internal.selectSequence(this.cst); return { - members: new SourceUnitMembers($members as RuleNode), + members: new SourceUnitMembers($members as NonTerminalNode), }; }); - public constructor(public readonly cst: RuleNode) { - assertKind(this.cst.kind, RuleKind.SourceUnit); + public constructor(public readonly cst: NonTerminalNode) { + assertKind(this.cst.kind, NonTerminalKind.SourceUnit); } public get members(): SourceUnitMembers { @@ -32,22 +32,22 @@ export class Tree { const [$keyword, $name, $node, $semicolon] = ast_internal.selectSequence(this.cst); return { - keyword: $keyword as TokenNode, - name: $name === null ? undefined : ($name as TokenNode), - node: new TreeNode($node as RuleNode), - semicolon: $semicolon as TokenNode, + keyword: $keyword as TerminalNode, + name: $name === null ? undefined : ($name as TerminalNode), + node: new TreeNode($node as NonTerminalNode), + semicolon: $semicolon as TerminalNode, }; }); - public constructor(public readonly cst: RuleNode) { - assertKind(this.cst.kind, RuleKind.Tree); + public constructor(public readonly cst: NonTerminalNode) { + assertKind(this.cst.kind, NonTerminalKind.Tree); } - public get keyword(): TokenNode { + public get keyword(): TerminalNode { return this.fetch().keyword; } - public get name(): TokenNode | undefined { + public get name(): TerminalNode | undefined { return this.fetch().name; } @@ -55,7 +55,7 @@ export class Tree { return this.fetch().node; } - public get semicolon(): TokenNode { + public get semicolon(): TerminalNode { return this.fetch().semicolon; } } @@ -65,17 +65,17 @@ export class TreeNode { const [$openBracket, $members, $closeBracket] = ast_internal.selectSequence(this.cst); return { - openBracket: $openBracket as TokenNode, - members: new TreeNodeChildren($members as RuleNode), - closeBracket: $closeBracket as TokenNode, + openBracket: $openBracket as TerminalNode, + members: new TreeNodeChildren($members as NonTerminalNode), + closeBracket: $closeBracket as TerminalNode, }; }); - public constructor(public readonly cst: RuleNode) { - assertKind(this.cst.kind, RuleKind.TreeNode); + public constructor(public readonly cst: NonTerminalNode) { + assertKind(this.cst.kind, NonTerminalKind.TreeNode); } - public get openBracket(): TokenNode { + public get openBracket(): TerminalNode { return this.fetch().openBracket; } @@ -83,7 +83,7 @@ export class TreeNode { return this.fetch().members; } - public get closeBracket(): TokenNode { + public get closeBracket(): TerminalNode { return this.fetch().closeBracket; } } @@ -93,21 +93,21 @@ export class AdditionExpression { const [$leftOperand, $operator, $rightOperand] = ast_internal.selectSequence(this.cst); return { - leftOperand: new Expression($leftOperand as RuleNode), - operator: $operator as TokenNode, - rightOperand: new Expression($rightOperand as RuleNode), + leftOperand: new Expression($leftOperand as NonTerminalNode), + operator: $operator as TerminalNode, + rightOperand: new Expression($rightOperand as NonTerminalNode), }; }); - public constructor(public readonly cst: RuleNode) { - assertKind(this.cst.kind, RuleKind.AdditionExpression); + public constructor(public readonly cst: NonTerminalNode) { + assertKind(this.cst.kind, NonTerminalKind.AdditionExpression); } public get leftOperand(): Expression { return this.fetch().leftOperand; } - public get operator(): TokenNode { + public get operator(): TerminalNode { return this.fetch().operator; } @@ -121,16 +121,16 @@ export class NegationExpression { const [$operator, $operand] = ast_internal.selectSequence(this.cst); return { - operator: $operator as TokenNode, - operand: new Expression($operand as RuleNode), + operator: $operator as TerminalNode, + operand: new Expression($operand as NonTerminalNode), }; }); - public constructor(public readonly cst: RuleNode) { - assertKind(this.cst.kind, RuleKind.NegationExpression); + public constructor(public readonly cst: NonTerminalNode) { + assertKind(this.cst.kind, NonTerminalKind.NegationExpression); } - public get operator(): TokenNode { + public get operator(): TerminalNode { return this.fetch().operator; } @@ -144,25 +144,25 @@ export class MemberAccessExpression { const [$operand, $period, $member] = ast_internal.selectSequence(this.cst); return { - operand: new Expression($operand as RuleNode), - period: $period as TokenNode, - member: $member as TokenNode, + operand: new Expression($operand as NonTerminalNode), + period: $period as TerminalNode, + member: $member as TerminalNode, }; }); - public constructor(public readonly cst: RuleNode) { - assertKind(this.cst.kind, RuleKind.MemberAccessExpression); + public constructor(public readonly cst: NonTerminalNode) { + assertKind(this.cst.kind, NonTerminalKind.MemberAccessExpression); } public get operand(): Expression { return this.fetch().operand; } - public get period(): TokenNode { + public get period(): TerminalNode { return this.fetch().period; } - public get member(): TokenNode { + public get member(): TerminalNode { return this.fetch().member; } } @@ -176,22 +176,22 @@ export class SourceUnitMember { const variant = ast_internal.selectChoice(this.cst); switch (variant.kind) { - case RuleKind.Tree: - return new Tree(variant as RuleNode); - case RuleKind.Expression: - return new Expression(variant as RuleNode); - case RuleKind.SeparatedIdentifiers: - return new SeparatedIdentifiers(variant as RuleNode); - case RuleKind.Literal: - return new Literal(variant as RuleNode); + case NonTerminalKind.Tree: + return new Tree(variant as NonTerminalNode); + case NonTerminalKind.Expression: + return new Expression(variant as NonTerminalNode); + case NonTerminalKind.SeparatedIdentifiers: + return new SeparatedIdentifiers(variant as NonTerminalNode); + case NonTerminalKind.Literal: + return new Literal(variant as NonTerminalNode); default: assert.fail(`Unexpected variant: ${variant.kind}`); } }); - public constructor(public readonly cst: RuleNode) { - assertKind(this.cst.kind, RuleKind.SourceUnitMember); + public constructor(public readonly cst: NonTerminalNode) { + assertKind(this.cst.kind, NonTerminalKind.SourceUnitMember); } public get variant(): Tree | Expression | SeparatedIdentifiers | Literal { @@ -200,46 +200,46 @@ export class SourceUnitMember { } export class TreeNodeChild { - private readonly fetch: () => TreeNode | TokenNode = once(() => { + private readonly fetch: () => TreeNode | TerminalNode = once(() => { const variant = ast_internal.selectChoice(this.cst); switch (variant.kind) { - case RuleKind.TreeNode: - return new TreeNode(variant as RuleNode); + case NonTerminalKind.TreeNode: + return new TreeNode(variant as NonTerminalNode); - case TokenKind.DelimitedIdentifier: - return variant as TokenNode; + case TerminalKind.DelimitedIdentifier: + return variant as TerminalNode; default: assert.fail(`Unexpected variant: ${variant.kind}`); } }); - public constructor(public readonly cst: RuleNode) { - assertKind(this.cst.kind, RuleKind.TreeNodeChild); + public constructor(public readonly cst: NonTerminalNode) { + assertKind(this.cst.kind, NonTerminalKind.TreeNodeChild); } - public get variant(): TreeNode | TokenNode { + public get variant(): TreeNode | TerminalNode { return this.fetch(); } } export class Expression { - private readonly fetch: () => AdditionExpression | NegationExpression | MemberAccessExpression | TokenNode = once( + private readonly fetch: () => AdditionExpression | NegationExpression | MemberAccessExpression | TerminalNode = once( () => { const variant = ast_internal.selectChoice(this.cst); switch (variant.kind) { - case RuleKind.AdditionExpression: - return new AdditionExpression(variant as RuleNode); - case RuleKind.NegationExpression: - return new NegationExpression(variant as RuleNode); - case RuleKind.MemberAccessExpression: - return new MemberAccessExpression(variant as RuleNode); + case NonTerminalKind.AdditionExpression: + return new AdditionExpression(variant as NonTerminalNode); + case NonTerminalKind.NegationExpression: + return new NegationExpression(variant as NonTerminalNode); + case NonTerminalKind.MemberAccessExpression: + return new MemberAccessExpression(variant as NonTerminalNode); - case TokenKind.StringLiteral: - case TokenKind.Identifier: - return variant as TokenNode; + case TerminalKind.StringLiteral: + case TerminalKind.Identifier: + return variant as TerminalNode; default: assert.fail(`Unexpected variant: ${variant.kind}`); @@ -247,33 +247,33 @@ export class Expression { }, ); - public constructor(public readonly cst: RuleNode) { - assertKind(this.cst.kind, RuleKind.Expression); + public constructor(public readonly cst: NonTerminalNode) { + assertKind(this.cst.kind, NonTerminalKind.Expression); } - public get variant(): AdditionExpression | NegationExpression | MemberAccessExpression | TokenNode { + public get variant(): AdditionExpression | NegationExpression | MemberAccessExpression | TerminalNode { return this.fetch(); } } export class Literal { - private readonly fetch: () => TokenNode = once(() => { + private readonly fetch: () => TerminalNode = once(() => { const variant = ast_internal.selectChoice(this.cst); switch (variant.kind) { - case TokenKind.StringLiteral: - return variant as TokenNode; + case TerminalKind.StringLiteral: + return variant as TerminalNode; default: assert.fail(`Unexpected variant: ${variant.kind}`); } }); - public constructor(public readonly cst: RuleNode) { - assertKind(this.cst.kind, RuleKind.Literal); + public constructor(public readonly cst: NonTerminalNode) { + assertKind(this.cst.kind, NonTerminalKind.Literal); } - public get variant(): TokenNode { + public get variant(): TerminalNode { return this.fetch(); } } @@ -285,11 +285,11 @@ export class Literal { export class SourceUnitMembers { private readonly fetch = once(() => { const items = ast_internal.selectRepeated(this.cst); - return items.map((item) => new SourceUnitMember(item as RuleNode)); + return items.map((item) => new SourceUnitMember(item as NonTerminalNode)); }); - public constructor(public readonly cst: RuleNode) { - assertKind(this.cst.kind, RuleKind.SourceUnitMembers); + public constructor(public readonly cst: NonTerminalNode) { + assertKind(this.cst.kind, NonTerminalKind.SourceUnitMembers); } public get items(): readonly SourceUnitMember[] { @@ -300,11 +300,11 @@ export class SourceUnitMembers { export class TreeNodeChildren { private readonly fetch = once(() => { const items = ast_internal.selectRepeated(this.cst); - return items.map((item) => new TreeNodeChild(item as RuleNode)); + return items.map((item) => new TreeNodeChild(item as NonTerminalNode)); }); - public constructor(public readonly cst: RuleNode) { - assertKind(this.cst.kind, RuleKind.TreeNodeChildren); + public constructor(public readonly cst: NonTerminalNode) { + assertKind(this.cst.kind, NonTerminalKind.TreeNodeChildren); } public get items(): readonly TreeNodeChild[] { @@ -320,18 +320,18 @@ export class SeparatedIdentifiers { private readonly fetch = once(() => { const [items, separators] = ast_internal.selectSeparated(this.cst); - return { items: items as TokenNode[], separators: separators as TokenNode[] }; + return { items: items as TerminalNode[], separators: separators as TerminalNode[] }; }); - public constructor(public readonly cst: RuleNode) { - assertKind(this.cst.kind, RuleKind.SeparatedIdentifiers); + public constructor(public readonly cst: NonTerminalNode) { + assertKind(this.cst.kind, NonTerminalKind.SeparatedIdentifiers); } - public get items(): readonly TokenNode[] { + public get items(): readonly TerminalNode[] { return this.fetch().items; } - public get separators(): readonly TokenNode[] { + public get separators(): readonly TerminalNode[] { return this.fetch().separators; } } @@ -350,6 +350,6 @@ function once(factory: () => T): () => T { }; } -function assertKind(actual: RuleKind, expected: RuleKind): void { +function assertKind(actual: NonTerminalKind, expected: NonTerminalKind): void { assert.equal(actual, expected, `${expected} can only be initialized with a CST node of the same kind.`); } diff --git a/crates/testlang/outputs/npm/package/src/generated/cst/index.ts b/crates/testlang/outputs/npm/package/src/generated/cst/index.ts index f44ac9563b..bc3e1ec87d 100644 --- a/crates/testlang/outputs/npm/package/src/generated/cst/index.ts +++ b/crates/testlang/outputs/npm/package/src/generated/cst/index.ts @@ -7,8 +7,8 @@ export type Node = generated.cst.Node; export const NodeType = generated.cst.NodeType; export type NodeType = generated.cst.NodeType; -export const RuleNode = generated.cst.RuleNode; -export type RuleNode = generated.cst.RuleNode; +export const NonTerminalNode = generated.cst.NonTerminalNode; +export type NonTerminalNode = generated.cst.NonTerminalNode; -export const TokenNode = generated.cst.TokenNode; -export type TokenNode = generated.cst.TokenNode; +export const TerminalNode = generated.cst.TerminalNode; +export type TerminalNode = generated.cst.TerminalNode; diff --git a/crates/testlang/outputs/npm/package/src/generated/kinds/index.ts b/crates/testlang/outputs/npm/package/src/generated/kinds/index.ts index 5828a42091..b094f4488b 100644 --- a/crates/testlang/outputs/npm/package/src/generated/kinds/index.ts +++ b/crates/testlang/outputs/npm/package/src/generated/kinds/index.ts @@ -2,11 +2,11 @@ import * as generated from "../napi-bindings/generated"; -export const RuleKind = generated.kinds.RuleKind; -export type RuleKind = generated.kinds.RuleKind; +export const NonTerminalKind = generated.kinds.NonTerminalKind; +export type NonTerminalKind = generated.kinds.NonTerminalKind; -export const TokenKind = generated.kinds.TokenKind; -export type TokenKind = generated.kinds.TokenKind; +export const TerminalKind = generated.kinds.TerminalKind; +export type TerminalKind = generated.kinds.TerminalKind; -export const NodeLabel = generated.kinds.NodeLabel; -export type NodeLabel = generated.kinds.NodeLabel; +export const EdgeLabel = generated.kinds.EdgeLabel; +export type EdgeLabel = generated.kinds.EdgeLabel; diff --git a/crates/testlang/outputs/npm/package/src/generated/napi-bindings/generated/index.d.ts b/crates/testlang/outputs/npm/package/src/generated/napi-bindings/generated/index.d.ts index 347919174b..a72ea5b8e3 100644 --- a/crates/testlang/outputs/npm/package/src/generated/napi-bindings/generated/index.d.ts +++ b/crates/testlang/outputs/npm/package/src/generated/napi-bindings/generated/index.d.ts @@ -9,7 +9,7 @@ /* auto-generated by NAPI-RS */ export namespace kinds { - export enum RuleKind { + export enum NonTerminalKind { AdditionExpression = "AdditionExpression", Expression = "Expression", Literal = "Literal", @@ -24,7 +24,7 @@ export namespace kinds { TreeNodeChild = "TreeNodeChild", TreeNodeChildren = "TreeNodeChildren", } - export enum NodeLabel { + export enum EdgeLabel { Item = "Item", Variant = "Variant", Separator = "Separator", @@ -44,7 +44,7 @@ export namespace kinds { Period = "Period", Semicolon = "Semicolon", } - export enum TokenKind { + export enum TerminalKind { SKIPPED = "SKIPPED", Bang = "Bang", CloseBracket = "CloseBracket", @@ -67,17 +67,17 @@ export namespace language { constructor(version: string); get version(): string; static supportedVersions(): Array; - parse(kind: kinds.RuleKind, input: string): parse_output.ParseOutput; + parse(kind: kinds.NonTerminalKind, input: string): parse_output.ParseOutput; } } export namespace cst { export enum NodeType { - Rule = "Rule", - Token = "Token", + NonTerminal = "NonTerminal", + Terminal = "Terminal", } - export class RuleNode { - get type(): NodeType.Rule; - get kind(): kinds.RuleKind; + export class NonTerminalNode { + get type(): NodeType.NonTerminal; + get kind(): kinds.NonTerminalKind; get textLength(): text_index.TextIndex; children(): Array; createCursor(textOffset: text_index.TextIndex): cursor.Cursor; @@ -85,13 +85,13 @@ export namespace cst { toJSON(): string; unparse(): string; } - export class TokenNode { - get type(): NodeType.Token; - get kind(): kinds.TokenKind; + export class TerminalNode { + get type(): NodeType.Terminal; + get kind(): kinds.TerminalKind; get textLength(): text_index.TextIndex; get text(): string; /** - * Serialize the token node to JSON. + * Serialize the terminal node to JSON. * * This method is intended for debugging purposes and may not be stable. */ @@ -107,11 +107,11 @@ export namespace cursor { spawn(): Cursor; get isCompleted(): boolean; node(): cst.Node; - get label(): kinds.NodeLabel; + get label(): kinds.EdgeLabel; get textOffset(): text_index.TextIndex; get textRange(): text_index.TextRange; get depth(): number; - ancestors(): Array; + ancestors(): Array; goToNext(): boolean; goToNextNonDescendent(): boolean; goToPrevious(): boolean; @@ -121,12 +121,12 @@ export namespace cursor { goToNthChild(childNumber: number): boolean; goToNextSibling(): boolean; goToPreviousSibling(): boolean; - goToNextToken(): boolean; - goToNextTokenWithKind(kind: kinds.TokenKind): boolean; - goToNextTokenWithKinds(kinds: Array): boolean; - goToNextRule(): boolean; - goToNextRuleWithKind(kind: kinds.RuleKind): boolean; - goToNextRuleWithKinds(kinds: Array): boolean; + goToNextTerminal(): boolean; + goToNextTerminalWithKind(kind: kinds.TerminalKind): boolean; + goToNextTokenWithKinds(kinds: Array): boolean; + goToNextNonterminal(): boolean; + goToNextNonterminalWithKind(kind: kinds.NonTerminalKind): boolean; + goToNextNonterminalWithKinds(kinds: Array): boolean; query(queries: Array): query.QueryResultIterator; } } @@ -169,12 +169,12 @@ export namespace text_index { } } export namespace ast_internal { - export function selectSequence(node: cst.RuleNode): Array; - export function selectChoice(node: cst.RuleNode): cst.Node; - export function selectRepeated(node: cst.RuleNode): Array; - export function selectSeparated(node: cst.RuleNode): [Array, Array]; + export function selectSequence(node: cst.NonTerminalNode): Array; + export function selectChoice(node: cst.NonTerminalNode): cst.Node; + export function selectRepeated(node: cst.NonTerminalNode): Array; + export function selectSeparated(node: cst.NonTerminalNode): [Array, Array]; } export namespace cst { - export type Node = RuleNode | TokenNode; + export type Node = TerminalNode | NonTerminalNode; } diff --git a/crates/testlang/outputs/npm/tests/src/tests/ast.ts b/crates/testlang/outputs/npm/tests/src/tests/ast.ts index 8a23cf19dc..2ef2aba34d 100644 --- a/crates/testlang/outputs/npm/tests/src/tests/ast.ts +++ b/crates/testlang/outputs/npm/tests/src/tests/ast.ts @@ -1,6 +1,6 @@ import assert from "node:assert"; import { Language } from "@slang-private/slang-testlang/language"; -import { RuleKind, TokenKind } from "@slang-private/slang-testlang/kinds"; +import { NonTerminalKind, TerminalKind } from "@slang-private/slang-testlang/kinds"; import { AdditionExpression, Expression, @@ -12,22 +12,22 @@ import { TreeNode, TreeNodeChild, } from "@slang-private/slang-testlang/ast"; -import { expectRule, expectToken } from "../utils/cst-helpers"; -import { TokenNode } from "@slang-private/slang-testlang/cst"; +import { expectNonTerminal, expectTerminal } from "../utils/cst-helpers"; +import { TerminalNode } from "@slang-private/slang-testlang/cst"; test("create and use sequence types", () => { const source = `tree [A B C];`.trim(); const language = new Language("1.0.0"); - const parseOutput = language.parse(RuleKind.Tree, source); + const parseOutput = language.parse(NonTerminalKind.Tree, source); expect(parseOutput.errors()).toHaveLength(0); const cst = parseOutput.tree(); - expectRule(cst, RuleKind.Tree); + expectNonTerminal(cst, NonTerminalKind.Tree); const tree = new Tree(cst); - expectRule(tree.cst, RuleKind.Tree); + expectNonTerminal(tree.cst, NonTerminalKind.Tree); expect(tree.name).toBeUndefined(); expect(tree.node.members.items).toHaveLength(3); }); @@ -37,21 +37,21 @@ test("create and use choice types", () => { const language = new Language("1.0.0"); - const parseOutput = language.parse(RuleKind.TreeNodeChild, source); + const parseOutput = language.parse(NonTerminalKind.TreeNodeChild, source); expect(parseOutput.errors()).toHaveLength(0); const cst = parseOutput.tree(); - expectRule(cst, RuleKind.TreeNodeChild); + expectNonTerminal(cst, NonTerminalKind.TreeNodeChild); const tree_node_child = new TreeNodeChild(cst); - expectRule(tree_node_child.cst, RuleKind.TreeNodeChild); + expectNonTerminal(tree_node_child.cst, NonTerminalKind.TreeNodeChild); expect(tree_node_child.variant).toBeInstanceOf(TreeNode); const tree_node = tree_node_child.variant as TreeNode; - expectRule(tree_node.cst, RuleKind.TreeNode); - expectRule(tree_node.members.cst, RuleKind.TreeNodeChildren); - expectToken(tree_node.openBracket, TokenKind.OpenBracket, "["); - expectToken(tree_node.closeBracket, TokenKind.CloseBracket, "]"); + expectNonTerminal(tree_node.cst, NonTerminalKind.TreeNode); + expectNonTerminal(tree_node.members.cst, NonTerminalKind.TreeNodeChildren); + expectTerminal(tree_node.openBracket, TerminalKind.OpenBracket, "["); + expectTerminal(tree_node.closeBracket, TerminalKind.CloseBracket, "]"); }); test("create and use repeated types", () => { @@ -59,19 +59,19 @@ test("create and use repeated types", () => { const language = new Language("1.0.0"); - const parseOutput = language.parse(RuleKind.Tree, source); + const parseOutput = language.parse(NonTerminalKind.Tree, source); expect(parseOutput.errors()).toHaveLength(0); const cst = parseOutput.tree(); - expectRule(cst, RuleKind.Tree); + expectNonTerminal(cst, NonTerminalKind.Tree); const tree = new Tree(cst); - expectRule(tree.node.members.cst, RuleKind.TreeNodeChildren); + expectNonTerminal(tree.node.members.cst, NonTerminalKind.TreeNodeChildren); const names = tree.node.members.items.map((item) => { - expect(item.variant).toBeInstanceOf(TokenNode); + expect(item.variant).toBeInstanceOf(TerminalNode); - return (item.variant as TokenNode).text; + return (item.variant as TerminalNode).text; }); expect(names).toStrictEqual(["A", "B", "C"]); @@ -82,14 +82,14 @@ test("create and use separated types", () => { const language = new Language("1.0.0"); - const parseOutput = language.parse(RuleKind.SeparatedIdentifiers, source); + const parseOutput = language.parse(NonTerminalKind.SeparatedIdentifiers, source); expect(parseOutput.errors()).toHaveLength(0); const cst = parseOutput.tree(); - expectRule(cst, RuleKind.SeparatedIdentifiers); + expectNonTerminal(cst, NonTerminalKind.SeparatedIdentifiers); const separated_identifiers = new SeparatedIdentifiers(cst); - expectRule(separated_identifiers.cst, RuleKind.SeparatedIdentifiers); + expectNonTerminal(separated_identifiers.cst, NonTerminalKind.SeparatedIdentifiers); const identifiers = separated_identifiers.items.map((identifier) => identifier.text); expect(identifiers).toStrictEqual(["Foo", "Bar", "Baz"]); @@ -103,11 +103,11 @@ test("throws an exception on initializing the wrong type", () => { const language = new Language("1.0.0"); - const parseOutput = language.parse(RuleKind.Tree, source); + const parseOutput = language.parse(NonTerminalKind.Tree, source); expect(parseOutput.errors()).toHaveLength(0); const cst = parseOutput.tree(); - expectRule(cst, RuleKind.Tree); + expectNonTerminal(cst, NonTerminalKind.Tree); expect(() => new SourceUnit(cst)).toThrowError( "SourceUnit can only be initialized with a CST node of the same kind.", @@ -119,20 +119,20 @@ test("throws an exception on on using an incorrect/incomplete CST node", () => { const language = new Language("1.0.0"); - const parseOutput = language.parse(RuleKind.Tree, source); + const parseOutput = language.parse(NonTerminalKind.Tree, source); expect(parseOutput.errors()).toHaveLength(1); const cst = parseOutput.tree(); - expectRule(cst, RuleKind.Tree); + expectNonTerminal(cst, NonTerminalKind.Tree); expect(cst.children()).toHaveLength(2); const [contractKeyword, skippedToken] = cst.children(); - expectToken(contractKeyword, TokenKind.TreeKeyword, "tree"); - expectToken(skippedToken, TokenKind.SKIPPED, ""); + expectTerminal(contractKeyword, TerminalKind.TreeKeyword, "tree"); + expectTerminal(skippedToken, TerminalKind.SKIPPED, ""); // Creating the tree should succeed, as the fields are lazily intialized. const tree = new Tree(cst); - expectRule(tree.cst, RuleKind.Tree); + expectNonTerminal(tree.cst, NonTerminalKind.Tree); expect(() => tree.node).toThrowError( "Unexpected SKIPPED token at index '1'. Creating AST types from incorrect/incomplete CST nodes is not supported yet.", @@ -144,18 +144,18 @@ test("create and use prefix expressions", () => { const language = new Language("1.0.0"); - const parseOutput = language.parse(RuleKind.Expression, source); + const parseOutput = language.parse(NonTerminalKind.Expression, source); expect(parseOutput.errors()).toHaveLength(0); const cst = parseOutput.tree(); - expectRule(cst, RuleKind.Expression); + expectNonTerminal(cst, NonTerminalKind.Expression); const expression = new Expression(cst); assert(expression.variant instanceof NegationExpression); const { operator, operand } = expression.variant; - expectToken(operator, TokenKind.Bang, "!"); - expectToken(operand.variant, TokenKind.Identifier, "foo"); + expectTerminal(operator, TerminalKind.Bang, "!"); + expectTerminal(operand.variant, TerminalKind.Identifier, "foo"); }); test("create and use postfix expressions", () => { @@ -163,19 +163,19 @@ test("create and use postfix expressions", () => { const language = new Language("1.0.0"); - const parseOutput = language.parse(RuleKind.Expression, source); + const parseOutput = language.parse(NonTerminalKind.Expression, source); expect(parseOutput.errors()).toHaveLength(0); const cst = parseOutput.tree(); - expectRule(cst, RuleKind.Expression); + expectNonTerminal(cst, NonTerminalKind.Expression); const expression = new Expression(cst); assert(expression.variant instanceof MemberAccessExpression); const { operand, period, member } = expression.variant; - expectToken(operand.variant, TokenKind.Identifier, "foo"); - expectToken(period, TokenKind.Period, "."); - expectToken(member, TokenKind.Identifier, "bar"); + expectTerminal(operand.variant, TerminalKind.Identifier, "foo"); + expectTerminal(period, TerminalKind.Period, "."); + expectTerminal(member, TerminalKind.Identifier, "bar"); }); test("create and use binary expressions", () => { @@ -183,17 +183,17 @@ test("create and use binary expressions", () => { const language = new Language("1.0.0"); - const parseOutput = language.parse(RuleKind.Expression, source); + const parseOutput = language.parse(NonTerminalKind.Expression, source); expect(parseOutput.errors()).toHaveLength(0); const cst = parseOutput.tree(); - expectRule(cst, RuleKind.Expression); + expectNonTerminal(cst, NonTerminalKind.Expression); const expression = new Expression(cst); assert(expression.variant instanceof AdditionExpression); const { leftOperand, operator, rightOperand } = expression.variant; - expectToken(leftOperand.variant, TokenKind.Identifier, "foo"); - expectToken(operator, TokenKind.Plus, "+"); - expectToken(rightOperand.variant, TokenKind.Identifier, "bar"); + expectTerminal(leftOperand.variant, TerminalKind.Identifier, "foo"); + expectTerminal(operator, TerminalKind.Plus, "+"); + expectTerminal(rightOperand.variant, TerminalKind.Identifier, "bar"); }); diff --git a/crates/testlang/outputs/npm/tests/src/tests/cst-cursor.ts b/crates/testlang/outputs/npm/tests/src/tests/cst-cursor.ts index 51e5f65fe0..2799709fc4 100644 --- a/crates/testlang/outputs/npm/tests/src/tests/cst-cursor.ts +++ b/crates/testlang/outputs/npm/tests/src/tests/cst-cursor.ts @@ -1,113 +1,113 @@ import { Language } from "@slang-private/slang-testlang/language"; -import { NodeLabel, RuleKind, TokenKind } from "@slang-private/slang-testlang/kinds"; +import { EdgeLabel, NonTerminalKind, TerminalKind } from "@slang-private/slang-testlang/kinds"; import { Cursor } from "@slang-private/slang-testlang/cursor"; -import { expectRule, expectToken } from "../utils/cst-helpers"; +import { expectNonTerminal, expectTerminal } from "../utils/cst-helpers"; import { NodeType } from "@slang-private/slang-testlang/cst"; test("use cursor", () => { const source = "tree [A [B C] D];"; const language = new Language("1.0.0"); - const parseOutput = language.parse(RuleKind.SourceUnit, source); + const parseOutput = language.parse(NonTerminalKind.SourceUnit, source); const cursor: Cursor = parseOutput.createTreeCursor(); - expectRule(cursor.node(), RuleKind.SourceUnit); + expectNonTerminal(cursor.node(), NonTerminalKind.SourceUnit); expect(cursor.goToNext()).toBe(true); - expectRule(cursor.node(), RuleKind.SourceUnitMembers); + expectNonTerminal(cursor.node(), NonTerminalKind.SourceUnitMembers); expect(cursor.goToNext()).toBe(true); - expectRule(cursor.node(), RuleKind.SourceUnitMember); + expectNonTerminal(cursor.node(), NonTerminalKind.SourceUnitMember); expect(cursor.goToNext()).toBe(true); - expectRule(cursor.node(), RuleKind.Tree); + expectNonTerminal(cursor.node(), NonTerminalKind.Tree); expect(cursor.goToNext()).toBe(true); - expectToken(cursor.node(), TokenKind.TreeKeyword, "tree"); + expectTerminal(cursor.node(), TerminalKind.TreeKeyword, "tree"); expect(cursor.goToNext()).toBe(true); - expectRule(cursor.node(), RuleKind.TreeNode); + expectNonTerminal(cursor.node(), NonTerminalKind.TreeNode); expect(cursor.goToNext()).toBe(true); - expectToken(cursor.node(), TokenKind.Whitespace, " "); + expectTerminal(cursor.node(), TerminalKind.Whitespace, " "); expect(cursor.goToNext()).toBe(true); - expectToken(cursor.node(), TokenKind.OpenBracket, "["); + expectTerminal(cursor.node(), TerminalKind.OpenBracket, "["); expect(cursor.goToNext()).toBe(true); - expectRule(cursor.node(), RuleKind.TreeNodeChildren); + expectNonTerminal(cursor.node(), NonTerminalKind.TreeNodeChildren); expect(cursor.goToNext()).toBe(true); - expectRule(cursor.node(), RuleKind.TreeNodeChild); + expectNonTerminal(cursor.node(), NonTerminalKind.TreeNodeChild); expect(cursor.goToNext()).toBe(true); - expectToken(cursor.node(), TokenKind.DelimitedIdentifier, "A"); + expectTerminal(cursor.node(), TerminalKind.DelimitedIdentifier, "A"); expect(cursor.goToNext()).toBe(true); - expectRule(cursor.node(), RuleKind.TreeNodeChild); + expectNonTerminal(cursor.node(), NonTerminalKind.TreeNodeChild); expect(cursor.goToNext()).toBe(true); - expectRule(cursor.node(), RuleKind.TreeNode); + expectNonTerminal(cursor.node(), NonTerminalKind.TreeNode); expect(cursor.goToNext()).toBe(true); - expectToken(cursor.node(), TokenKind.Whitespace, " "); + expectTerminal(cursor.node(), TerminalKind.Whitespace, " "); expect(cursor.goToNext()).toBe(true); - expectToken(cursor.node(), TokenKind.OpenBracket, "["); + expectTerminal(cursor.node(), TerminalKind.OpenBracket, "["); expect(cursor.goToNext()).toBe(true); - expectRule(cursor.node(), RuleKind.TreeNodeChildren); + expectNonTerminal(cursor.node(), NonTerminalKind.TreeNodeChildren); expect(cursor.goToNext()).toBe(true); - expectRule(cursor.node(), RuleKind.TreeNodeChild); + expectNonTerminal(cursor.node(), NonTerminalKind.TreeNodeChild); expect(cursor.goToNext()).toBe(true); - expectToken(cursor.node(), TokenKind.DelimitedIdentifier, "B"); + expectTerminal(cursor.node(), TerminalKind.DelimitedIdentifier, "B"); expect(cursor.goToNext()).toBe(true); - expectRule(cursor.node(), RuleKind.TreeNodeChild); + expectNonTerminal(cursor.node(), NonTerminalKind.TreeNodeChild); expect(cursor.goToNext()).toBe(true); - expectToken(cursor.node(), TokenKind.Whitespace, " "); + expectTerminal(cursor.node(), TerminalKind.Whitespace, " "); expect(cursor.goToNext()).toBe(true); - expectToken(cursor.node(), TokenKind.DelimitedIdentifier, "C"); + expectTerminal(cursor.node(), TerminalKind.DelimitedIdentifier, "C"); expect(cursor.goToNext()).toBe(true); - expectToken(cursor.node(), TokenKind.CloseBracket, "]"); + expectTerminal(cursor.node(), TerminalKind.CloseBracket, "]"); expect(cursor.goToNext()).toBe(true); - expectRule(cursor.node(), RuleKind.TreeNodeChild); + expectNonTerminal(cursor.node(), NonTerminalKind.TreeNodeChild); expect(cursor.goToNext()).toBe(true); - expectToken(cursor.node(), TokenKind.Whitespace, " "); + expectTerminal(cursor.node(), TerminalKind.Whitespace, " "); expect(cursor.goToNext()).toBe(true); - expectToken(cursor.node(), TokenKind.DelimitedIdentifier, "D"); + expectTerminal(cursor.node(), TerminalKind.DelimitedIdentifier, "D"); expect(cursor.goToNext()).toBe(true); - expectToken(cursor.node(), TokenKind.CloseBracket, "]"); + expectTerminal(cursor.node(), TerminalKind.CloseBracket, "]"); expect(cursor.goToNext()).toBe(true); - expectToken(cursor.node(), TokenKind.Semicolon, ";"); + expectTerminal(cursor.node(), TerminalKind.Semicolon, ";"); expect(cursor.goToNext()).toBe(false); }); test("access the node using its name", () => { const source = "tree [A [B C] D];"; const language = new Language("1.0.0"); - const parseTree = language.parse(RuleKind.SourceUnit, source); + const parseTree = language.parse(NonTerminalKind.SourceUnit, source); const cursor = parseTree.createTreeCursor(); let names: string[] = []; - while (cursor.goToNextRuleWithKind(RuleKind.TreeNode)) { + while (cursor.goToNextNonterminalWithKind(NonTerminalKind.TreeNode)) { const innerCursor = cursor.spawn(); while (innerCursor.goToNext()) { const node = innerCursor.node(); const label = innerCursor.label; - if (node.type == NodeType.Token && (label == NodeLabel.OpenBracket || label == NodeLabel.CloseBracket)) { + if (node.type == NodeType.Terminal && (label == EdgeLabel.OpenBracket || label == EdgeLabel.CloseBracket)) { names.push(node.text); } } diff --git a/crates/testlang/outputs/npm/tests/src/tests/cst-output.ts b/crates/testlang/outputs/npm/tests/src/tests/cst-output.ts index 7a3b093f13..ed231fcc5d 100644 --- a/crates/testlang/outputs/npm/tests/src/tests/cst-output.ts +++ b/crates/testlang/outputs/npm/tests/src/tests/cst-output.ts @@ -1,40 +1,40 @@ import { Language } from "@slang-private/slang-testlang/language"; -import { RuleKind, TokenKind } from "@slang-private/slang-testlang/kinds"; -import { expectRule, expectToken } from "../utils/cst-helpers"; +import { NonTerminalKind, TerminalKind } from "@slang-private/slang-testlang/kinds"; +import { expectNonTerminal, expectTerminal } from "../utils/cst-helpers"; test("parse token", () => { const source = "About_time"; const language = new Language("1.0.0"); - const parseTree = language.parse(RuleKind.TreeNodeChild, source).tree(); - expectRule(parseTree, RuleKind.TreeNodeChild); + const parseTree = language.parse(NonTerminalKind.TreeNodeChild, source).tree(); + expectNonTerminal(parseTree, NonTerminalKind.TreeNodeChild); const children = parseTree.children(); expect(children).toHaveLength(1); - expectToken(children[0]!, TokenKind.DelimitedIdentifier, "About_time"); + expectTerminal(children[0]!, TerminalKind.DelimitedIdentifier, "About_time"); }); test("parse rule", () => { const source = `tree [A [B C] D];`; const language = new Language("1.0.0"); - const parseTree = language.parse(RuleKind.SourceUnit, source).tree(); - expectRule(parseTree, RuleKind.SourceUnit); + const parseTree = language.parse(NonTerminalKind.SourceUnit, source).tree(); + expectNonTerminal(parseTree, NonTerminalKind.SourceUnit); const children = parseTree.children(); expect(children).toHaveLength(1); - expectRule(children[0]!, RuleKind.SourceUnitMembers); + expectNonTerminal(children[0]!, NonTerminalKind.SourceUnitMembers); }); test("trivial cursor access", () => { const source = `tree [A [B C] D];`; const language = new Language("1.0.0"); - const parseOutput = language.parse(RuleKind.SourceUnit, source); + const parseOutput = language.parse(NonTerminalKind.SourceUnit, source); const node = parseOutput.createTreeCursor().node(); - expectRule(node, RuleKind.SourceUnit); + expectNonTerminal(node, NonTerminalKind.SourceUnit); const children = node.children(); expect(children).toHaveLength(1); @@ -44,8 +44,8 @@ test("calculate unicode characters text length", () => { const source = `"some 😁 emoji"`; const language = new Language("1.0.0"); - const parseTree = language.parse(RuleKind.Literal, source).tree(); - expectRule(parseTree, RuleKind.Literal); + const parseTree = language.parse(NonTerminalKind.Literal, source).tree(); + expectNonTerminal(parseTree, NonTerminalKind.Literal); expect(parseTree.textLength).toEqual({ char: 14, @@ -57,7 +57,7 @@ test("calculate unicode characters text length", () => { expect(children).toHaveLength(1); const token = children[0]!; - expectToken(token, TokenKind.StringLiteral, `"some 😁 emoji"`); + expectTerminal(token, TerminalKind.StringLiteral, `"some 😁 emoji"`); expect(token.textLength).toEqual({ char: 14, utf16: 15, @@ -69,8 +69,8 @@ test("can unparse rule nodes", () => { const source = `tree [A [B C] D];`; const language = new Language("1.0.0"); - const parseTree = language.parse(RuleKind.SourceUnit, source).tree(); - expectRule(parseTree, RuleKind.SourceUnit); + const parseTree = language.parse(NonTerminalKind.SourceUnit, source).tree(); + expectNonTerminal(parseTree, NonTerminalKind.SourceUnit); expect(parseTree.unparse()).toEqual(source); }); diff --git a/crates/testlang/outputs/npm/tests/src/tests/errors.ts b/crates/testlang/outputs/npm/tests/src/tests/errors.ts index f3a76e13ef..f70b4dc4a6 100644 --- a/crates/testlang/outputs/npm/tests/src/tests/errors.ts +++ b/crates/testlang/outputs/npm/tests/src/tests/errors.ts @@ -1,11 +1,11 @@ import { Language } from "@slang-private/slang-testlang/language"; -import { RuleKind } from "@slang-private/slang-testlang/kinds"; +import { NonTerminalKind } from "@slang-private/slang-testlang/kinds"; test("render error reports", () => { const source = "tree [AB;"; const language = new Language("1.0.0"); - const errors = language.parse(RuleKind.SourceUnit, source).errors(); + const errors = language.parse(NonTerminalKind.SourceUnit, source).errors(); expect(errors).toHaveLength(1); const report = errors[0]!.toErrorReport("test.testlang", source, /* withColor */ false); diff --git a/crates/testlang/outputs/npm/tests/src/tests/public-api.ts b/crates/testlang/outputs/npm/tests/src/tests/public-api.ts index 17a8502b71..b02f400213 100644 --- a/crates/testlang/outputs/npm/tests/src/tests/public-api.ts +++ b/crates/testlang/outputs/npm/tests/src/tests/public-api.ts @@ -1,14 +1,14 @@ import * as slang from "@slang-private/slang-testlang"; -import { RuleKind, TokenKind } from "@slang-private/slang-testlang/kinds"; +import { NonTerminalKind, TerminalKind } from "@slang-private/slang-testlang/kinds"; test("use namespace imports of the API", () => { - expect(slang.kinds.RuleKind.SourceUnit).toEqual("SourceUnit"); - expect(slang.kinds.RuleKind.TreeNode).toEqual("TreeNode"); - expect(slang.kinds.TokenKind.Identifier).toEqual("Identifier"); + expect(slang.kinds.NonTerminalKind.SourceUnit).toEqual("SourceUnit"); + expect(slang.kinds.NonTerminalKind.TreeNode).toEqual("TreeNode"); + expect(slang.kinds.TerminalKind.Identifier).toEqual("Identifier"); }); test("use nested imports of the API", () => { - expect(RuleKind.SourceUnit).toEqual("SourceUnit"); - expect(RuleKind.TreeNode).toEqual("TreeNode"); - expect(TokenKind.Identifier).toEqual("Identifier"); + expect(NonTerminalKind.SourceUnit).toEqual("SourceUnit"); + expect(NonTerminalKind.TreeNode).toEqual("TreeNode"); + expect(TerminalKind.Identifier).toEqual("Identifier"); }); diff --git a/crates/testlang/outputs/npm/tests/src/tests/query.ts b/crates/testlang/outputs/npm/tests/src/tests/query.ts index 7b6a9549e3..e2c88e6a20 100644 --- a/crates/testlang/outputs/npm/tests/src/tests/query.ts +++ b/crates/testlang/outputs/npm/tests/src/tests/query.ts @@ -1,12 +1,12 @@ -import { RuleKind, TokenKind } from "@slang-private/slang-testlang/kinds"; +import { NonTerminalKind, TerminalKind } from "@slang-private/slang-testlang/kinds"; import { Language } from "@slang-private/slang-testlang/language"; import { Query } from "@slang-private/slang-testlang/query"; -import { expectToken } from "../utils/cst-helpers"; +import { expectTerminal } from "../utils/cst-helpers"; test("simple query", () => { const language = new Language("1.0.0"); const tree_source = `tree [A [B C] D];`; - const parse_output = language.parse(RuleKind.Tree, tree_source); + const parse_output = language.parse(NonTerminalKind.Tree, tree_source); const query_source = `[TreeNodeChild ... @id [DelimitedIdentifier]]`; const query = Query.parse(query_source); @@ -19,7 +19,7 @@ test("simple query", () => { expect(Object.keys(result!.bindings)).toStrictEqual(["id"]); let cursors = result!.bindings["id"]!; expect(cursors.length).toEqual(1); - expectToken(cursors[0]!.node(), TokenKind.DelimitedIdentifier, name); + expectTerminal(cursors[0]!.node(), TerminalKind.DelimitedIdentifier, name); }; expectNextResult("A"); diff --git a/crates/testlang/outputs/npm/tests/src/utils/cst-helpers.ts b/crates/testlang/outputs/npm/tests/src/utils/cst-helpers.ts index 7c2209714f..1dff178d7d 100644 --- a/crates/testlang/outputs/npm/tests/src/utils/cst-helpers.ts +++ b/crates/testlang/outputs/npm/tests/src/utils/cst-helpers.ts @@ -1,19 +1,19 @@ -import { NodeType, RuleNode, TokenNode } from "@slang-private/slang-testlang/cst"; -import { RuleKind, TokenKind } from "@slang-private/slang-testlang/kinds"; +import { NodeType, NonTerminalNode, TerminalNode } from "@slang-private/slang-testlang/cst"; +import { NonTerminalKind, TerminalKind } from "@slang-private/slang-testlang/kinds"; -export function expectRule(node: unknown, kind: RuleKind): asserts node is RuleNode { - expect(node).toBeInstanceOf(RuleNode); +export function expectNonTerminal(node: unknown, kind: NonTerminalKind): asserts node is NonTerminalNode { + expect(node).toBeInstanceOf(NonTerminalNode); - const rule = node as RuleNode; - expect(rule.type).toEqual(NodeType.Rule); + const rule = node as NonTerminalNode; + expect(rule.type).toEqual(NodeType.NonTerminal); expect(rule.kind).toEqual(kind); } -export function expectToken(node: unknown, kind: TokenKind, text: string): asserts node is TokenNode { - expect(node).toBeInstanceOf(TokenNode); +export function expectTerminal(node: unknown, kind: TerminalKind, text: string): asserts node is TerminalNode { + expect(node).toBeInstanceOf(TerminalNode); - const token = node as TokenNode; - expect(token.type).toEqual(NodeType.Token); + const token = node as TerminalNode; + expect(token.type).toEqual(NodeType.Terminal); expect(token.kind).toEqual(kind); expect(token.text).toEqual(text); } diff --git a/documentation/public/user-guide/concepts.md b/documentation/public/user-guide/concepts.md index 4228dc7386..820750fd75 100644 --- a/documentation/public/user-guide/concepts.md +++ b/documentation/public/user-guide/concepts.md @@ -45,7 +45,7 @@ to do it: - According to the DFS order, i.e. `goToNext()` and `goToPrevious()`, - According to the relationship between the current node and the next node, i.e. `goToParent()`, `goToFirstChild()`, `goToNextNonDescendent()` -- According to the kind of the next node, i.e. `goToNextTokenWithKind(kind)`, `goToNextRuleWithKind(kind)` +- According to the kind of the next node, i.e. `goToNextTerminalWithKind(kind)`, `goToNextNonterminalWithKind(kind)` As such, the cursor is stateful and keeps track of the path it has taken through the CST. It starts at the root it was created at and is completed when it reaches its root when navigating forward. From 18fa37469347fa4bb1f2a9a87b2c3c769a364a07 Mon Sep 17 00:00:00 2001 From: Igor Matuszewski Date: Tue, 21 May 2024 13:09:55 +0200 Subject: [PATCH 2/4] Add a changeset file --- .changeset/smooth-cougars-film.md | 5 +++++ 1 file changed, 5 insertions(+) create mode 100644 .changeset/smooth-cougars-film.md diff --git a/.changeset/smooth-cougars-film.md b/.changeset/smooth-cougars-film.md new file mode 100644 index 0000000000..9c6d98f816 --- /dev/null +++ b/.changeset/smooth-cougars-film.md @@ -0,0 +1,5 @@ +--- +"@nomicfoundation/slang": minor +--- + +Rename RuleKind, TerminalKind and NodeLabel From def721774b60d5cd441ac5fbc99b54b5cb89bfc5 Mon Sep 17 00:00:00 2001 From: Igor Matuszewski Date: Tue, 21 May 2024 20:12:23 +0200 Subject: [PATCH 3/4] Add an exception to cspell.json --- .cspell.json | 1 + 1 file changed, 1 insertion(+) diff --git a/.cspell.json b/.cspell.json index 1381d7855e..b5be6a3f37 100644 --- a/.cspell.json +++ b/.cspell.json @@ -18,6 +18,7 @@ "napi", "nomic", "nomicfoundation", + "nonterminal", "rustup", "struct", "structs", From a1ccbc8f1c4adb2f39b1424b3a9d172c9de8e233 Mon Sep 17 00:00:00 2001 From: Igor Matuszewski Date: Tue, 21 May 2024 20:14:38 +0200 Subject: [PATCH 4/4] Update concepts.md --- documentation/public/user-guide/concepts.md | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) diff --git a/documentation/public/user-guide/concepts.md b/documentation/public/user-guide/concepts.md index 820750fd75..7004530b17 100644 --- a/documentation/public/user-guide/concepts.md +++ b/documentation/public/user-guide/concepts.md @@ -13,9 +13,9 @@ Providing an accurate language version is important, as it affects the shape of You can use the `Language::getSupportedVersions()` API to get a list of all supported versions for the current Slang release. The `Language::parse()` API is the main entry point for the parser, and to generate concrete syntax trees (CSTs) that can be used for further analysis. -Each `parse()` operation accepts the input source code, and a `RuleKind` variant. -This allows callers to parse entire source files (`RuleKind::SourceUnit`), individual contracts (`RuleKind::ContractDefinition`), -methods (`RuleKind::FunctionDefinition`), or any other syntax nodes. +Each `parse()` operation accepts the input source code, and a `NonTerminalKind` variant. +This allows callers to parse entire source files (`NonTerminalKind::SourceUnit`), individual contracts (`NonTerminalKind::ContractDefinition`), +methods (`NonTerminalKind::FunctionDefinition`), or any other syntax nodes. The resulting `ParseOutput` object will contain syntax errors (if any), and the syntax tree corresponding to the input source code. @@ -31,8 +31,8 @@ tokens (lexical analysis), which then in turn is _parsed_ into the CST. The resulting CST is a regular tree data structure that you can visit. The tree nodes are represented by the `Node` structure, which can be one of two kinds: -- `RuleNode` (aka _non-terminals_) represent sub-trees, containing a vector of other `Node` children. -- `TokenNode` (aka _terminals_) are leaves and represent a lexical token (i.e. an identifier, keyword, punctuation) in the source. +- `NonTerminalNode` represent sub-trees, containing a vector of other `Node` children. +- `TerminalNode` are leaves and represent a lexical token (i.e. an identifier, keyword, punctuation) in the source. ## CST Cursors @@ -77,7 +77,7 @@ looking for matches. This mode of operation can replace all visitor patterns. AST types are a set of abstractions that provide a typed view of the untyped CST nodes. You can convert any untyped CST node to its corresponding AST type using their constructors. -There is a corresponding type for each `RuleKind` (non-terminal) in the language. AST types are immutable. +There is a corresponding type for each `NonTerminalKind` in the language. AST types are immutable. Additionally, their fields are constructed lazily as they are accessed for the first time. AST nodes maintain a reference to the CST node they were constructed from,