From 46b1dde2e39903cff6398d5da3a4d1a1820f0095 Mon Sep 17 00:00:00 2001 From: Omar Tawfik <15987992+OmarTawfik@users.noreply.github.com> Date: Mon, 27 May 2024 04:00:37 -0700 Subject: [PATCH] update remaining public API and user docs terminology (#975) Following up on changes in #971 and #918. --- .changeset/honest-shirts-enjoy.md | 5 + .changeset/smooth-cougars-film.md | 2 +- .cspell.json | 1 + crates/codegen/ebnf/src/model.rs | 2 +- .../language/definition/src/model/mod.rs | 4 +- .../{non_terminals => nonterminals}/enum_.rs | 0 .../{non_terminals => nonterminals}/field.rs | 2 +- .../{non_terminals => nonterminals}/mod.rs | 0 .../precedence.rs | 0 .../repeated.rs | 0 .../separated.rs | 0 .../struct_.rs | 0 .../cargo/src/runtime/generated/kinds.rs | 4 +- .../cargo/src/runtime/generated/language.rs | 17 +- .../runtime/cargo/src/runtime/kinds.rs.jinja2 | 4 +- .../cargo/src/runtime/language.rs.jinja2 | 37 +- .../runtime/cargo/src/runtime/lexer.rs | 48 +- .../codegen/runtime/cargo/src/runtime/mod.rs | 4 +- .../napi_interface/ast_selectors.rs.jinja2 | 78 +- .../cargo/src/runtime/napi_interface/cst.rs | 36 +- .../src/runtime/napi_interface/cursor.rs | 18 +- .../napi_interface/generated/ast_selectors.rs | 38 +- .../cargo/src/runtime/napi_interface/mod.rs | 4 +- .../runtime/napi_interface/parse_output.rs | 4 +- .../cargo/src/runtime/napi_interface/query.rs | 14 +- .../runtime/cargo/src/runtime/parse_error.rs | 22 +- .../runtime/parser_support/choice_helper.rs | 10 +- .../cargo/src/runtime/parser_support/mod.rs | 2 +- .../runtime/parser_support/optional_helper.rs | 4 +- .../runtime/parser_support/parser_function.rs | 22 +- .../runtime/parser_support/parser_result.rs | 62 +- .../parser_support/precedence_helper.rs | 12 +- .../src/runtime/parser_support/recovery.rs | 72 +- .../parser_support/repetition_helper.rs | 16 +- .../parser_support/separated_helper.rs | 20 +- .../runtime/parser_support/sequence_helper.rs | 38 +- crates/codegen/runtime/generator/src/ast.rs | 18 +- .../codegen/runtime/generator/src/parser.rs | 14 +- .../src/parser/grammar/constructor.rs | 14 +- .../src/parser/grammar/parser_definition.rs | 14 +- .../src/parser/keyword_scanner_definition.rs | 16 +- .../generator/src/parser/parser_definition.rs | 28 +- .../parser/precedence_parser_definition.rs | 20 +- .../npm/src/runtime/ast/ast_types.ts.jinja2 | 36 +- .../runtime/npm/src/runtime/cst/index.ts | 4 +- .../runtime/npm/src/runtime/kinds/index.ts | 4 +- .../napi-bindings/generated/index.d.ts | 40 +- .../napi/bindings/index.d.ts.jinja2 | 2 +- crates/metaslang/cst/src/cst.rs | 62 +- crates/metaslang/cst/src/cursor.rs | 22 +- crates/metaslang/cst/src/lib.rs | 4 +- crates/metaslang/cst/src/query/engine.rs | 54 +- crates/metaslang/cst/src/query/model.rs | 16 +- crates/metaslang/cst/src/query/parser.rs | 8 +- .../graph_builder/tests/functions.rs | 4 +- crates/metaslang/graph_builder/tests/graph.rs | 4 +- .../metaslang/graph_builder/tests/parser.rs | 6 +- .../inputs/language/src/definition.rs | 2 +- .../src/generated/generated/kinds.rs | 4 +- .../src/generated/generated/language.rs | 2141 +++++++++-------- .../slang_solidity/src/generated/lexer.rs | 48 +- .../cargo/slang_solidity/src/generated/mod.rs | 4 +- .../src/generated/napi_interface/cst.rs | 36 +- .../src/generated/napi_interface/cursor.rs | 18 +- .../napi_interface/generated/ast_selectors.rs | 1680 ++++++------- .../src/generated/napi_interface/mod.rs | 4 +- .../generated/napi_interface/parse_output.rs | 4 +- .../src/generated/napi_interface/query.rs | 14 +- .../src/generated/parse_error.rs | 22 +- .../generated/parser_support/choice_helper.rs | 10 +- .../src/generated/parser_support/mod.rs | 2 +- .../parser_support/optional_helper.rs | 4 +- .../parser_support/parser_function.rs | 22 +- .../generated/parser_support/parser_result.rs | 62 +- .../parser_support/precedence_helper.rs | 12 +- .../src/generated/parser_support/recovery.rs | 72 +- .../parser_support/repetition_helper.rs | 16 +- .../parser_support/separated_helper.rs | 20 +- .../parser_support/sequence_helper.rs | 38 +- .../outputs/cargo/slang_solidity/src/main.rs | 4 +- .../cargo/tests/src/cst_output/renderer.rs | 16 +- .../cargo/tests/src/cst_output/runner.rs | 6 +- .../src/doc_examples/tree_query_language.rs | 52 +- .../tests/src/doc_examples/using_queries.rs | 36 +- .../src/doc_examples/using_the_cursor.rs | 18 +- .../src/doc_examples/using_the_parser.rs | 8 +- .../outputs/cargo/tests/src/trivia.rs | 18 +- .../src/generated/ast/generated/ast_types.ts | 1886 +++++++-------- .../npm/package/src/generated/cst/index.ts | 4 +- .../npm/package/src/generated/kinds/index.ts | 4 +- .../napi-bindings/generated/index.d.ts | 40 +- .../tests/src/doc-examples/using-queries.ts | 68 +- .../tests/src/doc-examples/using-the-ast.ts | 8 +- .../src/doc-examples/using-the-cursor.ts | 26 +- .../src/doc-examples/using-the-parser.ts | 12 +- .../solidity/testing/sanctuary/src/tests.rs | 4 +- .../src/generated/generated/kinds.rs | 4 +- .../src/generated/generated/language.rs | 171 +- .../slang_testlang/src/generated/lexer.rs | 48 +- .../cargo/slang_testlang/src/generated/mod.rs | 4 +- .../src/generated/napi_interface/cst.rs | 36 +- .../src/generated/napi_interface/cursor.rs | 18 +- .../napi_interface/generated/ast_selectors.rs | 124 +- .../src/generated/napi_interface/mod.rs | 4 +- .../generated/napi_interface/parse_output.rs | 4 +- .../src/generated/napi_interface/query.rs | 14 +- .../src/generated/parse_error.rs | 22 +- .../generated/parser_support/choice_helper.rs | 10 +- .../src/generated/parser_support/mod.rs | 2 +- .../parser_support/optional_helper.rs | 4 +- .../parser_support/parser_function.rs | 22 +- .../generated/parser_support/parser_result.rs | 62 +- .../parser_support/precedence_helper.rs | 12 +- .../src/generated/parser_support/recovery.rs | 72 +- .../parser_support/repetition_helper.rs | 16 +- .../parser_support/separated_helper.rs | 20 +- .../parser_support/sequence_helper.rs | 38 +- .../cargo/tests/src/query/engine_tests.rs | 87 +- .../cargo/tests/src/query/parser_tests.rs | 4 +- .../src/generated/ast/generated/ast_types.ts | 108 +- .../npm/package/src/generated/cst/index.ts | 4 +- .../npm/package/src/generated/kinds/index.ts | 4 +- .../napi-bindings/generated/index.d.ts | 40 +- .../outputs/npm/tests/src/tests/ast.ts | 60 +- .../outputs/npm/tests/src/tests/cst-cursor.ts | 36 +- .../outputs/npm/tests/src/tests/cst-output.ts | 38 +- .../outputs/npm/tests/src/tests/errors.ts | 4 +- .../outputs/npm/tests/src/tests/public-api.ts | 10 +- .../outputs/npm/tests/src/tests/query.ts | 26 +- .../npm/tests/src/utils/cst-helpers.ts | 22 +- .../design-docs/language-definition-v2.md | 50 +- documentation/public/user-guide/concepts.md | 18 +- .../public/user-guide/introduction.md | 4 +- .../user-guide/npm-package/using-queries.md | 4 +- .../npm-package/using-the-parser.md | 4 +- .../user-guide/rust-crate/using-queries.md | 4 +- .../user-guide/rust-crate/using-the-cli.md | 22 +- .../user-guide/rust-crate/using-the-parser.md | 4 +- .../public/user-guide/tree-query-language.md | 2 +- 139 files changed, 4354 insertions(+), 4345 deletions(-) create mode 100644 .changeset/honest-shirts-enjoy.md rename crates/codegen/language/definition/src/model/{non_terminals => nonterminals}/enum_.rs (100%) rename crates/codegen/language/definition/src/model/{non_terminals => nonterminals}/field.rs (95%) rename crates/codegen/language/definition/src/model/{non_terminals => nonterminals}/mod.rs (100%) rename crates/codegen/language/definition/src/model/{non_terminals => nonterminals}/precedence.rs (100%) rename crates/codegen/language/definition/src/model/{non_terminals => nonterminals}/repeated.rs (100%) rename crates/codegen/language/definition/src/model/{non_terminals => nonterminals}/separated.rs (100%) rename crates/codegen/language/definition/src/model/{non_terminals => nonterminals}/struct_.rs (100%) diff --git a/.changeset/honest-shirts-enjoy.md b/.changeset/honest-shirts-enjoy.md new file mode 100644 index 0000000000..327bae4b6a --- /dev/null +++ b/.changeset/honest-shirts-enjoy.md @@ -0,0 +1,5 @@ +--- +"@nomicfoundation/slang": minor +--- + +rename `QueryResult` to `QueryMatch`, and its `bindings` to `captures`. diff --git a/.changeset/smooth-cougars-film.md b/.changeset/smooth-cougars-film.md index 9c6d98f816..6729664325 100644 --- a/.changeset/smooth-cougars-film.md +++ b/.changeset/smooth-cougars-film.md @@ -2,4 +2,4 @@ "@nomicfoundation/slang": minor --- -Rename RuleKind, TerminalKind and NodeLabel +Rename `RuleKind` to `NonterminalKind`, `TokenKind` to `TerminalKind`, and `NodeLabel` to `EdgeLabel`. diff --git a/.cspell.json b/.cspell.json index b5be6a3f37..05c4f7b4ba 100644 --- a/.cspell.json +++ b/.cspell.json @@ -19,6 +19,7 @@ "nomic", "nomicfoundation", "nonterminal", + "nonterminals", "rustup", "struct", "structs", diff --git a/crates/codegen/ebnf/src/model.rs b/crates/codegen/ebnf/src/model.rs index 574846e78f..fe609da9e7 100644 --- a/crates/codegen/ebnf/src/model.rs +++ b/crates/codegen/ebnf/src/model.rs @@ -5,7 +5,7 @@ use codegen_language_definition::model::Identifier; /// /// Additionally, it computes the EBNF ID from the name, accourding to the following rules: /// -/// - For non-terminals, we use the original name in `PascalCase`. +/// - For nonterminals, we use the original name in `PascalCase`. /// - For terminals, we use the name in `SCREAMING_SNAKE_CASE`. /// - For fragments, we add `«guillemets»` around the name. #[derive(derive_new::new)] diff --git a/crates/codegen/language/definition/src/model/mod.rs b/crates/codegen/language/definition/src/model/mod.rs index 4ecbd3d248..9b6c9b8558 100644 --- a/crates/codegen/language/definition/src/model/mod.rs +++ b/crates/codegen/language/definition/src/model/mod.rs @@ -1,11 +1,11 @@ mod item; mod manifest; -mod non_terminals; +mod nonterminals; mod terminals; mod utils; pub use item::*; pub use manifest::*; -pub use non_terminals::*; +pub use nonterminals::*; pub use terminals::*; pub use utils::*; diff --git a/crates/codegen/language/definition/src/model/non_terminals/enum_.rs b/crates/codegen/language/definition/src/model/nonterminals/enum_.rs similarity index 100% rename from crates/codegen/language/definition/src/model/non_terminals/enum_.rs rename to crates/codegen/language/definition/src/model/nonterminals/enum_.rs diff --git a/crates/codegen/language/definition/src/model/non_terminals/field.rs b/crates/codegen/language/definition/src/model/nonterminals/field.rs similarity index 95% rename from crates/codegen/language/definition/src/model/non_terminals/field.rs rename to crates/codegen/language/definition/src/model/nonterminals/field.rs index 3318099dee..acb05bfc38 100644 --- a/crates/codegen/language/definition/src/model/non_terminals/field.rs +++ b/crates/codegen/language/definition/src/model/nonterminals/field.rs @@ -21,7 +21,7 @@ pub struct FieldDelimiters { /// /// By default, we assume no lookahead (0) is required to recover from /// unrecognized body between delimiters, so it's always triggered. - pub tokens_matched_acceptance_threshold: Option, + pub terminals_matched_acceptance_threshold: Option, } #[derive(Clone, Debug, Deserialize, Eq, PartialEq, Serialize)] diff --git a/crates/codegen/language/definition/src/model/non_terminals/mod.rs b/crates/codegen/language/definition/src/model/nonterminals/mod.rs similarity index 100% rename from crates/codegen/language/definition/src/model/non_terminals/mod.rs rename to crates/codegen/language/definition/src/model/nonterminals/mod.rs diff --git a/crates/codegen/language/definition/src/model/non_terminals/precedence.rs b/crates/codegen/language/definition/src/model/nonterminals/precedence.rs similarity index 100% rename from crates/codegen/language/definition/src/model/non_terminals/precedence.rs rename to crates/codegen/language/definition/src/model/nonterminals/precedence.rs diff --git a/crates/codegen/language/definition/src/model/non_terminals/repeated.rs b/crates/codegen/language/definition/src/model/nonterminals/repeated.rs similarity index 100% rename from crates/codegen/language/definition/src/model/non_terminals/repeated.rs rename to crates/codegen/language/definition/src/model/nonterminals/repeated.rs diff --git a/crates/codegen/language/definition/src/model/non_terminals/separated.rs b/crates/codegen/language/definition/src/model/nonterminals/separated.rs similarity index 100% rename from crates/codegen/language/definition/src/model/non_terminals/separated.rs rename to crates/codegen/language/definition/src/model/nonterminals/separated.rs diff --git a/crates/codegen/language/definition/src/model/non_terminals/struct_.rs b/crates/codegen/language/definition/src/model/nonterminals/struct_.rs similarity index 100% rename from crates/codegen/language/definition/src/model/non_terminals/struct_.rs rename to crates/codegen/language/definition/src/model/nonterminals/struct_.rs diff --git a/crates/codegen/runtime/cargo/src/runtime/generated/kinds.rs b/crates/codegen/runtime/cargo/src/runtime/generated/kinds.rs index 0ee94c2050..c6cdd991c0 100644 --- a/crates/codegen/runtime/cargo/src/runtime/generated/kinds.rs +++ b/crates/codegen/runtime/cargo/src/runtime/generated/kinds.rs @@ -18,13 +18,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 NonTerminalKind { +pub enum NonterminalKind { Stub1, Stub2, Stub3, } -impl metaslang_cst::NonTerminalKind for NonTerminalKind {} +impl metaslang_cst::NonterminalKind for NonterminalKind {} #[derive( Debug, diff --git a/crates/codegen/runtime/cargo/src/runtime/generated/language.rs b/crates/codegen/runtime/cargo/src/runtime/generated/language.rs index fe6c01ef38..4a30b84464 100644 --- a/crates/codegen/runtime/cargo/src/runtime/generated/language.rs +++ b/crates/codegen/runtime/cargo/src/runtime/generated/language.rs @@ -16,15 +16,16 @@ use semver::Version; use crate::cst; use crate::kinds::{ - EdgeLabel, IsLexicalContext, LexicalContext, LexicalContextType, NonTerminalKind, TerminalKind, + EdgeLabel, IsLexicalContext, LexicalContext, LexicalContextType, NonterminalKind, TerminalKind, }; -use crate::lexer::{KeywordScan, Lexer, ScannedToken}; +use crate::lexer::{KeywordScan, Lexer, ScannedTerminal}; #[cfg(feature = "slang_napi_interfaces")] use crate::napi_interface::parse_output::ParseOutput as NAPIParseOutput; use crate::parse_output::ParseOutput; use crate::parser_support::{ ChoiceHelper, OneOrMoreHelper, OptionalHelper, ParserContext, ParserFunction, ParserResult, - PrecedenceHelper, SeparatedHelper, SequenceHelper, TokenAcceptanceThreshold, ZeroOrMoreHelper, + PrecedenceHelper, SeparatedHelper, SequenceHelper, TerminalAcceptanceThreshold, + ZeroOrMoreHelper, }; #[derive(Debug)] @@ -65,7 +66,7 @@ impl Language { &self.version } - pub fn parse(&self, kind: NonTerminalKind, input: &str) -> ParseOutput { + pub fn parse(&self, kind: NonterminalKind, input: &str) -> ParseOutput { unreachable!("Attempting to parse in stubs: {kind}: {input}") } } @@ -83,11 +84,11 @@ impl Lexer for Language { unreachable!("Invoking delimiters in stubs.") } - fn next_token( + fn next_terminal( &self, input: &mut ParserContext<'_>, - ) -> Option { - unreachable!("Invoking next_token in stubs: {input:#?}") + ) -> Option { + unreachable!("Invoking next_terminal in stubs: {input:#?}") } } @@ -123,7 +124,7 @@ impl Language { )] pub fn parse_napi( &self, - #[napi(ts_arg_type = "kinds.NonTerminalKind")] kind: NonTerminalKind, + #[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 8d21fef516..30e59186fb 100644 --- a/crates/codegen/runtime/cargo/src/runtime/kinds.rs.jinja2 +++ b/crates/codegen/runtime/cargo/src/runtime/kinds.rs.jinja2 @@ -16,7 +16,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 NonTerminalKind { +pub enum NonterminalKind { {%- if rendering_in_stubs -%} Stub1, Stub2, @@ -29,7 +29,7 @@ pub enum NonTerminalKind { {%- endif -%} } -impl metaslang_cst::NonTerminalKind for NonTerminalKind {} +impl metaslang_cst::NonterminalKind for NonterminalKind {} #[derive( Debug, diff --git a/crates/codegen/runtime/cargo/src/runtime/language.rs.jinja2 b/crates/codegen/runtime/cargo/src/runtime/language.rs.jinja2 index 345829c4ef..4f5c38fd5b 100644 --- a/crates/codegen/runtime/cargo/src/runtime/language.rs.jinja2 +++ b/crates/codegen/runtime/cargo/src/runtime/language.rs.jinja2 @@ -14,15 +14,16 @@ use napi_derive::napi; use crate::cst; use crate::kinds::{ - EdgeLabel, IsLexicalContext, LexicalContext, LexicalContextType, NonTerminalKind, TerminalKind, + EdgeLabel, IsLexicalContext, LexicalContext, LexicalContextType, NonterminalKind, TerminalKind, }; -use crate::lexer::{KeywordScan, Lexer, ScannedToken}; +use crate::lexer::{KeywordScan, Lexer, ScannedTerminal}; #[cfg(feature = "slang_napi_interfaces")] use crate::napi_interface::parse_output::ParseOutput as NAPIParseOutput; use crate::parse_output::ParseOutput; use crate::parser_support::{ ChoiceHelper, OneOrMoreHelper, OptionalHelper, ParserContext, ParserFunction, ParserResult, - PrecedenceHelper, SeparatedHelper, SequenceHelper, TokenAcceptanceThreshold, ZeroOrMoreHelper, + PrecedenceHelper, SeparatedHelper, SequenceHelper, TerminalAcceptanceThreshold, + ZeroOrMoreHelper, }; #[derive(Debug)] @@ -115,13 +116,13 @@ impl Language { {% endif %} - pub fn parse(&self, kind: NonTerminalKind, 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.parser_functions -%} - NonTerminalKind::{{ parser_name }} => Self::{{ parser_name | snake_case }}.parse(self, input), + NonterminalKind::{{ parser_name }} => Self::{{ parser_name | snake_case }}.parse(self, input), {%- endfor -%} } {%- endif -%} @@ -161,13 +162,13 @@ impl Lexer for Language { {%- endif -%} } - fn next_token(&self, input: &mut ParserContext<'_>) -> Option { + fn next_terminal(&self, input: &mut ParserContext<'_>) -> Option { {%- if rendering_in_stubs -%} - unreachable!("Invoking next_token in stubs: {input:#?}") + unreachable!("Invoking next_terminal in stubs: {input:#?}") {%- else -%} let save = input.position(); let mut furthest_position = input.position(); - let mut longest_token = None; + let mut longest_terminal = None; macro_rules! longest_match { ($( { $kind:ident = $function:ident } )*) => { @@ -175,7 +176,7 @@ impl Lexer for Language { if self.$function(input) && input.position() > furthest_position { furthest_position = input.position(); - longest_token = Some(TerminalKind::$kind); + longest_terminal = Some(TerminalKind::$kind); } input.set_position(save); )* @@ -187,7 +188,7 @@ impl Lexer for Language { LexicalContext::{{ context_name }} => { if let Some(kind) = {{ context.literal_scanner }} { furthest_position = input.position(); - longest_token = Some(kind); + longest_terminal = Some(kind); } input.set_position(save); @@ -206,7 +207,7 @@ 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| + if let Some(identifier) = longest_terminal.filter(|tok| [ {% for name in context.promotable_identifier_scanners %} TerminalKind::{{ name }}, @@ -246,21 +247,21 @@ impl Lexer for Language { {% endif %} input.set_position(furthest_position); - return Some(ScannedToken::IdentifierOrKeyword { identifier, kw: kw_scan }); + return Some(ScannedTerminal::IdentifierOrKeyword { identifier, kw: kw_scan }); } }, {%- endfor %} } - match longest_token { - Some(token) => { + match longest_terminal { + Some(terminal) => { input.set_position(furthest_position); - Some(ScannedToken::Single(token)) + Some(ScannedTerminal::Single(terminal)) }, - // Skip a character if possible and if we didn't recognize a token + // Skip a character if possible and if we didn't recognize a terminal None if input.peek().is_some() => { let _ = input.next(); - Some(ScannedToken::Single(TerminalKind::SKIPPED)) + Some(ScannedTerminal::Single(TerminalKind::SKIPPED)) }, None => None, } @@ -294,7 +295,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.NonTerminalKind")] kind: NonTerminalKind, + #[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 5d12ca8fec..25ba7d9f1d 100644 --- a/crates/codegen/runtime/cargo/src/runtime/lexer.rs +++ b/crates/codegen/runtime/cargo/src/runtime/lexer.rs @@ -16,7 +16,7 @@ pub enum KeywordScan { } #[derive(Debug, Clone, Copy, PartialEq, Eq)] -pub enum ScannedToken { +pub enum ScannedTerminal { Single(TerminalKind), IdentifierOrKeyword { identifier: TerminalKind, @@ -24,7 +24,7 @@ pub enum ScannedToken { }, } -impl ScannedToken { +impl ScannedTerminal { pub fn accepted_as(self, expected: TerminalKind) -> bool { match self { Self::Single(kind) => kind == expected, @@ -36,10 +36,10 @@ impl ScannedToken { } } - /// Returns the most general token kind that can be accepted for the scanned token. + /// Returns the most general terminal kind that can be accepted for the scanned terminal. /// - /// 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. + /// If the scanned terminal is an identifier, returns the specific keyword kind if the keyword is reserved, + /// otherwise returns the general identifier kind. For other terminals, returns the terminal kind itself. pub fn unambiguous(self) -> TerminalKind { match self { Self::Single(kind) => kind, @@ -56,10 +56,10 @@ impl ScannedToken { pub(crate) trait Lexer { // Generated by the templating engine #[doc(hidden)] - fn next_token( + fn next_terminal( &self, input: &mut ParserContext<'_>, - ) -> Option; + ) -> Option; // NOTE: These are context-insensitive #[doc(hidden)] fn leading_trivia(&self, input: &mut ParserContext<'_>) -> ParserResult; @@ -69,40 +69,40 @@ pub(crate) trait Lexer { /// Returns valid grouping delimiters in the given lexical context. fn delimiters() -> &'static [(TerminalKind, TerminalKind)]; - /// Peeks the next token, including trivia. Does not advance the input. - fn peek_token( + /// Peeks the next terminal, including trivia. Does not advance the input. + fn peek_terminal( &self, input: &mut ParserContext<'_>, - ) -> Option { + ) -> Option { let start = input.position(); - let token = self.next_token::(input); + let terminal = self.next_terminal::(input); input.set_position(start); - token + terminal } - /// Peeks the next significant (i.e. non-trivia) token. Does not advance the input. - fn peek_token_with_trivia( + /// Peeks the next significant (i.e. non-trivia) terminal. Does not advance the input. + fn peek_terminal_with_trivia( &self, input: &mut ParserContext<'_>, - ) -> Option { + ) -> Option { let start = input.position(); let _ = self.leading_trivia(input); - let token = self.next_token::(input); + let terminal = self.next_terminal::(input); input.set_position(start); - token + terminal } - /// Attempts to consume the next expected token. Advances the input only if the token matches. - fn parse_token( + /// Attempts to consume the next expected terminal. Advances the input only if the terminal matches. + fn parse_terminal( &self, input: &mut ParserContext<'_>, kind: TerminalKind, ) -> ParserResult { let start = input.position(); if !self - .next_token::(input) + .next_terminal::(input) .is_some_and(|t| t.accepted_as(kind)) { input.set_position(start); @@ -119,9 +119,9 @@ pub(crate) trait Lexer { ) } - /// Attempts to consume the next significant token including both leading and trailing trivia. - /// Advances the input only if the token matches. - fn parse_token_with_trivia( + /// Attempts to consume the next significant terminal including both leading and trailing trivia. + /// Advances the input only if the terminal matches. + fn parse_terminal_with_trivia( &self, input: &mut ParserContext<'_>, kind: TerminalKind, @@ -137,7 +137,7 @@ pub(crate) trait Lexer { let start = input.position(); if !self - .next_token::(input) + .next_terminal::(input) .is_some_and(|t| t.accepted_as(kind)) { input.set_position(restore); diff --git a/crates/codegen/runtime/cargo/src/runtime/mod.rs b/crates/codegen/runtime/cargo/src/runtime/mod.rs index 217fdca380..bd7d5f55f5 100644 --- a/crates/codegen/runtime/cargo/src/runtime/mod.rs +++ b/crates/codegen/runtime/cargo/src/runtime/mod.rs @@ -28,7 +28,7 @@ mod metaslang_cst { pub enum KindTypes {} impl metaslang_cst::KindTypes for KindTypes { - type NonTerminalKind = crate::kinds::NonTerminalKind; + type NonterminalKind = crate::kinds::NonterminalKind; type TerminalKind = crate::kinds::TerminalKind; type EdgeLabel = crate::kinds::EdgeLabel; } @@ -40,7 +40,7 @@ pub mod cst { use super::metaslang_cst::KindTypes; pub type Node = cst::Node; - pub type NonTerminalNode = cst::NonTerminalNode; + pub type NonterminalNode = cst::NonterminalNode; pub type TerminalNode = cst::TerminalNode; pub type Edge = cst::Edge; } 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 d22b695618..b6e6577bec 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, NonTerminalNode, TerminalNode}; -use crate::napi_interface::{NonTerminalKind, RustEdge, RustNode, RustNonTerminalNode, TerminalKind}; +use crate::napi_interface::cst::{NAPINodeExtensions, NonterminalNode, TerminalNode}; +use crate::napi_interface::{NonterminalKind, RustEdge, RustNode, RustNonterminalNode, TerminalKind}; // // Sequences: @@ -18,8 +18,8 @@ use crate::napi_interface::{NonTerminalKind, RustEdge, RustNode, RustNonTerminal catch_unwind, )] pub fn select_sequence( - #[napi(ts_arg_type = "cst.NonTerminalNode")] node: &NonTerminalNode, -) -> 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 -%} - NonTerminalKind::{{ sequence.name }} => { + NonterminalKind::{{ sequence.name }} => { selector.{{ sequence.name | snake_case }}()? }, {%- endfor -%} @@ -44,7 +44,7 @@ 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 -%} @@ -53,7 +53,7 @@ pub fn select_sequence( {%- if field.is_terminal -%} node.is_terminal_with_kind(TerminalKind::{{ field.reference }}) {%- else -%} - node.is_nonterminal_with_kind(NonTerminalKind::{{ field.reference }}) + node.is_nonterminal_with_kind(NonterminalKind::{{ field.reference }}) {%- endif -%} })?, @@ -63,7 +63,7 @@ pub fn select_sequence( {%- if field.is_terminal -%} node.is_terminal_with_kind(TerminalKind::{{ field.reference }}) {%- else -%} - node.is_nonterminal_with_kind(NonTerminalKind::{{ 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.NonTerminalNode")] node: &NonTerminalNode, -) -> 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 -%} - NonTerminalKind::{{ choice.name }} => { + NonterminalKind::{{ choice.name }} => { selector.{{ choice.name | snake_case }}()? }, {%- endfor -%} @@ -111,22 +111,22 @@ 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 nonterminals_len = choice.nonterminals | length -%} {%- set terminals_len = choice.terminals | length -%} - {%- if non_terminals_len == 1 -%} - node.is_nonterminal_with_kind(NonTerminalKind::{{ choice.non_terminals[0] }}) - {%- elif non_terminals_len > 1 -%} + {%- if nonterminals_len == 1 -%} + node.is_nonterminal_with_kind(NonterminalKind::{{ choice.nonterminals[0] }}) + {%- elif nonterminals_len > 1 -%} node.is_nonterminal_with_kinds(&[ - {%- for non_terminal in choice.non_terminals -%} - NonTerminalKind::{{ non_terminal }}, + {%- for nonterminal in choice.nonterminals -%} + NonterminalKind::{{ nonterminal }}, {%- endfor -%} ]) {%- endif -%} - {%- if non_terminals_len > 0 and terminals_len > 0 -%} + {%- if nonterminals_len > 0 and terminals_len > 0 -%} || {%- endif -%} @@ -155,8 +155,8 @@ pub fn select_choice( catch_unwind, )] pub fn select_repeated( - #[napi(ts_arg_type = "cst.NonTerminalNode")] node: &NonTerminalNode, -) -> 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 -%} - NonTerminalKind::{{ 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_terminal_with_kind(TerminalKind::{{ repeated.reference }}) {%- else -%} - node.is_nonterminal_with_kind(NonTerminalKind::{{ 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.NonTerminalNode")] node: &NonTerminalNode, -) -> 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 -%} - NonTerminalKind::{{ separated.name }} => { + NonterminalKind::{{ separated.name }} => { selector.{{ separated.name | snake_case }}()? }, {%- endfor -%} @@ -236,7 +236,7 @@ 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![]; @@ -244,7 +244,7 @@ pub fn select_separated( {%- if separated.is_terminal -%} node.is_terminal_with_kind(TerminalKind::{{ separated.reference }}) {%- else -%} - node.is_nonterminal_with_kind(NonTerminalKind::{{ separated.reference }}) + node.is_nonterminal_with_kind(NonterminalKind::{{ separated.reference }}) {%- endif -%} })? { separated.push(first); @@ -256,7 +256,7 @@ pub fn select_separated( {%- if separated.is_terminal -%} node.is_terminal_with_kind(TerminalKind::{{ separated.reference }}) {%- else -%} - node.is_nonterminal_with_kind(NonTerminalKind::{{ separated.reference }}) + node.is_nonterminal_with_kind(NonterminalKind::{{ separated.reference }}) {%- endif -%} })?); } @@ -273,26 +273,26 @@ pub fn select_separated( // struct Selector { - node: Rc, + node: Rc, index: usize, } impl Selector { - fn new(node: &NonTerminalNode) -> 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() => { @@ -304,7 +304,7 @@ impl Selector { node: RustNode::Terminal(terminal), .. } if matches!(terminal.kind, TerminalKind::SKIPPED) => { - return Error::SkippedToken(self.index).into(); + return Error::SkippedTerminal(self.index).into(); } labeled if filter(labeled) => { self.index += 1; @@ -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 NonTerminalKind '{0}'.")] - UnexpectedParent(NonTerminalKind), + #[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}'.")] @@ -345,8 +345,8 @@ enum Error { MissingChild(usize), // Can happen if the user decided to use an incorrect/incomplete CST node. - #[error("Unexpected SKIPPED token at index '{0}'. Creating AST types from incorrect/incomplete CST nodes is not supported yet.")] - SkippedToken(usize), + #[error("Unexpected SKIPPED terminal at index '{0}'. Creating AST types from incorrect/incomplete CST nodes is not supported yet.")] + SkippedTerminal(usize), } impl From for Result { 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 ea4bfb1060..246c57b941 100644 --- a/crates/codegen/runtime/cargo/src/runtime/napi_interface/cst.rs +++ b/crates/codegen/runtime/cargo/src/runtime/napi_interface/cst.rs @@ -6,24 +6,24 @@ use napi_derive::napi; use crate::napi_interface::cursor::Cursor; use crate::napi_interface::text_index::TextIndex; use crate::napi_interface::{ - NonTerminalKind, RustNode, RustNonTerminalNode, RustTerminalNode, RustTextIndex, TerminalKind, + NonterminalKind, RustNode, RustNonterminalNode, RustTerminalNode, RustTextIndex, TerminalKind, }; #[napi(namespace = "cst", string_enum)] pub enum NodeType { - NonTerminal, + 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 `NonTerminalNode | TerminalNode` 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::NonTerminal(nonterminal) => Either::A(NonTerminalNode(nonterminal)), + RustNode::Nonterminal(nonterminal) => Either::A(NonterminalNode(nonterminal)), RustNode::Terminal(terminal) => Either::B(TerminalNode(terminal)), } } @@ -31,26 +31,26 @@ impl NAPINodeExtensions for RustNode { #[derive(Debug)] #[napi(namespace = "cst")] -pub struct NonTerminalNode(pub(crate) Rc); +pub struct NonterminalNode(pub(crate) Rc); #[derive(Debug)] #[napi(namespace = "cst")] pub struct TerminalNode(pub(crate) Rc); #[napi(namespace = "cst")] -impl NonTerminalNode { +impl NonterminalNode { #[napi( getter, js_name = "type", - ts_return_type = "NodeType.NonTerminal", + ts_return_type = "NodeType.Nonterminal", catch_unwind )] pub fn tipe(&self) -> NodeType { - NodeType::NonTerminal + NodeType::Nonterminal } - #[napi(getter, ts_return_type = "kinds.NonTerminalKind", catch_unwind)] - pub fn kind(&self) -> NonTerminalKind { + #[napi(getter, ts_return_type = "kinds.NonterminalKind", catch_unwind)] + pub fn kind(&self) -> NonterminalKind { self.0.kind } @@ -65,7 +65,7 @@ impl NonTerminalNode { } #[napi(ts_return_type = "Array", catch_unwind)] - pub fn children(&self) -> Vec> { + pub fn children(&self) -> Vec> { self.0 .children .iter() @@ -78,13 +78,13 @@ impl NonTerminalNode { &self, #[napi(ts_arg_type = "text_index.TextIndex")] text_offset: TextIndex, ) -> Cursor { - RustNode::NonTerminal(Rc::clone(&self.0)) + RustNode::Nonterminal(Rc::clone(&self.0)) .cursor_with_offset(text_offset.into()) .into() } + /// Serialize the node to JSON. #[napi(catch_unwind, js_name = "toJSON")] - /// Serialize the token node to JSON. pub fn to_json(&self) -> String { serde_json::to_string(&self.0).unwrap() } @@ -105,7 +105,7 @@ impl NonTerminalNode { skip_typescript, catch_unwind )] - pub fn __children(&self) -> Vec> { + pub fn __children(&self) -> Vec> { Self::children(self) } @@ -157,10 +157,8 @@ impl TerminalNode { self.0.text.clone() } + /// Serialize the node to JSON. #[napi(catch_unwind, js_name = "toJSON")] - /// Serialize the terminal node to JSON. - /// - /// This method is intended for debugging purposes and may not be stable. pub fn to_json(&self) -> String { serde_json::to_string(&self.0).unwrap() } 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 8aa88d5c9e..3d880b8b37 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, NonTerminalNode, TerminalNode}; -use crate::napi_interface::{text_index, EdgeLabel, NonTerminalKind, RustCursor, TerminalKind}; +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,7 +52,7 @@ 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() } @@ -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::NonTerminalNode).collect() + #[napi(ts_return_type = "Array", catch_unwind)] + pub fn ancestors(&self) -> Vec { + self.0.ancestors().map(cst::NonterminalNode).collect() } #[napi(catch_unwind)] @@ -141,7 +141,7 @@ impl Cursor { } #[napi(catch_unwind)] - pub fn go_to_next_token_with_kinds( + pub fn go_to_next_terminal_with_kinds( &mut self, #[napi(ts_arg_type = "Array")] kinds: Vec, ) -> bool { @@ -156,7 +156,7 @@ impl Cursor { #[napi(catch_unwind)] pub fn go_to_next_nonterminal_with_kind( &mut self, - #[napi(ts_arg_type = "kinds.NonTerminalKind")] kind: NonTerminalKind, + #[napi(ts_arg_type = "kinds.NonterminalKind")] kind: NonterminalKind, ) -> bool { self.0.go_to_next_nonterminal_with_kind(kind) } @@ -164,7 +164,7 @@ impl Cursor { #[napi(catch_unwind)] 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_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 cdc56e2e65..ecff8ea39e 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,9 +7,9 @@ use std::rc::Rc; use napi::Either; use napi_derive::napi; -use crate::napi_interface::cst::{NAPINodeExtensions, NonTerminalNode, TerminalNode}; +use crate::napi_interface::cst::{NAPINodeExtensions, NonterminalNode, TerminalNode}; use crate::napi_interface::{ - NonTerminalKind, RustEdge, RustNode, RustNonTerminalNode, TerminalKind, + NonterminalKind, RustEdge, RustNode, RustNonterminalNode, TerminalKind, }; // @@ -22,8 +22,8 @@ use crate::napi_interface::{ catch_unwind )] pub fn select_sequence( - #[napi(ts_arg_type = "cst.NonTerminalNode")] node: &NonTerminalNode, -) -> Result>>> { + #[napi(ts_arg_type = "cst.NonterminalNode")] node: &NonterminalNode, +) -> Result>>> { unreachable!("Invoking AST selectors in stubs: {node:#?}") } // // Choices: @@ -31,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.NonTerminalNode")] node: &NonTerminalNode, -) -> Result> { + #[napi(ts_arg_type = "cst.NonterminalNode")] node: &NonterminalNode, +) -> Result> { unreachable!("Invoking AST selectors in stubs: {node:#?}") } @@ -46,8 +46,8 @@ pub fn select_choice( catch_unwind )] pub fn select_repeated( - #[napi(ts_arg_type = "cst.NonTerminalNode")] node: &NonTerminalNode, -) -> Result>> { + #[napi(ts_arg_type = "cst.NonterminalNode")] node: &NonterminalNode, +) -> Result>> { unreachable!("Invoking AST selectors in stubs: {node:#?}") } @@ -61,8 +61,8 @@ pub fn select_repeated( catch_unwind )] pub fn select_separated( - #[napi(ts_arg_type = "cst.NonTerminalNode")] node: &NonTerminalNode, -) -> Result>>> { + #[napi(ts_arg_type = "cst.NonterminalNode")] node: &NonterminalNode, +) -> Result>>> { unreachable!("Invoking AST selectors in stubs: {node:#?}") } @@ -71,12 +71,12 @@ pub fn select_separated( // struct Selector { - node: Rc, + node: Rc, index: usize, } impl Selector { - fn new(node: &NonTerminalNode) -> Self { + fn new(node: &NonterminalNode) -> Self { Self { node: Rc::clone(&node.0), index: 0, @@ -86,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(), @@ -96,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() => { @@ -108,7 +108,7 @@ impl Selector { node: RustNode::Terminal(terminal), .. } if matches!(terminal.kind, TerminalKind::SKIPPED) => { - return Error::SkippedToken(self.index).into(); + return Error::SkippedTerminal(self.index).into(); } labeled if filter(labeled) => { self.index += 1; @@ -137,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 NonTerminalKind '{0}'.")] - UnexpectedParent(NonTerminalKind), + #[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}'.")] @@ -149,8 +149,8 @@ enum Error { MissingChild(usize), // Can happen if the user decided to use an incorrect/incomplete CST node. - #[error("Unexpected SKIPPED token at index '{0}'. Creating AST types from incorrect/incomplete CST nodes is not supported yet.")] - SkippedToken(usize), + #[error("Unexpected SKIPPED terminal at index '{0}'. Creating AST types from incorrect/incomplete CST nodes is not supported yet.")] + SkippedTerminal(usize), } impl From for Result { 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 199869abc8..64ca90db24 100644 --- a/crates/codegen/runtime/cargo/src/runtime/napi_interface/mod.rs +++ b/crates/codegen/runtime/cargo/src/runtime/napi_interface/mod.rs @@ -16,11 +16,11 @@ type RustParseOutput = crate::parse_output::ParseOutput; type RustQuery = crate::query::Query; type RustQueryMatch = crate::query::QueryMatch; type RustQueryMatchIterator = crate::query::QueryMatchIterator; -type RustNonTerminalNode = crate::cst::NonTerminalNode; +type RustNonterminalNode = crate::cst::NonterminalNode; type RustTextIndex = crate::text_index::TextIndex; type RustTextRange = crate::text_index::TextRange; type RustTerminalNode = crate::cst::TerminalNode; -type NonTerminalKind = crate::kinds::NonTerminalKind; +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 8a518e1074..b76a7bdd63 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, NonTerminalNode, TerminalNode}; +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/napi_interface/query.rs b/crates/codegen/runtime/cargo/src/runtime/napi_interface/query.rs index c2a7867bcd..1a3744b2e6 100644 --- a/crates/codegen/runtime/cargo/src/runtime/napi_interface/query.rs +++ b/crates/codegen/runtime/cargo/src/runtime/napi_interface/query.rs @@ -39,16 +39,16 @@ pub struct QueryMatchIterator(RustQueryMatchIterator); pub struct QueryMatch { pub query_number: u32, #[napi(ts_type = "{ [key: string]: cursor.Cursor[] }")] - pub bindings: HashMap>>, + pub captures: HashMap>>, } impl QueryMatch { - fn new(env: Env, result: RustQueryMatch) -> napi::Result { + fn new(env: Env, r#match: RustQueryMatch) -> napi::Result { #[allow(clippy::cast_possible_truncation)] - let query_number = result.query_number as u32; - // transfer all of the bindings eagerly on the assumption + let query_number = r#match.query_number as u32; + // transfer all of the captures eagerly on the assumption // that they've all been explicitly requested. - let bindings = result + let captures = r#match .captures .into_iter() .map(|(key, values)| { @@ -63,7 +63,7 @@ impl QueryMatch { Ok(Self { query_number, - bindings, + captures, }) } } @@ -79,7 +79,7 @@ impl QueryMatchIterator { #[napi(catch_unwind)] pub fn next(&mut self, env: Env) -> napi::Result> { match self.0.next() { - Some(result) => Ok(Some(QueryMatch::new(env, result)?)), + Some(r#match) => Ok(Some(QueryMatch::new(env, r#match)?)), None => Ok(None), } } diff --git a/crates/codegen/runtime/cargo/src/runtime/parse_error.rs b/crates/codegen/runtime/cargo/src/runtime/parse_error.rs index 52c1a9e0ad..c32cc0eff5 100644 --- a/crates/codegen/runtime/cargo/src/runtime/parse_error.rs +++ b/crates/codegen/runtime/cargo/src/runtime/parse_error.rs @@ -6,7 +6,7 @@ use crate::text_index::TextRange; #[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) terminals_that_would_have_allowed_more_progress: Vec, } impl ParseError { @@ -14,13 +14,13 @@ impl ParseError { &self.text_range } - pub fn tokens_that_would_have_allowed_more_progress(&self) -> Vec { - let tokens_that_would_have_allowed_more_progress = self - .tokens_that_would_have_allowed_more_progress + pub fn terminals_that_would_have_allowed_more_progress(&self) -> Vec { + let terminals_that_would_have_allowed_more_progress = self + .terminals_that_would_have_allowed_more_progress .iter() .collect::>(); - tokens_that_would_have_allowed_more_progress + terminals_that_would_have_allowed_more_progress .into_iter() .map(TerminalKind::to_string) .collect() @@ -34,11 +34,11 @@ impl ParseError { impl ParseError { pub(crate) fn new( text_range: TextRange, - tokens_that_would_have_allowed_more_progress: Vec, + terminals_that_would_have_allowed_more_progress: Vec, ) -> Self { Self { text_range, - tokens_that_would_have_allowed_more_progress, + terminals_that_would_have_allowed_more_progress, } } } @@ -54,14 +54,14 @@ pub(crate) fn render_error_report( let kind = ReportKind::Error; let color = if with_color { Color::Red } else { Color::Unset }; - let tokens_that_would_have_allowed_more_progress = - error.tokens_that_would_have_allowed_more_progress(); - let message = if tokens_that_would_have_allowed_more_progress.is_empty() { + let terminals_that_would_have_allowed_more_progress = + error.terminals_that_would_have_allowed_more_progress(); + let message = if terminals_that_would_have_allowed_more_progress.is_empty() { "Expected end of file.".to_string() } else { format!( "Expected {expectations}.", - expectations = tokens_that_would_have_allowed_more_progress.join(" or ") + expectations = terminals_that_would_have_allowed_more_progress.join(" or ") ) }; 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 e0949ab1e7..4581bda92f 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 @@ -52,9 +52,11 @@ impl ChoiceHelper { return; } - // Still no match, extend the possible expected tokens. + // Still no match, extend the possible expected terminals. (ParserResult::NoMatch(running), ParserResult::NoMatch(next)) => { - running.expected_tokens.extend(next.expected_tokens.clone()); + running + .expected_terminals + .extend(next.expected_terminals.clone()); false } // Otherwise, we already have some match, so we ignore a next missing one. @@ -63,7 +65,7 @@ impl ChoiceHelper { // Try to improve our match. (_, ParserResult::Match(next)) if next.is_full_recursive() => true, (_, ParserResult::PrattOperatorMatch(..)) => true, - // Optimize for matches that have a longer span of non-skipped tokens. + // Optimize for matches that have a longer span of non-skipped terminals. (cur, next) => total_not_skipped_span(cur) < total_not_skipped_span(next), }; @@ -121,7 +123,7 @@ impl ChoiceHelper { } } -/// Returns the total length of the span of tokens that were not skipped. +/// Returns the total length of the span of terminals that were not skipped. pub fn total_not_skipped_span(result: &ParserResult) -> usize { let nodes = match result { ParserResult::Match(match_) => &match_.nodes, diff --git a/crates/codegen/runtime/cargo/src/runtime/parser_support/mod.rs b/crates/codegen/runtime/cargo/src/runtime/parser_support/mod.rs index 2673e34ebf..d76fa9e8a5 100644 --- a/crates/codegen/runtime/cargo/src/runtime/parser_support/mod.rs +++ b/crates/codegen/runtime/cargo/src/runtime/parser_support/mod.rs @@ -26,7 +26,7 @@ pub(crate) use parser_result::ParserResult; #[allow(unused_imports)] pub(crate) use precedence_helper::PrecedenceHelper; #[allow(unused_imports)] -pub(crate) use recovery::TokenAcceptanceThreshold; +pub(crate) use recovery::TerminalAcceptanceThreshold; #[allow(unused_imports)] pub(crate) use repetition_helper::{OneOrMoreHelper, ZeroOrMoreHelper}; #[allow(unused_imports)] diff --git a/crates/codegen/runtime/cargo/src/runtime/parser_support/optional_helper.rs b/crates/codegen/runtime/cargo/src/runtime/parser_support/optional_helper.rs index 94c8543f42..b0de767853 100644 --- a/crates/codegen/runtime/cargo/src/runtime/parser_support/optional_helper.rs +++ b/crates/codegen/runtime/cargo/src/runtime/parser_support/optional_helper.rs @@ -6,9 +6,9 @@ impl OptionalHelper { pub fn transform(result: ParserResult) -> ParserResult { match result { // If there's absolutely no match, we treat it as a match (for the purposes of the Result algebra) - // but we bubble up the information which tokens would have allowed more progress. + // but we bubble up the information which terminals would have allowed more progress. ParserResult::NoMatch(no_match) => { - ParserResult::r#match(vec![], no_match.expected_tokens) + ParserResult::r#match(vec![], no_match.expected_terminals) } // ... otherwise we return the result as-is ParserResult::Match(_) 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 743e6c85fb..5d3e5ef725 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 @@ -29,7 +29,7 @@ where if let ParserResult::Match(r#match) = &mut result { let [topmost] = r#match.nodes.as_mut_slice() else { unreachable!( - "Match at the top level of a parse does not have exactly one Rule node" + "Match at the top level of a parse does not have exactly one Nonterminal node" ) }; @@ -40,7 +40,7 @@ where _ => None, }; - if let (cst::Node::NonTerminal(nonterminal), Some(eof_trivia)) = + if let (cst::Node::Nonterminal(nonterminal), Some(eof_trivia)) = (&mut topmost.node, eof_trivia) { let mut new_children = nonterminal.children.clone(); @@ -60,22 +60,22 @@ where parse_tree: cst::Node::terminal(TerminalKind::SKIPPED, input.to_string()), errors: vec![ParseError::new( TextIndex::ZERO..input.into(), - no_match.expected_tokens, + no_match.expected_terminals, )], }, some_match => { - let (nodes, expected_tokens) = match some_match { + let (nodes, expected_terminals) = match some_match { ParserResult::PrattOperatorMatch(..) | ParserResult::NoMatch(..) => { unreachable!("Handled above") } ParserResult::Match(Match { nodes, - expected_tokens, + expected_terminals, }) | ParserResult::IncompleteMatch(IncompleteMatch { nodes, - expected_tokens, - }) => (nodes, expected_tokens), + expected_terminals, + }) => (nodes, expected_terminals), ParserResult::SkippedUntil(SkippedUntil { nodes, expected, .. @@ -83,9 +83,9 @@ where }; let topmost_node = match &nodes[..] { - [Edge { node: cst::Node::NonTerminal(nonterminal), ..} ] => Rc::clone(nonterminal), + [Edge { node: cst::Node::Nonterminal(nonterminal), ..} ] => Rc::clone(nonterminal), [_] => unreachable!( - "(Incomplete)Match at the top level of a parser is not a Rule node" + "(Incomplete)Match at the top level of a parser is not a Nonterminal node" ), _ => unreachable!( "(Incomplete)Match at the top level of a parser does not have exactly one node" @@ -109,14 +109,14 @@ where new_children.push(Edge::anonymous(skipped_node)); let mut errors = stream.into_errors(); - errors.push(ParseError::new(start..input.into(), expected_tokens)); + errors.push(ParseError::new(start..input.into(), expected_terminals)); ParseOutput { parse_tree: cst::Node::nonterminal(topmost_node.kind, new_children), errors, } } else { - let parse_tree = cst::Node::NonTerminal(topmost_node); + 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 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 6e93306e39..eafe7417eb 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 @@ -3,7 +3,7 @@ use std::ops::ControlFlow; use metaslang_cst::TerminalKind as _; use crate::cst::{self, Edge, Node}; -use crate::kinds::{EdgeLabel, NonTerminalKind, TerminalKind}; +use crate::kinds::{EdgeLabel, NonterminalKind, TerminalKind}; use crate::text_index::TextIndex; #[derive(PartialEq, Eq, Clone, Debug)] @@ -18,22 +18,22 @@ pub enum ParserResult { impl Default for ParserResult { fn default() -> Self { Self::NoMatch(NoMatch { - expected_tokens: vec![], + expected_terminals: vec![], }) } } impl ParserResult { - pub fn r#match(nodes: Vec, expected_tokens: Vec) -> Self { - ParserResult::Match(Match::new(nodes, expected_tokens)) + pub fn r#match(nodes: Vec, expected_terminals: Vec) -> Self { + ParserResult::Match(Match::new(nodes, expected_terminals)) } pub fn pratt_operator_match(elements: Vec) -> Self { ParserResult::PrattOperatorMatch(PrattOperatorMatch::new(elements)) } - pub fn incomplete_match(nodes: Vec, expected_tokens: Vec) -> Self { - ParserResult::IncompleteMatch(IncompleteMatch::new(nodes, expected_tokens)) + pub fn incomplete_match(nodes: Vec, expected_terminals: Vec) -> Self { + ParserResult::IncompleteMatch(IncompleteMatch::new(nodes, expected_terminals)) } /// Whenever a parser didn't run because it's disabled due to versioning. Shorthand for `no_match(vec![])`. @@ -41,26 +41,26 @@ impl ParserResult { Self::no_match(vec![]) } - pub fn no_match(expected_tokens: Vec) -> Self { - ParserResult::NoMatch(NoMatch::new(expected_tokens)) + pub fn no_match(expected_terminals: Vec) -> Self { + ParserResult::NoMatch(NoMatch::new(expected_terminals)) } #[must_use] - pub fn with_kind(self, new_kind: NonTerminalKind) -> ParserResult { + pub fn with_kind(self, new_kind: NonterminalKind) -> ParserResult { match self { ParserResult::Match(r#match) => ParserResult::r#match( vec![Edge::anonymous(cst::Node::nonterminal( new_kind, r#match.nodes, ))], - r#match.expected_tokens, + r#match.expected_terminals, ), ParserResult::IncompleteMatch(incomplete_match) => ParserResult::incomplete_match( vec![Edge::anonymous(cst::Node::nonterminal( new_kind, incomplete_match.nodes, ))], - incomplete_match.expected_tokens, + incomplete_match.expected_terminals, ), ParserResult::SkippedUntil(skipped) => ParserResult::SkippedUntil(SkippedUntil { nodes: vec![Edge::anonymous(cst::Node::nonterminal( @@ -84,7 +84,7 @@ impl ParserResult { { *prev_label = Some(label); } - // Also allow to name a single trivia token node + // Also allow to name a single trivia terminal node else if let ParserResult::Match(Match { nodes, .. }) = &mut self { if let [node] = nodes.as_mut_slice() { if node.as_terminal().is_some_and(|tok| tok.kind.is_trivia()) { @@ -122,15 +122,15 @@ impl ParserResult { #[derive(PartialEq, Eq, Clone, Debug)] pub struct Match { pub nodes: Vec, - /// Tokens that would have allowed for more progress. Collected for the purposes of error reporting. - pub expected_tokens: Vec, + /// Terminals that would have allowed for more progress. Collected for the purposes of error reporting. + pub expected_terminals: Vec, } impl Match { - pub fn new(nodes: Vec, expected_tokens: Vec) -> Self { + pub fn new(nodes: Vec, expected_terminals: Vec) -> Self { Self { nodes, - expected_tokens, + expected_terminals, } } @@ -148,18 +148,18 @@ pub enum PrattElement { nodes: Vec, }, Prefix { - kind: NonTerminalKind, + kind: NonterminalKind, nodes: Vec, right: u8, }, Binary { - kind: NonTerminalKind, + kind: NonterminalKind, nodes: Vec, left: u8, right: u8, }, Postfix { - kind: NonTerminalKind, + kind: NonterminalKind, nodes: Vec, left: u8, }, @@ -192,20 +192,20 @@ impl PrattOperatorMatch { #[derive(PartialEq, Eq, Clone, Debug)] pub struct IncompleteMatch { pub nodes: Vec, - /// Tokens that would have allowed for more progress. Collected for the purposes of error reporting. - pub expected_tokens: Vec, + /// Terminals that would have allowed for more progress. Collected for the purposes of error reporting. + pub expected_terminals: Vec, } impl IncompleteMatch { - pub fn new(nodes: Vec, expected_tokens: Vec) -> Self { + pub fn new(nodes: Vec, expected_terminals: Vec) -> Self { Self { nodes, - expected_tokens, + expected_terminals, } } - /// Whether this prefix-matched at least `n` (non-skipped) significant tokens. - pub fn matches_at_least_n_tokens(&self, n: u8) -> bool { + /// Whether this prefix-matched at least `n` (non-skipped) significant terminals. + pub fn matches_at_least_n_terminals(&self, n: u8) -> bool { let result = self .nodes .iter() @@ -236,13 +236,13 @@ 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, + /// Terminals that would have allowed for more progress. Collected for the purposes of error reporting. + pub expected_terminals: Vec, } impl NoMatch { - pub fn new(expected_tokens: Vec) -> Self { - Self { expected_tokens } + pub fn new(expected_terminals: Vec) -> Self { + Self { expected_terminals } } } @@ -251,8 +251,8 @@ pub struct SkippedUntil { pub nodes: Vec, /// Skipped text following the last node pub skipped: String, - /// At which token was the stream pointing at when we bailed + /// At which terminal was the stream pointing at when we bailed pub found: TerminalKind, - /// Token we expected to skip until + /// Terminal we expected to skip until 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 fa3bde8f59..cfda2349bc 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, Edge}; -use crate::kinds::{EdgeLabel, NonTerminalKind}; +use crate::kinds::{EdgeLabel, NonterminalKind}; use crate::parser_support::parser_result::PrattElement::{ self, Binary, Expression, Postfix, Prefix, }; @@ -9,7 +9,7 @@ pub struct PrecedenceHelper; impl PrecedenceHelper { pub fn to_prefix_operator( - kind: NonTerminalKind, + kind: NonterminalKind, right: u8, result: ParserResult, ) -> ParserResult { @@ -27,7 +27,7 @@ impl PrecedenceHelper { } pub fn to_postfix_operator( - kind: NonTerminalKind, + kind: NonterminalKind, left: u8, result: ParserResult, ) -> ParserResult { @@ -45,7 +45,7 @@ impl PrecedenceHelper { } pub fn to_binary_operator( - kind: NonTerminalKind, + kind: NonterminalKind, left: u8, right: u8, result: ParserResult, @@ -66,7 +66,7 @@ impl PrecedenceHelper { #[allow(clippy::too_many_lines, clippy::redundant_else)] // Explicit on purpose, see below. pub fn reduce_precedence_result( - child_kind: NonTerminalKind, + child_kind: NonterminalKind, result: ParserResult, ) -> ParserResult { // This requires some careful thinking. It could be more compact, @@ -160,7 +160,7 @@ impl PrecedenceHelper { // 2. Reduce the operator and it's child expressions to a new expression let make_expression = |left: Option, - kind: NonTerminalKind, + kind: NonterminalKind, nodes: Vec, right: Option| { assert!(left.is_some() || right.is_some()); 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 b7a5781ac5..b482b9fb44 100644 --- a/crates/codegen/runtime/cargo/src/runtime/parser_support/recovery.rs +++ b/crates/codegen/runtime/cargo/src/runtime/parser_support/recovery.rs @@ -1,17 +1,17 @@ use crate::cst; use crate::kinds::{IsLexicalContext, TerminalKind}; -use crate::lexer::{Lexer, ScannedToken}; +use crate::lexer::{Lexer, ScannedTerminal}; use crate::parse_error::ParseError; use crate::parser_support::context::ParserContext; use crate::parser_support::parser_result::SkippedUntil; use crate::parser_support::ParserResult; use crate::text_index::{TextRange, TextRangeExtensions}; -/// How many tokens have to be matched to trigger the error recovery. +/// How many terminals have to be matched to trigger the error recovery. /// For ambiguous syntaxes this needs to be set to at least N, where N -/// is the token lookahead required to disambiguate the syntax. +/// is the terminal lookahead required to disambiguate the syntax. #[derive(Clone, Copy)] -pub(crate) struct TokenAcceptanceThreshold(pub(crate) u8); +pub(crate) struct TerminalAcceptanceThreshold(pub(crate) u8); fn opt_parse( input: &mut ParserContext<'_>, @@ -27,19 +27,19 @@ fn opt_parse( } impl ParserResult { - /// For partial matches (partial prefix match or if the next token after the match is not expected) - /// attempts to skip tokens until a given token is found or until we hit a delimiter that's expected + /// For partial matches (partial prefix match or if the next terminal after the match is not expected) + /// attempts to skip terminals until a given terminal is found or until we hit a delimiter that's expected /// by an outer parse. Returns [`ParserResult::SkippedUntil`] on success. /// - /// Respects nested delimiters, i.e. the `expected` token is only accepted if it's not nested inside. - /// Does not consume the `expected` token. + /// Respects nested delimiters, i.e. the `expected` terminal is only accepted if it's not nested inside. + /// Does not consume the `expected` terminal. #[must_use] pub(crate) fn recover_until_with_nested_delims( self, input: &mut ParserContext<'_>, lexer: &L, expected: TerminalKind, - acceptance_threshold: TokenAcceptanceThreshold, + acceptance_threshold: TerminalAcceptanceThreshold, ) -> ParserResult { enum ParseResultKind { Match, @@ -49,26 +49,30 @@ impl ParserResult { let before_recovery = input.position(); - let (mut nodes, mut expected_tokens, result_kind) = match self { + let (mut nodes, mut expected_terminals, result_kind) = match self { ParserResult::IncompleteMatch(result) - if result.matches_at_least_n_tokens(acceptance_threshold.0) => + if result.matches_at_least_n_terminals(acceptance_threshold.0) => { ( result.nodes, - result.expected_tokens, + result.expected_terminals, ParseResultKind::Incomplete, ) } ParserResult::Match(result) if lexer - .peek_token_with_trivia::(input) - .map(ScannedToken::unambiguous) + .peek_terminal_with_trivia::(input) + .map(ScannedTerminal::unambiguous) != Some(expected) => { - (result.nodes, result.expected_tokens, ParseResultKind::Match) + ( + result.nodes, + result.expected_terminals, + ParseResultKind::Match, + ) } ParserResult::NoMatch(result) if acceptance_threshold.0 == 0 => { - (vec![], result.expected_tokens, ParseResultKind::NoMatch) + (vec![], result.expected_terminals, ParseResultKind::NoMatch) } // No need to recover, so just return as-is. _ => return self, @@ -81,14 +85,14 @@ impl ParserResult { { nodes.extend(leading_trivia); if matches!(result_kind, ParseResultKind::Match) { - expected_tokens.push(expected); + expected_terminals.push(expected); } let skipped = input.content(skipped_range.utf8()); input.emit(ParseError { text_range: skipped_range, - tokens_that_would_have_allowed_more_progress: expected_tokens.clone(), + terminals_that_would_have_allowed_more_progress: expected_terminals.clone(), }); ParserResult::SkippedUntil(SkippedUntil { @@ -102,21 +106,21 @@ impl ParserResult { input.set_position(before_recovery); match result_kind { - ParseResultKind::Match => ParserResult::r#match(nodes, expected_tokens), + ParseResultKind::Match => ParserResult::r#match(nodes, expected_terminals), ParseResultKind::Incomplete => { - ParserResult::incomplete_match(nodes, expected_tokens) + ParserResult::incomplete_match(nodes, expected_terminals) } - ParseResultKind::NoMatch => ParserResult::no_match(expected_tokens), + ParseResultKind::NoMatch => ParserResult::no_match(expected_terminals), } } } } -/// Skips tokens until a given token is found or until we hit a closing delimiter that's expected by an outer parse. -/// Respects nested delimiters, i.e. the `expected` token is only accepted if it's not nested inside. -/// Does not consume the `expected` token. +/// Skips terminals until a given terminal is found or until we hit a closing delimiter that's expected by an outer parse. +/// Respects nested delimiters, i.e. the `expected` terminal is only accepted if it's not nested inside. +/// Does not consume the `expected` terminal. /// -/// Returns the found token and the range of skipped tokens on success. +/// Returns the found terminal and the range of skipped terminals on success. pub(crate) fn skip_until_with_nested_delims( input: &mut ParserContext<'_>, lexer: &L, @@ -130,27 +134,27 @@ pub(crate) fn skip_until_with_nested_delims( loop { let save = input.position(); match lexer - .next_token::(input) - .map(ScannedToken::unambiguous) + .next_terminal::(input) + .map(ScannedTerminal::unambiguous) { // If we're not skipping past a local delimited group (delimiter stack is empty), - // we can unwind on a token that's expected by us or by our ancestor. - Some(token) + // we can unwind on a terminal that's expected by us or by our ancestor. + Some(terminal) if local_delims.is_empty() - && (token == until || input.closing_delimiters().contains(&token)) => + && (terminal == until || input.closing_delimiters().contains(&terminal)) => { // Don't consume the delimiter; parent will consume it input.set_position(save); - return Some((token, start..save)); + return Some((terminal, start..save)); } // Found the local closing delimiter, pop the stack - Some(token) if local_delims.last() == Some(&token) => { + Some(terminal) if local_delims.last() == Some(&terminal) => { local_delims.pop(); } - Some(token) => { + Some(terminal) => { // Found a local opening delimiter, skip until we find a closing one - if let Some((_, close)) = delims.iter().find(|(op, _)| token == *op) { + if let Some((_, close)) = delims.iter().find(|(op, _)| terminal == *op) { local_delims.push(*close); } else { // Keep eating (eventually hits EOF) diff --git a/crates/codegen/runtime/cargo/src/runtime/parser_support/repetition_helper.rs b/crates/codegen/runtime/cargo/src/runtime/parser_support/repetition_helper.rs index e8257595c8..012c338b0d 100644 --- a/crates/codegen/runtime/cargo/src/runtime/parser_support/repetition_helper.rs +++ b/crates/codegen/runtime/cargo/src/runtime/parser_support/repetition_helper.rs @@ -23,9 +23,9 @@ impl RepetitionHelper { result @ ParserResult::SkippedUntil(_) => return result, // Couldn't get a full match but we allow 0 items - return an empty match - // so the parse is considered valid but note the expected tokens - ParserResult::NoMatch(NoMatch { expected_tokens }) if MIN_COUNT == 0 => { - return ParserResult::r#match(vec![], expected_tokens); + // so the parse is considered valid but note the expected terminals + ParserResult::NoMatch(NoMatch { expected_terminals }) if MIN_COUNT == 0 => { + return ParserResult::r#match(vec![], expected_terminals); } // Don't try repeating if we don't have a full match and we require at least one incomplete_or_no_match => return incomplete_or_no_match, @@ -38,7 +38,7 @@ impl RepetitionHelper { match (&mut accum, next_result) { (ParserResult::Match(running), ParserResult::Match(next)) => { running.nodes.extend(next.nodes); - running.expected_tokens = next.expected_tokens; + running.expected_terminals = next.expected_terminals; } (ParserResult::PrattOperatorMatch(cur), ParserResult::PrattOperatorMatch(next)) => { @@ -52,16 +52,16 @@ impl RepetitionHelper { "Match seen while repeating PrattOperatorMatches in RepetitionHelper" ), // Can't proceed further with a complete parse, so back up, return - // the accumulated result and note the expected tokens + // the accumulated result and note the expected terminals ( ParserResult::Match(running), ParserResult::IncompleteMatch(IncompleteMatch { - expected_tokens, .. + expected_terminals, .. }) - | ParserResult::NoMatch(NoMatch { expected_tokens }), + | ParserResult::NoMatch(NoMatch { expected_terminals }), ) => { input.rewind(save); - running.expected_tokens = expected_tokens; + running.expected_terminals = expected_terminals; return accum; } 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 a2c8fe01bb..13f2769416 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 @@ -23,10 +23,10 @@ impl SeparatedHelper { ParserResult::Match(r#match) => { accum.extend(r#match.nodes); - match lexer.peek_token_with_trivia::(input) { + match lexer.peek_terminal_with_trivia::(input) { Some(scanned) if scanned.accepted_as(separator) => { match lexer - .parse_token_with_trivia::(input, separator) + .parse_terminal_with_trivia::(input, separator) .with_label(separator_label) { ParserResult::Match(r#match) => { @@ -39,12 +39,12 @@ impl SeparatedHelper { // Unrecognized, return the accumulated matches. // NOTE: We can't correctly attempt recovery until #600 lands, otherwise we'd risk misparses, - // as we need to stop at certain synchronizing tokens (and we can't reliably scan until + // as we need to stop at certain synchronizing terminals (and we can't reliably scan until // a delimiter, as not every list is enclosed in a delimited group). Some(..) | None => return ParserResult::r#match(accum, vec![separator]), } } - // Body was partially parsed, so try to recover by skipping tokens until we see a separator + // Body was partially parsed, so try to recover by skipping terminals until we see a separator ParserResult::IncompleteMatch(incomplete) => { accum.extend(incomplete.nodes); @@ -59,11 +59,11 @@ impl SeparatedHelper { ))); input.emit(ParseError { text_range: skipped_range, - tokens_that_would_have_allowed_more_progress: incomplete - .expected_tokens, + terminals_that_would_have_allowed_more_progress: incomplete + .expected_terminals, }); - match lexer.parse_token_with_trivia::(input, separator) { + match lexer.parse_terminal_with_trivia::(input, separator) { ParserResult::Match(r#match) => { accum.extend(r#match.nodes); continue; @@ -80,16 +80,16 @@ impl SeparatedHelper { return ParserResult::incomplete_match( accum, - incomplete.expected_tokens, + incomplete.expected_terminals, ); } } } ParserResult::NoMatch(no_match) => { return if accum.is_empty() { - ParserResult::no_match(no_match.expected_tokens) + ParserResult::no_match(no_match.expected_terminals) } else { - ParserResult::incomplete_match(accum, no_match.expected_tokens) + ParserResult::incomplete_match(accum, no_match.expected_terminals) }; } 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 6e99617799..949d83cafb 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 @@ -49,7 +49,7 @@ impl SequenceHelper { // Keep accepting or convert into PrattOperatorMatch (ParserResult::Match(running), ParserResult::Match(next)) => { running.nodes.extend(next.nodes); - running.expected_tokens = next.expected_tokens; + running.expected_terminals = next.expected_terminals; } (ParserResult::Match(running), ParserResult::PrattOperatorMatch(next)) => { let mut children = vec![PrattElement::Expression { @@ -63,15 +63,15 @@ impl SequenceHelper { running.nodes.extend(next.nodes); self.result = State::Running(ParserResult::incomplete_match( std::mem::take(&mut running.nodes), - next.expected_tokens, + next.expected_terminals, )); } (ParserResult::Match(running), ParserResult::NoMatch(next)) => { - running.expected_tokens.extend(next.expected_tokens); + running.expected_terminals.extend(next.expected_terminals); self.result = State::Running(ParserResult::incomplete_match( std::mem::take(&mut running.nodes), - std::mem::take(&mut running.expected_tokens), + std::mem::take(&mut running.expected_terminals), )); } // Keep accepting or convert Match -> PrattOperatorMatch @@ -93,7 +93,7 @@ impl SequenceHelper { .flat_map(PrattElement::into_nodes) .chain(next.nodes) .collect(), - next.expected_tokens, + next.expected_terminals, )); } (ParserResult::PrattOperatorMatch(cur), ParserResult::NoMatch(next)) => { @@ -102,7 +102,7 @@ impl SequenceHelper { .into_iter() .flat_map(PrattElement::into_nodes) .collect(), - next.expected_tokens, + next.expected_terminals, )); } // Enter recovery mode @@ -117,35 +117,35 @@ impl SequenceHelper { (ParserResult::PrattOperatorMatch(_), ParserResult::SkippedUntil(_)) => unreachable!("Error recovery happens outside precedence parsing"), - // Try to recover until we hit an expected boundary token. + // Try to recover until we hit an expected boundary terminal. // If the sequence is unwinding, then a subsequent non-empty match must mean that - // we found the expected token, so we can stop recovering. + // we found the expected terminal, so we can stop recovering. (ParserResult::SkippedUntil(running), ParserResult::Match(next)) => { if next.nodes.is_empty() { return; } - // We only support skipping to a single, significant token. + // We only support skipping to a single, significant terminal. // Sanity check that we are recovering to the expected one. - let next_token = next.nodes.iter().try_fold(None, |acc, node| { + let next_terminal = next.nodes.iter().try_fold(None, |acc, node| { match &**node { - cst::Node::Terminal(token) if token.kind.is_trivia() => Ok(acc), - cst::Node::Terminal(token) => { + cst::Node::Terminal(terminal) if terminal.kind.is_trivia() => Ok(acc), + cst::Node::Terminal(terminal) => { match acc { - None => Ok(Some(token.kind)), + None => Ok(Some(terminal.kind)), Some(..) => { - debug_assert!(false, "Recovery skipped to multiple tokens: {acc:?}, {token:?}"); + debug_assert!(false, "Recovery skipped to multiple terminals: {acc:?}, {terminal:?}"); Err(()) } } } - cst::Node::NonTerminal(node) => { + cst::Node::Nonterminal(node) => { debug_assert!(false, "Recovery skipped to a nonterminal: {node:?}"); Err(()) } } }); - debug_assert_eq!(next_token, Ok(Some(running.found))); + debug_assert_eq!(next_terminal, Ok(Some(running.found))); running.nodes.push(Edge::anonymous(cst::Node::terminal( TerminalKind::SKIPPED, @@ -155,17 +155,17 @@ impl SequenceHelper { self.result = State::Running(ParserResult::Match(Match { nodes: std::mem::take(&mut running.nodes), - expected_tokens: next.expected_tokens, + expected_terminals: next.expected_terminals, })); } // If the sequence is unwinding and and we didn't find a match, then it means // that we recovered past it and we need to push the recovery up. (ParserResult::SkippedUntil(_), ParserResult::NoMatch(_)) => { // Skip any possible subsequent expected elements in this sequence until - // we finally encounter the token we were looking for + // we finally encounter the terminal we were looking for } (ParserResult::SkippedUntil(_), _) => unreachable!( - "Only a single token parse can immediately follow SkippedUntil in sequences and these can either be Match or NoMatch" + "Only a single terminal parse can immediately follow SkippedUntil in sequences and these can either be Match or NoMatch" ), }, } diff --git a/crates/codegen/runtime/generator/src/ast.rs b/crates/codegen/runtime/generator/src/ast.rs index 2b6f5f2611..2a01439490 100644 --- a/crates/codegen/runtime/generator/src/ast.rs +++ b/crates/codegen/runtime/generator/src/ast.rs @@ -35,7 +35,7 @@ pub struct Choice { pub name: model::Identifier, pub terminals: Vec, - pub non_terminals: Vec, + pub nonterminals: Vec, } #[derive(Serialize)] @@ -63,8 +63,8 @@ impl AstModel { // First pass: collect all terminals: model.collect_terminals(language); - // Second pass: use them to build non-terminals: - model.collect_non_terminals(language); + // Second pass: use them to build nonterminals: + model.collect_nonterminals(language); model } @@ -77,7 +77,7 @@ impl AstModel { | model::Item::Repeated { .. } | model::Item::Separated { .. } | model::Item::Precedence { .. } => { - // These items are non-terminals. + // These items are nonterminals. } model::Item::Trivia { item } => { self.terminals.insert(item.name.clone()); @@ -95,7 +95,7 @@ impl AstModel { } } - fn collect_non_terminals(&mut self, language: &model::Language) { + fn collect_nonterminals(&mut self, language: &model::Language) { for item in language.items() { match item { model::Item::Struct { item } => { @@ -139,7 +139,7 @@ impl AstModel { fn add_enum_item(&mut self, item: &model::EnumItem) { let name = item.name.clone(); - let (terminals, non_terminals) = item + let (terminals, nonterminals) = item .variants .iter() .map(|variant| variant.reference.clone()) @@ -148,7 +148,7 @@ impl AstModel { self.choices.push(Choice { name, terminals, - non_terminals, + nonterminals, }); } @@ -191,14 +191,14 @@ impl AstModel { .iter() .map(|expression| expression.reference.clone()); - let (terminals, non_terminals) = precedence_expressions + let (terminals, nonterminals) = precedence_expressions .chain(primary_expressions) .partition(|reference| self.terminals.contains(reference)); self.choices.push(Choice { name, terminals, - non_terminals, + nonterminals, }); } diff --git a/crates/codegen/runtime/generator/src/parser.rs b/crates/codegen/runtime/generator/src/parser.rs index 82c8192503..e420c13645 100644 --- a/crates/codegen/runtime/generator/src/parser.rs +++ b/crates/codegen/runtime/generator/src/parser.rs @@ -36,13 +36,13 @@ pub struct ParserModel { /// Constructs inner `Language` the state to evaluate the version-dependent branches. referenced_versions: BTreeSet, - /// Defines the `NonTerminalKind` enum variants. + /// Defines the `NonterminalKind` enum variants. nonterminal_kinds: BTreeSet, /// Defines the `TerminalKind` enum variants. terminal_kinds: BTreeSet, /// Defines `TerminalKind::is_trivia` method. trivia_scanner_names: BTreeSet, - /// Defines `NodeLabel` enum variants. + /// Defines `EdgeLabel` enum variants. labels: BTreeSet, /// Defines the top-level scanner functions in `Language`. @@ -80,13 +80,13 @@ struct ParserAccumulatorState { /// Constructs inner `Language` the state to evaluate the version-dependent branches. referenced_versions: BTreeSet, - /// Defines the `NonTerminalKind` enum variants. + /// Defines the `NonterminalKind` enum variants. nonterminal_kinds: BTreeSet, /// Defines the `TerminalKind` enum variants. terminal_kinds: BTreeSet, /// Defines `TerminalKind::is_trivia` method. trivia_scanner_names: BTreeSet, - /// Defines `NodeLabel` enum variants. + /// Defines `EdgeLabel` enum variants. labels: BTreeSet, // Defines the `LexicalContext(Type)` enum and type-level variants. @@ -311,7 +311,7 @@ impl GrammarVisitor for ParserAccumulatorState { RustCode( { let nonterminal_kind = format_ident!("{}", parser.name()); - quote! { #code.with_kind(NonTerminalKind::#nonterminal_kind) } + quote! { #code.with_kind(NonterminalKind::#nonterminal_kind) } } .to_string(), ), @@ -326,7 +326,7 @@ impl GrammarVisitor for ParserAccumulatorState { self.nonterminal_kinds.insert(name.clone()); } - // 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, // we generate a function for completeness. for (name, code) in parser.to_precedence_expression_parser_code() { self.parser_functions @@ -339,7 +339,7 @@ impl GrammarVisitor for ParserAccumulatorState { { let code = parser.to_parser_code(); let nonterminal_kind = format_ident!("{}", parser.name()); - quote! { #code.with_kind(NonTerminalKind::#nonterminal_kind) } + quote! { #code.with_kind(NonterminalKind::#nonterminal_kind) } } .to_string(), ), diff --git a/crates/codegen/runtime/generator/src/parser/grammar/constructor.rs b/crates/codegen/runtime/generator/src/parser/grammar/constructor.rs index 0d7256e9ea..000fd320cf 100644 --- a/crates/codegen/runtime/generator/src/parser/grammar/constructor.rs +++ b/crates/codegen/runtime/generator/src/parser/grammar/constructor.rs @@ -10,7 +10,7 @@ use indexmap::IndexMap; use once_cell::sync::Lazy; use crate::parser::grammar::{ - DelimitedRecoveryTokenThreshold, Grammar, GrammarElement, KeywordScannerDefinition, Labeled, + DelimitedRecoveryTerminalThreshold, Grammar, GrammarElement, KeywordScannerDefinition, Labeled, ParserDefinition, ParserDefinitionNode, PrecedenceParserDefinition, PrecedenceParserDefinitionNode, ScannerDefinition, ScannerDefinitionNode, TriviaParserDefinition, @@ -250,8 +250,8 @@ fn resolve_grammar_element(ident: &Identifier, ctx: &mut ResolveCtx<'_>) -> Gram .clone() .unwrap_or_else(|| Identifier::from("Default")); - // The non-terminals are mutually recursive (so will be the resolution of their definitions), - // so make sure to insert a thunk for non-terminals to resolve to break the cycle. + // The nonterminals are mutually recursive (so will be the resolution of their definitions), + // so make sure to insert a thunk for nonterminals to resolve to break the cycle. let inserted_thunk = match (elem, ctx.resolved.contains_key(ident)) { ( Item::Struct { .. } @@ -291,8 +291,8 @@ fn resolve_grammar_element(ident: &Identifier, ctx: &mut ResolveCtx<'_>) -> Gram // Already resolved (None, Some(resolved)) => resolved.clone(), (Some(..), None) => unreachable!("We just inserted a thunk!"), - // First time resolving a non-terminal named `ident` (since we just inserted a thunk) - // Any recursive resolution for this non-terminal will already use the thunk. + // First time resolving a nonterminal named `ident` (since we just inserted a thunk) + // Any recursive resolution for this nonterminal will already use the thunk. // Once we're finished, we initialize the cell with the resolved definition. (Some(thunk), _) => { match elem { @@ -332,7 +332,7 @@ fn resolve_grammar_element(ident: &Identifier, ctx: &mut ResolveCtx<'_>) -> Gram .set(resolve_precedence(item.deref().clone(), &lex_ctx, ctx)) .unwrap(); } - _ => unreachable!("Only non-terminals can be resolved here"), + _ => unreachable!("Only nonterminals can be resolved here"), }; ctx.resolved.get(ident).cloned().unwrap() @@ -544,7 +544,7 @@ fn resolve_sequence_like( let open = delims.next().unwrap(); let close = delims.next().unwrap(); - let threshold = DelimitedRecoveryTokenThreshold::from(delimiters); + let threshold = DelimitedRecoveryTerminalThreshold::from(delimiters); ParserDefinitionNode::DelimitedBy(open, Box::new(delimited_body), close, threshold) }; // Replace with a new delimited node diff --git a/crates/codegen/runtime/generator/src/parser/grammar/parser_definition.rs b/crates/codegen/runtime/generator/src/parser/grammar/parser_definition.rs index e9c6985de6..7c5466b49e 100644 --- a/crates/codegen/runtime/generator/src/parser/grammar/parser_definition.rs +++ b/crates/codegen/runtime/generator/src/parser/grammar/parser_definition.rs @@ -54,21 +54,21 @@ impl Visitable for TriviaParserDefinitionRef { } } -/// How many tokens have to be matched to trigger the error recovery. +/// How many terminals have to be matched to trigger the error recovery. /// For ambiguous syntaxes this needs to be set to at least N, where N -/// is the token lookahead required to disambiguate the syntax. +/// is the terminal lookahead required to disambiguate the syntax. /// // By default, we assume no lookahead (0) is required to recover from // unrecognized body between delimiters, so it's always triggered. #[derive(Clone, Debug, Default)] -pub struct DelimitedRecoveryTokenThreshold(pub u8); +pub struct DelimitedRecoveryTerminalThreshold(pub u8); -impl From for DelimitedRecoveryTokenThreshold { +impl From for DelimitedRecoveryTerminalThreshold { fn from(delimiters: model::FieldDelimiters) -> Self { Self( delimiters - .tokens_matched_acceptance_threshold - .unwrap_or(DelimitedRecoveryTokenThreshold::default().0), + .terminals_matched_acceptance_threshold + .unwrap_or(DelimitedRecoveryTerminalThreshold::default().0), ) } } @@ -90,7 +90,7 @@ pub enum ParserDefinitionNode { Labeled>, Box, Labeled>, - DelimitedRecoveryTokenThreshold, + DelimitedRecoveryTerminalThreshold, ), SeparatedBy(Labeled>, Labeled>), TerminatedBy(Box, Labeled>), diff --git a/crates/codegen/runtime/generator/src/parser/keyword_scanner_definition.rs b/crates/codegen/runtime/generator/src/parser/keyword_scanner_definition.rs index de796d29d5..3129fdb13f 100644 --- a/crates/codegen/runtime/generator/src/parser/keyword_scanner_definition.rs +++ b/crates/codegen/runtime/generator/src/parser/keyword_scanner_definition.rs @@ -13,7 +13,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! { TerminalKind::#name_ident }; + let terminal_kind = quote! { TerminalKind::#name_ident }; let kw_scanners: Vec<_> = self .definitions() @@ -27,14 +27,14 @@ impl KeywordScannerDefinitionExtensions for KeywordScannerDefinitionRef { match (&*reserved_cond.to_string(), &*enabled_cond.to_string()) { ("true", _) => quote! { if #scanner { - KeywordScan::Reserved(#token_kind) + KeywordScan::Reserved(#terminal_kind) } else { KeywordScan::Absent } }, ("false", _) => quote! { if #enabled_cond && #scanner { - KeywordScan::Present(#token_kind) + KeywordScan::Present(#terminal_kind) } else { KeywordScan::Absent } @@ -42,9 +42,9 @@ impl KeywordScannerDefinitionExtensions for KeywordScannerDefinitionRef { (_, "true") => quote! { if #scanner { if #reserved_cond { - KeywordScan::Reserved(#token_kind) + KeywordScan::Reserved(#terminal_kind) } else { - KeywordScan::Present(#token_kind) + KeywordScan::Present(#terminal_kind) } } else { KeywordScan::Absent @@ -52,7 +52,7 @@ impl KeywordScannerDefinitionExtensions for KeywordScannerDefinitionRef { }, (_, "false") => quote! { if #reserved_cond && #scanner { - KeywordScan::Reserved(#token_kind) + KeywordScan::Reserved(#terminal_kind) } else { KeywordScan::Absent } @@ -60,9 +60,9 @@ impl KeywordScannerDefinitionExtensions for KeywordScannerDefinitionRef { _ => quote! { if (#reserved_cond || #enabled_cond) && #scanner { if #reserved_cond { - KeywordScan::Reserved(#token_kind) + KeywordScan::Reserved(#terminal_kind) } else { - KeywordScan::Present(#token_kind) + KeywordScan::Present(#terminal_kind) } } else { KeywordScan::Absent diff --git a/crates/codegen/runtime/generator/src/parser/parser_definition.rs b/crates/codegen/runtime/generator/src/parser/parser_definition.rs index f105770794..9bfc928139 100644 --- a/crates/codegen/runtime/generator/src/parser/parser_definition.rs +++ b/crates/codegen/runtime/generator/src/parser/parser_definition.rs @@ -128,29 +128,29 @@ impl ParserDefinitionNodeExtensions for ParserDefinitionNode { Self::ScannerDefinition(scanner_definition) => { let kind = format_ident!("{name}", name = scanner_definition.name()); - let parse_token = if is_trivia { - format_ident!("parse_token") + let parse_terminal = if is_trivia { + format_ident!("parse_terminal") } else { - format_ident!("parse_token_with_trivia") + format_ident!("parse_terminal_with_trivia") }; quote! { - self.#parse_token::<#lex_ctx>(input, TerminalKind::#kind) + self.#parse_terminal::<#lex_ctx>(input, TerminalKind::#kind) } } - // Keyword scanner uses the promotion inside the parse_token + // Keyword scanner uses the promotion inside the parse_terminal Self::KeywordScannerDefinition(scanner_definition) => { let kind = format_ident!("{name}", name = scanner_definition.name()); - let parse_token = if is_trivia { - format_ident!("parse_token") + let parse_terminal = if is_trivia { + format_ident!("parse_terminal") } else { - format_ident!("parse_token_with_trivia") + format_ident!("parse_terminal_with_trivia") }; quote! { - self.#parse_token::<#lex_ctx>(input, TerminalKind::#kind) + self.#parse_terminal::<#lex_ctx>(input, TerminalKind::#kind) } } @@ -210,7 +210,7 @@ impl ParserDefinitionNodeExtensions for ParserDefinitionNode { .recover_until_with_nested_delims::<_, #lex_ctx>(input, self, TerminalKind::#close_delim, - TokenAcceptanceThreshold(#threshold), + TerminalAcceptanceThreshold(#threshold), ) )?; }, @@ -224,12 +224,12 @@ impl ParserDefinitionNodeExtensions for ParserDefinitionNode { seq.elem_labeled( EdgeLabel::#open_label, - self.parse_token_with_trivia::<#lex_ctx>(input, TerminalKind::#open_delim) + self.parse_terminal_with_trivia::<#lex_ctx>(input, TerminalKind::#open_delim) )?; #body_parser seq.elem_labeled( EdgeLabel::#close_label, - self.parse_token_with_trivia::<#lex_ctx>(input, TerminalKind::#close_delim) + self.parse_terminal_with_trivia::<#lex_ctx>(input, TerminalKind::#close_delim) )?; seq.finish() }) @@ -277,7 +277,7 @@ impl ParserDefinitionNodeExtensions for ParserDefinitionNode { self, TerminalKind::#terminator, // Requires at least a partial match not to risk misparsing - TokenAcceptanceThreshold(1u8), + TerminalAcceptanceThreshold(1u8), ) )?; }, @@ -289,7 +289,7 @@ impl ParserDefinitionNodeExtensions for ParserDefinitionNode { #body_parser seq.elem_labeled( EdgeLabel::#terminator_label, - self.parse_token_with_trivia::<#lex_ctx>(input, TerminalKind::#terminator) + self.parse_terminal_with_trivia::<#lex_ctx>(input, TerminalKind::#terminator) )?; seq.finish() }) diff --git a/crates/codegen/runtime/generator/src/parser/precedence_parser_definition.rs b/crates/codegen/runtime/generator/src/parser/precedence_parser_definition.rs index e572d66d7a..1c27fda53e 100644 --- a/crates/codegen/runtime/generator/src/parser/precedence_parser_definition.rs +++ b/crates/codegen/runtime/generator/src/parser/precedence_parser_definition.rs @@ -41,11 +41,11 @@ impl PrecedenceParserDefinitionExtensions for PrecedenceParserDefinitionRef { let ParserResult::Match(r#match) = &result else { return result; }; // 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. + // can't precisely determine the expected terminals or completeness of the match otherwise. match &r#match.nodes[..] { - [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()) + [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_terminals.clone()) } _ => ParserResult::no_match(vec![]), } @@ -92,7 +92,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. `NonTerminalKind::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 @@ -133,7 +133,7 @@ impl PrecedenceParserDefinitionNodeExtensions for PrecedenceParserDefinitionNode operator_closures.push(quote! { let #closure_name = |input: &mut ParserContext<'_>| PrecedenceHelper::to_binary_operator( - NonTerminalKind::#nonterminal_kind, + NonterminalKind::#nonterminal_kind, #binding_power, #binding_power + 1, #operator_code @@ -145,7 +145,7 @@ impl PrecedenceParserDefinitionNodeExtensions for PrecedenceParserDefinitionNode operator_closures.push(quote! { let #closure_name = |input: &mut ParserContext<'_>| PrecedenceHelper::to_binary_operator( - NonTerminalKind::#nonterminal_kind, + NonterminalKind::#nonterminal_kind, #binding_power + 1, #binding_power, #operator_code @@ -157,7 +157,7 @@ impl PrecedenceParserDefinitionNodeExtensions for PrecedenceParserDefinitionNode operator_closures.push(quote! { let #closure_name = |input: &mut ParserContext<'_>| PrecedenceHelper::to_prefix_operator( - NonTerminalKind::#nonterminal_kind, + NonterminalKind::#nonterminal_kind, #binding_power, #operator_code ); @@ -168,7 +168,7 @@ impl PrecedenceParserDefinitionNodeExtensions for PrecedenceParserDefinitionNode operator_closures.push(quote! { let #closure_name = |input: &mut ParserContext<'_>| PrecedenceHelper::to_postfix_operator( - NonTerminalKind::#nonterminal_kind, + NonterminalKind::#nonterminal_kind, #binding_power, #operator_code ); @@ -231,7 +231,7 @@ impl PrecedenceParserDefinitionNodeExtensions for PrecedenceParserDefinitionNode #operator_closures )* - PrecedenceHelper::reduce_precedence_result(NonTerminalKind::#expression_kind, linear_expression_parser(input)) + PrecedenceHelper::reduce_precedence_result(NonterminalKind::#expression_kind, linear_expression_parser(input)) } } } 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 9013cf80f8..20befc358c 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 { NonTerminalNode, TerminalNode } from "../../cst"; - import { NonTerminalKind, TerminalKind } from "../../kinds"; + import { NonterminalNode, TerminalNode } from "../../cst"; + import { NonterminalKind, TerminalKind } from "../../kinds"; /* * Sequences: @@ -28,14 +28,14 @@ {%- if field.is_terminal -%} ${{ field.name | camel_case }} as TerminalNode, {%- else -%} - new {{ field.reference }}(${{ field.name | camel_case }} as NonTerminalNode), + new {{ field.reference }}(${{ field.name | camel_case }} as NonterminalNode), {%- endif -%} {% endfor -%} }; }); - public constructor(public readonly cst: NonTerminalNode) { - assertKind(this.cst.kind, NonTerminalKind.{{ sequence.name }}); + public constructor(public readonly cst: NonterminalNode) { + assertKind(this.cst.kind, NonterminalKind.{{ sequence.name }}); } {% for field in sequence.fields %} @@ -61,7 +61,7 @@ {% for choice in model.ast.choices %} export class {{ choice.name }} { - {%- set variant_types = choice.non_terminals -%} + {%- set variant_types = choice.nonterminals -%} {%- if choice.terminals | length > 0 -%} {%- set variant_types = variant_types | concat(with = "TerminalNode") -%} {%- endif -%} @@ -71,9 +71,9 @@ const variant = ast_internal.selectChoice(this.cst); switch (variant.kind) { - {%- for non_terminal in choice.non_terminals %} - case NonTerminalKind.{{ non_terminal }}: - return new {{ non_terminal }}(variant as NonTerminalNode); + {%- for nonterminal in choice.nonterminals %} + case NonterminalKind.{{ nonterminal }}: + return new {{ nonterminal }}(variant as NonterminalNode); {%- endfor %} {% if choice.terminals | length > 0 %} @@ -88,8 +88,8 @@ } }); - public constructor(public readonly cst: NonTerminalNode) { - assertKind(this.cst.kind, NonTerminalKind.{{ choice.name }}); + public constructor(public readonly cst: NonterminalNode) { + assertKind(this.cst.kind, NonterminalKind.{{ choice.name }}); } public get variant(): {{ variant_types }} { @@ -110,12 +110,12 @@ {%- if repeated.is_terminal -%} return items as TerminalNode[]; {%- else -%} - return items.map((item) => new {{ repeated.reference }}(item as NonTerminalNode)); + return items.map((item) => new {{ repeated.reference }}(item as NonterminalNode)); {%- endif -%} }); - public constructor(public readonly cst: NonTerminalNode) { - assertKind(this.cst.kind, NonTerminalKind.{{ repeated.name }}); + public constructor(public readonly cst: NonterminalNode) { + assertKind(this.cst.kind, NonterminalKind.{{ repeated.name }}); } public get items(): @@ -143,14 +143,14 @@ {%- if separated.is_terminal -%} items: items as TerminalNode[], {%- else -%} - items: items.map((item) => new {{ separated.reference }}(item as NonTerminalNode)), + items: items.map((item) => new {{ separated.reference }}(item as NonterminalNode)), {%- endif -%} separators: separators as TerminalNode[], }; }); - public constructor(public readonly cst: NonTerminalNode) { - assertKind(this.cst.kind, NonTerminalKind.{{ separated.name }}); + public constructor(public readonly cst: NonterminalNode) { + assertKind(this.cst.kind, NonterminalKind.{{ separated.name }}); } public get items(): @@ -183,7 +183,7 @@ }; } - function assertKind(actual: NonTerminalKind, expected: NonTerminalKind): 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 bd7bbd94e7..12fe01f690 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 NonTerminalNode = generated.cst.NonTerminalNode; -export type NonTerminalNode = generated.cst.NonTerminalNode; +export const NonterminalNode = generated.cst.NonterminalNode; +export type NonterminalNode = generated.cst.NonterminalNode; 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 7dbab0e96d..34423ca2fb 100644 --- a/crates/codegen/runtime/npm/src/runtime/kinds/index.ts +++ b/crates/codegen/runtime/npm/src/runtime/kinds/index.ts @@ -1,7 +1,7 @@ import * as generated from "../napi-bindings/generated"; -export const NonTerminalKind = generated.kinds.NonTerminalKind; -export type NonTerminalKind = generated.kinds.NonTerminalKind; +export const NonterminalKind = generated.kinds.NonterminalKind; +export type NonterminalKind = generated.kinds.NonterminalKind; export const TerminalKind = generated.kinds.TerminalKind; export type TerminalKind = generated.kinds.TerminalKind; 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 cbb7cfb052..536cb7bb59 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,7 +9,7 @@ /* auto-generated by NAPI-RS */ export namespace kinds { - export enum NonTerminalKind { + export enum NonterminalKind { Stub1 = "Stub1", Stub2 = "Stub2", Stub3 = "Stub3", @@ -39,21 +39,21 @@ export namespace language { constructor(version: string); get version(): string; static supportedVersions(): Array; - parse(kind: kinds.NonTerminalKind, input: string): parse_output.ParseOutput; + parse(kind: kinds.NonterminalKind, input: string): parse_output.ParseOutput; } } export namespace cst { export enum NodeType { - NonTerminal = "NonTerminal", + Nonterminal = "Nonterminal", Terminal = "Terminal", } - export class NonTerminalNode { - get type(): NodeType.NonTerminal; - get kind(): kinds.NonTerminalKind; + 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; - /** Serialize the token node to JSON. */ + /** Serialize the node to JSON. */ toJSON(): string; unparse(): string; } @@ -62,11 +62,7 @@ export namespace cst { get kind(): kinds.TerminalKind; get textLength(): text_index.TextIndex; get text(): string; - /** - * Serialize the terminal node to JSON. - * - * This method is intended for debugging purposes and may not be stable. - */ + /** Serialize the node to JSON. */ toJSON(): string; createCursor(textOffset: text_index.TextIndex): cursor.Cursor; } @@ -83,7 +79,7 @@ export namespace cursor { get textOffset(): text_index.TextIndex; get textRange(): text_index.TextRange; get depth(): number; - ancestors(): Array; + ancestors(): Array; goToNext(): boolean; goToNextNonDescendent(): boolean; goToPrevious(): boolean; @@ -95,10 +91,10 @@ export namespace cursor { goToPreviousSibling(): boolean; goToNextTerminal(): boolean; goToNextTerminalWithKind(kind: kinds.TerminalKind): boolean; - goToNextTokenWithKinds(kinds: Array): boolean; + goToNextTerminalWithKinds(kinds: Array): boolean; goToNextNonterminal(): boolean; - goToNextNonterminalWithKind(kind: kinds.NonTerminalKind): boolean; - goToNextNonterminalWithKinds(kinds: Array): boolean; + goToNextNonterminalWithKind(kind: kinds.NonterminalKind): boolean; + goToNextNonterminalWithKinds(kinds: Array): boolean; query(queries: Array): query.QueryMatchIterator; } } @@ -120,7 +116,7 @@ export namespace parse_output { export namespace query { export interface QueryMatch { queryNumber: number; - bindings: { [key: string]: cursor.Cursor[] }; + captures: { [key: string]: cursor.Cursor[] }; } export class Query { static parse(text: string): Query; @@ -142,12 +138,12 @@ export namespace text_index { } } export namespace ast_internal { - 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 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 = TerminalNode | NonTerminalNode; + 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 bf736f11e1..97986be7c3 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 = TerminalNode | NonTerminalNode; + export type Node = TerminalNode | NonterminalNode; } diff --git a/crates/metaslang/cst/src/cst.rs b/crates/metaslang/cst/src/cst.rs index 33cae656db..a82ecc1551 100644 --- a/crates/metaslang/cst/src/cst.rs +++ b/crates/metaslang/cst/src/cst.rs @@ -8,14 +8,14 @@ use crate::{AbstractKind as _, KindTypes, TerminalKind as _}; #[derive(Debug, Copy, Clone, PartialEq, Eq)] pub enum NodeKind { - NonTerminal(T::NonTerminalKind), + Nonterminal(T::NonterminalKind), Terminal(T::TerminalKind), } impl From> for &'static str { fn from(val: NodeKind) -> Self { match val { - NodeKind::NonTerminal(t) => t.as_static_str(), + NodeKind::Nonterminal(t) => t.as_static_str(), NodeKind::Terminal(t) => t.as_static_str(), } } @@ -24,7 +24,7 @@ impl From> for &'static str { impl std::fmt::Display for NodeKind { fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result { match self { - NodeKind::NonTerminal(t) => { + NodeKind::Nonterminal(t) => { write!(f, "{}", t.as_static_str()) } NodeKind::Terminal(t) => { @@ -41,8 +41,8 @@ pub struct TerminalNode { } #[derive(Clone, Debug, PartialEq, Eq, Serialize)] -pub struct NonTerminalNode { - pub kind: T::NonTerminalKind, +pub struct NonterminalNode { + pub kind: T::NonterminalKind, pub text_len: TextIndex, #[serde(skip_serializing_if = "Vec::is_empty")] pub children: Vec>, @@ -50,7 +50,7 @@ pub struct NonTerminalNode { #[derive(Clone, Debug, PartialEq, Eq, Serialize)] pub enum Node { - NonTerminal(Rc>), + Nonterminal(Rc>), Terminal(Rc>), } @@ -76,10 +76,10 @@ impl std::ops::Deref for Edge { } impl Node { - pub fn nonterminal(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::NonTerminal(Rc::new(NonTerminalNode { + Self::Nonterminal(Rc::new(NonterminalNode { kind, text_len, children, @@ -94,21 +94,21 @@ impl Node { /// and cannot be used in a persistent/serialised sense. pub fn id(&self) -> usize { match self { - Self::NonTerminal(node) => Rc::as_ptr(node) as usize, + Self::Nonterminal(node) => Rc::as_ptr(node) as usize, Self::Terminal(node) => Rc::as_ptr(node) as usize, } } pub fn kind(&self) -> NodeKind { match self { - Self::NonTerminal(node) => NodeKind::NonTerminal(node.kind), + Self::Nonterminal(node) => NodeKind::Nonterminal(node.kind), Self::Terminal(node) => NodeKind::Terminal(node.kind), } } pub fn text_len(&self) -> TextIndex { match self { - Self::NonTerminal(node) => node.text_len, + Self::Nonterminal(node) => node.text_len, Self::Terminal(node) => (&node.text).into(), } } @@ -116,7 +116,7 @@ impl Node { /// Returns a slice of the edges (not all descendants) leaving this node. pub fn edges(&self) -> &[Edge] { match self { - Self::NonTerminal(node) => &node.children, + Self::Nonterminal(node) => &node.children, Self::Terminal(_) => &[], } } @@ -138,14 +138,14 @@ impl Node { /// Reconstructs the original source code from the parse tree. pub fn unparse(self) -> String { match self { - Self::NonTerminal(nonterminal) => nonterminal.unparse(), + Self::Nonterminal(nonterminal) => nonterminal.unparse(), Self::Terminal(terminal) => terminal.text.clone(), } } - pub fn into_nonterminal(self) -> Option>> { + pub fn into_nonterminal(self) -> Option>> { match self { - Self::NonTerminal(nonterminal) => Some(nonterminal), + Self::Nonterminal(nonterminal) => Some(nonterminal), Self::Terminal(..) => None, } } @@ -154,32 +154,32 @@ impl Node { self.as_nonterminal().is_some() } - pub fn as_nonterminal(&self) -> Option<&Rc>> { + pub fn as_nonterminal(&self) -> Option<&Rc>> { match self { - Self::NonTerminal(nonterminal) => Some(nonterminal), + Self::Nonterminal(nonterminal) => Some(nonterminal), Self::Terminal(..) => None, } } - pub fn is_nonterminal_with_kind(&self, kind: T::NonTerminalKind) -> bool { + pub fn is_nonterminal_with_kind(&self, kind: T::NonterminalKind) -> bool { self.as_nonterminal_with_kind(kind).is_some() } pub fn as_nonterminal_with_kind( &self, - kind: T::NonTerminalKind, - ) -> Option<&Rc>> { + kind: T::NonterminalKind, + ) -> Option<&Rc>> { self.as_nonterminal().filter(|node| node.kind == kind) } - pub fn is_nonterminal_with_kinds(&self, kinds: &[T::NonTerminalKind]) -> bool { + pub fn is_nonterminal_with_kinds(&self, kinds: &[T::NonterminalKind]) -> bool { self.as_nonterminal_with_kinds(kinds).is_some() } pub fn as_nonterminal_with_kinds( &self, - kinds: &[T::NonTerminalKind], - ) -> Option<&Rc>> { + kinds: &[T::NonterminalKind], + ) -> Option<&Rc>> { self.as_nonterminal() .filter(|nonterminal| kinds.contains(&nonterminal.kind)) } @@ -187,7 +187,7 @@ impl Node { pub fn into_terminal(self) -> Option>> { match self { Self::Terminal(terminal) => Some(terminal), - Self::NonTerminal(..) => None, + Self::Nonterminal(..) => None, } } @@ -198,7 +198,7 @@ impl Node { pub fn as_terminal(&self) -> Option<&Rc>> { match self { Self::Terminal(terminal) => Some(terminal), - Self::NonTerminal(..) => None, + Self::Nonterminal(..) => None, } } @@ -224,15 +224,15 @@ impl Node { pub fn is_trivia(&self) -> bool { match self { - Self::NonTerminal(_) => false, + Self::Nonterminal(_) => false, Self::Terminal(terminal) => terminal.kind.is_trivia(), } } } -impl From>> for Node { - fn from(nonterminal: Rc>) -> Self { - Self::NonTerminal(nonterminal) +impl From>> for Node { + fn from(nonterminal: Rc>) -> Self { + Self::Nonterminal(nonterminal) } } @@ -242,10 +242,10 @@ impl From>> for Node { } } -impl NonTerminalNode { +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::NonTerminal(self), text_offset) + Cursor::new(Node::Nonterminal(self), text_offset) } /// Reconstructs the original source code from the parse tree. diff --git a/crates/metaslang/cst/src/cursor.rs b/crates/metaslang/cst/src/cursor.rs index a040368b94..9e561f1606 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::{Edge, 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>>, - nonterminal_node: Rc>, + nonterminal_node: Rc>, child_number: usize, text_offset: TextIndex, } @@ -36,7 +36,7 @@ pub struct Cursor { impl Cursor { fn as_ancestor_node(&self) -> Option>> { - if let Node::::NonTerminal(nonterminal_node) = &self.node { + if let Node::::Nonterminal(nonterminal_node) = &self.node { Some(Rc::new(PathAncestor { parent: self.parent.clone(), nonterminal_node: nonterminal_node.clone(), @@ -50,7 +50,7 @@ impl Cursor { fn set_from_ancestor_node(&mut self, ancestor: &Rc>) { self.parent = ancestor.parent.clone(); - self.node = Node::::NonTerminal(ancestor.nonterminal_node.clone()); + self.node = Node::::Nonterminal(ancestor.nonterminal_node.clone()); self.child_number = ancestor.child_number; self.text_offset = ancestor.text_offset; } @@ -160,12 +160,12 @@ impl Cursor { } /// Returns an iterator over the current node's ancestors, starting from the parent of the current node. - pub fn ancestors(&self) -> impl Iterator>> { + pub fn ancestors(&self) -> impl Iterator>> { struct Iter { a: Option>>, } impl Iterator for Iter { - type Item = Rc>; + type Item = Rc>; fn next(&mut self) -> Option { if let Some(a) = self.a.take() { @@ -390,24 +390,24 @@ impl Cursor { self.go_to_next_matching(|node| node.is_terminal_with_kinds(kinds)) } - /// Attempts to go to the next non-terminal node, according to the DFS pre-order traversal. + /// Attempts to go to the next nonterminal node, according to the DFS pre-order traversal. /// /// Returns `false` if the cursor is finished and at the root. pub fn go_to_next_nonterminal(&mut self) -> bool { self.go_to_next_matching(|node| node.is_nonterminal()) } - /// Attempts to go to the next non-terminal node with the given kind, according to the DFS pre-order traversal. + /// Attempts to go to the next nonterminal 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_nonterminal_with_kind(&mut self, kind: T::NonTerminalKind) -> bool { + 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 non-terminal node with any of the given kinds, according to the DFS pre-order traversal. + /// Attempts to go to the next nonterminal 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_nonterminal_with_kinds(&mut self, kinds: &[T::NonTerminalKind]) -> bool { + 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)) } diff --git a/crates/metaslang/cst/src/lib.rs b/crates/metaslang/cst/src/lib.rs index 63f81cb801..098854b89a 100644 --- a/crates/metaslang/cst/src/lib.rs +++ b/crates/metaslang/cst/src/lib.rs @@ -38,12 +38,12 @@ pub trait TerminalKind: AbstractKind { } } -pub trait NonTerminalKind: AbstractKind {} +pub trait NonterminalKind: AbstractKind {} pub trait EdgeLabel: AbstractKind {} pub trait KindTypes: std::fmt::Debug + Clone + PartialEq { - type NonTerminalKind: NonTerminalKind; + type NonterminalKind: NonterminalKind; type TerminalKind: TerminalKind; type EdgeLabel: EdgeLabel; } diff --git a/crates/metaslang/cst/src/query/engine.rs b/crates/metaslang/cst/src/query/engine.rs index 74cf7bfb2b..2aa70373b7 100644 --- a/crates/metaslang/cst/src/query/engine.rs +++ b/crates/metaslang/cst/src/query/engine.rs @@ -29,10 +29,10 @@ impl Cursor { fn matches_node_selector(&self, node_selector: &NodeSelector) -> bool { match self.node() { - Node::::NonTerminal(nonterminal) => match node_selector { + Node::::Nonterminal(nonterminal) => match node_selector { NodeSelector::Anonymous => true, NodeSelector::NodeKind { node_kind } => { - NodeKind::NonTerminal(nonterminal.kind) == *node_kind + NodeKind::Nonterminal(nonterminal.kind) == *node_kind } NodeSelector::NodeText { .. } => false, NodeSelector::EdgeLabel { edge_label } => Some(*edge_label) == self.label(), @@ -41,15 +41,15 @@ impl Cursor { node_kind, } => { Some(*edge_label) == self.label() - && NodeKind::NonTerminal(nonterminal.kind) == *node_kind + && NodeKind::Nonterminal(nonterminal.kind) == *node_kind } NodeSelector::EdgeLabelAndNodeText { .. } => false, }, Node::::Terminal(terminal) => match node_selector { NodeSelector::Anonymous => true, - NodeSelector::NodeKind { node_kind: kind } => { - NodeKind::Terminal(terminal.kind) == *kind + NodeSelector::NodeKind { node_kind } => { + NodeKind::Terminal(terminal.kind) == *node_kind } NodeSelector::NodeText { node_text } => terminal.text == *node_text, NodeSelector::EdgeLabel { edge_label } => Some(*edge_label) == self.label(), @@ -73,7 +73,7 @@ impl ASTNode { // This allows for queries to pre-flight against a cursor without allocating fn can_match(&self, cursor: &Cursor) -> bool { match self { - Self::Binding(matcher) => matcher.child.can_match(cursor), + Self::Capture(matcher) => matcher.child.can_match(cursor), Self::NodeMatch(matcher) => cursor.matches_node_selector(&matcher.node_selector), Self::Alternatives(matcher) => matcher.children.iter().any(|c| c.can_match(cursor)), Self::Sequence(matcher) => matcher.children[0].can_match(cursor), @@ -85,7 +85,7 @@ impl ASTNode { fn create_matcher(&self, cursor: Cursor) -> MatcherRef { match self { - Self::Binding(matcher) => Box::new(CaptureMatcher::::new(matcher.clone(), cursor)), + Self::Capture(matcher) => Box::new(CaptureMatcher::::new(matcher.clone(), cursor)), Self::NodeMatch(matcher) => { Box::new(NodeMatchMatcher::::new(matcher.clone(), cursor)) } @@ -191,13 +191,13 @@ impl Iterator for QueryMatchIterator { while !self.cursor.is_completed() { if let Some(matcher) = self.matcher.as_mut() { if matcher.next().is_some() { - let mut bindings = BTreeMap::new(); - matcher.record_captures(&mut bindings); + let mut captures = BTreeMap::new(); + matcher.record_captures(&mut captures); return Some(QueryMatch { queries: Rc::clone(&self.queries), root_cursor: self.cursor.clone(), query_number: self.query_number, - captures: bindings, + captures, }); } self.query_number += 1; @@ -215,7 +215,7 @@ trait Matcher { // Some(cursor) if cursor.is_complete -> matched, end of input // Some(cursor) if !cursor.is_complete -> matched, more input to go fn next(&mut self) -> Option>; - fn record_captures(&self, bindings: &mut BTreeMap>>); + fn record_captures(&self, captures: &mut BTreeMap>>); } type MatcherRef = Box>; @@ -241,12 +241,12 @@ impl Matcher for CaptureMatcher { self.child.next() } - fn record_captures(&self, bindings: &mut BTreeMap>>) { - bindings + fn record_captures(&self, captures: &mut BTreeMap>>) { + captures .entry(self.matcher.name.clone()) .or_default() .push(self.cursor.clone()); - self.child.record_captures(bindings); + self.child.record_captures(captures); } } @@ -312,9 +312,9 @@ impl Matcher for NodeMatchMatcher { None } - fn record_captures(&self, bindings: &mut BTreeMap>>) { + fn record_captures(&self, captures: &mut BTreeMap>>) { if let Some(child) = self.child.as_ref() { - child.record_captures(bindings); + child.record_captures(captures); } } } @@ -363,9 +363,9 @@ impl Matcher for SequenceMatcher { None } - fn record_captures(&self, bindings: &mut BTreeMap>>) { + fn record_captures(&self, captures: &mut BTreeMap>>) { for child in &self.children { - child.record_captures(bindings); + child.record_captures(captures); } } } @@ -409,8 +409,8 @@ impl Matcher for AlternativesMatcher { } } - fn record_captures(&self, bindings: &mut BTreeMap>>) { - self.child.as_ref().unwrap().record_captures(bindings); + fn record_captures(&self, captures: &mut BTreeMap>>) { + self.child.as_ref().unwrap().record_captures(captures); } } @@ -436,9 +436,9 @@ impl Matcher for OptionalMatcher { fn next(&mut self) -> Option> { if let Some(child) = self.child.as_mut() { match child.next() { - result @ Some(_) => { + r#match @ Some(_) => { self.have_nonempty_match = true; - result + r#match } None => { self.child = None; @@ -453,10 +453,10 @@ impl Matcher for OptionalMatcher { } } - fn record_captures(&self, bindings: &mut BTreeMap>>) { + fn record_captures(&self, captures: &mut BTreeMap>>) { if self.have_nonempty_match { if let Some(child) = self.child.as_ref() { - child.record_captures(bindings); + child.record_captures(captures); } } } @@ -504,9 +504,9 @@ impl Matcher for OneOrMoreMatcher { } } - fn record_captures(&self, bindings: &mut BTreeMap>>) { + fn record_captures(&self, captures: &mut BTreeMap>>) { for child in &self.children { - child.record_captures(bindings); + child.record_captures(captures); } } } @@ -539,5 +539,5 @@ impl Matcher for EllipsisMatcher { None } - fn record_captures(&self, _bindings: &mut BTreeMap>>) {} + fn record_captures(&self, _: &mut BTreeMap>>) {} } diff --git a/crates/metaslang/cst/src/query/model.rs b/crates/metaslang/cst/src/query/model.rs index 27798a260e..0e074ecded 100644 --- a/crates/metaslang/cst/src/query/model.rs +++ b/crates/metaslang/cst/src/query/model.rs @@ -23,17 +23,17 @@ impl Query { capture_quantifiers: &mut BTreeMap, ) -> Result<(), QueryError> { match ast_node { - ASTNode::Binding(binding) => { + ASTNode::Capture(capture) => { // If the capture has already been used, return an error - if capture_quantifiers.contains_key(&binding.name) { + if capture_quantifiers.contains_key(&capture.name) { return Err(QueryError { - message: format!("Capture name '{}' used more than once", binding.name), + message: format!("Capture name '{}' used more than once", capture.name), row: 0, column: 0, }); } - capture_quantifiers.insert(binding.name.clone(), quantifier); - collect_capture_quantifiers(&binding.child, quantifier, capture_quantifiers)?; + capture_quantifiers.insert(capture.name.clone(), quantifier); + collect_capture_quantifiers(&capture.child, quantifier, capture_quantifiers)?; } ASTNode::NodeMatch(node_match) => { if let Some(child) = &node_match.child { @@ -106,7 +106,7 @@ impl fmt::Display for Query { #[derive(Clone, Debug)] pub enum ASTNode { - Binding(Rc>), + Capture(Rc>), NodeMatch(Rc>), Optional(Rc>), Alternatives(Rc>), @@ -124,8 +124,8 @@ impl ASTNode { impl fmt::Display for ASTNode { fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result { match self { - Self::Binding(binding) => { - write!(f, "@{} {}", binding.name, binding.child) + Self::Capture(capture) => { + write!(f, "@{} {}", capture.name, capture.child) } Self::NodeMatch(node) => { if let Some(child) = &node.child { diff --git a/crates/metaslang/cst/src/query/parser.rs b/crates/metaslang/cst/src/query/parser.rs index 99c1c49f25..eade2c431a 100644 --- a/crates/metaslang/cst/src/query/parser.rs +++ b/crates/metaslang/cst/src/query/parser.rs @@ -101,14 +101,14 @@ pub(super) fn parse_bound_matcher( i: &str, ) -> IResult<&str, ASTNode, VerboseError<&str>> { pair( - opt(binding_name_token), + opt(capture_name_token), alt(( delimited(token('('), parse_matcher_alternatives::, token(')')), parse_edge, )), ) .map(|(name, child)| match name { - Some(name) => ASTNode::Binding(Rc::new(CaptureASTNode { name, child })), + Some(name) => ASTNode::Capture(Rc::new(CaptureASTNode { name, child })), None => child, }) .parse(i) @@ -198,7 +198,7 @@ fn raw_identifier(i: &str) -> IResult<&str, String, VerboseError<&str>> { .parse(i) } -fn binding_name_token(i: &str) -> IResult<&str, String, VerboseError<&str>> { +fn capture_name_token(i: &str) -> IResult<&str, String, VerboseError<&str>> { terminated(preceded(char('@'), raw_identifier), multispace0).parse(i) } @@ -208,7 +208,7 @@ fn kind_token(i: &str) -> IResult<&str, NodeKind, VerboseError< T::TerminalKind::try_from_str(id.as_str()) .map(NodeKind::Terminal) .or_else(|_| { - T::NonTerminalKind::try_from_str(id.as_str()).map(NodeKind::NonTerminal) + T::NonterminalKind::try_from_str(id.as_str()).map(NodeKind::Nonterminal) }) }), multispace0, diff --git a/crates/metaslang/graph_builder/tests/functions.rs b/crates/metaslang/graph_builder/tests/functions.rs index 370dc544d0..ce10fc4006 100644 --- a/crates/metaslang/graph_builder/tests/functions.rs +++ b/crates/metaslang/graph_builder/tests/functions.rs @@ -26,12 +26,12 @@ pub enum DummyKind { Module, } impl metaslang_cst::TerminalKind for DummyKind {} -impl metaslang_cst::NonTerminalKind for DummyKind {} +impl metaslang_cst::NonterminalKind for DummyKind {} impl metaslang_cst::EdgeLabel for DummyKind {} #[derive(Clone, Debug, PartialEq, Eq, serde::Serialize)] pub struct KindTypes; impl metaslang_cst::KindTypes for KindTypes { - type NonTerminalKind = DummyKind; + type NonterminalKind = DummyKind; type TerminalKind = DummyKind; type EdgeLabel = DummyKind; } diff --git a/crates/metaslang/graph_builder/tests/graph.rs b/crates/metaslang/graph_builder/tests/graph.rs index 5c9587fa1e..edb8a9a2e4 100644 --- a/crates/metaslang/graph_builder/tests/graph.rs +++ b/crates/metaslang/graph_builder/tests/graph.rs @@ -23,12 +23,12 @@ pub enum DummyKind { Module, } impl metaslang_cst::TerminalKind for DummyKind {} -impl metaslang_cst::NonTerminalKind for DummyKind {} +impl metaslang_cst::NonterminalKind for DummyKind {} impl metaslang_cst::EdgeLabel for DummyKind {} #[derive(Clone, Debug, PartialEq, Eq, serde::Serialize)] pub struct KindTypes; impl metaslang_cst::KindTypes for KindTypes { - type NonTerminalKind = DummyKind; + type NonterminalKind = DummyKind; type TerminalKind = DummyKind; type EdgeLabel = DummyKind; } diff --git a/crates/metaslang/graph_builder/tests/parser.rs b/crates/metaslang/graph_builder/tests/parser.rs index 8a5d2c616a..0cd8263338 100644 --- a/crates/metaslang/graph_builder/tests/parser.rs +++ b/crates/metaslang/graph_builder/tests/parser.rs @@ -19,7 +19,7 @@ use metaslang_graph_builder::{Identifier, Location, ParseError}; strum_macros::IntoStaticStr, strum_macros::EnumString, )] -pub enum NonTerminalKind { +pub enum NonterminalKind { Module, FunctionDefinition, PassStatement, @@ -51,12 +51,12 @@ pub enum EdgeLabel { Name, } impl metaslang_cst::TerminalKind for TerminalKind {} -impl metaslang_cst::NonTerminalKind for NonTerminalKind {} +impl metaslang_cst::NonterminalKind for NonterminalKind {} impl metaslang_cst::EdgeLabel for EdgeLabel {} #[derive(Clone, Debug, PartialEq, Eq, serde::Serialize)] pub struct KindTypes; impl metaslang_cst::KindTypes for KindTypes { - type NonTerminalKind = NonTerminalKind; + type NonterminalKind = NonterminalKind; type TerminalKind = TerminalKind; type EdgeLabel = EdgeLabel; } diff --git a/crates/solidity/inputs/language/src/definition.rs b/crates/solidity/inputs/language/src/definition.rs index f3a536ae1d..d1f5f309e1 100644 --- a/crates/solidity/inputs/language/src/definition.rs +++ b/crates/solidity/inputs/language/src/definition.rs @@ -3439,7 +3439,7 @@ codegen_language_macros::compile!(Language( // we can only recover if we found at least two tokens (`ident:`) // in the body, as this may be otherwise ambiguous with // `try { func() } catch {}`. - tokens_matched_acceptance_threshold = 2 + terminals_matched_acceptance_threshold = 2 ) ), fields = ( 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 d1c316a948..013faab58a 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 @@ -18,7 +18,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 NonTerminalKind { +pub enum NonterminalKind { ABICoderPragma, AdditiveExpression, AddressType, @@ -235,7 +235,7 @@ pub enum NonTerminalKind { YulVariableDeclarationValue, } -impl metaslang_cst::NonTerminalKind for NonTerminalKind {} +impl metaslang_cst::NonterminalKind for NonterminalKind {} #[derive( Debug, 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 ae2d196bf4..b81cd28140 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,15 +16,16 @@ use semver::Version; use crate::cst; use crate::kinds::{ - EdgeLabel, IsLexicalContext, LexicalContext, LexicalContextType, NonTerminalKind, TerminalKind, + EdgeLabel, IsLexicalContext, LexicalContext, LexicalContextType, NonterminalKind, TerminalKind, }; -use crate::lexer::{KeywordScan, Lexer, ScannedToken}; +use crate::lexer::{KeywordScan, Lexer, ScannedTerminal}; #[cfg(feature = "slang_napi_interfaces")] use crate::napi_interface::parse_output::ParseOutput as NAPIParseOutput; use crate::parse_output::ParseOutput; use crate::parser_support::{ ChoiceHelper, OneOrMoreHelper, OptionalHelper, ParserContext, ParserFunction, ParserResult, - PrecedenceHelper, SeparatedHelper, SequenceHelper, TokenAcceptanceThreshold, ZeroOrMoreHelper, + PrecedenceHelper, SeparatedHelper, SequenceHelper, TerminalAcceptanceThreshold, + ZeroOrMoreHelper, }; #[derive(Debug)] @@ -219,21 +220,21 @@ impl Language { SequenceHelper::run(|mut seq| { seq.elem_labeled( EdgeLabel::AbicoderKeyword, - self.parse_token_with_trivia::( + self.parse_terminal_with_trivia::( input, TerminalKind::AbicoderKeyword, ), )?; seq.elem_labeled( EdgeLabel::Version, - self.parse_token_with_trivia::( + self.parse_terminal_with_trivia::( input, TerminalKind::Identifier, ), )?; seq.finish() }) - .with_kind(NonTerminalKind::ABICoderPragma) + .with_kind(NonterminalKind::ABICoderPragma) } #[allow(unused_assignments, unused_parens)] @@ -244,14 +245,14 @@ impl Language { }; match &r#match.nodes[..] { [cst::Edge { - node: cst::Node::NonTerminal(node), + node: cst::Node::Nonterminal(node), .. - }] if node.kind == NonTerminalKind::Expression => match &node.children[..] { + }] if node.kind == NonterminalKind::Expression => match &node.children[..] { [inner @ cst::Edge { - node: cst::Node::NonTerminal(node), + node: cst::Node::Nonterminal(node), .. - }] if node.kind == NonTerminalKind::AdditiveExpression => { - ParserResult::r#match(vec![inner.clone()], r#match.expected_tokens.clone()) + }] if node.kind == NonterminalKind::AdditiveExpression => { + ParserResult::r#match(vec![inner.clone()], r#match.expected_terminals.clone()) } _ => ParserResult::no_match(vec![]), }, @@ -264,7 +265,7 @@ impl Language { SequenceHelper::run(|mut seq| { seq.elem_labeled( EdgeLabel::AddressKeyword, - self.parse_token_with_trivia::( + self.parse_terminal_with_trivia::( input, TerminalKind::AddressKeyword, ), @@ -272,7 +273,7 @@ impl Language { seq.elem_labeled( EdgeLabel::PayableKeyword, OptionalHelper::transform( - self.parse_token_with_trivia::( + self.parse_terminal_with_trivia::( input, TerminalKind::PayableKeyword, ), @@ -280,7 +281,7 @@ impl Language { )?; seq.finish() }) - .with_kind(NonTerminalKind::AddressType) + .with_kind(NonterminalKind::AddressType) } #[allow(unused_assignments, unused_parens)] @@ -291,14 +292,14 @@ impl Language { }; match &r#match.nodes[..] { [cst::Edge { - node: cst::Node::NonTerminal(node), + node: cst::Node::Nonterminal(node), .. - }] if node.kind == NonTerminalKind::Expression => match &node.children[..] { + }] if node.kind == NonterminalKind::Expression => match &node.children[..] { [inner @ cst::Edge { - node: cst::Node::NonTerminal(node), + node: cst::Node::Nonterminal(node), .. - }] if node.kind == NonTerminalKind::AndExpression => { - ParserResult::r#match(vec![inner.clone()], r#match.expected_tokens.clone()) + }] if node.kind == NonterminalKind::AndExpression => { + ParserResult::r#match(vec![inner.clone()], r#match.expected_terminals.clone()) } _ => ParserResult::no_match(vec![]), }, @@ -316,7 +317,7 @@ impl Language { choice.finish(input) }) .with_label(EdgeLabel::Variant) - .with_kind(NonTerminalKind::ArgumentsDeclaration) + .with_kind(NonterminalKind::ArgumentsDeclaration) } #[allow(unused_assignments, unused_parens)] @@ -326,7 +327,7 @@ impl Language { let input = delim_guard.ctx(); seq.elem_labeled( EdgeLabel::OpenBracket, - self.parse_token_with_trivia::( + self.parse_terminal_with_trivia::( input, TerminalKind::OpenBracket, ), @@ -338,19 +339,19 @@ impl Language { input, self, TerminalKind::CloseBracket, - TokenAcceptanceThreshold(0u8), + TerminalAcceptanceThreshold(0u8), ), )?; seq.elem_labeled( EdgeLabel::CloseBracket, - self.parse_token_with_trivia::( + self.parse_terminal_with_trivia::( input, TerminalKind::CloseBracket, ), )?; seq.finish() }) - .with_kind(NonTerminalKind::ArrayExpression) + .with_kind(NonterminalKind::ArrayExpression) } #[allow(unused_assignments, unused_parens)] @@ -361,14 +362,14 @@ impl Language { }; match &r#match.nodes[..] { [cst::Edge { - node: cst::Node::NonTerminal(node), + node: cst::Node::Nonterminal(node), .. - }] if node.kind == NonTerminalKind::TypeName => match &node.children[..] { + }] if node.kind == NonterminalKind::TypeName => match &node.children[..] { [inner @ cst::Edge { - node: cst::Node::NonTerminal(node), + node: cst::Node::Nonterminal(node), .. - }] if node.kind == NonTerminalKind::ArrayTypeName => { - ParserResult::r#match(vec![inner.clone()], r#match.expected_tokens.clone()) + }] if node.kind == NonterminalKind::ArrayTypeName => { + ParserResult::r#match(vec![inner.clone()], r#match.expected_terminals.clone()) } _ => ParserResult::no_match(vec![]), }, @@ -385,7 +386,7 @@ impl Language { TerminalKind::Comma, EdgeLabel::Separator, ) - .with_kind(NonTerminalKind::ArrayValues) + .with_kind(NonterminalKind::ArrayValues) } #[allow(unused_assignments, unused_parens)] @@ -397,7 +398,7 @@ impl Language { TerminalKind::Comma, EdgeLabel::Separator, ) - .with_kind(NonTerminalKind::AssemblyFlags) + .with_kind(NonterminalKind::AssemblyFlags) } #[allow(unused_assignments, unused_parens)] @@ -407,7 +408,7 @@ impl Language { let input = delim_guard.ctx(); seq.elem_labeled( EdgeLabel::OpenParen, - self.parse_token_with_trivia::( + self.parse_terminal_with_trivia::( input, TerminalKind::OpenParen, ), @@ -419,19 +420,19 @@ impl Language { input, self, TerminalKind::CloseParen, - TokenAcceptanceThreshold(0u8), + TerminalAcceptanceThreshold(0u8), ), )?; seq.elem_labeled( EdgeLabel::CloseParen, - self.parse_token_with_trivia::( + self.parse_terminal_with_trivia::( input, TerminalKind::CloseParen, ), )?; seq.finish() }) - .with_kind(NonTerminalKind::AssemblyFlagsDeclaration) + .with_kind(NonterminalKind::AssemblyFlagsDeclaration) } #[allow(unused_assignments, unused_parens)] @@ -439,7 +440,7 @@ impl Language { SequenceHelper::run(|mut seq| { seq.elem_labeled( EdgeLabel::AssemblyKeyword, - self.parse_token_with_trivia::( + self.parse_terminal_with_trivia::( input, TerminalKind::AssemblyKeyword, ), @@ -455,7 +456,7 @@ impl Language { seq.elem_labeled(EdgeLabel::Body, self.yul_block(input))?; seq.finish() }) - .with_kind(NonTerminalKind::AssemblyStatement) + .with_kind(NonterminalKind::AssemblyStatement) } #[allow(unused_assignments, unused_parens)] @@ -466,14 +467,14 @@ impl Language { }; match &r#match.nodes[..] { [cst::Edge { - node: cst::Node::NonTerminal(node), + node: cst::Node::Nonterminal(node), .. - }] if node.kind == NonTerminalKind::Expression => match &node.children[..] { + }] if node.kind == NonterminalKind::Expression => match &node.children[..] { [inner @ cst::Edge { - node: cst::Node::NonTerminal(node), + node: cst::Node::Nonterminal(node), .. - }] if node.kind == NonTerminalKind::AssignmentExpression => { - ParserResult::r#match(vec![inner.clone()], r#match.expected_tokens.clone()) + }] if node.kind == NonterminalKind::AssignmentExpression => { + ParserResult::r#match(vec![inner.clone()], r#match.expected_terminals.clone()) } _ => ParserResult::no_match(vec![]), }, @@ -489,14 +490,14 @@ impl Language { }; match &r#match.nodes[..] { [cst::Edge { - node: cst::Node::NonTerminal(node), + node: cst::Node::Nonterminal(node), .. - }] if node.kind == NonTerminalKind::Expression => match &node.children[..] { + }] if node.kind == NonterminalKind::Expression => match &node.children[..] { [inner @ cst::Edge { - node: cst::Node::NonTerminal(node), + node: cst::Node::Nonterminal(node), .. - }] if node.kind == NonTerminalKind::BitwiseAndExpression => { - ParserResult::r#match(vec![inner.clone()], r#match.expected_tokens.clone()) + }] if node.kind == NonterminalKind::BitwiseAndExpression => { + ParserResult::r#match(vec![inner.clone()], r#match.expected_terminals.clone()) } _ => ParserResult::no_match(vec![]), }, @@ -512,14 +513,14 @@ impl Language { }; match &r#match.nodes[..] { [cst::Edge { - node: cst::Node::NonTerminal(node), + node: cst::Node::Nonterminal(node), .. - }] if node.kind == NonTerminalKind::Expression => match &node.children[..] { + }] if node.kind == NonterminalKind::Expression => match &node.children[..] { [inner @ cst::Edge { - node: cst::Node::NonTerminal(node), + node: cst::Node::Nonterminal(node), .. - }] if node.kind == NonTerminalKind::BitwiseOrExpression => { - ParserResult::r#match(vec![inner.clone()], r#match.expected_tokens.clone()) + }] if node.kind == NonterminalKind::BitwiseOrExpression => { + ParserResult::r#match(vec![inner.clone()], r#match.expected_terminals.clone()) } _ => ParserResult::no_match(vec![]), }, @@ -535,14 +536,14 @@ impl Language { }; match &r#match.nodes[..] { [cst::Edge { - node: cst::Node::NonTerminal(node), + node: cst::Node::Nonterminal(node), .. - }] if node.kind == NonTerminalKind::Expression => match &node.children[..] { + }] if node.kind == NonterminalKind::Expression => match &node.children[..] { [inner @ cst::Edge { - node: cst::Node::NonTerminal(node), + node: cst::Node::Nonterminal(node), .. - }] if node.kind == NonTerminalKind::BitwiseXorExpression => { - ParserResult::r#match(vec![inner.clone()], r#match.expected_tokens.clone()) + }] if node.kind == NonterminalKind::BitwiseXorExpression => { + ParserResult::r#match(vec![inner.clone()], r#match.expected_terminals.clone()) } _ => ParserResult::no_match(vec![]), }, @@ -557,7 +558,7 @@ impl Language { let input = delim_guard.ctx(); seq.elem_labeled( EdgeLabel::OpenBrace, - self.parse_token_with_trivia::( + self.parse_terminal_with_trivia::( input, TerminalKind::OpenBrace, ), @@ -569,26 +570,26 @@ impl Language { input, self, TerminalKind::CloseBrace, - TokenAcceptanceThreshold(0u8), + TerminalAcceptanceThreshold(0u8), ), )?; seq.elem_labeled( EdgeLabel::CloseBrace, - self.parse_token_with_trivia::( + self.parse_terminal_with_trivia::( input, TerminalKind::CloseBrace, ), )?; seq.finish() }) - .with_kind(NonTerminalKind::Block) + .with_kind(NonterminalKind::Block) } #[allow(unused_assignments, unused_parens)] fn break_statement(&self, input: &mut ParserContext<'_>) -> ParserResult { SequenceHelper::run(|mut seq| { seq.elem( - self.parse_token_with_trivia::( + self.parse_terminal_with_trivia::( input, TerminalKind::BreakKeyword, ) @@ -597,19 +598,19 @@ impl Language { input, self, TerminalKind::Semicolon, - TokenAcceptanceThreshold(1u8), + TerminalAcceptanceThreshold(1u8), ), )?; seq.elem_labeled( EdgeLabel::Semicolon, - self.parse_token_with_trivia::( + self.parse_terminal_with_trivia::( input, TerminalKind::Semicolon, ), )?; seq.finish() }) - .with_kind(NonTerminalKind::BreakStatement) + .with_kind(NonterminalKind::BreakStatement) } #[allow(unused_assignments, unused_parens)] @@ -625,7 +626,7 @@ impl Language { } else { ParserResult::disabled() } - .with_kind(NonTerminalKind::CallOptions) + .with_kind(NonterminalKind::CallOptions) } #[allow(unused_assignments, unused_parens)] @@ -636,14 +637,14 @@ impl Language { }; match &r#match.nodes[..] { [cst::Edge { - node: cst::Node::NonTerminal(node), + node: cst::Node::Nonterminal(node), .. - }] if node.kind == NonTerminalKind::Expression => match &node.children[..] { + }] if node.kind == NonterminalKind::Expression => match &node.children[..] { [inner @ cst::Edge { - node: cst::Node::NonTerminal(node), + node: cst::Node::Nonterminal(node), .. - }] if node.kind == NonTerminalKind::CallOptionsExpression => { - ParserResult::r#match(vec![inner.clone()], r#match.expected_tokens.clone()) + }] if node.kind == NonterminalKind::CallOptionsExpression => { + ParserResult::r#match(vec![inner.clone()], r#match.expected_terminals.clone()) } _ => ParserResult::no_match(vec![]), }, @@ -657,7 +658,7 @@ impl Language { SequenceHelper::run(|mut seq| { seq.elem_labeled( EdgeLabel::CatchKeyword, - self.parse_token_with_trivia::( + self.parse_terminal_with_trivia::( input, TerminalKind::CatchKeyword, ), @@ -672,7 +673,7 @@ impl Language { } else { ParserResult::disabled() } - .with_kind(NonTerminalKind::CatchClause) + .with_kind(NonterminalKind::CatchClause) } #[allow(unused_assignments, unused_parens)] @@ -682,7 +683,7 @@ impl Language { seq.elem_labeled( EdgeLabel::Name, OptionalHelper::transform( - self.parse_token_with_trivia::( + self.parse_terminal_with_trivia::( input, TerminalKind::Identifier, ), @@ -694,7 +695,7 @@ impl Language { } else { ParserResult::disabled() } - .with_kind(NonTerminalKind::CatchClauseError) + .with_kind(NonterminalKind::CatchClauseError) } #[allow(unused_assignments, unused_parens)] @@ -706,7 +707,7 @@ impl Language { } else { ParserResult::disabled() } - .with_kind(NonTerminalKind::CatchClauses) + .with_kind(NonterminalKind::CatchClauses) } #[allow(unused_assignments, unused_parens)] @@ -717,14 +718,14 @@ impl Language { }; match &r#match.nodes[..] { [cst::Edge { - node: cst::Node::NonTerminal(node), + node: cst::Node::Nonterminal(node), .. - }] if node.kind == NonTerminalKind::Expression => match &node.children[..] { + }] if node.kind == NonterminalKind::Expression => match &node.children[..] { [inner @ cst::Edge { - node: cst::Node::NonTerminal(node), + node: cst::Node::Nonterminal(node), .. - }] if node.kind == NonTerminalKind::ComparisonExpression => { - ParserResult::r#match(vec![inner.clone()], r#match.expected_tokens.clone()) + }] if node.kind == NonterminalKind::ComparisonExpression => { + ParserResult::r#match(vec![inner.clone()], r#match.expected_terminals.clone()) } _ => ParserResult::no_match(vec![]), }, @@ -740,14 +741,14 @@ impl Language { }; match &r#match.nodes[..] { [cst::Edge { - node: cst::Node::NonTerminal(node), + node: cst::Node::Nonterminal(node), .. - }] if node.kind == NonTerminalKind::Expression => match &node.children[..] { + }] if node.kind == NonterminalKind::Expression => match &node.children[..] { [inner @ cst::Edge { - node: cst::Node::NonTerminal(node), + node: cst::Node::Nonterminal(node), .. - }] if node.kind == NonTerminalKind::ConditionalExpression => { - ParserResult::r#match(vec![inner.clone()], r#match.expected_tokens.clone()) + }] if node.kind == NonterminalKind::ConditionalExpression => { + ParserResult::r#match(vec![inner.clone()], r#match.expected_terminals.clone()) } _ => ParserResult::no_match(vec![]), }, @@ -764,21 +765,21 @@ impl Language { seq.elem_labeled(EdgeLabel::TypeName, self.type_name(input))?; seq.elem_labeled( EdgeLabel::ConstantKeyword, - self.parse_token_with_trivia::( + self.parse_terminal_with_trivia::( input, TerminalKind::ConstantKeyword, ), )?; seq.elem_labeled( EdgeLabel::Name, - self.parse_token_with_trivia::( + self.parse_terminal_with_trivia::( input, TerminalKind::Identifier, ), )?; seq.elem_labeled( EdgeLabel::Equal, - self.parse_token_with_trivia::( + self.parse_terminal_with_trivia::( input, TerminalKind::Equal, ), @@ -790,12 +791,12 @@ impl Language { input, self, TerminalKind::Semicolon, - TokenAcceptanceThreshold(1u8), + TerminalAcceptanceThreshold(1u8), ), )?; seq.elem_labeled( EdgeLabel::Semicolon, - self.parse_token_with_trivia::( + self.parse_terminal_with_trivia::( input, TerminalKind::Semicolon, ), @@ -805,7 +806,7 @@ impl Language { } else { ParserResult::disabled() } - .with_kind(NonTerminalKind::ConstantDefinition) + .with_kind(NonterminalKind::ConstantDefinition) } #[allow(unused_assignments, unused_parens)] @@ -814,30 +815,30 @@ impl Language { ChoiceHelper::run(input, |mut choice, input| { let result = self.modifier_invocation(input); choice.consider(input, result)?; - let result = self.parse_token_with_trivia::( + let result = self.parse_terminal_with_trivia::( input, 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::( + let result = self.parse_terminal_with_trivia::( input, TerminalKind::OverrideKeyword, ); choice.consider(input, result)?; } - let result = self.parse_token_with_trivia::( + let result = self.parse_terminal_with_trivia::( input, TerminalKind::PayableKeyword, ); choice.consider(input, result)?; - let result = self.parse_token_with_trivia::( + let result = self.parse_terminal_with_trivia::( input, 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::( + let result = self.parse_terminal_with_trivia::( input, TerminalKind::VirtualKeyword, ); @@ -849,7 +850,7 @@ impl Language { } else { ParserResult::disabled() } - .with_kind(NonTerminalKind::ConstructorAttribute) + .with_kind(NonterminalKind::ConstructorAttribute) } #[allow(unused_assignments, unused_parens)] @@ -862,7 +863,7 @@ impl Language { } else { ParserResult::disabled() } - .with_kind(NonTerminalKind::ConstructorAttributes) + .with_kind(NonterminalKind::ConstructorAttributes) } #[allow(unused_assignments, unused_parens)] @@ -871,7 +872,7 @@ impl Language { SequenceHelper::run(|mut seq| { seq.elem_labeled( EdgeLabel::ConstructorKeyword, - self.parse_token_with_trivia::( + self.parse_terminal_with_trivia::( input, TerminalKind::ConstructorKeyword, ), @@ -884,14 +885,14 @@ impl Language { } else { ParserResult::disabled() } - .with_kind(NonTerminalKind::ConstructorDefinition) + .with_kind(NonterminalKind::ConstructorDefinition) } #[allow(unused_assignments, unused_parens)] fn continue_statement(&self, input: &mut ParserContext<'_>) -> ParserResult { SequenceHelper::run(|mut seq| { seq.elem( - self.parse_token_with_trivia::( + self.parse_terminal_with_trivia::( input, TerminalKind::ContinueKeyword, ) @@ -900,19 +901,19 @@ impl Language { input, self, TerminalKind::Semicolon, - TokenAcceptanceThreshold(1u8), + TerminalAcceptanceThreshold(1u8), ), )?; seq.elem_labeled( EdgeLabel::Semicolon, - self.parse_token_with_trivia::( + self.parse_terminal_with_trivia::( input, TerminalKind::Semicolon, ), )?; seq.finish() }) - .with_kind(NonTerminalKind::ContinueStatement) + .with_kind(NonterminalKind::ContinueStatement) } #[allow(unused_assignments, unused_parens)] @@ -922,7 +923,7 @@ impl Language { seq.elem_labeled( EdgeLabel::AbstractKeyword, OptionalHelper::transform( - self.parse_token_with_trivia::( + self.parse_terminal_with_trivia::( input, TerminalKind::AbstractKeyword, ), @@ -931,14 +932,14 @@ impl Language { } seq.elem_labeled( EdgeLabel::ContractKeyword, - self.parse_token_with_trivia::( + self.parse_terminal_with_trivia::( input, TerminalKind::ContractKeyword, ), )?; seq.elem_labeled( EdgeLabel::Name, - self.parse_token_with_trivia::( + self.parse_terminal_with_trivia::( input, TerminalKind::Identifier, ), @@ -952,7 +953,7 @@ impl Language { let input = delim_guard.ctx(); seq.elem_labeled( EdgeLabel::OpenBrace, - self.parse_token_with_trivia::( + self.parse_terminal_with_trivia::( input, TerminalKind::OpenBrace, ), @@ -964,12 +965,12 @@ impl Language { input, self, TerminalKind::CloseBrace, - TokenAcceptanceThreshold(0u8), + TerminalAcceptanceThreshold(0u8), ), )?; seq.elem_labeled( EdgeLabel::CloseBrace, - self.parse_token_with_trivia::( + self.parse_terminal_with_trivia::( input, TerminalKind::CloseBrace, ), @@ -978,7 +979,7 @@ impl Language { }))?; seq.finish() }) - .with_kind(NonTerminalKind::ContractDefinition) + .with_kind(NonterminalKind::ContractDefinition) } #[allow(unused_assignments, unused_parens)] @@ -1025,7 +1026,7 @@ impl Language { choice.finish(input) }) .with_label(EdgeLabel::Variant) - .with_kind(NonTerminalKind::ContractMember) + .with_kind(NonterminalKind::ContractMember) } #[allow(unused_assignments, unused_parens)] @@ -1033,7 +1034,7 @@ impl Language { ZeroOrMoreHelper::run(input, |input| { self.contract_member(input).with_label(EdgeLabel::Item) }) - .with_kind(NonTerminalKind::ContractMembers) + .with_kind(NonterminalKind::ContractMembers) } #[allow(unused_assignments, unused_parens)] @@ -1041,7 +1042,7 @@ impl Language { SequenceHelper::run(|mut seq| { seq.elem_labeled( EdgeLabel::Literal, - self.parse_token_with_trivia::( + self.parse_terminal_with_trivia::( input, TerminalKind::DecimalLiteral, ), @@ -1052,7 +1053,7 @@ impl Language { )?; seq.finish() }) - .with_kind(NonTerminalKind::DecimalNumberExpression) + .with_kind(NonterminalKind::DecimalNumberExpression) } #[allow(unused_assignments, unused_parens)] @@ -1062,7 +1063,7 @@ impl Language { SequenceHelper::run(|mut seq| { seq.elem_labeled( EdgeLabel::DoKeyword, - self.parse_token_with_trivia::( + self.parse_terminal_with_trivia::( input, TerminalKind::DoKeyword, ), @@ -1070,7 +1071,7 @@ impl Language { seq.elem_labeled(EdgeLabel::Body, self.statement(input))?; seq.elem_labeled( EdgeLabel::WhileKeyword, - self.parse_token_with_trivia::( + self.parse_terminal_with_trivia::( input, TerminalKind::WhileKeyword, ), @@ -1080,7 +1081,7 @@ impl Language { let input = delim_guard.ctx(); seq.elem_labeled( EdgeLabel::OpenParen, - self.parse_token_with_trivia::( + self.parse_terminal_with_trivia::( input, TerminalKind::OpenParen, ), @@ -1092,12 +1093,12 @@ impl Language { input, self, TerminalKind::CloseParen, - TokenAcceptanceThreshold(0u8), + TerminalAcceptanceThreshold(0u8), ), )?; seq.elem_labeled( EdgeLabel::CloseParen, - self.parse_token_with_trivia::( + self.parse_terminal_with_trivia::( input, TerminalKind::CloseParen, ), @@ -1110,64 +1111,64 @@ impl Language { input, self, TerminalKind::Semicolon, - TokenAcceptanceThreshold(1u8), + TerminalAcceptanceThreshold(1u8), ), )?; seq.elem_labeled( EdgeLabel::Semicolon, - self.parse_token_with_trivia::( + self.parse_terminal_with_trivia::( input, TerminalKind::Semicolon, ), )?; seq.finish() }) - .with_kind(NonTerminalKind::DoWhileStatement) + .with_kind(NonterminalKind::DoWhileStatement) } #[allow(unused_assignments, unused_parens)] fn elementary_type(&self, input: &mut ParserContext<'_>) -> ParserResult { ChoiceHelper::run(input, |mut choice, input| { - let result = self.parse_token_with_trivia::( + let result = self.parse_terminal_with_trivia::( input, TerminalKind::BoolKeyword, ); choice.consider(input, result)?; if !self.version_is_at_least_0_8_0 { - let result = self.parse_token_with_trivia::( + let result = self.parse_terminal_with_trivia::( input, TerminalKind::ByteKeyword, ); choice.consider(input, result)?; } - let result = self.parse_token_with_trivia::( + let result = self.parse_terminal_with_trivia::( input, TerminalKind::StringKeyword, ); choice.consider(input, result)?; let result = self.address_type(input); choice.consider(input, result)?; - let result = self.parse_token_with_trivia::( + let result = self.parse_terminal_with_trivia::( input, TerminalKind::BytesKeyword, ); choice.consider(input, result)?; - let result = self.parse_token_with_trivia::( + let result = self.parse_terminal_with_trivia::( input, TerminalKind::IntKeyword, ); choice.consider(input, result)?; - let result = self.parse_token_with_trivia::( + let result = self.parse_terminal_with_trivia::( input, TerminalKind::UintKeyword, ); choice.consider(input, result)?; - let result = self.parse_token_with_trivia::( + let result = self.parse_terminal_with_trivia::( input, TerminalKind::FixedKeyword, ); choice.consider(input, result)?; - let result = self.parse_token_with_trivia::( + let result = self.parse_terminal_with_trivia::( input, TerminalKind::UfixedKeyword, ); @@ -1175,7 +1176,7 @@ impl Language { choice.finish(input) }) .with_label(EdgeLabel::Variant) - .with_kind(NonTerminalKind::ElementaryType) + .with_kind(NonterminalKind::ElementaryType) } #[allow(unused_assignments, unused_parens)] @@ -1183,7 +1184,7 @@ impl Language { SequenceHelper::run(|mut seq| { seq.elem_labeled( EdgeLabel::ElseKeyword, - self.parse_token_with_trivia::( + self.parse_terminal_with_trivia::( input, TerminalKind::ElseKeyword, ), @@ -1191,7 +1192,7 @@ impl Language { seq.elem_labeled(EdgeLabel::Body, self.statement(input))?; seq.finish() }) - .with_kind(NonTerminalKind::ElseBranch) + .with_kind(NonterminalKind::ElseBranch) } #[allow(unused_assignments, unused_parens)] @@ -1202,7 +1203,7 @@ impl Language { SequenceHelper::run(|mut seq| { seq.elem_labeled( EdgeLabel::EmitKeyword, - self.parse_token_with_trivia::( + self.parse_terminal_with_trivia::( input, TerminalKind::EmitKeyword, ), @@ -1215,12 +1216,12 @@ impl Language { input, self, TerminalKind::Semicolon, - TokenAcceptanceThreshold(1u8), + TerminalAcceptanceThreshold(1u8), ), )?; seq.elem_labeled( EdgeLabel::Semicolon, - self.parse_token_with_trivia::( + self.parse_terminal_with_trivia::( input, TerminalKind::Semicolon, ), @@ -1230,7 +1231,7 @@ impl Language { } else { ParserResult::disabled() } - .with_kind(NonTerminalKind::EmitStatement) + .with_kind(NonterminalKind::EmitStatement) } #[allow(unused_assignments, unused_parens)] @@ -1238,14 +1239,14 @@ impl Language { SequenceHelper::run(|mut seq| { seq.elem_labeled( EdgeLabel::EnumKeyword, - self.parse_token_with_trivia::( + self.parse_terminal_with_trivia::( input, TerminalKind::EnumKeyword, ), )?; seq.elem_labeled( EdgeLabel::Name, - self.parse_token_with_trivia::( + self.parse_terminal_with_trivia::( input, TerminalKind::Identifier, ), @@ -1255,7 +1256,7 @@ impl Language { let input = delim_guard.ctx(); seq.elem_labeled( EdgeLabel::OpenBrace, - self.parse_token_with_trivia::( + self.parse_terminal_with_trivia::( input, TerminalKind::OpenBrace, ), @@ -1267,12 +1268,12 @@ impl Language { input, self, TerminalKind::CloseBrace, - TokenAcceptanceThreshold(0u8), + TerminalAcceptanceThreshold(0u8), ), )?; seq.elem_labeled( EdgeLabel::CloseBrace, - self.parse_token_with_trivia::( + self.parse_terminal_with_trivia::( input, TerminalKind::CloseBrace, ), @@ -1281,7 +1282,7 @@ impl Language { }))?; seq.finish() }) - .with_kind(NonTerminalKind::EnumDefinition) + .with_kind(NonterminalKind::EnumDefinition) } #[allow(unused_assignments, unused_parens)] @@ -1290,7 +1291,7 @@ impl Language { input, self, |input| { - self.parse_token_with_trivia::( + self.parse_terminal_with_trivia::( input, TerminalKind::Identifier, ) @@ -1299,7 +1300,7 @@ impl Language { TerminalKind::Comma, EdgeLabel::Separator, )) - .with_kind(NonTerminalKind::EnumMembers) + .with_kind(NonterminalKind::EnumMembers) } #[allow(unused_assignments, unused_parens)] @@ -1310,14 +1311,14 @@ impl Language { }; match &r#match.nodes[..] { [cst::Edge { - node: cst::Node::NonTerminal(node), + node: cst::Node::Nonterminal(node), .. - }] if node.kind == NonTerminalKind::Expression => match &node.children[..] { + }] if node.kind == NonterminalKind::Expression => match &node.children[..] { [inner @ cst::Edge { - node: cst::Node::NonTerminal(node), + node: cst::Node::Nonterminal(node), .. - }] if node.kind == NonTerminalKind::EqualityExpression => { - ParserResult::r#match(vec![inner.clone()], r#match.expected_tokens.clone()) + }] if node.kind == NonterminalKind::EqualityExpression => { + ParserResult::r#match(vec![inner.clone()], r#match.expected_terminals.clone()) } _ => ParserResult::no_match(vec![]), }, @@ -1333,14 +1334,14 @@ impl Language { SequenceHelper::run(|mut seq| { seq.elem_labeled( EdgeLabel::ErrorKeyword, - self.parse_token_with_trivia::( + self.parse_terminal_with_trivia::( input, TerminalKind::ErrorKeyword, ), )?; seq.elem_labeled( EdgeLabel::Name, - self.parse_token_with_trivia::( + self.parse_terminal_with_trivia::( input, TerminalKind::Identifier, ), @@ -1355,12 +1356,12 @@ impl Language { input, self, TerminalKind::Semicolon, - TokenAcceptanceThreshold(1u8), + TerminalAcceptanceThreshold(1u8), ), )?; seq.elem_labeled( EdgeLabel::Semicolon, - self.parse_token_with_trivia::( + self.parse_terminal_with_trivia::( input, TerminalKind::Semicolon, ), @@ -1370,7 +1371,7 @@ impl Language { } else { ParserResult::disabled() } - .with_kind(NonTerminalKind::ErrorDefinition) + .with_kind(NonterminalKind::ErrorDefinition) } #[allow(unused_assignments, unused_parens)] @@ -1381,7 +1382,7 @@ impl Language { seq.elem_labeled( EdgeLabel::Name, OptionalHelper::transform( - self.parse_token_with_trivia::( + self.parse_terminal_with_trivia::( input, TerminalKind::Identifier, ), @@ -1392,7 +1393,7 @@ impl Language { } else { ParserResult::disabled() } - .with_kind(NonTerminalKind::ErrorParameter) + .with_kind(NonterminalKind::ErrorParameter) } #[allow(unused_assignments, unused_parens)] @@ -1408,7 +1409,7 @@ impl Language { } else { ParserResult::disabled() } - .with_kind(NonTerminalKind::ErrorParameters) + .with_kind(NonterminalKind::ErrorParameters) } #[allow(unused_assignments, unused_parens)] @@ -1419,7 +1420,7 @@ impl Language { let input = delim_guard.ctx(); seq.elem_labeled( EdgeLabel::OpenParen, - self.parse_token_with_trivia::( + self.parse_terminal_with_trivia::( input, TerminalKind::OpenParen, ), @@ -1431,12 +1432,12 @@ impl Language { input, self, TerminalKind::CloseParen, - TokenAcceptanceThreshold(0u8), + TerminalAcceptanceThreshold(0u8), ), )?; seq.elem_labeled( EdgeLabel::CloseParen, - self.parse_token_with_trivia::( + self.parse_terminal_with_trivia::( input, TerminalKind::CloseParen, ), @@ -1446,7 +1447,7 @@ impl Language { } else { ParserResult::disabled() } - .with_kind(NonTerminalKind::ErrorParametersDeclaration) + .with_kind(NonterminalKind::ErrorParametersDeclaration) } #[allow(unused_assignments, unused_parens)] @@ -1456,14 +1457,14 @@ impl Language { SequenceHelper::run(|mut seq| { seq.elem_labeled( EdgeLabel::EventKeyword, - self.parse_token_with_trivia::( + self.parse_terminal_with_trivia::( input, TerminalKind::EventKeyword, ), )?; seq.elem_labeled( EdgeLabel::Name, - self.parse_token_with_trivia::( + self.parse_terminal_with_trivia::( input, TerminalKind::Identifier, ), @@ -1475,7 +1476,7 @@ impl Language { seq.elem_labeled( EdgeLabel::AnonymousKeyword, OptionalHelper::transform( - self.parse_token_with_trivia::( + self.parse_terminal_with_trivia::( input, TerminalKind::AnonymousKeyword, ), @@ -1487,19 +1488,19 @@ impl Language { input, self, TerminalKind::Semicolon, - TokenAcceptanceThreshold(1u8), + TerminalAcceptanceThreshold(1u8), ), )?; seq.elem_labeled( EdgeLabel::Semicolon, - self.parse_token_with_trivia::( + self.parse_terminal_with_trivia::( input, TerminalKind::Semicolon, ), )?; seq.finish() }) - .with_kind(NonTerminalKind::EventDefinition) + .with_kind(NonterminalKind::EventDefinition) } #[allow(unused_assignments, unused_parens)] @@ -1509,7 +1510,7 @@ impl Language { seq.elem_labeled( EdgeLabel::IndexedKeyword, OptionalHelper::transform( - self.parse_token_with_trivia::( + self.parse_terminal_with_trivia::( input, TerminalKind::IndexedKeyword, ), @@ -1518,7 +1519,7 @@ impl Language { seq.elem_labeled( EdgeLabel::Name, OptionalHelper::transform( - self.parse_token_with_trivia::( + self.parse_terminal_with_trivia::( input, TerminalKind::Identifier, ), @@ -1526,7 +1527,7 @@ impl Language { )?; seq.finish() }) - .with_kind(NonTerminalKind::EventParameter) + .with_kind(NonterminalKind::EventParameter) } #[allow(unused_assignments, unused_parens)] @@ -1538,7 +1539,7 @@ impl Language { TerminalKind::Comma, EdgeLabel::Separator, )) - .with_kind(NonTerminalKind::EventParameters) + .with_kind(NonterminalKind::EventParameters) } #[allow(unused_assignments, unused_parens)] @@ -1548,7 +1549,7 @@ impl Language { let input = delim_guard.ctx(); seq.elem_labeled( EdgeLabel::OpenParen, - self.parse_token_with_trivia::( + self.parse_terminal_with_trivia::( input, TerminalKind::OpenParen, ), @@ -1560,25 +1561,25 @@ impl Language { input, self, TerminalKind::CloseParen, - TokenAcceptanceThreshold(0u8), + TerminalAcceptanceThreshold(0u8), ), )?; seq.elem_labeled( EdgeLabel::CloseParen, - self.parse_token_with_trivia::( + self.parse_terminal_with_trivia::( input, TerminalKind::CloseParen, ), )?; seq.finish() }) - .with_kind(NonTerminalKind::EventParametersDeclaration) + .with_kind(NonterminalKind::EventParametersDeclaration) } #[allow(unused_assignments, unused_parens)] fn experimental_feature(&self, input: &mut ParserContext<'_>) -> ParserResult { ChoiceHelper::run(input, |mut choice, input| { - let result = self.parse_token_with_trivia::( + let result = self.parse_terminal_with_trivia::( input, TerminalKind::Identifier, ); @@ -1588,7 +1589,7 @@ impl Language { choice.finish(input) }) .with_label(EdgeLabel::Variant) - .with_kind(NonTerminalKind::ExperimentalFeature) + .with_kind(NonterminalKind::ExperimentalFeature) } #[allow(unused_assignments, unused_parens)] @@ -1596,7 +1597,7 @@ impl Language { SequenceHelper::run(|mut seq| { seq.elem_labeled( EdgeLabel::ExperimentalKeyword, - self.parse_token_with_trivia::( + self.parse_terminal_with_trivia::( input, TerminalKind::ExperimentalKeyword, ), @@ -1604,7 +1605,7 @@ impl Language { seq.elem_labeled(EdgeLabel::Feature, self.experimental_feature(input))?; seq.finish() }) - .with_kind(NonTerminalKind::ExperimentalPragma) + .with_kind(NonterminalKind::ExperimentalPragma) } #[allow(unused_assignments, unused_parens)] @@ -1615,14 +1616,14 @@ impl Language { }; match &r#match.nodes[..] { [cst::Edge { - node: cst::Node::NonTerminal(node), + node: cst::Node::Nonterminal(node), .. - }] if node.kind == NonTerminalKind::Expression => match &node.children[..] { + }] if node.kind == NonterminalKind::Expression => match &node.children[..] { [inner @ cst::Edge { - node: cst::Node::NonTerminal(node), + node: cst::Node::Nonterminal(node), .. - }] if node.kind == NonTerminalKind::ExponentiationExpression => { - ParserResult::r#match(vec![inner.clone()], r#match.expected_tokens.clone()) + }] if node.kind == NonterminalKind::ExponentiationExpression => { + ParserResult::r#match(vec![inner.clone()], r#match.expected_terminals.clone()) } _ => ParserResult::no_match(vec![]), }, @@ -1634,89 +1635,89 @@ impl Language { fn expression(&self, input: &mut ParserContext<'_>) -> ParserResult { let parse_left_assignment_expression = |input: &mut ParserContext<'_>| { PrecedenceHelper::to_binary_operator( - NonTerminalKind::AssignmentExpression, + NonterminalKind::AssignmentExpression, 1u8, 1u8 + 1, ChoiceHelper::run(input, |mut choice, input| { let result = self - .parse_token_with_trivia::( + .parse_terminal_with_trivia::( input, TerminalKind::Equal, ) .with_label(EdgeLabel::Operator); choice.consider(input, result)?; let result = self - .parse_token_with_trivia::( + .parse_terminal_with_trivia::( input, TerminalKind::BarEqual, ) .with_label(EdgeLabel::Operator); choice.consider(input, result)?; let result = self - .parse_token_with_trivia::( + .parse_terminal_with_trivia::( input, TerminalKind::PlusEqual, ) .with_label(EdgeLabel::Operator); choice.consider(input, result)?; let result = self - .parse_token_with_trivia::( + .parse_terminal_with_trivia::( input, TerminalKind::MinusEqual, ) .with_label(EdgeLabel::Operator); choice.consider(input, result)?; let result = self - .parse_token_with_trivia::( + .parse_terminal_with_trivia::( input, TerminalKind::CaretEqual, ) .with_label(EdgeLabel::Operator); choice.consider(input, result)?; let result = self - .parse_token_with_trivia::( + .parse_terminal_with_trivia::( input, TerminalKind::SlashEqual, ) .with_label(EdgeLabel::Operator); choice.consider(input, result)?; let result = self - .parse_token_with_trivia::( + .parse_terminal_with_trivia::( input, TerminalKind::PercentEqual, ) .with_label(EdgeLabel::Operator); choice.consider(input, result)?; let result = self - .parse_token_with_trivia::( + .parse_terminal_with_trivia::( input, TerminalKind::AsteriskEqual, ) .with_label(EdgeLabel::Operator); choice.consider(input, result)?; let result = self - .parse_token_with_trivia::( + .parse_terminal_with_trivia::( input, TerminalKind::AmpersandEqual, ) .with_label(EdgeLabel::Operator); choice.consider(input, result)?; let result = self - .parse_token_with_trivia::( + .parse_terminal_with_trivia::( input, TerminalKind::LessThanLessThanEqual, ) .with_label(EdgeLabel::Operator); choice.consider(input, result)?; let result = self - .parse_token_with_trivia::( + .parse_terminal_with_trivia::( input, TerminalKind::GreaterThanGreaterThanEqual, ) .with_label(EdgeLabel::Operator); choice.consider(input, result)?; let result = self - .parse_token_with_trivia::( + .parse_terminal_with_trivia::( input, TerminalKind::GreaterThanGreaterThanGreaterThanEqual, ) @@ -1728,12 +1729,12 @@ impl Language { }; let parse_postfix_conditional_expression = |input: &mut ParserContext<'_>| { PrecedenceHelper::to_postfix_operator( - NonTerminalKind::ConditionalExpression, + NonterminalKind::ConditionalExpression, 3u8, SequenceHelper::run(|mut seq| { seq.elem_labeled( EdgeLabel::QuestionMark, - self.parse_token_with_trivia::( + self.parse_terminal_with_trivia::( input, TerminalKind::QuestionMark, ), @@ -1741,7 +1742,7 @@ impl Language { seq.elem_labeled(EdgeLabel::TrueExpression, self.expression(input))?; seq.elem_labeled( EdgeLabel::Colon, - self.parse_token_with_trivia::( + self.parse_terminal_with_trivia::( input, TerminalKind::Colon, ), @@ -1753,10 +1754,10 @@ impl Language { }; let parse_left_or_expression = |input: &mut ParserContext<'_>| { PrecedenceHelper::to_binary_operator( - NonTerminalKind::OrExpression, + NonterminalKind::OrExpression, 5u8, 5u8 + 1, - self.parse_token_with_trivia::( + self.parse_terminal_with_trivia::( input, TerminalKind::BarBar, ) @@ -1765,10 +1766,10 @@ impl Language { }; let parse_left_and_expression = |input: &mut ParserContext<'_>| { PrecedenceHelper::to_binary_operator( - NonTerminalKind::AndExpression, + NonterminalKind::AndExpression, 7u8, 7u8 + 1, - self.parse_token_with_trivia::( + self.parse_terminal_with_trivia::( input, TerminalKind::AmpersandAmpersand, ) @@ -1777,19 +1778,19 @@ impl Language { }; let parse_left_equality_expression = |input: &mut ParserContext<'_>| { PrecedenceHelper::to_binary_operator( - NonTerminalKind::EqualityExpression, + NonterminalKind::EqualityExpression, 9u8, 9u8 + 1, ChoiceHelper::run(input, |mut choice, input| { let result = self - .parse_token_with_trivia::( + .parse_terminal_with_trivia::( input, TerminalKind::EqualEqual, ) .with_label(EdgeLabel::Operator); choice.consider(input, result)?; let result = self - .parse_token_with_trivia::( + .parse_terminal_with_trivia::( input, TerminalKind::BangEqual, ) @@ -1801,33 +1802,33 @@ impl Language { }; let parse_left_comparison_expression = |input: &mut ParserContext<'_>| { PrecedenceHelper::to_binary_operator( - NonTerminalKind::ComparisonExpression, + NonterminalKind::ComparisonExpression, 11u8, 11u8 + 1, ChoiceHelper::run(input, |mut choice, input| { let result = self - .parse_token_with_trivia::( + .parse_terminal_with_trivia::( input, TerminalKind::LessThan, ) .with_label(EdgeLabel::Operator); choice.consider(input, result)?; let result = self - .parse_token_with_trivia::( + .parse_terminal_with_trivia::( input, TerminalKind::GreaterThan, ) .with_label(EdgeLabel::Operator); choice.consider(input, result)?; let result = self - .parse_token_with_trivia::( + .parse_terminal_with_trivia::( input, TerminalKind::LessThanEqual, ) .with_label(EdgeLabel::Operator); choice.consider(input, result)?; let result = self - .parse_token_with_trivia::( + .parse_terminal_with_trivia::( input, TerminalKind::GreaterThanEqual, ) @@ -1839,10 +1840,10 @@ impl Language { }; let parse_left_bitwise_or_expression = |input: &mut ParserContext<'_>| { PrecedenceHelper::to_binary_operator( - NonTerminalKind::BitwiseOrExpression, + NonterminalKind::BitwiseOrExpression, 13u8, 13u8 + 1, - self.parse_token_with_trivia::( + self.parse_terminal_with_trivia::( input, TerminalKind::Bar, ) @@ -1851,10 +1852,10 @@ impl Language { }; let parse_left_bitwise_xor_expression = |input: &mut ParserContext<'_>| { PrecedenceHelper::to_binary_operator( - NonTerminalKind::BitwiseXorExpression, + NonterminalKind::BitwiseXorExpression, 15u8, 15u8 + 1, - self.parse_token_with_trivia::( + self.parse_terminal_with_trivia::( input, TerminalKind::Caret, ) @@ -1863,10 +1864,10 @@ impl Language { }; let parse_left_bitwise_and_expression = |input: &mut ParserContext<'_>| { PrecedenceHelper::to_binary_operator( - NonTerminalKind::BitwiseAndExpression, + NonterminalKind::BitwiseAndExpression, 17u8, 17u8 + 1, - self.parse_token_with_trivia::( + self.parse_terminal_with_trivia::( input, TerminalKind::Ampersand, ) @@ -1875,26 +1876,26 @@ impl Language { }; let parse_left_shift_expression = |input: &mut ParserContext<'_>| { PrecedenceHelper::to_binary_operator( - NonTerminalKind::ShiftExpression, + NonterminalKind::ShiftExpression, 19u8, 19u8 + 1, ChoiceHelper::run(input, |mut choice, input| { let result = self - .parse_token_with_trivia::( + .parse_terminal_with_trivia::( input, TerminalKind::LessThanLessThan, ) .with_label(EdgeLabel::Operator); choice.consider(input, result)?; let result = self - .parse_token_with_trivia::( + .parse_terminal_with_trivia::( input, TerminalKind::GreaterThanGreaterThan, ) .with_label(EdgeLabel::Operator); choice.consider(input, result)?; let result = self - .parse_token_with_trivia::( + .parse_terminal_with_trivia::( input, TerminalKind::GreaterThanGreaterThanGreaterThan, ) @@ -1906,19 +1907,19 @@ impl Language { }; let parse_left_additive_expression = |input: &mut ParserContext<'_>| { PrecedenceHelper::to_binary_operator( - NonTerminalKind::AdditiveExpression, + NonterminalKind::AdditiveExpression, 21u8, 21u8 + 1, ChoiceHelper::run(input, |mut choice, input| { let result = self - .parse_token_with_trivia::( + .parse_terminal_with_trivia::( input, TerminalKind::Plus, ) .with_label(EdgeLabel::Operator); choice.consider(input, result)?; let result = self - .parse_token_with_trivia::( + .parse_terminal_with_trivia::( input, TerminalKind::Minus, ) @@ -1930,26 +1931,26 @@ impl Language { }; let parse_left_multiplicative_expression = |input: &mut ParserContext<'_>| { PrecedenceHelper::to_binary_operator( - NonTerminalKind::MultiplicativeExpression, + NonterminalKind::MultiplicativeExpression, 23u8, 23u8 + 1, ChoiceHelper::run(input, |mut choice, input| { let result = self - .parse_token_with_trivia::( + .parse_terminal_with_trivia::( input, TerminalKind::Asterisk, ) .with_label(EdgeLabel::Operator); choice.consider(input, result)?; let result = self - .parse_token_with_trivia::( + .parse_terminal_with_trivia::( input, TerminalKind::Slash, ) .with_label(EdgeLabel::Operator); choice.consider(input, result)?; let result = self - .parse_token_with_trivia::( + .parse_terminal_with_trivia::( input, TerminalKind::Percent, ) @@ -1961,13 +1962,13 @@ impl Language { }; let parse_left_exponentiation_expression = |input: &mut ParserContext<'_>| { PrecedenceHelper::to_binary_operator( - NonTerminalKind::ExponentiationExpression, + NonterminalKind::ExponentiationExpression, 25u8, 25u8 + 1, ChoiceHelper::run(input, |mut choice, input| { if !self.version_is_at_least_0_6_0 { let result = self - .parse_token_with_trivia::( + .parse_terminal_with_trivia::( input, TerminalKind::AsteriskAsterisk, ) @@ -1980,13 +1981,13 @@ impl Language { }; let parse_right_exponentiation_expression = |input: &mut ParserContext<'_>| { PrecedenceHelper::to_binary_operator( - NonTerminalKind::ExponentiationExpression, + NonterminalKind::ExponentiationExpression, 27u8 + 1, 27u8, ChoiceHelper::run(input, |mut choice, input| { if self.version_is_at_least_0_6_0 { let result = self - .parse_token_with_trivia::( + .parse_terminal_with_trivia::( input, TerminalKind::AsteriskAsterisk, ) @@ -1999,18 +2000,18 @@ impl Language { }; let parse_postfix_postfix_expression = |input: &mut ParserContext<'_>| { PrecedenceHelper::to_postfix_operator( - NonTerminalKind::PostfixExpression, + NonterminalKind::PostfixExpression, 29u8, ChoiceHelper::run(input, |mut choice, input| { let result = self - .parse_token_with_trivia::( + .parse_terminal_with_trivia::( input, TerminalKind::PlusPlus, ) .with_label(EdgeLabel::Operator); choice.consider(input, result)?; let result = self - .parse_token_with_trivia::( + .parse_terminal_with_trivia::( input, TerminalKind::MinusMinus, ) @@ -2022,39 +2023,39 @@ impl Language { }; let parse_prefix_prefix_expression = |input: &mut ParserContext<'_>| { PrecedenceHelper::to_prefix_operator( - NonTerminalKind::PrefixExpression, + NonterminalKind::PrefixExpression, 31u8, ChoiceHelper::run(input, |mut choice, input| { let result = self - .parse_token_with_trivia::( + .parse_terminal_with_trivia::( input, TerminalKind::PlusPlus, ) .with_label(EdgeLabel::Operator); choice.consider(input, result)?; let result = self - .parse_token_with_trivia::( + .parse_terminal_with_trivia::( input, TerminalKind::MinusMinus, ) .with_label(EdgeLabel::Operator); choice.consider(input, result)?; let result = self - .parse_token_with_trivia::( + .parse_terminal_with_trivia::( input, TerminalKind::Tilde, ) .with_label(EdgeLabel::Operator); choice.consider(input, result)?; let result = self - .parse_token_with_trivia::( + .parse_terminal_with_trivia::( input, TerminalKind::Bang, ) .with_label(EdgeLabel::Operator); choice.consider(input, result)?; let result = self - .parse_token_with_trivia::( + .parse_terminal_with_trivia::( input, TerminalKind::Minus, ) @@ -2062,7 +2063,7 @@ impl Language { choice.consider(input, result)?; if !self.version_is_at_least_0_5_0 { let result = self - .parse_token_with_trivia::( + .parse_terminal_with_trivia::( input, TerminalKind::Plus, ) @@ -2070,7 +2071,7 @@ impl Language { choice.consider(input, result)?; } let result = self - .parse_token_with_trivia::( + .parse_terminal_with_trivia::( input, TerminalKind::DeleteKeyword, ) @@ -2082,7 +2083,7 @@ impl Language { }; let parse_postfix_function_call_expression = |input: &mut ParserContext<'_>| { PrecedenceHelper::to_postfix_operator( - NonTerminalKind::FunctionCallExpression, + NonterminalKind::FunctionCallExpression, 33u8, self.arguments_declaration(input) .with_label(EdgeLabel::Arguments), @@ -2090,7 +2091,7 @@ impl Language { }; let parse_postfix_call_options_expression = |input: &mut ParserContext<'_>| { PrecedenceHelper::to_postfix_operator( - NonTerminalKind::CallOptionsExpression, + NonterminalKind::CallOptionsExpression, 35u8, ChoiceHelper::run(input, |mut choice, input| { if self.version_is_at_least_0_6_2 { @@ -2099,15 +2100,15 @@ impl Language { let input = delim_guard.ctx(); seq.elem_labeled( EdgeLabel::OpenBrace, - self.parse_token_with_trivia::( + self.parse_terminal_with_trivia::( input, TerminalKind::OpenBrace, ), )?; - 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 (self . call_options (input) . with_label (EdgeLabel :: Options) . recover_until_with_nested_delims :: < _ , LexicalContextType :: Default > (input , self , TerminalKind :: CloseBrace , TerminalAcceptanceThreshold (2u8) ,)) ? ; seq.elem_labeled( EdgeLabel::CloseBrace, - self.parse_token_with_trivia::( + self.parse_terminal_with_trivia::( input, TerminalKind::CloseBrace, ), @@ -2122,12 +2123,12 @@ impl Language { }; let parse_postfix_member_access_expression = |input: &mut ParserContext<'_>| { PrecedenceHelper::to_postfix_operator( - NonTerminalKind::MemberAccessExpression, + NonterminalKind::MemberAccessExpression, 37u8, SequenceHelper::run(|mut seq| { seq.elem_labeled( EdgeLabel::Period, - self.parse_token_with_trivia::( + self.parse_terminal_with_trivia::( input, TerminalKind::Period, ), @@ -2139,14 +2140,14 @@ impl Language { }; let parse_postfix_index_access_expression = |input: &mut ParserContext<'_>| { PrecedenceHelper::to_postfix_operator( - NonTerminalKind::IndexAccessExpression, + NonterminalKind::IndexAccessExpression, 39u8, SequenceHelper::run(|mut seq| { let mut delim_guard = input.open_delim(TerminalKind::CloseBracket); let input = delim_guard.ctx(); seq.elem_labeled( EdgeLabel::OpenBracket, - self.parse_token_with_trivia::( + self.parse_terminal_with_trivia::( input, TerminalKind::OpenBracket, ), @@ -2167,12 +2168,12 @@ impl Language { input, self, TerminalKind::CloseBracket, - TokenAcceptanceThreshold(0u8), + TerminalAcceptanceThreshold(0u8), ), )?; seq.elem_labeled( EdgeLabel::CloseBracket, - self.parse_token_with_trivia::( + self.parse_terminal_with_trivia::( input, TerminalKind::CloseBracket, ), @@ -2209,23 +2210,23 @@ impl Language { let result = self.elementary_type(input); choice.consider(input, result)?; if self.version_is_at_least_0_6_0 { - let result = self.parse_token_with_trivia::( + let result = self.parse_terminal_with_trivia::( input, TerminalKind::PayableKeyword, ); choice.consider(input, result)?; } - let result = self.parse_token_with_trivia::( + let result = self.parse_terminal_with_trivia::( input, TerminalKind::TrueKeyword, ); choice.consider(input, result)?; - let result = self.parse_token_with_trivia::( + let result = self.parse_terminal_with_trivia::( input, TerminalKind::FalseKeyword, ); choice.consider(input, result)?; - let result = self.parse_token_with_trivia::( + let result = self.parse_terminal_with_trivia::( input, TerminalKind::Identifier, ); @@ -2304,10 +2305,10 @@ impl Language { }) }; PrecedenceHelper::reduce_precedence_result( - NonTerminalKind::Expression, + NonterminalKind::Expression, linear_expression_parser(input), ) - .with_kind(NonTerminalKind::Expression) + .with_kind(NonterminalKind::Expression) } #[allow(unused_assignments, unused_parens)] @@ -2320,19 +2321,19 @@ impl Language { input, self, TerminalKind::Semicolon, - TokenAcceptanceThreshold(1u8), + TerminalAcceptanceThreshold(1u8), ), )?; seq.elem_labeled( EdgeLabel::Semicolon, - self.parse_token_with_trivia::( + self.parse_terminal_with_trivia::( input, TerminalKind::Semicolon, ), )?; seq.finish() }) - .with_kind(NonTerminalKind::ExpressionStatement) + .with_kind(NonterminalKind::ExpressionStatement) } #[allow(unused_assignments, unused_parens)] @@ -2343,27 +2344,27 @@ impl Language { choice.consider(input, result)?; let result = self.override_specifier(input); choice.consider(input, result)?; - let result = self.parse_token_with_trivia::( + let result = self.parse_terminal_with_trivia::( input, TerminalKind::ExternalKeyword, ); choice.consider(input, result)?; - let result = self.parse_token_with_trivia::( + let result = self.parse_terminal_with_trivia::( input, TerminalKind::PayableKeyword, ); choice.consider(input, result)?; - let result = self.parse_token_with_trivia::( + let result = self.parse_terminal_with_trivia::( input, TerminalKind::PureKeyword, ); choice.consider(input, result)?; - let result = self.parse_token_with_trivia::( + let result = self.parse_terminal_with_trivia::( input, TerminalKind::ViewKeyword, ); choice.consider(input, result)?; - let result = self.parse_token_with_trivia::( + let result = self.parse_terminal_with_trivia::( input, TerminalKind::VirtualKeyword, ); @@ -2374,7 +2375,7 @@ impl Language { } else { ParserResult::disabled() } - .with_kind(NonTerminalKind::FallbackFunctionAttribute) + .with_kind(NonterminalKind::FallbackFunctionAttribute) } #[allow(unused_assignments, unused_parens)] @@ -2387,7 +2388,7 @@ impl Language { } else { ParserResult::disabled() } - .with_kind(NonTerminalKind::FallbackFunctionAttributes) + .with_kind(NonterminalKind::FallbackFunctionAttributes) } #[allow(unused_assignments, unused_parens)] @@ -2396,7 +2397,7 @@ impl Language { SequenceHelper::run(|mut seq| { seq.elem_labeled( EdgeLabel::FallbackKeyword, - self.parse_token_with_trivia::( + self.parse_terminal_with_trivia::( input, TerminalKind::FallbackKeyword, ), @@ -2416,7 +2417,7 @@ impl Language { } else { ParserResult::disabled() } - .with_kind(NonTerminalKind::FallbackFunctionDefinition) + .with_kind(NonterminalKind::FallbackFunctionDefinition) } #[allow(unused_assignments, unused_parens)] @@ -2424,7 +2425,7 @@ impl Language { SequenceHelper::run(|mut seq| { seq.elem_labeled( EdgeLabel::ForKeyword, - self.parse_token_with_trivia::( + self.parse_terminal_with_trivia::( input, TerminalKind::ForKeyword, ), @@ -2434,7 +2435,7 @@ impl Language { let input = delim_guard.ctx(); seq.elem_labeled( EdgeLabel::OpenParen, - self.parse_token_with_trivia::( + self.parse_terminal_with_trivia::( input, TerminalKind::OpenParen, ), @@ -2459,12 +2460,12 @@ impl Language { input, self, TerminalKind::CloseParen, - TokenAcceptanceThreshold(0u8), + TerminalAcceptanceThreshold(0u8), ), )?; seq.elem_labeled( EdgeLabel::CloseParen, - self.parse_token_with_trivia::( + self.parse_terminal_with_trivia::( input, TerminalKind::CloseParen, ), @@ -2474,7 +2475,7 @@ impl Language { seq.elem_labeled(EdgeLabel::Body, self.statement(input))?; seq.finish() }) - .with_kind(NonTerminalKind::ForStatement) + .with_kind(NonterminalKind::ForStatement) } #[allow(unused_assignments, unused_parens)] @@ -2482,7 +2483,7 @@ impl Language { ChoiceHelper::run(input, |mut choice, input| { let result = self.expression_statement(input); choice.consider(input, result)?; - let result = self.parse_token_with_trivia::( + let result = self.parse_terminal_with_trivia::( input, TerminalKind::Semicolon, ); @@ -2490,7 +2491,7 @@ impl Language { choice.finish(input) }) .with_label(EdgeLabel::Variant) - .with_kind(NonTerminalKind::ForStatementCondition) + .with_kind(NonterminalKind::ForStatementCondition) } #[allow(unused_assignments, unused_parens)] @@ -2502,7 +2503,7 @@ impl Language { choice.consider(input, result)?; let result = self.tuple_deconstruction_statement(input); choice.consider(input, result)?; - let result = self.parse_token_with_trivia::( + let result = self.parse_terminal_with_trivia::( input, TerminalKind::Semicolon, ); @@ -2510,7 +2511,7 @@ impl Language { choice.finish(input) }) .with_label(EdgeLabel::Variant) - .with_kind(NonTerminalKind::ForStatementInitialization) + .with_kind(NonterminalKind::ForStatementInitialization) } #[allow(unused_assignments, unused_parens)] @@ -2523,53 +2524,53 @@ impl Language { choice.consider(input, result)?; } if !self.version_is_at_least_0_5_0 { - let result = self.parse_token_with_trivia::( + let result = self.parse_terminal_with_trivia::( input, TerminalKind::ConstantKeyword, ); choice.consider(input, result)?; } - let result = self.parse_token_with_trivia::( + let result = self.parse_terminal_with_trivia::( input, TerminalKind::ExternalKeyword, ); choice.consider(input, result)?; - let result = self.parse_token_with_trivia::( + let result = self.parse_terminal_with_trivia::( input, TerminalKind::InternalKeyword, ); choice.consider(input, result)?; - let result = self.parse_token_with_trivia::( + let result = self.parse_terminal_with_trivia::( input, TerminalKind::PayableKeyword, ); choice.consider(input, result)?; - let result = self.parse_token_with_trivia::( + let result = self.parse_terminal_with_trivia::( input, TerminalKind::PrivateKeyword, ); choice.consider(input, result)?; - let result = self.parse_token_with_trivia::( + let result = self.parse_terminal_with_trivia::( input, TerminalKind::PublicKeyword, ); choice.consider(input, result)?; if self.version_is_at_least_0_4_16 { - let result = self.parse_token_with_trivia::( + let result = self.parse_terminal_with_trivia::( input, TerminalKind::PureKeyword, ); choice.consider(input, result)?; } if self.version_is_at_least_0_4_16 { - let result = self.parse_token_with_trivia::( + let result = self.parse_terminal_with_trivia::( input, TerminalKind::ViewKeyword, ); choice.consider(input, result)?; } if self.version_is_at_least_0_6_0 { - let result = self.parse_token_with_trivia::( + let result = self.parse_terminal_with_trivia::( input, TerminalKind::VirtualKeyword, ); @@ -2578,7 +2579,7 @@ impl Language { choice.finish(input) }) .with_label(EdgeLabel::Variant) - .with_kind(NonTerminalKind::FunctionAttribute) + .with_kind(NonterminalKind::FunctionAttribute) } #[allow(unused_assignments, unused_parens)] @@ -2586,7 +2587,7 @@ impl Language { ZeroOrMoreHelper::run(input, |input| { self.function_attribute(input).with_label(EdgeLabel::Item) }) - .with_kind(NonTerminalKind::FunctionAttributes) + .with_kind(NonterminalKind::FunctionAttributes) } #[allow(unused_assignments, unused_parens)] @@ -2594,7 +2595,7 @@ impl Language { ChoiceHelper::run(input, |mut choice, input| { let result = self.block(input); choice.consider(input, result)?; - let result = self.parse_token_with_trivia::( + let result = self.parse_terminal_with_trivia::( input, TerminalKind::Semicolon, ); @@ -2602,7 +2603,7 @@ impl Language { choice.finish(input) }) .with_label(EdgeLabel::Variant) - .with_kind(NonTerminalKind::FunctionBody) + .with_kind(NonterminalKind::FunctionBody) } #[allow(unused_assignments, unused_parens)] @@ -2613,14 +2614,14 @@ impl Language { }; match &r#match.nodes[..] { [cst::Edge { - node: cst::Node::NonTerminal(node), + node: cst::Node::Nonterminal(node), .. - }] if node.kind == NonTerminalKind::Expression => match &node.children[..] { + }] if node.kind == NonterminalKind::Expression => match &node.children[..] { [inner @ cst::Edge { - node: cst::Node::NonTerminal(node), + node: cst::Node::Nonterminal(node), .. - }] if node.kind == NonTerminalKind::FunctionCallExpression => { - ParserResult::r#match(vec![inner.clone()], r#match.expected_tokens.clone()) + }] if node.kind == NonterminalKind::FunctionCallExpression => { + ParserResult::r#match(vec![inner.clone()], r#match.expected_terminals.clone()) } _ => ParserResult::no_match(vec![]), }, @@ -2633,7 +2634,7 @@ impl Language { SequenceHelper::run(|mut seq| { seq.elem_labeled( EdgeLabel::FunctionKeyword, - self.parse_token_with_trivia::( + self.parse_terminal_with_trivia::( input, TerminalKind::FunctionKeyword, ), @@ -2648,23 +2649,23 @@ impl Language { seq.elem_labeled(EdgeLabel::Body, self.function_body(input))?; seq.finish() }) - .with_kind(NonTerminalKind::FunctionDefinition) + .with_kind(NonterminalKind::FunctionDefinition) } #[allow(unused_assignments, unused_parens)] fn function_name(&self, input: &mut ParserContext<'_>) -> ParserResult { ChoiceHelper::run(input, |mut choice, input| { - let result = self.parse_token_with_trivia::( + let result = self.parse_terminal_with_trivia::( input, TerminalKind::Identifier, ); choice.consider(input, result)?; - let result = self.parse_token_with_trivia::( + let result = self.parse_terminal_with_trivia::( input, TerminalKind::FallbackKeyword, ); choice.consider(input, result)?; - let result = self.parse_token_with_trivia::( + let result = self.parse_terminal_with_trivia::( input, TerminalKind::ReceiveKeyword, ); @@ -2672,7 +2673,7 @@ impl Language { choice.finish(input) }) .with_label(EdgeLabel::Variant) - .with_kind(NonTerminalKind::FunctionName) + .with_kind(NonterminalKind::FunctionName) } #[allow(unused_assignments, unused_parens)] @@ -2680,7 +2681,7 @@ impl Language { SequenceHelper::run(|mut seq| { seq.elem_labeled( EdgeLabel::FunctionKeyword, - self.parse_token_with_trivia::( + self.parse_terminal_with_trivia::( input, TerminalKind::FunctionKeyword, ), @@ -2693,54 +2694,54 @@ impl Language { )?; seq.finish() }) - .with_kind(NonTerminalKind::FunctionType) + .with_kind(NonterminalKind::FunctionType) } #[allow(unused_assignments, unused_parens)] fn function_type_attribute(&self, input: &mut ParserContext<'_>) -> ParserResult { ChoiceHelper::run(input, |mut choice, input| { - let result = self.parse_token_with_trivia::( + let result = self.parse_terminal_with_trivia::( input, TerminalKind::InternalKeyword, ); choice.consider(input, result)?; - let result = self.parse_token_with_trivia::( + let result = self.parse_terminal_with_trivia::( input, TerminalKind::ExternalKeyword, ); choice.consider(input, result)?; - let result = self.parse_token_with_trivia::( + let result = self.parse_terminal_with_trivia::( input, TerminalKind::PrivateKeyword, ); choice.consider(input, result)?; - let result = self.parse_token_with_trivia::( + let result = self.parse_terminal_with_trivia::( input, TerminalKind::PublicKeyword, ); choice.consider(input, result)?; if !self.version_is_at_least_0_5_0 { - let result = self.parse_token_with_trivia::( + let result = self.parse_terminal_with_trivia::( input, TerminalKind::ConstantKeyword, ); choice.consider(input, result)?; } if self.version_is_at_least_0_4_16 { - let result = self.parse_token_with_trivia::( + let result = self.parse_terminal_with_trivia::( input, TerminalKind::PureKeyword, ); choice.consider(input, result)?; } if self.version_is_at_least_0_4_16 { - let result = self.parse_token_with_trivia::( + let result = self.parse_terminal_with_trivia::( input, TerminalKind::ViewKeyword, ); choice.consider(input, result)?; } - let result = self.parse_token_with_trivia::( + let result = self.parse_terminal_with_trivia::( input, TerminalKind::PayableKeyword, ); @@ -2748,7 +2749,7 @@ impl Language { choice.finish(input) }) .with_label(EdgeLabel::Variant) - .with_kind(NonTerminalKind::FunctionTypeAttribute) + .with_kind(NonterminalKind::FunctionTypeAttribute) } #[allow(unused_assignments, unused_parens)] @@ -2757,7 +2758,7 @@ impl Language { self.function_type_attribute(input) .with_label(EdgeLabel::Item) }) - .with_kind(NonTerminalKind::FunctionTypeAttributes) + .with_kind(NonterminalKind::FunctionTypeAttributes) } #[allow(unused_assignments, unused_parens)] @@ -2765,7 +2766,7 @@ impl Language { SequenceHelper::run(|mut seq| { seq.elem_labeled( EdgeLabel::Literal, - self.parse_token_with_trivia::( + self.parse_terminal_with_trivia::( input, TerminalKind::HexLiteral, ), @@ -2778,18 +2779,18 @@ impl Language { } seq.finish() }) - .with_kind(NonTerminalKind::HexNumberExpression) + .with_kind(NonterminalKind::HexNumberExpression) } #[allow(unused_assignments, unused_parens)] fn hex_string_literal(&self, input: &mut ParserContext<'_>) -> ParserResult { ChoiceHelper::run(input, |mut choice, input| { - let result = self.parse_token_with_trivia::( + let result = self.parse_terminal_with_trivia::( input, TerminalKind::SingleQuotedHexStringLiteral, ); choice.consider(input, result)?; - let result = self.parse_token_with_trivia::( + let result = self.parse_terminal_with_trivia::( input, TerminalKind::DoubleQuotedHexStringLiteral, ); @@ -2797,7 +2798,7 @@ impl Language { choice.finish(input) }) .with_label(EdgeLabel::Variant) - .with_kind(NonTerminalKind::HexStringLiteral) + .with_kind(NonterminalKind::HexStringLiteral) } #[allow(unused_assignments, unused_parens)] @@ -2809,7 +2810,7 @@ impl Language { } else { ParserResult::disabled() } - .with_kind(NonTerminalKind::HexStringLiterals) + .with_kind(NonterminalKind::HexStringLiterals) } #[allow(unused_assignments, unused_parens)] @@ -2818,7 +2819,7 @@ impl Language { input, self, |input| { - self.parse_token_with_trivia::( + self.parse_terminal_with_trivia::( input, TerminalKind::Identifier, ) @@ -2827,7 +2828,7 @@ impl Language { TerminalKind::Period, EdgeLabel::Separator, ) - .with_kind(NonTerminalKind::IdentifierPath) + .with_kind(NonterminalKind::IdentifierPath) } #[allow(unused_assignments, unused_parens)] @@ -2835,7 +2836,7 @@ impl Language { SequenceHelper::run(|mut seq| { seq.elem_labeled( EdgeLabel::IfKeyword, - self.parse_token_with_trivia::( + self.parse_terminal_with_trivia::( input, TerminalKind::IfKeyword, ), @@ -2845,7 +2846,7 @@ impl Language { let input = delim_guard.ctx(); seq.elem_labeled( EdgeLabel::OpenParen, - self.parse_token_with_trivia::( + self.parse_terminal_with_trivia::( input, TerminalKind::OpenParen, ), @@ -2857,12 +2858,12 @@ impl Language { input, self, TerminalKind::CloseParen, - TokenAcceptanceThreshold(0u8), + TerminalAcceptanceThreshold(0u8), ), )?; seq.elem_labeled( EdgeLabel::CloseParen, - self.parse_token_with_trivia::( + self.parse_terminal_with_trivia::( input, TerminalKind::CloseParen, ), @@ -2876,7 +2877,7 @@ impl Language { )?; seq.finish() }) - .with_kind(NonTerminalKind::IfStatement) + .with_kind(NonterminalKind::IfStatement) } #[allow(unused_assignments, unused_parens)] @@ -2884,21 +2885,21 @@ impl Language { SequenceHelper::run(|mut seq| { seq.elem_labeled( EdgeLabel::AsKeyword, - self.parse_token_with_trivia::( + self.parse_terminal_with_trivia::( input, TerminalKind::AsKeyword, ), )?; seq.elem_labeled( EdgeLabel::Identifier, - self.parse_token_with_trivia::( + self.parse_terminal_with_trivia::( input, TerminalKind::Identifier, ), )?; seq.finish() }) - .with_kind(NonTerminalKind::ImportAlias) + .with_kind(NonterminalKind::ImportAlias) } #[allow(unused_assignments, unused_parens)] @@ -2913,7 +2914,7 @@ impl Language { choice.finish(input) }) .with_label(EdgeLabel::Variant) - .with_kind(NonTerminalKind::ImportClause) + .with_kind(NonterminalKind::ImportClause) } #[allow(unused_assignments, unused_parens)] @@ -2924,7 +2925,7 @@ impl Language { let input = delim_guard.ctx(); seq.elem_labeled( EdgeLabel::OpenBrace, - self.parse_token_with_trivia::( + self.parse_terminal_with_trivia::( input, TerminalKind::OpenBrace, ), @@ -2936,12 +2937,12 @@ impl Language { input, self, TerminalKind::CloseBrace, - TokenAcceptanceThreshold(0u8), + TerminalAcceptanceThreshold(0u8), ), )?; seq.elem_labeled( EdgeLabel::CloseBrace, - self.parse_token_with_trivia::( + self.parse_terminal_with_trivia::( input, TerminalKind::CloseBrace, ), @@ -2950,7 +2951,7 @@ impl Language { }))?; seq.elem_labeled( EdgeLabel::FromKeyword, - self.parse_token_with_trivia::( + self.parse_terminal_with_trivia::( input, TerminalKind::FromKeyword, ), @@ -2958,7 +2959,7 @@ impl Language { seq.elem_labeled(EdgeLabel::Path, self.string_literal(input))?; seq.finish() }) - .with_kind(NonTerminalKind::ImportDeconstruction) + .with_kind(NonterminalKind::ImportDeconstruction) } #[allow(unused_assignments, unused_parens)] @@ -2966,7 +2967,7 @@ impl Language { SequenceHelper::run(|mut seq| { seq.elem_labeled( EdgeLabel::Name, - self.parse_token_with_trivia::( + self.parse_terminal_with_trivia::( input, TerminalKind::Identifier, ), @@ -2977,7 +2978,7 @@ impl Language { )?; seq.finish() }) - .with_kind(NonTerminalKind::ImportDeconstructionSymbol) + .with_kind(NonterminalKind::ImportDeconstructionSymbol) } #[allow(unused_assignments, unused_parens)] @@ -2992,7 +2993,7 @@ impl Language { TerminalKind::Comma, EdgeLabel::Separator, ) - .with_kind(NonTerminalKind::ImportDeconstructionSymbols) + .with_kind(NonterminalKind::ImportDeconstructionSymbols) } #[allow(unused_assignments, unused_parens)] @@ -3002,7 +3003,7 @@ impl Language { SequenceHelper::run(|mut seq| { seq.elem_labeled( EdgeLabel::ImportKeyword, - self.parse_token_with_trivia::( + self.parse_terminal_with_trivia::( input, TerminalKind::ImportKeyword, ), @@ -3014,19 +3015,19 @@ impl Language { input, self, TerminalKind::Semicolon, - TokenAcceptanceThreshold(1u8), + TerminalAcceptanceThreshold(1u8), ), )?; seq.elem_labeled( EdgeLabel::Semicolon, - self.parse_token_with_trivia::( + self.parse_terminal_with_trivia::( input, TerminalKind::Semicolon, ), )?; seq.finish() }) - .with_kind(NonTerminalKind::ImportDirective) + .with_kind(NonterminalKind::ImportDirective) } #[allow(unused_assignments, unused_parens)] @@ -3034,7 +3035,7 @@ impl Language { SequenceHelper::run(|mut seq| { seq.elem_labeled( EdgeLabel::Colon, - self.parse_token_with_trivia::( + self.parse_terminal_with_trivia::( input, TerminalKind::Colon, ), @@ -3045,7 +3046,7 @@ impl Language { )?; seq.finish() }) - .with_kind(NonTerminalKind::IndexAccessEnd) + .with_kind(NonterminalKind::IndexAccessEnd) } #[allow(unused_assignments, unused_parens)] @@ -3056,14 +3057,14 @@ impl Language { }; match &r#match.nodes[..] { [cst::Edge { - node: cst::Node::NonTerminal(node), + node: cst::Node::Nonterminal(node), .. - }] if node.kind == NonTerminalKind::Expression => match &node.children[..] { + }] if node.kind == NonterminalKind::Expression => match &node.children[..] { [inner @ cst::Edge { - node: cst::Node::NonTerminal(node), + node: cst::Node::Nonterminal(node), .. - }] if node.kind == NonTerminalKind::IndexAccessExpression => { - ParserResult::r#match(vec![inner.clone()], r#match.expected_tokens.clone()) + }] if node.kind == NonterminalKind::IndexAccessExpression => { + ParserResult::r#match(vec![inner.clone()], r#match.expected_terminals.clone()) } _ => ParserResult::no_match(vec![]), }, @@ -3076,7 +3077,7 @@ impl Language { SequenceHelper::run(|mut seq| { seq.elem_labeled( EdgeLabel::IsKeyword, - self.parse_token_with_trivia::( + self.parse_terminal_with_trivia::( input, TerminalKind::IsKeyword, ), @@ -3084,7 +3085,7 @@ impl Language { seq.elem_labeled(EdgeLabel::Types, self.inheritance_types(input))?; seq.finish() }) - .with_kind(NonTerminalKind::InheritanceSpecifier) + .with_kind(NonterminalKind::InheritanceSpecifier) } #[allow(unused_assignments, unused_parens)] @@ -3097,7 +3098,7 @@ impl Language { )?; seq.finish() }) - .with_kind(NonTerminalKind::InheritanceType) + .with_kind(NonterminalKind::InheritanceType) } #[allow(unused_assignments, unused_parens)] @@ -3109,7 +3110,7 @@ impl Language { TerminalKind::Comma, EdgeLabel::Separator, ) - .with_kind(NonTerminalKind::InheritanceTypes) + .with_kind(NonterminalKind::InheritanceTypes) } #[allow(unused_assignments, unused_parens)] @@ -3117,14 +3118,14 @@ impl Language { SequenceHelper::run(|mut seq| { seq.elem_labeled( EdgeLabel::InterfaceKeyword, - self.parse_token_with_trivia::( + self.parse_terminal_with_trivia::( input, TerminalKind::InterfaceKeyword, ), )?; seq.elem_labeled( EdgeLabel::Name, - self.parse_token_with_trivia::( + self.parse_terminal_with_trivia::( input, TerminalKind::Identifier, ), @@ -3138,7 +3139,7 @@ impl Language { let input = delim_guard.ctx(); seq.elem_labeled( EdgeLabel::OpenBrace, - self.parse_token_with_trivia::( + self.parse_terminal_with_trivia::( input, TerminalKind::OpenBrace, ), @@ -3150,12 +3151,12 @@ impl Language { input, self, TerminalKind::CloseBrace, - TokenAcceptanceThreshold(0u8), + TerminalAcceptanceThreshold(0u8), ), )?; seq.elem_labeled( EdgeLabel::CloseBrace, - self.parse_token_with_trivia::( + self.parse_terminal_with_trivia::( input, TerminalKind::CloseBrace, ), @@ -3164,7 +3165,7 @@ impl Language { }))?; seq.finish() }) - .with_kind(NonTerminalKind::InterfaceDefinition) + .with_kind(NonterminalKind::InterfaceDefinition) } #[allow(unused_assignments, unused_parens)] @@ -3172,7 +3173,7 @@ impl Language { ZeroOrMoreHelper::run(input, |input| { self.contract_member(input).with_label(EdgeLabel::Item) }) - .with_kind(NonTerminalKind::InterfaceMembers) + .with_kind(NonterminalKind::InterfaceMembers) } #[allow(unused_assignments, unused_parens)] @@ -3180,14 +3181,14 @@ impl Language { SequenceHelper::run(|mut seq| { seq.elem_labeled( EdgeLabel::LibraryKeyword, - self.parse_token_with_trivia::( + self.parse_terminal_with_trivia::( input, TerminalKind::LibraryKeyword, ), )?; seq.elem_labeled( EdgeLabel::Name, - self.parse_token_with_trivia::( + self.parse_terminal_with_trivia::( input, TerminalKind::Identifier, ), @@ -3197,7 +3198,7 @@ impl Language { let input = delim_guard.ctx(); seq.elem_labeled( EdgeLabel::OpenBrace, - self.parse_token_with_trivia::( + self.parse_terminal_with_trivia::( input, TerminalKind::OpenBrace, ), @@ -3209,12 +3210,12 @@ impl Language { input, self, TerminalKind::CloseBrace, - TokenAcceptanceThreshold(0u8), + TerminalAcceptanceThreshold(0u8), ), )?; seq.elem_labeled( EdgeLabel::CloseBrace, - self.parse_token_with_trivia::( + self.parse_terminal_with_trivia::( input, TerminalKind::CloseBrace, ), @@ -3223,7 +3224,7 @@ impl Language { }))?; seq.finish() }) - .with_kind(NonTerminalKind::LibraryDefinition) + .with_kind(NonterminalKind::LibraryDefinition) } #[allow(unused_assignments, unused_parens)] @@ -3231,7 +3232,7 @@ impl Language { ZeroOrMoreHelper::run(input, |input| { self.contract_member(input).with_label(EdgeLabel::Item) }) - .with_kind(NonTerminalKind::LibraryMembers) + .with_kind(NonterminalKind::LibraryMembers) } #[allow(unused_assignments, unused_parens)] @@ -3242,7 +3243,7 @@ impl Language { seq.elem_labeled( EdgeLabel::Name, OptionalHelper::transform( - self.parse_token_with_trivia::( + self.parse_terminal_with_trivia::( input, TerminalKind::Identifier, ), @@ -3251,7 +3252,7 @@ impl Language { } seq.finish() }) - .with_kind(NonTerminalKind::MappingKey) + .with_kind(NonterminalKind::MappingKey) } #[allow(unused_assignments, unused_parens)] @@ -3264,7 +3265,7 @@ impl Language { choice.finish(input) }) .with_label(EdgeLabel::Variant) - .with_kind(NonTerminalKind::MappingKeyType) + .with_kind(NonterminalKind::MappingKeyType) } #[allow(unused_assignments, unused_parens)] @@ -3272,7 +3273,7 @@ impl Language { SequenceHelper::run(|mut seq| { seq.elem_labeled( EdgeLabel::MappingKeyword, - self.parse_token_with_trivia::( + self.parse_terminal_with_trivia::( input, TerminalKind::MappingKeyword, ), @@ -3282,7 +3283,7 @@ impl Language { let input = delim_guard.ctx(); seq.elem_labeled( EdgeLabel::OpenParen, - self.parse_token_with_trivia::( + self.parse_terminal_with_trivia::( input, TerminalKind::OpenParen, ), @@ -3292,7 +3293,7 @@ impl Language { seq.elem_labeled(EdgeLabel::KeyType, self.mapping_key(input))?; seq.elem_labeled( EdgeLabel::EqualGreaterThan, - self.parse_token_with_trivia::( + self.parse_terminal_with_trivia::( input, TerminalKind::EqualGreaterThan, ), @@ -3304,12 +3305,12 @@ impl Language { input, self, TerminalKind::CloseParen, - TokenAcceptanceThreshold(0u8), + TerminalAcceptanceThreshold(0u8), ), )?; seq.elem_labeled( EdgeLabel::CloseParen, - self.parse_token_with_trivia::( + self.parse_terminal_with_trivia::( input, TerminalKind::CloseParen, ), @@ -3318,7 +3319,7 @@ impl Language { }))?; seq.finish() }) - .with_kind(NonTerminalKind::MappingType) + .with_kind(NonterminalKind::MappingType) } #[allow(unused_assignments, unused_parens)] @@ -3329,7 +3330,7 @@ impl Language { seq.elem_labeled( EdgeLabel::Name, OptionalHelper::transform( - self.parse_token_with_trivia::( + self.parse_terminal_with_trivia::( input, TerminalKind::Identifier, ), @@ -3338,18 +3339,18 @@ impl Language { } seq.finish() }) - .with_kind(NonTerminalKind::MappingValue) + .with_kind(NonterminalKind::MappingValue) } #[allow(unused_assignments, unused_parens)] fn member_access(&self, input: &mut ParserContext<'_>) -> ParserResult { ChoiceHelper::run(input, |mut choice, input| { - let result = self.parse_token_with_trivia::( + let result = self.parse_terminal_with_trivia::( input, TerminalKind::Identifier, ); choice.consider(input, result)?; - let result = self.parse_token_with_trivia::( + let result = self.parse_terminal_with_trivia::( input, TerminalKind::AddressKeyword, ); @@ -3357,7 +3358,7 @@ impl Language { choice.finish(input) }) .with_label(EdgeLabel::Variant) - .with_kind(NonTerminalKind::MemberAccess) + .with_kind(NonterminalKind::MemberAccess) } #[allow(unused_assignments, unused_parens)] @@ -3368,14 +3369,14 @@ impl Language { }; match &r#match.nodes[..] { [cst::Edge { - node: cst::Node::NonTerminal(node), + node: cst::Node::Nonterminal(node), .. - }] if node.kind == NonTerminalKind::Expression => match &node.children[..] { + }] if node.kind == NonterminalKind::Expression => match &node.children[..] { [inner @ cst::Edge { - node: cst::Node::NonTerminal(node), + node: cst::Node::Nonterminal(node), .. - }] if node.kind == NonTerminalKind::MemberAccessExpression => { - ParserResult::r#match(vec![inner.clone()], r#match.expected_tokens.clone()) + }] if node.kind == NonterminalKind::MemberAccessExpression => { + ParserResult::r#match(vec![inner.clone()], r#match.expected_terminals.clone()) } _ => ParserResult::no_match(vec![]), }, @@ -3391,7 +3392,7 @@ impl Language { choice.consider(input, result)?; } if self.version_is_at_least_0_6_0 { - let result = self.parse_token_with_trivia::( + let result = self.parse_terminal_with_trivia::( input, TerminalKind::VirtualKeyword, ); @@ -3400,7 +3401,7 @@ impl Language { choice.finish(input) }) .with_label(EdgeLabel::Variant) - .with_kind(NonTerminalKind::ModifierAttribute) + .with_kind(NonterminalKind::ModifierAttribute) } #[allow(unused_assignments, unused_parens)] @@ -3408,7 +3409,7 @@ impl Language { ZeroOrMoreHelper::run(input, |input| { self.modifier_attribute(input).with_label(EdgeLabel::Item) }) - .with_kind(NonTerminalKind::ModifierAttributes) + .with_kind(NonterminalKind::ModifierAttributes) } #[allow(unused_assignments, unused_parens)] @@ -3416,14 +3417,14 @@ impl Language { SequenceHelper::run(|mut seq| { seq.elem_labeled( EdgeLabel::ModifierKeyword, - self.parse_token_with_trivia::( + self.parse_terminal_with_trivia::( input, TerminalKind::ModifierKeyword, ), )?; seq.elem_labeled( EdgeLabel::Name, - self.parse_token_with_trivia::( + self.parse_terminal_with_trivia::( input, TerminalKind::Identifier, ), @@ -3436,7 +3437,7 @@ impl Language { seq.elem_labeled(EdgeLabel::Body, self.function_body(input))?; seq.finish() }) - .with_kind(NonTerminalKind::ModifierDefinition) + .with_kind(NonterminalKind::ModifierDefinition) } #[allow(unused_assignments, unused_parens)] @@ -3449,7 +3450,7 @@ impl Language { )?; seq.finish() }) - .with_kind(NonTerminalKind::ModifierInvocation) + .with_kind(NonterminalKind::ModifierInvocation) } #[allow(unused_assignments, unused_parens)] @@ -3460,14 +3461,14 @@ impl Language { }; match &r#match.nodes[..] { [cst::Edge { - node: cst::Node::NonTerminal(node), + node: cst::Node::Nonterminal(node), .. - }] if node.kind == NonTerminalKind::Expression => match &node.children[..] { + }] if node.kind == NonterminalKind::Expression => match &node.children[..] { [inner @ cst::Edge { - node: cst::Node::NonTerminal(node), + node: cst::Node::Nonterminal(node), .. - }] if node.kind == NonTerminalKind::MultiplicativeExpression => { - ParserResult::r#match(vec![inner.clone()], r#match.expected_tokens.clone()) + }] if node.kind == NonterminalKind::MultiplicativeExpression => { + ParserResult::r#match(vec![inner.clone()], r#match.expected_terminals.clone()) } _ => ParserResult::no_match(vec![]), }, @@ -3480,14 +3481,14 @@ impl Language { SequenceHelper::run(|mut seq| { seq.elem_labeled( EdgeLabel::Name, - self.parse_token_with_trivia::( + self.parse_terminal_with_trivia::( input, TerminalKind::Identifier, ), )?; seq.elem_labeled( EdgeLabel::Colon, - self.parse_token_with_trivia::( + self.parse_terminal_with_trivia::( input, TerminalKind::Colon, ), @@ -3495,7 +3496,7 @@ impl Language { seq.elem_labeled(EdgeLabel::Value, self.expression(input))?; seq.finish() }) - .with_kind(NonTerminalKind::NamedArgument) + .with_kind(NonterminalKind::NamedArgument) } #[allow(unused_assignments, unused_parens)] @@ -3505,7 +3506,7 @@ impl Language { let input = delim_guard.ctx(); seq.elem_labeled( EdgeLabel::OpenBrace, - self.parse_token_with_trivia::( + self.parse_terminal_with_trivia::( input, TerminalKind::OpenBrace, ), @@ -3517,19 +3518,19 @@ impl Language { input, self, TerminalKind::CloseBrace, - TokenAcceptanceThreshold(0u8), + TerminalAcceptanceThreshold(0u8), ), )?; seq.elem_labeled( EdgeLabel::CloseBrace, - self.parse_token_with_trivia::( + self.parse_terminal_with_trivia::( input, TerminalKind::CloseBrace, ), )?; seq.finish() }) - .with_kind(NonTerminalKind::NamedArgumentGroup) + .with_kind(NonterminalKind::NamedArgumentGroup) } #[allow(unused_assignments, unused_parens)] @@ -3541,7 +3542,7 @@ impl Language { TerminalKind::Comma, EdgeLabel::Separator, )) - .with_kind(NonTerminalKind::NamedArguments) + .with_kind(NonterminalKind::NamedArguments) } #[allow(unused_assignments, unused_parens)] @@ -3551,7 +3552,7 @@ impl Language { let input = delim_guard.ctx(); seq.elem_labeled( EdgeLabel::OpenParen, - self.parse_token_with_trivia::( + self.parse_terminal_with_trivia::( input, TerminalKind::OpenParen, ), @@ -3563,19 +3564,19 @@ impl Language { input, self, TerminalKind::CloseParen, - TokenAcceptanceThreshold(0u8), + TerminalAcceptanceThreshold(0u8), ), )?; seq.elem_labeled( EdgeLabel::CloseParen, - self.parse_token_with_trivia::( + self.parse_terminal_with_trivia::( input, TerminalKind::CloseParen, ), )?; seq.finish() }) - .with_kind(NonTerminalKind::NamedArgumentsDeclaration) + .with_kind(NonterminalKind::NamedArgumentsDeclaration) } #[allow(unused_assignments, unused_parens)] @@ -3583,7 +3584,7 @@ impl Language { SequenceHelper::run(|mut seq| { seq.elem_labeled( EdgeLabel::Asterisk, - self.parse_token_with_trivia::( + self.parse_terminal_with_trivia::( input, TerminalKind::Asterisk, ), @@ -3591,7 +3592,7 @@ impl Language { seq.elem_labeled(EdgeLabel::Alias, self.import_alias(input))?; seq.elem_labeled( EdgeLabel::FromKeyword, - self.parse_token_with_trivia::( + self.parse_terminal_with_trivia::( input, TerminalKind::FromKeyword, ), @@ -3599,7 +3600,7 @@ impl Language { seq.elem_labeled(EdgeLabel::Path, self.string_literal(input))?; seq.finish() }) - .with_kind(NonTerminalKind::NamedImport) + .with_kind(NonterminalKind::NamedImport) } #[allow(unused_assignments, unused_parens)] @@ -3607,7 +3608,7 @@ impl Language { SequenceHelper::run(|mut seq| { seq.elem_labeled( EdgeLabel::NewKeyword, - self.parse_token_with_trivia::( + self.parse_terminal_with_trivia::( input, TerminalKind::NewKeyword, ), @@ -3615,70 +3616,70 @@ impl Language { seq.elem_labeled(EdgeLabel::TypeName, self.type_name(input))?; seq.finish() }) - .with_kind(NonTerminalKind::NewExpression) + .with_kind(NonterminalKind::NewExpression) } #[allow(unused_assignments, unused_parens)] fn number_unit(&self, input: &mut ParserContext<'_>) -> ParserResult { ChoiceHelper::run(input, |mut choice, input| { - let result = self.parse_token_with_trivia::( + let result = self.parse_terminal_with_trivia::( input, TerminalKind::WeiKeyword, ); choice.consider(input, result)?; if self.version_is_at_least_0_6_11 { - let result = self.parse_token_with_trivia::( + let result = self.parse_terminal_with_trivia::( input, TerminalKind::GweiKeyword, ); choice.consider(input, result)?; } if !self.version_is_at_least_0_7_0 { - let result = self.parse_token_with_trivia::( + let result = self.parse_terminal_with_trivia::( input, TerminalKind::SzaboKeyword, ); choice.consider(input, result)?; } if !self.version_is_at_least_0_7_0 { - let result = self.parse_token_with_trivia::( + let result = self.parse_terminal_with_trivia::( input, TerminalKind::FinneyKeyword, ); choice.consider(input, result)?; } - let result = self.parse_token_with_trivia::( + let result = self.parse_terminal_with_trivia::( input, TerminalKind::EtherKeyword, ); choice.consider(input, result)?; - let result = self.parse_token_with_trivia::( + let result = self.parse_terminal_with_trivia::( input, TerminalKind::SecondsKeyword, ); choice.consider(input, result)?; - let result = self.parse_token_with_trivia::( + let result = self.parse_terminal_with_trivia::( input, TerminalKind::MinutesKeyword, ); choice.consider(input, result)?; - let result = self.parse_token_with_trivia::( + let result = self.parse_terminal_with_trivia::( input, TerminalKind::HoursKeyword, ); choice.consider(input, result)?; - let result = self.parse_token_with_trivia::( + let result = self.parse_terminal_with_trivia::( input, TerminalKind::DaysKeyword, ); choice.consider(input, result)?; - let result = self.parse_token_with_trivia::( + let result = self.parse_terminal_with_trivia::( input, TerminalKind::WeeksKeyword, ); choice.consider(input, result)?; if !self.version_is_at_least_0_5_0 { - let result = self.parse_token_with_trivia::( + let result = self.parse_terminal_with_trivia::( input, TerminalKind::YearsKeyword, ); @@ -3687,7 +3688,7 @@ impl Language { choice.finish(input) }) .with_label(EdgeLabel::Variant) - .with_kind(NonTerminalKind::NumberUnit) + .with_kind(NonterminalKind::NumberUnit) } #[allow(unused_assignments, unused_parens)] @@ -3698,14 +3699,14 @@ impl Language { }; match &r#match.nodes[..] { [cst::Edge { - node: cst::Node::NonTerminal(node), + node: cst::Node::Nonterminal(node), .. - }] if node.kind == NonTerminalKind::Expression => match &node.children[..] { + }] if node.kind == NonterminalKind::Expression => match &node.children[..] { [inner @ cst::Edge { - node: cst::Node::NonTerminal(node), + node: cst::Node::Nonterminal(node), .. - }] if node.kind == NonTerminalKind::OrExpression => { - ParserResult::r#match(vec![inner.clone()], r#match.expected_tokens.clone()) + }] if node.kind == NonterminalKind::OrExpression => { + ParserResult::r#match(vec![inner.clone()], r#match.expected_terminals.clone()) } _ => ParserResult::no_match(vec![]), }, @@ -3726,7 +3727,7 @@ impl Language { } else { ParserResult::disabled() } - .with_kind(NonTerminalKind::OverridePaths) + .with_kind(NonterminalKind::OverridePaths) } #[allow(unused_assignments, unused_parens)] @@ -3737,7 +3738,7 @@ impl Language { let input = delim_guard.ctx(); seq.elem_labeled( EdgeLabel::OpenParen, - self.parse_token_with_trivia::( + self.parse_terminal_with_trivia::( input, TerminalKind::OpenParen, ), @@ -3749,12 +3750,12 @@ impl Language { input, self, TerminalKind::CloseParen, - TokenAcceptanceThreshold(0u8), + TerminalAcceptanceThreshold(0u8), ), )?; seq.elem_labeled( EdgeLabel::CloseParen, - self.parse_token_with_trivia::( + self.parse_terminal_with_trivia::( input, TerminalKind::CloseParen, ), @@ -3764,7 +3765,7 @@ impl Language { } else { ParserResult::disabled() } - .with_kind(NonTerminalKind::OverridePathsDeclaration) + .with_kind(NonterminalKind::OverridePathsDeclaration) } #[allow(unused_assignments, unused_parens)] @@ -3773,7 +3774,7 @@ impl Language { SequenceHelper::run(|mut seq| { seq.elem_labeled( EdgeLabel::OverrideKeyword, - self.parse_token_with_trivia::( + self.parse_terminal_with_trivia::( input, TerminalKind::OverrideKeyword, ), @@ -3787,7 +3788,7 @@ impl Language { } else { ParserResult::disabled() } - .with_kind(NonTerminalKind::OverrideSpecifier) + .with_kind(NonterminalKind::OverrideSpecifier) } #[allow(unused_assignments, unused_parens)] @@ -3801,7 +3802,7 @@ impl Language { seq.elem_labeled( EdgeLabel::Name, OptionalHelper::transform( - self.parse_token_with_trivia::( + self.parse_terminal_with_trivia::( input, TerminalKind::Identifier, ), @@ -3809,7 +3810,7 @@ impl Language { )?; seq.finish() }) - .with_kind(NonTerminalKind::Parameter) + .with_kind(NonterminalKind::Parameter) } #[allow(unused_assignments, unused_parens)] @@ -3821,7 +3822,7 @@ impl Language { TerminalKind::Comma, EdgeLabel::Separator, )) - .with_kind(NonTerminalKind::Parameters) + .with_kind(NonterminalKind::Parameters) } #[allow(unused_assignments, unused_parens)] @@ -3831,7 +3832,7 @@ impl Language { let input = delim_guard.ctx(); seq.elem_labeled( EdgeLabel::OpenParen, - self.parse_token_with_trivia::( + self.parse_terminal_with_trivia::( input, TerminalKind::OpenParen, ), @@ -3843,19 +3844,19 @@ impl Language { input, self, TerminalKind::CloseParen, - TokenAcceptanceThreshold(0u8), + TerminalAcceptanceThreshold(0u8), ), )?; seq.elem_labeled( EdgeLabel::CloseParen, - self.parse_token_with_trivia::( + self.parse_terminal_with_trivia::( input, TerminalKind::CloseParen, ), )?; seq.finish() }) - .with_kind(NonTerminalKind::ParametersDeclaration) + .with_kind(NonterminalKind::ParametersDeclaration) } #[allow(unused_assignments, unused_parens)] @@ -3868,7 +3869,7 @@ impl Language { )?; seq.finish() }) - .with_kind(NonTerminalKind::PathImport) + .with_kind(NonterminalKind::PathImport) } #[allow(unused_assignments, unused_parens)] @@ -3880,7 +3881,7 @@ impl Language { TerminalKind::Comma, EdgeLabel::Separator, )) - .with_kind(NonTerminalKind::PositionalArguments) + .with_kind(NonterminalKind::PositionalArguments) } #[allow(unused_assignments, unused_parens)] @@ -3890,7 +3891,7 @@ impl Language { let input = delim_guard.ctx(); seq.elem_labeled( EdgeLabel::OpenParen, - self.parse_token_with_trivia::( + self.parse_terminal_with_trivia::( input, TerminalKind::OpenParen, ), @@ -3902,19 +3903,19 @@ impl Language { input, self, TerminalKind::CloseParen, - TokenAcceptanceThreshold(0u8), + TerminalAcceptanceThreshold(0u8), ), )?; seq.elem_labeled( EdgeLabel::CloseParen, - self.parse_token_with_trivia::( + self.parse_terminal_with_trivia::( input, TerminalKind::CloseParen, ), )?; seq.finish() }) - .with_kind(NonTerminalKind::PositionalArgumentsDeclaration) + .with_kind(NonterminalKind::PositionalArgumentsDeclaration) } #[allow(unused_assignments, unused_parens)] @@ -3925,14 +3926,14 @@ impl Language { }; match &r#match.nodes[..] { [cst::Edge { - node: cst::Node::NonTerminal(node), + node: cst::Node::Nonterminal(node), .. - }] if node.kind == NonTerminalKind::Expression => match &node.children[..] { + }] if node.kind == NonterminalKind::Expression => match &node.children[..] { [inner @ cst::Edge { - node: cst::Node::NonTerminal(node), + node: cst::Node::Nonterminal(node), .. - }] if node.kind == NonTerminalKind::PostfixExpression => { - ParserResult::r#match(vec![inner.clone()], r#match.expected_tokens.clone()) + }] if node.kind == NonterminalKind::PostfixExpression => { + ParserResult::r#match(vec![inner.clone()], r#match.expected_terminals.clone()) } _ => ParserResult::no_match(vec![]), }, @@ -3952,7 +3953,7 @@ impl Language { choice.finish(input) }) .with_label(EdgeLabel::Variant) - .with_kind(NonTerminalKind::Pragma) + .with_kind(NonterminalKind::Pragma) } #[allow(unused_assignments, unused_parens)] @@ -3962,7 +3963,7 @@ impl Language { SequenceHelper::run(|mut seq| { seq.elem_labeled( EdgeLabel::PragmaKeyword, - self.parse_token_with_trivia::( + self.parse_terminal_with_trivia::( input, TerminalKind::PragmaKeyword, ), @@ -3974,19 +3975,19 @@ impl Language { input, self, TerminalKind::Semicolon, - TokenAcceptanceThreshold(1u8), + TerminalAcceptanceThreshold(1u8), ), )?; seq.elem_labeled( EdgeLabel::Semicolon, - self.parse_token_with_trivia::( + self.parse_terminal_with_trivia::( input, TerminalKind::Semicolon, ), )?; seq.finish() }) - .with_kind(NonTerminalKind::PragmaDirective) + .with_kind(NonterminalKind::PragmaDirective) } #[allow(unused_assignments, unused_parens)] @@ -3997,14 +3998,14 @@ impl Language { }; match &r#match.nodes[..] { [cst::Edge { - node: cst::Node::NonTerminal(node), + node: cst::Node::Nonterminal(node), .. - }] if node.kind == NonTerminalKind::Expression => match &node.children[..] { + }] if node.kind == NonterminalKind::Expression => match &node.children[..] { [inner @ cst::Edge { - node: cst::Node::NonTerminal(node), + node: cst::Node::Nonterminal(node), .. - }] if node.kind == NonTerminalKind::PrefixExpression => { - ParserResult::r#match(vec![inner.clone()], r#match.expected_tokens.clone()) + }] if node.kind == NonterminalKind::PrefixExpression => { + ParserResult::r#match(vec![inner.clone()], r#match.expected_terminals.clone()) } _ => ParserResult::no_match(vec![]), }, @@ -4020,17 +4021,17 @@ impl Language { choice.consider(input, result)?; let result = self.override_specifier(input); choice.consider(input, result)?; - let result = self.parse_token_with_trivia::( + let result = self.parse_terminal_with_trivia::( input, TerminalKind::ExternalKeyword, ); choice.consider(input, result)?; - let result = self.parse_token_with_trivia::( + let result = self.parse_terminal_with_trivia::( input, TerminalKind::PayableKeyword, ); choice.consider(input, result)?; - let result = self.parse_token_with_trivia::( + let result = self.parse_terminal_with_trivia::( input, TerminalKind::VirtualKeyword, ); @@ -4041,7 +4042,7 @@ impl Language { } else { ParserResult::disabled() } - .with_kind(NonTerminalKind::ReceiveFunctionAttribute) + .with_kind(NonterminalKind::ReceiveFunctionAttribute) } #[allow(unused_assignments, unused_parens)] @@ -4054,7 +4055,7 @@ impl Language { } else { ParserResult::disabled() } - .with_kind(NonTerminalKind::ReceiveFunctionAttributes) + .with_kind(NonterminalKind::ReceiveFunctionAttributes) } #[allow(unused_assignments, unused_parens)] @@ -4063,7 +4064,7 @@ impl Language { SequenceHelper::run(|mut seq| { seq.elem_labeled( EdgeLabel::ReceiveKeyword, - self.parse_token_with_trivia::( + self.parse_terminal_with_trivia::( input, TerminalKind::ReceiveKeyword, ), @@ -4079,7 +4080,7 @@ impl Language { } else { ParserResult::disabled() } - .with_kind(NonTerminalKind::ReceiveFunctionDefinition) + .with_kind(NonterminalKind::ReceiveFunctionDefinition) } #[allow(unused_assignments, unused_parens)] @@ -4089,7 +4090,7 @@ impl Language { SequenceHelper::run(|mut seq| { seq.elem_labeled( EdgeLabel::ReturnKeyword, - self.parse_token_with_trivia::( + self.parse_terminal_with_trivia::( input, TerminalKind::ReturnKeyword, ), @@ -4104,19 +4105,19 @@ impl Language { input, self, TerminalKind::Semicolon, - TokenAcceptanceThreshold(1u8), + TerminalAcceptanceThreshold(1u8), ), )?; seq.elem_labeled( EdgeLabel::Semicolon, - self.parse_token_with_trivia::( + self.parse_terminal_with_trivia::( input, TerminalKind::Semicolon, ), )?; seq.finish() }) - .with_kind(NonTerminalKind::ReturnStatement) + .with_kind(NonterminalKind::ReturnStatement) } #[allow(unused_assignments, unused_parens)] @@ -4124,7 +4125,7 @@ impl Language { SequenceHelper::run(|mut seq| { seq.elem_labeled( EdgeLabel::ReturnsKeyword, - self.parse_token_with_trivia::( + self.parse_terminal_with_trivia::( input, TerminalKind::ReturnsKeyword, ), @@ -4132,7 +4133,7 @@ impl Language { seq.elem_labeled(EdgeLabel::Variables, self.parameters_declaration(input))?; seq.finish() }) - .with_kind(NonTerminalKind::ReturnsDeclaration) + .with_kind(NonterminalKind::ReturnsDeclaration) } #[allow(unused_assignments, unused_parens)] @@ -4143,7 +4144,7 @@ impl Language { SequenceHelper::run(|mut seq| { seq.elem_labeled( EdgeLabel::RevertKeyword, - self.parse_token_with_trivia::( + self.parse_terminal_with_trivia::( input, TerminalKind::RevertKeyword, ), @@ -4159,12 +4160,12 @@ impl Language { input, self, TerminalKind::Semicolon, - TokenAcceptanceThreshold(1u8), + TerminalAcceptanceThreshold(1u8), ), )?; seq.elem_labeled( EdgeLabel::Semicolon, - self.parse_token_with_trivia::( + self.parse_terminal_with_trivia::( input, TerminalKind::Semicolon, ), @@ -4174,7 +4175,7 @@ impl Language { } else { ParserResult::disabled() } - .with_kind(NonTerminalKind::RevertStatement) + .with_kind(NonterminalKind::RevertStatement) } #[allow(unused_assignments, unused_parens)] @@ -4185,14 +4186,14 @@ impl Language { }; match &r#match.nodes[..] { [cst::Edge { - node: cst::Node::NonTerminal(node), + node: cst::Node::Nonterminal(node), .. - }] if node.kind == NonTerminalKind::Expression => match &node.children[..] { + }] if node.kind == NonterminalKind::Expression => match &node.children[..] { [inner @ cst::Edge { - node: cst::Node::NonTerminal(node), + node: cst::Node::Nonterminal(node), .. - }] if node.kind == NonTerminalKind::ShiftExpression => { - ParserResult::r#match(vec![inner.clone()], r#match.expected_tokens.clone()) + }] if node.kind == NonterminalKind::ShiftExpression => { + ParserResult::r#match(vec![inner.clone()], r#match.expected_terminals.clone()) } _ => ParserResult::no_match(vec![]), }, @@ -4204,7 +4205,7 @@ impl Language { fn source_unit(&self, input: &mut ParserContext<'_>) -> ParserResult { self.source_unit_members(input) .with_label(EdgeLabel::Members) - .with_kind(NonTerminalKind::SourceUnit) + .with_kind(NonterminalKind::SourceUnit) } #[allow(unused_assignments, unused_parens)] @@ -4255,7 +4256,7 @@ impl Language { choice.finish(input) }) .with_label(EdgeLabel::Variant) - .with_kind(NonTerminalKind::SourceUnitMember) + .with_kind(NonterminalKind::SourceUnitMember) } #[allow(unused_assignments, unused_parens)] @@ -4263,7 +4264,7 @@ impl Language { ZeroOrMoreHelper::run(input, |input| { self.source_unit_member(input).with_label(EdgeLabel::Item) }) - .with_kind(NonTerminalKind::SourceUnitMembers) + .with_kind(NonterminalKind::SourceUnitMembers) } #[allow(unused_assignments, unused_parens)] @@ -4273,28 +4274,28 @@ impl Language { let result = self.override_specifier(input); choice.consider(input, result)?; } - let result = self.parse_token_with_trivia::( + let result = self.parse_terminal_with_trivia::( input, TerminalKind::ConstantKeyword, ); choice.consider(input, result)?; - let result = self.parse_token_with_trivia::( + let result = self.parse_terminal_with_trivia::( input, TerminalKind::InternalKeyword, ); choice.consider(input, result)?; - let result = self.parse_token_with_trivia::( + let result = self.parse_terminal_with_trivia::( input, TerminalKind::PrivateKeyword, ); choice.consider(input, result)?; - let result = self.parse_token_with_trivia::( + let result = self.parse_terminal_with_trivia::( input, TerminalKind::PublicKeyword, ); choice.consider(input, result)?; if self.version_is_at_least_0_6_5 { - let result = self.parse_token_with_trivia::( + let result = self.parse_terminal_with_trivia::( input, TerminalKind::ImmutableKeyword, ); @@ -4303,7 +4304,7 @@ impl Language { choice.finish(input) }) .with_label(EdgeLabel::Variant) - .with_kind(NonTerminalKind::StateVariableAttribute) + .with_kind(NonterminalKind::StateVariableAttribute) } #[allow(unused_assignments, unused_parens)] @@ -4312,7 +4313,7 @@ impl Language { self.state_variable_attribute(input) .with_label(EdgeLabel::Item) }) - .with_kind(NonTerminalKind::StateVariableAttributes) + .with_kind(NonterminalKind::StateVariableAttributes) } #[allow(unused_assignments, unused_parens)] @@ -4324,7 +4325,7 @@ impl Language { seq.elem_labeled(EdgeLabel::Attributes, self.state_variable_attributes(input))?; seq.elem_labeled( EdgeLabel::Name, - self.parse_token_with_trivia::( + self.parse_terminal_with_trivia::( input, TerminalKind::Identifier, ), @@ -4339,19 +4340,19 @@ impl Language { input, self, TerminalKind::Semicolon, - TokenAcceptanceThreshold(1u8), + TerminalAcceptanceThreshold(1u8), ), )?; seq.elem_labeled( EdgeLabel::Semicolon, - self.parse_token_with_trivia::( + self.parse_terminal_with_trivia::( input, TerminalKind::Semicolon, ), )?; seq.finish() }) - .with_kind(NonTerminalKind::StateVariableDefinition) + .with_kind(NonterminalKind::StateVariableDefinition) } #[allow(unused_assignments, unused_parens)] @@ -4359,7 +4360,7 @@ impl Language { SequenceHelper::run(|mut seq| { seq.elem_labeled( EdgeLabel::Equal, - self.parse_token_with_trivia::( + self.parse_terminal_with_trivia::( input, TerminalKind::Equal, ), @@ -4367,7 +4368,7 @@ impl Language { seq.elem_labeled(EdgeLabel::Value, self.expression(input))?; seq.finish() }) - .with_kind(NonTerminalKind::StateVariableDefinitionValue) + .with_kind(NonterminalKind::StateVariableDefinitionValue) } #[allow(unused_assignments, unused_parens)] @@ -4420,7 +4421,7 @@ impl Language { choice.finish(input) }) .with_label(EdgeLabel::Variant) - .with_kind(NonTerminalKind::Statement) + .with_kind(NonterminalKind::Statement) } #[allow(unused_assignments, unused_parens)] @@ -4428,24 +4429,24 @@ impl Language { ZeroOrMoreHelper::run(input, |input| { self.statement(input).with_label(EdgeLabel::Item) }) - .with_kind(NonTerminalKind::Statements) + .with_kind(NonterminalKind::Statements) } #[allow(unused_assignments, unused_parens)] fn storage_location(&self, input: &mut ParserContext<'_>) -> ParserResult { ChoiceHelper::run(input, |mut choice, input| { - let result = self.parse_token_with_trivia::( + let result = self.parse_terminal_with_trivia::( input, TerminalKind::MemoryKeyword, ); choice.consider(input, result)?; - let result = self.parse_token_with_trivia::( + let result = self.parse_terminal_with_trivia::( input, TerminalKind::StorageKeyword, ); choice.consider(input, result)?; if self.version_is_at_least_0_5_0 { - let result = self.parse_token_with_trivia::( + let result = self.parse_terminal_with_trivia::( input, TerminalKind::CallDataKeyword, ); @@ -4454,7 +4455,7 @@ impl Language { choice.finish(input) }) .with_label(EdgeLabel::Variant) - .with_kind(NonTerminalKind::StorageLocation) + .with_kind(NonterminalKind::StorageLocation) } #[allow(unused_assignments, unused_parens)] @@ -4483,18 +4484,18 @@ impl Language { choice.finish(input) }) .with_label(EdgeLabel::Variant) - .with_kind(NonTerminalKind::StringExpression) + .with_kind(NonterminalKind::StringExpression) } #[allow(unused_assignments, unused_parens)] fn string_literal(&self, input: &mut ParserContext<'_>) -> ParserResult { ChoiceHelper::run(input, |mut choice, input| { - let result = self.parse_token_with_trivia::( + let result = self.parse_terminal_with_trivia::( input, TerminalKind::SingleQuotedStringLiteral, ); choice.consider(input, result)?; - let result = self.parse_token_with_trivia::( + let result = self.parse_terminal_with_trivia::( input, TerminalKind::DoubleQuotedStringLiteral, ); @@ -4502,7 +4503,7 @@ impl Language { choice.finish(input) }) .with_label(EdgeLabel::Variant) - .with_kind(NonTerminalKind::StringLiteral) + .with_kind(NonterminalKind::StringLiteral) } #[allow(unused_assignments, unused_parens)] @@ -4514,7 +4515,7 @@ impl Language { } else { ParserResult::disabled() } - .with_kind(NonTerminalKind::StringLiterals) + .with_kind(NonterminalKind::StringLiterals) } #[allow(unused_assignments, unused_parens)] @@ -4522,14 +4523,14 @@ impl Language { SequenceHelper::run(|mut seq| { seq.elem_labeled( EdgeLabel::StructKeyword, - self.parse_token_with_trivia::( + self.parse_terminal_with_trivia::( input, TerminalKind::StructKeyword, ), )?; seq.elem_labeled( EdgeLabel::Name, - self.parse_token_with_trivia::( + self.parse_terminal_with_trivia::( input, TerminalKind::Identifier, ), @@ -4539,7 +4540,7 @@ impl Language { let input = delim_guard.ctx(); seq.elem_labeled( EdgeLabel::OpenBrace, - self.parse_token_with_trivia::( + self.parse_terminal_with_trivia::( input, TerminalKind::OpenBrace, ), @@ -4551,12 +4552,12 @@ impl Language { input, self, TerminalKind::CloseBrace, - TokenAcceptanceThreshold(0u8), + TerminalAcceptanceThreshold(0u8), ), )?; seq.elem_labeled( EdgeLabel::CloseBrace, - self.parse_token_with_trivia::( + self.parse_terminal_with_trivia::( input, TerminalKind::CloseBrace, ), @@ -4565,7 +4566,7 @@ impl Language { }))?; seq.finish() }) - .with_kind(NonTerminalKind::StructDefinition) + .with_kind(NonterminalKind::StructDefinition) } #[allow(unused_assignments, unused_parens)] @@ -4576,7 +4577,7 @@ impl Language { seq.elem_labeled(EdgeLabel::TypeName, self.type_name(input))?; seq.elem_labeled( EdgeLabel::Name, - self.parse_token_with_trivia::( + self.parse_terminal_with_trivia::( input, TerminalKind::Identifier, ), @@ -4587,19 +4588,19 @@ impl Language { input, self, TerminalKind::Semicolon, - TokenAcceptanceThreshold(1u8), + TerminalAcceptanceThreshold(1u8), ), )?; seq.elem_labeled( EdgeLabel::Semicolon, - self.parse_token_with_trivia::( + self.parse_terminal_with_trivia::( input, TerminalKind::Semicolon, ), )?; seq.finish() }) - .with_kind(NonTerminalKind::StructMember) + .with_kind(NonterminalKind::StructMember) } #[allow(unused_assignments, unused_parens)] @@ -4607,7 +4608,7 @@ impl Language { ZeroOrMoreHelper::run(input, |input| { self.struct_member(input).with_label(EdgeLabel::Item) }) - .with_kind(NonTerminalKind::StructMembers) + .with_kind(NonterminalKind::StructMembers) } #[allow(unused_assignments, unused_parens)] @@ -4615,7 +4616,7 @@ impl Language { if !self.version_is_at_least_0_5_0 { SequenceHelper::run(|mut seq| { seq.elem( - self.parse_token_with_trivia::( + self.parse_terminal_with_trivia::( input, TerminalKind::ThrowKeyword, ) @@ -4624,12 +4625,12 @@ impl Language { input, self, TerminalKind::Semicolon, - TokenAcceptanceThreshold(1u8), + TerminalAcceptanceThreshold(1u8), ), )?; seq.elem_labeled( EdgeLabel::Semicolon, - self.parse_token_with_trivia::( + self.parse_terminal_with_trivia::( input, TerminalKind::Semicolon, ), @@ -4639,7 +4640,7 @@ impl Language { } else { ParserResult::disabled() } - .with_kind(NonTerminalKind::ThrowStatement) + .with_kind(NonterminalKind::ThrowStatement) } #[allow(unused_assignments, unused_parens)] @@ -4648,7 +4649,7 @@ impl Language { SequenceHelper::run(|mut seq| { seq.elem_labeled( EdgeLabel::TryKeyword, - self.parse_token_with_trivia::( + self.parse_terminal_with_trivia::( input, TerminalKind::TryKeyword, ), @@ -4665,14 +4666,14 @@ impl Language { } else { ParserResult::disabled() } - .with_kind(NonTerminalKind::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(EdgeLabel::Member) - .with_kind(NonTerminalKind::TupleDeconstructionElement) + .with_kind(NonterminalKind::TupleDeconstructionElement) } #[allow(unused_assignments, unused_parens)] @@ -4687,7 +4688,7 @@ impl Language { TerminalKind::Comma, EdgeLabel::Separator, ) - .with_kind(NonTerminalKind::TupleDeconstructionElements) + .with_kind(NonterminalKind::TupleDeconstructionElements) } #[allow(unused_assignments, unused_parens)] @@ -4699,7 +4700,7 @@ impl Language { seq.elem_labeled( EdgeLabel::VarKeyword, OptionalHelper::transform( - self.parse_token_with_trivia::( + self.parse_terminal_with_trivia::( input, TerminalKind::VarKeyword, ), @@ -4711,7 +4712,7 @@ impl Language { let input = delim_guard.ctx(); seq.elem_labeled( EdgeLabel::OpenParen, - self.parse_token_with_trivia::( + self.parse_terminal_with_trivia::( input, TerminalKind::OpenParen, ), @@ -4723,12 +4724,12 @@ impl Language { input, self, TerminalKind::CloseParen, - TokenAcceptanceThreshold(0u8), + TerminalAcceptanceThreshold(0u8), ), )?; seq.elem_labeled( EdgeLabel::CloseParen, - self.parse_token_with_trivia::( + self.parse_terminal_with_trivia::( input, TerminalKind::CloseParen, ), @@ -4737,7 +4738,7 @@ impl Language { }))?; seq.elem_labeled( EdgeLabel::Equal, - self.parse_token_with_trivia::( + self.parse_terminal_with_trivia::( input, TerminalKind::Equal, ), @@ -4749,19 +4750,19 @@ impl Language { input, self, TerminalKind::Semicolon, - TokenAcceptanceThreshold(1u8), + TerminalAcceptanceThreshold(1u8), ), )?; seq.elem_labeled( EdgeLabel::Semicolon, - self.parse_token_with_trivia::( + self.parse_terminal_with_trivia::( input, TerminalKind::Semicolon, ), )?; seq.finish() }) - .with_kind(NonTerminalKind::TupleDeconstructionStatement) + .with_kind(NonterminalKind::TupleDeconstructionStatement) } #[allow(unused_assignments, unused_parens)] @@ -4771,7 +4772,7 @@ impl Language { let input = delim_guard.ctx(); seq.elem_labeled( EdgeLabel::OpenParen, - self.parse_token_with_trivia::( + self.parse_terminal_with_trivia::( input, TerminalKind::OpenParen, ), @@ -4783,19 +4784,19 @@ impl Language { input, self, TerminalKind::CloseParen, - TokenAcceptanceThreshold(0u8), + TerminalAcceptanceThreshold(0u8), ), )?; seq.elem_labeled( EdgeLabel::CloseParen, - self.parse_token_with_trivia::( + self.parse_terminal_with_trivia::( input, TerminalKind::CloseParen, ), )?; seq.finish() }) - .with_kind(NonTerminalKind::TupleExpression) + .with_kind(NonterminalKind::TupleExpression) } #[allow(unused_assignments, unused_parens)] @@ -4808,14 +4809,14 @@ impl Language { choice.finish(input) }) .with_label(EdgeLabel::Variant) - .with_kind(NonTerminalKind::TupleMember) + .with_kind(NonterminalKind::TupleMember) } #[allow(unused_assignments, unused_parens)] fn tuple_value(&self, input: &mut ParserContext<'_>) -> ParserResult { OptionalHelper::transform(self.expression(input)) .with_label(EdgeLabel::Expression) - .with_kind(NonTerminalKind::TupleValue) + .with_kind(NonterminalKind::TupleValue) } #[allow(unused_assignments, unused_parens)] @@ -4827,7 +4828,7 @@ impl Language { TerminalKind::Comma, EdgeLabel::Separator, ) - .with_kind(NonTerminalKind::TupleValues) + .with_kind(NonterminalKind::TupleValues) } #[allow(unused_assignments, unused_parens)] @@ -4836,7 +4837,7 @@ impl Language { SequenceHelper::run(|mut seq| { seq.elem_labeled( EdgeLabel::TypeKeyword, - self.parse_token_with_trivia::( + self.parse_terminal_with_trivia::( input, TerminalKind::TypeKeyword, ), @@ -4846,7 +4847,7 @@ impl Language { let input = delim_guard.ctx(); seq.elem_labeled( EdgeLabel::OpenParen, - self.parse_token_with_trivia::( + self.parse_terminal_with_trivia::( input, TerminalKind::OpenParen, ), @@ -4858,12 +4859,12 @@ impl Language { input, self, TerminalKind::CloseParen, - TokenAcceptanceThreshold(0u8), + TerminalAcceptanceThreshold(0u8), ), )?; seq.elem_labeled( EdgeLabel::CloseParen, - self.parse_token_with_trivia::( + self.parse_terminal_with_trivia::( input, TerminalKind::CloseParen, ), @@ -4875,21 +4876,21 @@ impl Language { } else { ParserResult::disabled() } - .with_kind(NonTerminalKind::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( - NonTerminalKind::ArrayTypeName, + NonterminalKind::ArrayTypeName, 1u8, SequenceHelper::run(|mut seq| { let mut delim_guard = input.open_delim(TerminalKind::CloseBracket); let input = delim_guard.ctx(); seq.elem_labeled( EdgeLabel::OpenBracket, - self.parse_token_with_trivia::( + self.parse_terminal_with_trivia::( input, TerminalKind::OpenBracket, ), @@ -4901,12 +4902,12 @@ impl Language { input, self, TerminalKind::CloseBracket, - TokenAcceptanceThreshold(0u8), + TerminalAcceptanceThreshold(0u8), ), )?; seq.elem_labeled( EdgeLabel::CloseBracket, - self.parse_token_with_trivia::( + self.parse_terminal_with_trivia::( input, TerminalKind::CloseBracket, ), @@ -4944,10 +4945,10 @@ impl Language { }) }; PrecedenceHelper::reduce_precedence_result( - NonTerminalKind::TypeName, + NonterminalKind::TypeName, linear_expression_parser(input), ) - .with_kind(NonTerminalKind::TypeName) + .with_kind(NonterminalKind::TypeName) } #[allow(unused_assignments, unused_parens)] @@ -4960,14 +4961,14 @@ impl Language { )?; seq.elem_labeled( EdgeLabel::Name, - self.parse_token_with_trivia::( + self.parse_terminal_with_trivia::( input, TerminalKind::Identifier, ), )?; seq.finish() }) - .with_kind(NonTerminalKind::TypedTupleMember) + .with_kind(NonterminalKind::TypedTupleMember) } #[allow(unused_assignments, unused_parens)] @@ -4976,7 +4977,7 @@ impl Language { SequenceHelper::run(|mut seq| { seq.elem_labeled( EdgeLabel::UncheckedKeyword, - self.parse_token_with_trivia::( + self.parse_terminal_with_trivia::( input, TerminalKind::UncheckedKeyword, ), @@ -4987,19 +4988,19 @@ impl Language { } else { ParserResult::disabled() } - .with_kind(NonTerminalKind::UncheckedBlock) + .with_kind(NonterminalKind::UncheckedBlock) } #[allow(unused_assignments, unused_parens)] fn unicode_string_literal(&self, input: &mut ParserContext<'_>) -> ParserResult { if self.version_is_at_least_0_7_0 { ChoiceHelper::run(input, |mut choice, input| { - let result = self.parse_token_with_trivia::( + let result = self.parse_terminal_with_trivia::( input, TerminalKind::SingleQuotedUnicodeStringLiteral, ); choice.consider(input, result)?; - let result = self.parse_token_with_trivia::( + let result = self.parse_terminal_with_trivia::( input, TerminalKind::DoubleQuotedUnicodeStringLiteral, ); @@ -5010,7 +5011,7 @@ impl Language { } else { ParserResult::disabled() } - .with_kind(NonTerminalKind::UnicodeStringLiteral) + .with_kind(NonterminalKind::UnicodeStringLiteral) } #[allow(unused_assignments, unused_parens)] @@ -5023,7 +5024,7 @@ impl Language { } else { ParserResult::disabled() } - .with_kind(NonTerminalKind::UnicodeStringLiterals) + .with_kind(NonterminalKind::UnicodeStringLiterals) } #[allow(unused_assignments, unused_parens)] @@ -5033,52 +5034,52 @@ impl Language { let result = self.modifier_invocation(input); choice.consider(input, result)?; if !self.version_is_at_least_0_5_0 { - let result = self.parse_token_with_trivia::( + let result = self.parse_terminal_with_trivia::( input, TerminalKind::ConstantKeyword, ); choice.consider(input, result)?; } - let result = self.parse_token_with_trivia::( + let result = self.parse_terminal_with_trivia::( input, TerminalKind::ExternalKeyword, ); choice.consider(input, result)?; if !self.version_is_at_least_0_5_0 { - let result = self.parse_token_with_trivia::( + let result = self.parse_terminal_with_trivia::( input, TerminalKind::InternalKeyword, ); choice.consider(input, result)?; } - let result = self.parse_token_with_trivia::( + let result = self.parse_terminal_with_trivia::( input, TerminalKind::PayableKeyword, ); choice.consider(input, result)?; if !self.version_is_at_least_0_5_0 { - let result = self.parse_token_with_trivia::( + let result = self.parse_terminal_with_trivia::( input, TerminalKind::PrivateKeyword, ); choice.consider(input, result)?; } if !self.version_is_at_least_0_5_0 { - let result = self.parse_token_with_trivia::( + let result = self.parse_terminal_with_trivia::( input, 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::( + let result = self.parse_terminal_with_trivia::( input, 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::( + let result = self.parse_terminal_with_trivia::( input, TerminalKind::ViewKeyword, ); @@ -5090,7 +5091,7 @@ impl Language { } else { ParserResult::disabled() } - .with_kind(NonTerminalKind::UnnamedFunctionAttribute) + .with_kind(NonterminalKind::UnnamedFunctionAttribute) } #[allow(unused_assignments, unused_parens)] @@ -5103,7 +5104,7 @@ impl Language { } else { ParserResult::disabled() } - .with_kind(NonTerminalKind::UnnamedFunctionAttributes) + .with_kind(NonterminalKind::UnnamedFunctionAttributes) } #[allow(unused_assignments, unused_parens)] @@ -5112,7 +5113,7 @@ impl Language { SequenceHelper::run(|mut seq| { seq.elem_labeled( EdgeLabel::FunctionKeyword, - self.parse_token_with_trivia::( + self.parse_terminal_with_trivia::( input, TerminalKind::FunctionKeyword, ), @@ -5128,7 +5129,7 @@ impl Language { } else { ParserResult::disabled() } - .with_kind(NonTerminalKind::UnnamedFunctionDefinition) + .with_kind(NonterminalKind::UnnamedFunctionDefinition) } #[allow(unused_assignments, unused_parens)] @@ -5140,14 +5141,14 @@ impl Language { )?; seq.elem_labeled( EdgeLabel::Name, - self.parse_token_with_trivia::( + self.parse_terminal_with_trivia::( input, TerminalKind::Identifier, ), )?; seq.finish() }) - .with_kind(NonTerminalKind::UntypedTupleMember) + .with_kind(NonterminalKind::UntypedTupleMember) } #[allow(unused_assignments, unused_parens)] @@ -5158,21 +5159,21 @@ impl Language { SequenceHelper::run(|mut seq| { seq.elem_labeled( EdgeLabel::TypeKeyword, - self.parse_token_with_trivia::( + self.parse_terminal_with_trivia::( input, TerminalKind::TypeKeyword, ), )?; seq.elem_labeled( EdgeLabel::Name, - self.parse_token_with_trivia::( + self.parse_terminal_with_trivia::( input, TerminalKind::Identifier, ), )?; seq.elem_labeled( EdgeLabel::IsKeyword, - self.parse_token_with_trivia::( + self.parse_terminal_with_trivia::( input, TerminalKind::IsKeyword, ), @@ -5184,12 +5185,12 @@ impl Language { input, self, TerminalKind::Semicolon, - TokenAcceptanceThreshold(1u8), + TerminalAcceptanceThreshold(1u8), ), )?; seq.elem_labeled( EdgeLabel::Semicolon, - self.parse_token_with_trivia::( + self.parse_terminal_with_trivia::( input, TerminalKind::Semicolon, ), @@ -5199,7 +5200,7 @@ impl Language { } else { ParserResult::disabled() } - .with_kind(NonTerminalKind::UserDefinedValueTypeDefinition) + .with_kind(NonterminalKind::UserDefinedValueTypeDefinition) } #[allow(unused_assignments, unused_parens)] @@ -5208,7 +5209,7 @@ impl Language { SequenceHelper::run(|mut seq| { seq.elem_labeled( EdgeLabel::AsKeyword, - self.parse_token_with_trivia::( + self.parse_terminal_with_trivia::( input, TerminalKind::AsKeyword, ), @@ -5219,7 +5220,7 @@ impl Language { } else { ParserResult::disabled() } - .with_kind(NonTerminalKind::UsingAlias) + .with_kind(NonterminalKind::UsingAlias) } #[allow(unused_assignments, unused_parens)] @@ -5234,7 +5235,7 @@ impl Language { choice.finish(input) }) .with_label(EdgeLabel::Variant) - .with_kind(NonTerminalKind::UsingClause) + .with_kind(NonterminalKind::UsingClause) } #[allow(unused_assignments, unused_parens)] @@ -5245,7 +5246,7 @@ impl Language { let input = delim_guard.ctx(); seq.elem_labeled( EdgeLabel::OpenBrace, - self.parse_token_with_trivia::( + self.parse_terminal_with_trivia::( input, TerminalKind::OpenBrace, ), @@ -5257,12 +5258,12 @@ impl Language { input, self, TerminalKind::CloseBrace, - TokenAcceptanceThreshold(0u8), + TerminalAcceptanceThreshold(0u8), ), )?; seq.elem_labeled( EdgeLabel::CloseBrace, - self.parse_token_with_trivia::( + self.parse_terminal_with_trivia::( input, TerminalKind::CloseBrace, ), @@ -5272,7 +5273,7 @@ impl Language { } else { ParserResult::disabled() } - .with_kind(NonTerminalKind::UsingDeconstruction) + .with_kind(NonterminalKind::UsingDeconstruction) } #[allow(unused_assignments, unused_parens)] @@ -5291,7 +5292,7 @@ impl Language { } else { ParserResult::disabled() } - .with_kind(NonTerminalKind::UsingDeconstructionSymbol) + .with_kind(NonterminalKind::UsingDeconstructionSymbol) } #[allow(unused_assignments, unused_parens)] @@ -5310,7 +5311,7 @@ impl Language { } else { ParserResult::disabled() } - .with_kind(NonTerminalKind::UsingDeconstructionSymbols) + .with_kind(NonterminalKind::UsingDeconstructionSymbols) } #[allow(unused_assignments, unused_parens)] @@ -5320,7 +5321,7 @@ impl Language { SequenceHelper::run(|mut seq| { seq.elem_labeled( EdgeLabel::UsingKeyword, - self.parse_token_with_trivia::( + self.parse_terminal_with_trivia::( input, TerminalKind::UsingKeyword, ), @@ -5328,7 +5329,7 @@ impl Language { seq.elem_labeled(EdgeLabel::Clause, self.using_clause(input))?; seq.elem_labeled( EdgeLabel::ForKeyword, - self.parse_token_with_trivia::( + self.parse_terminal_with_trivia::( input, TerminalKind::ForKeyword, ), @@ -5338,7 +5339,7 @@ impl Language { seq.elem_labeled( EdgeLabel::GlobalKeyword, OptionalHelper::transform( - self.parse_token_with_trivia::( + self.parse_terminal_with_trivia::( input, TerminalKind::GlobalKeyword, ), @@ -5351,96 +5352,96 @@ impl Language { input, self, TerminalKind::Semicolon, - TokenAcceptanceThreshold(1u8), + TerminalAcceptanceThreshold(1u8), ), )?; seq.elem_labeled( EdgeLabel::Semicolon, - self.parse_token_with_trivia::( + self.parse_terminal_with_trivia::( input, TerminalKind::Semicolon, ), )?; seq.finish() }) - .with_kind(NonTerminalKind::UsingDirective) + .with_kind(NonterminalKind::UsingDirective) } #[allow(unused_assignments, unused_parens)] fn using_operator(&self, input: &mut ParserContext<'_>) -> ParserResult { if self.version_is_at_least_0_8_19 { ChoiceHelper::run(input, |mut choice, input| { - let result = self.parse_token_with_trivia::( + let result = self.parse_terminal_with_trivia::( input, TerminalKind::Ampersand, ); choice.consider(input, result)?; - let result = self.parse_token_with_trivia::( + let result = self.parse_terminal_with_trivia::( input, TerminalKind::Asterisk, ); choice.consider(input, result)?; - let result = self.parse_token_with_trivia::( + let result = self.parse_terminal_with_trivia::( input, TerminalKind::BangEqual, ); choice.consider(input, result)?; - let result = self.parse_token_with_trivia::( + let result = self.parse_terminal_with_trivia::( input, TerminalKind::Bar, ); choice.consider(input, result)?; - let result = self.parse_token_with_trivia::( + let result = self.parse_terminal_with_trivia::( input, TerminalKind::Caret, ); choice.consider(input, result)?; - let result = self.parse_token_with_trivia::( + let result = self.parse_terminal_with_trivia::( input, TerminalKind::EqualEqual, ); choice.consider(input, result)?; - let result = self.parse_token_with_trivia::( + let result = self.parse_terminal_with_trivia::( input, TerminalKind::GreaterThan, ); choice.consider(input, result)?; - let result = self.parse_token_with_trivia::( + let result = self.parse_terminal_with_trivia::( input, TerminalKind::GreaterThanEqual, ); choice.consider(input, result)?; - let result = self.parse_token_with_trivia::( + let result = self.parse_terminal_with_trivia::( input, TerminalKind::LessThan, ); choice.consider(input, result)?; - let result = self.parse_token_with_trivia::( + let result = self.parse_terminal_with_trivia::( input, TerminalKind::LessThanEqual, ); choice.consider(input, result)?; - let result = self.parse_token_with_trivia::( + let result = self.parse_terminal_with_trivia::( input, TerminalKind::Minus, ); choice.consider(input, result)?; - let result = self.parse_token_with_trivia::( + let result = self.parse_terminal_with_trivia::( input, TerminalKind::Percent, ); choice.consider(input, result)?; - let result = self.parse_token_with_trivia::( + let result = self.parse_terminal_with_trivia::( input, TerminalKind::Plus, ); choice.consider(input, result)?; - let result = self.parse_token_with_trivia::( + let result = self.parse_terminal_with_trivia::( input, TerminalKind::Slash, ); choice.consider(input, result)?; - let result = self.parse_token_with_trivia::( + let result = self.parse_terminal_with_trivia::( input, TerminalKind::Tilde, ); @@ -5451,7 +5452,7 @@ impl Language { } else { ParserResult::disabled() } - .with_kind(NonTerminalKind::UsingOperator) + .with_kind(NonterminalKind::UsingOperator) } #[allow(unused_assignments, unused_parens)] @@ -5459,7 +5460,7 @@ 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::( + let result = self.parse_terminal_with_trivia::( input, TerminalKind::Asterisk, ); @@ -5467,7 +5468,7 @@ impl Language { choice.finish(input) }) .with_label(EdgeLabel::Variant) - .with_kind(NonTerminalKind::UsingTarget) + .with_kind(NonterminalKind::UsingTarget) } #[allow(unused_assignments, unused_parens)] @@ -5485,7 +5486,7 @@ impl Language { )?; seq.elem_labeled( EdgeLabel::Name, - self.parse_token_with_trivia::( + self.parse_terminal_with_trivia::( input, TerminalKind::Identifier, ), @@ -5500,19 +5501,19 @@ impl Language { input, self, TerminalKind::Semicolon, - TokenAcceptanceThreshold(1u8), + TerminalAcceptanceThreshold(1u8), ), )?; seq.elem_labeled( EdgeLabel::Semicolon, - self.parse_token_with_trivia::( + self.parse_terminal_with_trivia::( input, TerminalKind::Semicolon, ), )?; seq.finish() }) - .with_kind(NonTerminalKind::VariableDeclarationStatement) + .with_kind(NonterminalKind::VariableDeclarationStatement) } #[allow(unused_assignments, unused_parens)] @@ -5521,7 +5522,7 @@ impl Language { let result = self.type_name(input); choice.consider(input, result)?; if !self.version_is_at_least_0_5_0 { - let result = self.parse_token_with_trivia::( + let result = self.parse_terminal_with_trivia::( input, TerminalKind::VarKeyword, ); @@ -5530,7 +5531,7 @@ impl Language { choice.finish(input) }) .with_label(EdgeLabel::Variant) - .with_kind(NonTerminalKind::VariableDeclarationType) + .with_kind(NonterminalKind::VariableDeclarationType) } #[allow(unused_assignments, unused_parens)] @@ -5538,7 +5539,7 @@ impl Language { SequenceHelper::run(|mut seq| { seq.elem_labeled( EdgeLabel::Equal, - self.parse_token_with_trivia::( + self.parse_terminal_with_trivia::( input, TerminalKind::Equal, ), @@ -5546,7 +5547,7 @@ impl Language { seq.elem_labeled(EdgeLabel::Expression, self.expression(input))?; seq.finish() }) - .with_kind(NonTerminalKind::VariableDeclarationValue) + .with_kind(NonterminalKind::VariableDeclarationValue) } #[allow(unused_assignments, unused_parens)] @@ -5557,14 +5558,14 @@ impl Language { }; match &r#match.nodes[..] { [cst::Edge { - node: cst::Node::NonTerminal(node), + node: cst::Node::Nonterminal(node), .. - }] if node.kind == NonTerminalKind::VersionExpression => match &node.children[..] { + }] if node.kind == NonterminalKind::VersionExpression => match &node.children[..] { [inner @ cst::Edge { - node: cst::Node::NonTerminal(node), + node: cst::Node::Nonterminal(node), .. - }] if node.kind == NonTerminalKind::VersionComparator => { - ParserResult::r#match(vec![inner.clone()], r#match.expected_tokens.clone()) + }] if node.kind == NonterminalKind::VersionComparator => { + ParserResult::r#match(vec![inner.clone()], r#match.expected_terminals.clone()) } _ => ParserResult::no_match(vec![]), }, @@ -5576,10 +5577,10 @@ impl Language { fn version_expression(&self, input: &mut ParserContext<'_>) -> ParserResult { let parse_left_version_range = |input: &mut ParserContext<'_>| { PrecedenceHelper::to_binary_operator( - NonTerminalKind::VersionRange, + NonterminalKind::VersionRange, 1u8, 1u8 + 1, - self.parse_token_with_trivia::( + self.parse_terminal_with_trivia::( input, TerminalKind::Minus, ) @@ -5588,53 +5589,53 @@ impl Language { }; let parse_prefix_version_comparator = |input: &mut ParserContext<'_>| { PrecedenceHelper::to_prefix_operator( - NonTerminalKind::VersionComparator, + NonterminalKind::VersionComparator, 3u8, ChoiceHelper::run(input, |mut choice, input| { let result = self - .parse_token_with_trivia::( + .parse_terminal_with_trivia::( input, TerminalKind::Caret, ) .with_label(EdgeLabel::Operator); choice.consider(input, result)?; let result = self - .parse_token_with_trivia::( + .parse_terminal_with_trivia::( input, TerminalKind::Tilde, ) .with_label(EdgeLabel::Operator); choice.consider(input, result)?; let result = self - .parse_token_with_trivia::( + .parse_terminal_with_trivia::( input, TerminalKind::Equal, ) .with_label(EdgeLabel::Operator); choice.consider(input, result)?; let result = self - .parse_token_with_trivia::( + .parse_terminal_with_trivia::( input, TerminalKind::LessThan, ) .with_label(EdgeLabel::Operator); choice.consider(input, result)?; let result = self - .parse_token_with_trivia::( + .parse_terminal_with_trivia::( input, TerminalKind::GreaterThan, ) .with_label(EdgeLabel::Operator); choice.consider(input, result)?; let result = self - .parse_token_with_trivia::( + .parse_terminal_with_trivia::( input, TerminalKind::LessThanEqual, ) .with_label(EdgeLabel::Operator); choice.consider(input, result)?; let result = self - .parse_token_with_trivia::( + .parse_terminal_with_trivia::( input, TerminalKind::GreaterThanEqual, ) @@ -5655,12 +5656,12 @@ impl Language { ChoiceHelper::run(input, |mut choice, input| { let result = self.version_specifiers(input); choice.consider(input, result)?; - let result = self.parse_token_with_trivia::( + let result = self.parse_terminal_with_trivia::( input, TerminalKind::SingleQuotedVersionLiteral, ); choice.consider(input, result)?; - let result = self.parse_token_with_trivia::( + let result = self.parse_terminal_with_trivia::( input, TerminalKind::DoubleQuotedVersionLiteral, ); @@ -5697,10 +5698,10 @@ impl Language { }) }; PrecedenceHelper::reduce_precedence_result( - NonTerminalKind::VersionExpression, + NonterminalKind::VersionExpression, linear_expression_parser(input), ) - .with_kind(NonTerminalKind::VersionExpression) + .with_kind(NonterminalKind::VersionExpression) } #[allow(unused_assignments, unused_parens)] @@ -5708,7 +5709,7 @@ impl Language { OneOrMoreHelper::run(input, |input| { self.version_expression(input).with_label(EdgeLabel::Item) }) - .with_kind(NonTerminalKind::VersionExpressionSet) + .with_kind(NonterminalKind::VersionExpressionSet) } #[allow(unused_assignments, unused_parens)] @@ -5723,7 +5724,7 @@ impl Language { TerminalKind::BarBar, EdgeLabel::Separator, ) - .with_kind(NonTerminalKind::VersionExpressionSets) + .with_kind(NonterminalKind::VersionExpressionSets) } #[allow(unused_assignments, unused_parens)] @@ -5731,7 +5732,7 @@ impl Language { SequenceHelper::run(|mut seq| { seq.elem_labeled( EdgeLabel::SolidityKeyword, - self.parse_token_with_trivia::( + self.parse_terminal_with_trivia::( input, TerminalKind::SolidityKeyword, ), @@ -5739,7 +5740,7 @@ impl Language { seq.elem_labeled(EdgeLabel::Sets, self.version_expression_sets(input))?; seq.finish() }) - .with_kind(NonTerminalKind::VersionPragma) + .with_kind(NonterminalKind::VersionPragma) } #[allow(unused_assignments, unused_parens)] @@ -5750,14 +5751,14 @@ impl Language { }; match &r#match.nodes[..] { [cst::Edge { - node: cst::Node::NonTerminal(node), + node: cst::Node::Nonterminal(node), .. - }] if node.kind == NonTerminalKind::VersionExpression => match &node.children[..] { + }] if node.kind == NonterminalKind::VersionExpression => match &node.children[..] { [inner @ cst::Edge { - node: cst::Node::NonTerminal(node), + node: cst::Node::Nonterminal(node), .. - }] if node.kind == NonTerminalKind::VersionRange => { - ParserResult::r#match(vec![inner.clone()], r#match.expected_tokens.clone()) + }] if node.kind == NonterminalKind::VersionRange => { + ParserResult::r#match(vec![inner.clone()], r#match.expected_terminals.clone()) } _ => ParserResult::no_match(vec![]), }, @@ -5771,7 +5772,7 @@ impl Language { input, self, |input| { - self.parse_token_with_trivia::( + self.parse_terminal_with_trivia::( input, TerminalKind::VersionSpecifier, ) @@ -5780,7 +5781,7 @@ impl Language { TerminalKind::Period, EdgeLabel::Separator, ) - .with_kind(NonTerminalKind::VersionSpecifiers) + .with_kind(NonterminalKind::VersionSpecifiers) } #[allow(unused_assignments, unused_parens)] @@ -5788,7 +5789,7 @@ impl Language { SequenceHelper::run(|mut seq| { seq.elem_labeled( EdgeLabel::WhileKeyword, - self.parse_token_with_trivia::( + self.parse_terminal_with_trivia::( input, TerminalKind::WhileKeyword, ), @@ -5798,7 +5799,7 @@ impl Language { let input = delim_guard.ctx(); seq.elem_labeled( EdgeLabel::OpenParen, - self.parse_token_with_trivia::( + self.parse_terminal_with_trivia::( input, TerminalKind::OpenParen, ), @@ -5810,12 +5811,12 @@ impl Language { input, self, TerminalKind::CloseParen, - TokenAcceptanceThreshold(0u8), + TerminalAcceptanceThreshold(0u8), ), )?; seq.elem_labeled( EdgeLabel::CloseParen, - self.parse_token_with_trivia::( + self.parse_terminal_with_trivia::( input, TerminalKind::CloseParen, ), @@ -5825,7 +5826,7 @@ impl Language { seq.elem_labeled(EdgeLabel::Body, self.statement(input))?; seq.finish() }) - .with_kind(NonTerminalKind::WhileStatement) + .with_kind(NonterminalKind::WhileStatement) } #[allow(unused_assignments, unused_parens)] @@ -5837,7 +5838,7 @@ impl Language { TerminalKind::Comma, EdgeLabel::Separator, )) - .with_kind(NonTerminalKind::YulArguments) + .with_kind(NonterminalKind::YulArguments) } #[allow(unused_assignments, unused_parens)] @@ -5847,7 +5848,7 @@ impl Language { let result = self.yul_colon_and_equal(input); choice.consider(input, result)?; } - let result = self.parse_token_with_trivia::( + let result = self.parse_terminal_with_trivia::( input, TerminalKind::ColonEqual, ); @@ -5855,7 +5856,7 @@ impl Language { choice.finish(input) }) .with_label(EdgeLabel::Variant) - .with_kind(NonTerminalKind::YulAssignmentOperator) + .with_kind(NonterminalKind::YulAssignmentOperator) } #[allow(unused_assignments, unused_parens)] @@ -5866,7 +5867,7 @@ impl Language { seq.elem_labeled(EdgeLabel::Expression, self.yul_expression(input))?; seq.finish() }) - .with_kind(NonTerminalKind::YulAssignmentStatement) + .with_kind(NonterminalKind::YulAssignmentStatement) } #[allow(unused_assignments, unused_parens)] @@ -5876,7 +5877,7 @@ impl Language { let input = delim_guard.ctx(); seq.elem_labeled( EdgeLabel::OpenBrace, - self.parse_token_with_trivia::( + self.parse_terminal_with_trivia::( input, TerminalKind::OpenBrace, ), @@ -5888,466 +5889,466 @@ impl Language { input, self, TerminalKind::CloseBrace, - TokenAcceptanceThreshold(0u8), + TerminalAcceptanceThreshold(0u8), ), )?; seq.elem_labeled( EdgeLabel::CloseBrace, - self.parse_token_with_trivia::( + self.parse_terminal_with_trivia::( input, TerminalKind::CloseBrace, ), )?; seq.finish() }) - .with_kind(NonTerminalKind::YulBlock) + .with_kind(NonterminalKind::YulBlock) } #[allow(unused_assignments, unused_parens)] fn yul_break_statement(&self, input: &mut ParserContext<'_>) -> ParserResult { - self.parse_token_with_trivia::( + self.parse_terminal_with_trivia::( input, TerminalKind::YulBreakKeyword, ) .with_label(EdgeLabel::BreakKeyword) - .with_kind(NonTerminalKind::YulBreakStatement) + .with_kind(NonterminalKind::YulBreakStatement) } #[allow(unused_assignments, unused_parens)] fn yul_built_in_function(&self, input: &mut ParserContext<'_>) -> ParserResult { ChoiceHelper::run(input, |mut choice, input| { - let result = self.parse_token_with_trivia::( + let result = self.parse_terminal_with_trivia::( input, TerminalKind::YulAddKeyword, ); choice.consider(input, result)?; - let result = self.parse_token_with_trivia::( + let result = self.parse_terminal_with_trivia::( input, TerminalKind::YulAddModKeyword, ); choice.consider(input, result)?; - let result = self.parse_token_with_trivia::( + let result = self.parse_terminal_with_trivia::( input, TerminalKind::YulAddressKeyword, ); choice.consider(input, result)?; - let result = self.parse_token_with_trivia::( + let result = self.parse_terminal_with_trivia::( input, TerminalKind::YulAndKeyword, ); choice.consider(input, result)?; - let result = self.parse_token_with_trivia::( + let result = self.parse_terminal_with_trivia::( input, TerminalKind::YulBalanceKeyword, ); choice.consider(input, result)?; - let result = self.parse_token_with_trivia::( + let result = self.parse_terminal_with_trivia::( input, TerminalKind::YulBlockHashKeyword, ); choice.consider(input, result)?; - let result = self.parse_token_with_trivia::( + let result = self.parse_terminal_with_trivia::( input, TerminalKind::YulByteKeyword, ); choice.consider(input, result)?; - let result = self.parse_token_with_trivia::( + let result = self.parse_terminal_with_trivia::( input, TerminalKind::YulCallCodeKeyword, ); choice.consider(input, result)?; - let result = self.parse_token_with_trivia::( + let result = self.parse_terminal_with_trivia::( input, TerminalKind::YulCallDataCopyKeyword, ); choice.consider(input, result)?; - let result = self.parse_token_with_trivia::( + let result = self.parse_terminal_with_trivia::( input, TerminalKind::YulCallDataLoadKeyword, ); choice.consider(input, result)?; - let result = self.parse_token_with_trivia::( + let result = self.parse_terminal_with_trivia::( input, TerminalKind::YulCallDataSizeKeyword, ); choice.consider(input, result)?; - let result = self.parse_token_with_trivia::( + let result = self.parse_terminal_with_trivia::( input, TerminalKind::YulCallerKeyword, ); choice.consider(input, result)?; - let result = self.parse_token_with_trivia::( + let result = self.parse_terminal_with_trivia::( input, TerminalKind::YulCallKeyword, ); choice.consider(input, result)?; - let result = self.parse_token_with_trivia::( + let result = self.parse_terminal_with_trivia::( input, TerminalKind::YulCallValueKeyword, ); choice.consider(input, result)?; - let result = self.parse_token_with_trivia::( + let result = self.parse_terminal_with_trivia::( input, TerminalKind::YulCoinBaseKeyword, ); choice.consider(input, result)?; - let result = self.parse_token_with_trivia::( + let result = self.parse_terminal_with_trivia::( input, TerminalKind::YulCreateKeyword, ); choice.consider(input, result)?; - let result = self.parse_token_with_trivia::( + let result = self.parse_terminal_with_trivia::( input, TerminalKind::YulDelegateCallKeyword, ); choice.consider(input, result)?; - let result = self.parse_token_with_trivia::( + let result = self.parse_terminal_with_trivia::( input, TerminalKind::YulDivKeyword, ); choice.consider(input, result)?; - let result = self.parse_token_with_trivia::( + let result = self.parse_terminal_with_trivia::( input, TerminalKind::YulEqKeyword, ); choice.consider(input, result)?; - let result = self.parse_token_with_trivia::( + let result = self.parse_terminal_with_trivia::( input, TerminalKind::YulExpKeyword, ); choice.consider(input, result)?; - let result = self.parse_token_with_trivia::( + let result = self.parse_terminal_with_trivia::( input, TerminalKind::YulExtCodeCopyKeyword, ); choice.consider(input, result)?; - let result = self.parse_token_with_trivia::( + let result = self.parse_terminal_with_trivia::( input, TerminalKind::YulExtCodeSizeKeyword, ); choice.consider(input, result)?; - let result = self.parse_token_with_trivia::( + let result = self.parse_terminal_with_trivia::( input, TerminalKind::YulGasKeyword, ); choice.consider(input, result)?; - let result = self.parse_token_with_trivia::( + let result = self.parse_terminal_with_trivia::( input, TerminalKind::YulGasLimitKeyword, ); choice.consider(input, result)?; - let result = self.parse_token_with_trivia::( + let result = self.parse_terminal_with_trivia::( input, TerminalKind::YulGasPriceKeyword, ); choice.consider(input, result)?; - let result = self.parse_token_with_trivia::( + let result = self.parse_terminal_with_trivia::( input, TerminalKind::YulGtKeyword, ); choice.consider(input, result)?; - let result = self.parse_token_with_trivia::( + let result = self.parse_terminal_with_trivia::( input, TerminalKind::YulInvalidKeyword, ); choice.consider(input, result)?; - let result = self.parse_token_with_trivia::( + let result = self.parse_terminal_with_trivia::( input, TerminalKind::YulIsZeroKeyword, ); choice.consider(input, result)?; - let result = self.parse_token_with_trivia::( + let result = self.parse_terminal_with_trivia::( input, TerminalKind::YulLog0Keyword, ); choice.consider(input, result)?; - let result = self.parse_token_with_trivia::( + let result = self.parse_terminal_with_trivia::( input, TerminalKind::YulLog1Keyword, ); choice.consider(input, result)?; - let result = self.parse_token_with_trivia::( + let result = self.parse_terminal_with_trivia::( input, TerminalKind::YulLog2Keyword, ); choice.consider(input, result)?; - let result = self.parse_token_with_trivia::( + let result = self.parse_terminal_with_trivia::( input, TerminalKind::YulLog3Keyword, ); choice.consider(input, result)?; - let result = self.parse_token_with_trivia::( + let result = self.parse_terminal_with_trivia::( input, TerminalKind::YulLog4Keyword, ); choice.consider(input, result)?; - let result = self.parse_token_with_trivia::( + let result = self.parse_terminal_with_trivia::( input, TerminalKind::YulLtKeyword, ); choice.consider(input, result)?; - let result = self.parse_token_with_trivia::( + let result = self.parse_terminal_with_trivia::( input, TerminalKind::YulMLoadKeyword, ); choice.consider(input, result)?; - let result = self.parse_token_with_trivia::( + let result = self.parse_terminal_with_trivia::( input, TerminalKind::YulModKeyword, ); choice.consider(input, result)?; - let result = self.parse_token_with_trivia::( + let result = self.parse_terminal_with_trivia::( input, TerminalKind::YulMSizeKeyword, ); choice.consider(input, result)?; - let result = self.parse_token_with_trivia::( + let result = self.parse_terminal_with_trivia::( input, TerminalKind::YulMStore8Keyword, ); choice.consider(input, result)?; - let result = self.parse_token_with_trivia::( + let result = self.parse_terminal_with_trivia::( input, TerminalKind::YulMStoreKeyword, ); choice.consider(input, result)?; - let result = self.parse_token_with_trivia::( + let result = self.parse_terminal_with_trivia::( input, TerminalKind::YulMulKeyword, ); choice.consider(input, result)?; - let result = self.parse_token_with_trivia::( + let result = self.parse_terminal_with_trivia::( input, TerminalKind::YulMulModKeyword, ); choice.consider(input, result)?; - let result = self.parse_token_with_trivia::( + let result = self.parse_terminal_with_trivia::( input, TerminalKind::YulNotKeyword, ); choice.consider(input, result)?; - let result = self.parse_token_with_trivia::( + let result = self.parse_terminal_with_trivia::( input, TerminalKind::YulNumberKeyword, ); choice.consider(input, result)?; - let result = self.parse_token_with_trivia::( + let result = self.parse_terminal_with_trivia::( input, TerminalKind::YulOriginKeyword, ); choice.consider(input, result)?; - let result = self.parse_token_with_trivia::( + let result = self.parse_terminal_with_trivia::( input, TerminalKind::YulOrKeyword, ); choice.consider(input, result)?; - let result = self.parse_token_with_trivia::( + let result = self.parse_terminal_with_trivia::( input, TerminalKind::YulPopKeyword, ); choice.consider(input, result)?; - let result = self.parse_token_with_trivia::( + let result = self.parse_terminal_with_trivia::( input, TerminalKind::YulReturnKeyword, ); choice.consider(input, result)?; - let result = self.parse_token_with_trivia::( + let result = self.parse_terminal_with_trivia::( input, TerminalKind::YulRevertKeyword, ); choice.consider(input, result)?; - let result = self.parse_token_with_trivia::( + let result = self.parse_terminal_with_trivia::( input, TerminalKind::YulSDivKeyword, ); choice.consider(input, result)?; - let result = self.parse_token_with_trivia::( + let result = self.parse_terminal_with_trivia::( input, TerminalKind::YulSelfDestructKeyword, ); choice.consider(input, result)?; - let result = self.parse_token_with_trivia::( + let result = self.parse_terminal_with_trivia::( input, TerminalKind::YulSgtKeyword, ); choice.consider(input, result)?; - let result = self.parse_token_with_trivia::( + let result = self.parse_terminal_with_trivia::( input, TerminalKind::YulSignExtendKeyword, ); choice.consider(input, result)?; - let result = self.parse_token_with_trivia::( + let result = self.parse_terminal_with_trivia::( input, TerminalKind::YulSLoadKeyword, ); choice.consider(input, result)?; - let result = self.parse_token_with_trivia::( + let result = self.parse_terminal_with_trivia::( input, TerminalKind::YulSltKeyword, ); choice.consider(input, result)?; - let result = self.parse_token_with_trivia::( + let result = self.parse_terminal_with_trivia::( input, TerminalKind::YulSModKeyword, ); choice.consider(input, result)?; - let result = self.parse_token_with_trivia::( + let result = self.parse_terminal_with_trivia::( input, TerminalKind::YulSStoreKeyword, ); choice.consider(input, result)?; - let result = self.parse_token_with_trivia::( + let result = self.parse_terminal_with_trivia::( input, TerminalKind::YulStopKeyword, ); choice.consider(input, result)?; - let result = self.parse_token_with_trivia::( + let result = self.parse_terminal_with_trivia::( input, TerminalKind::YulSubKeyword, ); choice.consider(input, result)?; - let result = self.parse_token_with_trivia::( + let result = self.parse_terminal_with_trivia::( input, TerminalKind::YulTimestampKeyword, ); choice.consider(input, result)?; - let result = self.parse_token_with_trivia::( + let result = self.parse_terminal_with_trivia::( input, TerminalKind::YulXorKeyword, ); choice.consider(input, result)?; if self.version_is_at_least_0_4_12 { - let result = self.parse_token_with_trivia::( + let result = self.parse_terminal_with_trivia::( input, TerminalKind::YulKeccak256Keyword, ); choice.consider(input, result)?; } if !self.version_is_at_least_0_5_0 { - let result = self.parse_token_with_trivia::( + let result = self.parse_terminal_with_trivia::( input, TerminalKind::YulSha3Keyword, ); choice.consider(input, result)?; } if !self.version_is_at_least_0_5_0 { - let result = self.parse_token_with_trivia::( + let result = self.parse_terminal_with_trivia::( input, TerminalKind::YulSuicideKeyword, ); choice.consider(input, result)?; } if self.version_is_at_least_0_4_12 { - let result = self.parse_token_with_trivia::( + let result = self.parse_terminal_with_trivia::( input, TerminalKind::YulReturnDataCopyKeyword, ); choice.consider(input, result)?; } if self.version_is_at_least_0_4_12 { - let result = self.parse_token_with_trivia::( + let result = self.parse_terminal_with_trivia::( input, TerminalKind::YulReturnDataSizeKeyword, ); choice.consider(input, result)?; } if self.version_is_at_least_0_4_12 { - let result = self.parse_token_with_trivia::( + let result = self.parse_terminal_with_trivia::( input, TerminalKind::YulStaticCallKeyword, ); choice.consider(input, result)?; } if self.version_is_at_least_0_4_12 { - let result = self.parse_token_with_trivia::( + let result = self.parse_terminal_with_trivia::( input, TerminalKind::YulCreate2Keyword, ); choice.consider(input, result)?; } if self.version_is_at_least_0_5_0 { - let result = self.parse_token_with_trivia::( + let result = self.parse_terminal_with_trivia::( input, TerminalKind::YulExtCodeHashKeyword, ); choice.consider(input, result)?; } - let result = self.parse_token_with_trivia::( + let result = self.parse_terminal_with_trivia::( input, TerminalKind::YulSarKeyword, ); choice.consider(input, result)?; - let result = self.parse_token_with_trivia::( + let result = self.parse_terminal_with_trivia::( input, TerminalKind::YulShlKeyword, ); choice.consider(input, result)?; - let result = self.parse_token_with_trivia::( + let result = self.parse_terminal_with_trivia::( input, TerminalKind::YulShrKeyword, ); choice.consider(input, result)?; - let result = self.parse_token_with_trivia::( + let result = self.parse_terminal_with_trivia::( input, TerminalKind::YulChainIdKeyword, ); choice.consider(input, result)?; - let result = self.parse_token_with_trivia::( + let result = self.parse_terminal_with_trivia::( input, TerminalKind::YulSelfBalanceKeyword, ); choice.consider(input, result)?; if self.version_is_at_least_0_8_7 { - let result = self.parse_token_with_trivia::( + let result = self.parse_terminal_with_trivia::( input, TerminalKind::YulBaseFeeKeyword, ); choice.consider(input, result)?; } if !self.version_is_at_least_0_8_18 { - let result = self.parse_token_with_trivia::( + let result = self.parse_terminal_with_trivia::( input, TerminalKind::YulDifficultyKeyword, ); choice.consider(input, result)?; } if self.version_is_at_least_0_8_18 { - let result = self.parse_token_with_trivia::( + let result = self.parse_terminal_with_trivia::( input, TerminalKind::YulPrevRandaoKeyword, ); choice.consider(input, result)?; } if self.version_is_at_least_0_8_24 { - let result = self.parse_token_with_trivia::( + let result = self.parse_terminal_with_trivia::( input, TerminalKind::YulBlobBaseFeeKeyword, ); choice.consider(input, result)?; } if self.version_is_at_least_0_8_24 { - let result = self.parse_token_with_trivia::( + let result = self.parse_terminal_with_trivia::( input, TerminalKind::YulBlobHashKeyword, ); choice.consider(input, result)?; } if self.version_is_at_least_0_8_24 { - let result = self.parse_token_with_trivia::( + let result = self.parse_terminal_with_trivia::( input, TerminalKind::YulTLoadKeyword, ); choice.consider(input, result)?; } if self.version_is_at_least_0_8_24 { - let result = self.parse_token_with_trivia::( + let result = self.parse_terminal_with_trivia::( input, TerminalKind::YulTStoreKeyword, ); choice.consider(input, result)?; } if self.version_is_at_least_0_8_24 { - let result = self.parse_token_with_trivia::( + let result = self.parse_terminal_with_trivia::( input, TerminalKind::YulMCopyKeyword, ); @@ -6356,7 +6357,7 @@ impl Language { choice.finish(input) }) .with_label(EdgeLabel::Variant) - .with_kind(NonTerminalKind::YulBuiltInFunction) + .with_kind(NonterminalKind::YulBuiltInFunction) } #[allow(unused_assignments, unused_parens)] @@ -6365,14 +6366,14 @@ impl Language { SequenceHelper::run(|mut seq| { seq.elem_labeled( EdgeLabel::Colon, - self.parse_token_with_trivia::( + self.parse_terminal_with_trivia::( input, TerminalKind::Colon, ), )?; seq.elem_labeled( EdgeLabel::Equal, - self.parse_token_with_trivia::( + self.parse_terminal_with_trivia::( input, TerminalKind::Equal, ), @@ -6382,17 +6383,17 @@ impl Language { } else { ParserResult::disabled() } - .with_kind(NonTerminalKind::YulColonAndEqual) + .with_kind(NonterminalKind::YulColonAndEqual) } #[allow(unused_assignments, unused_parens)] fn yul_continue_statement(&self, input: &mut ParserContext<'_>) -> ParserResult { - self.parse_token_with_trivia::( + self.parse_terminal_with_trivia::( input, TerminalKind::YulContinueKeyword, ) .with_label(EdgeLabel::ContinueKeyword) - .with_kind(NonTerminalKind::YulContinueStatement) + .with_kind(NonterminalKind::YulContinueStatement) } #[allow(unused_assignments, unused_parens)] @@ -6400,7 +6401,7 @@ impl Language { SequenceHelper::run(|mut seq| { seq.elem_labeled( EdgeLabel::DefaultKeyword, - self.parse_token_with_trivia::( + self.parse_terminal_with_trivia::( input, TerminalKind::YulDefaultKeyword, ), @@ -6408,21 +6409,21 @@ impl Language { seq.elem_labeled(EdgeLabel::Body, self.yul_block(input))?; seq.finish() }) - .with_kind(NonTerminalKind::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( - NonTerminalKind::YulFunctionCallExpression, + NonterminalKind::YulFunctionCallExpression, 1u8, SequenceHelper::run(|mut seq| { let mut delim_guard = input.open_delim(TerminalKind::CloseParen); let input = delim_guard.ctx(); seq.elem_labeled( EdgeLabel::OpenParen, - self.parse_token_with_trivia::( + self.parse_terminal_with_trivia::( input, TerminalKind::OpenParen, ), @@ -6434,12 +6435,12 @@ impl Language { input, self, TerminalKind::CloseParen, - TokenAcceptanceThreshold(0u8), + TerminalAcceptanceThreshold(0u8), ), )?; seq.elem_labeled( EdgeLabel::CloseParen, - self.parse_token_with_trivia::( + self.parse_terminal_with_trivia::( input, TerminalKind::CloseParen, ), @@ -6475,10 +6476,10 @@ impl Language { }) }; PrecedenceHelper::reduce_precedence_result( - NonTerminalKind::YulExpression, + NonterminalKind::YulExpression, linear_expression_parser(input), ) - .with_kind(NonTerminalKind::YulExpression) + .with_kind(NonterminalKind::YulExpression) } #[allow(unused_assignments, unused_parens)] @@ -6486,7 +6487,7 @@ impl Language { SequenceHelper::run(|mut seq| { seq.elem_labeled( EdgeLabel::ForKeyword, - self.parse_token_with_trivia::( + self.parse_terminal_with_trivia::( input, TerminalKind::YulForKeyword, ), @@ -6497,7 +6498,7 @@ impl Language { seq.elem_labeled(EdgeLabel::Body, self.yul_block(input))?; seq.finish() }) - .with_kind(NonTerminalKind::YulForStatement) + .with_kind(NonterminalKind::YulForStatement) } #[allow(unused_assignments, unused_parens)] @@ -6508,14 +6509,14 @@ impl Language { }; match &r#match.nodes[..] { [cst::Edge { - node: cst::Node::NonTerminal(node), + node: cst::Node::Nonterminal(node), .. - }] if node.kind == NonTerminalKind::YulExpression => match &node.children[..] { + }] if node.kind == NonterminalKind::YulExpression => match &node.children[..] { [inner @ cst::Edge { - node: cst::Node::NonTerminal(node), + node: cst::Node::Nonterminal(node), .. - }] if node.kind == NonTerminalKind::YulFunctionCallExpression => { - ParserResult::r#match(vec![inner.clone()], r#match.expected_tokens.clone()) + }] if node.kind == NonterminalKind::YulFunctionCallExpression => { + ParserResult::r#match(vec![inner.clone()], r#match.expected_terminals.clone()) } _ => ParserResult::no_match(vec![]), }, @@ -6528,14 +6529,14 @@ impl Language { SequenceHelper::run(|mut seq| { seq.elem_labeled( EdgeLabel::FunctionKeyword, - self.parse_token_with_trivia::( + self.parse_terminal_with_trivia::( input, TerminalKind::YulFunctionKeyword, ), )?; seq.elem_labeled( EdgeLabel::Name, - self.parse_token_with_trivia::( + self.parse_terminal_with_trivia::( input, TerminalKind::YulIdentifier, ), @@ -6551,7 +6552,7 @@ impl Language { seq.elem_labeled(EdgeLabel::Body, self.yul_block(input))?; seq.finish() }) - .with_kind(NonTerminalKind::YulFunctionDefinition) + .with_kind(NonterminalKind::YulFunctionDefinition) } #[allow(unused_assignments, unused_parens)] @@ -6559,7 +6560,7 @@ impl Language { SequenceHelper::run(|mut seq| { seq.elem_labeled( EdgeLabel::IfKeyword, - self.parse_token_with_trivia::( + self.parse_terminal_with_trivia::( input, TerminalKind::YulIfKeyword, ), @@ -6568,7 +6569,7 @@ impl Language { seq.elem_labeled(EdgeLabel::Body, self.yul_block(input))?; seq.finish() }) - .with_kind(NonTerminalKind::YulIfStatement) + .with_kind(NonterminalKind::YulIfStatement) } #[allow(unused_assignments, unused_parens)] @@ -6577,14 +6578,14 @@ impl Language { SequenceHelper::run(|mut seq| { seq.elem_labeled( EdgeLabel::Label, - self.parse_token_with_trivia::( + self.parse_terminal_with_trivia::( input, TerminalKind::YulIdentifier, ), )?; seq.elem_labeled( EdgeLabel::Colon, - self.parse_token_with_trivia::( + self.parse_terminal_with_trivia::( input, TerminalKind::Colon, ), @@ -6594,13 +6595,13 @@ impl Language { } else { ParserResult::disabled() } - .with_kind(NonTerminalKind::YulLabel) + .with_kind(NonterminalKind::YulLabel) } #[allow(unused_assignments, unused_parens)] fn yul_leave_statement(&self, input: &mut ParserContext<'_>) -> ParserResult { if self.version_is_at_least_0_6_0 { - self.parse_token_with_trivia::( + self.parse_terminal_with_trivia::( input, TerminalKind::YulLeaveKeyword, ) @@ -6608,28 +6609,28 @@ impl Language { } else { ParserResult::disabled() } - .with_kind(NonTerminalKind::YulLeaveStatement) + .with_kind(NonterminalKind::YulLeaveStatement) } #[allow(unused_assignments, unused_parens)] fn yul_literal(&self, input: &mut ParserContext<'_>) -> ParserResult { ChoiceHelper::run(input, |mut choice, input| { - let result = self.parse_token_with_trivia::( + let result = self.parse_terminal_with_trivia::( input, TerminalKind::YulTrueKeyword, ); choice.consider(input, result)?; - let result = self.parse_token_with_trivia::( + let result = self.parse_terminal_with_trivia::( input, TerminalKind::YulFalseKeyword, ); choice.consider(input, result)?; - let result = self.parse_token_with_trivia::( + let result = self.parse_terminal_with_trivia::( input, TerminalKind::YulDecimalLiteral, ); choice.consider(input, result)?; - let result = self.parse_token_with_trivia::( + let result = self.parse_terminal_with_trivia::( input, TerminalKind::YulHexLiteral, ); @@ -6641,7 +6642,7 @@ impl Language { choice.finish(input) }) .with_label(EdgeLabel::Variant) - .with_kind(NonTerminalKind::YulLiteral) + .with_kind(NonterminalKind::YulLiteral) } #[allow(unused_assignments, unused_parens)] @@ -6650,7 +6651,7 @@ impl Language { input, self, |input| { - self.parse_token_with_trivia::( + self.parse_terminal_with_trivia::( input, TerminalKind::YulIdentifier, ) @@ -6659,7 +6660,7 @@ impl Language { TerminalKind::Comma, EdgeLabel::Separator, )) - .with_kind(NonTerminalKind::YulParameters) + .with_kind(NonterminalKind::YulParameters) } #[allow(unused_assignments, unused_parens)] @@ -6669,7 +6670,7 @@ impl Language { let input = delim_guard.ctx(); seq.elem_labeled( EdgeLabel::OpenParen, - self.parse_token_with_trivia::( + self.parse_terminal_with_trivia::( input, TerminalKind::OpenParen, ), @@ -6681,19 +6682,19 @@ impl Language { input, self, TerminalKind::CloseParen, - TokenAcceptanceThreshold(0u8), + TerminalAcceptanceThreshold(0u8), ), )?; seq.elem_labeled( EdgeLabel::CloseParen, - self.parse_token_with_trivia::( + self.parse_terminal_with_trivia::( input, TerminalKind::CloseParen, ), )?; seq.finish() }) - .with_kind(NonTerminalKind::YulParametersDeclaration) + .with_kind(NonterminalKind::YulParametersDeclaration) } #[allow(unused_assignments, unused_parens)] @@ -6705,19 +6706,19 @@ impl Language { TerminalKind::Period, EdgeLabel::Separator, ) - .with_kind(NonTerminalKind::YulPath) + .with_kind(NonterminalKind::YulPath) } #[allow(unused_assignments, unused_parens)] fn yul_path_component(&self, input: &mut ParserContext<'_>) -> ParserResult { ChoiceHelper::run(input, |mut choice, input| { - let result = self.parse_token_with_trivia::( + let result = self.parse_terminal_with_trivia::( input, TerminalKind::YulIdentifier, ); choice.consider(input, result)?; if self.version_is_at_least_0_8_10 { - let result = self.parse_token_with_trivia::( + let result = self.parse_terminal_with_trivia::( input, TerminalKind::YulAddressKeyword, ); @@ -6726,7 +6727,7 @@ impl Language { choice.finish(input) }) .with_label(EdgeLabel::Variant) - .with_kind(NonTerminalKind::YulPathComponent) + .with_kind(NonterminalKind::YulPathComponent) } #[allow(unused_assignments, unused_parens)] @@ -6738,7 +6739,7 @@ impl Language { TerminalKind::Comma, EdgeLabel::Separator, ) - .with_kind(NonTerminalKind::YulPaths) + .with_kind(NonterminalKind::YulPaths) } #[allow(unused_assignments, unused_parens)] @@ -6747,7 +6748,7 @@ impl Language { input, self, |input| { - self.parse_token_with_trivia::( + self.parse_terminal_with_trivia::( input, TerminalKind::YulIdentifier, ) @@ -6756,7 +6757,7 @@ impl Language { TerminalKind::Comma, EdgeLabel::Separator, ) - .with_kind(NonTerminalKind::YulReturnVariables) + .with_kind(NonterminalKind::YulReturnVariables) } #[allow(unused_assignments, unused_parens)] @@ -6764,7 +6765,7 @@ impl Language { SequenceHelper::run(|mut seq| { seq.elem_labeled( EdgeLabel::MinusGreaterThan, - self.parse_token_with_trivia::( + self.parse_terminal_with_trivia::( input, TerminalKind::MinusGreaterThan, ), @@ -6772,7 +6773,7 @@ impl Language { seq.elem_labeled(EdgeLabel::Variables, self.yul_return_variables(input))?; seq.finish() }) - .with_kind(NonTerminalKind::YulReturnsDeclaration) + .with_kind(NonterminalKind::YulReturnsDeclaration) } #[allow(unused_assignments, unused_parens)] @@ -6809,7 +6810,7 @@ impl Language { choice.finish(input) }) .with_label(EdgeLabel::Variant) - .with_kind(NonTerminalKind::YulStatement) + .with_kind(NonterminalKind::YulStatement) } #[allow(unused_assignments, unused_parens)] @@ -6817,7 +6818,7 @@ impl Language { ZeroOrMoreHelper::run(input, |input| { self.yul_statement(input).with_label(EdgeLabel::Item) }) - .with_kind(NonTerminalKind::YulStatements) + .with_kind(NonterminalKind::YulStatements) } #[allow(unused_assignments, unused_parens)] @@ -6830,7 +6831,7 @@ impl Language { choice.finish(input) }) .with_label(EdgeLabel::Variant) - .with_kind(NonTerminalKind::YulSwitchCase) + .with_kind(NonterminalKind::YulSwitchCase) } #[allow(unused_assignments, unused_parens)] @@ -6838,7 +6839,7 @@ impl Language { OneOrMoreHelper::run(input, |input| { self.yul_switch_case(input).with_label(EdgeLabel::Item) }) - .with_kind(NonTerminalKind::YulSwitchCases) + .with_kind(NonterminalKind::YulSwitchCases) } #[allow(unused_assignments, unused_parens)] @@ -6846,7 +6847,7 @@ impl Language { SequenceHelper::run(|mut seq| { seq.elem_labeled( EdgeLabel::SwitchKeyword, - self.parse_token_with_trivia::( + self.parse_terminal_with_trivia::( input, TerminalKind::YulSwitchKeyword, ), @@ -6855,7 +6856,7 @@ impl Language { seq.elem_labeled(EdgeLabel::Cases, self.yul_switch_cases(input))?; seq.finish() }) - .with_kind(NonTerminalKind::YulSwitchStatement) + .with_kind(NonterminalKind::YulSwitchStatement) } #[allow(unused_assignments, unused_parens)] @@ -6863,7 +6864,7 @@ impl Language { SequenceHelper::run(|mut seq| { seq.elem_labeled( EdgeLabel::CaseKeyword, - self.parse_token_with_trivia::( + self.parse_terminal_with_trivia::( input, TerminalKind::YulCaseKeyword, ), @@ -6872,7 +6873,7 @@ impl Language { seq.elem_labeled(EdgeLabel::Body, self.yul_block(input))?; seq.finish() }) - .with_kind(NonTerminalKind::YulValueCase) + .with_kind(NonterminalKind::YulValueCase) } #[allow(unused_assignments, unused_parens)] @@ -6880,14 +6881,14 @@ impl Language { SequenceHelper::run(|mut seq| { seq.elem_labeled( EdgeLabel::LetKeyword, - self.parse_token_with_trivia::( + self.parse_terminal_with_trivia::( input, TerminalKind::YulLetKeyword, ), )?; seq.elem_labeled( EdgeLabel::Names, - self.parse_token_with_trivia::( + self.parse_terminal_with_trivia::( input, TerminalKind::YulIdentifier, ), @@ -6898,7 +6899,7 @@ impl Language { )?; seq.finish() }) - .with_kind(NonTerminalKind::YulVariableDeclarationStatement) + .with_kind(NonterminalKind::YulVariableDeclarationStatement) } #[allow(unused_assignments, unused_parens)] @@ -6908,7 +6909,7 @@ impl Language { seq.elem_labeled(EdgeLabel::Expression, self.yul_expression(input))?; seq.finish() }) - .with_kind(NonTerminalKind::YulVariableDeclarationValue) + .with_kind(NonterminalKind::YulVariableDeclarationValue) } #[allow(unused_assignments, unused_parens)] @@ -6916,36 +6917,36 @@ impl Language { OneOrMoreHelper::run(input, |input| { ChoiceHelper::run(input, |mut choice, input| { let result = self - .parse_token::(input, TerminalKind::Whitespace) + .parse_terminal::(input, TerminalKind::Whitespace) .with_label(EdgeLabel::LeadingTrivia); choice.consider(input, result)?; let result = self - .parse_token::(input, TerminalKind::EndOfLine) + .parse_terminal::(input, TerminalKind::EndOfLine) .with_label(EdgeLabel::LeadingTrivia); choice.consider(input, result)?; let result = self - .parse_token::( + .parse_terminal::( input, TerminalKind::SingleLineComment, ) .with_label(EdgeLabel::LeadingTrivia); choice.consider(input, result)?; let result = self - .parse_token::( + .parse_terminal::( input, TerminalKind::MultiLineComment, ) .with_label(EdgeLabel::LeadingTrivia); choice.consider(input, result)?; let result = self - .parse_token::( + .parse_terminal::( input, TerminalKind::SingleLineNatSpecComment, ) .with_label(EdgeLabel::LeadingTrivia); choice.consider(input, result)?; let result = self - .parse_token::( + .parse_terminal::( input, TerminalKind::MultiLineNatSpecComment, ) @@ -6960,18 +6961,18 @@ impl Language { fn trailing_trivia(&self, input: &mut ParserContext<'_>) -> ParserResult { SequenceHelper::run(|mut seq| { seq.elem(OptionalHelper::transform( - self.parse_token::(input, TerminalKind::Whitespace) + self.parse_terminal::(input, TerminalKind::Whitespace) .with_label(EdgeLabel::TrailingTrivia), ))?; seq.elem(OptionalHelper::transform( - self.parse_token::( + self.parse_terminal::( input, TerminalKind::SingleLineComment, ) .with_label(EdgeLabel::TrailingTrivia), ))?; seq.elem( - self.parse_token::(input, TerminalKind::EndOfLine) + self.parse_terminal::(input, TerminalKind::EndOfLine) .with_label(EdgeLabel::TrailingTrivia), )?; seq.finish() @@ -9139,340 +9140,340 @@ impl Language { ) } - pub fn parse(&self, kind: NonTerminalKind, input: &str) -> ParseOutput { + pub fn parse(&self, kind: NonterminalKind, input: &str) -> ParseOutput { match kind { - 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 => { + 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) } - NonTerminalKind::AssemblyStatement => Self::assembly_statement.parse(self, input), - NonTerminalKind::AssignmentExpression => Self::assignment_expression.parse(self, input), - NonTerminalKind::BitwiseAndExpression => { + 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 => { + 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 => { + 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 => { + 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 => { + 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 => { + 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 => { + 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 => { + 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) } - 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 => { + 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) } - NonTerminalKind::ExperimentalFeature => Self::experimental_feature.parse(self, input), - NonTerminalKind::ExperimentalPragma => Self::experimental_pragma.parse(self, input), - NonTerminalKind::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) } - NonTerminalKind::Expression => Self::expression.parse(self, input), - NonTerminalKind::ExpressionStatement => Self::expression_statement.parse(self, input), - NonTerminalKind::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) } - NonTerminalKind::FallbackFunctionAttributes => { + NonterminalKind::FallbackFunctionAttributes => { Self::fallback_function_attributes.parse(self, input) } - NonTerminalKind::FallbackFunctionDefinition => { + NonterminalKind::FallbackFunctionDefinition => { Self::fallback_function_definition.parse(self, input) } - NonTerminalKind::ForStatement => Self::for_statement.parse(self, input), - NonTerminalKind::ForStatementCondition => { + NonterminalKind::ForStatement => Self::for_statement.parse(self, input), + NonterminalKind::ForStatementCondition => { Self::for_statement_condition.parse(self, input) } - NonTerminalKind::ForStatementInitialization => { + NonterminalKind::ForStatementInitialization => { Self::for_statement_initialization.parse(self, input) } - 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 => { + 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 => { + 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 => { + 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 => { + 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) } - NonTerminalKind::ImportDeconstructionSymbols => { + NonterminalKind::ImportDeconstructionSymbols => { Self::import_deconstruction_symbols.parse(self, input) } - NonTerminalKind::ImportDirective => Self::import_directive.parse(self, input), - NonTerminalKind::IndexAccessEnd => Self::index_access_end.parse(self, input), - NonTerminalKind::IndexAccessExpression => { + 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 => { + 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 => { + 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) } - 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 => { + 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) } - 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 => { + 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) } - NonTerminalKind::OverrideSpecifier => Self::override_specifier.parse(self, input), - NonTerminalKind::Parameter => Self::parameter.parse(self, input), - NonTerminalKind::Parameters => Self::parameters.parse(self, input), - NonTerminalKind::ParametersDeclaration => { + 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 => { + 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) } - 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 => { + 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) } - NonTerminalKind::ReceiveFunctionAttributes => { + NonterminalKind::ReceiveFunctionAttributes => { Self::receive_function_attributes.parse(self, input) } - NonTerminalKind::ReceiveFunctionDefinition => { + NonterminalKind::ReceiveFunctionDefinition => { Self::receive_function_definition.parse(self, input) } - 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 => { + 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 => { + NonterminalKind::StateVariableAttributes => { Self::state_variable_attributes.parse(self, input) } - NonTerminalKind::StateVariableDefinition => { + NonterminalKind::StateVariableDefinition => { Self::state_variable_definition.parse(self, input) } - NonTerminalKind::StateVariableDefinitionValue => { + NonterminalKind::StateVariableDefinitionValue => { Self::state_variable_definition_value.parse(self, input) } - 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 => { + 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) } - NonTerminalKind::TupleDeconstructionElements => { + NonterminalKind::TupleDeconstructionElements => { Self::tuple_deconstruction_elements.parse(self, input) } - NonTerminalKind::TupleDeconstructionStatement => { + NonterminalKind::TupleDeconstructionStatement => { Self::tuple_deconstruction_statement.parse(self, input) } - 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 => { + 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 => { + NonterminalKind::UnicodeStringLiterals => { Self::unicode_string_literals.parse(self, input) } - NonTerminalKind::UnnamedFunctionAttribute => { + NonterminalKind::UnnamedFunctionAttribute => { Self::unnamed_function_attribute.parse(self, input) } - NonTerminalKind::UnnamedFunctionAttributes => { + NonterminalKind::UnnamedFunctionAttributes => { Self::unnamed_function_attributes.parse(self, input) } - NonTerminalKind::UnnamedFunctionDefinition => { + NonterminalKind::UnnamedFunctionDefinition => { Self::unnamed_function_definition.parse(self, input) } - NonTerminalKind::UntypedTupleMember => Self::untyped_tuple_member.parse(self, input), - NonTerminalKind::UserDefinedValueTypeDefinition => { + NonterminalKind::UntypedTupleMember => Self::untyped_tuple_member.parse(self, input), + NonterminalKind::UserDefinedValueTypeDefinition => { Self::user_defined_value_type_definition.parse(self, input) } - 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 => { + 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) } - NonTerminalKind::UsingDeconstructionSymbols => { + NonterminalKind::UsingDeconstructionSymbols => { Self::using_deconstruction_symbols.parse(self, input) } - 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 => { + 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) } - NonTerminalKind::VariableDeclarationType => { + NonterminalKind::VariableDeclarationType => { Self::variable_declaration_type.parse(self, input) } - NonTerminalKind::VariableDeclarationValue => { + NonterminalKind::VariableDeclarationValue => { Self::variable_declaration_value.parse(self, input) } - NonTerminalKind::VersionComparator => Self::version_comparator.parse(self, input), - NonTerminalKind::VersionExpression => Self::version_expression.parse(self, input), - NonTerminalKind::VersionExpressionSet => { + 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 => { + 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 => { + 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 => { + 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 => { + 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 => { + 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) } - NonTerminalKind::YulFunctionDefinition => { + 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 => { + 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) } - 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 => { + 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 => { + 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) } - NonTerminalKind::YulVariableDeclarationValue => { + NonterminalKind::YulVariableDeclarationValue => { Self::yul_variable_declaration_value.parse(self, input) } } @@ -9503,13 +9504,13 @@ impl Lexer for Language { } } - fn next_token( + fn next_terminal( &self, input: &mut ParserContext<'_>, - ) -> Option { + ) -> Option { let save = input.position(); let mut furthest_position = input.position(); - let mut longest_token = None; + let mut longest_terminal = None; macro_rules! longest_match { ($( { $kind:ident = $function:ident } )*) => { @@ -9517,7 +9518,7 @@ impl Lexer for Language { if self.$function(input) && input.position() > furthest_position { furthest_position = input.position(); - longest_token = Some(TerminalKind::$kind); + longest_terminal = Some(TerminalKind::$kind); } input.set_position(save); )* @@ -9673,7 +9674,7 @@ impl Lexer for Language { None => None, } { furthest_position = input.position(); - longest_token = Some(kind); + longest_terminal = Some(kind); } input.set_position(save); @@ -9701,7 +9702,7 @@ 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| [TerminalKind::Identifier].contains(tok)) + longest_terminal.filter(|tok| [TerminalKind::Identifier].contains(tok)) { let kw_scan = match input.next() { Some('a') => match input.next() { @@ -10925,7 +10926,7 @@ impl Lexer for Language { } input.set_position(furthest_position); - return Some(ScannedToken::IdentifierOrKeyword { + return Some(ScannedTerminal::IdentifierOrKeyword { identifier, kw: kw_scan, }); @@ -10969,7 +10970,7 @@ impl Lexer for Language { None => None, } { furthest_position = input.position(); - longest_token = Some(kind); + longest_terminal = Some(kind); } input.set_position(save); @@ -10985,7 +10986,7 @@ 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| [TerminalKind::Identifier].contains(tok)) + longest_terminal.filter(|tok| [TerminalKind::Identifier].contains(tok)) { let kw_scan = match input.next() { Some('a') => { @@ -11031,7 +11032,7 @@ impl Lexer for Language { }; input.set_position(furthest_position); - return Some(ScannedToken::IdentifierOrKeyword { + return Some(ScannedTerminal::IdentifierOrKeyword { identifier, kw: kw_scan, }); @@ -11068,7 +11069,7 @@ impl Lexer for Language { None => None, } { furthest_position = input.position(); - longest_token = Some(kind); + longest_terminal = Some(kind); } input.set_position(save); @@ -11083,7 +11084,7 @@ 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| [TerminalKind::YulIdentifier].contains(tok)) + longest_terminal.filter(|tok| [TerminalKind::YulIdentifier].contains(tok)) { let kw_scan = match input.next() { Some('a') => match input.next() { @@ -13453,7 +13454,7 @@ impl Lexer for Language { } input.set_position(furthest_position); - return Some(ScannedToken::IdentifierOrKeyword { + return Some(ScannedTerminal::IdentifierOrKeyword { identifier, kw: kw_scan, }); @@ -13461,15 +13462,15 @@ impl Lexer for Language { } } - match longest_token { - Some(token) => { + match longest_terminal { + Some(terminal) => { input.set_position(furthest_position); - Some(ScannedToken::Single(token)) + Some(ScannedTerminal::Single(terminal)) } - // Skip a character if possible and if we didn't recognize a token + // Skip a character if possible and if we didn't recognize a terminal None if input.peek().is_some() => { let _ = input.next(); - Some(ScannedToken::Single(TerminalKind::SKIPPED)) + Some(ScannedTerminal::Single(TerminalKind::SKIPPED)) } None => None, } @@ -13508,7 +13509,7 @@ impl Language { )] pub fn parse_napi( &self, - #[napi(ts_arg_type = "kinds.NonTerminalKind")] kind: NonTerminalKind, + #[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 74af1b635f..e3c2878760 100644 --- a/crates/solidity/outputs/cargo/slang_solidity/src/generated/lexer.rs +++ b/crates/solidity/outputs/cargo/slang_solidity/src/generated/lexer.rs @@ -18,7 +18,7 @@ pub enum KeywordScan { } #[derive(Debug, Clone, Copy, PartialEq, Eq)] -pub enum ScannedToken { +pub enum ScannedTerminal { Single(TerminalKind), IdentifierOrKeyword { identifier: TerminalKind, @@ -26,7 +26,7 @@ pub enum ScannedToken { }, } -impl ScannedToken { +impl ScannedTerminal { pub fn accepted_as(self, expected: TerminalKind) -> bool { match self { Self::Single(kind) => kind == expected, @@ -38,10 +38,10 @@ impl ScannedToken { } } - /// Returns the most general token kind that can be accepted for the scanned token. + /// Returns the most general terminal kind that can be accepted for the scanned terminal. /// - /// 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. + /// If the scanned terminal is an identifier, returns the specific keyword kind if the keyword is reserved, + /// otherwise returns the general identifier kind. For other terminals, returns the terminal kind itself. pub fn unambiguous(self) -> TerminalKind { match self { Self::Single(kind) => kind, @@ -58,10 +58,10 @@ impl ScannedToken { pub(crate) trait Lexer { // Generated by the templating engine #[doc(hidden)] - fn next_token( + fn next_terminal( &self, input: &mut ParserContext<'_>, - ) -> Option; + ) -> Option; // NOTE: These are context-insensitive #[doc(hidden)] fn leading_trivia(&self, input: &mut ParserContext<'_>) -> ParserResult; @@ -71,40 +71,40 @@ pub(crate) trait Lexer { /// Returns valid grouping delimiters in the given lexical context. fn delimiters() -> &'static [(TerminalKind, TerminalKind)]; - /// Peeks the next token, including trivia. Does not advance the input. - fn peek_token( + /// Peeks the next terminal, including trivia. Does not advance the input. + fn peek_terminal( &self, input: &mut ParserContext<'_>, - ) -> Option { + ) -> Option { let start = input.position(); - let token = self.next_token::(input); + let terminal = self.next_terminal::(input); input.set_position(start); - token + terminal } - /// Peeks the next significant (i.e. non-trivia) token. Does not advance the input. - fn peek_token_with_trivia( + /// Peeks the next significant (i.e. non-trivia) terminal. Does not advance the input. + fn peek_terminal_with_trivia( &self, input: &mut ParserContext<'_>, - ) -> Option { + ) -> Option { let start = input.position(); let _ = self.leading_trivia(input); - let token = self.next_token::(input); + let terminal = self.next_terminal::(input); input.set_position(start); - token + terminal } - /// Attempts to consume the next expected token. Advances the input only if the token matches. - fn parse_token( + /// Attempts to consume the next expected terminal. Advances the input only if the terminal matches. + fn parse_terminal( &self, input: &mut ParserContext<'_>, kind: TerminalKind, ) -> ParserResult { let start = input.position(); if !self - .next_token::(input) + .next_terminal::(input) .is_some_and(|t| t.accepted_as(kind)) { input.set_position(start); @@ -121,9 +121,9 @@ pub(crate) trait Lexer { ) } - /// Attempts to consume the next significant token including both leading and trailing trivia. - /// Advances the input only if the token matches. - fn parse_token_with_trivia( + /// Attempts to consume the next significant terminal including both leading and trailing trivia. + /// Advances the input only if the terminal matches. + fn parse_terminal_with_trivia( &self, input: &mut ParserContext<'_>, kind: TerminalKind, @@ -139,7 +139,7 @@ pub(crate) trait Lexer { let start = input.position(); if !self - .next_token::(input) + .next_terminal::(input) .is_some_and(|t| t.accepted_as(kind)) { input.set_position(restore); 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 fc0c873252..2a51ee987d 100644 --- a/crates/solidity/outputs/cargo/slang_solidity/src/generated/mod.rs +++ b/crates/solidity/outputs/cargo/slang_solidity/src/generated/mod.rs @@ -30,7 +30,7 @@ mod metaslang_cst { pub enum KindTypes {} impl metaslang_cst::KindTypes for KindTypes { - type NonTerminalKind = crate::kinds::NonTerminalKind; + type NonterminalKind = crate::kinds::NonterminalKind; type TerminalKind = crate::kinds::TerminalKind; type EdgeLabel = crate::kinds::EdgeLabel; } @@ -42,7 +42,7 @@ pub mod cst { use super::metaslang_cst::KindTypes; pub type Node = cst::Node; - pub type NonTerminalNode = cst::NonTerminalNode; + pub type NonterminalNode = cst::NonterminalNode; pub type TerminalNode = cst::TerminalNode; pub type Edge = cst::Edge; } 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 fbb7e68798..7eef078e23 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,24 +8,24 @@ use napi_derive::napi; use crate::napi_interface::cursor::Cursor; use crate::napi_interface::text_index::TextIndex; use crate::napi_interface::{ - NonTerminalKind, RustNode, RustNonTerminalNode, RustTerminalNode, RustTextIndex, TerminalKind, + NonterminalKind, RustNode, RustNonterminalNode, RustTerminalNode, RustTextIndex, TerminalKind, }; #[napi(namespace = "cst", string_enum)] pub enum NodeType { - NonTerminal, + 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 `NonTerminalNode | TerminalNode` 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::NonTerminal(nonterminal) => Either::A(NonTerminalNode(nonterminal)), + RustNode::Nonterminal(nonterminal) => Either::A(NonterminalNode(nonterminal)), RustNode::Terminal(terminal) => Either::B(TerminalNode(terminal)), } } @@ -33,26 +33,26 @@ impl NAPINodeExtensions for RustNode { #[derive(Debug)] #[napi(namespace = "cst")] -pub struct NonTerminalNode(pub(crate) Rc); +pub struct NonterminalNode(pub(crate) Rc); #[derive(Debug)] #[napi(namespace = "cst")] pub struct TerminalNode(pub(crate) Rc); #[napi(namespace = "cst")] -impl NonTerminalNode { +impl NonterminalNode { #[napi( getter, js_name = "type", - ts_return_type = "NodeType.NonTerminal", + ts_return_type = "NodeType.Nonterminal", catch_unwind )] pub fn tipe(&self) -> NodeType { - NodeType::NonTerminal + NodeType::Nonterminal } - #[napi(getter, ts_return_type = "kinds.NonTerminalKind", catch_unwind)] - pub fn kind(&self) -> NonTerminalKind { + #[napi(getter, ts_return_type = "kinds.NonterminalKind", catch_unwind)] + pub fn kind(&self) -> NonterminalKind { self.0.kind } @@ -67,7 +67,7 @@ impl NonTerminalNode { } #[napi(ts_return_type = "Array", catch_unwind)] - pub fn children(&self) -> Vec> { + pub fn children(&self) -> Vec> { self.0 .children .iter() @@ -80,13 +80,13 @@ impl NonTerminalNode { &self, #[napi(ts_arg_type = "text_index.TextIndex")] text_offset: TextIndex, ) -> Cursor { - RustNode::NonTerminal(Rc::clone(&self.0)) + RustNode::Nonterminal(Rc::clone(&self.0)) .cursor_with_offset(text_offset.into()) .into() } + /// Serialize the node to JSON. #[napi(catch_unwind, js_name = "toJSON")] - /// Serialize the token node to JSON. pub fn to_json(&self) -> String { serde_json::to_string(&self.0).unwrap() } @@ -107,7 +107,7 @@ impl NonTerminalNode { skip_typescript, catch_unwind )] - pub fn __children(&self) -> Vec> { + pub fn __children(&self) -> Vec> { Self::children(self) } @@ -159,10 +159,8 @@ impl TerminalNode { self.0.text.clone() } + /// Serialize the node to JSON. #[napi(catch_unwind, js_name = "toJSON")] - /// Serialize the terminal node to JSON. - /// - /// This method is intended for debugging purposes and may not be stable. pub fn to_json(&self) -> String { serde_json::to_string(&self.0).unwrap() } 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 61da4beac9..6d38a68a23 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, NonTerminalNode, TerminalNode}; -use crate::napi_interface::{text_index, EdgeLabel, NonTerminalKind, RustCursor, TerminalKind}; +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,7 +54,7 @@ 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() } @@ -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::NonTerminalNode).collect() + #[napi(ts_return_type = "Array", catch_unwind)] + pub fn ancestors(&self) -> Vec { + self.0.ancestors().map(cst::NonterminalNode).collect() } #[napi(catch_unwind)] @@ -143,7 +143,7 @@ impl Cursor { } #[napi(catch_unwind)] - pub fn go_to_next_token_with_kinds( + pub fn go_to_next_terminal_with_kinds( &mut self, #[napi(ts_arg_type = "Array")] kinds: Vec, ) -> bool { @@ -158,7 +158,7 @@ impl Cursor { #[napi(catch_unwind)] pub fn go_to_next_nonterminal_with_kind( &mut self, - #[napi(ts_arg_type = "kinds.NonTerminalKind")] kind: NonTerminalKind, + #[napi(ts_arg_type = "kinds.NonterminalKind")] kind: NonterminalKind, ) -> bool { self.0.go_to_next_nonterminal_with_kind(kind) } @@ -166,7 +166,7 @@ impl Cursor { #[napi(catch_unwind)] 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_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 ca83ea3074..99ad07fc9f 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,9 +7,9 @@ use std::rc::Rc; use napi::Either; use napi_derive::napi; -use crate::napi_interface::cst::{NAPINodeExtensions, NonTerminalNode, TerminalNode}; +use crate::napi_interface::cst::{NAPINodeExtensions, NonterminalNode, TerminalNode}; use crate::napi_interface::{ - NonTerminalKind, RustEdge, RustNode, RustNonTerminalNode, TerminalKind, + NonterminalKind, RustEdge, RustNode, RustNonterminalNode, TerminalKind, }; // @@ -22,152 +22,152 @@ use crate::napi_interface::{ catch_unwind )] pub fn select_sequence( - #[napi(ts_arg_type = "cst.NonTerminalNode")] node: &NonTerminalNode, -) -> Result>>> { + #[napi(ts_arg_type = "cst.NonterminalNode")] node: &NonterminalNode, +) -> Result>>> { let mut selector = Selector::new(node); let result = match node.kind() { - 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 => { + 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 => { + 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()? } - 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 => { + 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 => { + 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 => { + 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 => { + 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()? } - NonTerminalKind::YulVariableDeclarationValue => { + 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()?, + 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(); } @@ -177,25 +177,25 @@ 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_nonterminal_with_kind(NonTerminalKind::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_terminal_with_kind(TerminalKind::PragmaKeyword))?), - Some(self.select(|node| node.is_nonterminal_with_kind(NonTerminalKind::Pragma))?), + 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_terminal_with_kind(TerminalKind::AbicoderKeyword))?), Some(self.select(|node| node.is_terminal_with_kind(TerminalKind::Identifier))?), @@ -206,83 +206,83 @@ impl Selector { impl Selector { fn experimental_pragma( &mut self, - ) -> Result>>> { + ) -> Result>>> { Ok(vec![ Some( self.select(|node| node.is_terminal_with_kind(TerminalKind::ExperimentalKeyword))?, ), Some(self.select(|node| { - node.is_nonterminal_with_kind(NonTerminalKind::ExperimentalFeature) + 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_terminal_with_kind(TerminalKind::SolidityKeyword))?), Some(self.select(|node| { - node.is_nonterminal_with_kind(NonTerminalKind::VersionExpressionSets) + 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_nonterminal_with_kind(NonTerminalKind::VersionExpression) + 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) + 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_terminal_with_kind(TerminalKind::Caret))?), Some(self.select(|node| { - node.is_nonterminal_with_kind(NonTerminalKind::VersionExpression) + 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_terminal_with_kind(TerminalKind::ImportKeyword))?), - Some(self.select(|node| node.is_nonterminal_with_kind(NonTerminalKind::ImportClause))?), + 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_nonterminal_with_kind(NonTerminalKind::StringLiteral))?, + self.select(|node| node.is_nonterminal_with_kind(NonterminalKind::StringLiteral))?, ), - self.try_select(|node| node.is_nonterminal_with_kind(NonTerminalKind::ImportAlias))?, + 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_terminal_with_kind(TerminalKind::Asterisk))?), - Some(self.select(|node| node.is_nonterminal_with_kind(NonTerminalKind::ImportAlias))?), + 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))?, + self.select(|node| node.is_nonterminal_with_kind(NonterminalKind::StringLiteral))?, ), ]) } @@ -291,16 +291,16 @@ impl Selector { impl Selector { fn import_deconstruction( &mut self, - ) -> Result>>> { + ) -> 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) + 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_nonterminal_with_kind(NonTerminalKind::StringLiteral))?, + self.select(|node| node.is_nonterminal_with_kind(NonterminalKind::StringLiteral))?, ), ]) } @@ -309,16 +309,16 @@ impl Selector { impl Selector { fn import_deconstruction_symbol( &mut self, - ) -> Result>>> { + ) -> Result>>> { Ok(vec![ Some(self.select(|node| node.is_terminal_with_kind(TerminalKind::Identifier))?), - self.try_select(|node| node.is_nonterminal_with_kind(NonTerminalKind::ImportAlias))?, + 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_terminal_with_kind(TerminalKind::AsKeyword))?), Some(self.select(|node| node.is_terminal_with_kind(TerminalKind::Identifier))?), @@ -327,12 +327,12 @@ impl Selector { } impl Selector { - fn using_directive(&mut self) -> Result>>> { + fn using_directive(&mut self) -> Result>>> { Ok(vec![ 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_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))?), + 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))?), ]) @@ -342,11 +342,11 @@ impl Selector { impl Selector { fn using_deconstruction( &mut self, - ) -> Result>>> { + ) -> Result>>> { Ok(vec![ Some(self.select(|node| node.is_terminal_with_kind(TerminalKind::OpenBrace))?), Some(self.select(|node| { - node.is_nonterminal_with_kind(NonTerminalKind::UsingDeconstructionSymbols) + node.is_nonterminal_with_kind(NonterminalKind::UsingDeconstructionSymbols) })?), Some(self.select(|node| node.is_terminal_with_kind(TerminalKind::CloseBrace))?), ]) @@ -356,22 +356,22 @@ impl Selector { impl Selector { fn using_deconstruction_symbol( &mut self, - ) -> Result>>> { + ) -> Result>>> { Ok(vec![ Some( - self.select(|node| node.is_nonterminal_with_kind(NonTerminalKind::IdentifierPath))?, + self.select(|node| node.is_nonterminal_with_kind(NonterminalKind::IdentifierPath))?, ), - self.try_select(|node| node.is_nonterminal_with_kind(NonTerminalKind::UsingAlias))?, + 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_terminal_with_kind(TerminalKind::AsKeyword))?), Some( - self.select(|node| node.is_nonterminal_with_kind(NonTerminalKind::UsingOperator))?, + self.select(|node| node.is_nonterminal_with_kind(NonterminalKind::UsingOperator))?, ), ]) } @@ -380,18 +380,18 @@ impl Selector { impl Selector { fn contract_definition( &mut self, - ) -> Result>>> { + ) -> 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) + 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) + node.is_nonterminal_with_kind(NonterminalKind::ContractMembers) })?, ), Some(self.select(|node| node.is_terminal_with_kind(TerminalKind::CloseBrace))?), @@ -402,12 +402,12 @@ impl Selector { impl Selector { fn inheritance_specifier( &mut self, - ) -> Result>>> { + ) -> Result>>> { Ok(vec![ Some(self.select(|node| node.is_terminal_with_kind(TerminalKind::IsKeyword))?), Some( self.select(|node| { - node.is_nonterminal_with_kind(NonTerminalKind::InheritanceTypes) + node.is_nonterminal_with_kind(NonterminalKind::InheritanceTypes) })?, ), ]) @@ -415,13 +415,13 @@ impl Selector { } impl Selector { - fn inheritance_type(&mut self) -> Result>>> { + fn inheritance_type(&mut self) -> Result>>> { Ok(vec![ Some( - self.select(|node| node.is_nonterminal_with_kind(NonTerminalKind::IdentifierPath))?, + self.select(|node| node.is_nonterminal_with_kind(NonterminalKind::IdentifierPath))?, ), self.try_select(|node| { - node.is_nonterminal_with_kind(NonTerminalKind::ArgumentsDeclaration) + node.is_nonterminal_with_kind(NonterminalKind::ArgumentsDeclaration) })?, ]) } @@ -430,17 +430,17 @@ impl Selector { impl Selector { fn interface_definition( &mut self, - ) -> Result>>> { + ) -> 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) + 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) + node.is_nonterminal_with_kind(NonterminalKind::InterfaceMembers) })?, ), Some(self.select(|node| node.is_terminal_with_kind(TerminalKind::CloseBrace))?), @@ -449,13 +449,13 @@ impl Selector { } impl Selector { - fn library_definition(&mut self) -> Result>>> { + fn library_definition(&mut self) -> Result>>> { Ok(vec![ 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))?, + self.select(|node| node.is_nonterminal_with_kind(NonterminalKind::LibraryMembers))?, ), Some(self.select(|node| node.is_terminal_with_kind(TerminalKind::CloseBrace))?), ]) @@ -463,13 +463,13 @@ impl Selector { } impl Selector { - fn struct_definition(&mut self) -> Result>>> { + fn struct_definition(&mut self) -> Result>>> { Ok(vec![ 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))?, + self.select(|node| node.is_nonterminal_with_kind(NonterminalKind::StructMembers))?, ), Some(self.select(|node| node.is_terminal_with_kind(TerminalKind::CloseBrace))?), ]) @@ -477,9 +477,9 @@ impl Selector { } impl Selector { - fn struct_member(&mut self) -> Result>>> { + fn struct_member(&mut self) -> Result>>> { Ok(vec![ - Some(self.select(|node| node.is_nonterminal_with_kind(NonTerminalKind::TypeName))?), + 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))?), ]) @@ -487,12 +487,12 @@ impl Selector { } impl Selector { - fn enum_definition(&mut self) -> Result>>> { + fn enum_definition(&mut self) -> Result>>> { Ok(vec![ 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_nonterminal_with_kind(NonterminalKind::EnumMembers))?), Some(self.select(|node| node.is_terminal_with_kind(TerminalKind::CloseBrace))?), ]) } @@ -501,13 +501,13 @@ impl Selector { impl Selector { fn constant_definition( &mut self, - ) -> Result>>> { + ) -> Result>>> { Ok(vec![ - Some(self.select(|node| node.is_nonterminal_with_kind(NonTerminalKind::TypeName))?), + 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_nonterminal_with_kind(NonterminalKind::Expression))?), Some(self.select(|node| node.is_terminal_with_kind(TerminalKind::Semicolon))?), ]) } @@ -516,15 +516,15 @@ impl Selector { impl Selector { fn state_variable_definition( &mut self, - ) -> Result>>> { + ) -> Result>>> { Ok(vec![ - Some(self.select(|node| node.is_nonterminal_with_kind(NonTerminalKind::TypeName))?), + Some(self.select(|node| node.is_nonterminal_with_kind(NonterminalKind::TypeName))?), Some(self.select(|node| { - node.is_nonterminal_with_kind(NonTerminalKind::StateVariableAttributes) + 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) + node.is_nonterminal_with_kind(NonterminalKind::StateVariableDefinitionValue) })?, Some(self.select(|node| node.is_terminal_with_kind(TerminalKind::Semicolon))?), ]) @@ -534,10 +534,10 @@ impl Selector { impl Selector { fn state_variable_definition_value( &mut self, - ) -> Result>>> { + ) -> Result>>> { Ok(vec![ 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_nonterminal_with_kind(NonterminalKind::Expression))?), ]) } } @@ -545,20 +545,20 @@ impl Selector { impl Selector { fn function_definition( &mut self, - ) -> Result>>> { + ) -> Result>>> { Ok(vec![ 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::FunctionName))?), Some(self.select(|node| { - node.is_nonterminal_with_kind(NonTerminalKind::ParametersDeclaration) + node.is_nonterminal_with_kind(NonterminalKind::ParametersDeclaration) })?), Some(self.select(|node| { - node.is_nonterminal_with_kind(NonTerminalKind::FunctionAttributes) + node.is_nonterminal_with_kind(NonterminalKind::FunctionAttributes) })?), self.try_select(|node| { - node.is_nonterminal_with_kind(NonTerminalKind::ReturnsDeclaration) + node.is_nonterminal_with_kind(NonterminalKind::ReturnsDeclaration) })?, - Some(self.select(|node| node.is_nonterminal_with_kind(NonTerminalKind::FunctionBody))?), + Some(self.select(|node| node.is_nonterminal_with_kind(NonterminalKind::FunctionBody))?), ]) } } @@ -566,21 +566,21 @@ impl Selector { impl Selector { fn parameters_declaration( &mut self, - ) -> Result>>> { + ) -> Result>>> { Ok(vec![ 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_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_nonterminal_with_kind(NonTerminalKind::TypeName))?), + Some(self.select(|node| node.is_nonterminal_with_kind(NonterminalKind::TypeName))?), self.try_select(|node| { - node.is_nonterminal_with_kind(NonTerminalKind::StorageLocation) + node.is_nonterminal_with_kind(NonterminalKind::StorageLocation) })?, self.try_select(|node| node.is_terminal_with_kind(TerminalKind::Identifier))?, ]) @@ -588,11 +588,11 @@ impl Selector { } impl Selector { - fn override_specifier(&mut self) -> Result>>> { + fn override_specifier(&mut self) -> Result>>> { Ok(vec![ Some(self.select(|node| node.is_terminal_with_kind(TerminalKind::OverrideKeyword))?), self.try_select(|node| { - node.is_nonterminal_with_kind(NonTerminalKind::OverridePathsDeclaration) + node.is_nonterminal_with_kind(NonterminalKind::OverridePathsDeclaration) })?, ]) } @@ -601,11 +601,11 @@ impl Selector { impl Selector { fn override_paths_declaration( &mut self, - ) -> Result>>> { + ) -> Result>>> { Ok(vec![ Some(self.select(|node| node.is_terminal_with_kind(TerminalKind::OpenParen))?), Some( - self.select(|node| node.is_nonterminal_with_kind(NonTerminalKind::OverridePaths))?, + self.select(|node| node.is_nonterminal_with_kind(NonterminalKind::OverridePaths))?, ), Some(self.select(|node| node.is_terminal_with_kind(TerminalKind::CloseParen))?), ]) @@ -615,11 +615,11 @@ impl Selector { impl Selector { fn returns_declaration( &mut self, - ) -> Result>>> { + ) -> Result>>> { Ok(vec![ Some(self.select(|node| node.is_terminal_with_kind(TerminalKind::ReturnsKeyword))?), Some(self.select(|node| { - node.is_nonterminal_with_kind(NonTerminalKind::ParametersDeclaration) + node.is_nonterminal_with_kind(NonterminalKind::ParametersDeclaration) })?), ]) } @@ -628,16 +628,16 @@ impl Selector { impl Selector { fn constructor_definition( &mut self, - ) -> Result>>> { + ) -> Result>>> { Ok(vec![ Some(self.select(|node| node.is_terminal_with_kind(TerminalKind::ConstructorKeyword))?), Some(self.select(|node| { - node.is_nonterminal_with_kind(NonTerminalKind::ParametersDeclaration) + node.is_nonterminal_with_kind(NonterminalKind::ParametersDeclaration) })?), Some(self.select(|node| { - node.is_nonterminal_with_kind(NonTerminalKind::ConstructorAttributes) + node.is_nonterminal_with_kind(NonterminalKind::ConstructorAttributes) })?), - Some(self.select(|node| node.is_nonterminal_with_kind(NonTerminalKind::Block))?), + Some(self.select(|node| node.is_nonterminal_with_kind(NonterminalKind::Block))?), ]) } } @@ -645,16 +645,16 @@ impl Selector { impl Selector { fn unnamed_function_definition( &mut self, - ) -> Result>>> { + ) -> Result>>> { Ok(vec![ Some(self.select(|node| node.is_terminal_with_kind(TerminalKind::FunctionKeyword))?), Some(self.select(|node| { - node.is_nonterminal_with_kind(NonTerminalKind::ParametersDeclaration) + node.is_nonterminal_with_kind(NonterminalKind::ParametersDeclaration) })?), Some(self.select(|node| { - node.is_nonterminal_with_kind(NonTerminalKind::UnnamedFunctionAttributes) + node.is_nonterminal_with_kind(NonterminalKind::UnnamedFunctionAttributes) })?), - Some(self.select(|node| node.is_nonterminal_with_kind(NonTerminalKind::FunctionBody))?), + Some(self.select(|node| node.is_nonterminal_with_kind(NonterminalKind::FunctionBody))?), ]) } } @@ -662,19 +662,19 @@ impl Selector { impl Selector { fn fallback_function_definition( &mut self, - ) -> Result>>> { + ) -> Result>>> { Ok(vec![ Some(self.select(|node| node.is_terminal_with_kind(TerminalKind::FallbackKeyword))?), Some(self.select(|node| { - node.is_nonterminal_with_kind(NonTerminalKind::ParametersDeclaration) + node.is_nonterminal_with_kind(NonterminalKind::ParametersDeclaration) })?), Some(self.select(|node| { - node.is_nonterminal_with_kind(NonTerminalKind::FallbackFunctionAttributes) + node.is_nonterminal_with_kind(NonterminalKind::FallbackFunctionAttributes) })?), self.try_select(|node| { - node.is_nonterminal_with_kind(NonTerminalKind::ReturnsDeclaration) + node.is_nonterminal_with_kind(NonterminalKind::ReturnsDeclaration) })?, - Some(self.select(|node| node.is_nonterminal_with_kind(NonTerminalKind::FunctionBody))?), + Some(self.select(|node| node.is_nonterminal_with_kind(NonterminalKind::FunctionBody))?), ]) } } @@ -682,16 +682,16 @@ impl Selector { impl Selector { fn receive_function_definition( &mut self, - ) -> Result>>> { + ) -> Result>>> { Ok(vec![ Some(self.select(|node| node.is_terminal_with_kind(TerminalKind::ReceiveKeyword))?), Some(self.select(|node| { - node.is_nonterminal_with_kind(NonTerminalKind::ParametersDeclaration) + node.is_nonterminal_with_kind(NonterminalKind::ParametersDeclaration) })?), Some(self.select(|node| { - node.is_nonterminal_with_kind(NonTerminalKind::ReceiveFunctionAttributes) + node.is_nonterminal_with_kind(NonterminalKind::ReceiveFunctionAttributes) })?), - Some(self.select(|node| node.is_nonterminal_with_kind(NonTerminalKind::FunctionBody))?), + Some(self.select(|node| node.is_nonterminal_with_kind(NonterminalKind::FunctionBody))?), ]) } } @@ -699,17 +699,17 @@ impl Selector { impl Selector { fn modifier_definition( &mut self, - ) -> Result>>> { + ) -> Result>>> { Ok(vec![ 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) + node.is_nonterminal_with_kind(NonterminalKind::ParametersDeclaration) })?, Some(self.select(|node| { - node.is_nonterminal_with_kind(NonTerminalKind::ModifierAttributes) + node.is_nonterminal_with_kind(NonterminalKind::ModifierAttributes) })?), - Some(self.select(|node| node.is_nonterminal_with_kind(NonTerminalKind::FunctionBody))?), + Some(self.select(|node| node.is_nonterminal_with_kind(NonterminalKind::FunctionBody))?), ]) } } @@ -717,25 +717,25 @@ impl Selector { impl Selector { fn modifier_invocation( &mut self, - ) -> Result>>> { + ) -> Result>>> { Ok(vec![ Some( - self.select(|node| node.is_nonterminal_with_kind(NonTerminalKind::IdentifierPath))?, + self.select(|node| node.is_nonterminal_with_kind(NonterminalKind::IdentifierPath))?, ), self.try_select(|node| { - node.is_nonterminal_with_kind(NonTerminalKind::ArgumentsDeclaration) + 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_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) + 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))?), @@ -746,12 +746,12 @@ impl Selector { impl Selector { fn event_parameters_declaration( &mut self, - ) -> Result>>> { + ) -> Result>>> { Ok(vec![ Some(self.select(|node| node.is_terminal_with_kind(TerminalKind::OpenParen))?), Some( self.select(|node| { - node.is_nonterminal_with_kind(NonTerminalKind::EventParameters) + node.is_nonterminal_with_kind(NonterminalKind::EventParameters) })?, ), Some(self.select(|node| node.is_terminal_with_kind(TerminalKind::CloseParen))?), @@ -760,9 +760,9 @@ impl Selector { } impl Selector { - fn event_parameter(&mut self) -> Result>>> { + fn event_parameter(&mut self) -> Result>>> { Ok(vec![ - Some(self.select(|node| node.is_nonterminal_with_kind(NonTerminalKind::TypeName))?), + 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))?, ]) @@ -772,13 +772,13 @@ impl Selector { impl Selector { fn user_defined_value_type_definition( &mut self, - ) -> Result>>> { + ) -> Result>>> { Ok(vec![ 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))?, + self.select(|node| node.is_nonterminal_with_kind(NonterminalKind::ElementaryType))?, ), Some(self.select(|node| node.is_terminal_with_kind(TerminalKind::Semicolon))?), ]) @@ -786,12 +786,12 @@ impl Selector { } impl Selector { - fn error_definition(&mut self) -> Result>>> { + fn error_definition(&mut self) -> Result>>> { Ok(vec![ 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) + node.is_nonterminal_with_kind(NonterminalKind::ErrorParametersDeclaration) })?), Some(self.select(|node| node.is_terminal_with_kind(TerminalKind::Semicolon))?), ]) @@ -801,12 +801,12 @@ impl Selector { impl Selector { fn error_parameters_declaration( &mut self, - ) -> Result>>> { + ) -> Result>>> { Ok(vec![ Some(self.select(|node| node.is_terminal_with_kind(TerminalKind::OpenParen))?), Some( self.select(|node| { - node.is_nonterminal_with_kind(NonTerminalKind::ErrorParameters) + node.is_nonterminal_with_kind(NonterminalKind::ErrorParameters) })?, ), Some(self.select(|node| node.is_terminal_with_kind(TerminalKind::CloseParen))?), @@ -815,60 +815,60 @@ impl Selector { } impl Selector { - fn error_parameter(&mut self) -> Result>>> { + fn error_parameter(&mut self) -> Result>>> { Ok(vec![ - Some(self.select(|node| node.is_nonterminal_with_kind(NonTerminalKind::TypeName))?), + 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_nonterminal_with_kind(NonTerminalKind::TypeName))?), + 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))?, + 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_terminal_with_kind(TerminalKind::FunctionKeyword))?), Some(self.select(|node| { - node.is_nonterminal_with_kind(NonTerminalKind::ParametersDeclaration) + node.is_nonterminal_with_kind(NonterminalKind::ParametersDeclaration) })?), Some(self.select(|node| { - node.is_nonterminal_with_kind(NonTerminalKind::FunctionTypeAttributes) + node.is_nonterminal_with_kind(NonterminalKind::FunctionTypeAttributes) })?), self.try_select(|node| { - node.is_nonterminal_with_kind(NonTerminalKind::ReturnsDeclaration) + 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_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_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_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_nonterminal_with_kind(NonTerminalKind::MappingKeyType))?, + self.select(|node| node.is_nonterminal_with_kind(NonterminalKind::MappingKeyType))?, ), self.try_select(|node| node.is_terminal_with_kind(TerminalKind::Identifier))?, ]) @@ -876,16 +876,16 @@ impl Selector { } impl Selector { - fn mapping_value(&mut self) -> Result>>> { + fn mapping_value(&mut self) -> Result>>> { Ok(vec![ - Some(self.select(|node| node.is_nonterminal_with_kind(NonTerminalKind::TypeName))?), + 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_terminal_with_kind(TerminalKind::AddressKeyword))?), self.try_select(|node| node.is_terminal_with_kind(TerminalKind::PayableKeyword))?, @@ -894,20 +894,20 @@ impl Selector { } impl Selector { - fn block(&mut self) -> Result>>> { + fn block(&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::Statements))?), + 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_terminal_with_kind(TerminalKind::UncheckedKeyword))?), - Some(self.select(|node| node.is_nonterminal_with_kind(NonTerminalKind::Block))?), + Some(self.select(|node| node.is_nonterminal_with_kind(NonterminalKind::Block))?), ]) } } @@ -915,23 +915,23 @@ impl Selector { impl Selector { fn expression_statement( &mut self, - ) -> Result>>> { + ) -> Result>>> { Ok(vec![ - Some(self.select(|node| node.is_nonterminal_with_kind(NonTerminalKind::Expression))?), + 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_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::StringLiteral))?, self.try_select(|node| { - node.is_nonterminal_with_kind(NonTerminalKind::AssemblyFlagsDeclaration) + node.is_nonterminal_with_kind(NonterminalKind::AssemblyFlagsDeclaration) })?, - Some(self.select(|node| node.is_nonterminal_with_kind(NonTerminalKind::YulBlock))?), + Some(self.select(|node| node.is_nonterminal_with_kind(NonterminalKind::YulBlock))?), ]) } } @@ -939,11 +939,11 @@ impl Selector { impl Selector { fn assembly_flags_declaration( &mut self, - ) -> Result>>> { + ) -> Result>>> { Ok(vec![ Some(self.select(|node| node.is_terminal_with_kind(TerminalKind::OpenParen))?), Some( - self.select(|node| node.is_nonterminal_with_kind(NonTerminalKind::AssemblyFlags))?, + self.select(|node| node.is_nonterminal_with_kind(NonterminalKind::AssemblyFlags))?, ), Some(self.select(|node| node.is_terminal_with_kind(TerminalKind::CloseParen))?), ]) @@ -953,16 +953,16 @@ impl Selector { impl Selector { fn tuple_deconstruction_statement( &mut self, - ) -> Result>>> { + ) -> Result>>> { Ok(vec![ 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) + 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_nonterminal_with_kind(NonterminalKind::Expression))?), Some(self.select(|node| node.is_terminal_with_kind(TerminalKind::Semicolon))?), ]) } @@ -971,19 +971,19 @@ impl Selector { impl Selector { fn tuple_deconstruction_element( &mut self, - ) -> Result>>> { + ) -> Result>>> { Ok(vec![self.try_select(|node| { - node.is_nonterminal_with_kind(NonTerminalKind::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_nonterminal_with_kind(NonTerminalKind::TypeName))?), + Some(self.select(|node| node.is_nonterminal_with_kind(NonterminalKind::TypeName))?), self.try_select(|node| { - node.is_nonterminal_with_kind(NonTerminalKind::StorageLocation) + node.is_nonterminal_with_kind(NonterminalKind::StorageLocation) })?, Some(self.select(|node| node.is_terminal_with_kind(TerminalKind::Identifier))?), ]) @@ -993,10 +993,10 @@ impl Selector { impl Selector { fn untyped_tuple_member( &mut self, - ) -> Result>>> { + ) -> Result>>> { Ok(vec![ self.try_select(|node| { - node.is_nonterminal_with_kind(NonTerminalKind::StorageLocation) + node.is_nonterminal_with_kind(NonterminalKind::StorageLocation) })?, Some(self.select(|node| node.is_terminal_with_kind(TerminalKind::Identifier))?), ]) @@ -1006,17 +1006,17 @@ impl Selector { impl Selector { fn variable_declaration_statement( &mut self, - ) -> Result>>> { + ) -> Result>>> { Ok(vec![ Some(self.select(|node| { - node.is_nonterminal_with_kind(NonTerminalKind::VariableDeclarationType) + node.is_nonterminal_with_kind(NonterminalKind::VariableDeclarationType) })?), self.try_select(|node| { - node.is_nonterminal_with_kind(NonTerminalKind::StorageLocation) + 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) + node.is_nonterminal_with_kind(NonterminalKind::VariableDeclarationValue) })?, Some(self.select(|node| node.is_terminal_with_kind(TerminalKind::Semicolon))?), ]) @@ -1026,74 +1026,74 @@ impl Selector { impl Selector { fn variable_declaration_value( &mut self, - ) -> Result>>> { + ) -> Result>>> { Ok(vec![ 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_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_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_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))?, + 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_terminal_with_kind(TerminalKind::ElseKeyword))?), - Some(self.select(|node| node.is_nonterminal_with_kind(NonTerminalKind::Statement))?), + 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_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) + node.is_nonterminal_with_kind(NonterminalKind::ForStatementInitialization) })?), Some(self.select(|node| { - node.is_nonterminal_with_kind(NonTerminalKind::ForStatementCondition) + node.is_nonterminal_with_kind(NonterminalKind::ForStatementCondition) })?), - self.try_select(|node| node.is_nonterminal_with_kind(NonTerminalKind::Expression))?, + 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))?), + 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_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_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))?), + 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_terminal_with_kind(TerminalKind::DoKeyword))?), - Some(self.select(|node| node.is_nonterminal_with_kind(NonTerminalKind::Statement))?), + 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_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))?), ]) @@ -1101,7 +1101,7 @@ impl Selector { } impl Selector { - fn continue_statement(&mut self) -> Result>>> { + fn continue_statement(&mut self) -> Result>>> { Ok(vec![ Some(self.select(|node| node.is_terminal_with_kind(TerminalKind::ContinueKeyword))?), Some(self.select(|node| node.is_terminal_with_kind(TerminalKind::Semicolon))?), @@ -1110,7 +1110,7 @@ impl Selector { } impl Selector { - fn break_statement(&mut self) -> Result>>> { + fn break_statement(&mut self) -> Result>>> { Ok(vec![ Some(self.select(|node| node.is_terminal_with_kind(TerminalKind::BreakKeyword))?), Some(self.select(|node| node.is_terminal_with_kind(TerminalKind::Semicolon))?), @@ -1119,24 +1119,24 @@ impl Selector { } impl Selector { - fn return_statement(&mut self) -> Result>>> { + fn return_statement(&mut self) -> Result>>> { Ok(vec![ Some(self.select(|node| node.is_terminal_with_kind(TerminalKind::ReturnKeyword))?), - self.try_select(|node| node.is_nonterminal_with_kind(NonTerminalKind::Expression))?, + 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_terminal_with_kind(TerminalKind::EmitKeyword))?), Some( - self.select(|node| node.is_nonterminal_with_kind(NonTerminalKind::IdentifierPath))?, + self.select(|node| node.is_nonterminal_with_kind(NonterminalKind::IdentifierPath))?, ), Some(self.select(|node| { - node.is_nonterminal_with_kind(NonTerminalKind::ArgumentsDeclaration) + node.is_nonterminal_with_kind(NonterminalKind::ArgumentsDeclaration) })?), Some(self.select(|node| node.is_terminal_with_kind(TerminalKind::Semicolon))?), ]) @@ -1144,49 +1144,49 @@ impl Selector { } impl Selector { - fn try_statement(&mut self) -> Result>>> { + fn try_statement(&mut self) -> Result>>> { Ok(vec![ Some(self.select(|node| node.is_terminal_with_kind(TerminalKind::TryKeyword))?), - Some(self.select(|node| node.is_nonterminal_with_kind(NonTerminalKind::Expression))?), + Some(self.select(|node| node.is_nonterminal_with_kind(NonterminalKind::Expression))?), self.try_select(|node| { - node.is_nonterminal_with_kind(NonTerminalKind::ReturnsDeclaration) + 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))?), + 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_terminal_with_kind(TerminalKind::CatchKeyword))?), self.try_select(|node| { - node.is_nonterminal_with_kind(NonTerminalKind::CatchClauseError) + node.is_nonterminal_with_kind(NonterminalKind::CatchClauseError) })?, - Some(self.select(|node| node.is_nonterminal_with_kind(NonTerminalKind::Block))?), + 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_terminal_with_kind(TerminalKind::Identifier))?, Some(self.select(|node| { - node.is_nonterminal_with_kind(NonTerminalKind::ParametersDeclaration) + 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_terminal_with_kind(TerminalKind::RevertKeyword))?), - self.try_select(|node| node.is_nonterminal_with_kind(NonTerminalKind::IdentifierPath))?, + self.try_select(|node| node.is_nonterminal_with_kind(NonterminalKind::IdentifierPath))?, Some(self.select(|node| { - node.is_nonterminal_with_kind(NonTerminalKind::ArgumentsDeclaration) + node.is_nonterminal_with_kind(NonterminalKind::ArgumentsDeclaration) })?), Some(self.select(|node| node.is_terminal_with_kind(TerminalKind::Semicolon))?), ]) @@ -1194,7 +1194,7 @@ impl Selector { } impl Selector { - fn throw_statement(&mut self) -> Result>>> { + fn throw_statement(&mut self) -> Result>>> { Ok(vec![ Some(self.select(|node| node.is_terminal_with_kind(TerminalKind::ThrowKeyword))?), Some(self.select(|node| node.is_terminal_with_kind(TerminalKind::Semicolon))?), @@ -1205,11 +1205,11 @@ impl Selector { impl Selector { fn assignment_expression( &mut self, - ) -> Result>>> { + ) -> Result>>> { Ok(vec![ - Some(self.select(|node| node.is_nonterminal_with_kind(NonTerminalKind::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))?), + Some(self.select(|node| node.is_nonterminal_with_kind(NonterminalKind::Expression))?), ]) } } @@ -1217,33 +1217,33 @@ impl Selector { impl Selector { fn conditional_expression( &mut self, - ) -> Result>>> { + ) -> Result>>> { Ok(vec![ - Some(self.select(|node| node.is_nonterminal_with_kind(NonTerminalKind::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_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))?), + 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_nonterminal_with_kind(NonTerminalKind::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))?), + 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_nonterminal_with_kind(NonTerminalKind::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))?), + Some(self.select(|node| node.is_nonterminal_with_kind(NonterminalKind::Expression))?), ]) } } @@ -1251,11 +1251,11 @@ impl Selector { impl Selector { fn equality_expression( &mut self, - ) -> Result>>> { + ) -> Result>>> { Ok(vec![ - Some(self.select(|node| node.is_nonterminal_with_kind(NonTerminalKind::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))?), + Some(self.select(|node| node.is_nonterminal_with_kind(NonterminalKind::Expression))?), ]) } } @@ -1263,11 +1263,11 @@ impl Selector { impl Selector { fn comparison_expression( &mut self, - ) -> Result>>> { + ) -> Result>>> { Ok(vec![ - Some(self.select(|node| node.is_nonterminal_with_kind(NonTerminalKind::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))?), + Some(self.select(|node| node.is_nonterminal_with_kind(NonterminalKind::Expression))?), ]) } } @@ -1275,11 +1275,11 @@ impl Selector { impl Selector { fn bitwise_or_expression( &mut self, - ) -> Result>>> { + ) -> Result>>> { Ok(vec![ - Some(self.select(|node| node.is_nonterminal_with_kind(NonTerminalKind::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))?), + Some(self.select(|node| node.is_nonterminal_with_kind(NonterminalKind::Expression))?), ]) } } @@ -1287,11 +1287,11 @@ impl Selector { impl Selector { fn bitwise_xor_expression( &mut self, - ) -> Result>>> { + ) -> Result>>> { Ok(vec![ - Some(self.select(|node| node.is_nonterminal_with_kind(NonTerminalKind::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))?), + Some(self.select(|node| node.is_nonterminal_with_kind(NonterminalKind::Expression))?), ]) } } @@ -1299,21 +1299,21 @@ impl Selector { impl Selector { fn bitwise_and_expression( &mut self, - ) -> Result>>> { + ) -> Result>>> { Ok(vec![ - Some(self.select(|node| node.is_nonterminal_with_kind(NonTerminalKind::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))?), + 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_nonterminal_with_kind(NonTerminalKind::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))?), + Some(self.select(|node| node.is_nonterminal_with_kind(NonterminalKind::Expression))?), ]) } } @@ -1321,11 +1321,11 @@ impl Selector { impl Selector { fn additive_expression( &mut self, - ) -> Result>>> { + ) -> Result>>> { Ok(vec![ - Some(self.select(|node| node.is_nonterminal_with_kind(NonTerminalKind::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))?), + Some(self.select(|node| node.is_nonterminal_with_kind(NonterminalKind::Expression))?), ]) } } @@ -1333,11 +1333,11 @@ impl Selector { impl Selector { fn multiplicative_expression( &mut self, - ) -> Result>>> { + ) -> Result>>> { Ok(vec![ - Some(self.select(|node| node.is_nonterminal_with_kind(NonTerminalKind::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))?), + Some(self.select(|node| node.is_nonterminal_with_kind(NonterminalKind::Expression))?), ]) } } @@ -1345,29 +1345,29 @@ impl Selector { impl Selector { fn exponentiation_expression( &mut self, - ) -> Result>>> { + ) -> Result>>> { Ok(vec![ - Some(self.select(|node| node.is_nonterminal_with_kind(NonTerminalKind::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))?), + 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_nonterminal_with_kind(NonTerminalKind::Expression))?), + 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_terminal_with_kind(TerminalKind::PlusPlus))?), - Some(self.select(|node| node.is_nonterminal_with_kind(NonTerminalKind::Expression))?), + Some(self.select(|node| node.is_nonterminal_with_kind(NonterminalKind::Expression))?), ]) } } @@ -1375,11 +1375,11 @@ impl Selector { impl Selector { fn function_call_expression( &mut self, - ) -> Result>>> { + ) -> Result>>> { Ok(vec![ - Some(self.select(|node| node.is_nonterminal_with_kind(NonTerminalKind::Expression))?), + Some(self.select(|node| node.is_nonterminal_with_kind(NonterminalKind::Expression))?), Some(self.select(|node| { - node.is_nonterminal_with_kind(NonTerminalKind::ArgumentsDeclaration) + node.is_nonterminal_with_kind(NonterminalKind::ArgumentsDeclaration) })?), ]) } @@ -1388,11 +1388,11 @@ impl Selector { impl Selector { fn call_options_expression( &mut self, - ) -> Result>>> { + ) -> Result>>> { Ok(vec![ - Some(self.select(|node| node.is_nonterminal_with_kind(NonTerminalKind::Expression))?), + 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_nonterminal_with_kind(NonterminalKind::CallOptions))?), Some(self.select(|node| node.is_terminal_with_kind(TerminalKind::CloseBrace))?), ]) } @@ -1401,11 +1401,11 @@ impl Selector { impl Selector { fn member_access_expression( &mut self, - ) -> Result>>> { + ) -> Result>>> { Ok(vec![ - Some(self.select(|node| node.is_nonterminal_with_kind(NonTerminalKind::Expression))?), + 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))?), + Some(self.select(|node| node.is_nonterminal_with_kind(NonterminalKind::MemberAccess))?), ]) } } @@ -1413,22 +1413,22 @@ impl Selector { impl Selector { fn index_access_expression( &mut self, - ) -> Result>>> { + ) -> Result>>> { Ok(vec![ - Some(self.select(|node| node.is_nonterminal_with_kind(NonTerminalKind::Expression))?), + 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))?, + 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_terminal_with_kind(TerminalKind::Colon))?), - self.try_select(|node| node.is_nonterminal_with_kind(NonTerminalKind::Expression))?, + self.try_select(|node| node.is_nonterminal_with_kind(NonterminalKind::Expression))?, ]) } } @@ -1436,11 +1436,11 @@ impl Selector { impl Selector { fn positional_arguments_declaration( &mut self, - ) -> Result>>> { + ) -> Result>>> { Ok(vec![ Some(self.select(|node| node.is_terminal_with_kind(TerminalKind::OpenParen))?), Some(self.select(|node| { - node.is_nonterminal_with_kind(NonTerminalKind::PositionalArguments) + node.is_nonterminal_with_kind(NonterminalKind::PositionalArguments) })?), Some(self.select(|node| node.is_terminal_with_kind(TerminalKind::CloseParen))?), ]) @@ -1450,11 +1450,11 @@ impl Selector { impl Selector { fn named_arguments_declaration( &mut self, - ) -> Result>>> { + ) -> Result>>> { Ok(vec![ Some(self.select(|node| node.is_terminal_with_kind(TerminalKind::OpenParen))?), self.try_select(|node| { - node.is_nonterminal_with_kind(NonTerminalKind::NamedArgumentGroup) + node.is_nonterminal_with_kind(NonterminalKind::NamedArgumentGroup) })?, Some(self.select(|node| node.is_terminal_with_kind(TerminalKind::CloseParen))?), ]) @@ -1464,11 +1464,11 @@ impl Selector { impl Selector { fn named_argument_group( &mut self, - ) -> Result>>> { + ) -> Result>>> { Ok(vec![ Some(self.select(|node| node.is_terminal_with_kind(TerminalKind::OpenBrace))?), Some( - self.select(|node| node.is_nonterminal_with_kind(NonTerminalKind::NamedArguments))?, + self.select(|node| node.is_nonterminal_with_kind(NonterminalKind::NamedArguments))?, ), Some(self.select(|node| node.is_terminal_with_kind(TerminalKind::CloseBrace))?), ]) @@ -1476,58 +1476,58 @@ impl Selector { } impl Selector { - fn named_argument(&mut self) -> Result>>> { + fn named_argument(&mut self) -> Result>>> { Ok(vec![ 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))?), + 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_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_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_terminal_with_kind(TerminalKind::NewKeyword))?), - Some(self.select(|node| node.is_nonterminal_with_kind(NonTerminalKind::TypeName))?), + 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_terminal_with_kind(TerminalKind::OpenParen))?), - Some(self.select(|node| node.is_nonterminal_with_kind(NonTerminalKind::TupleValues))?), + 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_nonterminal_with_kind(NonTerminalKind::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_terminal_with_kind(TerminalKind::OpenBracket))?), - Some(self.select(|node| node.is_nonterminal_with_kind(NonTerminalKind::ArrayValues))?), + Some(self.select(|node| node.is_nonterminal_with_kind(NonterminalKind::ArrayValues))?), Some(self.select(|node| node.is_terminal_with_kind(TerminalKind::CloseBracket))?), ]) } @@ -1536,10 +1536,10 @@ impl Selector { impl Selector { fn hex_number_expression( &mut self, - ) -> Result>>> { + ) -> Result>>> { Ok(vec![ Some(self.select(|node| node.is_terminal_with_kind(TerminalKind::HexLiteral))?), - self.try_select(|node| node.is_nonterminal_with_kind(NonTerminalKind::NumberUnit))?, + self.try_select(|node| node.is_nonterminal_with_kind(NonterminalKind::NumberUnit))?, ]) } } @@ -1547,20 +1547,20 @@ impl Selector { impl Selector { fn decimal_number_expression( &mut self, - ) -> Result>>> { + ) -> Result>>> { Ok(vec![ Some(self.select(|node| node.is_terminal_with_kind(TerminalKind::DecimalLiteral))?), - self.try_select(|node| node.is_nonterminal_with_kind(NonTerminalKind::NumberUnit))?, + 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_terminal_with_kind(TerminalKind::OpenBrace))?), Some( - self.select(|node| node.is_nonterminal_with_kind(NonTerminalKind::YulStatements))?, + self.select(|node| node.is_nonterminal_with_kind(NonterminalKind::YulStatements))?, ), Some(self.select(|node| node.is_terminal_with_kind(TerminalKind::CloseBrace))?), ]) @@ -1570,17 +1570,17 @@ impl Selector { impl Selector { fn yul_function_definition( &mut self, - ) -> Result>>> { + ) -> Result>>> { Ok(vec![ 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) + node.is_nonterminal_with_kind(NonterminalKind::YulParametersDeclaration) })?), self.try_select(|node| { - node.is_nonterminal_with_kind(NonTerminalKind::YulReturnsDeclaration) + node.is_nonterminal_with_kind(NonterminalKind::YulReturnsDeclaration) })?, - Some(self.select(|node| node.is_nonterminal_with_kind(NonTerminalKind::YulBlock))?), + Some(self.select(|node| node.is_nonterminal_with_kind(NonterminalKind::YulBlock))?), ]) } } @@ -1588,11 +1588,11 @@ impl Selector { impl Selector { fn yul_parameters_declaration( &mut self, - ) -> Result>>> { + ) -> Result>>> { Ok(vec![ Some(self.select(|node| node.is_terminal_with_kind(TerminalKind::OpenParen))?), Some( - self.select(|node| node.is_nonterminal_with_kind(NonTerminalKind::YulParameters))?, + self.select(|node| node.is_nonterminal_with_kind(NonterminalKind::YulParameters))?, ), Some(self.select(|node| node.is_terminal_with_kind(TerminalKind::CloseParen))?), ]) @@ -1602,11 +1602,11 @@ impl Selector { impl Selector { fn yul_returns_declaration( &mut self, - ) -> Result>>> { + ) -> Result>>> { Ok(vec![ Some(self.select(|node| node.is_terminal_with_kind(TerminalKind::MinusGreaterThan))?), Some(self.select(|node| { - node.is_nonterminal_with_kind(NonTerminalKind::YulReturnVariables) + node.is_nonterminal_with_kind(NonterminalKind::YulReturnVariables) })?), ]) } @@ -1615,12 +1615,12 @@ impl Selector { impl Selector { fn yul_variable_declaration_statement( &mut self, - ) -> Result>>> { + ) -> Result>>> { Ok(vec![ 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) + node.is_nonterminal_with_kind(NonterminalKind::YulVariableDeclarationValue) })?, ]) } @@ -1629,13 +1629,13 @@ impl Selector { impl Selector { fn yul_variable_declaration_value( &mut self, - ) -> Result>>> { + ) -> Result>>> { Ok(vec![ Some(self.select(|node| { - node.is_nonterminal_with_kind(NonTerminalKind::YulAssignmentOperator) + node.is_nonterminal_with_kind(NonterminalKind::YulAssignmentOperator) })?), Some( - self.select(|node| node.is_nonterminal_with_kind(NonTerminalKind::YulExpression))?, + self.select(|node| node.is_nonterminal_with_kind(NonterminalKind::YulExpression))?, ), ]) } @@ -1644,14 +1644,14 @@ impl Selector { impl Selector { fn yul_assignment_statement( &mut self, - ) -> Result>>> { + ) -> Result>>> { Ok(vec![ - Some(self.select(|node| node.is_nonterminal_with_kind(NonTerminalKind::YulPaths))?), + Some(self.select(|node| node.is_nonterminal_with_kind(NonterminalKind::YulPaths))?), Some(self.select(|node| { - node.is_nonterminal_with_kind(NonTerminalKind::YulAssignmentOperator) + node.is_nonterminal_with_kind(NonterminalKind::YulAssignmentOperator) })?), Some( - self.select(|node| node.is_nonterminal_with_kind(NonTerminalKind::YulExpression))?, + self.select(|node| node.is_nonterminal_with_kind(NonterminalKind::YulExpression))?, ), ]) } @@ -1660,7 +1660,7 @@ impl Selector { impl Selector { fn yul_colon_and_equal( &mut self, - ) -> Result>>> { + ) -> Result>>> { Ok(vec![ Some(self.select(|node| node.is_terminal_with_kind(TerminalKind::Colon))?), Some(self.select(|node| node.is_terminal_with_kind(TerminalKind::Equal))?), @@ -1669,27 +1669,27 @@ impl Selector { } impl Selector { - fn yul_if_statement(&mut self) -> Result>>> { + fn yul_if_statement(&mut self) -> Result>>> { Ok(vec![ Some(self.select(|node| node.is_terminal_with_kind(TerminalKind::YulIfKeyword))?), Some( - self.select(|node| node.is_nonterminal_with_kind(NonTerminalKind::YulExpression))?, + 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_for_statement(&mut self) -> Result>>> { + fn yul_for_statement(&mut self) -> Result>>> { Ok(vec![ 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::YulBlock))?), Some( - self.select(|node| node.is_nonterminal_with_kind(NonTerminalKind::YulExpression))?, + 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))?), + Some(self.select(|node| node.is_nonterminal_with_kind(NonterminalKind::YulBlock))?), + Some(self.select(|node| node.is_nonterminal_with_kind(NonterminalKind::YulBlock))?), ]) } } @@ -1697,34 +1697,34 @@ impl Selector { impl Selector { fn yul_switch_statement( &mut self, - ) -> Result>>> { + ) -> Result>>> { Ok(vec![ Some(self.select(|node| node.is_terminal_with_kind(TerminalKind::YulSwitchKeyword))?), Some( - self.select(|node| node.is_nonterminal_with_kind(NonTerminalKind::YulExpression))?, + self.select(|node| node.is_nonterminal_with_kind(NonterminalKind::YulExpression))?, ), Some( - self.select(|node| node.is_nonterminal_with_kind(NonTerminalKind::YulSwitchCases))?, + 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_terminal_with_kind(TerminalKind::YulDefaultKeyword))?), - 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_value_case(&mut self) -> Result>>> { + fn yul_value_case(&mut self) -> Result>>> { Ok(vec![ 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))?), + Some(self.select(|node| node.is_nonterminal_with_kind(NonterminalKind::YulLiteral))?), + Some(self.select(|node| node.is_nonterminal_with_kind(NonterminalKind::YulBlock))?), ]) } } @@ -1732,7 +1732,7 @@ impl Selector { impl Selector { fn yul_leave_statement( &mut self, - ) -> Result>>> { + ) -> Result>>> { Ok(vec![Some(self.select(|node| { node.is_terminal_with_kind(TerminalKind::YulLeaveKeyword) })?)]) @@ -1742,7 +1742,7 @@ impl Selector { impl Selector { fn yul_break_statement( &mut self, - ) -> Result>>> { + ) -> Result>>> { Ok(vec![Some(self.select(|node| { node.is_terminal_with_kind(TerminalKind::YulBreakKeyword) })?)]) @@ -1752,7 +1752,7 @@ impl Selector { impl Selector { fn yul_continue_statement( &mut self, - ) -> Result>>> { + ) -> Result>>> { Ok(vec![Some(self.select(|node| { node.is_terminal_with_kind(TerminalKind::YulContinueKeyword) })?)]) @@ -1760,7 +1760,7 @@ impl Selector { } impl Selector { - fn yul_label(&mut self) -> Result>>> { + fn yul_label(&mut self) -> Result>>> { Ok(vec![ Some(self.select(|node| node.is_terminal_with_kind(TerminalKind::YulIdentifier))?), Some(self.select(|node| node.is_terminal_with_kind(TerminalKind::Colon))?), @@ -1771,13 +1771,13 @@ impl Selector { impl Selector { fn yul_function_call_expression( &mut self, - ) -> Result>>> { + ) -> Result>>> { Ok(vec![ Some( - self.select(|node| node.is_nonterminal_with_kind(NonTerminalKind::YulExpression))?, + 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_nonterminal_with_kind(NonterminalKind::YulArguments))?), Some(self.select(|node| node.is_terminal_with_kind(TerminalKind::CloseParen))?), ]) } @@ -1788,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.NonTerminalNode")] node: &NonTerminalNode, -) -> Result> { + #[napi(ts_arg_type = "cst.NonterminalNode")] node: &NonterminalNode, +) -> Result> { let mut selector = Selector::new(node); let result = match node.kind() { - 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()?, + 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(); } @@ -1846,55 +1846,55 @@ 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_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, + 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_nonterminal_with_kinds(&[ - NonTerminalKind::ABICoderPragma, - NonTerminalKind::ExperimentalPragma, - NonTerminalKind::VersionPragma, + 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_nonterminal_with_kind(NonTerminalKind::StringLiteral) + 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_nonterminal_with_kinds(&[ - NonTerminalKind::VersionRange, - NonTerminalKind::VersionComparator, - NonTerminalKind::VersionSpecifiers, + NonterminalKind::VersionRange, + NonterminalKind::VersionComparator, + NonterminalKind::VersionSpecifiers, ]) || node.is_terminal_with_kinds(&[ TerminalKind::SingleQuotedVersionLiteral, TerminalKind::DoubleQuotedVersionLiteral, @@ -1904,30 +1904,30 @@ impl Selector { } impl Selector { - fn import_clause(&mut self) -> Result> { + fn import_clause(&mut self) -> Result> { self.select(|node| { node.is_nonterminal_with_kinds(&[ - NonTerminalKind::PathImport, - NonTerminalKind::NamedImport, - NonTerminalKind::ImportDeconstruction, + 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_nonterminal_with_kinds(&[ - NonTerminalKind::IdentifierPath, - NonTerminalKind::UsingDeconstruction, + NonterminalKind::IdentifierPath, + NonterminalKind::UsingDeconstruction, ]) }) } } impl Selector { - fn using_operator(&mut self) -> Result> { + fn using_operator(&mut self) -> Result> { self.select(|node| { node.is_terminal_with_kinds(&[ TerminalKind::Ampersand, @@ -1951,40 +1951,40 @@ impl Selector { } impl Selector { - fn using_target(&mut self) -> Result> { + fn using_target(&mut self) -> Result> { self.select(|node| { - node.is_nonterminal_with_kind(NonTerminalKind::TypeName) + 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_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, + 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_nonterminal_with_kind(NonTerminalKind::OverrideSpecifier) + node.is_nonterminal_with_kind(NonterminalKind::OverrideSpecifier) || node.is_terminal_with_kinds(&[ TerminalKind::ConstantKeyword, TerminalKind::InternalKeyword, @@ -1997,7 +1997,7 @@ impl Selector { } impl Selector { - fn function_name(&mut self) -> Result> { + fn function_name(&mut self) -> Result> { self.select(|node| { node.is_terminal_with_kinds(&[ TerminalKind::Identifier, @@ -2009,11 +2009,11 @@ impl Selector { } impl Selector { - fn function_attribute(&mut self) -> Result> { + fn function_attribute(&mut self) -> Result> { self.select(|node| { node.is_nonterminal_with_kinds(&[ - NonTerminalKind::ModifierInvocation, - NonTerminalKind::OverrideSpecifier, + NonterminalKind::ModifierInvocation, + NonterminalKind::OverrideSpecifier, ]) || node.is_terminal_with_kinds(&[ TerminalKind::ConstantKeyword, TerminalKind::ExternalKeyword, @@ -2030,18 +2030,18 @@ impl Selector { } impl Selector { - fn function_body(&mut self) -> Result> { + fn function_body(&mut self) -> Result> { self.select(|node| { - node.is_nonterminal_with_kind(NonTerminalKind::Block) + 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_nonterminal_with_kind(NonTerminalKind::ModifierInvocation) + node.is_nonterminal_with_kind(NonterminalKind::ModifierInvocation) || node.is_terminal_with_kinds(&[ TerminalKind::InternalKeyword, TerminalKind::OverrideKeyword, @@ -2054,9 +2054,9 @@ impl Selector { } impl Selector { - fn unnamed_function_attribute(&mut self) -> Result> { + fn unnamed_function_attribute(&mut self) -> Result> { self.select(|node| { - node.is_nonterminal_with_kind(NonTerminalKind::ModifierInvocation) + node.is_nonterminal_with_kind(NonterminalKind::ModifierInvocation) || node.is_terminal_with_kinds(&[ TerminalKind::ConstantKeyword, TerminalKind::ExternalKeyword, @@ -2072,11 +2072,11 @@ impl Selector { } impl Selector { - fn fallback_function_attribute(&mut self) -> Result> { + fn fallback_function_attribute(&mut self) -> Result> { self.select(|node| { node.is_nonterminal_with_kinds(&[ - NonTerminalKind::ModifierInvocation, - NonTerminalKind::OverrideSpecifier, + NonterminalKind::ModifierInvocation, + NonterminalKind::OverrideSpecifier, ]) || node.is_terminal_with_kinds(&[ TerminalKind::ExternalKeyword, TerminalKind::PayableKeyword, @@ -2089,11 +2089,11 @@ impl Selector { } impl Selector { - fn receive_function_attribute(&mut self) -> Result> { + fn receive_function_attribute(&mut self) -> Result> { self.select(|node| { node.is_nonterminal_with_kinds(&[ - NonTerminalKind::ModifierInvocation, - NonTerminalKind::OverrideSpecifier, + NonterminalKind::ModifierInvocation, + NonterminalKind::OverrideSpecifier, ]) || node.is_terminal_with_kinds(&[ TerminalKind::ExternalKeyword, TerminalKind::PayableKeyword, @@ -2104,30 +2104,30 @@ impl Selector { } impl Selector { - fn modifier_attribute(&mut self) -> Result> { + fn modifier_attribute(&mut self) -> Result> { self.select(|node| { - node.is_nonterminal_with_kind(NonTerminalKind::OverrideSpecifier) + 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_nonterminal_with_kinds(&[ - NonTerminalKind::ArrayTypeName, - NonTerminalKind::FunctionType, - NonTerminalKind::MappingType, - NonTerminalKind::ElementaryType, - NonTerminalKind::IdentifierPath, + 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_terminal_with_kinds(&[ TerminalKind::InternalKeyword, @@ -2144,20 +2144,20 @@ impl Selector { } impl Selector { - fn mapping_key_type(&mut self) -> Result> { + fn mapping_key_type(&mut self) -> Result> { self.select(|node| { node.is_nonterminal_with_kinds(&[ - NonTerminalKind::ElementaryType, - NonTerminalKind::IdentifierPath, + NonterminalKind::ElementaryType, + NonterminalKind::IdentifierPath, ]) }) } } impl Selector { - fn elementary_type(&mut self) -> Result> { + fn elementary_type(&mut self) -> Result> { self.select(|node| { - node.is_nonterminal_with_kind(NonTerminalKind::AddressType) + node.is_nonterminal_with_kind(NonterminalKind::AddressType) || node.is_terminal_with_kinds(&[ TerminalKind::BoolKeyword, TerminalKind::ByteKeyword, @@ -2173,53 +2173,53 @@ impl Selector { } impl Selector { - fn statement(&mut self) -> Result> { + fn statement(&mut self) -> Result> { self.select(|node| { 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, + 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_nonterminal_with_kinds(&[ - NonTerminalKind::TypedTupleMember, - NonTerminalKind::UntypedTupleMember, + 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_nonterminal_with_kind(NonTerminalKind::TypeName) + 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_terminal_with_kinds(&[ TerminalKind::MemoryKeyword, @@ -2231,57 +2231,57 @@ impl Selector { } impl Selector { - fn for_statement_initialization(&mut self) -> Result> { + fn for_statement_initialization(&mut self) -> Result> { self.select(|node| { node.is_nonterminal_with_kinds(&[ - NonTerminalKind::ExpressionStatement, - NonTerminalKind::VariableDeclarationStatement, - NonTerminalKind::TupleDeconstructionStatement, + 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_nonterminal_with_kind(NonTerminalKind::ExpressionStatement) + 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_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, + 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, @@ -2293,7 +2293,7 @@ impl Selector { } impl Selector { - fn member_access(&mut self) -> Result> { + fn member_access(&mut self) -> Result> { self.select(|node| { node.is_terminal_with_kinds(&[TerminalKind::Identifier, TerminalKind::AddressKeyword]) }) @@ -2301,18 +2301,18 @@ impl Selector { } impl Selector { - fn arguments_declaration(&mut self) -> Result> { + fn arguments_declaration(&mut self) -> Result> { self.select(|node| { node.is_nonterminal_with_kinds(&[ - NonTerminalKind::PositionalArgumentsDeclaration, - NonTerminalKind::NamedArgumentsDeclaration, + NonterminalKind::PositionalArgumentsDeclaration, + NonterminalKind::NamedArgumentsDeclaration, ]) }) } } impl Selector { - fn number_unit(&mut self) -> Result> { + fn number_unit(&mut self) -> Result> { self.select(|node| { node.is_terminal_with_kinds(&[ TerminalKind::WeiKeyword, @@ -2332,21 +2332,21 @@ impl Selector { } impl Selector { - fn string_expression(&mut self) -> Result> { + fn string_expression(&mut self) -> Result> { self.select(|node| { node.is_nonterminal_with_kinds(&[ - NonTerminalKind::StringLiteral, - NonTerminalKind::StringLiterals, - NonTerminalKind::HexStringLiteral, - NonTerminalKind::HexStringLiterals, - NonTerminalKind::UnicodeStringLiterals, + 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_terminal_with_kinds(&[ TerminalKind::SingleQuotedStringLiteral, @@ -2357,7 +2357,7 @@ impl Selector { } impl Selector { - fn hex_string_literal(&mut self) -> Result> { + fn hex_string_literal(&mut self) -> Result> { self.select(|node| { node.is_terminal_with_kinds(&[ TerminalKind::SingleQuotedHexStringLiteral, @@ -2368,7 +2368,7 @@ impl Selector { } impl Selector { - fn unicode_string_literal(&mut self) -> Result> { + fn unicode_string_literal(&mut self) -> Result> { self.select(|node| { node.is_terminal_with_kinds(&[ TerminalKind::SingleQuotedUnicodeStringLiteral, @@ -2379,61 +2379,61 @@ impl Selector { } impl Selector { - fn yul_statement(&mut self) -> Result> { + fn yul_statement(&mut self) -> Result> { self.select(|node| { 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, + 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_nonterminal_with_kind(NonTerminalKind::YulColonAndEqual) + 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_nonterminal_with_kinds(&[ - NonTerminalKind::YulDefaultCase, - NonTerminalKind::YulValueCase, + NonterminalKind::YulDefaultCase, + NonterminalKind::YulValueCase, ]) }) } } impl Selector { - fn yul_expression(&mut self) -> Result> { + fn yul_expression(&mut self) -> Result> { self.select(|node| { node.is_nonterminal_with_kinds(&[ - NonTerminalKind::YulFunctionCallExpression, - NonTerminalKind::YulLiteral, - NonTerminalKind::YulBuiltInFunction, - NonTerminalKind::YulPath, + 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_terminal_with_kinds(&[ TerminalKind::YulIdentifier, @@ -2444,7 +2444,7 @@ impl Selector { } impl Selector { - fn yul_built_in_function(&mut self) -> Result> { + fn yul_built_in_function(&mut self) -> Result> { self.select(|node| { node.is_terminal_with_kinds(&[ TerminalKind::YulAddKeyword, @@ -2534,11 +2534,11 @@ impl Selector { } impl Selector { - fn yul_literal(&mut self) -> Result> { + fn yul_literal(&mut self) -> Result> { self.select(|node| { node.is_nonterminal_with_kinds(&[ - NonTerminalKind::HexStringLiteral, - NonTerminalKind::StringLiteral, + NonterminalKind::HexStringLiteral, + NonterminalKind::StringLiteral, ]) || node.is_terminal_with_kinds(&[ TerminalKind::YulTrueKeyword, TerminalKind::YulFalseKeyword, @@ -2559,32 +2559,32 @@ impl Selector { catch_unwind )] pub fn select_repeated( - #[napi(ts_arg_type = "cst.NonTerminalNode")] node: &NonTerminalNode, -) -> Result>> { + #[napi(ts_arg_type = "cst.NonterminalNode")] node: &NonterminalNode, +) -> Result>> { let mut selector = Selector::new(node); let result = match node.kind() { - 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()?, + 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(); } @@ -2595,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_nonterminal_with_kind(NonTerminalKind::SourceUnitMember))? + .try_select(|node| node.is_nonterminal_with_kind(NonterminalKind::SourceUnitMember))? { items.push(item); } @@ -2609,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_nonterminal_with_kind(NonTerminalKind::VersionExpression))? + .try_select(|node| node.is_nonterminal_with_kind(NonterminalKind::VersionExpression))? { items.push(item); } @@ -2623,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_nonterminal_with_kind(NonTerminalKind::ContractMember))? + self.try_select(|node| node.is_nonterminal_with_kind(NonterminalKind::ContractMember))? { items.push(item); } @@ -2637,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_nonterminal_with_kind(NonTerminalKind::ContractMember))? + self.try_select(|node| node.is_nonterminal_with_kind(NonterminalKind::ContractMember))? { items.push(item); } @@ -2651,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_nonterminal_with_kind(NonTerminalKind::ContractMember))? + self.try_select(|node| node.is_nonterminal_with_kind(NonterminalKind::ContractMember))? { items.push(item); } @@ -2665,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_nonterminal_with_kind(NonTerminalKind::StructMember))? + self.try_select(|node| node.is_nonterminal_with_kind(NonterminalKind::StructMember))? { items.push(item); } @@ -2679,11 +2679,11 @@ 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_nonterminal_with_kind(NonTerminalKind::StateVariableAttribute) + node.is_nonterminal_with_kind(NonterminalKind::StateVariableAttribute) })? { items.push(item); } @@ -2693,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_nonterminal_with_kind(NonTerminalKind::FunctionAttribute))? + .try_select(|node| node.is_nonterminal_with_kind(NonterminalKind::FunctionAttribute))? { items.push(item); } @@ -2707,11 +2707,11 @@ 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_nonterminal_with_kind(NonTerminalKind::ConstructorAttribute) + node.is_nonterminal_with_kind(NonterminalKind::ConstructorAttribute) })? { items.push(item); } @@ -2723,11 +2723,11 @@ impl Selector { impl Selector { fn unnamed_function_attributes( &mut self, - ) -> Result>> { + ) -> Result>> { let mut items = vec![]; while let Some(item) = self.try_select(|node| { - node.is_nonterminal_with_kind(NonTerminalKind::UnnamedFunctionAttribute) + node.is_nonterminal_with_kind(NonterminalKind::UnnamedFunctionAttribute) })? { items.push(item); } @@ -2739,11 +2739,11 @@ impl Selector { impl Selector { fn fallback_function_attributes( &mut self, - ) -> Result>> { + ) -> Result>> { let mut items = vec![]; while let Some(item) = self.try_select(|node| { - node.is_nonterminal_with_kind(NonTerminalKind::FallbackFunctionAttribute) + node.is_nonterminal_with_kind(NonterminalKind::FallbackFunctionAttribute) })? { items.push(item); } @@ -2755,11 +2755,11 @@ impl Selector { impl Selector { fn receive_function_attributes( &mut self, - ) -> Result>> { + ) -> Result>> { let mut items = vec![]; while let Some(item) = self.try_select(|node| { - node.is_nonterminal_with_kind(NonTerminalKind::ReceiveFunctionAttribute) + node.is_nonterminal_with_kind(NonterminalKind::ReceiveFunctionAttribute) })? { items.push(item); } @@ -2769,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_nonterminal_with_kind(NonTerminalKind::ModifierAttribute))? + .try_select(|node| node.is_nonterminal_with_kind(NonterminalKind::ModifierAttribute))? { items.push(item); } @@ -2783,11 +2783,11 @@ 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_nonterminal_with_kind(NonTerminalKind::FunctionTypeAttribute) + node.is_nonterminal_with_kind(NonterminalKind::FunctionTypeAttribute) })? { items.push(item); } @@ -2797,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_nonterminal_with_kind(NonTerminalKind::Statement))? + self.try_select(|node| node.is_nonterminal_with_kind(NonterminalKind::Statement))? { items.push(item); } @@ -2811,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_nonterminal_with_kind(NonTerminalKind::CatchClause))? + self.try_select(|node| node.is_nonterminal_with_kind(NonterminalKind::CatchClause))? { items.push(item); } @@ -2825,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_nonterminal_with_kind(NonTerminalKind::StringLiteral))? + self.try_select(|node| node.is_nonterminal_with_kind(NonterminalKind::StringLiteral))? { items.push(item); } @@ -2839,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_nonterminal_with_kind(NonTerminalKind::HexStringLiteral))? + .try_select(|node| node.is_nonterminal_with_kind(NonterminalKind::HexStringLiteral))? { items.push(item); } @@ -2853,11 +2853,11 @@ 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_nonterminal_with_kind(NonTerminalKind::UnicodeStringLiteral) + node.is_nonterminal_with_kind(NonterminalKind::UnicodeStringLiteral) })? { items.push(item); } @@ -2867,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_nonterminal_with_kind(NonTerminalKind::YulStatement))? + self.try_select(|node| node.is_nonterminal_with_kind(NonterminalKind::YulStatement))? { items.push(item); } @@ -2881,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_nonterminal_with_kind(NonTerminalKind::YulSwitchCase))? + self.try_select(|node| node.is_nonterminal_with_kind(NonterminalKind::YulSwitchCase))? { items.push(item); } @@ -2904,34 +2904,34 @@ impl Selector { catch_unwind )] pub fn select_separated( - #[napi(ts_arg_type = "cst.NonTerminalNode")] node: &NonTerminalNode, -) -> Result>>> { + #[napi(ts_arg_type = "cst.NonterminalNode")] node: &NonterminalNode, +) -> Result>>> { let mut selector = Selector::new(node); let result = match node.kind() { - 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()?, + 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(); } @@ -2944,12 +2944,12 @@ pub fn select_separated( impl Selector { fn version_expression_sets( &mut self, - ) -> Result>>> { + ) -> Result>>> { let mut separated = vec![]; let mut separators = vec![]; if let Some(first) = self.try_select(|node| { - node.is_nonterminal_with_kind(NonTerminalKind::VersionExpressionSet) + node.is_nonterminal_with_kind(NonterminalKind::VersionExpressionSet) })? { separated.push(first); @@ -2959,7 +2959,7 @@ impl Selector { separators.push(separator); separated.push(self.select(|node| { - node.is_nonterminal_with_kind(NonTerminalKind::VersionExpressionSet) + node.is_nonterminal_with_kind(NonterminalKind::VersionExpressionSet) })?); } } @@ -2969,7 +2969,7 @@ impl Selector { } impl Selector { - fn version_specifiers(&mut self) -> Result>>> { + fn version_specifiers(&mut self) -> Result>>> { let mut separated = vec![]; let mut separators = vec![]; @@ -2996,12 +2996,12 @@ impl Selector { impl Selector { fn import_deconstruction_symbols( &mut self, - ) -> Result>>> { + ) -> Result>>> { let mut separated = vec![]; let mut separators = vec![]; if let Some(first) = self.try_select(|node| { - node.is_nonterminal_with_kind(NonTerminalKind::ImportDeconstructionSymbol) + node.is_nonterminal_with_kind(NonterminalKind::ImportDeconstructionSymbol) })? { separated.push(first); @@ -3011,7 +3011,7 @@ impl Selector { separators.push(separator); separated.push(self.select(|node| { - node.is_nonterminal_with_kind(NonTerminalKind::ImportDeconstructionSymbol) + node.is_nonterminal_with_kind(NonterminalKind::ImportDeconstructionSymbol) })?); } } @@ -3023,12 +3023,12 @@ impl Selector { impl Selector { fn using_deconstruction_symbols( &mut self, - ) -> Result>>> { + ) -> Result>>> { let mut separated = vec![]; let mut separators = vec![]; if let Some(first) = self.try_select(|node| { - node.is_nonterminal_with_kind(NonTerminalKind::UsingDeconstructionSymbol) + node.is_nonterminal_with_kind(NonterminalKind::UsingDeconstructionSymbol) })? { separated.push(first); @@ -3038,7 +3038,7 @@ impl Selector { separators.push(separator); separated.push(self.select(|node| { - node.is_nonterminal_with_kind(NonTerminalKind::UsingDeconstructionSymbol) + node.is_nonterminal_with_kind(NonterminalKind::UsingDeconstructionSymbol) })?); } } @@ -3048,12 +3048,12 @@ 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_nonterminal_with_kind(NonTerminalKind::InheritanceType))? + self.try_select(|node| node.is_nonterminal_with_kind(NonterminalKind::InheritanceType))? { separated.push(first); @@ -3063,7 +3063,7 @@ impl Selector { separators.push(separator); separated.push(self.select(|node| { - node.is_nonterminal_with_kind(NonTerminalKind::InheritanceType) + node.is_nonterminal_with_kind(NonterminalKind::InheritanceType) })?); } } @@ -3073,7 +3073,7 @@ impl Selector { } impl Selector { - fn enum_members(&mut self) -> Result>>> { + fn enum_members(&mut self) -> Result>>> { let mut separated = vec![]; let mut separators = vec![]; @@ -3098,12 +3098,12 @@ 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_nonterminal_with_kind(NonTerminalKind::Parameter))? + self.try_select(|node| node.is_nonterminal_with_kind(NonterminalKind::Parameter))? { separated.push(first); @@ -3113,7 +3113,7 @@ impl Selector { separators.push(separator); separated.push( - self.select(|node| node.is_nonterminal_with_kind(NonTerminalKind::Parameter))?, + self.select(|node| node.is_nonterminal_with_kind(NonterminalKind::Parameter))?, ); } } @@ -3123,12 +3123,12 @@ 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_nonterminal_with_kind(NonTerminalKind::IdentifierPath))? + self.try_select(|node| node.is_nonterminal_with_kind(NonterminalKind::IdentifierPath))? { separated.push(first); @@ -3138,7 +3138,7 @@ impl Selector { separators.push(separator); separated.push(self.select(|node| { - node.is_nonterminal_with_kind(NonTerminalKind::IdentifierPath) + node.is_nonterminal_with_kind(NonterminalKind::IdentifierPath) })?); } } @@ -3148,12 +3148,12 @@ 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_nonterminal_with_kind(NonTerminalKind::EventParameter))? + self.try_select(|node| node.is_nonterminal_with_kind(NonterminalKind::EventParameter))? { separated.push(first); @@ -3163,7 +3163,7 @@ impl Selector { separators.push(separator); separated.push(self.select(|node| { - node.is_nonterminal_with_kind(NonTerminalKind::EventParameter) + node.is_nonterminal_with_kind(NonterminalKind::EventParameter) })?); } } @@ -3173,12 +3173,12 @@ 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_nonterminal_with_kind(NonTerminalKind::ErrorParameter))? + self.try_select(|node| node.is_nonterminal_with_kind(NonterminalKind::ErrorParameter))? { separated.push(first); @@ -3188,7 +3188,7 @@ impl Selector { separators.push(separator); separated.push(self.select(|node| { - node.is_nonterminal_with_kind(NonTerminalKind::ErrorParameter) + node.is_nonterminal_with_kind(NonterminalKind::ErrorParameter) })?); } } @@ -3198,12 +3198,12 @@ 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_nonterminal_with_kind(NonTerminalKind::StringLiteral))? + self.try_select(|node| node.is_nonterminal_with_kind(NonterminalKind::StringLiteral))? { separated.push(first); @@ -3213,7 +3213,7 @@ impl Selector { separators.push(separator); separated.push(self.select(|node| { - node.is_nonterminal_with_kind(NonTerminalKind::StringLiteral) + node.is_nonterminal_with_kind(NonterminalKind::StringLiteral) })?); } } @@ -3225,12 +3225,12 @@ impl Selector { impl Selector { fn tuple_deconstruction_elements( &mut self, - ) -> Result>>> { + ) -> Result>>> { let mut separated = vec![]; let mut separators = vec![]; if let Some(first) = self.try_select(|node| { - node.is_nonterminal_with_kind(NonTerminalKind::TupleDeconstructionElement) + node.is_nonterminal_with_kind(NonterminalKind::TupleDeconstructionElement) })? { separated.push(first); @@ -3240,7 +3240,7 @@ impl Selector { separators.push(separator); separated.push(self.select(|node| { - node.is_nonterminal_with_kind(NonTerminalKind::TupleDeconstructionElement) + node.is_nonterminal_with_kind(NonterminalKind::TupleDeconstructionElement) })?); } } @@ -3250,12 +3250,12 @@ 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_nonterminal_with_kind(NonTerminalKind::Expression))? + self.try_select(|node| node.is_nonterminal_with_kind(NonterminalKind::Expression))? { separated.push(first); @@ -3265,7 +3265,7 @@ impl Selector { separators.push(separator); separated.push( - self.select(|node| node.is_nonterminal_with_kind(NonTerminalKind::Expression))?, + self.select(|node| node.is_nonterminal_with_kind(NonterminalKind::Expression))?, ); } } @@ -3275,12 +3275,12 @@ 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_nonterminal_with_kind(NonTerminalKind::NamedArgument))? + self.try_select(|node| node.is_nonterminal_with_kind(NonterminalKind::NamedArgument))? { separated.push(first); @@ -3290,7 +3290,7 @@ impl Selector { separators.push(separator); separated.push(self.select(|node| { - node.is_nonterminal_with_kind(NonTerminalKind::NamedArgument) + node.is_nonterminal_with_kind(NonterminalKind::NamedArgument) })?); } } @@ -3300,12 +3300,12 @@ 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_nonterminal_with_kind(NonTerminalKind::NamedArgument))? + self.try_select(|node| node.is_nonterminal_with_kind(NonterminalKind::NamedArgument))? { separated.push(first); @@ -3315,7 +3315,7 @@ impl Selector { separators.push(separator); separated.push(self.select(|node| { - node.is_nonterminal_with_kind(NonTerminalKind::NamedArgument) + node.is_nonterminal_with_kind(NonterminalKind::NamedArgument) })?); } } @@ -3325,12 +3325,12 @@ 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_nonterminal_with_kind(NonTerminalKind::TupleValue))? + self.try_select(|node| node.is_nonterminal_with_kind(NonterminalKind::TupleValue))? { separated.push(first); @@ -3340,7 +3340,7 @@ impl Selector { separators.push(separator); separated.push( - self.select(|node| node.is_nonterminal_with_kind(NonTerminalKind::TupleValue))?, + self.select(|node| node.is_nonterminal_with_kind(NonterminalKind::TupleValue))?, ); } } @@ -3350,12 +3350,12 @@ 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_nonterminal_with_kind(NonTerminalKind::Expression))? + self.try_select(|node| node.is_nonterminal_with_kind(NonterminalKind::Expression))? { separated.push(first); @@ -3365,7 +3365,7 @@ impl Selector { separators.push(separator); separated.push( - self.select(|node| node.is_nonterminal_with_kind(NonTerminalKind::Expression))?, + self.select(|node| node.is_nonterminal_with_kind(NonterminalKind::Expression))?, ); } } @@ -3375,7 +3375,7 @@ impl Selector { } impl Selector { - fn identifier_path(&mut self) -> Result>>> { + fn identifier_path(&mut self) -> Result>>> { let mut separated = vec![]; let mut separators = vec![]; @@ -3400,7 +3400,7 @@ impl Selector { } impl Selector { - fn yul_parameters(&mut self) -> Result>>> { + fn yul_parameters(&mut self) -> Result>>> { let mut separated = vec![]; let mut separators = vec![]; @@ -3425,7 +3425,7 @@ 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![]; @@ -3450,12 +3450,12 @@ 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_nonterminal_with_kind(NonTerminalKind::YulExpression))? + self.try_select(|node| node.is_nonterminal_with_kind(NonterminalKind::YulExpression))? { separated.push(first); @@ -3465,7 +3465,7 @@ impl Selector { separators.push(separator); separated.push(self.select(|node| { - node.is_nonterminal_with_kind(NonTerminalKind::YulExpression) + node.is_nonterminal_with_kind(NonterminalKind::YulExpression) })?); } } @@ -3475,12 +3475,12 @@ 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_nonterminal_with_kind(NonTerminalKind::YulPath))? + self.try_select(|node| node.is_nonterminal_with_kind(NonterminalKind::YulPath))? { separated.push(first); @@ -3490,7 +3490,7 @@ impl Selector { separators.push(separator); separated.push( - self.select(|node| node.is_nonterminal_with_kind(NonTerminalKind::YulPath))?, + self.select(|node| node.is_nonterminal_with_kind(NonterminalKind::YulPath))?, ); } } @@ -3500,12 +3500,12 @@ 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_nonterminal_with_kind(NonTerminalKind::YulPathComponent))? + .try_select(|node| node.is_nonterminal_with_kind(NonterminalKind::YulPathComponent))? { separated.push(first); @@ -3515,7 +3515,7 @@ impl Selector { separators.push(separator); separated.push(self.select(|node| { - node.is_nonterminal_with_kind(NonTerminalKind::YulPathComponent) + node.is_nonterminal_with_kind(NonterminalKind::YulPathComponent) })?); } } @@ -3529,12 +3529,12 @@ impl Selector { // struct Selector { - node: Rc, + node: Rc, index: usize, } impl Selector { - fn new(node: &NonTerminalNode) -> Self { + fn new(node: &NonterminalNode) -> Self { Self { node: Rc::clone(&node.0), index: 0, @@ -3544,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(), @@ -3554,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() => { @@ -3566,7 +3566,7 @@ impl Selector { node: RustNode::Terminal(terminal), .. } if matches!(terminal.kind, TerminalKind::SKIPPED) => { - return Error::SkippedToken(self.index).into(); + return Error::SkippedTerminal(self.index).into(); } labeled if filter(labeled) => { self.index += 1; @@ -3595,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 NonTerminalKind '{0}'.")] - UnexpectedParent(NonTerminalKind), + #[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}'.")] @@ -3607,8 +3607,8 @@ enum Error { MissingChild(usize), // Can happen if the user decided to use an incorrect/incomplete CST node. - #[error("Unexpected SKIPPED token at index '{0}'. Creating AST types from incorrect/incomplete CST nodes is not supported yet.")] - SkippedToken(usize), + #[error("Unexpected SKIPPED terminal at index '{0}'. Creating AST types from incorrect/incomplete CST nodes is not supported yet.")] + SkippedTerminal(usize), } impl From for Result { 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 bd0a794415..1f127807e3 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 @@ -18,11 +18,11 @@ type RustParseOutput = crate::parse_output::ParseOutput; type RustQuery = crate::query::Query; type RustQueryMatch = crate::query::QueryMatch; type RustQueryMatchIterator = crate::query::QueryMatchIterator; -type RustNonTerminalNode = crate::cst::NonTerminalNode; +type RustNonterminalNode = crate::cst::NonterminalNode; type RustTextIndex = crate::text_index::TextIndex; type RustTextRange = crate::text_index::TextRange; type RustTerminalNode = crate::cst::TerminalNode; -type NonTerminalKind = crate::kinds::NonTerminalKind; +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 573b75ab1f..debfd1f130 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, NonTerminalNode, TerminalNode}; +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/napi_interface/query.rs b/crates/solidity/outputs/cargo/slang_solidity/src/generated/napi_interface/query.rs index 2eeee7a7bd..79dcc9e5c4 100644 --- a/crates/solidity/outputs/cargo/slang_solidity/src/generated/napi_interface/query.rs +++ b/crates/solidity/outputs/cargo/slang_solidity/src/generated/napi_interface/query.rs @@ -41,16 +41,16 @@ pub struct QueryMatchIterator(RustQueryMatchIterator); pub struct QueryMatch { pub query_number: u32, #[napi(ts_type = "{ [key: string]: cursor.Cursor[] }")] - pub bindings: HashMap>>, + pub captures: HashMap>>, } impl QueryMatch { - fn new(env: Env, result: RustQueryMatch) -> napi::Result { + fn new(env: Env, r#match: RustQueryMatch) -> napi::Result { #[allow(clippy::cast_possible_truncation)] - let query_number = result.query_number as u32; - // transfer all of the bindings eagerly on the assumption + let query_number = r#match.query_number as u32; + // transfer all of the captures eagerly on the assumption // that they've all been explicitly requested. - let bindings = result + let captures = r#match .captures .into_iter() .map(|(key, values)| { @@ -65,7 +65,7 @@ impl QueryMatch { Ok(Self { query_number, - bindings, + captures, }) } } @@ -81,7 +81,7 @@ impl QueryMatchIterator { #[napi(catch_unwind)] pub fn next(&mut self, env: Env) -> napi::Result> { match self.0.next() { - Some(result) => Ok(Some(QueryMatch::new(env, result)?)), + Some(r#match) => Ok(Some(QueryMatch::new(env, r#match)?)), None => Ok(None), } } 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 a93d647d57..120851c6ac 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 @@ -8,7 +8,7 @@ use crate::text_index::TextRange; #[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) terminals_that_would_have_allowed_more_progress: Vec, } impl ParseError { @@ -16,13 +16,13 @@ impl ParseError { &self.text_range } - pub fn tokens_that_would_have_allowed_more_progress(&self) -> Vec { - let tokens_that_would_have_allowed_more_progress = self - .tokens_that_would_have_allowed_more_progress + pub fn terminals_that_would_have_allowed_more_progress(&self) -> Vec { + let terminals_that_would_have_allowed_more_progress = self + .terminals_that_would_have_allowed_more_progress .iter() .collect::>(); - tokens_that_would_have_allowed_more_progress + terminals_that_would_have_allowed_more_progress .into_iter() .map(TerminalKind::to_string) .collect() @@ -36,11 +36,11 @@ impl ParseError { impl ParseError { pub(crate) fn new( text_range: TextRange, - tokens_that_would_have_allowed_more_progress: Vec, + terminals_that_would_have_allowed_more_progress: Vec, ) -> Self { Self { text_range, - tokens_that_would_have_allowed_more_progress, + terminals_that_would_have_allowed_more_progress, } } } @@ -56,14 +56,14 @@ pub(crate) fn render_error_report( let kind = ReportKind::Error; let color = if with_color { Color::Red } else { Color::Unset }; - let tokens_that_would_have_allowed_more_progress = - error.tokens_that_would_have_allowed_more_progress(); - let message = if tokens_that_would_have_allowed_more_progress.is_empty() { + let terminals_that_would_have_allowed_more_progress = + error.terminals_that_would_have_allowed_more_progress(); + let message = if terminals_that_would_have_allowed_more_progress.is_empty() { "Expected end of file.".to_string() } else { format!( "Expected {expectations}.", - expectations = tokens_that_would_have_allowed_more_progress.join(" or ") + expectations = terminals_that_would_have_allowed_more_progress.join(" or ") ) }; 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 9efafc325e..3a63eb6cad 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 @@ -54,9 +54,11 @@ impl ChoiceHelper { return; } - // Still no match, extend the possible expected tokens. + // Still no match, extend the possible expected terminals. (ParserResult::NoMatch(running), ParserResult::NoMatch(next)) => { - running.expected_tokens.extend(next.expected_tokens.clone()); + running + .expected_terminals + .extend(next.expected_terminals.clone()); false } // Otherwise, we already have some match, so we ignore a next missing one. @@ -65,7 +67,7 @@ impl ChoiceHelper { // Try to improve our match. (_, ParserResult::Match(next)) if next.is_full_recursive() => true, (_, ParserResult::PrattOperatorMatch(..)) => true, - // Optimize for matches that have a longer span of non-skipped tokens. + // Optimize for matches that have a longer span of non-skipped terminals. (cur, next) => total_not_skipped_span(cur) < total_not_skipped_span(next), }; @@ -123,7 +125,7 @@ impl ChoiceHelper { } } -/// Returns the total length of the span of tokens that were not skipped. +/// Returns the total length of the span of terminals that were not skipped. pub fn total_not_skipped_span(result: &ParserResult) -> usize { let nodes = match result { ParserResult::Match(match_) => &match_.nodes, diff --git a/crates/solidity/outputs/cargo/slang_solidity/src/generated/parser_support/mod.rs b/crates/solidity/outputs/cargo/slang_solidity/src/generated/parser_support/mod.rs index 2d005d87d3..293665c77d 100644 --- a/crates/solidity/outputs/cargo/slang_solidity/src/generated/parser_support/mod.rs +++ b/crates/solidity/outputs/cargo/slang_solidity/src/generated/parser_support/mod.rs @@ -28,7 +28,7 @@ pub(crate) use parser_result::ParserResult; #[allow(unused_imports)] pub(crate) use precedence_helper::PrecedenceHelper; #[allow(unused_imports)] -pub(crate) use recovery::TokenAcceptanceThreshold; +pub(crate) use recovery::TerminalAcceptanceThreshold; #[allow(unused_imports)] pub(crate) use repetition_helper::{OneOrMoreHelper, ZeroOrMoreHelper}; #[allow(unused_imports)] diff --git a/crates/solidity/outputs/cargo/slang_solidity/src/generated/parser_support/optional_helper.rs b/crates/solidity/outputs/cargo/slang_solidity/src/generated/parser_support/optional_helper.rs index dd933143b6..d8400f1fd6 100644 --- a/crates/solidity/outputs/cargo/slang_solidity/src/generated/parser_support/optional_helper.rs +++ b/crates/solidity/outputs/cargo/slang_solidity/src/generated/parser_support/optional_helper.rs @@ -8,9 +8,9 @@ impl OptionalHelper { pub fn transform(result: ParserResult) -> ParserResult { match result { // If there's absolutely no match, we treat it as a match (for the purposes of the Result algebra) - // but we bubble up the information which tokens would have allowed more progress. + // but we bubble up the information which terminals would have allowed more progress. ParserResult::NoMatch(no_match) => { - ParserResult::r#match(vec![], no_match.expected_tokens) + ParserResult::r#match(vec![], no_match.expected_terminals) } // ... otherwise we return the result as-is ParserResult::Match(_) 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 4721491788..0378a64785 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 @@ -31,7 +31,7 @@ where if let ParserResult::Match(r#match) = &mut result { let [topmost] = r#match.nodes.as_mut_slice() else { unreachable!( - "Match at the top level of a parse does not have exactly one Rule node" + "Match at the top level of a parse does not have exactly one Nonterminal node" ) }; @@ -42,7 +42,7 @@ where _ => None, }; - if let (cst::Node::NonTerminal(nonterminal), Some(eof_trivia)) = + if let (cst::Node::Nonterminal(nonterminal), Some(eof_trivia)) = (&mut topmost.node, eof_trivia) { let mut new_children = nonterminal.children.clone(); @@ -62,22 +62,22 @@ where parse_tree: cst::Node::terminal(TerminalKind::SKIPPED, input.to_string()), errors: vec![ParseError::new( TextIndex::ZERO..input.into(), - no_match.expected_tokens, + no_match.expected_terminals, )], }, some_match => { - let (nodes, expected_tokens) = match some_match { + let (nodes, expected_terminals) = match some_match { ParserResult::PrattOperatorMatch(..) | ParserResult::NoMatch(..) => { unreachable!("Handled above") } ParserResult::Match(Match { nodes, - expected_tokens, + expected_terminals, }) | ParserResult::IncompleteMatch(IncompleteMatch { nodes, - expected_tokens, - }) => (nodes, expected_tokens), + expected_terminals, + }) => (nodes, expected_terminals), ParserResult::SkippedUntil(SkippedUntil { nodes, expected, .. @@ -85,9 +85,9 @@ where }; let topmost_node = match &nodes[..] { - [Edge { node: cst::Node::NonTerminal(nonterminal), ..} ] => Rc::clone(nonterminal), + [Edge { node: cst::Node::Nonterminal(nonterminal), ..} ] => Rc::clone(nonterminal), [_] => unreachable!( - "(Incomplete)Match at the top level of a parser is not a Rule node" + "(Incomplete)Match at the top level of a parser is not a Nonterminal node" ), _ => unreachable!( "(Incomplete)Match at the top level of a parser does not have exactly one node" @@ -111,14 +111,14 @@ where new_children.push(Edge::anonymous(skipped_node)); let mut errors = stream.into_errors(); - errors.push(ParseError::new(start..input.into(), expected_tokens)); + errors.push(ParseError::new(start..input.into(), expected_terminals)); ParseOutput { parse_tree: cst::Node::nonterminal(topmost_node.kind, new_children), errors, } } else { - let parse_tree = cst::Node::NonTerminal(topmost_node); + 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 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 f9a192912e..e4bfc89826 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 @@ -5,7 +5,7 @@ use std::ops::ControlFlow; use metaslang_cst::TerminalKind as _; use crate::cst::{self, Edge, Node}; -use crate::kinds::{EdgeLabel, NonTerminalKind, TerminalKind}; +use crate::kinds::{EdgeLabel, NonterminalKind, TerminalKind}; use crate::text_index::TextIndex; #[derive(PartialEq, Eq, Clone, Debug)] @@ -20,22 +20,22 @@ pub enum ParserResult { impl Default for ParserResult { fn default() -> Self { Self::NoMatch(NoMatch { - expected_tokens: vec![], + expected_terminals: vec![], }) } } impl ParserResult { - pub fn r#match(nodes: Vec, expected_tokens: Vec) -> Self { - ParserResult::Match(Match::new(nodes, expected_tokens)) + pub fn r#match(nodes: Vec, expected_terminals: Vec) -> Self { + ParserResult::Match(Match::new(nodes, expected_terminals)) } pub fn pratt_operator_match(elements: Vec) -> Self { ParserResult::PrattOperatorMatch(PrattOperatorMatch::new(elements)) } - pub fn incomplete_match(nodes: Vec, expected_tokens: Vec) -> Self { - ParserResult::IncompleteMatch(IncompleteMatch::new(nodes, expected_tokens)) + pub fn incomplete_match(nodes: Vec, expected_terminals: Vec) -> Self { + ParserResult::IncompleteMatch(IncompleteMatch::new(nodes, expected_terminals)) } /// Whenever a parser didn't run because it's disabled due to versioning. Shorthand for `no_match(vec![])`. @@ -43,26 +43,26 @@ impl ParserResult { Self::no_match(vec![]) } - pub fn no_match(expected_tokens: Vec) -> Self { - ParserResult::NoMatch(NoMatch::new(expected_tokens)) + pub fn no_match(expected_terminals: Vec) -> Self { + ParserResult::NoMatch(NoMatch::new(expected_terminals)) } #[must_use] - pub fn with_kind(self, new_kind: NonTerminalKind) -> ParserResult { + pub fn with_kind(self, new_kind: NonterminalKind) -> ParserResult { match self { ParserResult::Match(r#match) => ParserResult::r#match( vec![Edge::anonymous(cst::Node::nonterminal( new_kind, r#match.nodes, ))], - r#match.expected_tokens, + r#match.expected_terminals, ), ParserResult::IncompleteMatch(incomplete_match) => ParserResult::incomplete_match( vec![Edge::anonymous(cst::Node::nonterminal( new_kind, incomplete_match.nodes, ))], - incomplete_match.expected_tokens, + incomplete_match.expected_terminals, ), ParserResult::SkippedUntil(skipped) => ParserResult::SkippedUntil(SkippedUntil { nodes: vec![Edge::anonymous(cst::Node::nonterminal( @@ -86,7 +86,7 @@ impl ParserResult { { *prev_label = Some(label); } - // Also allow to name a single trivia token node + // Also allow to name a single trivia terminal node else if let ParserResult::Match(Match { nodes, .. }) = &mut self { if let [node] = nodes.as_mut_slice() { if node.as_terminal().is_some_and(|tok| tok.kind.is_trivia()) { @@ -124,15 +124,15 @@ impl ParserResult { #[derive(PartialEq, Eq, Clone, Debug)] pub struct Match { pub nodes: Vec, - /// Tokens that would have allowed for more progress. Collected for the purposes of error reporting. - pub expected_tokens: Vec, + /// Terminals that would have allowed for more progress. Collected for the purposes of error reporting. + pub expected_terminals: Vec, } impl Match { - pub fn new(nodes: Vec, expected_tokens: Vec) -> Self { + pub fn new(nodes: Vec, expected_terminals: Vec) -> Self { Self { nodes, - expected_tokens, + expected_terminals, } } @@ -150,18 +150,18 @@ pub enum PrattElement { nodes: Vec, }, Prefix { - kind: NonTerminalKind, + kind: NonterminalKind, nodes: Vec, right: u8, }, Binary { - kind: NonTerminalKind, + kind: NonterminalKind, nodes: Vec, left: u8, right: u8, }, Postfix { - kind: NonTerminalKind, + kind: NonterminalKind, nodes: Vec, left: u8, }, @@ -194,20 +194,20 @@ impl PrattOperatorMatch { #[derive(PartialEq, Eq, Clone, Debug)] pub struct IncompleteMatch { pub nodes: Vec, - /// Tokens that would have allowed for more progress. Collected for the purposes of error reporting. - pub expected_tokens: Vec, + /// Terminals that would have allowed for more progress. Collected for the purposes of error reporting. + pub expected_terminals: Vec, } impl IncompleteMatch { - pub fn new(nodes: Vec, expected_tokens: Vec) -> Self { + pub fn new(nodes: Vec, expected_terminals: Vec) -> Self { Self { nodes, - expected_tokens, + expected_terminals, } } - /// Whether this prefix-matched at least `n` (non-skipped) significant tokens. - pub fn matches_at_least_n_tokens(&self, n: u8) -> bool { + /// Whether this prefix-matched at least `n` (non-skipped) significant terminals. + pub fn matches_at_least_n_terminals(&self, n: u8) -> bool { let result = self .nodes .iter() @@ -238,13 +238,13 @@ 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, + /// Terminals that would have allowed for more progress. Collected for the purposes of error reporting. + pub expected_terminals: Vec, } impl NoMatch { - pub fn new(expected_tokens: Vec) -> Self { - Self { expected_tokens } + pub fn new(expected_terminals: Vec) -> Self { + Self { expected_terminals } } } @@ -253,8 +253,8 @@ pub struct SkippedUntil { pub nodes: Vec, /// Skipped text following the last node pub skipped: String, - /// At which token was the stream pointing at when we bailed + /// At which terminal was the stream pointing at when we bailed pub found: TerminalKind, - /// Token we expected to skip until + /// Terminal we expected to skip until 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 7d307a1c0d..28c4a203ec 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, Edge}; -use crate::kinds::{EdgeLabel, NonTerminalKind}; +use crate::kinds::{EdgeLabel, NonterminalKind}; use crate::parser_support::parser_result::PrattElement::{ self, Binary, Expression, Postfix, Prefix, }; @@ -11,7 +11,7 @@ pub struct PrecedenceHelper; impl PrecedenceHelper { pub fn to_prefix_operator( - kind: NonTerminalKind, + kind: NonterminalKind, right: u8, result: ParserResult, ) -> ParserResult { @@ -29,7 +29,7 @@ impl PrecedenceHelper { } pub fn to_postfix_operator( - kind: NonTerminalKind, + kind: NonterminalKind, left: u8, result: ParserResult, ) -> ParserResult { @@ -47,7 +47,7 @@ impl PrecedenceHelper { } pub fn to_binary_operator( - kind: NonTerminalKind, + kind: NonterminalKind, left: u8, right: u8, result: ParserResult, @@ -68,7 +68,7 @@ impl PrecedenceHelper { #[allow(clippy::too_many_lines, clippy::redundant_else)] // Explicit on purpose, see below. pub fn reduce_precedence_result( - child_kind: NonTerminalKind, + child_kind: NonterminalKind, result: ParserResult, ) -> ParserResult { // This requires some careful thinking. It could be more compact, @@ -162,7 +162,7 @@ impl PrecedenceHelper { // 2. Reduce the operator and it's child expressions to a new expression let make_expression = |left: Option, - kind: NonTerminalKind, + kind: NonterminalKind, nodes: Vec, right: Option| { assert!(left.is_some() || right.is_some()); 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 7fceddc3ae..6b336c4a28 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 @@ -2,18 +2,18 @@ use crate::cst; use crate::kinds::{IsLexicalContext, TerminalKind}; -use crate::lexer::{Lexer, ScannedToken}; +use crate::lexer::{Lexer, ScannedTerminal}; use crate::parse_error::ParseError; use crate::parser_support::context::ParserContext; use crate::parser_support::parser_result::SkippedUntil; use crate::parser_support::ParserResult; use crate::text_index::{TextRange, TextRangeExtensions}; -/// How many tokens have to be matched to trigger the error recovery. +/// How many terminals have to be matched to trigger the error recovery. /// For ambiguous syntaxes this needs to be set to at least N, where N -/// is the token lookahead required to disambiguate the syntax. +/// is the terminal lookahead required to disambiguate the syntax. #[derive(Clone, Copy)] -pub(crate) struct TokenAcceptanceThreshold(pub(crate) u8); +pub(crate) struct TerminalAcceptanceThreshold(pub(crate) u8); fn opt_parse( input: &mut ParserContext<'_>, @@ -29,19 +29,19 @@ fn opt_parse( } impl ParserResult { - /// For partial matches (partial prefix match or if the next token after the match is not expected) - /// attempts to skip tokens until a given token is found or until we hit a delimiter that's expected + /// For partial matches (partial prefix match or if the next terminal after the match is not expected) + /// attempts to skip terminals until a given terminal is found or until we hit a delimiter that's expected /// by an outer parse. Returns [`ParserResult::SkippedUntil`] on success. /// - /// Respects nested delimiters, i.e. the `expected` token is only accepted if it's not nested inside. - /// Does not consume the `expected` token. + /// Respects nested delimiters, i.e. the `expected` terminal is only accepted if it's not nested inside. + /// Does not consume the `expected` terminal. #[must_use] pub(crate) fn recover_until_with_nested_delims( self, input: &mut ParserContext<'_>, lexer: &L, expected: TerminalKind, - acceptance_threshold: TokenAcceptanceThreshold, + acceptance_threshold: TerminalAcceptanceThreshold, ) -> ParserResult { enum ParseResultKind { Match, @@ -51,26 +51,30 @@ impl ParserResult { let before_recovery = input.position(); - let (mut nodes, mut expected_tokens, result_kind) = match self { + let (mut nodes, mut expected_terminals, result_kind) = match self { ParserResult::IncompleteMatch(result) - if result.matches_at_least_n_tokens(acceptance_threshold.0) => + if result.matches_at_least_n_terminals(acceptance_threshold.0) => { ( result.nodes, - result.expected_tokens, + result.expected_terminals, ParseResultKind::Incomplete, ) } ParserResult::Match(result) if lexer - .peek_token_with_trivia::(input) - .map(ScannedToken::unambiguous) + .peek_terminal_with_trivia::(input) + .map(ScannedTerminal::unambiguous) != Some(expected) => { - (result.nodes, result.expected_tokens, ParseResultKind::Match) + ( + result.nodes, + result.expected_terminals, + ParseResultKind::Match, + ) } ParserResult::NoMatch(result) if acceptance_threshold.0 == 0 => { - (vec![], result.expected_tokens, ParseResultKind::NoMatch) + (vec![], result.expected_terminals, ParseResultKind::NoMatch) } // No need to recover, so just return as-is. _ => return self, @@ -83,14 +87,14 @@ impl ParserResult { { nodes.extend(leading_trivia); if matches!(result_kind, ParseResultKind::Match) { - expected_tokens.push(expected); + expected_terminals.push(expected); } let skipped = input.content(skipped_range.utf8()); input.emit(ParseError { text_range: skipped_range, - tokens_that_would_have_allowed_more_progress: expected_tokens.clone(), + terminals_that_would_have_allowed_more_progress: expected_terminals.clone(), }); ParserResult::SkippedUntil(SkippedUntil { @@ -104,21 +108,21 @@ impl ParserResult { input.set_position(before_recovery); match result_kind { - ParseResultKind::Match => ParserResult::r#match(nodes, expected_tokens), + ParseResultKind::Match => ParserResult::r#match(nodes, expected_terminals), ParseResultKind::Incomplete => { - ParserResult::incomplete_match(nodes, expected_tokens) + ParserResult::incomplete_match(nodes, expected_terminals) } - ParseResultKind::NoMatch => ParserResult::no_match(expected_tokens), + ParseResultKind::NoMatch => ParserResult::no_match(expected_terminals), } } } } -/// Skips tokens until a given token is found or until we hit a closing delimiter that's expected by an outer parse. -/// Respects nested delimiters, i.e. the `expected` token is only accepted if it's not nested inside. -/// Does not consume the `expected` token. +/// Skips terminals until a given terminal is found or until we hit a closing delimiter that's expected by an outer parse. +/// Respects nested delimiters, i.e. the `expected` terminal is only accepted if it's not nested inside. +/// Does not consume the `expected` terminal. /// -/// Returns the found token and the range of skipped tokens on success. +/// Returns the found terminal and the range of skipped terminals on success. pub(crate) fn skip_until_with_nested_delims( input: &mut ParserContext<'_>, lexer: &L, @@ -132,27 +136,27 @@ pub(crate) fn skip_until_with_nested_delims( loop { let save = input.position(); match lexer - .next_token::(input) - .map(ScannedToken::unambiguous) + .next_terminal::(input) + .map(ScannedTerminal::unambiguous) { // If we're not skipping past a local delimited group (delimiter stack is empty), - // we can unwind on a token that's expected by us or by our ancestor. - Some(token) + // we can unwind on a terminal that's expected by us or by our ancestor. + Some(terminal) if local_delims.is_empty() - && (token == until || input.closing_delimiters().contains(&token)) => + && (terminal == until || input.closing_delimiters().contains(&terminal)) => { // Don't consume the delimiter; parent will consume it input.set_position(save); - return Some((token, start..save)); + return Some((terminal, start..save)); } // Found the local closing delimiter, pop the stack - Some(token) if local_delims.last() == Some(&token) => { + Some(terminal) if local_delims.last() == Some(&terminal) => { local_delims.pop(); } - Some(token) => { + Some(terminal) => { // Found a local opening delimiter, skip until we find a closing one - if let Some((_, close)) = delims.iter().find(|(op, _)| token == *op) { + if let Some((_, close)) = delims.iter().find(|(op, _)| terminal == *op) { local_delims.push(*close); } else { // Keep eating (eventually hits EOF) diff --git a/crates/solidity/outputs/cargo/slang_solidity/src/generated/parser_support/repetition_helper.rs b/crates/solidity/outputs/cargo/slang_solidity/src/generated/parser_support/repetition_helper.rs index 91438e0bf0..d07108f65a 100644 --- a/crates/solidity/outputs/cargo/slang_solidity/src/generated/parser_support/repetition_helper.rs +++ b/crates/solidity/outputs/cargo/slang_solidity/src/generated/parser_support/repetition_helper.rs @@ -25,9 +25,9 @@ impl RepetitionHelper { result @ ParserResult::SkippedUntil(_) => return result, // Couldn't get a full match but we allow 0 items - return an empty match - // so the parse is considered valid but note the expected tokens - ParserResult::NoMatch(NoMatch { expected_tokens }) if MIN_COUNT == 0 => { - return ParserResult::r#match(vec![], expected_tokens); + // so the parse is considered valid but note the expected terminals + ParserResult::NoMatch(NoMatch { expected_terminals }) if MIN_COUNT == 0 => { + return ParserResult::r#match(vec![], expected_terminals); } // Don't try repeating if we don't have a full match and we require at least one incomplete_or_no_match => return incomplete_or_no_match, @@ -40,7 +40,7 @@ impl RepetitionHelper { match (&mut accum, next_result) { (ParserResult::Match(running), ParserResult::Match(next)) => { running.nodes.extend(next.nodes); - running.expected_tokens = next.expected_tokens; + running.expected_terminals = next.expected_terminals; } (ParserResult::PrattOperatorMatch(cur), ParserResult::PrattOperatorMatch(next)) => { @@ -54,16 +54,16 @@ impl RepetitionHelper { "Match seen while repeating PrattOperatorMatches in RepetitionHelper" ), // Can't proceed further with a complete parse, so back up, return - // the accumulated result and note the expected tokens + // the accumulated result and note the expected terminals ( ParserResult::Match(running), ParserResult::IncompleteMatch(IncompleteMatch { - expected_tokens, .. + expected_terminals, .. }) - | ParserResult::NoMatch(NoMatch { expected_tokens }), + | ParserResult::NoMatch(NoMatch { expected_terminals }), ) => { input.rewind(save); - running.expected_tokens = expected_tokens; + running.expected_terminals = expected_terminals; return accum; } 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 0c87c6aea2..eb6cdf67f2 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 @@ -25,10 +25,10 @@ impl SeparatedHelper { ParserResult::Match(r#match) => { accum.extend(r#match.nodes); - match lexer.peek_token_with_trivia::(input) { + match lexer.peek_terminal_with_trivia::(input) { Some(scanned) if scanned.accepted_as(separator) => { match lexer - .parse_token_with_trivia::(input, separator) + .parse_terminal_with_trivia::(input, separator) .with_label(separator_label) { ParserResult::Match(r#match) => { @@ -41,12 +41,12 @@ impl SeparatedHelper { // Unrecognized, return the accumulated matches. // NOTE: We can't correctly attempt recovery until #600 lands, otherwise we'd risk misparses, - // as we need to stop at certain synchronizing tokens (and we can't reliably scan until + // as we need to stop at certain synchronizing terminals (and we can't reliably scan until // a delimiter, as not every list is enclosed in a delimited group). Some(..) | None => return ParserResult::r#match(accum, vec![separator]), } } - // Body was partially parsed, so try to recover by skipping tokens until we see a separator + // Body was partially parsed, so try to recover by skipping terminals until we see a separator ParserResult::IncompleteMatch(incomplete) => { accum.extend(incomplete.nodes); @@ -61,11 +61,11 @@ impl SeparatedHelper { ))); input.emit(ParseError { text_range: skipped_range, - tokens_that_would_have_allowed_more_progress: incomplete - .expected_tokens, + terminals_that_would_have_allowed_more_progress: incomplete + .expected_terminals, }); - match lexer.parse_token_with_trivia::(input, separator) { + match lexer.parse_terminal_with_trivia::(input, separator) { ParserResult::Match(r#match) => { accum.extend(r#match.nodes); continue; @@ -82,16 +82,16 @@ impl SeparatedHelper { return ParserResult::incomplete_match( accum, - incomplete.expected_tokens, + incomplete.expected_terminals, ); } } } ParserResult::NoMatch(no_match) => { return if accum.is_empty() { - ParserResult::no_match(no_match.expected_tokens) + ParserResult::no_match(no_match.expected_terminals) } else { - ParserResult::incomplete_match(accum, no_match.expected_tokens) + ParserResult::incomplete_match(accum, no_match.expected_terminals) }; } 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 cd455cfcab..36ff4f3478 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 @@ -51,7 +51,7 @@ impl SequenceHelper { // Keep accepting or convert into PrattOperatorMatch (ParserResult::Match(running), ParserResult::Match(next)) => { running.nodes.extend(next.nodes); - running.expected_tokens = next.expected_tokens; + running.expected_terminals = next.expected_terminals; } (ParserResult::Match(running), ParserResult::PrattOperatorMatch(next)) => { let mut children = vec![PrattElement::Expression { @@ -65,15 +65,15 @@ impl SequenceHelper { running.nodes.extend(next.nodes); self.result = State::Running(ParserResult::incomplete_match( std::mem::take(&mut running.nodes), - next.expected_tokens, + next.expected_terminals, )); } (ParserResult::Match(running), ParserResult::NoMatch(next)) => { - running.expected_tokens.extend(next.expected_tokens); + running.expected_terminals.extend(next.expected_terminals); self.result = State::Running(ParserResult::incomplete_match( std::mem::take(&mut running.nodes), - std::mem::take(&mut running.expected_tokens), + std::mem::take(&mut running.expected_terminals), )); } // Keep accepting or convert Match -> PrattOperatorMatch @@ -95,7 +95,7 @@ impl SequenceHelper { .flat_map(PrattElement::into_nodes) .chain(next.nodes) .collect(), - next.expected_tokens, + next.expected_terminals, )); } (ParserResult::PrattOperatorMatch(cur), ParserResult::NoMatch(next)) => { @@ -104,7 +104,7 @@ impl SequenceHelper { .into_iter() .flat_map(PrattElement::into_nodes) .collect(), - next.expected_tokens, + next.expected_terminals, )); } // Enter recovery mode @@ -119,35 +119,35 @@ impl SequenceHelper { (ParserResult::PrattOperatorMatch(_), ParserResult::SkippedUntil(_)) => unreachable!("Error recovery happens outside precedence parsing"), - // Try to recover until we hit an expected boundary token. + // Try to recover until we hit an expected boundary terminal. // If the sequence is unwinding, then a subsequent non-empty match must mean that - // we found the expected token, so we can stop recovering. + // we found the expected terminal, so we can stop recovering. (ParserResult::SkippedUntil(running), ParserResult::Match(next)) => { if next.nodes.is_empty() { return; } - // We only support skipping to a single, significant token. + // We only support skipping to a single, significant terminal. // Sanity check that we are recovering to the expected one. - let next_token = next.nodes.iter().try_fold(None, |acc, node| { + let next_terminal = next.nodes.iter().try_fold(None, |acc, node| { match &**node { - cst::Node::Terminal(token) if token.kind.is_trivia() => Ok(acc), - cst::Node::Terminal(token) => { + cst::Node::Terminal(terminal) if terminal.kind.is_trivia() => Ok(acc), + cst::Node::Terminal(terminal) => { match acc { - None => Ok(Some(token.kind)), + None => Ok(Some(terminal.kind)), Some(..) => { - debug_assert!(false, "Recovery skipped to multiple tokens: {acc:?}, {token:?}"); + debug_assert!(false, "Recovery skipped to multiple terminals: {acc:?}, {terminal:?}"); Err(()) } } } - cst::Node::NonTerminal(node) => { + cst::Node::Nonterminal(node) => { debug_assert!(false, "Recovery skipped to a nonterminal: {node:?}"); Err(()) } } }); - debug_assert_eq!(next_token, Ok(Some(running.found))); + debug_assert_eq!(next_terminal, Ok(Some(running.found))); running.nodes.push(Edge::anonymous(cst::Node::terminal( TerminalKind::SKIPPED, @@ -157,17 +157,17 @@ impl SequenceHelper { self.result = State::Running(ParserResult::Match(Match { nodes: std::mem::take(&mut running.nodes), - expected_tokens: next.expected_tokens, + expected_terminals: next.expected_terminals, })); } // If the sequence is unwinding and and we didn't find a match, then it means // that we recovered past it and we need to push the recovery up. (ParserResult::SkippedUntil(_), ParserResult::NoMatch(_)) => { // Skip any possible subsequent expected elements in this sequence until - // we finally encounter the token we were looking for + // we finally encounter the terminal we were looking for } (ParserResult::SkippedUntil(_), _) => unreachable!( - "Only a single token parse can immediately follow SkippedUntil in sequences and these can either be Match or NoMatch" + "Only a single terminal parse can immediately follow SkippedUntil in sequences and these can either be Match or NoMatch" ), }, } diff --git a/crates/solidity/outputs/cargo/slang_solidity/src/main.rs b/crates/solidity/outputs/cargo/slang_solidity/src/main.rs index f7c60a4469..1ba81fd09b 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::NonTerminalKind; +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(NonTerminalKind::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 93fd99b0bf..1a043b48c6 100644 --- a/crates/solidity/outputs/cargo/tests/src/cst_output/renderer.rs +++ b/crates/solidity/outputs/cargo/tests/src/cst_output/renderer.rs @@ -9,7 +9,7 @@ use inflector::Inflector; use once_cell::sync::Lazy; use slang_solidity::cst::Node; use slang_solidity::cursor::CursorWithEdges; -use slang_solidity::kinds::NonTerminalKind; +use slang_solidity::kinds::NonterminalKind; use slang_solidity::text_index::TextRangeExtensions; use solidity_language::SolidityDefinition; @@ -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::NonTerminal(rule) if rule.children.len() == 1 && !NON_INLINABLE.contains(&rule.kind)) + if matches!(cursor.node(), Node::Nonterminal(nonterminal) if nonterminal.children.len() == 1 && !NON_INLINABLE.contains(&nonterminal.kind)) { let parent_range = cursor.text_range(); assert!(cursor.go_to_next()); @@ -136,7 +136,7 @@ fn write_node( fn render_key(cursor: &mut CursorWithEdges) -> String { let kind = match cursor.node() { - Node::NonTerminal(nonterminal) => nonterminal.kind.to_string(), + Node::Nonterminal(nonterminal) => nonterminal.kind.to_string(), Node::Terminal(terminal) => terminal.kind.to_string(), }; @@ -157,8 +157,10 @@ fn render_value(cursor: &mut CursorWithEdges, source: &str) -> String { let preview = render_preview(source, &char_range); match cursor.node() { - Node::NonTerminal(rule) if rule.children.is_empty() => format!("[] # ({utf8_range:?})"), - Node::NonTerminal(_) => format!("# {preview} ({utf8_range:?})"), + Node::Nonterminal(nonterminal) if nonterminal.children.is_empty() => { + format!("[] # ({utf8_range:?})") + } + Node::Nonterminal(_) => format!("# {preview} ({utf8_range:?})"), Node::Terminal(_) => format!("{preview} # ({utf8_range:?})"), } } @@ -195,7 +197,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() { @@ -205,7 +207,7 @@ static NON_INLINABLE: Lazy> = Lazy::new(|| { kinds.insert(item.name().parse().unwrap()); } Item::Struct { .. } | Item::Enum { .. } | Item::Precedence { .. } => { - // These non-terminals can be inlined if they have a single child. + // These nonterminals can be inlined if they have a single child. // Note: same goes for 'PrecedenceExpression' items under each 'Precedence' item. } Item::Trivia { .. } 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 42ce5dedde..3ef9f30fa5 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::NonTerminalKind; +use slang_solidity::kinds::NonterminalKind; use slang_solidity::language::Language; use strum_macros::Display; @@ -34,10 +34,10 @@ pub fn run(parser_name: &str, test_name: &str) -> Result<()> { let mut last_output = None; for version in VERSION_BREAKS { - let tested_rule_kind = NonTerminalKind::from_str(parser_name) + let tested_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); + let output = Language::new(version.clone())?.parse(tested_kind, &source); let output = match last_output { // Skip this version if it produces the same output. 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 29bbb2a0b3..e36df96531 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::NonTerminalKind; +use slang_solidity::kinds::NonterminalKind; use slang_solidity::language::Language; use slang_solidity::query::{Query, QueryMatchIterator}; @@ -19,7 +19,7 @@ impl RemoveMkdocSnippetMarkers for &str { } } -fn assert_matches(query: &Query, kind: NonTerminalKind, source: &str) -> QueryMatchIterator { +fn assert_matches(query: &Query, kind: NonterminalKind, source: &str) -> QueryMatchIterator { 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, NonTerminalKind::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, NonTerminalKind::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, NonTerminalKind::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, NonTerminalKind::MultiplicativeExpression, "1*2"); + assert_matches(&query, NonterminalKind::MultiplicativeExpression, "1*2"); let query = Query::parse( &" @@ -92,12 +92,12 @@ fn query_syntax() { .unwrap(); assert_matches( &query, - NonTerminalKind::MultiplicativeExpression, + NonterminalKind::MultiplicativeExpression, "1 * 'abc'", ); assert_matches( &query, - NonTerminalKind::MultiplicativeExpression, + NonterminalKind::MultiplicativeExpression, "'abc' * 1", ); } @@ -114,7 +114,7 @@ fn capturing_nodes() { ) .unwrap(); - assert_matches(&query, NonTerminalKind::StructDefinition, "struct Abc {}"); + assert_matches(&query, NonterminalKind::StructDefinition, "struct Abc {}"); let query = Query::parse( &" @@ -144,7 +144,7 @@ fn capturing_nodes() { assert_matches( &query, - NonTerminalKind::ContractDefinition, + NonterminalKind::ContractDefinition, "contract A { event A(); }", ); } @@ -163,7 +163,7 @@ fn quantification() { assert_matches( &query, - NonTerminalKind::SourceUnit, + NonterminalKind::SourceUnit, "// comment 1\n// comment 2\n/* comment 3 */", ); @@ -185,7 +185,7 @@ fn quantification() { assert_matches( &query, - NonTerminalKind::SourceUnit, + NonterminalKind::SourceUnit, " /// A doc comment contract A {} @@ -219,15 +219,15 @@ fn quantification() { let iter = assert_matches( &query, - NonTerminalKind::FunctionCallExpression, + NonterminalKind::FunctionCallExpression, " call(1, 'abc', 3) ", ); - let results: Vec<_> = iter.collect(); + let matches: Vec<_> = iter.collect(); - results[3].captures.get("arg").unwrap(); + matches[3].captures.get("arg").unwrap(); } #[test] @@ -248,12 +248,12 @@ fn alternations() { ) .unwrap(); - let results: Vec<_> = - assert_matches(&query, NonTerminalKind::FunctionCallExpression, "call(1)").collect(); - results.first().unwrap().captures.get("function").unwrap(); - let results: Vec<_> = - assert_matches(&query, NonTerminalKind::FunctionCallExpression, "a.call(1)").collect(); - results.first().unwrap().captures.get("method").unwrap(); + let matches: Vec<_> = + assert_matches(&query, NonterminalKind::FunctionCallExpression, "call(1)").collect(); + matches.first().unwrap().captures.get("function").unwrap(); + let matches: Vec<_> = + assert_matches(&query, NonterminalKind::FunctionCallExpression, "a.call(1)").collect(); + matches.first().unwrap().captures.get("method").unwrap(); let query = Query::parse( &r#" @@ -275,18 +275,18 @@ fn alternations() { ) .unwrap(); - let iter = assert_matches(&query, NonTerminalKind::IfStatement, "if (true) { break; }"); + let iter = assert_matches(&query, NonterminalKind::IfStatement, "if (true) { break; }"); - let results: Vec<_> = iter.collect(); - assert_eq!(results.len(), 2); + let matches: Vec<_> = iter.collect(); + assert_eq!(matches.len(), 2); assert_eq!( - results[0].captures.get("keyword").unwrap()[0] + matches[0].captures.get("keyword").unwrap()[0] .node() .unparse(), "if" ); assert_eq!( - results[1].captures.get("keyword").unwrap()[0] + matches[1].captures.get("keyword").unwrap()[0] .node() .unparse(), "break" 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 b87ea07aa1..dc29c26a6d 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::NonTerminalKind; +use slang_solidity::kinds::NonterminalKind; use slang_solidity::language::Language; use slang_solidity::parse_output::ParseOutput; use slang_solidity::query::{Query, QueryMatchIterator}; @@ -15,7 +15,7 @@ fn parse_doc_input_file>(path: T) -> Result { let language = Language::new(Version::new(0, 8, 0))?; - Ok(language.parse(NonTerminalKind::SourceUnit, source.trim())) + Ok(language.parse(NonterminalKind::SourceUnit, source.trim())) } #[test] @@ -42,9 +42,9 @@ fn using_queries() -> Result<()> { let query = Query::parse("@contract [ContractDefinition]").unwrap(); - for result in cursor.query(vec![query]) { - let bindings = result.captures; - let cursors = bindings.get("contract").unwrap(); + for r#match in cursor.query(vec![query]) { + let captures = r#match.captures; + let cursors = captures.get("contract").unwrap(); let cursor = cursors.first().unwrap(); @@ -67,10 +67,10 @@ fn using_queries() -> Result<()> { let struct_def = Query::parse("[StructDefinition ... @name [Identifier] ...]").unwrap(); let enum_def = Query::parse("[EnumDefinition ... @name [Identifier] ...]").unwrap(); - for result in cursor.query(vec![struct_def, enum_def]) { - let index = result.query_number; - let bindings = result.captures; - let cursors = bindings.get("name").unwrap(); + for r#match in cursor.query(vec![struct_def, enum_def]) { + let index = r#match.query_number; + let captures = r#match.captures; + let cursors = captures.get("name").unwrap(); let cursor = cursors.first().unwrap(); @@ -98,9 +98,9 @@ fn using_queries() -> Result<()> { let query = Query::parse("[TypedTupleMember ... @type type_name:[_] ...]").unwrap(); - for result in cursor.query(vec![query]) { - let bindings = result.captures; - let cursors = bindings.get("type").unwrap(); + for r#match in cursor.query(vec![query]) { + let captures = r#match.captures; + let cursors = captures.get("type").unwrap(); let cursor = cursors.first().unwrap(); @@ -121,9 +121,9 @@ fn using_queries() -> Result<()> { let query = Query::parse(r#"[ElementaryType @uint_keyword variant:["uint"]]"#).unwrap(); - for result in cursor.query(vec![query]) { - let bindings = result.captures; - let cursors = bindings.get("uint_keyword").unwrap(); + for r#match in cursor.query(vec![query]) { + let captures = r#match.captures; + let cursors = captures.get("uint_keyword").unwrap(); let cursor = cursors.first().unwrap(); @@ -162,9 +162,9 @@ fn tx_origin_query() -> Result<()> { let mut results = vec![]; - for result in cursor.query(vec![query]) { - let bindings = result.captures; - let cursors = bindings.get("txorigin").unwrap(); + for r#match in cursor.query(vec![query]) { + let captures = r#match.captures; + let cursors = captures.get("txorigin").unwrap(); let cursor = cursors.first().unwrap(); 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 2df2309df9..a5b5151aec 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::{EdgeLabel, NonTerminalKind, TerminalKind}; + 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(NonTerminalKind::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_nonterminal_with_kind(NonTerminalKind::ContractDefinition) { + while cursor.go_to_next_nonterminal_with_kind(NonterminalKind::ContractDefinition) { assert!(cursor.go_to_first_child()); assert!(cursor.go_to_next_terminal_with_kind(TerminalKind::Identifier)); - let token_node = cursor.node(); - contracts.push(token_node.as_terminal().unwrap().text.clone()); + let terminal_node = cursor.node(); + contracts.push(terminal_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_nonterminal_with_kind(NonTerminalKind::ContractDefinition) { + while cursor.go_to_next_nonterminal_with_kind(NonterminalKind::ContractDefinition) { let mut child_cursor = cursor.spawn(); assert!(child_cursor.go_to_next_terminal_with_kind(TerminalKind::Identifier)); - let token_node = child_cursor.node(); - contracts.push(token_node.as_terminal().unwrap().text.clone()); + let terminal_node = child_cursor.node(); + contracts.push(terminal_node.as_terminal().unwrap().text.clone()); } assert_eq!(contracts, &["Foo", "Bar", "Baz"]); @@ -70,7 +70,7 @@ fn using_the_cursor() -> Result<()> { let mut cursor = parse_output.create_tree_cursor(); - while cursor.go_to_next_nonterminal_with_kind(NonTerminalKind::ContractDefinition) { + while cursor.go_to_next_nonterminal_with_kind(NonterminalKind::ContractDefinition) { let range = cursor.text_range().utf8(); let text = Rc::clone(cursor.node().as_nonterminal().unwrap()).unparse(); 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 16e9ece4ae..825b8a39b3 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::{NonTerminalKind, TerminalKind}; + 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(NonTerminalKind::ContractDefinition, source); + let parse_output = language.parse(NonterminalKind::ContractDefinition, source); // --8<-- [end:parse-input] // --8<-- [start:print-errors] @@ -39,7 +39,7 @@ fn using_the_parser() -> Result<()> { let parse_tree = parse_output.tree(); let contract = parse_tree.as_nonterminal().unwrap(); - assert_eq!(contract.kind, NonTerminalKind::ContractDefinition); + assert_eq!(contract.kind, NonterminalKind::ContractDefinition); assert_eq!(contract.children.len(), 7); let children = &contract.children; @@ -51,7 +51,7 @@ fn using_the_parser() -> Result<()> { 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) + 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] diff --git a/crates/solidity/outputs/cargo/tests/src/trivia.rs b/crates/solidity/outputs/cargo/tests/src/trivia.rs index 02ce1dc2d5..34e800188b 100644 --- a/crates/solidity/outputs/cargo/tests/src/trivia.rs +++ b/crates/solidity/outputs/cargo/tests/src/trivia.rs @@ -1,20 +1,20 @@ use anyhow::Result; use semver::Version; use slang_solidity::cst::Node; -use slang_solidity::kinds::{NonTerminalKind, TerminalKind}; +use slang_solidity::kinds::{NonterminalKind, TerminalKind}; use slang_solidity::language::Language; #[test] fn end_of_line() -> Result<()> { - // Only one is valid as a single token: + // Only one is valid as a single terminal: compare_end_of_lines("\r", &["\r"])?; compare_end_of_lines("\n", &["\n"])?; - // Two of the same are two tokens: + // Two of the same are two terminals: compare_end_of_lines("\n\n", &["\n", "\n"])?; compare_end_of_lines("\r\r", &["\r", "\r"])?; - // A carriage return followed by a newline is one token, but the opposite is not: + // A carriage return followed by a newline is one terminal, but the opposite is not: compare_end_of_lines("\r\n", &["\r\n"])?; compare_end_of_lines("\n\r", &["\n", "\r"])?; @@ -25,17 +25,17 @@ 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(NonTerminalKind::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::NonTerminal(_) => None, + Node::Nonterminal(_) => None, - Node::Terminal(token) => { - assert_eq!(token.kind, TerminalKind::EndOfLine); - Some(token.text.clone()) + Node::Terminal(terminal) => { + assert_eq!(terminal.kind, TerminalKind::EndOfLine); + Some(terminal.text.clone()) } }) .collect::>(); 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 cd61b8d60a..3842274cd9 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 { NonTerminalNode, TerminalNode } from "../../cst"; -import { NonTerminalKind, TerminalKind } 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 NonTerminalNode), + members: new SourceUnitMembers($members as NonterminalNode), }; }); - public constructor(public readonly cst: NonTerminalNode) { - assertKind(this.cst.kind, NonTerminalKind.SourceUnit); + public constructor(public readonly cst: NonterminalNode) { + assertKind(this.cst.kind, NonterminalKind.SourceUnit); } public get members(): SourceUnitMembers { @@ -33,13 +33,13 @@ export class PragmaDirective { return { pragmaKeyword: $pragmaKeyword as TerminalNode, - pragma: new Pragma($pragma as NonTerminalNode), + pragma: new Pragma($pragma as NonterminalNode), semicolon: $semicolon as TerminalNode, }; }); - public constructor(public readonly cst: NonTerminalNode) { - assertKind(this.cst.kind, NonTerminalKind.PragmaDirective); + public constructor(public readonly cst: NonterminalNode) { + assertKind(this.cst.kind, NonterminalKind.PragmaDirective); } public get pragmaKeyword(): TerminalNode { @@ -65,8 +65,8 @@ export class ABICoderPragma { }; }); - public constructor(public readonly cst: NonTerminalNode) { - assertKind(this.cst.kind, NonTerminalKind.ABICoderPragma); + public constructor(public readonly cst: NonterminalNode) { + assertKind(this.cst.kind, NonterminalKind.ABICoderPragma); } public get abicoderKeyword(): TerminalNode { @@ -84,12 +84,12 @@ export class ExperimentalPragma { return { experimentalKeyword: $experimentalKeyword as TerminalNode, - feature: new ExperimentalFeature($feature as NonTerminalNode), + feature: new ExperimentalFeature($feature as NonterminalNode), }; }); - public constructor(public readonly cst: NonTerminalNode) { - assertKind(this.cst.kind, NonTerminalKind.ExperimentalPragma); + public constructor(public readonly cst: NonterminalNode) { + assertKind(this.cst.kind, NonterminalKind.ExperimentalPragma); } public get experimentalKeyword(): TerminalNode { @@ -107,12 +107,12 @@ export class VersionPragma { return { solidityKeyword: $solidityKeyword as TerminalNode, - sets: new VersionExpressionSets($sets as NonTerminalNode), + sets: new VersionExpressionSets($sets as NonterminalNode), }; }); - public constructor(public readonly cst: NonTerminalNode) { - assertKind(this.cst.kind, NonTerminalKind.VersionPragma); + public constructor(public readonly cst: NonterminalNode) { + assertKind(this.cst.kind, NonterminalKind.VersionPragma); } public get solidityKeyword(): TerminalNode { @@ -129,14 +129,14 @@ export class VersionRange { const [$leftOperand, $operator, $rightOperand] = ast_internal.selectSequence(this.cst); return { - leftOperand: new VersionExpression($leftOperand as NonTerminalNode), + leftOperand: new VersionExpression($leftOperand as NonterminalNode), operator: $operator as TerminalNode, - rightOperand: new VersionExpression($rightOperand as NonTerminalNode), + rightOperand: new VersionExpression($rightOperand as NonterminalNode), }; }); - public constructor(public readonly cst: NonTerminalNode) { - assertKind(this.cst.kind, NonTerminalKind.VersionRange); + public constructor(public readonly cst: NonterminalNode) { + assertKind(this.cst.kind, NonterminalKind.VersionRange); } public get leftOperand(): VersionExpression { @@ -158,12 +158,12 @@ export class VersionComparator { return { operator: $operator as TerminalNode, - operand: new VersionExpression($operand as NonTerminalNode), + operand: new VersionExpression($operand as NonterminalNode), }; }); - public constructor(public readonly cst: NonTerminalNode) { - assertKind(this.cst.kind, NonTerminalKind.VersionComparator); + public constructor(public readonly cst: NonterminalNode) { + assertKind(this.cst.kind, NonterminalKind.VersionComparator); } public get operator(): TerminalNode { @@ -181,13 +181,13 @@ export class ImportDirective { return { importKeyword: $importKeyword as TerminalNode, - clause: new ImportClause($clause as NonTerminalNode), + clause: new ImportClause($clause as NonterminalNode), semicolon: $semicolon as TerminalNode, }; }); - public constructor(public readonly cst: NonTerminalNode) { - assertKind(this.cst.kind, NonTerminalKind.ImportDirective); + public constructor(public readonly cst: NonterminalNode) { + assertKind(this.cst.kind, NonterminalKind.ImportDirective); } public get importKeyword(): TerminalNode { @@ -208,13 +208,13 @@ export class PathImport { const [$path, $alias] = ast_internal.selectSequence(this.cst); return { - path: new StringLiteral($path as NonTerminalNode), - alias: $alias === null ? undefined : new ImportAlias($alias as NonTerminalNode), + path: new StringLiteral($path as NonterminalNode), + alias: $alias === null ? undefined : new ImportAlias($alias as NonterminalNode), }; }); - public constructor(public readonly cst: NonTerminalNode) { - assertKind(this.cst.kind, NonTerminalKind.PathImport); + public constructor(public readonly cst: NonterminalNode) { + assertKind(this.cst.kind, NonterminalKind.PathImport); } public get path(): StringLiteral { @@ -232,14 +232,14 @@ export class NamedImport { return { asterisk: $asterisk as TerminalNode, - alias: new ImportAlias($alias as NonTerminalNode), + alias: new ImportAlias($alias as NonterminalNode), fromKeyword: $fromKeyword as TerminalNode, - path: new StringLiteral($path as NonTerminalNode), + path: new StringLiteral($path as NonterminalNode), }; }); - public constructor(public readonly cst: NonTerminalNode) { - assertKind(this.cst.kind, NonTerminalKind.NamedImport); + public constructor(public readonly cst: NonterminalNode) { + assertKind(this.cst.kind, NonterminalKind.NamedImport); } public get asterisk(): TerminalNode { @@ -265,15 +265,15 @@ export class ImportDeconstruction { return { openBrace: $openBrace as TerminalNode, - symbols: new ImportDeconstructionSymbols($symbols as NonTerminalNode), + symbols: new ImportDeconstructionSymbols($symbols as NonterminalNode), closeBrace: $closeBrace as TerminalNode, fromKeyword: $fromKeyword as TerminalNode, - path: new StringLiteral($path as NonTerminalNode), + path: new StringLiteral($path as NonterminalNode), }; }); - public constructor(public readonly cst: NonTerminalNode) { - assertKind(this.cst.kind, NonTerminalKind.ImportDeconstruction); + public constructor(public readonly cst: NonterminalNode) { + assertKind(this.cst.kind, NonterminalKind.ImportDeconstruction); } public get openBrace(): TerminalNode { @@ -303,12 +303,12 @@ export class ImportDeconstructionSymbol { return { name: $name as TerminalNode, - alias: $alias === null ? undefined : new ImportAlias($alias as NonTerminalNode), + alias: $alias === null ? undefined : new ImportAlias($alias as NonterminalNode), }; }); - public constructor(public readonly cst: NonTerminalNode) { - assertKind(this.cst.kind, NonTerminalKind.ImportDeconstructionSymbol); + public constructor(public readonly cst: NonterminalNode) { + assertKind(this.cst.kind, NonterminalKind.ImportDeconstructionSymbol); } public get name(): TerminalNode { @@ -330,8 +330,8 @@ export class ImportAlias { }; }); - public constructor(public readonly cst: NonTerminalNode) { - assertKind(this.cst.kind, NonTerminalKind.ImportAlias); + public constructor(public readonly cst: NonterminalNode) { + assertKind(this.cst.kind, NonterminalKind.ImportAlias); } public get asKeyword(): TerminalNode { @@ -351,16 +351,16 @@ export class UsingDirective { return { usingKeyword: $usingKeyword as TerminalNode, - clause: new UsingClause($clause as NonTerminalNode), + clause: new UsingClause($clause as NonterminalNode), forKeyword: $forKeyword as TerminalNode, - target: new UsingTarget($target as NonTerminalNode), + target: new UsingTarget($target as NonterminalNode), globalKeyword: $globalKeyword === null ? undefined : ($globalKeyword as TerminalNode), semicolon: $semicolon as TerminalNode, }; }); - public constructor(public readonly cst: NonTerminalNode) { - assertKind(this.cst.kind, NonTerminalKind.UsingDirective); + public constructor(public readonly cst: NonterminalNode) { + assertKind(this.cst.kind, NonterminalKind.UsingDirective); } public get usingKeyword(): TerminalNode { @@ -394,13 +394,13 @@ export class UsingDeconstruction { return { openBrace: $openBrace as TerminalNode, - symbols: new UsingDeconstructionSymbols($symbols as NonTerminalNode), + symbols: new UsingDeconstructionSymbols($symbols as NonterminalNode), closeBrace: $closeBrace as TerminalNode, }; }); - public constructor(public readonly cst: NonTerminalNode) { - assertKind(this.cst.kind, NonTerminalKind.UsingDeconstruction); + public constructor(public readonly cst: NonterminalNode) { + assertKind(this.cst.kind, NonterminalKind.UsingDeconstruction); } public get openBrace(): TerminalNode { @@ -421,13 +421,13 @@ export class UsingDeconstructionSymbol { const [$name, $alias] = ast_internal.selectSequence(this.cst); return { - name: new IdentifierPath($name as NonTerminalNode), - alias: $alias === null ? undefined : new UsingAlias($alias as NonTerminalNode), + name: new IdentifierPath($name as NonterminalNode), + alias: $alias === null ? undefined : new UsingAlias($alias as NonterminalNode), }; }); - public constructor(public readonly cst: NonTerminalNode) { - assertKind(this.cst.kind, NonTerminalKind.UsingDeconstructionSymbol); + public constructor(public readonly cst: NonterminalNode) { + assertKind(this.cst.kind, NonterminalKind.UsingDeconstructionSymbol); } public get name(): IdentifierPath { @@ -445,12 +445,12 @@ export class UsingAlias { return { asKeyword: $asKeyword as TerminalNode, - operator: new UsingOperator($operator as NonTerminalNode), + operator: new UsingOperator($operator as NonterminalNode), }; }); - public constructor(public readonly cst: NonTerminalNode) { - assertKind(this.cst.kind, NonTerminalKind.UsingAlias); + public constructor(public readonly cst: NonterminalNode) { + assertKind(this.cst.kind, NonterminalKind.UsingAlias); } public get asKeyword(): TerminalNode { @@ -471,15 +471,15 @@ export class ContractDefinition { abstractKeyword: $abstractKeyword === null ? undefined : ($abstractKeyword as TerminalNode), contractKeyword: $contractKeyword as TerminalNode, name: $name as TerminalNode, - inheritence: $inheritence === null ? undefined : new InheritanceSpecifier($inheritence as NonTerminalNode), + inheritence: $inheritence === null ? undefined : new InheritanceSpecifier($inheritence as NonterminalNode), openBrace: $openBrace as TerminalNode, - members: new ContractMembers($members as NonTerminalNode), + members: new ContractMembers($members as NonterminalNode), closeBrace: $closeBrace as TerminalNode, }; }); - public constructor(public readonly cst: NonTerminalNode) { - assertKind(this.cst.kind, NonTerminalKind.ContractDefinition); + public constructor(public readonly cst: NonterminalNode) { + assertKind(this.cst.kind, NonterminalKind.ContractDefinition); } public get abstractKeyword(): TerminalNode | undefined { @@ -517,12 +517,12 @@ export class InheritanceSpecifier { return { isKeyword: $isKeyword as TerminalNode, - types: new InheritanceTypes($types as NonTerminalNode), + types: new InheritanceTypes($types as NonterminalNode), }; }); - public constructor(public readonly cst: NonTerminalNode) { - assertKind(this.cst.kind, NonTerminalKind.InheritanceSpecifier); + public constructor(public readonly cst: NonterminalNode) { + assertKind(this.cst.kind, NonterminalKind.InheritanceSpecifier); } public get isKeyword(): TerminalNode { @@ -539,13 +539,13 @@ export class InheritanceType { const [$typeName, $arguments] = ast_internal.selectSequence(this.cst); return { - typeName: new IdentifierPath($typeName as NonTerminalNode), - arguments: $arguments === null ? undefined : new ArgumentsDeclaration($arguments as NonTerminalNode), + typeName: new IdentifierPath($typeName as NonterminalNode), + arguments: $arguments === null ? undefined : new ArgumentsDeclaration($arguments as NonterminalNode), }; }); - public constructor(public readonly cst: NonTerminalNode) { - assertKind(this.cst.kind, NonTerminalKind.InheritanceType); + public constructor(public readonly cst: NonterminalNode) { + assertKind(this.cst.kind, NonterminalKind.InheritanceType); } public get typeName(): IdentifierPath { @@ -566,15 +566,15 @@ export class InterfaceDefinition { return { interfaceKeyword: $interfaceKeyword as TerminalNode, name: $name as TerminalNode, - inheritence: $inheritence === null ? undefined : new InheritanceSpecifier($inheritence as NonTerminalNode), + inheritence: $inheritence === null ? undefined : new InheritanceSpecifier($inheritence as NonterminalNode), openBrace: $openBrace as TerminalNode, - members: new InterfaceMembers($members as NonTerminalNode), + members: new InterfaceMembers($members as NonterminalNode), closeBrace: $closeBrace as TerminalNode, }; }); - public constructor(public readonly cst: NonTerminalNode) { - assertKind(this.cst.kind, NonTerminalKind.InterfaceDefinition); + public constructor(public readonly cst: NonterminalNode) { + assertKind(this.cst.kind, NonterminalKind.InterfaceDefinition); } public get interfaceKeyword(): TerminalNode { @@ -610,13 +610,13 @@ export class LibraryDefinition { libraryKeyword: $libraryKeyword as TerminalNode, name: $name as TerminalNode, openBrace: $openBrace as TerminalNode, - members: new LibraryMembers($members as NonTerminalNode), + members: new LibraryMembers($members as NonterminalNode), closeBrace: $closeBrace as TerminalNode, }; }); - public constructor(public readonly cst: NonTerminalNode) { - assertKind(this.cst.kind, NonTerminalKind.LibraryDefinition); + public constructor(public readonly cst: NonterminalNode) { + assertKind(this.cst.kind, NonterminalKind.LibraryDefinition); } public get libraryKeyword(): TerminalNode { @@ -648,13 +648,13 @@ export class StructDefinition { structKeyword: $structKeyword as TerminalNode, name: $name as TerminalNode, openBrace: $openBrace as TerminalNode, - members: new StructMembers($members as NonTerminalNode), + members: new StructMembers($members as NonterminalNode), closeBrace: $closeBrace as TerminalNode, }; }); - public constructor(public readonly cst: NonTerminalNode) { - assertKind(this.cst.kind, NonTerminalKind.StructDefinition); + public constructor(public readonly cst: NonterminalNode) { + assertKind(this.cst.kind, NonterminalKind.StructDefinition); } public get structKeyword(): TerminalNode { @@ -683,14 +683,14 @@ export class StructMember { const [$typeName, $name, $semicolon] = ast_internal.selectSequence(this.cst); return { - typeName: new TypeName($typeName as NonTerminalNode), + typeName: new TypeName($typeName as NonterminalNode), name: $name as TerminalNode, semicolon: $semicolon as TerminalNode, }; }); - public constructor(public readonly cst: NonTerminalNode) { - assertKind(this.cst.kind, NonTerminalKind.StructMember); + public constructor(public readonly cst: NonterminalNode) { + assertKind(this.cst.kind, NonterminalKind.StructMember); } public get typeName(): TypeName { @@ -714,13 +714,13 @@ export class EnumDefinition { enumKeyword: $enumKeyword as TerminalNode, name: $name as TerminalNode, openBrace: $openBrace as TerminalNode, - members: new EnumMembers($members as NonTerminalNode), + members: new EnumMembers($members as NonterminalNode), closeBrace: $closeBrace as TerminalNode, }; }); - public constructor(public readonly cst: NonTerminalNode) { - assertKind(this.cst.kind, NonTerminalKind.EnumDefinition); + public constructor(public readonly cst: NonterminalNode) { + assertKind(this.cst.kind, NonterminalKind.EnumDefinition); } public get enumKeyword(): TerminalNode { @@ -749,17 +749,17 @@ export class ConstantDefinition { const [$typeName, $constantKeyword, $name, $equal, $value, $semicolon] = ast_internal.selectSequence(this.cst); return { - typeName: new TypeName($typeName as NonTerminalNode), + typeName: new TypeName($typeName as NonterminalNode), constantKeyword: $constantKeyword as TerminalNode, name: $name as TerminalNode, equal: $equal as TerminalNode, - value: new Expression($value as NonTerminalNode), + value: new Expression($value as NonterminalNode), semicolon: $semicolon as TerminalNode, }; }); - public constructor(public readonly cst: NonTerminalNode) { - assertKind(this.cst.kind, NonTerminalKind.ConstantDefinition); + public constructor(public readonly cst: NonterminalNode) { + assertKind(this.cst.kind, NonterminalKind.ConstantDefinition); } public get typeName(): TypeName { @@ -792,16 +792,16 @@ export class StateVariableDefinition { const [$typeName, $attributes, $name, $value, $semicolon] = ast_internal.selectSequence(this.cst); return { - typeName: new TypeName($typeName as NonTerminalNode), - attributes: new StateVariableAttributes($attributes as NonTerminalNode), + 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), + value: $value === null ? undefined : new StateVariableDefinitionValue($value as NonterminalNode), semicolon: $semicolon as TerminalNode, }; }); - public constructor(public readonly cst: NonTerminalNode) { - assertKind(this.cst.kind, NonTerminalKind.StateVariableDefinition); + public constructor(public readonly cst: NonterminalNode) { + assertKind(this.cst.kind, NonterminalKind.StateVariableDefinition); } public get typeName(): TypeName { @@ -831,12 +831,12 @@ export class StateVariableDefinitionValue { return { equal: $equal as TerminalNode, - value: new Expression($value as NonTerminalNode), + value: new Expression($value as NonterminalNode), }; }); - public constructor(public readonly cst: NonTerminalNode) { - assertKind(this.cst.kind, NonTerminalKind.StateVariableDefinitionValue); + public constructor(public readonly cst: NonterminalNode) { + assertKind(this.cst.kind, NonterminalKind.StateVariableDefinitionValue); } public get equal(): TerminalNode { @@ -854,16 +854,16 @@ export class FunctionDefinition { return { 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), + 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: NonTerminalNode) { - assertKind(this.cst.kind, NonTerminalKind.FunctionDefinition); + public constructor(public readonly cst: NonterminalNode) { + assertKind(this.cst.kind, NonterminalKind.FunctionDefinition); } public get functionKeyword(): TerminalNode { @@ -897,13 +897,13 @@ export class ParametersDeclaration { return { openParen: $openParen as TerminalNode, - parameters: new Parameters($parameters as NonTerminalNode), + parameters: new Parameters($parameters as NonterminalNode), closeParen: $closeParen as TerminalNode, }; }); - public constructor(public readonly cst: NonTerminalNode) { - assertKind(this.cst.kind, NonTerminalKind.ParametersDeclaration); + public constructor(public readonly cst: NonterminalNode) { + assertKind(this.cst.kind, NonterminalKind.ParametersDeclaration); } public get openParen(): TerminalNode { @@ -924,14 +924,14 @@ export class Parameter { const [$typeName, $storageLocation, $name] = ast_internal.selectSequence(this.cst); return { - typeName: new TypeName($typeName as NonTerminalNode), - storageLocation: $storageLocation === null ? undefined : new StorageLocation($storageLocation as NonTerminalNode), + 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: NonTerminalNode) { - assertKind(this.cst.kind, NonTerminalKind.Parameter); + public constructor(public readonly cst: NonterminalNode) { + assertKind(this.cst.kind, NonterminalKind.Parameter); } public get typeName(): TypeName { @@ -953,12 +953,12 @@ export class OverrideSpecifier { return { overrideKeyword: $overrideKeyword as TerminalNode, - overridden: $overridden === null ? undefined : new OverridePathsDeclaration($overridden as NonTerminalNode), + overridden: $overridden === null ? undefined : new OverridePathsDeclaration($overridden as NonterminalNode), }; }); - public constructor(public readonly cst: NonTerminalNode) { - assertKind(this.cst.kind, NonTerminalKind.OverrideSpecifier); + public constructor(public readonly cst: NonterminalNode) { + assertKind(this.cst.kind, NonterminalKind.OverrideSpecifier); } public get overrideKeyword(): TerminalNode { @@ -976,13 +976,13 @@ export class OverridePathsDeclaration { return { openParen: $openParen as TerminalNode, - paths: new OverridePaths($paths as NonTerminalNode), + paths: new OverridePaths($paths as NonterminalNode), closeParen: $closeParen as TerminalNode, }; }); - public constructor(public readonly cst: NonTerminalNode) { - assertKind(this.cst.kind, NonTerminalKind.OverridePathsDeclaration); + public constructor(public readonly cst: NonterminalNode) { + assertKind(this.cst.kind, NonterminalKind.OverridePathsDeclaration); } public get openParen(): TerminalNode { @@ -1004,12 +1004,12 @@ export class ReturnsDeclaration { return { returnsKeyword: $returnsKeyword as TerminalNode, - variables: new ParametersDeclaration($variables as NonTerminalNode), + variables: new ParametersDeclaration($variables as NonterminalNode), }; }); - public constructor(public readonly cst: NonTerminalNode) { - assertKind(this.cst.kind, NonTerminalKind.ReturnsDeclaration); + public constructor(public readonly cst: NonterminalNode) { + assertKind(this.cst.kind, NonterminalKind.ReturnsDeclaration); } public get returnsKeyword(): TerminalNode { @@ -1027,14 +1027,14 @@ export class ConstructorDefinition { return { constructorKeyword: $constructorKeyword as TerminalNode, - parameters: new ParametersDeclaration($parameters as NonTerminalNode), - attributes: new ConstructorAttributes($attributes as NonTerminalNode), - body: new Block($body as NonTerminalNode), + parameters: new ParametersDeclaration($parameters as NonterminalNode), + attributes: new ConstructorAttributes($attributes as NonterminalNode), + body: new Block($body as NonterminalNode), }; }); - public constructor(public readonly cst: NonTerminalNode) { - assertKind(this.cst.kind, NonTerminalKind.ConstructorDefinition); + public constructor(public readonly cst: NonterminalNode) { + assertKind(this.cst.kind, NonterminalKind.ConstructorDefinition); } public get constructorKeyword(): TerminalNode { @@ -1060,14 +1060,14 @@ export class UnnamedFunctionDefinition { return { functionKeyword: $functionKeyword as TerminalNode, - parameters: new ParametersDeclaration($parameters as NonTerminalNode), - attributes: new UnnamedFunctionAttributes($attributes as NonTerminalNode), - body: new FunctionBody($body as NonTerminalNode), + parameters: new ParametersDeclaration($parameters as NonterminalNode), + attributes: new UnnamedFunctionAttributes($attributes as NonterminalNode), + body: new FunctionBody($body as NonterminalNode), }; }); - public constructor(public readonly cst: NonTerminalNode) { - assertKind(this.cst.kind, NonTerminalKind.UnnamedFunctionDefinition); + public constructor(public readonly cst: NonterminalNode) { + assertKind(this.cst.kind, NonterminalKind.UnnamedFunctionDefinition); } public get functionKeyword(): TerminalNode { @@ -1093,15 +1093,15 @@ export class FallbackFunctionDefinition { return { 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), + 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: NonTerminalNode) { - assertKind(this.cst.kind, NonTerminalKind.FallbackFunctionDefinition); + public constructor(public readonly cst: NonterminalNode) { + assertKind(this.cst.kind, NonterminalKind.FallbackFunctionDefinition); } public get fallbackKeyword(): TerminalNode { @@ -1131,14 +1131,14 @@ export class ReceiveFunctionDefinition { return { receiveKeyword: $receiveKeyword as TerminalNode, - parameters: new ParametersDeclaration($parameters as NonTerminalNode), - attributes: new ReceiveFunctionAttributes($attributes as NonTerminalNode), - body: new FunctionBody($body as NonTerminalNode), + parameters: new ParametersDeclaration($parameters as NonterminalNode), + attributes: new ReceiveFunctionAttributes($attributes as NonterminalNode), + body: new FunctionBody($body as NonterminalNode), }; }); - public constructor(public readonly cst: NonTerminalNode) { - assertKind(this.cst.kind, NonTerminalKind.ReceiveFunctionDefinition); + public constructor(public readonly cst: NonterminalNode) { + assertKind(this.cst.kind, NonterminalKind.ReceiveFunctionDefinition); } public get receiveKeyword(): TerminalNode { @@ -1165,14 +1165,14 @@ export class ModifierDefinition { return { 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), + 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: NonTerminalNode) { - assertKind(this.cst.kind, NonTerminalKind.ModifierDefinition); + public constructor(public readonly cst: NonterminalNode) { + assertKind(this.cst.kind, NonterminalKind.ModifierDefinition); } public get modifierKeyword(): TerminalNode { @@ -1201,13 +1201,13 @@ export class ModifierInvocation { const [$name, $arguments] = ast_internal.selectSequence(this.cst); return { - name: new IdentifierPath($name as NonTerminalNode), - arguments: $arguments === null ? undefined : new ArgumentsDeclaration($arguments as NonTerminalNode), + name: new IdentifierPath($name as NonterminalNode), + arguments: $arguments === null ? undefined : new ArgumentsDeclaration($arguments as NonterminalNode), }; }); - public constructor(public readonly cst: NonTerminalNode) { - assertKind(this.cst.kind, NonTerminalKind.ModifierInvocation); + public constructor(public readonly cst: NonterminalNode) { + assertKind(this.cst.kind, NonterminalKind.ModifierInvocation); } public get name(): IdentifierPath { @@ -1226,14 +1226,14 @@ export class EventDefinition { return { eventKeyword: $eventKeyword as TerminalNode, name: $name as TerminalNode, - parameters: new EventParametersDeclaration($parameters as NonTerminalNode), + parameters: new EventParametersDeclaration($parameters as NonterminalNode), anonymousKeyword: $anonymousKeyword === null ? undefined : ($anonymousKeyword as TerminalNode), semicolon: $semicolon as TerminalNode, }; }); - public constructor(public readonly cst: NonTerminalNode) { - assertKind(this.cst.kind, NonTerminalKind.EventDefinition); + public constructor(public readonly cst: NonterminalNode) { + assertKind(this.cst.kind, NonterminalKind.EventDefinition); } public get eventKeyword(): TerminalNode { @@ -1263,13 +1263,13 @@ export class EventParametersDeclaration { return { openParen: $openParen as TerminalNode, - parameters: new EventParameters($parameters as NonTerminalNode), + parameters: new EventParameters($parameters as NonterminalNode), closeParen: $closeParen as TerminalNode, }; }); - public constructor(public readonly cst: NonTerminalNode) { - assertKind(this.cst.kind, NonTerminalKind.EventParametersDeclaration); + public constructor(public readonly cst: NonterminalNode) { + assertKind(this.cst.kind, NonterminalKind.EventParametersDeclaration); } public get openParen(): TerminalNode { @@ -1290,14 +1290,14 @@ export class EventParameter { const [$typeName, $indexedKeyword, $name] = ast_internal.selectSequence(this.cst); return { - typeName: new TypeName($typeName as NonTerminalNode), + 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: NonTerminalNode) { - assertKind(this.cst.kind, NonTerminalKind.EventParameter); + public constructor(public readonly cst: NonterminalNode) { + assertKind(this.cst.kind, NonterminalKind.EventParameter); } public get typeName(): TypeName { @@ -1321,13 +1321,13 @@ export class UserDefinedValueTypeDefinition { typeKeyword: $typeKeyword as TerminalNode, name: $name as TerminalNode, isKeyword: $isKeyword as TerminalNode, - valueType: new ElementaryType($valueType as NonTerminalNode), + valueType: new ElementaryType($valueType as NonterminalNode), semicolon: $semicolon as TerminalNode, }; }); - public constructor(public readonly cst: NonTerminalNode) { - assertKind(this.cst.kind, NonTerminalKind.UserDefinedValueTypeDefinition); + public constructor(public readonly cst: NonterminalNode) { + assertKind(this.cst.kind, NonterminalKind.UserDefinedValueTypeDefinition); } public get typeKeyword(): TerminalNode { @@ -1358,13 +1358,13 @@ export class ErrorDefinition { return { errorKeyword: $errorKeyword as TerminalNode, name: $name as TerminalNode, - members: new ErrorParametersDeclaration($members as NonTerminalNode), + members: new ErrorParametersDeclaration($members as NonterminalNode), semicolon: $semicolon as TerminalNode, }; }); - public constructor(public readonly cst: NonTerminalNode) { - assertKind(this.cst.kind, NonTerminalKind.ErrorDefinition); + public constructor(public readonly cst: NonterminalNode) { + assertKind(this.cst.kind, NonterminalKind.ErrorDefinition); } public get errorKeyword(): TerminalNode { @@ -1390,13 +1390,13 @@ export class ErrorParametersDeclaration { return { openParen: $openParen as TerminalNode, - parameters: new ErrorParameters($parameters as NonTerminalNode), + parameters: new ErrorParameters($parameters as NonterminalNode), closeParen: $closeParen as TerminalNode, }; }); - public constructor(public readonly cst: NonTerminalNode) { - assertKind(this.cst.kind, NonTerminalKind.ErrorParametersDeclaration); + public constructor(public readonly cst: NonterminalNode) { + assertKind(this.cst.kind, NonterminalKind.ErrorParametersDeclaration); } public get openParen(): TerminalNode { @@ -1417,13 +1417,13 @@ export class ErrorParameter { const [$typeName, $name] = ast_internal.selectSequence(this.cst); return { - typeName: new TypeName($typeName as NonTerminalNode), + typeName: new TypeName($typeName as NonterminalNode), name: $name === null ? undefined : ($name as TerminalNode), }; }); - public constructor(public readonly cst: NonTerminalNode) { - assertKind(this.cst.kind, NonTerminalKind.ErrorParameter); + public constructor(public readonly cst: NonterminalNode) { + assertKind(this.cst.kind, NonterminalKind.ErrorParameter); } public get typeName(): TypeName { @@ -1440,15 +1440,15 @@ export class ArrayTypeName { const [$operand, $openBracket, $index, $closeBracket] = ast_internal.selectSequence(this.cst); return { - operand: new TypeName($operand as NonTerminalNode), + operand: new TypeName($operand as NonterminalNode), openBracket: $openBracket as TerminalNode, - index: $index === null ? undefined : new Expression($index as NonTerminalNode), + index: $index === null ? undefined : new Expression($index as NonterminalNode), closeBracket: $closeBracket as TerminalNode, }; }); - public constructor(public readonly cst: NonTerminalNode) { - assertKind(this.cst.kind, NonTerminalKind.ArrayTypeName); + public constructor(public readonly cst: NonterminalNode) { + assertKind(this.cst.kind, NonterminalKind.ArrayTypeName); } public get operand(): TypeName { @@ -1474,14 +1474,14 @@ export class FunctionType { return { 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), + 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: NonTerminalNode) { - assertKind(this.cst.kind, NonTerminalKind.FunctionType); + public constructor(public readonly cst: NonterminalNode) { + assertKind(this.cst.kind, NonterminalKind.FunctionType); } public get functionKeyword(): TerminalNode { @@ -1509,15 +1509,15 @@ export class MappingType { return { mappingKeyword: $mappingKeyword as TerminalNode, openParen: $openParen as TerminalNode, - keyType: new MappingKey($keyType as NonTerminalNode), + keyType: new MappingKey($keyType as NonterminalNode), equalGreaterThan: $equalGreaterThan as TerminalNode, - valueType: new MappingValue($valueType as NonTerminalNode), + valueType: new MappingValue($valueType as NonterminalNode), closeParen: $closeParen as TerminalNode, }; }); - public constructor(public readonly cst: NonTerminalNode) { - assertKind(this.cst.kind, NonTerminalKind.MappingType); + public constructor(public readonly cst: NonterminalNode) { + assertKind(this.cst.kind, NonterminalKind.MappingType); } public get mappingKeyword(): TerminalNode { @@ -1550,13 +1550,13 @@ export class MappingKey { const [$keyType, $name] = ast_internal.selectSequence(this.cst); return { - keyType: new MappingKeyType($keyType as NonTerminalNode), + keyType: new MappingKeyType($keyType as NonterminalNode), name: $name === null ? undefined : ($name as TerminalNode), }; }); - public constructor(public readonly cst: NonTerminalNode) { - assertKind(this.cst.kind, NonTerminalKind.MappingKey); + public constructor(public readonly cst: NonterminalNode) { + assertKind(this.cst.kind, NonterminalKind.MappingKey); } public get keyType(): MappingKeyType { @@ -1573,13 +1573,13 @@ export class MappingValue { const [$typeName, $name] = ast_internal.selectSequence(this.cst); return { - typeName: new TypeName($typeName as NonTerminalNode), + typeName: new TypeName($typeName as NonterminalNode), name: $name === null ? undefined : ($name as TerminalNode), }; }); - public constructor(public readonly cst: NonTerminalNode) { - assertKind(this.cst.kind, NonTerminalKind.MappingValue); + public constructor(public readonly cst: NonterminalNode) { + assertKind(this.cst.kind, NonterminalKind.MappingValue); } public get typeName(): TypeName { @@ -1601,8 +1601,8 @@ export class AddressType { }; }); - public constructor(public readonly cst: NonTerminalNode) { - assertKind(this.cst.kind, NonTerminalKind.AddressType); + public constructor(public readonly cst: NonterminalNode) { + assertKind(this.cst.kind, NonterminalKind.AddressType); } public get addressKeyword(): TerminalNode { @@ -1620,13 +1620,13 @@ export class Block { return { openBrace: $openBrace as TerminalNode, - statements: new Statements($statements as NonTerminalNode), + statements: new Statements($statements as NonterminalNode), closeBrace: $closeBrace as TerminalNode, }; }); - public constructor(public readonly cst: NonTerminalNode) { - assertKind(this.cst.kind, NonTerminalKind.Block); + public constructor(public readonly cst: NonterminalNode) { + assertKind(this.cst.kind, NonterminalKind.Block); } public get openBrace(): TerminalNode { @@ -1648,12 +1648,12 @@ export class UncheckedBlock { return { uncheckedKeyword: $uncheckedKeyword as TerminalNode, - block: new Block($block as NonTerminalNode), + block: new Block($block as NonterminalNode), }; }); - public constructor(public readonly cst: NonTerminalNode) { - assertKind(this.cst.kind, NonTerminalKind.UncheckedBlock); + public constructor(public readonly cst: NonterminalNode) { + assertKind(this.cst.kind, NonterminalKind.UncheckedBlock); } public get uncheckedKeyword(): TerminalNode { @@ -1670,13 +1670,13 @@ export class ExpressionStatement { const [$expression, $semicolon] = ast_internal.selectSequence(this.cst); return { - expression: new Expression($expression as NonTerminalNode), + expression: new Expression($expression as NonterminalNode), semicolon: $semicolon as TerminalNode, }; }); - public constructor(public readonly cst: NonTerminalNode) { - assertKind(this.cst.kind, NonTerminalKind.ExpressionStatement); + public constructor(public readonly cst: NonterminalNode) { + assertKind(this.cst.kind, NonterminalKind.ExpressionStatement); } public get expression(): Expression { @@ -1694,14 +1694,14 @@ export class AssemblyStatement { return { 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), + 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: NonTerminalNode) { - assertKind(this.cst.kind, NonTerminalKind.AssemblyStatement); + public constructor(public readonly cst: NonterminalNode) { + assertKind(this.cst.kind, NonterminalKind.AssemblyStatement); } public get assemblyKeyword(): TerminalNode { @@ -1727,13 +1727,13 @@ export class AssemblyFlagsDeclaration { return { openParen: $openParen as TerminalNode, - flags: new AssemblyFlags($flags as NonTerminalNode), + flags: new AssemblyFlags($flags as NonterminalNode), closeParen: $closeParen as TerminalNode, }; }); - public constructor(public readonly cst: NonTerminalNode) { - assertKind(this.cst.kind, NonTerminalKind.AssemblyFlagsDeclaration); + public constructor(public readonly cst: NonterminalNode) { + assertKind(this.cst.kind, NonterminalKind.AssemblyFlagsDeclaration); } public get openParen(): TerminalNode { @@ -1757,16 +1757,16 @@ export class TupleDeconstructionStatement { return { varKeyword: $varKeyword === null ? undefined : ($varKeyword as TerminalNode), openParen: $openParen as TerminalNode, - elements: new TupleDeconstructionElements($elements as NonTerminalNode), + elements: new TupleDeconstructionElements($elements as NonterminalNode), closeParen: $closeParen as TerminalNode, equal: $equal as TerminalNode, - expression: new Expression($expression as NonTerminalNode), + expression: new Expression($expression as NonterminalNode), semicolon: $semicolon as TerminalNode, }; }); - public constructor(public readonly cst: NonTerminalNode) { - assertKind(this.cst.kind, NonTerminalKind.TupleDeconstructionStatement); + public constructor(public readonly cst: NonterminalNode) { + assertKind(this.cst.kind, NonterminalKind.TupleDeconstructionStatement); } public get varKeyword(): TerminalNode | undefined { @@ -1803,12 +1803,12 @@ export class TupleDeconstructionElement { const [$member] = ast_internal.selectSequence(this.cst); return { - member: $member === null ? undefined : new TupleMember($member as NonTerminalNode), + member: $member === null ? undefined : new TupleMember($member as NonterminalNode), }; }); - public constructor(public readonly cst: NonTerminalNode) { - assertKind(this.cst.kind, NonTerminalKind.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 NonTerminalNode), - storageLocation: $storageLocation === null ? undefined : new StorageLocation($storageLocation as NonTerminalNode), + typeName: new TypeName($typeName as NonterminalNode), + storageLocation: $storageLocation === null ? undefined : new StorageLocation($storageLocation as NonterminalNode), name: $name as TerminalNode, }; }); - public constructor(public readonly cst: NonTerminalNode) { - assertKind(this.cst.kind, NonTerminalKind.TypedTupleMember); + public constructor(public readonly cst: NonterminalNode) { + assertKind(this.cst.kind, NonterminalKind.TypedTupleMember); } public get typeName(): TypeName { @@ -1849,13 +1849,13 @@ export class UntypedTupleMember { const [$storageLocation, $name] = ast_internal.selectSequence(this.cst); return { - storageLocation: $storageLocation === null ? undefined : new StorageLocation($storageLocation as NonTerminalNode), + storageLocation: $storageLocation === null ? undefined : new StorageLocation($storageLocation as NonterminalNode), name: $name as TerminalNode, }; }); - public constructor(public readonly cst: NonTerminalNode) { - assertKind(this.cst.kind, NonTerminalKind.UntypedTupleMember); + public constructor(public readonly cst: NonterminalNode) { + assertKind(this.cst.kind, NonterminalKind.UntypedTupleMember); } public get storageLocation(): StorageLocation | undefined { @@ -1872,16 +1872,16 @@ export class VariableDeclarationStatement { const [$variableType, $storageLocation, $name, $value, $semicolon] = ast_internal.selectSequence(this.cst); return { - variableType: new VariableDeclarationType($variableType as NonTerminalNode), - storageLocation: $storageLocation === null ? undefined : new StorageLocation($storageLocation as NonTerminalNode), + 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), + value: $value === null ? undefined : new VariableDeclarationValue($value as NonterminalNode), semicolon: $semicolon as TerminalNode, }; }); - public constructor(public readonly cst: NonTerminalNode) { - assertKind(this.cst.kind, NonTerminalKind.VariableDeclarationStatement); + public constructor(public readonly cst: NonterminalNode) { + assertKind(this.cst.kind, NonterminalKind.VariableDeclarationStatement); } public get variableType(): VariableDeclarationType { @@ -1911,12 +1911,12 @@ export class VariableDeclarationValue { return { equal: $equal as TerminalNode, - expression: new Expression($expression as NonTerminalNode), + expression: new Expression($expression as NonterminalNode), }; }); - public constructor(public readonly cst: NonTerminalNode) { - assertKind(this.cst.kind, NonTerminalKind.VariableDeclarationValue); + public constructor(public readonly cst: NonterminalNode) { + assertKind(this.cst.kind, NonterminalKind.VariableDeclarationValue); } public get equal(): TerminalNode { @@ -1935,15 +1935,15 @@ export class IfStatement { return { ifKeyword: $ifKeyword as TerminalNode, openParen: $openParen as TerminalNode, - condition: new Expression($condition as NonTerminalNode), + 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), + body: new Statement($body as NonterminalNode), + elseBranch: $elseBranch === null ? undefined : new ElseBranch($elseBranch as NonterminalNode), }; }); - public constructor(public readonly cst: NonTerminalNode) { - assertKind(this.cst.kind, NonTerminalKind.IfStatement); + public constructor(public readonly cst: NonterminalNode) { + assertKind(this.cst.kind, NonterminalKind.IfStatement); } public get ifKeyword(): TerminalNode { @@ -1977,12 +1977,12 @@ export class ElseBranch { return { elseKeyword: $elseKeyword as TerminalNode, - body: new Statement($body as NonTerminalNode), + body: new Statement($body as NonterminalNode), }; }); - public constructor(public readonly cst: NonTerminalNode) { - assertKind(this.cst.kind, NonTerminalKind.ElseBranch); + public constructor(public readonly cst: NonterminalNode) { + assertKind(this.cst.kind, NonterminalKind.ElseBranch); } public get elseKeyword(): TerminalNode { @@ -2002,16 +2002,16 @@ export class ForStatement { return { 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), + 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), + body: new Statement($body as NonterminalNode), }; }); - public constructor(public readonly cst: NonTerminalNode) { - assertKind(this.cst.kind, NonTerminalKind.ForStatement); + public constructor(public readonly cst: NonterminalNode) { + assertKind(this.cst.kind, NonterminalKind.ForStatement); } public get forKeyword(): TerminalNode { @@ -2050,14 +2050,14 @@ export class WhileStatement { return { whileKeyword: $whileKeyword as TerminalNode, openParen: $openParen as TerminalNode, - condition: new Expression($condition as NonTerminalNode), + condition: new Expression($condition as NonterminalNode), closeParen: $closeParen as TerminalNode, - body: new Statement($body as NonTerminalNode), + body: new Statement($body as NonterminalNode), }; }); - public constructor(public readonly cst: NonTerminalNode) { - assertKind(this.cst.kind, NonTerminalKind.WhileStatement); + public constructor(public readonly cst: NonterminalNode) { + assertKind(this.cst.kind, NonterminalKind.WhileStatement); } public get whileKeyword(): TerminalNode { @@ -2088,17 +2088,17 @@ export class DoWhileStatement { return { doKeyword: $doKeyword as TerminalNode, - body: new Statement($body as NonTerminalNode), + body: new Statement($body as NonterminalNode), whileKeyword: $whileKeyword as TerminalNode, openParen: $openParen as TerminalNode, - condition: new Expression($condition as NonTerminalNode), + condition: new Expression($condition as NonterminalNode), closeParen: $closeParen as TerminalNode, semicolon: $semicolon as TerminalNode, }; }); - public constructor(public readonly cst: NonTerminalNode) { - assertKind(this.cst.kind, NonTerminalKind.DoWhileStatement); + public constructor(public readonly cst: NonterminalNode) { + assertKind(this.cst.kind, NonterminalKind.DoWhileStatement); } public get doKeyword(): TerminalNode { @@ -2140,8 +2140,8 @@ export class ContinueStatement { }; }); - public constructor(public readonly cst: NonTerminalNode) { - assertKind(this.cst.kind, NonTerminalKind.ContinueStatement); + public constructor(public readonly cst: NonterminalNode) { + assertKind(this.cst.kind, NonterminalKind.ContinueStatement); } public get continueKeyword(): TerminalNode { @@ -2163,8 +2163,8 @@ export class BreakStatement { }; }); - public constructor(public readonly cst: NonTerminalNode) { - assertKind(this.cst.kind, NonTerminalKind.BreakStatement); + public constructor(public readonly cst: NonterminalNode) { + assertKind(this.cst.kind, NonterminalKind.BreakStatement); } public get breakKeyword(): TerminalNode { @@ -2182,13 +2182,13 @@ export class ReturnStatement { return { returnKeyword: $returnKeyword as TerminalNode, - expression: $expression === null ? undefined : new Expression($expression as NonTerminalNode), + expression: $expression === null ? undefined : new Expression($expression as NonterminalNode), semicolon: $semicolon as TerminalNode, }; }); - public constructor(public readonly cst: NonTerminalNode) { - assertKind(this.cst.kind, NonTerminalKind.ReturnStatement); + public constructor(public readonly cst: NonterminalNode) { + assertKind(this.cst.kind, NonterminalKind.ReturnStatement); } public get returnKeyword(): TerminalNode { @@ -2210,14 +2210,14 @@ export class EmitStatement { return { emitKeyword: $emitKeyword as TerminalNode, - event: new IdentifierPath($event as NonTerminalNode), - arguments: new ArgumentsDeclaration($arguments as NonTerminalNode), + event: new IdentifierPath($event as NonterminalNode), + arguments: new ArgumentsDeclaration($arguments as NonterminalNode), semicolon: $semicolon as TerminalNode, }; }); - public constructor(public readonly cst: NonTerminalNode) { - assertKind(this.cst.kind, NonTerminalKind.EmitStatement); + public constructor(public readonly cst: NonterminalNode) { + assertKind(this.cst.kind, NonterminalKind.EmitStatement); } public get emitKeyword(): TerminalNode { @@ -2243,15 +2243,15 @@ export class TryStatement { return { 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), + 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: NonTerminalNode) { - assertKind(this.cst.kind, NonTerminalKind.TryStatement); + public constructor(public readonly cst: NonterminalNode) { + assertKind(this.cst.kind, NonterminalKind.TryStatement); } public get tryKeyword(): TerminalNode { @@ -2281,13 +2281,13 @@ export class CatchClause { return { catchKeyword: $catchKeyword as TerminalNode, - error: $error === null ? undefined : new CatchClauseError($error as NonTerminalNode), - body: new Block($body as NonTerminalNode), + error: $error === null ? undefined : new CatchClauseError($error as NonterminalNode), + body: new Block($body as NonterminalNode), }; }); - public constructor(public readonly cst: NonTerminalNode) { - assertKind(this.cst.kind, NonTerminalKind.CatchClause); + public constructor(public readonly cst: NonterminalNode) { + assertKind(this.cst.kind, NonterminalKind.CatchClause); } public get catchKeyword(): TerminalNode { @@ -2309,12 +2309,12 @@ export class CatchClauseError { return { name: $name === null ? undefined : ($name as TerminalNode), - parameters: new ParametersDeclaration($parameters as NonTerminalNode), + parameters: new ParametersDeclaration($parameters as NonterminalNode), }; }); - public constructor(public readonly cst: NonTerminalNode) { - assertKind(this.cst.kind, NonTerminalKind.CatchClauseError); + public constructor(public readonly cst: NonterminalNode) { + assertKind(this.cst.kind, NonterminalKind.CatchClauseError); } public get name(): TerminalNode | undefined { @@ -2332,14 +2332,14 @@ export class RevertStatement { return { revertKeyword: $revertKeyword as TerminalNode, - error: $error === null ? undefined : new IdentifierPath($error as NonTerminalNode), - arguments: new ArgumentsDeclaration($arguments as NonTerminalNode), + error: $error === null ? undefined : new IdentifierPath($error as NonterminalNode), + arguments: new ArgumentsDeclaration($arguments as NonterminalNode), semicolon: $semicolon as TerminalNode, }; }); - public constructor(public readonly cst: NonTerminalNode) { - assertKind(this.cst.kind, NonTerminalKind.RevertStatement); + public constructor(public readonly cst: NonterminalNode) { + assertKind(this.cst.kind, NonterminalKind.RevertStatement); } public get revertKeyword(): TerminalNode { @@ -2369,8 +2369,8 @@ export class ThrowStatement { }; }); - public constructor(public readonly cst: NonTerminalNode) { - assertKind(this.cst.kind, NonTerminalKind.ThrowStatement); + public constructor(public readonly cst: NonterminalNode) { + assertKind(this.cst.kind, NonterminalKind.ThrowStatement); } public get throwKeyword(): TerminalNode { @@ -2387,14 +2387,14 @@ export class AssignmentExpression { const [$leftOperand, $operator, $rightOperand] = ast_internal.selectSequence(this.cst); return { - leftOperand: new Expression($leftOperand as NonTerminalNode), + leftOperand: new Expression($leftOperand as NonterminalNode), operator: $operator as TerminalNode, - rightOperand: new Expression($rightOperand as NonTerminalNode), + rightOperand: new Expression($rightOperand as NonterminalNode), }; }); - public constructor(public readonly cst: NonTerminalNode) { - assertKind(this.cst.kind, NonTerminalKind.AssignmentExpression); + public constructor(public readonly cst: NonterminalNode) { + assertKind(this.cst.kind, NonterminalKind.AssignmentExpression); } public get leftOperand(): Expression { @@ -2415,16 +2415,16 @@ export class ConditionalExpression { const [$operand, $questionMark, $trueExpression, $colon, $falseExpression] = ast_internal.selectSequence(this.cst); return { - operand: new Expression($operand as NonTerminalNode), + operand: new Expression($operand as NonterminalNode), questionMark: $questionMark as TerminalNode, - trueExpression: new Expression($trueExpression as NonTerminalNode), + trueExpression: new Expression($trueExpression as NonterminalNode), colon: $colon as TerminalNode, - falseExpression: new Expression($falseExpression as NonTerminalNode), + falseExpression: new Expression($falseExpression as NonterminalNode), }; }); - public constructor(public readonly cst: NonTerminalNode) { - assertKind(this.cst.kind, NonTerminalKind.ConditionalExpression); + public constructor(public readonly cst: NonterminalNode) { + assertKind(this.cst.kind, NonterminalKind.ConditionalExpression); } public get operand(): Expression { @@ -2453,14 +2453,14 @@ export class OrExpression { const [$leftOperand, $operator, $rightOperand] = ast_internal.selectSequence(this.cst); return { - leftOperand: new Expression($leftOperand as NonTerminalNode), + leftOperand: new Expression($leftOperand as NonterminalNode), operator: $operator as TerminalNode, - rightOperand: new Expression($rightOperand as NonTerminalNode), + rightOperand: new Expression($rightOperand as NonterminalNode), }; }); - public constructor(public readonly cst: NonTerminalNode) { - assertKind(this.cst.kind, NonTerminalKind.OrExpression); + public constructor(public readonly cst: NonterminalNode) { + assertKind(this.cst.kind, NonterminalKind.OrExpression); } public get leftOperand(): Expression { @@ -2481,14 +2481,14 @@ export class AndExpression { const [$leftOperand, $operator, $rightOperand] = ast_internal.selectSequence(this.cst); return { - leftOperand: new Expression($leftOperand as NonTerminalNode), + leftOperand: new Expression($leftOperand as NonterminalNode), operator: $operator as TerminalNode, - rightOperand: new Expression($rightOperand as NonTerminalNode), + rightOperand: new Expression($rightOperand as NonterminalNode), }; }); - public constructor(public readonly cst: NonTerminalNode) { - assertKind(this.cst.kind, NonTerminalKind.AndExpression); + public constructor(public readonly cst: NonterminalNode) { + assertKind(this.cst.kind, NonterminalKind.AndExpression); } public get leftOperand(): Expression { @@ -2509,14 +2509,14 @@ export class EqualityExpression { const [$leftOperand, $operator, $rightOperand] = ast_internal.selectSequence(this.cst); return { - leftOperand: new Expression($leftOperand as NonTerminalNode), + leftOperand: new Expression($leftOperand as NonterminalNode), operator: $operator as TerminalNode, - rightOperand: new Expression($rightOperand as NonTerminalNode), + rightOperand: new Expression($rightOperand as NonterminalNode), }; }); - public constructor(public readonly cst: NonTerminalNode) { - assertKind(this.cst.kind, NonTerminalKind.EqualityExpression); + public constructor(public readonly cst: NonterminalNode) { + assertKind(this.cst.kind, NonterminalKind.EqualityExpression); } public get leftOperand(): Expression { @@ -2537,14 +2537,14 @@ export class ComparisonExpression { const [$leftOperand, $operator, $rightOperand] = ast_internal.selectSequence(this.cst); return { - leftOperand: new Expression($leftOperand as NonTerminalNode), + leftOperand: new Expression($leftOperand as NonterminalNode), operator: $operator as TerminalNode, - rightOperand: new Expression($rightOperand as NonTerminalNode), + rightOperand: new Expression($rightOperand as NonterminalNode), }; }); - public constructor(public readonly cst: NonTerminalNode) { - assertKind(this.cst.kind, NonTerminalKind.ComparisonExpression); + public constructor(public readonly cst: NonterminalNode) { + assertKind(this.cst.kind, NonterminalKind.ComparisonExpression); } public get leftOperand(): Expression { @@ -2565,14 +2565,14 @@ export class BitwiseOrExpression { const [$leftOperand, $operator, $rightOperand] = ast_internal.selectSequence(this.cst); return { - leftOperand: new Expression($leftOperand as NonTerminalNode), + leftOperand: new Expression($leftOperand as NonterminalNode), operator: $operator as TerminalNode, - rightOperand: new Expression($rightOperand as NonTerminalNode), + rightOperand: new Expression($rightOperand as NonterminalNode), }; }); - public constructor(public readonly cst: NonTerminalNode) { - assertKind(this.cst.kind, NonTerminalKind.BitwiseOrExpression); + public constructor(public readonly cst: NonterminalNode) { + assertKind(this.cst.kind, NonterminalKind.BitwiseOrExpression); } public get leftOperand(): Expression { @@ -2593,14 +2593,14 @@ export class BitwiseXorExpression { const [$leftOperand, $operator, $rightOperand] = ast_internal.selectSequence(this.cst); return { - leftOperand: new Expression($leftOperand as NonTerminalNode), + leftOperand: new Expression($leftOperand as NonterminalNode), operator: $operator as TerminalNode, - rightOperand: new Expression($rightOperand as NonTerminalNode), + rightOperand: new Expression($rightOperand as NonterminalNode), }; }); - public constructor(public readonly cst: NonTerminalNode) { - assertKind(this.cst.kind, NonTerminalKind.BitwiseXorExpression); + public constructor(public readonly cst: NonterminalNode) { + assertKind(this.cst.kind, NonterminalKind.BitwiseXorExpression); } public get leftOperand(): Expression { @@ -2621,14 +2621,14 @@ export class BitwiseAndExpression { const [$leftOperand, $operator, $rightOperand] = ast_internal.selectSequence(this.cst); return { - leftOperand: new Expression($leftOperand as NonTerminalNode), + leftOperand: new Expression($leftOperand as NonterminalNode), operator: $operator as TerminalNode, - rightOperand: new Expression($rightOperand as NonTerminalNode), + rightOperand: new Expression($rightOperand as NonterminalNode), }; }); - public constructor(public readonly cst: NonTerminalNode) { - assertKind(this.cst.kind, NonTerminalKind.BitwiseAndExpression); + public constructor(public readonly cst: NonterminalNode) { + assertKind(this.cst.kind, NonterminalKind.BitwiseAndExpression); } public get leftOperand(): Expression { @@ -2649,14 +2649,14 @@ export class ShiftExpression { const [$leftOperand, $operator, $rightOperand] = ast_internal.selectSequence(this.cst); return { - leftOperand: new Expression($leftOperand as NonTerminalNode), + leftOperand: new Expression($leftOperand as NonterminalNode), operator: $operator as TerminalNode, - rightOperand: new Expression($rightOperand as NonTerminalNode), + rightOperand: new Expression($rightOperand as NonterminalNode), }; }); - public constructor(public readonly cst: NonTerminalNode) { - assertKind(this.cst.kind, NonTerminalKind.ShiftExpression); + public constructor(public readonly cst: NonterminalNode) { + assertKind(this.cst.kind, NonterminalKind.ShiftExpression); } public get leftOperand(): Expression { @@ -2677,14 +2677,14 @@ export class AdditiveExpression { const [$leftOperand, $operator, $rightOperand] = ast_internal.selectSequence(this.cst); return { - leftOperand: new Expression($leftOperand as NonTerminalNode), + leftOperand: new Expression($leftOperand as NonterminalNode), operator: $operator as TerminalNode, - rightOperand: new Expression($rightOperand as NonTerminalNode), + rightOperand: new Expression($rightOperand as NonterminalNode), }; }); - public constructor(public readonly cst: NonTerminalNode) { - assertKind(this.cst.kind, NonTerminalKind.AdditiveExpression); + public constructor(public readonly cst: NonterminalNode) { + assertKind(this.cst.kind, NonterminalKind.AdditiveExpression); } public get leftOperand(): Expression { @@ -2705,14 +2705,14 @@ export class MultiplicativeExpression { const [$leftOperand, $operator, $rightOperand] = ast_internal.selectSequence(this.cst); return { - leftOperand: new Expression($leftOperand as NonTerminalNode), + leftOperand: new Expression($leftOperand as NonterminalNode), operator: $operator as TerminalNode, - rightOperand: new Expression($rightOperand as NonTerminalNode), + rightOperand: new Expression($rightOperand as NonterminalNode), }; }); - public constructor(public readonly cst: NonTerminalNode) { - assertKind(this.cst.kind, NonTerminalKind.MultiplicativeExpression); + public constructor(public readonly cst: NonterminalNode) { + assertKind(this.cst.kind, NonterminalKind.MultiplicativeExpression); } public get leftOperand(): Expression { @@ -2733,14 +2733,14 @@ export class ExponentiationExpression { const [$leftOperand, $operator, $rightOperand] = ast_internal.selectSequence(this.cst); return { - leftOperand: new Expression($leftOperand as NonTerminalNode), + leftOperand: new Expression($leftOperand as NonterminalNode), operator: $operator as TerminalNode, - rightOperand: new Expression($rightOperand as NonTerminalNode), + rightOperand: new Expression($rightOperand as NonterminalNode), }; }); - public constructor(public readonly cst: NonTerminalNode) { - assertKind(this.cst.kind, NonTerminalKind.ExponentiationExpression); + public constructor(public readonly cst: NonterminalNode) { + assertKind(this.cst.kind, NonterminalKind.ExponentiationExpression); } public get leftOperand(): Expression { @@ -2761,13 +2761,13 @@ export class PostfixExpression { const [$operand, $operator] = ast_internal.selectSequence(this.cst); return { - operand: new Expression($operand as NonTerminalNode), + operand: new Expression($operand as NonterminalNode), operator: $operator as TerminalNode, }; }); - public constructor(public readonly cst: NonTerminalNode) { - assertKind(this.cst.kind, NonTerminalKind.PostfixExpression); + public constructor(public readonly cst: NonterminalNode) { + assertKind(this.cst.kind, NonterminalKind.PostfixExpression); } public get operand(): Expression { @@ -2785,12 +2785,12 @@ export class PrefixExpression { return { operator: $operator as TerminalNode, - operand: new Expression($operand as NonTerminalNode), + operand: new Expression($operand as NonterminalNode), }; }); - public constructor(public readonly cst: NonTerminalNode) { - assertKind(this.cst.kind, NonTerminalKind.PrefixExpression); + public constructor(public readonly cst: NonterminalNode) { + assertKind(this.cst.kind, NonterminalKind.PrefixExpression); } public get operator(): TerminalNode { @@ -2807,13 +2807,13 @@ export class FunctionCallExpression { const [$operand, $arguments] = ast_internal.selectSequence(this.cst); return { - operand: new Expression($operand as NonTerminalNode), - arguments: new ArgumentsDeclaration($arguments as NonTerminalNode), + operand: new Expression($operand as NonterminalNode), + arguments: new ArgumentsDeclaration($arguments as NonterminalNode), }; }); - public constructor(public readonly cst: NonTerminalNode) { - assertKind(this.cst.kind, NonTerminalKind.FunctionCallExpression); + public constructor(public readonly cst: NonterminalNode) { + assertKind(this.cst.kind, NonterminalKind.FunctionCallExpression); } public get operand(): Expression { @@ -2830,15 +2830,15 @@ export class CallOptionsExpression { const [$operand, $openBrace, $options, $closeBrace] = ast_internal.selectSequence(this.cst); return { - operand: new Expression($operand as NonTerminalNode), + operand: new Expression($operand as NonterminalNode), openBrace: $openBrace as TerminalNode, - options: new CallOptions($options as NonTerminalNode), + options: new CallOptions($options as NonterminalNode), closeBrace: $closeBrace as TerminalNode, }; }); - public constructor(public readonly cst: NonTerminalNode) { - assertKind(this.cst.kind, NonTerminalKind.CallOptionsExpression); + public constructor(public readonly cst: NonterminalNode) { + assertKind(this.cst.kind, NonterminalKind.CallOptionsExpression); } public get operand(): Expression { @@ -2863,14 +2863,14 @@ export class MemberAccessExpression { const [$operand, $period, $member] = ast_internal.selectSequence(this.cst); return { - operand: new Expression($operand as NonTerminalNode), + operand: new Expression($operand as NonterminalNode), period: $period as TerminalNode, - member: new MemberAccess($member as NonTerminalNode), + member: new MemberAccess($member as NonterminalNode), }; }); - public constructor(public readonly cst: NonTerminalNode) { - assertKind(this.cst.kind, NonTerminalKind.MemberAccessExpression); + public constructor(public readonly cst: NonterminalNode) { + assertKind(this.cst.kind, NonterminalKind.MemberAccessExpression); } public get operand(): Expression { @@ -2891,16 +2891,16 @@ export class IndexAccessExpression { const [$operand, $openBracket, $start, $end, $closeBracket] = ast_internal.selectSequence(this.cst); return { - operand: new Expression($operand as NonTerminalNode), + 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), + 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: NonTerminalNode) { - assertKind(this.cst.kind, NonTerminalKind.IndexAccessExpression); + public constructor(public readonly cst: NonterminalNode) { + assertKind(this.cst.kind, NonterminalKind.IndexAccessExpression); } public get operand(): Expression { @@ -2930,12 +2930,12 @@ export class IndexAccessEnd { return { colon: $colon as TerminalNode, - end: $end === null ? undefined : new Expression($end as NonTerminalNode), + end: $end === null ? undefined : new Expression($end as NonterminalNode), }; }); - public constructor(public readonly cst: NonTerminalNode) { - assertKind(this.cst.kind, NonTerminalKind.IndexAccessEnd); + public constructor(public readonly cst: NonterminalNode) { + assertKind(this.cst.kind, NonterminalKind.IndexAccessEnd); } public get colon(): TerminalNode { @@ -2953,13 +2953,13 @@ export class PositionalArgumentsDeclaration { return { openParen: $openParen as TerminalNode, - arguments: new PositionalArguments($arguments as NonTerminalNode), + arguments: new PositionalArguments($arguments as NonterminalNode), closeParen: $closeParen as TerminalNode, }; }); - public constructor(public readonly cst: NonTerminalNode) { - assertKind(this.cst.kind, NonTerminalKind.PositionalArgumentsDeclaration); + public constructor(public readonly cst: NonterminalNode) { + assertKind(this.cst.kind, NonterminalKind.PositionalArgumentsDeclaration); } public get openParen(): TerminalNode { @@ -2981,13 +2981,13 @@ export class NamedArgumentsDeclaration { return { openParen: $openParen as TerminalNode, - arguments: $arguments === null ? undefined : new NamedArgumentGroup($arguments as NonTerminalNode), + arguments: $arguments === null ? undefined : new NamedArgumentGroup($arguments as NonterminalNode), closeParen: $closeParen as TerminalNode, }; }); - public constructor(public readonly cst: NonTerminalNode) { - assertKind(this.cst.kind, NonTerminalKind.NamedArgumentsDeclaration); + public constructor(public readonly cst: NonterminalNode) { + assertKind(this.cst.kind, NonterminalKind.NamedArgumentsDeclaration); } public get openParen(): TerminalNode { @@ -3009,13 +3009,13 @@ export class NamedArgumentGroup { return { openBrace: $openBrace as TerminalNode, - arguments: new NamedArguments($arguments as NonTerminalNode), + arguments: new NamedArguments($arguments as NonterminalNode), closeBrace: $closeBrace as TerminalNode, }; }); - public constructor(public readonly cst: NonTerminalNode) { - assertKind(this.cst.kind, NonTerminalKind.NamedArgumentGroup); + public constructor(public readonly cst: NonterminalNode) { + assertKind(this.cst.kind, NonterminalKind.NamedArgumentGroup); } public get openBrace(): TerminalNode { @@ -3038,12 +3038,12 @@ export class NamedArgument { return { name: $name as TerminalNode, colon: $colon as TerminalNode, - value: new Expression($value as NonTerminalNode), + value: new Expression($value as NonterminalNode), }; }); - public constructor(public readonly cst: NonTerminalNode) { - assertKind(this.cst.kind, NonTerminalKind.NamedArgument); + public constructor(public readonly cst: NonterminalNode) { + assertKind(this.cst.kind, NonterminalKind.NamedArgument); } public get name(): TerminalNode { @@ -3066,13 +3066,13 @@ export class TypeExpression { return { typeKeyword: $typeKeyword as TerminalNode, openParen: $openParen as TerminalNode, - typeName: new TypeName($typeName as NonTerminalNode), + typeName: new TypeName($typeName as NonterminalNode), closeParen: $closeParen as TerminalNode, }; }); - public constructor(public readonly cst: NonTerminalNode) { - assertKind(this.cst.kind, NonTerminalKind.TypeExpression); + public constructor(public readonly cst: NonterminalNode) { + assertKind(this.cst.kind, NonterminalKind.TypeExpression); } public get typeKeyword(): TerminalNode { @@ -3098,12 +3098,12 @@ export class NewExpression { return { newKeyword: $newKeyword as TerminalNode, - typeName: new TypeName($typeName as NonTerminalNode), + typeName: new TypeName($typeName as NonterminalNode), }; }); - public constructor(public readonly cst: NonTerminalNode) { - assertKind(this.cst.kind, NonTerminalKind.NewExpression); + public constructor(public readonly cst: NonterminalNode) { + assertKind(this.cst.kind, NonterminalKind.NewExpression); } public get newKeyword(): TerminalNode { @@ -3121,13 +3121,13 @@ export class TupleExpression { return { openParen: $openParen as TerminalNode, - items: new TupleValues($items as NonTerminalNode), + items: new TupleValues($items as NonterminalNode), closeParen: $closeParen as TerminalNode, }; }); - public constructor(public readonly cst: NonTerminalNode) { - assertKind(this.cst.kind, NonTerminalKind.TupleExpression); + public constructor(public readonly cst: NonterminalNode) { + assertKind(this.cst.kind, NonterminalKind.TupleExpression); } public get openParen(): TerminalNode { @@ -3148,12 +3148,12 @@ export class TupleValue { const [$expression] = ast_internal.selectSequence(this.cst); return { - expression: $expression === null ? undefined : new Expression($expression as NonTerminalNode), + expression: $expression === null ? undefined : new Expression($expression as NonterminalNode), }; }); - public constructor(public readonly cst: NonTerminalNode) { - assertKind(this.cst.kind, NonTerminalKind.TupleValue); + public constructor(public readonly cst: NonterminalNode) { + assertKind(this.cst.kind, NonterminalKind.TupleValue); } public get expression(): Expression | undefined { @@ -3167,13 +3167,13 @@ export class ArrayExpression { return { openBracket: $openBracket as TerminalNode, - items: new ArrayValues($items as NonTerminalNode), + items: new ArrayValues($items as NonterminalNode), closeBracket: $closeBracket as TerminalNode, }; }); - public constructor(public readonly cst: NonTerminalNode) { - assertKind(this.cst.kind, NonTerminalKind.ArrayExpression); + public constructor(public readonly cst: NonterminalNode) { + assertKind(this.cst.kind, NonterminalKind.ArrayExpression); } public get openBracket(): TerminalNode { @@ -3195,12 +3195,12 @@ export class HexNumberExpression { return { literal: $literal as TerminalNode, - unit: $unit === null ? undefined : new NumberUnit($unit as NonTerminalNode), + unit: $unit === null ? undefined : new NumberUnit($unit as NonterminalNode), }; }); - public constructor(public readonly cst: NonTerminalNode) { - assertKind(this.cst.kind, NonTerminalKind.HexNumberExpression); + public constructor(public readonly cst: NonterminalNode) { + assertKind(this.cst.kind, NonterminalKind.HexNumberExpression); } public get literal(): TerminalNode { @@ -3218,12 +3218,12 @@ export class DecimalNumberExpression { return { literal: $literal as TerminalNode, - unit: $unit === null ? undefined : new NumberUnit($unit as NonTerminalNode), + unit: $unit === null ? undefined : new NumberUnit($unit as NonterminalNode), }; }); - public constructor(public readonly cst: NonTerminalNode) { - assertKind(this.cst.kind, NonTerminalKind.DecimalNumberExpression); + public constructor(public readonly cst: NonterminalNode) { + assertKind(this.cst.kind, NonterminalKind.DecimalNumberExpression); } public get literal(): TerminalNode { @@ -3241,13 +3241,13 @@ export class YulBlock { return { openBrace: $openBrace as TerminalNode, - statements: new YulStatements($statements as NonTerminalNode), + statements: new YulStatements($statements as NonterminalNode), closeBrace: $closeBrace as TerminalNode, }; }); - public constructor(public readonly cst: NonTerminalNode) { - assertKind(this.cst.kind, NonTerminalKind.YulBlock); + public constructor(public readonly cst: NonterminalNode) { + assertKind(this.cst.kind, NonterminalKind.YulBlock); } public get openBrace(): TerminalNode { @@ -3270,14 +3270,14 @@ export class YulFunctionDefinition { return { 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), + 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: NonTerminalNode) { - assertKind(this.cst.kind, NonTerminalKind.YulFunctionDefinition); + public constructor(public readonly cst: NonterminalNode) { + assertKind(this.cst.kind, NonterminalKind.YulFunctionDefinition); } public get functionKeyword(): TerminalNode { @@ -3307,13 +3307,13 @@ export class YulParametersDeclaration { return { openParen: $openParen as TerminalNode, - parameters: new YulParameters($parameters as NonTerminalNode), + parameters: new YulParameters($parameters as NonterminalNode), closeParen: $closeParen as TerminalNode, }; }); - public constructor(public readonly cst: NonTerminalNode) { - assertKind(this.cst.kind, NonTerminalKind.YulParametersDeclaration); + public constructor(public readonly cst: NonterminalNode) { + assertKind(this.cst.kind, NonterminalKind.YulParametersDeclaration); } public get openParen(): TerminalNode { @@ -3335,12 +3335,12 @@ export class YulReturnsDeclaration { return { minusGreaterThan: $minusGreaterThan as TerminalNode, - variables: new YulReturnVariables($variables as NonTerminalNode), + variables: new YulReturnVariables($variables as NonterminalNode), }; }); - public constructor(public readonly cst: NonTerminalNode) { - assertKind(this.cst.kind, NonTerminalKind.YulReturnsDeclaration); + public constructor(public readonly cst: NonterminalNode) { + assertKind(this.cst.kind, NonterminalKind.YulReturnsDeclaration); } public get minusGreaterThan(): TerminalNode { @@ -3359,12 +3359,12 @@ export class YulVariableDeclarationStatement { return { letKeyword: $letKeyword as TerminalNode, names: $names as TerminalNode, - value: $value === null ? undefined : new YulVariableDeclarationValue($value as NonTerminalNode), + value: $value === null ? undefined : new YulVariableDeclarationValue($value as NonterminalNode), }; }); - public constructor(public readonly cst: NonTerminalNode) { - assertKind(this.cst.kind, NonTerminalKind.YulVariableDeclarationStatement); + public constructor(public readonly cst: NonterminalNode) { + assertKind(this.cst.kind, NonterminalKind.YulVariableDeclarationStatement); } public get letKeyword(): TerminalNode { @@ -3385,13 +3385,13 @@ export class YulVariableDeclarationValue { const [$assignment, $expression] = ast_internal.selectSequence(this.cst); return { - assignment: new YulAssignmentOperator($assignment as NonTerminalNode), - expression: new YulExpression($expression as NonTerminalNode), + assignment: new YulAssignmentOperator($assignment as NonterminalNode), + expression: new YulExpression($expression as NonterminalNode), }; }); - public constructor(public readonly cst: NonTerminalNode) { - assertKind(this.cst.kind, NonTerminalKind.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 NonTerminalNode), - assignment: new YulAssignmentOperator($assignment as NonTerminalNode), - expression: new YulExpression($expression as NonTerminalNode), + names: new YulPaths($names as NonterminalNode), + assignment: new YulAssignmentOperator($assignment as NonterminalNode), + expression: new YulExpression($expression as NonterminalNode), }; }); - public constructor(public readonly cst: NonTerminalNode) { - assertKind(this.cst.kind, NonTerminalKind.YulAssignmentStatement); + public constructor(public readonly cst: NonterminalNode) { + assertKind(this.cst.kind, NonterminalKind.YulAssignmentStatement); } public get names(): YulPaths { @@ -3441,8 +3441,8 @@ export class YulColonAndEqual { }; }); - public constructor(public readonly cst: NonTerminalNode) { - assertKind(this.cst.kind, NonTerminalKind.YulColonAndEqual); + public constructor(public readonly cst: NonterminalNode) { + assertKind(this.cst.kind, NonterminalKind.YulColonAndEqual); } public get colon(): TerminalNode { @@ -3460,13 +3460,13 @@ export class YulIfStatement { return { ifKeyword: $ifKeyword as TerminalNode, - condition: new YulExpression($condition as NonTerminalNode), - body: new YulBlock($body as NonTerminalNode), + condition: new YulExpression($condition as NonterminalNode), + body: new YulBlock($body as NonterminalNode), }; }); - public constructor(public readonly cst: NonTerminalNode) { - assertKind(this.cst.kind, NonTerminalKind.YulIfStatement); + public constructor(public readonly cst: NonterminalNode) { + assertKind(this.cst.kind, NonterminalKind.YulIfStatement); } public get ifKeyword(): TerminalNode { @@ -3488,15 +3488,15 @@ export class YulForStatement { return { 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), + 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: NonTerminalNode) { - assertKind(this.cst.kind, NonTerminalKind.YulForStatement); + public constructor(public readonly cst: NonterminalNode) { + assertKind(this.cst.kind, NonterminalKind.YulForStatement); } public get forKeyword(): TerminalNode { @@ -3526,13 +3526,13 @@ export class YulSwitchStatement { return { switchKeyword: $switchKeyword as TerminalNode, - expression: new YulExpression($expression as NonTerminalNode), - cases: new YulSwitchCases($cases as NonTerminalNode), + expression: new YulExpression($expression as NonterminalNode), + cases: new YulSwitchCases($cases as NonterminalNode), }; }); - public constructor(public readonly cst: NonTerminalNode) { - assertKind(this.cst.kind, NonTerminalKind.YulSwitchStatement); + public constructor(public readonly cst: NonterminalNode) { + assertKind(this.cst.kind, NonterminalKind.YulSwitchStatement); } public get switchKeyword(): TerminalNode { @@ -3554,12 +3554,12 @@ export class YulDefaultCase { return { defaultKeyword: $defaultKeyword as TerminalNode, - body: new YulBlock($body as NonTerminalNode), + body: new YulBlock($body as NonterminalNode), }; }); - public constructor(public readonly cst: NonTerminalNode) { - assertKind(this.cst.kind, NonTerminalKind.YulDefaultCase); + public constructor(public readonly cst: NonterminalNode) { + assertKind(this.cst.kind, NonterminalKind.YulDefaultCase); } public get defaultKeyword(): TerminalNode { @@ -3577,13 +3577,13 @@ export class YulValueCase { return { caseKeyword: $caseKeyword as TerminalNode, - value: new YulLiteral($value as NonTerminalNode), - body: new YulBlock($body as NonTerminalNode), + value: new YulLiteral($value as NonterminalNode), + body: new YulBlock($body as NonterminalNode), }; }); - public constructor(public readonly cst: NonTerminalNode) { - assertKind(this.cst.kind, NonTerminalKind.YulValueCase); + public constructor(public readonly cst: NonterminalNode) { + assertKind(this.cst.kind, NonterminalKind.YulValueCase); } public get caseKeyword(): TerminalNode { @@ -3608,8 +3608,8 @@ export class YulLeaveStatement { }; }); - public constructor(public readonly cst: NonTerminalNode) { - assertKind(this.cst.kind, NonTerminalKind.YulLeaveStatement); + public constructor(public readonly cst: NonterminalNode) { + assertKind(this.cst.kind, NonterminalKind.YulLeaveStatement); } public get leaveKeyword(): TerminalNode { @@ -3626,8 +3626,8 @@ export class YulBreakStatement { }; }); - public constructor(public readonly cst: NonTerminalNode) { - assertKind(this.cst.kind, NonTerminalKind.YulBreakStatement); + public constructor(public readonly cst: NonterminalNode) { + assertKind(this.cst.kind, NonterminalKind.YulBreakStatement); } public get breakKeyword(): TerminalNode { @@ -3644,8 +3644,8 @@ export class YulContinueStatement { }; }); - public constructor(public readonly cst: NonTerminalNode) { - assertKind(this.cst.kind, NonTerminalKind.YulContinueStatement); + public constructor(public readonly cst: NonterminalNode) { + assertKind(this.cst.kind, NonterminalKind.YulContinueStatement); } public get continueKeyword(): TerminalNode { @@ -3663,8 +3663,8 @@ export class YulLabel { }; }); - public constructor(public readonly cst: NonTerminalNode) { - assertKind(this.cst.kind, NonTerminalKind.YulLabel); + public constructor(public readonly cst: NonterminalNode) { + assertKind(this.cst.kind, NonterminalKind.YulLabel); } public get label(): TerminalNode { @@ -3681,15 +3681,15 @@ export class YulFunctionCallExpression { const [$operand, $openParen, $arguments, $closeParen] = ast_internal.selectSequence(this.cst); return { - operand: new YulExpression($operand as NonTerminalNode), + operand: new YulExpression($operand as NonterminalNode), openParen: $openParen as TerminalNode, - arguments: new YulArguments($arguments as NonTerminalNode), + arguments: new YulArguments($arguments as NonterminalNode), closeParen: $closeParen as TerminalNode, }; }); - public constructor(public readonly cst: NonTerminalNode) { - assertKind(this.cst.kind, NonTerminalKind.YulFunctionCallExpression); + public constructor(public readonly cst: NonterminalNode) { + assertKind(this.cst.kind, NonterminalKind.YulFunctionCallExpression); } public get operand(): YulExpression { @@ -3731,40 +3731,40 @@ export class SourceUnitMember { const variant = ast_internal.selectChoice(this.cst); switch (variant.kind) { - 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); + 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: NonTerminalNode) { - assertKind(this.cst.kind, NonTerminalKind.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 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); + 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: NonTerminalNode) { - assertKind(this.cst.kind, NonTerminalKind.Pragma); + public constructor(public readonly cst: NonterminalNode) { + assertKind(this.cst.kind, NonterminalKind.Pragma); } public get variant(): ABICoderPragma | ExperimentalPragma | VersionPragma { @@ -3816,8 +3816,8 @@ export class ExperimentalFeature { const variant = ast_internal.selectChoice(this.cst); switch (variant.kind) { - case NonTerminalKind.StringLiteral: - return new StringLiteral(variant as NonTerminalNode); + case NonterminalKind.StringLiteral: + return new StringLiteral(variant as NonterminalNode); case TerminalKind.Identifier: return variant as TerminalNode; @@ -3827,8 +3827,8 @@ export class ExperimentalFeature { } }); - public constructor(public readonly cst: NonTerminalNode) { - assertKind(this.cst.kind, NonTerminalKind.ExperimentalFeature); + public constructor(public readonly cst: NonterminalNode) { + assertKind(this.cst.kind, NonterminalKind.ExperimentalFeature); } public get variant(): StringLiteral | TerminalNode { @@ -3841,12 +3841,12 @@ export class VersionExpression { const variant = ast_internal.selectChoice(this.cst); switch (variant.kind) { - 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 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 TerminalKind.SingleQuotedVersionLiteral: case TerminalKind.DoubleQuotedVersionLiteral: @@ -3857,8 +3857,8 @@ export class VersionExpression { } }); - public constructor(public readonly cst: NonTerminalNode) { - assertKind(this.cst.kind, NonTerminalKind.VersionExpression); + public constructor(public readonly cst: NonterminalNode) { + assertKind(this.cst.kind, NonterminalKind.VersionExpression); } public get variant(): VersionRange | VersionComparator | VersionSpecifiers | TerminalNode { @@ -3871,20 +3871,20 @@ export class ImportClause { const variant = ast_internal.selectChoice(this.cst); switch (variant.kind) { - 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); + 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: NonTerminalNode) { - assertKind(this.cst.kind, NonTerminalKind.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 NonTerminalKind.IdentifierPath: - return new IdentifierPath(variant as NonTerminalNode); - case NonTerminalKind.UsingDeconstruction: - return new UsingDeconstruction(variant as NonTerminalNode); + 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: NonTerminalNode) { - assertKind(this.cst.kind, NonTerminalKind.UsingClause); + public constructor(public readonly cst: NonterminalNode) { + assertKind(this.cst.kind, NonterminalKind.UsingClause); } public get variant(): IdentifierPath | UsingDeconstruction { @@ -3943,8 +3943,8 @@ export class UsingOperator { } }); - public constructor(public readonly cst: NonTerminalNode) { - assertKind(this.cst.kind, NonTerminalKind.UsingOperator); + public constructor(public readonly cst: NonterminalNode) { + assertKind(this.cst.kind, NonterminalKind.UsingOperator); } public get variant(): TerminalNode { @@ -3957,8 +3957,8 @@ export class UsingTarget { const variant = ast_internal.selectChoice(this.cst); switch (variant.kind) { - case NonTerminalKind.TypeName: - return new TypeName(variant as NonTerminalNode); + case NonterminalKind.TypeName: + return new TypeName(variant as NonterminalNode); case TerminalKind.Asterisk: return variant as TerminalNode; @@ -3968,8 +3968,8 @@ export class UsingTarget { } }); - public constructor(public readonly cst: NonTerminalNode) { - assertKind(this.cst.kind, NonTerminalKind.UsingTarget); + public constructor(public readonly cst: NonterminalNode) { + assertKind(this.cst.kind, NonterminalKind.UsingTarget); } public get variant(): TypeName | TerminalNode { @@ -3995,40 +3995,40 @@ export class ContractMember { const variant = ast_internal.selectChoice(this.cst); switch (variant.kind) { - 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); + 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: NonTerminalNode) { - assertKind(this.cst.kind, NonTerminalKind.ContractMember); + public constructor(public readonly cst: NonterminalNode) { + assertKind(this.cst.kind, NonterminalKind.ContractMember); } public get variant(): @@ -4054,8 +4054,8 @@ export class StateVariableAttribute { const variant = ast_internal.selectChoice(this.cst); switch (variant.kind) { - case NonTerminalKind.OverrideSpecifier: - return new OverrideSpecifier(variant as NonTerminalNode); + case NonterminalKind.OverrideSpecifier: + return new OverrideSpecifier(variant as NonterminalNode); case TerminalKind.ConstantKeyword: case TerminalKind.InternalKeyword: @@ -4069,8 +4069,8 @@ export class StateVariableAttribute { } }); - public constructor(public readonly cst: NonTerminalNode) { - assertKind(this.cst.kind, NonTerminalKind.StateVariableAttribute); + public constructor(public readonly cst: NonterminalNode) { + assertKind(this.cst.kind, NonterminalKind.StateVariableAttribute); } public get variant(): OverrideSpecifier | TerminalNode { @@ -4093,8 +4093,8 @@ export class FunctionName { } }); - public constructor(public readonly cst: NonTerminalNode) { - assertKind(this.cst.kind, NonTerminalKind.FunctionName); + public constructor(public readonly cst: NonterminalNode) { + assertKind(this.cst.kind, NonterminalKind.FunctionName); } public get variant(): TerminalNode { @@ -4107,10 +4107,10 @@ export class FunctionAttribute { const variant = ast_internal.selectChoice(this.cst); switch (variant.kind) { - case NonTerminalKind.ModifierInvocation: - return new ModifierInvocation(variant as NonTerminalNode); - case NonTerminalKind.OverrideSpecifier: - return new OverrideSpecifier(variant as NonTerminalNode); + case NonterminalKind.ModifierInvocation: + return new ModifierInvocation(variant as NonterminalNode); + case NonterminalKind.OverrideSpecifier: + return new OverrideSpecifier(variant as NonterminalNode); case TerminalKind.ConstantKeyword: case TerminalKind.ExternalKeyword: @@ -4128,8 +4128,8 @@ export class FunctionAttribute { } }); - public constructor(public readonly cst: NonTerminalNode) { - assertKind(this.cst.kind, NonTerminalKind.FunctionAttribute); + public constructor(public readonly cst: NonterminalNode) { + assertKind(this.cst.kind, NonterminalKind.FunctionAttribute); } public get variant(): ModifierInvocation | OverrideSpecifier | TerminalNode { @@ -4142,8 +4142,8 @@ export class FunctionBody { const variant = ast_internal.selectChoice(this.cst); switch (variant.kind) { - case NonTerminalKind.Block: - return new Block(variant as NonTerminalNode); + case NonterminalKind.Block: + return new Block(variant as NonterminalNode); case TerminalKind.Semicolon: return variant as TerminalNode; @@ -4153,8 +4153,8 @@ export class FunctionBody { } }); - public constructor(public readonly cst: NonTerminalNode) { - assertKind(this.cst.kind, NonTerminalKind.FunctionBody); + public constructor(public readonly cst: NonterminalNode) { + assertKind(this.cst.kind, NonterminalKind.FunctionBody); } public get variant(): Block | TerminalNode { @@ -4167,8 +4167,8 @@ export class ConstructorAttribute { const variant = ast_internal.selectChoice(this.cst); switch (variant.kind) { - case NonTerminalKind.ModifierInvocation: - return new ModifierInvocation(variant as NonTerminalNode); + case NonterminalKind.ModifierInvocation: + return new ModifierInvocation(variant as NonterminalNode); case TerminalKind.InternalKeyword: case TerminalKind.OverrideKeyword: @@ -4182,8 +4182,8 @@ export class ConstructorAttribute { } }); - public constructor(public readonly cst: NonTerminalNode) { - assertKind(this.cst.kind, NonTerminalKind.ConstructorAttribute); + public constructor(public readonly cst: NonterminalNode) { + assertKind(this.cst.kind, NonterminalKind.ConstructorAttribute); } public get variant(): ModifierInvocation | TerminalNode { @@ -4196,8 +4196,8 @@ export class UnnamedFunctionAttribute { const variant = ast_internal.selectChoice(this.cst); switch (variant.kind) { - case NonTerminalKind.ModifierInvocation: - return new ModifierInvocation(variant as NonTerminalNode); + case NonterminalKind.ModifierInvocation: + return new ModifierInvocation(variant as NonterminalNode); case TerminalKind.ConstantKeyword: case TerminalKind.ExternalKeyword: @@ -4214,8 +4214,8 @@ export class UnnamedFunctionAttribute { } }); - public constructor(public readonly cst: NonTerminalNode) { - assertKind(this.cst.kind, NonTerminalKind.UnnamedFunctionAttribute); + public constructor(public readonly cst: NonterminalNode) { + assertKind(this.cst.kind, NonterminalKind.UnnamedFunctionAttribute); } public get variant(): ModifierInvocation | TerminalNode { @@ -4228,10 +4228,10 @@ export class FallbackFunctionAttribute { const variant = ast_internal.selectChoice(this.cst); switch (variant.kind) { - case NonTerminalKind.ModifierInvocation: - return new ModifierInvocation(variant as NonTerminalNode); - case NonTerminalKind.OverrideSpecifier: - return new OverrideSpecifier(variant as NonTerminalNode); + case NonterminalKind.ModifierInvocation: + return new ModifierInvocation(variant as NonterminalNode); + case NonterminalKind.OverrideSpecifier: + return new OverrideSpecifier(variant as NonterminalNode); case TerminalKind.ExternalKeyword: case TerminalKind.PayableKeyword: @@ -4245,8 +4245,8 @@ export class FallbackFunctionAttribute { } }); - public constructor(public readonly cst: NonTerminalNode) { - assertKind(this.cst.kind, NonTerminalKind.FallbackFunctionAttribute); + public constructor(public readonly cst: NonterminalNode) { + assertKind(this.cst.kind, NonterminalKind.FallbackFunctionAttribute); } public get variant(): ModifierInvocation | OverrideSpecifier | TerminalNode { @@ -4259,10 +4259,10 @@ export class ReceiveFunctionAttribute { const variant = ast_internal.selectChoice(this.cst); switch (variant.kind) { - case NonTerminalKind.ModifierInvocation: - return new ModifierInvocation(variant as NonTerminalNode); - case NonTerminalKind.OverrideSpecifier: - return new OverrideSpecifier(variant as NonTerminalNode); + case NonterminalKind.ModifierInvocation: + return new ModifierInvocation(variant as NonterminalNode); + case NonterminalKind.OverrideSpecifier: + return new OverrideSpecifier(variant as NonterminalNode); case TerminalKind.ExternalKeyword: case TerminalKind.PayableKeyword: @@ -4274,8 +4274,8 @@ export class ReceiveFunctionAttribute { } }); - public constructor(public readonly cst: NonTerminalNode) { - assertKind(this.cst.kind, NonTerminalKind.ReceiveFunctionAttribute); + public constructor(public readonly cst: NonterminalNode) { + assertKind(this.cst.kind, NonterminalKind.ReceiveFunctionAttribute); } public get variant(): ModifierInvocation | OverrideSpecifier | TerminalNode { @@ -4288,8 +4288,8 @@ export class ModifierAttribute { const variant = ast_internal.selectChoice(this.cst); switch (variant.kind) { - case NonTerminalKind.OverrideSpecifier: - return new OverrideSpecifier(variant as NonTerminalNode); + case NonterminalKind.OverrideSpecifier: + return new OverrideSpecifier(variant as NonterminalNode); case TerminalKind.VirtualKeyword: return variant as TerminalNode; @@ -4299,8 +4299,8 @@ export class ModifierAttribute { } }); - public constructor(public readonly cst: NonTerminalNode) { - assertKind(this.cst.kind, NonTerminalKind.ModifierAttribute); + public constructor(public readonly cst: NonterminalNode) { + assertKind(this.cst.kind, NonterminalKind.ModifierAttribute); } public get variant(): OverrideSpecifier | TerminalNode { @@ -4314,16 +4314,16 @@ export class TypeName { const variant = ast_internal.selectChoice(this.cst); switch (variant.kind) { - 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); + 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: NonTerminalNode) { - assertKind(this.cst.kind, NonTerminalKind.TypeName); + public constructor(public readonly cst: NonterminalNode) { + assertKind(this.cst.kind, NonterminalKind.TypeName); } public get variant(): ArrayTypeName | FunctionType | MappingType | ElementaryType | IdentifierPath { @@ -4360,8 +4360,8 @@ export class FunctionTypeAttribute { } }); - public constructor(public readonly cst: NonTerminalNode) { - assertKind(this.cst.kind, NonTerminalKind.FunctionTypeAttribute); + public constructor(public readonly cst: NonterminalNode) { + assertKind(this.cst.kind, NonterminalKind.FunctionTypeAttribute); } public get variant(): TerminalNode { @@ -4374,18 +4374,18 @@ export class MappingKeyType { const variant = ast_internal.selectChoice(this.cst); switch (variant.kind) { - case NonTerminalKind.ElementaryType: - return new ElementaryType(variant as NonTerminalNode); - case NonTerminalKind.IdentifierPath: - return new IdentifierPath(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}`); } }); - public constructor(public readonly cst: NonTerminalNode) { - assertKind(this.cst.kind, NonTerminalKind.MappingKeyType); + public constructor(public readonly cst: NonterminalNode) { + assertKind(this.cst.kind, NonterminalKind.MappingKeyType); } public get variant(): ElementaryType | IdentifierPath { @@ -4398,8 +4398,8 @@ export class ElementaryType { const variant = ast_internal.selectChoice(this.cst); switch (variant.kind) { - case NonTerminalKind.AddressType: - return new AddressType(variant as NonTerminalNode); + case NonterminalKind.AddressType: + return new AddressType(variant as NonterminalNode); case TerminalKind.BoolKeyword: case TerminalKind.ByteKeyword: @@ -4416,8 +4416,8 @@ export class ElementaryType { } }); - public constructor(public readonly cst: NonTerminalNode) { - assertKind(this.cst.kind, NonTerminalKind.ElementaryType); + public constructor(public readonly cst: NonterminalNode) { + assertKind(this.cst.kind, NonterminalKind.ElementaryType); } public get variant(): AddressType | TerminalNode { @@ -4447,48 +4447,48 @@ export class Statement { const variant = ast_internal.selectChoice(this.cst); switch (variant.kind) { - 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); + 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: NonTerminalNode) { - assertKind(this.cst.kind, NonTerminalKind.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 NonTerminalKind.TypedTupleMember: - return new TypedTupleMember(variant as NonTerminalNode); - case NonTerminalKind.UntypedTupleMember: - return new UntypedTupleMember(variant as NonTerminalNode); + 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: NonTerminalNode) { - assertKind(this.cst.kind, NonTerminalKind.TupleMember); + public constructor(public readonly cst: NonterminalNode) { + assertKind(this.cst.kind, NonterminalKind.TupleMember); } public get variant(): TypedTupleMember | UntypedTupleMember { @@ -4542,8 +4542,8 @@ export class VariableDeclarationType { const variant = ast_internal.selectChoice(this.cst); switch (variant.kind) { - case NonTerminalKind.TypeName: - return new TypeName(variant as NonTerminalNode); + case NonterminalKind.TypeName: + return new TypeName(variant as NonterminalNode); case TerminalKind.VarKeyword: return variant as TerminalNode; @@ -4553,8 +4553,8 @@ export class VariableDeclarationType { } }); - public constructor(public readonly cst: NonTerminalNode) { - assertKind(this.cst.kind, NonTerminalKind.VariableDeclarationType); + public constructor(public readonly cst: NonterminalNode) { + assertKind(this.cst.kind, NonterminalKind.VariableDeclarationType); } public get variant(): TypeName | TerminalNode { @@ -4577,8 +4577,8 @@ export class StorageLocation { } }); - public constructor(public readonly cst: NonTerminalNode) { - assertKind(this.cst.kind, NonTerminalKind.StorageLocation); + public constructor(public readonly cst: NonterminalNode) { + assertKind(this.cst.kind, NonterminalKind.StorageLocation); } public get variant(): TerminalNode { @@ -4595,12 +4595,12 @@ export class ForStatementInitialization { const variant = ast_internal.selectChoice(this.cst); switch (variant.kind) { - 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.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 TerminalKind.Semicolon: return variant as TerminalNode; @@ -4610,8 +4610,8 @@ export class ForStatementInitialization { } }); - public constructor(public readonly cst: NonTerminalNode) { - assertKind(this.cst.kind, NonTerminalKind.ForStatementInitialization); + public constructor(public readonly cst: NonterminalNode) { + assertKind(this.cst.kind, NonterminalKind.ForStatementInitialization); } public get variant(): @@ -4628,8 +4628,8 @@ export class ForStatementCondition { const variant = ast_internal.selectChoice(this.cst); switch (variant.kind) { - case NonTerminalKind.ExpressionStatement: - return new ExpressionStatement(variant as NonTerminalNode); + case NonterminalKind.ExpressionStatement: + return new ExpressionStatement(variant as NonterminalNode); case TerminalKind.Semicolon: return variant as TerminalNode; @@ -4639,8 +4639,8 @@ export class ForStatementCondition { } }); - public constructor(public readonly cst: NonTerminalNode) { - assertKind(this.cst.kind, NonTerminalKind.ForStatementCondition); + public constructor(public readonly cst: NonterminalNode) { + assertKind(this.cst.kind, NonterminalKind.ForStatementCondition); } public get variant(): ExpressionStatement | TerminalNode { @@ -4681,60 +4681,60 @@ export class Expression { const variant = ast_internal.selectChoice(this.cst); switch (variant.kind) { - 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 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: @@ -4747,8 +4747,8 @@ export class Expression { } }); - public constructor(public readonly cst: NonTerminalNode) { - assertKind(this.cst.kind, NonTerminalKind.Expression); + public constructor(public readonly cst: NonterminalNode) { + assertKind(this.cst.kind, NonterminalKind.Expression); } public get variant(): @@ -4798,8 +4798,8 @@ export class MemberAccess { } }); - public constructor(public readonly cst: NonTerminalNode) { - assertKind(this.cst.kind, NonTerminalKind.MemberAccess); + public constructor(public readonly cst: NonterminalNode) { + assertKind(this.cst.kind, NonterminalKind.MemberAccess); } public get variant(): TerminalNode { @@ -4812,18 +4812,18 @@ export class ArgumentsDeclaration { const variant = ast_internal.selectChoice(this.cst); switch (variant.kind) { - case NonTerminalKind.PositionalArgumentsDeclaration: - return new PositionalArgumentsDeclaration(variant as NonTerminalNode); - case NonTerminalKind.NamedArgumentsDeclaration: - return new NamedArgumentsDeclaration(variant as NonTerminalNode); + 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: NonTerminalNode) { - assertKind(this.cst.kind, NonTerminalKind.ArgumentsDeclaration); + public constructor(public readonly cst: NonterminalNode) { + assertKind(this.cst.kind, NonterminalKind.ArgumentsDeclaration); } public get variant(): PositionalArgumentsDeclaration | NamedArgumentsDeclaration { @@ -4854,8 +4854,8 @@ export class NumberUnit { } }); - public constructor(public readonly cst: NonTerminalNode) { - assertKind(this.cst.kind, NonTerminalKind.NumberUnit); + public constructor(public readonly cst: NonterminalNode) { + assertKind(this.cst.kind, NonterminalKind.NumberUnit); } public get variant(): TerminalNode { @@ -4873,24 +4873,24 @@ export class StringExpression { const variant = ast_internal.selectChoice(this.cst); switch (variant.kind) { - 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); + 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: NonTerminalNode) { - assertKind(this.cst.kind, NonTerminalKind.StringExpression); + public constructor(public readonly cst: NonterminalNode) { + assertKind(this.cst.kind, NonterminalKind.StringExpression); } public get variant(): StringLiteral | StringLiterals | HexStringLiteral | HexStringLiterals | UnicodeStringLiterals { @@ -4912,8 +4912,8 @@ export class StringLiteral { } }); - public constructor(public readonly cst: NonTerminalNode) { - assertKind(this.cst.kind, NonTerminalKind.StringLiteral); + public constructor(public readonly cst: NonterminalNode) { + assertKind(this.cst.kind, NonterminalKind.StringLiteral); } public get variant(): TerminalNode { @@ -4935,8 +4935,8 @@ export class HexStringLiteral { } }); - public constructor(public readonly cst: NonTerminalNode) { - assertKind(this.cst.kind, NonTerminalKind.HexStringLiteral); + public constructor(public readonly cst: NonterminalNode) { + assertKind(this.cst.kind, NonterminalKind.HexStringLiteral); } public get variant(): TerminalNode { @@ -4958,8 +4958,8 @@ export class UnicodeStringLiteral { } }); - public constructor(public readonly cst: NonTerminalNode) { - assertKind(this.cst.kind, NonTerminalKind.UnicodeStringLiteral); + public constructor(public readonly cst: NonterminalNode) { + assertKind(this.cst.kind, NonterminalKind.UnicodeStringLiteral); } public get variant(): TerminalNode { @@ -4984,38 +4984,38 @@ export class YulStatement { const variant = ast_internal.selectChoice(this.cst); switch (variant.kind) { - 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); + 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: NonTerminalNode) { - assertKind(this.cst.kind, NonTerminalKind.YulStatement); + public constructor(public readonly cst: NonterminalNode) { + assertKind(this.cst.kind, NonterminalKind.YulStatement); } public get variant(): @@ -5040,8 +5040,8 @@ export class YulAssignmentOperator { const variant = ast_internal.selectChoice(this.cst); switch (variant.kind) { - case NonTerminalKind.YulColonAndEqual: - return new YulColonAndEqual(variant as NonTerminalNode); + case NonterminalKind.YulColonAndEqual: + return new YulColonAndEqual(variant as NonterminalNode); case TerminalKind.ColonEqual: return variant as TerminalNode; @@ -5051,8 +5051,8 @@ export class YulAssignmentOperator { } }); - public constructor(public readonly cst: NonTerminalNode) { - assertKind(this.cst.kind, NonTerminalKind.YulAssignmentOperator); + public constructor(public readonly cst: NonterminalNode) { + assertKind(this.cst.kind, NonterminalKind.YulAssignmentOperator); } public get variant(): YulColonAndEqual | TerminalNode { @@ -5065,18 +5065,18 @@ export class YulSwitchCase { const variant = ast_internal.selectChoice(this.cst); switch (variant.kind) { - case NonTerminalKind.YulDefaultCase: - return new YulDefaultCase(variant as NonTerminalNode); - case NonTerminalKind.YulValueCase: - return new YulValueCase(variant as NonTerminalNode); + 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: NonTerminalNode) { - assertKind(this.cst.kind, NonTerminalKind.YulSwitchCase); + public constructor(public readonly cst: NonterminalNode) { + assertKind(this.cst.kind, NonterminalKind.YulSwitchCase); } public get variant(): YulDefaultCase | YulValueCase { @@ -5089,22 +5089,22 @@ export class YulExpression { const variant = ast_internal.selectChoice(this.cst); switch (variant.kind) { - 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); + 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: NonTerminalNode) { - assertKind(this.cst.kind, NonTerminalKind.YulExpression); + public constructor(public readonly cst: NonterminalNode) { + assertKind(this.cst.kind, NonterminalKind.YulExpression); } public get variant(): YulFunctionCallExpression | YulLiteral | YulBuiltInFunction | YulPath { @@ -5126,8 +5126,8 @@ export class YulPathComponent { } }); - public constructor(public readonly cst: NonTerminalNode) { - assertKind(this.cst.kind, NonTerminalKind.YulPathComponent); + public constructor(public readonly cst: NonterminalNode) { + assertKind(this.cst.kind, NonterminalKind.YulPathComponent); } public get variant(): TerminalNode { @@ -5228,8 +5228,8 @@ export class YulBuiltInFunction { } }); - public constructor(public readonly cst: NonTerminalNode) { - assertKind(this.cst.kind, NonTerminalKind.YulBuiltInFunction); + public constructor(public readonly cst: NonterminalNode) { + assertKind(this.cst.kind, NonterminalKind.YulBuiltInFunction); } public get variant(): TerminalNode { @@ -5242,10 +5242,10 @@ export class YulLiteral { const variant = ast_internal.selectChoice(this.cst); switch (variant.kind) { - case NonTerminalKind.HexStringLiteral: - return new HexStringLiteral(variant as NonTerminalNode); - case NonTerminalKind.StringLiteral: - return new StringLiteral(variant as NonTerminalNode); + case NonterminalKind.HexStringLiteral: + return new HexStringLiteral(variant as NonterminalNode); + case NonterminalKind.StringLiteral: + return new StringLiteral(variant as NonterminalNode); case TerminalKind.YulTrueKeyword: case TerminalKind.YulFalseKeyword: @@ -5258,8 +5258,8 @@ export class YulLiteral { } }); - public constructor(public readonly cst: NonTerminalNode) { - assertKind(this.cst.kind, NonTerminalKind.YulLiteral); + public constructor(public readonly cst: NonterminalNode) { + assertKind(this.cst.kind, NonterminalKind.YulLiteral); } public get variant(): HexStringLiteral | StringLiteral | TerminalNode { @@ -5274,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 NonTerminalNode)); + return items.map((item) => new SourceUnitMember(item as NonterminalNode)); }); - public constructor(public readonly cst: NonTerminalNode) { - assertKind(this.cst.kind, NonTerminalKind.SourceUnitMembers); + public constructor(public readonly cst: NonterminalNode) { + assertKind(this.cst.kind, NonterminalKind.SourceUnitMembers); } public get items(): readonly SourceUnitMember[] { @@ -5289,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 NonTerminalNode)); + return items.map((item) => new VersionExpression(item as NonterminalNode)); }); - public constructor(public readonly cst: NonTerminalNode) { - assertKind(this.cst.kind, NonTerminalKind.VersionExpressionSet); + public constructor(public readonly cst: NonterminalNode) { + assertKind(this.cst.kind, NonterminalKind.VersionExpressionSet); } public get items(): readonly VersionExpression[] { @@ -5304,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 NonTerminalNode)); + return items.map((item) => new ContractMember(item as NonterminalNode)); }); - public constructor(public readonly cst: NonTerminalNode) { - assertKind(this.cst.kind, NonTerminalKind.ContractMembers); + public constructor(public readonly cst: NonterminalNode) { + assertKind(this.cst.kind, NonterminalKind.ContractMembers); } public get items(): readonly ContractMember[] { @@ -5319,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 NonTerminalNode)); + return items.map((item) => new ContractMember(item as NonterminalNode)); }); - public constructor(public readonly cst: NonTerminalNode) { - assertKind(this.cst.kind, NonTerminalKind.InterfaceMembers); + public constructor(public readonly cst: NonterminalNode) { + assertKind(this.cst.kind, NonterminalKind.InterfaceMembers); } public get items(): readonly ContractMember[] { @@ -5334,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 NonTerminalNode)); + return items.map((item) => new ContractMember(item as NonterminalNode)); }); - public constructor(public readonly cst: NonTerminalNode) { - assertKind(this.cst.kind, NonTerminalKind.LibraryMembers); + public constructor(public readonly cst: NonterminalNode) { + assertKind(this.cst.kind, NonterminalKind.LibraryMembers); } public get items(): readonly ContractMember[] { @@ -5349,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 NonTerminalNode)); + return items.map((item) => new StructMember(item as NonterminalNode)); }); - public constructor(public readonly cst: NonTerminalNode) { - assertKind(this.cst.kind, NonTerminalKind.StructMembers); + public constructor(public readonly cst: NonterminalNode) { + assertKind(this.cst.kind, NonterminalKind.StructMembers); } public get items(): readonly StructMember[] { @@ -5364,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 NonTerminalNode)); + return items.map((item) => new StateVariableAttribute(item as NonterminalNode)); }); - public constructor(public readonly cst: NonTerminalNode) { - assertKind(this.cst.kind, NonTerminalKind.StateVariableAttributes); + public constructor(public readonly cst: NonterminalNode) { + assertKind(this.cst.kind, NonterminalKind.StateVariableAttributes); } public get items(): readonly StateVariableAttribute[] { @@ -5379,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 NonTerminalNode)); + return items.map((item) => new FunctionAttribute(item as NonterminalNode)); }); - public constructor(public readonly cst: NonTerminalNode) { - assertKind(this.cst.kind, NonTerminalKind.FunctionAttributes); + public constructor(public readonly cst: NonterminalNode) { + assertKind(this.cst.kind, NonterminalKind.FunctionAttributes); } public get items(): readonly FunctionAttribute[] { @@ -5394,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 NonTerminalNode)); + return items.map((item) => new ConstructorAttribute(item as NonterminalNode)); }); - public constructor(public readonly cst: NonTerminalNode) { - assertKind(this.cst.kind, NonTerminalKind.ConstructorAttributes); + public constructor(public readonly cst: NonterminalNode) { + assertKind(this.cst.kind, NonterminalKind.ConstructorAttributes); } public get items(): readonly ConstructorAttribute[] { @@ -5409,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 NonTerminalNode)); + return items.map((item) => new UnnamedFunctionAttribute(item as NonterminalNode)); }); - public constructor(public readonly cst: NonTerminalNode) { - assertKind(this.cst.kind, NonTerminalKind.UnnamedFunctionAttributes); + public constructor(public readonly cst: NonterminalNode) { + assertKind(this.cst.kind, NonterminalKind.UnnamedFunctionAttributes); } public get items(): readonly UnnamedFunctionAttribute[] { @@ -5424,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 NonTerminalNode)); + return items.map((item) => new FallbackFunctionAttribute(item as NonterminalNode)); }); - public constructor(public readonly cst: NonTerminalNode) { - assertKind(this.cst.kind, NonTerminalKind.FallbackFunctionAttributes); + public constructor(public readonly cst: NonterminalNode) { + assertKind(this.cst.kind, NonterminalKind.FallbackFunctionAttributes); } public get items(): readonly FallbackFunctionAttribute[] { @@ -5439,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 NonTerminalNode)); + return items.map((item) => new ReceiveFunctionAttribute(item as NonterminalNode)); }); - public constructor(public readonly cst: NonTerminalNode) { - assertKind(this.cst.kind, NonTerminalKind.ReceiveFunctionAttributes); + public constructor(public readonly cst: NonterminalNode) { + assertKind(this.cst.kind, NonterminalKind.ReceiveFunctionAttributes); } public get items(): readonly ReceiveFunctionAttribute[] { @@ -5454,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 NonTerminalNode)); + return items.map((item) => new ModifierAttribute(item as NonterminalNode)); }); - public constructor(public readonly cst: NonTerminalNode) { - assertKind(this.cst.kind, NonTerminalKind.ModifierAttributes); + public constructor(public readonly cst: NonterminalNode) { + assertKind(this.cst.kind, NonterminalKind.ModifierAttributes); } public get items(): readonly ModifierAttribute[] { @@ -5469,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 NonTerminalNode)); + return items.map((item) => new FunctionTypeAttribute(item as NonterminalNode)); }); - public constructor(public readonly cst: NonTerminalNode) { - assertKind(this.cst.kind, NonTerminalKind.FunctionTypeAttributes); + public constructor(public readonly cst: NonterminalNode) { + assertKind(this.cst.kind, NonterminalKind.FunctionTypeAttributes); } public get items(): readonly FunctionTypeAttribute[] { @@ -5484,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 NonTerminalNode)); + return items.map((item) => new Statement(item as NonterminalNode)); }); - public constructor(public readonly cst: NonTerminalNode) { - assertKind(this.cst.kind, NonTerminalKind.Statements); + public constructor(public readonly cst: NonterminalNode) { + assertKind(this.cst.kind, NonterminalKind.Statements); } public get items(): readonly Statement[] { @@ -5499,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 NonTerminalNode)); + return items.map((item) => new CatchClause(item as NonterminalNode)); }); - public constructor(public readonly cst: NonTerminalNode) { - assertKind(this.cst.kind, NonTerminalKind.CatchClauses); + public constructor(public readonly cst: NonterminalNode) { + assertKind(this.cst.kind, NonterminalKind.CatchClauses); } public get items(): readonly CatchClause[] { @@ -5514,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 NonTerminalNode)); + return items.map((item) => new StringLiteral(item as NonterminalNode)); }); - public constructor(public readonly cst: NonTerminalNode) { - assertKind(this.cst.kind, NonTerminalKind.StringLiterals); + public constructor(public readonly cst: NonterminalNode) { + assertKind(this.cst.kind, NonterminalKind.StringLiterals); } public get items(): readonly StringLiteral[] { @@ -5529,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 NonTerminalNode)); + return items.map((item) => new HexStringLiteral(item as NonterminalNode)); }); - public constructor(public readonly cst: NonTerminalNode) { - assertKind(this.cst.kind, NonTerminalKind.HexStringLiterals); + public constructor(public readonly cst: NonterminalNode) { + assertKind(this.cst.kind, NonterminalKind.HexStringLiterals); } public get items(): readonly HexStringLiteral[] { @@ -5544,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 NonTerminalNode)); + return items.map((item) => new UnicodeStringLiteral(item as NonterminalNode)); }); - public constructor(public readonly cst: NonTerminalNode) { - assertKind(this.cst.kind, NonTerminalKind.UnicodeStringLiterals); + public constructor(public readonly cst: NonterminalNode) { + assertKind(this.cst.kind, NonterminalKind.UnicodeStringLiterals); } public get items(): readonly UnicodeStringLiteral[] { @@ -5559,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 NonTerminalNode)); + return items.map((item) => new YulStatement(item as NonterminalNode)); }); - public constructor(public readonly cst: NonTerminalNode) { - assertKind(this.cst.kind, NonTerminalKind.YulStatements); + public constructor(public readonly cst: NonterminalNode) { + assertKind(this.cst.kind, NonterminalKind.YulStatements); } public get items(): readonly YulStatement[] { @@ -5574,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 NonTerminalNode)); + return items.map((item) => new YulSwitchCase(item as NonterminalNode)); }); - public constructor(public readonly cst: NonTerminalNode) { - assertKind(this.cst.kind, NonTerminalKind.YulSwitchCases); + public constructor(public readonly cst: NonterminalNode) { + assertKind(this.cst.kind, NonterminalKind.YulSwitchCases); } public get items(): readonly YulSwitchCase[] { @@ -5595,13 +5595,13 @@ export class VersionExpressionSets { const [items, separators] = ast_internal.selectSeparated(this.cst); return { - items: items.map((item) => new VersionExpressionSet(item as NonTerminalNode)), + items: items.map((item) => new VersionExpressionSet(item as NonterminalNode)), separators: separators as TerminalNode[], }; }); - public constructor(public readonly cst: NonTerminalNode) { - assertKind(this.cst.kind, NonTerminalKind.VersionExpressionSets); + public constructor(public readonly cst: NonterminalNode) { + assertKind(this.cst.kind, NonterminalKind.VersionExpressionSets); } public get items(): readonly VersionExpressionSet[] { @@ -5620,8 +5620,8 @@ export class VersionSpecifiers { return { items: items as TerminalNode[], separators: separators as TerminalNode[] }; }); - public constructor(public readonly cst: NonTerminalNode) { - assertKind(this.cst.kind, NonTerminalKind.VersionSpecifiers); + public constructor(public readonly cst: NonterminalNode) { + assertKind(this.cst.kind, NonterminalKind.VersionSpecifiers); } public get items(): readonly TerminalNode[] { @@ -5638,13 +5638,13 @@ export class ImportDeconstructionSymbols { const [items, separators] = ast_internal.selectSeparated(this.cst); return { - items: items.map((item) => new ImportDeconstructionSymbol(item as NonTerminalNode)), + items: items.map((item) => new ImportDeconstructionSymbol(item as NonterminalNode)), separators: separators as TerminalNode[], }; }); - public constructor(public readonly cst: NonTerminalNode) { - assertKind(this.cst.kind, NonTerminalKind.ImportDeconstructionSymbols); + public constructor(public readonly cst: NonterminalNode) { + assertKind(this.cst.kind, NonterminalKind.ImportDeconstructionSymbols); } public get items(): readonly ImportDeconstructionSymbol[] { @@ -5661,13 +5661,13 @@ export class UsingDeconstructionSymbols { const [items, separators] = ast_internal.selectSeparated(this.cst); return { - items: items.map((item) => new UsingDeconstructionSymbol(item as NonTerminalNode)), + items: items.map((item) => new UsingDeconstructionSymbol(item as NonterminalNode)), separators: separators as TerminalNode[], }; }); - public constructor(public readonly cst: NonTerminalNode) { - assertKind(this.cst.kind, NonTerminalKind.UsingDeconstructionSymbols); + public constructor(public readonly cst: NonterminalNode) { + assertKind(this.cst.kind, NonterminalKind.UsingDeconstructionSymbols); } public get items(): readonly UsingDeconstructionSymbol[] { @@ -5684,13 +5684,13 @@ export class InheritanceTypes { const [items, separators] = ast_internal.selectSeparated(this.cst); return { - items: items.map((item) => new InheritanceType(item as NonTerminalNode)), + items: items.map((item) => new InheritanceType(item as NonterminalNode)), separators: separators as TerminalNode[], }; }); - public constructor(public readonly cst: NonTerminalNode) { - assertKind(this.cst.kind, NonTerminalKind.InheritanceTypes); + public constructor(public readonly cst: NonterminalNode) { + assertKind(this.cst.kind, NonterminalKind.InheritanceTypes); } public get items(): readonly InheritanceType[] { @@ -5709,8 +5709,8 @@ export class EnumMembers { return { items: items as TerminalNode[], separators: separators as TerminalNode[] }; }); - public constructor(public readonly cst: NonTerminalNode) { - assertKind(this.cst.kind, NonTerminalKind.EnumMembers); + public constructor(public readonly cst: NonterminalNode) { + assertKind(this.cst.kind, NonterminalKind.EnumMembers); } public get items(): readonly TerminalNode[] { @@ -5727,13 +5727,13 @@ export class Parameters { const [items, separators] = ast_internal.selectSeparated(this.cst); return { - items: items.map((item) => new Parameter(item as NonTerminalNode)), + items: items.map((item) => new Parameter(item as NonterminalNode)), separators: separators as TerminalNode[], }; }); - public constructor(public readonly cst: NonTerminalNode) { - assertKind(this.cst.kind, NonTerminalKind.Parameters); + public constructor(public readonly cst: NonterminalNode) { + assertKind(this.cst.kind, NonterminalKind.Parameters); } public get items(): readonly Parameter[] { @@ -5750,13 +5750,13 @@ export class OverridePaths { const [items, separators] = ast_internal.selectSeparated(this.cst); return { - items: items.map((item) => new IdentifierPath(item as NonTerminalNode)), + items: items.map((item) => new IdentifierPath(item as NonterminalNode)), separators: separators as TerminalNode[], }; }); - public constructor(public readonly cst: NonTerminalNode) { - assertKind(this.cst.kind, NonTerminalKind.OverridePaths); + public constructor(public readonly cst: NonterminalNode) { + assertKind(this.cst.kind, NonterminalKind.OverridePaths); } public get items(): readonly IdentifierPath[] { @@ -5773,13 +5773,13 @@ export class EventParameters { const [items, separators] = ast_internal.selectSeparated(this.cst); return { - items: items.map((item) => new EventParameter(item as NonTerminalNode)), + items: items.map((item) => new EventParameter(item as NonterminalNode)), separators: separators as TerminalNode[], }; }); - public constructor(public readonly cst: NonTerminalNode) { - assertKind(this.cst.kind, NonTerminalKind.EventParameters); + public constructor(public readonly cst: NonterminalNode) { + assertKind(this.cst.kind, NonterminalKind.EventParameters); } public get items(): readonly EventParameter[] { @@ -5796,13 +5796,13 @@ export class ErrorParameters { const [items, separators] = ast_internal.selectSeparated(this.cst); return { - items: items.map((item) => new ErrorParameter(item as NonTerminalNode)), + items: items.map((item) => new ErrorParameter(item as NonterminalNode)), separators: separators as TerminalNode[], }; }); - public constructor(public readonly cst: NonTerminalNode) { - assertKind(this.cst.kind, NonTerminalKind.ErrorParameters); + public constructor(public readonly cst: NonterminalNode) { + assertKind(this.cst.kind, NonterminalKind.ErrorParameters); } public get items(): readonly ErrorParameter[] { @@ -5819,13 +5819,13 @@ export class AssemblyFlags { const [items, separators] = ast_internal.selectSeparated(this.cst); return { - items: items.map((item) => new StringLiteral(item as NonTerminalNode)), + items: items.map((item) => new StringLiteral(item as NonterminalNode)), separators: separators as TerminalNode[], }; }); - public constructor(public readonly cst: NonTerminalNode) { - assertKind(this.cst.kind, NonTerminalKind.AssemblyFlags); + public constructor(public readonly cst: NonterminalNode) { + assertKind(this.cst.kind, NonterminalKind.AssemblyFlags); } public get items(): readonly StringLiteral[] { @@ -5842,13 +5842,13 @@ export class TupleDeconstructionElements { const [items, separators] = ast_internal.selectSeparated(this.cst); return { - items: items.map((item) => new TupleDeconstructionElement(item as NonTerminalNode)), + items: items.map((item) => new TupleDeconstructionElement(item as NonterminalNode)), separators: separators as TerminalNode[], }; }); - public constructor(public readonly cst: NonTerminalNode) { - assertKind(this.cst.kind, NonTerminalKind.TupleDeconstructionElements); + public constructor(public readonly cst: NonterminalNode) { + assertKind(this.cst.kind, NonterminalKind.TupleDeconstructionElements); } public get items(): readonly TupleDeconstructionElement[] { @@ -5865,13 +5865,13 @@ export class PositionalArguments { const [items, separators] = ast_internal.selectSeparated(this.cst); return { - items: items.map((item) => new Expression(item as NonTerminalNode)), + items: items.map((item) => new Expression(item as NonterminalNode)), separators: separators as TerminalNode[], }; }); - public constructor(public readonly cst: NonTerminalNode) { - assertKind(this.cst.kind, NonTerminalKind.PositionalArguments); + public constructor(public readonly cst: NonterminalNode) { + assertKind(this.cst.kind, NonterminalKind.PositionalArguments); } public get items(): readonly Expression[] { @@ -5888,13 +5888,13 @@ export class NamedArguments { const [items, separators] = ast_internal.selectSeparated(this.cst); return { - items: items.map((item) => new NamedArgument(item as NonTerminalNode)), + items: items.map((item) => new NamedArgument(item as NonterminalNode)), separators: separators as TerminalNode[], }; }); - public constructor(public readonly cst: NonTerminalNode) { - assertKind(this.cst.kind, NonTerminalKind.NamedArguments); + public constructor(public readonly cst: NonterminalNode) { + assertKind(this.cst.kind, NonterminalKind.NamedArguments); } public get items(): readonly NamedArgument[] { @@ -5911,13 +5911,13 @@ export class CallOptions { const [items, separators] = ast_internal.selectSeparated(this.cst); return { - items: items.map((item) => new NamedArgument(item as NonTerminalNode)), + items: items.map((item) => new NamedArgument(item as NonterminalNode)), separators: separators as TerminalNode[], }; }); - public constructor(public readonly cst: NonTerminalNode) { - assertKind(this.cst.kind, NonTerminalKind.CallOptions); + public constructor(public readonly cst: NonterminalNode) { + assertKind(this.cst.kind, NonterminalKind.CallOptions); } public get items(): readonly NamedArgument[] { @@ -5934,13 +5934,13 @@ export class TupleValues { const [items, separators] = ast_internal.selectSeparated(this.cst); return { - items: items.map((item) => new TupleValue(item as NonTerminalNode)), + items: items.map((item) => new TupleValue(item as NonterminalNode)), separators: separators as TerminalNode[], }; }); - public constructor(public readonly cst: NonTerminalNode) { - assertKind(this.cst.kind, NonTerminalKind.TupleValues); + public constructor(public readonly cst: NonterminalNode) { + assertKind(this.cst.kind, NonterminalKind.TupleValues); } public get items(): readonly TupleValue[] { @@ -5957,13 +5957,13 @@ export class ArrayValues { const [items, separators] = ast_internal.selectSeparated(this.cst); return { - items: items.map((item) => new Expression(item as NonTerminalNode)), + items: items.map((item) => new Expression(item as NonterminalNode)), separators: separators as TerminalNode[], }; }); - public constructor(public readonly cst: NonTerminalNode) { - assertKind(this.cst.kind, NonTerminalKind.ArrayValues); + public constructor(public readonly cst: NonterminalNode) { + assertKind(this.cst.kind, NonterminalKind.ArrayValues); } public get items(): readonly Expression[] { @@ -5982,8 +5982,8 @@ export class IdentifierPath { return { items: items as TerminalNode[], separators: separators as TerminalNode[] }; }); - public constructor(public readonly cst: NonTerminalNode) { - assertKind(this.cst.kind, NonTerminalKind.IdentifierPath); + public constructor(public readonly cst: NonterminalNode) { + assertKind(this.cst.kind, NonterminalKind.IdentifierPath); } public get items(): readonly TerminalNode[] { @@ -6002,8 +6002,8 @@ export class YulParameters { return { items: items as TerminalNode[], separators: separators as TerminalNode[] }; }); - public constructor(public readonly cst: NonTerminalNode) { - assertKind(this.cst.kind, NonTerminalKind.YulParameters); + public constructor(public readonly cst: NonterminalNode) { + assertKind(this.cst.kind, NonterminalKind.YulParameters); } public get items(): readonly TerminalNode[] { @@ -6022,8 +6022,8 @@ export class YulReturnVariables { return { items: items as TerminalNode[], separators: separators as TerminalNode[] }; }); - public constructor(public readonly cst: NonTerminalNode) { - assertKind(this.cst.kind, NonTerminalKind.YulReturnVariables); + public constructor(public readonly cst: NonterminalNode) { + assertKind(this.cst.kind, NonterminalKind.YulReturnVariables); } public get items(): readonly TerminalNode[] { @@ -6040,13 +6040,13 @@ export class YulArguments { const [items, separators] = ast_internal.selectSeparated(this.cst); return { - items: items.map((item) => new YulExpression(item as NonTerminalNode)), + items: items.map((item) => new YulExpression(item as NonterminalNode)), separators: separators as TerminalNode[], }; }); - public constructor(public readonly cst: NonTerminalNode) { - assertKind(this.cst.kind, NonTerminalKind.YulArguments); + public constructor(public readonly cst: NonterminalNode) { + assertKind(this.cst.kind, NonterminalKind.YulArguments); } public get items(): readonly YulExpression[] { @@ -6063,13 +6063,13 @@ export class YulPaths { const [items, separators] = ast_internal.selectSeparated(this.cst); return { - items: items.map((item) => new YulPath(item as NonTerminalNode)), + items: items.map((item) => new YulPath(item as NonterminalNode)), separators: separators as TerminalNode[], }; }); - public constructor(public readonly cst: NonTerminalNode) { - assertKind(this.cst.kind, NonTerminalKind.YulPaths); + public constructor(public readonly cst: NonterminalNode) { + assertKind(this.cst.kind, NonterminalKind.YulPaths); } public get items(): readonly YulPath[] { @@ -6086,13 +6086,13 @@ export class YulPath { const [items, separators] = ast_internal.selectSeparated(this.cst); return { - items: items.map((item) => new YulPathComponent(item as NonTerminalNode)), + items: items.map((item) => new YulPathComponent(item as NonterminalNode)), separators: separators as TerminalNode[], }; }); - public constructor(public readonly cst: NonTerminalNode) { - assertKind(this.cst.kind, NonTerminalKind.YulPath); + public constructor(public readonly cst: NonterminalNode) { + assertKind(this.cst.kind, NonterminalKind.YulPath); } public get items(): readonly YulPathComponent[] { @@ -6118,6 +6118,6 @@ function once(factory: () => T): () => T { }; } -function assertKind(actual: NonTerminalKind, expected: NonTerminalKind): 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 bc3e1ec87d..faa7cf9fe8 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 NonTerminalNode = generated.cst.NonTerminalNode; -export type NonTerminalNode = generated.cst.NonTerminalNode; +export const NonterminalNode = generated.cst.NonterminalNode; +export type NonterminalNode = generated.cst.NonterminalNode; 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 b094f4488b..8156168274 100644 --- a/crates/solidity/outputs/npm/package/src/generated/kinds/index.ts +++ b/crates/solidity/outputs/npm/package/src/generated/kinds/index.ts @@ -2,8 +2,8 @@ import * as generated from "../napi-bindings/generated"; -export const NonTerminalKind = generated.kinds.NonTerminalKind; -export type NonTerminalKind = generated.kinds.NonTerminalKind; +export const NonterminalKind = generated.kinds.NonterminalKind; +export type NonterminalKind = generated.kinds.NonterminalKind; export const TerminalKind = generated.kinds.TerminalKind; export type TerminalKind = generated.kinds.TerminalKind; 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 1882d8703f..5d188ee4a4 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 NonTerminalKind { + export enum NonterminalKind { ABICoderPragma = "ABICoderPragma", AdditiveExpression = "AdditiveExpression", AddressType = "AddressType", @@ -734,21 +734,21 @@ export namespace language { constructor(version: string); get version(): string; static supportedVersions(): Array; - parse(kind: kinds.NonTerminalKind, input: string): parse_output.ParseOutput; + parse(kind: kinds.NonterminalKind, input: string): parse_output.ParseOutput; } } export namespace cst { export enum NodeType { - NonTerminal = "NonTerminal", + Nonterminal = "Nonterminal", Terminal = "Terminal", } - export class NonTerminalNode { - get type(): NodeType.NonTerminal; - get kind(): kinds.NonTerminalKind; + 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; - /** Serialize the token node to JSON. */ + /** Serialize the node to JSON. */ toJSON(): string; unparse(): string; } @@ -757,11 +757,7 @@ export namespace cst { get kind(): kinds.TerminalKind; get textLength(): text_index.TextIndex; get text(): string; - /** - * Serialize the terminal node to JSON. - * - * This method is intended for debugging purposes and may not be stable. - */ + /** Serialize the node to JSON. */ toJSON(): string; createCursor(textOffset: text_index.TextIndex): cursor.Cursor; } @@ -778,7 +774,7 @@ export namespace cursor { get textOffset(): text_index.TextIndex; get textRange(): text_index.TextRange; get depth(): number; - ancestors(): Array; + ancestors(): Array; goToNext(): boolean; goToNextNonDescendent(): boolean; goToPrevious(): boolean; @@ -790,10 +786,10 @@ export namespace cursor { goToPreviousSibling(): boolean; goToNextTerminal(): boolean; goToNextTerminalWithKind(kind: kinds.TerminalKind): boolean; - goToNextTokenWithKinds(kinds: Array): boolean; + goToNextTerminalWithKinds(kinds: Array): boolean; goToNextNonterminal(): boolean; - goToNextNonterminalWithKind(kind: kinds.NonTerminalKind): boolean; - goToNextNonterminalWithKinds(kinds: Array): boolean; + goToNextNonterminalWithKind(kind: kinds.NonterminalKind): boolean; + goToNextNonterminalWithKinds(kinds: Array): boolean; query(queries: Array): query.QueryMatchIterator; } } @@ -815,7 +811,7 @@ export namespace parse_output { export namespace query { export interface QueryMatch { queryNumber: number; - bindings: { [key: string]: cursor.Cursor[] }; + captures: { [key: string]: cursor.Cursor[] }; } export class Query { static parse(text: string): Query; @@ -837,12 +833,12 @@ export namespace text_index { } } export namespace ast_internal { - 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 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 = TerminalNode | NonTerminalNode; + 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 0a3f1ee24a..53479d4b46 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 { NonTerminalKind } from "@nomicfoundation/slang/kinds"; +import { NonterminalKind } from "@nomicfoundation/slang/kinds"; import { Query, QueryMatchIterator } from "@nomicfoundation/slang/query"; -import { NonTerminalNode, TerminalNode } 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(NonTerminalKind.SourceUnit, source); + return language.parse(NonterminalKind.SourceUnit, source); } test("using queries", async () => { @@ -24,9 +24,9 @@ test("using queries", async () => { const cursor = parse_output.createTreeCursor(); const query = Query.parse("[ContractDefinition]"); - const results: QueryMatchIterator = cursor.query([query]); + const matches: QueryMatchIterator = cursor.query([query]); // --8<-- [end:creating-a-query] - results; // Silence the unused warning + matches; // Silence the unused warning } { @@ -36,14 +36,14 @@ test("using queries", async () => { const found = []; const query = Query.parse("@contract [ContractDefinition]"); - const results = cursor.query([query]); + const matches = cursor.query([query]); - let result = null; - while ((result = results.next())) { - const bindings = result.bindings; - const cursors = bindings["contract"]; + let match = null; + while ((match = matches.next())) { + const captures = match.captures; + const cursors = captures["contract"]; - const cursor = cursors?.[0]?.node() as NonTerminalNode; + const cursor = cursors?.[0]?.node() as NonterminalNode; found.push(cursor.unparse().trim()); } @@ -60,13 +60,13 @@ test("using queries", async () => { const struct_def = Query.parse("[StructDefinition ... @name [Identifier] ...]"); const enum_def = Query.parse("[EnumDefinition ... @name [Identifier] ...]"); - const results = cursor.query([struct_def, enum_def]); + const matches = cursor.query([struct_def, enum_def]); - let result = null; - while ((result = results.next())) { - const index = result.queryNumber; - const bindings = result.bindings; - const cursors = bindings["name"]; + let match = null; + while ((match = matches.next())) { + const index = match.queryNumber; + const captures = match.captures; + const cursors = captures["name"]; const cursor = cursors?.[0]; @@ -90,16 +90,16 @@ test("using queries", async () => { const names = []; const query = Query.parse("[TypedTupleMember ... @type type_name:[_] ...]"); - const results = cursor.query([query]); + const matches = cursor.query([query]); - let result = null; - while ((result = results.next())) { - const bindings = result.bindings; - const cursors = bindings["type"]; + let match = null; + while ((match = matches.next())) { + const captures = match.captures; + const cursors = captures["type"]; const cursor = cursors?.[0]; - names.push((cursor?.node() as NonTerminalNode).unparse()); + names.push((cursor?.node() as NonterminalNode).unparse()); } assert.deepStrictEqual(names, ["uint", " uint16", " uint64", " uint256"]); @@ -115,12 +115,12 @@ test("using queries", async () => { const names = []; const query = Query.parse(`[ElementaryType @uint_keyword variant:["uint"]]`); - const results = cursor.query([query]); + const matches = cursor.query([query]); - let result = null; - while ((result = results.next())) { - const bindings = result.bindings; - const cursors = bindings["uint_keyword"]; + let match = null; + while ((match = matches.next())) { + const captures = match.captures; + const cursors = captures["uint_keyword"]; const cursor = cursors?.[0]; @@ -150,18 +150,18 @@ test("using queries", async () => { ... ] ]`); - const results = cursor.query([query]); + const matches = cursor.query([query]); const found = []; - let result = null; - while ((result = results.next())) { - const bindings = result.bindings; - const cursors = bindings["txorigin"]; + let match = null; + while ((match = matches.next())) { + const captures = match.captures; + const cursors = captures["txorigin"]; const cursor = cursors?.[0]; - found.push([cursor?.textOffset.utf8, (cursor?.node() as NonTerminalNode).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 5054b69813..2f7200c25f 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 { NonTerminalKind } from "@nomicfoundation/slang/kinds"; -import { NonTerminalNode } 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(NonTerminalKind.FunctionDefinition, source); + const parseOutput = language.parse(NonterminalKind.FunctionDefinition, source); // --8<-- [end:parse-input] // --8<-- [start:create-node] - const $function = new FunctionDefinition(parseOutput.tree() as NonTerminalNode); + 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 846f4bdea6..58361aaadc 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 { NonTerminalKind, TerminalKind } from "@nomicfoundation/slang/kinds"; -import { NonTerminalNode, TerminalNode } 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(NonTerminalKind.SourceUnit, source); + const parseOutput = language.parse(NonterminalKind.SourceUnit, source); // --8<-- [end:parse-input] { @@ -24,13 +24,13 @@ test("using the cursor", async () => { const cursor = parseOutput.createTreeCursor(); - while (cursor.goToNextNonterminalWithKind(NonTerminalKind.ContractDefinition)) { + while (cursor.goToNextNonterminalWithKind(NonterminalKind.ContractDefinition)) { assert(cursor.goToFirstChild()); assert(cursor.goToNextTerminalWithKind(TerminalKind.Identifier)); - const tokenNode = cursor.node(); - assert(tokenNode instanceof TerminalNode); - contracts.push(tokenNode.text); + const terminalNode = cursor.node(); + assert(terminalNode instanceof TerminalNode); + contracts.push(terminalNode.text); assert(cursor.goToParent()); } @@ -45,13 +45,13 @@ test("using the cursor", async () => { const cursor = parseOutput.createTreeCursor(); - while (cursor.goToNextNonterminalWithKind(NonTerminalKind.ContractDefinition)) { + while (cursor.goToNextNonterminalWithKind(NonterminalKind.ContractDefinition)) { const childCursor = cursor.spawn(); assert(childCursor.goToNextTerminalWithKind(TerminalKind.Identifier)); - const tokenNode = childCursor.node(); - assert(tokenNode instanceof TerminalNode); - contracts.push(tokenNode.text); + const terminalNode = childCursor.node(); + assert(terminalNode instanceof TerminalNode); + contracts.push(terminalNode.text); } assert.deepStrictEqual(contracts, ["Foo", "Bar", "Baz"]); @@ -64,11 +64,11 @@ test("using the cursor", async () => { const cursor = parseOutput.createTreeCursor(); - while (cursor.goToNextNonterminalWithKind(NonTerminalKind.ContractDefinition)) { + while (cursor.goToNextNonterminalWithKind(NonterminalKind.ContractDefinition)) { const range = cursor.textRange; const contractNode = cursor.node(); - assert(contractNode instanceof NonTerminalNode); + assert(contractNode instanceof NonterminalNode); contracts.push([ range.start.line, 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 a1081ea025..c95ae6e780 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 { NonTerminalKind, TerminalKind } from "@nomicfoundation/slang/kinds"; -import { NonTerminalNode } 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(NonTerminalKind.ContractDefinition, source); + const parseOutput = language.parse(NonterminalKind.ContractDefinition, source); // --8<-- [end:parse-input] // --8<-- [start:print-errors] @@ -30,8 +30,8 @@ test("using the parser", async () => { // --8<-- [start:inspect-tree] const contract = parseOutput.tree(); - assert(contract instanceof NonTerminalNode); - assert.equal(contract.kind, NonTerminalKind.ContractDefinition); + assert(contract instanceof NonterminalNode); + assert.equal(contract.kind, NonterminalKind.ContractDefinition); const contractChildren = contract.children(); assert.equal(contractChildren.length, 7); @@ -43,7 +43,7 @@ test("using the parser", async () => { 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(members?.kind, NonterminalKind.ContractMembers); assert.equal(closeBrace?.kind, TerminalKind.CloseBrace); // --8<-- [end:inspect-tree] diff --git a/crates/solidity/testing/sanctuary/src/tests.rs b/crates/solidity/testing/sanctuary/src/tests.rs index 3ac093982a..0e209d25a0 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::NonTerminalKind; +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(NonTerminalKind::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 ef3165c6d8..53b7c36e56 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 @@ -18,7 +18,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 NonTerminalKind { +pub enum NonterminalKind { AdditionExpression, Expression, Literal, @@ -34,7 +34,7 @@ pub enum NonTerminalKind { TreeNodeChildren, } -impl metaslang_cst::NonTerminalKind for NonTerminalKind {} +impl metaslang_cst::NonterminalKind for NonterminalKind {} #[derive( Debug, 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 7bc17689a9..aed3cf41f7 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,15 +16,16 @@ use semver::Version; use crate::cst; use crate::kinds::{ - EdgeLabel, IsLexicalContext, LexicalContext, LexicalContextType, NonTerminalKind, TerminalKind, + EdgeLabel, IsLexicalContext, LexicalContext, LexicalContextType, NonterminalKind, TerminalKind, }; -use crate::lexer::{KeywordScan, Lexer, ScannedToken}; +use crate::lexer::{KeywordScan, Lexer, ScannedTerminal}; #[cfg(feature = "slang_napi_interfaces")] use crate::napi_interface::parse_output::ParseOutput as NAPIParseOutput; use crate::parse_output::ParseOutput; use crate::parser_support::{ ChoiceHelper, OneOrMoreHelper, OptionalHelper, ParserContext, ParserFunction, ParserResult, - PrecedenceHelper, SeparatedHelper, SequenceHelper, TokenAcceptanceThreshold, ZeroOrMoreHelper, + PrecedenceHelper, SeparatedHelper, SequenceHelper, TerminalAcceptanceThreshold, + ZeroOrMoreHelper, }; #[derive(Debug)] @@ -84,14 +85,14 @@ impl Language { }; match &r#match.nodes[..] { [cst::Edge { - node: cst::Node::NonTerminal(node), + node: cst::Node::Nonterminal(node), .. - }] if node.kind == NonTerminalKind::Expression => match &node.children[..] { + }] if node.kind == NonterminalKind::Expression => match &node.children[..] { [inner @ cst::Edge { - node: cst::Node::NonTerminal(node), + node: cst::Node::Nonterminal(node), .. - }] if node.kind == NonTerminalKind::AdditionExpression => { - ParserResult::r#match(vec![inner.clone()], r#match.expected_tokens.clone()) + }] if node.kind == NonterminalKind::AdditionExpression => { + ParserResult::r#match(vec![inner.clone()], r#match.expected_terminals.clone()) } _ => ParserResult::no_match(vec![]), }, @@ -103,10 +104,10 @@ impl Language { fn expression(&self, input: &mut ParserContext<'_>) -> ParserResult { let parse_left_addition_expression = |input: &mut ParserContext<'_>| { PrecedenceHelper::to_binary_operator( - NonTerminalKind::AdditionExpression, + NonterminalKind::AdditionExpression, 1u8, 1u8 + 1, - self.parse_token_with_trivia::( + self.parse_terminal_with_trivia::( input, TerminalKind::Plus, ) @@ -115,9 +116,9 @@ impl Language { }; let parse_prefix_negation_expression = |input: &mut ParserContext<'_>| { PrecedenceHelper::to_prefix_operator( - NonTerminalKind::NegationExpression, + NonterminalKind::NegationExpression, 3u8, - self.parse_token_with_trivia::( + self.parse_terminal_with_trivia::( input, TerminalKind::Bang, ) @@ -126,19 +127,19 @@ impl Language { }; let parse_postfix_member_access_expression = |input: &mut ParserContext<'_>| { PrecedenceHelper::to_postfix_operator( - NonTerminalKind::MemberAccessExpression, + NonterminalKind::MemberAccessExpression, 5u8, SequenceHelper::run(|mut seq| { seq.elem_labeled( EdgeLabel::Period, - self.parse_token_with_trivia::( + self.parse_terminal_with_trivia::( input, TerminalKind::Period, ), )?; seq.elem_labeled( EdgeLabel::Member, - self.parse_token_with_trivia::( + self.parse_terminal_with_trivia::( input, TerminalKind::Identifier, ), @@ -156,12 +157,12 @@ impl Language { }; let primary_expression_parser = |input: &mut ParserContext<'_>| { ChoiceHelper::run(input, |mut choice, input| { - let result = self.parse_token_with_trivia::( + let result = self.parse_terminal_with_trivia::( input, TerminalKind::StringLiteral, ); choice.consider(input, result)?; - let result = self.parse_token_with_trivia::( + let result = self.parse_terminal_with_trivia::( input, TerminalKind::Identifier, ); @@ -206,16 +207,16 @@ impl Language { }) }; PrecedenceHelper::reduce_precedence_result( - NonTerminalKind::Expression, + NonterminalKind::Expression, linear_expression_parser(input), ) - .with_kind(NonTerminalKind::Expression) + .with_kind(NonterminalKind::Expression) } #[allow(unused_assignments, unused_parens)] fn literal(&self, input: &mut ParserContext<'_>) -> ParserResult { ChoiceHelper::run(input, |mut choice, input| { - let result = self.parse_token_with_trivia::( + let result = self.parse_terminal_with_trivia::( input, TerminalKind::StringLiteral, ); @@ -223,7 +224,7 @@ impl Language { choice.finish(input) }) .with_label(EdgeLabel::Variant) - .with_kind(NonTerminalKind::Literal) + .with_kind(NonterminalKind::Literal) } #[allow(unused_assignments, unused_parens)] @@ -234,14 +235,14 @@ impl Language { }; match &r#match.nodes[..] { [cst::Edge { - node: cst::Node::NonTerminal(node), + node: cst::Node::Nonterminal(node), .. - }] if node.kind == NonTerminalKind::Expression => match &node.children[..] { + }] if node.kind == NonterminalKind::Expression => match &node.children[..] { [inner @ cst::Edge { - node: cst::Node::NonTerminal(node), + node: cst::Node::Nonterminal(node), .. - }] if node.kind == NonTerminalKind::MemberAccessExpression => { - ParserResult::r#match(vec![inner.clone()], r#match.expected_tokens.clone()) + }] if node.kind == NonterminalKind::MemberAccessExpression => { + ParserResult::r#match(vec![inner.clone()], r#match.expected_terminals.clone()) } _ => ParserResult::no_match(vec![]), }, @@ -257,14 +258,14 @@ impl Language { }; match &r#match.nodes[..] { [cst::Edge { - node: cst::Node::NonTerminal(node), + node: cst::Node::Nonterminal(node), .. - }] if node.kind == NonTerminalKind::Expression => match &node.children[..] { + }] if node.kind == NonterminalKind::Expression => match &node.children[..] { [inner @ cst::Edge { - node: cst::Node::NonTerminal(node), + node: cst::Node::Nonterminal(node), .. - }] if node.kind == NonTerminalKind::NegationExpression => { - ParserResult::r#match(vec![inner.clone()], r#match.expected_tokens.clone()) + }] if node.kind == NonterminalKind::NegationExpression => { + ParserResult::r#match(vec![inner.clone()], r#match.expected_terminals.clone()) } _ => ParserResult::no_match(vec![]), }, @@ -279,7 +280,7 @@ impl Language { input, self, |input| { - self.parse_token_with_trivia::( + self.parse_terminal_with_trivia::( input, TerminalKind::Identifier, ) @@ -291,14 +292,14 @@ impl Language { } else { ParserResult::disabled() } - .with_kind(NonTerminalKind::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(EdgeLabel::Members) - .with_kind(NonTerminalKind::SourceUnit) + .with_kind(NonterminalKind::SourceUnit) } #[allow(unused_assignments, unused_parens)] @@ -315,7 +316,7 @@ impl Language { choice.finish(input) }) .with_label(EdgeLabel::Variant) - .with_kind(NonTerminalKind::SourceUnitMember) + .with_kind(NonterminalKind::SourceUnitMember) } #[allow(unused_assignments, unused_parens)] @@ -323,7 +324,7 @@ impl Language { OneOrMoreHelper::run(input, |input| { self.source_unit_member(input).with_label(EdgeLabel::Item) }) - .with_kind(NonTerminalKind::SourceUnitMembers) + .with_kind(NonterminalKind::SourceUnitMembers) } #[allow(unused_assignments, unused_parens)] @@ -333,7 +334,7 @@ impl Language { SequenceHelper::run(|mut seq| { seq.elem_labeled( EdgeLabel::Keyword, - self.parse_token_with_trivia::( + self.parse_terminal_with_trivia::( input, TerminalKind::TreeKeyword, ), @@ -341,7 +342,7 @@ impl Language { seq.elem_labeled( EdgeLabel::Name, OptionalHelper::transform( - self.parse_token_with_trivia::( + self.parse_terminal_with_trivia::( input, TerminalKind::Identifier, ), @@ -354,19 +355,19 @@ impl Language { input, self, TerminalKind::Semicolon, - TokenAcceptanceThreshold(1u8), + TerminalAcceptanceThreshold(1u8), ), )?; seq.elem_labeled( EdgeLabel::Semicolon, - self.parse_token_with_trivia::( + self.parse_terminal_with_trivia::( input, TerminalKind::Semicolon, ), )?; seq.finish() }) - .with_kind(NonTerminalKind::Tree) + .with_kind(NonterminalKind::Tree) } #[allow(unused_assignments, unused_parens)] @@ -376,7 +377,7 @@ impl Language { let input = delim_guard.ctx(); seq.elem_labeled( EdgeLabel::OpenBracket, - self.parse_token_with_trivia::( + self.parse_terminal_with_trivia::( input, TerminalKind::OpenBracket, ), @@ -388,19 +389,19 @@ impl Language { input, self, TerminalKind::CloseBracket, - TokenAcceptanceThreshold(0u8), + TerminalAcceptanceThreshold(0u8), ), )?; seq.elem_labeled( EdgeLabel::CloseBracket, - self.parse_token_with_trivia::( + self.parse_terminal_with_trivia::( input, TerminalKind::CloseBracket, ), )?; seq.finish() }) - .with_kind(NonTerminalKind::TreeNode) + .with_kind(NonterminalKind::TreeNode) } #[allow(unused_assignments, unused_parens)] @@ -408,7 +409,7 @@ impl Language { ChoiceHelper::run(input, |mut choice, input| { let result = self.tree_node(input); choice.consider(input, result)?; - let result = self.parse_token_with_trivia::( + let result = self.parse_terminal_with_trivia::( input, TerminalKind::DelimitedIdentifier, ); @@ -416,7 +417,7 @@ impl Language { choice.finish(input) }) .with_label(EdgeLabel::Variant) - .with_kind(NonTerminalKind::TreeNodeChild) + .with_kind(NonterminalKind::TreeNodeChild) } #[allow(unused_assignments, unused_parens)] @@ -424,7 +425,7 @@ impl Language { OneOrMoreHelper::run(input, |input| { self.tree_node_child(input).with_label(EdgeLabel::Item) }) - .with_kind(NonTerminalKind::TreeNodeChildren) + .with_kind(NonterminalKind::TreeNodeChildren) } #[allow(unused_assignments, unused_parens)] @@ -432,22 +433,22 @@ impl Language { OneOrMoreHelper::run(input, |input| { ChoiceHelper::run(input, |mut choice, input| { let result = self - .parse_token::(input, TerminalKind::Whitespace) + .parse_terminal::(input, TerminalKind::Whitespace) .with_label(EdgeLabel::LeadingTrivia); choice.consider(input, result)?; let result = self - .parse_token::(input, TerminalKind::EndOfLine) + .parse_terminal::(input, TerminalKind::EndOfLine) .with_label(EdgeLabel::LeadingTrivia); choice.consider(input, result)?; let result = self - .parse_token::( + .parse_terminal::( input, TerminalKind::SingleLineComment, ) .with_label(EdgeLabel::LeadingTrivia); choice.consider(input, result)?; let result = self - .parse_token::( + .parse_terminal::( input, TerminalKind::MultiLineComment, ) @@ -462,18 +463,18 @@ impl Language { fn trailing_trivia(&self, input: &mut ParserContext<'_>) -> ParserResult { SequenceHelper::run(|mut seq| { seq.elem(OptionalHelper::transform( - self.parse_token::(input, TerminalKind::Whitespace) + self.parse_terminal::(input, TerminalKind::Whitespace) .with_label(EdgeLabel::TrailingTrivia), ))?; seq.elem(OptionalHelper::transform( - self.parse_token::( + self.parse_terminal::( input, TerminalKind::SingleLineComment, ) .with_label(EdgeLabel::TrailingTrivia), ))?; seq.elem( - self.parse_token::(input, TerminalKind::EndOfLine) + self.parse_terminal::(input, TerminalKind::EndOfLine) .with_label(EdgeLabel::TrailingTrivia), )?; seq.finish() @@ -654,23 +655,23 @@ impl Language { ) } - pub fn parse(&self, kind: NonTerminalKind, input: &str) -> ParseOutput { + pub fn parse(&self, kind: NonterminalKind, input: &str) -> ParseOutput { match kind { - NonTerminalKind::AdditionExpression => Self::addition_expression.parse(self, input), - NonTerminalKind::Expression => Self::expression.parse(self, input), - NonTerminalKind::Literal => Self::literal.parse(self, input), - NonTerminalKind::MemberAccessExpression => { + 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), + 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), } } } @@ -691,13 +692,13 @@ impl Lexer for Language { } } - fn next_token( + fn next_terminal( &self, input: &mut ParserContext<'_>, - ) -> Option { + ) -> Option { let save = input.position(); let mut furthest_position = input.position(); - let mut longest_token = None; + let mut longest_terminal = None; macro_rules! longest_match { ($( { $kind:ident = $function:ident } )*) => { @@ -705,7 +706,7 @@ impl Lexer for Language { if self.$function(input) && input.position() > furthest_position { furthest_position = input.position(); - longest_token = Some(TerminalKind::$kind); + longest_terminal = Some(TerminalKind::$kind); } input.set_position(save); )* @@ -725,7 +726,7 @@ impl Lexer for Language { None => None, } { furthest_position = input.position(); - longest_token = Some(kind); + longest_terminal = Some(kind); } input.set_position(save); @@ -741,7 +742,7 @@ impl Lexer for Language { longest_match! {} // We have an identifier; we need to check if it's a keyword - if let Some(identifier) = longest_token.filter(|tok| [].contains(tok)) { + if let Some(identifier) = longest_terminal.filter(|tok| [].contains(tok)) { let kw_scan = KeywordScan::Absent; let kw_scan = match kw_scan { // Strict prefix; we need to match the whole identifier to promote @@ -750,7 +751,7 @@ impl Lexer for Language { }; input.set_position(furthest_position); - return Some(ScannedToken::IdentifierOrKeyword { + return Some(ScannedTerminal::IdentifierOrKeyword { identifier, kw: kw_scan, }); @@ -768,7 +769,7 @@ impl Lexer for Language { None => None, } { furthest_position = input.position(); - longest_token = Some(kind); + longest_terminal = Some(kind); } input.set_position(save); @@ -782,7 +783,7 @@ 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| [TerminalKind::Identifier].contains(tok)) + longest_terminal.filter(|tok| [TerminalKind::Identifier].contains(tok)) { let kw_scan = if scan_chars!(input, 't', 'r', 'e', 'e') { KeywordScan::Reserved(TerminalKind::TreeKeyword) @@ -796,7 +797,7 @@ impl Lexer for Language { }; input.set_position(furthest_position); - return Some(ScannedToken::IdentifierOrKeyword { + return Some(ScannedTerminal::IdentifierOrKeyword { identifier, kw: kw_scan, }); @@ -804,15 +805,15 @@ impl Lexer for Language { } } - match longest_token { - Some(token) => { + match longest_terminal { + Some(terminal) => { input.set_position(furthest_position); - Some(ScannedToken::Single(token)) + Some(ScannedTerminal::Single(terminal)) } - // Skip a character if possible and if we didn't recognize a token + // Skip a character if possible and if we didn't recognize a terminal None if input.peek().is_some() => { let _ = input.next(); - Some(ScannedToken::Single(TerminalKind::SKIPPED)) + Some(ScannedTerminal::Single(TerminalKind::SKIPPED)) } None => None, } @@ -851,7 +852,7 @@ impl Language { )] pub fn parse_napi( &self, - #[napi(ts_arg_type = "kinds.NonTerminalKind")] kind: NonTerminalKind, + #[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 74af1b635f..e3c2878760 100644 --- a/crates/testlang/outputs/cargo/slang_testlang/src/generated/lexer.rs +++ b/crates/testlang/outputs/cargo/slang_testlang/src/generated/lexer.rs @@ -18,7 +18,7 @@ pub enum KeywordScan { } #[derive(Debug, Clone, Copy, PartialEq, Eq)] -pub enum ScannedToken { +pub enum ScannedTerminal { Single(TerminalKind), IdentifierOrKeyword { identifier: TerminalKind, @@ -26,7 +26,7 @@ pub enum ScannedToken { }, } -impl ScannedToken { +impl ScannedTerminal { pub fn accepted_as(self, expected: TerminalKind) -> bool { match self { Self::Single(kind) => kind == expected, @@ -38,10 +38,10 @@ impl ScannedToken { } } - /// Returns the most general token kind that can be accepted for the scanned token. + /// Returns the most general terminal kind that can be accepted for the scanned terminal. /// - /// 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. + /// If the scanned terminal is an identifier, returns the specific keyword kind if the keyword is reserved, + /// otherwise returns the general identifier kind. For other terminals, returns the terminal kind itself. pub fn unambiguous(self) -> TerminalKind { match self { Self::Single(kind) => kind, @@ -58,10 +58,10 @@ impl ScannedToken { pub(crate) trait Lexer { // Generated by the templating engine #[doc(hidden)] - fn next_token( + fn next_terminal( &self, input: &mut ParserContext<'_>, - ) -> Option; + ) -> Option; // NOTE: These are context-insensitive #[doc(hidden)] fn leading_trivia(&self, input: &mut ParserContext<'_>) -> ParserResult; @@ -71,40 +71,40 @@ pub(crate) trait Lexer { /// Returns valid grouping delimiters in the given lexical context. fn delimiters() -> &'static [(TerminalKind, TerminalKind)]; - /// Peeks the next token, including trivia. Does not advance the input. - fn peek_token( + /// Peeks the next terminal, including trivia. Does not advance the input. + fn peek_terminal( &self, input: &mut ParserContext<'_>, - ) -> Option { + ) -> Option { let start = input.position(); - let token = self.next_token::(input); + let terminal = self.next_terminal::(input); input.set_position(start); - token + terminal } - /// Peeks the next significant (i.e. non-trivia) token. Does not advance the input. - fn peek_token_with_trivia( + /// Peeks the next significant (i.e. non-trivia) terminal. Does not advance the input. + fn peek_terminal_with_trivia( &self, input: &mut ParserContext<'_>, - ) -> Option { + ) -> Option { let start = input.position(); let _ = self.leading_trivia(input); - let token = self.next_token::(input); + let terminal = self.next_terminal::(input); input.set_position(start); - token + terminal } - /// Attempts to consume the next expected token. Advances the input only if the token matches. - fn parse_token( + /// Attempts to consume the next expected terminal. Advances the input only if the terminal matches. + fn parse_terminal( &self, input: &mut ParserContext<'_>, kind: TerminalKind, ) -> ParserResult { let start = input.position(); if !self - .next_token::(input) + .next_terminal::(input) .is_some_and(|t| t.accepted_as(kind)) { input.set_position(start); @@ -121,9 +121,9 @@ pub(crate) trait Lexer { ) } - /// Attempts to consume the next significant token including both leading and trailing trivia. - /// Advances the input only if the token matches. - fn parse_token_with_trivia( + /// Attempts to consume the next significant terminal including both leading and trailing trivia. + /// Advances the input only if the terminal matches. + fn parse_terminal_with_trivia( &self, input: &mut ParserContext<'_>, kind: TerminalKind, @@ -139,7 +139,7 @@ pub(crate) trait Lexer { let start = input.position(); if !self - .next_token::(input) + .next_terminal::(input) .is_some_and(|t| t.accepted_as(kind)) { input.set_position(restore); 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 fc0c873252..2a51ee987d 100644 --- a/crates/testlang/outputs/cargo/slang_testlang/src/generated/mod.rs +++ b/crates/testlang/outputs/cargo/slang_testlang/src/generated/mod.rs @@ -30,7 +30,7 @@ mod metaslang_cst { pub enum KindTypes {} impl metaslang_cst::KindTypes for KindTypes { - type NonTerminalKind = crate::kinds::NonTerminalKind; + type NonterminalKind = crate::kinds::NonterminalKind; type TerminalKind = crate::kinds::TerminalKind; type EdgeLabel = crate::kinds::EdgeLabel; } @@ -42,7 +42,7 @@ pub mod cst { use super::metaslang_cst::KindTypes; pub type Node = cst::Node; - pub type NonTerminalNode = cst::NonTerminalNode; + pub type NonterminalNode = cst::NonterminalNode; pub type TerminalNode = cst::TerminalNode; pub type Edge = cst::Edge; } 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 fbb7e68798..7eef078e23 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,24 +8,24 @@ use napi_derive::napi; use crate::napi_interface::cursor::Cursor; use crate::napi_interface::text_index::TextIndex; use crate::napi_interface::{ - NonTerminalKind, RustNode, RustNonTerminalNode, RustTerminalNode, RustTextIndex, TerminalKind, + NonterminalKind, RustNode, RustNonterminalNode, RustTerminalNode, RustTextIndex, TerminalKind, }; #[napi(namespace = "cst", string_enum)] pub enum NodeType { - NonTerminal, + 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 `NonTerminalNode | TerminalNode` 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::NonTerminal(nonterminal) => Either::A(NonTerminalNode(nonterminal)), + RustNode::Nonterminal(nonterminal) => Either::A(NonterminalNode(nonterminal)), RustNode::Terminal(terminal) => Either::B(TerminalNode(terminal)), } } @@ -33,26 +33,26 @@ impl NAPINodeExtensions for RustNode { #[derive(Debug)] #[napi(namespace = "cst")] -pub struct NonTerminalNode(pub(crate) Rc); +pub struct NonterminalNode(pub(crate) Rc); #[derive(Debug)] #[napi(namespace = "cst")] pub struct TerminalNode(pub(crate) Rc); #[napi(namespace = "cst")] -impl NonTerminalNode { +impl NonterminalNode { #[napi( getter, js_name = "type", - ts_return_type = "NodeType.NonTerminal", + ts_return_type = "NodeType.Nonterminal", catch_unwind )] pub fn tipe(&self) -> NodeType { - NodeType::NonTerminal + NodeType::Nonterminal } - #[napi(getter, ts_return_type = "kinds.NonTerminalKind", catch_unwind)] - pub fn kind(&self) -> NonTerminalKind { + #[napi(getter, ts_return_type = "kinds.NonterminalKind", catch_unwind)] + pub fn kind(&self) -> NonterminalKind { self.0.kind } @@ -67,7 +67,7 @@ impl NonTerminalNode { } #[napi(ts_return_type = "Array", catch_unwind)] - pub fn children(&self) -> Vec> { + pub fn children(&self) -> Vec> { self.0 .children .iter() @@ -80,13 +80,13 @@ impl NonTerminalNode { &self, #[napi(ts_arg_type = "text_index.TextIndex")] text_offset: TextIndex, ) -> Cursor { - RustNode::NonTerminal(Rc::clone(&self.0)) + RustNode::Nonterminal(Rc::clone(&self.0)) .cursor_with_offset(text_offset.into()) .into() } + /// Serialize the node to JSON. #[napi(catch_unwind, js_name = "toJSON")] - /// Serialize the token node to JSON. pub fn to_json(&self) -> String { serde_json::to_string(&self.0).unwrap() } @@ -107,7 +107,7 @@ impl NonTerminalNode { skip_typescript, catch_unwind )] - pub fn __children(&self) -> Vec> { + pub fn __children(&self) -> Vec> { Self::children(self) } @@ -159,10 +159,8 @@ impl TerminalNode { self.0.text.clone() } + /// Serialize the node to JSON. #[napi(catch_unwind, js_name = "toJSON")] - /// Serialize the terminal node to JSON. - /// - /// This method is intended for debugging purposes and may not be stable. pub fn to_json(&self) -> String { serde_json::to_string(&self.0).unwrap() } 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 61da4beac9..6d38a68a23 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, NonTerminalNode, TerminalNode}; -use crate::napi_interface::{text_index, EdgeLabel, NonTerminalKind, RustCursor, TerminalKind}; +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,7 +54,7 @@ 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() } @@ -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::NonTerminalNode).collect() + #[napi(ts_return_type = "Array", catch_unwind)] + pub fn ancestors(&self) -> Vec { + self.0.ancestors().map(cst::NonterminalNode).collect() } #[napi(catch_unwind)] @@ -143,7 +143,7 @@ impl Cursor { } #[napi(catch_unwind)] - pub fn go_to_next_token_with_kinds( + pub fn go_to_next_terminal_with_kinds( &mut self, #[napi(ts_arg_type = "Array")] kinds: Vec, ) -> bool { @@ -158,7 +158,7 @@ impl Cursor { #[napi(catch_unwind)] pub fn go_to_next_nonterminal_with_kind( &mut self, - #[napi(ts_arg_type = "kinds.NonTerminalKind")] kind: NonTerminalKind, + #[napi(ts_arg_type = "kinds.NonterminalKind")] kind: NonterminalKind, ) -> bool { self.0.go_to_next_nonterminal_with_kind(kind) } @@ -166,7 +166,7 @@ impl Cursor { #[napi(catch_unwind)] 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_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 7fff20f419..82931cf4aa 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,9 +7,9 @@ use std::rc::Rc; use napi::Either; use napi_derive::napi; -use crate::napi_interface::cst::{NAPINodeExtensions, NonTerminalNode, TerminalNode}; +use crate::napi_interface::cst::{NAPINodeExtensions, NonterminalNode, TerminalNode}; use crate::napi_interface::{ - NonTerminalKind, RustEdge, RustNode, RustNonTerminalNode, TerminalKind, + NonterminalKind, RustEdge, RustNode, RustNonterminalNode, TerminalKind, }; // @@ -22,17 +22,17 @@ use crate::napi_interface::{ catch_unwind )] pub fn select_sequence( - #[napi(ts_arg_type = "cst.NonTerminalNode")] node: &NonTerminalNode, -) -> Result>>> { + #[napi(ts_arg_type = "cst.NonterminalNode")] node: &NonterminalNode, +) -> Result>>> { let mut selector = Selector::new(node); let result = match node.kind() { - 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()?, + 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(); } @@ -42,31 +42,31 @@ 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_nonterminal_with_kind(NonTerminalKind::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_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_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_terminal_with_kind(TerminalKind::OpenBracket))?), Some( self.select(|node| { - node.is_nonterminal_with_kind(NonTerminalKind::TreeNodeChildren) + node.is_nonterminal_with_kind(NonterminalKind::TreeNodeChildren) })?, ), Some(self.select(|node| node.is_terminal_with_kind(TerminalKind::CloseBracket))?), @@ -77,11 +77,11 @@ impl Selector { impl Selector { fn addition_expression( &mut self, - ) -> Result>>> { + ) -> Result>>> { Ok(vec![ - Some(self.select(|node| node.is_nonterminal_with_kind(NonTerminalKind::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))?), + Some(self.select(|node| node.is_nonterminal_with_kind(NonterminalKind::Expression))?), ]) } } @@ -89,10 +89,10 @@ impl Selector { impl Selector { fn negation_expression( &mut self, - ) -> Result>>> { + ) -> Result>>> { Ok(vec![ Some(self.select(|node| node.is_terminal_with_kind(TerminalKind::Bang))?), - Some(self.select(|node| node.is_nonterminal_with_kind(NonTerminalKind::Expression))?), + Some(self.select(|node| node.is_nonterminal_with_kind(NonterminalKind::Expression))?), ]) } } @@ -100,9 +100,9 @@ impl Selector { impl Selector { fn member_access_expression( &mut self, - ) -> Result>>> { + ) -> Result>>> { Ok(vec![ - Some(self.select(|node| node.is_nonterminal_with_kind(NonTerminalKind::Expression))?), + 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))?), ]) @@ -114,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.NonTerminalNode")] node: &NonTerminalNode, -) -> Result> { + #[napi(ts_arg_type = "cst.NonterminalNode")] node: &NonterminalNode, +) -> Result> { let mut selector = Selector::new(node); let result = match node.kind() { - NonTerminalKind::SourceUnitMember => selector.source_unit_member()?, - NonTerminalKind::TreeNodeChild => selector.tree_node_child()?, - NonTerminalKind::Expression => selector.expression()?, - NonTerminalKind::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(); } @@ -133,34 +133,34 @@ 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_nonterminal_with_kinds(&[ - NonTerminalKind::Tree, - NonTerminalKind::Expression, - NonTerminalKind::SeparatedIdentifiers, - NonTerminalKind::Literal, + 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_nonterminal_with_kind(NonTerminalKind::TreeNode) + 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_nonterminal_with_kinds(&[ - NonTerminalKind::AdditionExpression, - NonTerminalKind::NegationExpression, - NonTerminalKind::MemberAccessExpression, + NonterminalKind::AdditionExpression, + NonterminalKind::NegationExpression, + NonterminalKind::MemberAccessExpression, ]) || node .is_terminal_with_kinds(&[TerminalKind::StringLiteral, TerminalKind::Identifier]) }) @@ -168,7 +168,7 @@ impl Selector { } impl Selector { - fn literal(&mut self) -> Result> { + fn literal(&mut self) -> Result> { self.select(|node| node.is_terminal_with_kind(TerminalKind::StringLiteral)) } } @@ -183,13 +183,13 @@ impl Selector { catch_unwind )] pub fn select_repeated( - #[napi(ts_arg_type = "cst.NonTerminalNode")] node: &NonTerminalNode, -) -> Result>> { + #[napi(ts_arg_type = "cst.NonterminalNode")] node: &NonterminalNode, +) -> Result>> { let mut selector = Selector::new(node); let result = match node.kind() { - NonTerminalKind::SourceUnitMembers => selector.source_unit_members()?, - NonTerminalKind::TreeNodeChildren => selector.tree_node_children()?, + NonterminalKind::SourceUnitMembers => selector.source_unit_members()?, + NonterminalKind::TreeNodeChildren => selector.tree_node_children()?, _ => { return Error::UnexpectedParent(node.kind()).into(); } @@ -200,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_nonterminal_with_kind(NonTerminalKind::SourceUnitMember))? + .try_select(|node| node.is_nonterminal_with_kind(NonterminalKind::SourceUnitMember))? { items.push(item); } @@ -214,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_nonterminal_with_kind(NonTerminalKind::TreeNodeChild))? + self.try_select(|node| node.is_nonterminal_with_kind(NonterminalKind::TreeNodeChild))? { items.push(item); } @@ -237,12 +237,12 @@ impl Selector { catch_unwind )] pub fn select_separated( - #[napi(ts_arg_type = "cst.NonTerminalNode")] node: &NonTerminalNode, -) -> Result>>> { + #[napi(ts_arg_type = "cst.NonterminalNode")] node: &NonterminalNode, +) -> Result>>> { let mut selector = Selector::new(node); let result = match node.kind() { - NonTerminalKind::SeparatedIdentifiers => selector.separated_identifiers()?, + NonterminalKind::SeparatedIdentifiers => selector.separated_identifiers()?, _ => { return Error::UnexpectedParent(node.kind()).into(); } @@ -253,7 +253,7 @@ 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![]; @@ -282,12 +282,12 @@ impl Selector { // struct Selector { - node: Rc, + node: Rc, index: usize, } impl Selector { - fn new(node: &NonTerminalNode) -> Self { + fn new(node: &NonterminalNode) -> Self { Self { node: Rc::clone(&node.0), index: 0, @@ -297,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(), @@ -307,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() => { @@ -319,7 +319,7 @@ impl Selector { node: RustNode::Terminal(terminal), .. } if matches!(terminal.kind, TerminalKind::SKIPPED) => { - return Error::SkippedToken(self.index).into(); + return Error::SkippedTerminal(self.index).into(); } labeled if filter(labeled) => { self.index += 1; @@ -348,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 NonTerminalKind '{0}'.")] - UnexpectedParent(NonTerminalKind), + #[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}'.")] @@ -360,8 +360,8 @@ enum Error { MissingChild(usize), // Can happen if the user decided to use an incorrect/incomplete CST node. - #[error("Unexpected SKIPPED token at index '{0}'. Creating AST types from incorrect/incomplete CST nodes is not supported yet.")] - SkippedToken(usize), + #[error("Unexpected SKIPPED terminal at index '{0}'. Creating AST types from incorrect/incomplete CST nodes is not supported yet.")] + SkippedTerminal(usize), } impl From for Result { 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 bd0a794415..1f127807e3 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 @@ -18,11 +18,11 @@ type RustParseOutput = crate::parse_output::ParseOutput; type RustQuery = crate::query::Query; type RustQueryMatch = crate::query::QueryMatch; type RustQueryMatchIterator = crate::query::QueryMatchIterator; -type RustNonTerminalNode = crate::cst::NonTerminalNode; +type RustNonterminalNode = crate::cst::NonterminalNode; type RustTextIndex = crate::text_index::TextIndex; type RustTextRange = crate::text_index::TextRange; type RustTerminalNode = crate::cst::TerminalNode; -type NonTerminalKind = crate::kinds::NonTerminalKind; +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 573b75ab1f..debfd1f130 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, NonTerminalNode, TerminalNode}; +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/napi_interface/query.rs b/crates/testlang/outputs/cargo/slang_testlang/src/generated/napi_interface/query.rs index 2eeee7a7bd..79dcc9e5c4 100644 --- a/crates/testlang/outputs/cargo/slang_testlang/src/generated/napi_interface/query.rs +++ b/crates/testlang/outputs/cargo/slang_testlang/src/generated/napi_interface/query.rs @@ -41,16 +41,16 @@ pub struct QueryMatchIterator(RustQueryMatchIterator); pub struct QueryMatch { pub query_number: u32, #[napi(ts_type = "{ [key: string]: cursor.Cursor[] }")] - pub bindings: HashMap>>, + pub captures: HashMap>>, } impl QueryMatch { - fn new(env: Env, result: RustQueryMatch) -> napi::Result { + fn new(env: Env, r#match: RustQueryMatch) -> napi::Result { #[allow(clippy::cast_possible_truncation)] - let query_number = result.query_number as u32; - // transfer all of the bindings eagerly on the assumption + let query_number = r#match.query_number as u32; + // transfer all of the captures eagerly on the assumption // that they've all been explicitly requested. - let bindings = result + let captures = r#match .captures .into_iter() .map(|(key, values)| { @@ -65,7 +65,7 @@ impl QueryMatch { Ok(Self { query_number, - bindings, + captures, }) } } @@ -81,7 +81,7 @@ impl QueryMatchIterator { #[napi(catch_unwind)] pub fn next(&mut self, env: Env) -> napi::Result> { match self.0.next() { - Some(result) => Ok(Some(QueryMatch::new(env, result)?)), + Some(r#match) => Ok(Some(QueryMatch::new(env, r#match)?)), None => Ok(None), } } 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 a93d647d57..120851c6ac 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 @@ -8,7 +8,7 @@ use crate::text_index::TextRange; #[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) terminals_that_would_have_allowed_more_progress: Vec, } impl ParseError { @@ -16,13 +16,13 @@ impl ParseError { &self.text_range } - pub fn tokens_that_would_have_allowed_more_progress(&self) -> Vec { - let tokens_that_would_have_allowed_more_progress = self - .tokens_that_would_have_allowed_more_progress + pub fn terminals_that_would_have_allowed_more_progress(&self) -> Vec { + let terminals_that_would_have_allowed_more_progress = self + .terminals_that_would_have_allowed_more_progress .iter() .collect::>(); - tokens_that_would_have_allowed_more_progress + terminals_that_would_have_allowed_more_progress .into_iter() .map(TerminalKind::to_string) .collect() @@ -36,11 +36,11 @@ impl ParseError { impl ParseError { pub(crate) fn new( text_range: TextRange, - tokens_that_would_have_allowed_more_progress: Vec, + terminals_that_would_have_allowed_more_progress: Vec, ) -> Self { Self { text_range, - tokens_that_would_have_allowed_more_progress, + terminals_that_would_have_allowed_more_progress, } } } @@ -56,14 +56,14 @@ pub(crate) fn render_error_report( let kind = ReportKind::Error; let color = if with_color { Color::Red } else { Color::Unset }; - let tokens_that_would_have_allowed_more_progress = - error.tokens_that_would_have_allowed_more_progress(); - let message = if tokens_that_would_have_allowed_more_progress.is_empty() { + let terminals_that_would_have_allowed_more_progress = + error.terminals_that_would_have_allowed_more_progress(); + let message = if terminals_that_would_have_allowed_more_progress.is_empty() { "Expected end of file.".to_string() } else { format!( "Expected {expectations}.", - expectations = tokens_that_would_have_allowed_more_progress.join(" or ") + expectations = terminals_that_would_have_allowed_more_progress.join(" or ") ) }; 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 9efafc325e..3a63eb6cad 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 @@ -54,9 +54,11 @@ impl ChoiceHelper { return; } - // Still no match, extend the possible expected tokens. + // Still no match, extend the possible expected terminals. (ParserResult::NoMatch(running), ParserResult::NoMatch(next)) => { - running.expected_tokens.extend(next.expected_tokens.clone()); + running + .expected_terminals + .extend(next.expected_terminals.clone()); false } // Otherwise, we already have some match, so we ignore a next missing one. @@ -65,7 +67,7 @@ impl ChoiceHelper { // Try to improve our match. (_, ParserResult::Match(next)) if next.is_full_recursive() => true, (_, ParserResult::PrattOperatorMatch(..)) => true, - // Optimize for matches that have a longer span of non-skipped tokens. + // Optimize for matches that have a longer span of non-skipped terminals. (cur, next) => total_not_skipped_span(cur) < total_not_skipped_span(next), }; @@ -123,7 +125,7 @@ impl ChoiceHelper { } } -/// Returns the total length of the span of tokens that were not skipped. +/// Returns the total length of the span of terminals that were not skipped. pub fn total_not_skipped_span(result: &ParserResult) -> usize { let nodes = match result { ParserResult::Match(match_) => &match_.nodes, diff --git a/crates/testlang/outputs/cargo/slang_testlang/src/generated/parser_support/mod.rs b/crates/testlang/outputs/cargo/slang_testlang/src/generated/parser_support/mod.rs index 2d005d87d3..293665c77d 100644 --- a/crates/testlang/outputs/cargo/slang_testlang/src/generated/parser_support/mod.rs +++ b/crates/testlang/outputs/cargo/slang_testlang/src/generated/parser_support/mod.rs @@ -28,7 +28,7 @@ pub(crate) use parser_result::ParserResult; #[allow(unused_imports)] pub(crate) use precedence_helper::PrecedenceHelper; #[allow(unused_imports)] -pub(crate) use recovery::TokenAcceptanceThreshold; +pub(crate) use recovery::TerminalAcceptanceThreshold; #[allow(unused_imports)] pub(crate) use repetition_helper::{OneOrMoreHelper, ZeroOrMoreHelper}; #[allow(unused_imports)] diff --git a/crates/testlang/outputs/cargo/slang_testlang/src/generated/parser_support/optional_helper.rs b/crates/testlang/outputs/cargo/slang_testlang/src/generated/parser_support/optional_helper.rs index dd933143b6..d8400f1fd6 100644 --- a/crates/testlang/outputs/cargo/slang_testlang/src/generated/parser_support/optional_helper.rs +++ b/crates/testlang/outputs/cargo/slang_testlang/src/generated/parser_support/optional_helper.rs @@ -8,9 +8,9 @@ impl OptionalHelper { pub fn transform(result: ParserResult) -> ParserResult { match result { // If there's absolutely no match, we treat it as a match (for the purposes of the Result algebra) - // but we bubble up the information which tokens would have allowed more progress. + // but we bubble up the information which terminals would have allowed more progress. ParserResult::NoMatch(no_match) => { - ParserResult::r#match(vec![], no_match.expected_tokens) + ParserResult::r#match(vec![], no_match.expected_terminals) } // ... otherwise we return the result as-is ParserResult::Match(_) 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 4721491788..0378a64785 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 @@ -31,7 +31,7 @@ where if let ParserResult::Match(r#match) = &mut result { let [topmost] = r#match.nodes.as_mut_slice() else { unreachable!( - "Match at the top level of a parse does not have exactly one Rule node" + "Match at the top level of a parse does not have exactly one Nonterminal node" ) }; @@ -42,7 +42,7 @@ where _ => None, }; - if let (cst::Node::NonTerminal(nonterminal), Some(eof_trivia)) = + if let (cst::Node::Nonterminal(nonterminal), Some(eof_trivia)) = (&mut topmost.node, eof_trivia) { let mut new_children = nonterminal.children.clone(); @@ -62,22 +62,22 @@ where parse_tree: cst::Node::terminal(TerminalKind::SKIPPED, input.to_string()), errors: vec![ParseError::new( TextIndex::ZERO..input.into(), - no_match.expected_tokens, + no_match.expected_terminals, )], }, some_match => { - let (nodes, expected_tokens) = match some_match { + let (nodes, expected_terminals) = match some_match { ParserResult::PrattOperatorMatch(..) | ParserResult::NoMatch(..) => { unreachable!("Handled above") } ParserResult::Match(Match { nodes, - expected_tokens, + expected_terminals, }) | ParserResult::IncompleteMatch(IncompleteMatch { nodes, - expected_tokens, - }) => (nodes, expected_tokens), + expected_terminals, + }) => (nodes, expected_terminals), ParserResult::SkippedUntil(SkippedUntil { nodes, expected, .. @@ -85,9 +85,9 @@ where }; let topmost_node = match &nodes[..] { - [Edge { node: cst::Node::NonTerminal(nonterminal), ..} ] => Rc::clone(nonterminal), + [Edge { node: cst::Node::Nonterminal(nonterminal), ..} ] => Rc::clone(nonterminal), [_] => unreachable!( - "(Incomplete)Match at the top level of a parser is not a Rule node" + "(Incomplete)Match at the top level of a parser is not a Nonterminal node" ), _ => unreachable!( "(Incomplete)Match at the top level of a parser does not have exactly one node" @@ -111,14 +111,14 @@ where new_children.push(Edge::anonymous(skipped_node)); let mut errors = stream.into_errors(); - errors.push(ParseError::new(start..input.into(), expected_tokens)); + errors.push(ParseError::new(start..input.into(), expected_terminals)); ParseOutput { parse_tree: cst::Node::nonterminal(topmost_node.kind, new_children), errors, } } else { - let parse_tree = cst::Node::NonTerminal(topmost_node); + 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 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 f9a192912e..e4bfc89826 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 @@ -5,7 +5,7 @@ use std::ops::ControlFlow; use metaslang_cst::TerminalKind as _; use crate::cst::{self, Edge, Node}; -use crate::kinds::{EdgeLabel, NonTerminalKind, TerminalKind}; +use crate::kinds::{EdgeLabel, NonterminalKind, TerminalKind}; use crate::text_index::TextIndex; #[derive(PartialEq, Eq, Clone, Debug)] @@ -20,22 +20,22 @@ pub enum ParserResult { impl Default for ParserResult { fn default() -> Self { Self::NoMatch(NoMatch { - expected_tokens: vec![], + expected_terminals: vec![], }) } } impl ParserResult { - pub fn r#match(nodes: Vec, expected_tokens: Vec) -> Self { - ParserResult::Match(Match::new(nodes, expected_tokens)) + pub fn r#match(nodes: Vec, expected_terminals: Vec) -> Self { + ParserResult::Match(Match::new(nodes, expected_terminals)) } pub fn pratt_operator_match(elements: Vec) -> Self { ParserResult::PrattOperatorMatch(PrattOperatorMatch::new(elements)) } - pub fn incomplete_match(nodes: Vec, expected_tokens: Vec) -> Self { - ParserResult::IncompleteMatch(IncompleteMatch::new(nodes, expected_tokens)) + pub fn incomplete_match(nodes: Vec, expected_terminals: Vec) -> Self { + ParserResult::IncompleteMatch(IncompleteMatch::new(nodes, expected_terminals)) } /// Whenever a parser didn't run because it's disabled due to versioning. Shorthand for `no_match(vec![])`. @@ -43,26 +43,26 @@ impl ParserResult { Self::no_match(vec![]) } - pub fn no_match(expected_tokens: Vec) -> Self { - ParserResult::NoMatch(NoMatch::new(expected_tokens)) + pub fn no_match(expected_terminals: Vec) -> Self { + ParserResult::NoMatch(NoMatch::new(expected_terminals)) } #[must_use] - pub fn with_kind(self, new_kind: NonTerminalKind) -> ParserResult { + pub fn with_kind(self, new_kind: NonterminalKind) -> ParserResult { match self { ParserResult::Match(r#match) => ParserResult::r#match( vec![Edge::anonymous(cst::Node::nonterminal( new_kind, r#match.nodes, ))], - r#match.expected_tokens, + r#match.expected_terminals, ), ParserResult::IncompleteMatch(incomplete_match) => ParserResult::incomplete_match( vec![Edge::anonymous(cst::Node::nonterminal( new_kind, incomplete_match.nodes, ))], - incomplete_match.expected_tokens, + incomplete_match.expected_terminals, ), ParserResult::SkippedUntil(skipped) => ParserResult::SkippedUntil(SkippedUntil { nodes: vec![Edge::anonymous(cst::Node::nonterminal( @@ -86,7 +86,7 @@ impl ParserResult { { *prev_label = Some(label); } - // Also allow to name a single trivia token node + // Also allow to name a single trivia terminal node else if let ParserResult::Match(Match { nodes, .. }) = &mut self { if let [node] = nodes.as_mut_slice() { if node.as_terminal().is_some_and(|tok| tok.kind.is_trivia()) { @@ -124,15 +124,15 @@ impl ParserResult { #[derive(PartialEq, Eq, Clone, Debug)] pub struct Match { pub nodes: Vec, - /// Tokens that would have allowed for more progress. Collected for the purposes of error reporting. - pub expected_tokens: Vec, + /// Terminals that would have allowed for more progress. Collected for the purposes of error reporting. + pub expected_terminals: Vec, } impl Match { - pub fn new(nodes: Vec, expected_tokens: Vec) -> Self { + pub fn new(nodes: Vec, expected_terminals: Vec) -> Self { Self { nodes, - expected_tokens, + expected_terminals, } } @@ -150,18 +150,18 @@ pub enum PrattElement { nodes: Vec, }, Prefix { - kind: NonTerminalKind, + kind: NonterminalKind, nodes: Vec, right: u8, }, Binary { - kind: NonTerminalKind, + kind: NonterminalKind, nodes: Vec, left: u8, right: u8, }, Postfix { - kind: NonTerminalKind, + kind: NonterminalKind, nodes: Vec, left: u8, }, @@ -194,20 +194,20 @@ impl PrattOperatorMatch { #[derive(PartialEq, Eq, Clone, Debug)] pub struct IncompleteMatch { pub nodes: Vec, - /// Tokens that would have allowed for more progress. Collected for the purposes of error reporting. - pub expected_tokens: Vec, + /// Terminals that would have allowed for more progress. Collected for the purposes of error reporting. + pub expected_terminals: Vec, } impl IncompleteMatch { - pub fn new(nodes: Vec, expected_tokens: Vec) -> Self { + pub fn new(nodes: Vec, expected_terminals: Vec) -> Self { Self { nodes, - expected_tokens, + expected_terminals, } } - /// Whether this prefix-matched at least `n` (non-skipped) significant tokens. - pub fn matches_at_least_n_tokens(&self, n: u8) -> bool { + /// Whether this prefix-matched at least `n` (non-skipped) significant terminals. + pub fn matches_at_least_n_terminals(&self, n: u8) -> bool { let result = self .nodes .iter() @@ -238,13 +238,13 @@ 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, + /// Terminals that would have allowed for more progress. Collected for the purposes of error reporting. + pub expected_terminals: Vec, } impl NoMatch { - pub fn new(expected_tokens: Vec) -> Self { - Self { expected_tokens } + pub fn new(expected_terminals: Vec) -> Self { + Self { expected_terminals } } } @@ -253,8 +253,8 @@ pub struct SkippedUntil { pub nodes: Vec, /// Skipped text following the last node pub skipped: String, - /// At which token was the stream pointing at when we bailed + /// At which terminal was the stream pointing at when we bailed pub found: TerminalKind, - /// Token we expected to skip until + /// Terminal we expected to skip until 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 7d307a1c0d..28c4a203ec 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, Edge}; -use crate::kinds::{EdgeLabel, NonTerminalKind}; +use crate::kinds::{EdgeLabel, NonterminalKind}; use crate::parser_support::parser_result::PrattElement::{ self, Binary, Expression, Postfix, Prefix, }; @@ -11,7 +11,7 @@ pub struct PrecedenceHelper; impl PrecedenceHelper { pub fn to_prefix_operator( - kind: NonTerminalKind, + kind: NonterminalKind, right: u8, result: ParserResult, ) -> ParserResult { @@ -29,7 +29,7 @@ impl PrecedenceHelper { } pub fn to_postfix_operator( - kind: NonTerminalKind, + kind: NonterminalKind, left: u8, result: ParserResult, ) -> ParserResult { @@ -47,7 +47,7 @@ impl PrecedenceHelper { } pub fn to_binary_operator( - kind: NonTerminalKind, + kind: NonterminalKind, left: u8, right: u8, result: ParserResult, @@ -68,7 +68,7 @@ impl PrecedenceHelper { #[allow(clippy::too_many_lines, clippy::redundant_else)] // Explicit on purpose, see below. pub fn reduce_precedence_result( - child_kind: NonTerminalKind, + child_kind: NonterminalKind, result: ParserResult, ) -> ParserResult { // This requires some careful thinking. It could be more compact, @@ -162,7 +162,7 @@ impl PrecedenceHelper { // 2. Reduce the operator and it's child expressions to a new expression let make_expression = |left: Option, - kind: NonTerminalKind, + kind: NonterminalKind, nodes: Vec, right: Option| { assert!(left.is_some() || right.is_some()); 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 7fceddc3ae..6b336c4a28 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 @@ -2,18 +2,18 @@ use crate::cst; use crate::kinds::{IsLexicalContext, TerminalKind}; -use crate::lexer::{Lexer, ScannedToken}; +use crate::lexer::{Lexer, ScannedTerminal}; use crate::parse_error::ParseError; use crate::parser_support::context::ParserContext; use crate::parser_support::parser_result::SkippedUntil; use crate::parser_support::ParserResult; use crate::text_index::{TextRange, TextRangeExtensions}; -/// How many tokens have to be matched to trigger the error recovery. +/// How many terminals have to be matched to trigger the error recovery. /// For ambiguous syntaxes this needs to be set to at least N, where N -/// is the token lookahead required to disambiguate the syntax. +/// is the terminal lookahead required to disambiguate the syntax. #[derive(Clone, Copy)] -pub(crate) struct TokenAcceptanceThreshold(pub(crate) u8); +pub(crate) struct TerminalAcceptanceThreshold(pub(crate) u8); fn opt_parse( input: &mut ParserContext<'_>, @@ -29,19 +29,19 @@ fn opt_parse( } impl ParserResult { - /// For partial matches (partial prefix match or if the next token after the match is not expected) - /// attempts to skip tokens until a given token is found or until we hit a delimiter that's expected + /// For partial matches (partial prefix match or if the next terminal after the match is not expected) + /// attempts to skip terminals until a given terminal is found or until we hit a delimiter that's expected /// by an outer parse. Returns [`ParserResult::SkippedUntil`] on success. /// - /// Respects nested delimiters, i.e. the `expected` token is only accepted if it's not nested inside. - /// Does not consume the `expected` token. + /// Respects nested delimiters, i.e. the `expected` terminal is only accepted if it's not nested inside. + /// Does not consume the `expected` terminal. #[must_use] pub(crate) fn recover_until_with_nested_delims( self, input: &mut ParserContext<'_>, lexer: &L, expected: TerminalKind, - acceptance_threshold: TokenAcceptanceThreshold, + acceptance_threshold: TerminalAcceptanceThreshold, ) -> ParserResult { enum ParseResultKind { Match, @@ -51,26 +51,30 @@ impl ParserResult { let before_recovery = input.position(); - let (mut nodes, mut expected_tokens, result_kind) = match self { + let (mut nodes, mut expected_terminals, result_kind) = match self { ParserResult::IncompleteMatch(result) - if result.matches_at_least_n_tokens(acceptance_threshold.0) => + if result.matches_at_least_n_terminals(acceptance_threshold.0) => { ( result.nodes, - result.expected_tokens, + result.expected_terminals, ParseResultKind::Incomplete, ) } ParserResult::Match(result) if lexer - .peek_token_with_trivia::(input) - .map(ScannedToken::unambiguous) + .peek_terminal_with_trivia::(input) + .map(ScannedTerminal::unambiguous) != Some(expected) => { - (result.nodes, result.expected_tokens, ParseResultKind::Match) + ( + result.nodes, + result.expected_terminals, + ParseResultKind::Match, + ) } ParserResult::NoMatch(result) if acceptance_threshold.0 == 0 => { - (vec![], result.expected_tokens, ParseResultKind::NoMatch) + (vec![], result.expected_terminals, ParseResultKind::NoMatch) } // No need to recover, so just return as-is. _ => return self, @@ -83,14 +87,14 @@ impl ParserResult { { nodes.extend(leading_trivia); if matches!(result_kind, ParseResultKind::Match) { - expected_tokens.push(expected); + expected_terminals.push(expected); } let skipped = input.content(skipped_range.utf8()); input.emit(ParseError { text_range: skipped_range, - tokens_that_would_have_allowed_more_progress: expected_tokens.clone(), + terminals_that_would_have_allowed_more_progress: expected_terminals.clone(), }); ParserResult::SkippedUntil(SkippedUntil { @@ -104,21 +108,21 @@ impl ParserResult { input.set_position(before_recovery); match result_kind { - ParseResultKind::Match => ParserResult::r#match(nodes, expected_tokens), + ParseResultKind::Match => ParserResult::r#match(nodes, expected_terminals), ParseResultKind::Incomplete => { - ParserResult::incomplete_match(nodes, expected_tokens) + ParserResult::incomplete_match(nodes, expected_terminals) } - ParseResultKind::NoMatch => ParserResult::no_match(expected_tokens), + ParseResultKind::NoMatch => ParserResult::no_match(expected_terminals), } } } } -/// Skips tokens until a given token is found or until we hit a closing delimiter that's expected by an outer parse. -/// Respects nested delimiters, i.e. the `expected` token is only accepted if it's not nested inside. -/// Does not consume the `expected` token. +/// Skips terminals until a given terminal is found or until we hit a closing delimiter that's expected by an outer parse. +/// Respects nested delimiters, i.e. the `expected` terminal is only accepted if it's not nested inside. +/// Does not consume the `expected` terminal. /// -/// Returns the found token and the range of skipped tokens on success. +/// Returns the found terminal and the range of skipped terminals on success. pub(crate) fn skip_until_with_nested_delims( input: &mut ParserContext<'_>, lexer: &L, @@ -132,27 +136,27 @@ pub(crate) fn skip_until_with_nested_delims( loop { let save = input.position(); match lexer - .next_token::(input) - .map(ScannedToken::unambiguous) + .next_terminal::(input) + .map(ScannedTerminal::unambiguous) { // If we're not skipping past a local delimited group (delimiter stack is empty), - // we can unwind on a token that's expected by us or by our ancestor. - Some(token) + // we can unwind on a terminal that's expected by us or by our ancestor. + Some(terminal) if local_delims.is_empty() - && (token == until || input.closing_delimiters().contains(&token)) => + && (terminal == until || input.closing_delimiters().contains(&terminal)) => { // Don't consume the delimiter; parent will consume it input.set_position(save); - return Some((token, start..save)); + return Some((terminal, start..save)); } // Found the local closing delimiter, pop the stack - Some(token) if local_delims.last() == Some(&token) => { + Some(terminal) if local_delims.last() == Some(&terminal) => { local_delims.pop(); } - Some(token) => { + Some(terminal) => { // Found a local opening delimiter, skip until we find a closing one - if let Some((_, close)) = delims.iter().find(|(op, _)| token == *op) { + if let Some((_, close)) = delims.iter().find(|(op, _)| terminal == *op) { local_delims.push(*close); } else { // Keep eating (eventually hits EOF) diff --git a/crates/testlang/outputs/cargo/slang_testlang/src/generated/parser_support/repetition_helper.rs b/crates/testlang/outputs/cargo/slang_testlang/src/generated/parser_support/repetition_helper.rs index 91438e0bf0..d07108f65a 100644 --- a/crates/testlang/outputs/cargo/slang_testlang/src/generated/parser_support/repetition_helper.rs +++ b/crates/testlang/outputs/cargo/slang_testlang/src/generated/parser_support/repetition_helper.rs @@ -25,9 +25,9 @@ impl RepetitionHelper { result @ ParserResult::SkippedUntil(_) => return result, // Couldn't get a full match but we allow 0 items - return an empty match - // so the parse is considered valid but note the expected tokens - ParserResult::NoMatch(NoMatch { expected_tokens }) if MIN_COUNT == 0 => { - return ParserResult::r#match(vec![], expected_tokens); + // so the parse is considered valid but note the expected terminals + ParserResult::NoMatch(NoMatch { expected_terminals }) if MIN_COUNT == 0 => { + return ParserResult::r#match(vec![], expected_terminals); } // Don't try repeating if we don't have a full match and we require at least one incomplete_or_no_match => return incomplete_or_no_match, @@ -40,7 +40,7 @@ impl RepetitionHelper { match (&mut accum, next_result) { (ParserResult::Match(running), ParserResult::Match(next)) => { running.nodes.extend(next.nodes); - running.expected_tokens = next.expected_tokens; + running.expected_terminals = next.expected_terminals; } (ParserResult::PrattOperatorMatch(cur), ParserResult::PrattOperatorMatch(next)) => { @@ -54,16 +54,16 @@ impl RepetitionHelper { "Match seen while repeating PrattOperatorMatches in RepetitionHelper" ), // Can't proceed further with a complete parse, so back up, return - // the accumulated result and note the expected tokens + // the accumulated result and note the expected terminals ( ParserResult::Match(running), ParserResult::IncompleteMatch(IncompleteMatch { - expected_tokens, .. + expected_terminals, .. }) - | ParserResult::NoMatch(NoMatch { expected_tokens }), + | ParserResult::NoMatch(NoMatch { expected_terminals }), ) => { input.rewind(save); - running.expected_tokens = expected_tokens; + running.expected_terminals = expected_terminals; return accum; } 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 0c87c6aea2..eb6cdf67f2 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 @@ -25,10 +25,10 @@ impl SeparatedHelper { ParserResult::Match(r#match) => { accum.extend(r#match.nodes); - match lexer.peek_token_with_trivia::(input) { + match lexer.peek_terminal_with_trivia::(input) { Some(scanned) if scanned.accepted_as(separator) => { match lexer - .parse_token_with_trivia::(input, separator) + .parse_terminal_with_trivia::(input, separator) .with_label(separator_label) { ParserResult::Match(r#match) => { @@ -41,12 +41,12 @@ impl SeparatedHelper { // Unrecognized, return the accumulated matches. // NOTE: We can't correctly attempt recovery until #600 lands, otherwise we'd risk misparses, - // as we need to stop at certain synchronizing tokens (and we can't reliably scan until + // as we need to stop at certain synchronizing terminals (and we can't reliably scan until // a delimiter, as not every list is enclosed in a delimited group). Some(..) | None => return ParserResult::r#match(accum, vec![separator]), } } - // Body was partially parsed, so try to recover by skipping tokens until we see a separator + // Body was partially parsed, so try to recover by skipping terminals until we see a separator ParserResult::IncompleteMatch(incomplete) => { accum.extend(incomplete.nodes); @@ -61,11 +61,11 @@ impl SeparatedHelper { ))); input.emit(ParseError { text_range: skipped_range, - tokens_that_would_have_allowed_more_progress: incomplete - .expected_tokens, + terminals_that_would_have_allowed_more_progress: incomplete + .expected_terminals, }); - match lexer.parse_token_with_trivia::(input, separator) { + match lexer.parse_terminal_with_trivia::(input, separator) { ParserResult::Match(r#match) => { accum.extend(r#match.nodes); continue; @@ -82,16 +82,16 @@ impl SeparatedHelper { return ParserResult::incomplete_match( accum, - incomplete.expected_tokens, + incomplete.expected_terminals, ); } } } ParserResult::NoMatch(no_match) => { return if accum.is_empty() { - ParserResult::no_match(no_match.expected_tokens) + ParserResult::no_match(no_match.expected_terminals) } else { - ParserResult::incomplete_match(accum, no_match.expected_tokens) + ParserResult::incomplete_match(accum, no_match.expected_terminals) }; } 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 cd455cfcab..36ff4f3478 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 @@ -51,7 +51,7 @@ impl SequenceHelper { // Keep accepting or convert into PrattOperatorMatch (ParserResult::Match(running), ParserResult::Match(next)) => { running.nodes.extend(next.nodes); - running.expected_tokens = next.expected_tokens; + running.expected_terminals = next.expected_terminals; } (ParserResult::Match(running), ParserResult::PrattOperatorMatch(next)) => { let mut children = vec![PrattElement::Expression { @@ -65,15 +65,15 @@ impl SequenceHelper { running.nodes.extend(next.nodes); self.result = State::Running(ParserResult::incomplete_match( std::mem::take(&mut running.nodes), - next.expected_tokens, + next.expected_terminals, )); } (ParserResult::Match(running), ParserResult::NoMatch(next)) => { - running.expected_tokens.extend(next.expected_tokens); + running.expected_terminals.extend(next.expected_terminals); self.result = State::Running(ParserResult::incomplete_match( std::mem::take(&mut running.nodes), - std::mem::take(&mut running.expected_tokens), + std::mem::take(&mut running.expected_terminals), )); } // Keep accepting or convert Match -> PrattOperatorMatch @@ -95,7 +95,7 @@ impl SequenceHelper { .flat_map(PrattElement::into_nodes) .chain(next.nodes) .collect(), - next.expected_tokens, + next.expected_terminals, )); } (ParserResult::PrattOperatorMatch(cur), ParserResult::NoMatch(next)) => { @@ -104,7 +104,7 @@ impl SequenceHelper { .into_iter() .flat_map(PrattElement::into_nodes) .collect(), - next.expected_tokens, + next.expected_terminals, )); } // Enter recovery mode @@ -119,35 +119,35 @@ impl SequenceHelper { (ParserResult::PrattOperatorMatch(_), ParserResult::SkippedUntil(_)) => unreachable!("Error recovery happens outside precedence parsing"), - // Try to recover until we hit an expected boundary token. + // Try to recover until we hit an expected boundary terminal. // If the sequence is unwinding, then a subsequent non-empty match must mean that - // we found the expected token, so we can stop recovering. + // we found the expected terminal, so we can stop recovering. (ParserResult::SkippedUntil(running), ParserResult::Match(next)) => { if next.nodes.is_empty() { return; } - // We only support skipping to a single, significant token. + // We only support skipping to a single, significant terminal. // Sanity check that we are recovering to the expected one. - let next_token = next.nodes.iter().try_fold(None, |acc, node| { + let next_terminal = next.nodes.iter().try_fold(None, |acc, node| { match &**node { - cst::Node::Terminal(token) if token.kind.is_trivia() => Ok(acc), - cst::Node::Terminal(token) => { + cst::Node::Terminal(terminal) if terminal.kind.is_trivia() => Ok(acc), + cst::Node::Terminal(terminal) => { match acc { - None => Ok(Some(token.kind)), + None => Ok(Some(terminal.kind)), Some(..) => { - debug_assert!(false, "Recovery skipped to multiple tokens: {acc:?}, {token:?}"); + debug_assert!(false, "Recovery skipped to multiple terminals: {acc:?}, {terminal:?}"); Err(()) } } } - cst::Node::NonTerminal(node) => { + cst::Node::Nonterminal(node) => { debug_assert!(false, "Recovery skipped to a nonterminal: {node:?}"); Err(()) } } }); - debug_assert_eq!(next_token, Ok(Some(running.found))); + debug_assert_eq!(next_terminal, Ok(Some(running.found))); running.nodes.push(Edge::anonymous(cst::Node::terminal( TerminalKind::SKIPPED, @@ -157,17 +157,17 @@ impl SequenceHelper { self.result = State::Running(ParserResult::Match(Match { nodes: std::mem::take(&mut running.nodes), - expected_tokens: next.expected_tokens, + expected_terminals: next.expected_terminals, })); } // If the sequence is unwinding and and we didn't find a match, then it means // that we recovered past it and we need to push the recovery up. (ParserResult::SkippedUntil(_), ParserResult::NoMatch(_)) => { // Skip any possible subsequent expected elements in this sequence until - // we finally encounter the token we were looking for + // we finally encounter the terminal we were looking for } (ParserResult::SkippedUntil(_), _) => unreachable!( - "Only a single token parse can immediately follow SkippedUntil in sequences and these can either be Match or NoMatch" + "Only a single terminal parse can immediately follow SkippedUntil in sequences and these can either be Match or NoMatch" ), }, } 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 66faa65a72..0c6c464075 100644 --- a/crates/testlang/outputs/cargo/tests/src/query/engine_tests.rs +++ b/crates/testlang/outputs/cargo/tests/src/query/engine_tests.rs @@ -2,7 +2,7 @@ use std::collections::BTreeMap; use slang_testlang::cst::{Edge, Node}; use slang_testlang::cursor::Cursor; -use slang_testlang::kinds::{EdgeLabel, NonTerminalKind, TerminalKind}; +use slang_testlang::kinds::{EdgeLabel, NonterminalKind, TerminalKind}; use slang_testlang::query::{Query, QueryMatch}; use slang_testlang::text_index::TextIndex; @@ -15,7 +15,7 @@ fn terminal(label: Option, kind: TerminalKind, text: &str) -> Edge { fn nonterminal( label: Option, - kind: NonTerminalKind, + kind: NonterminalKind, children: [Edge; N], ) -> Edge { Edge { @@ -24,10 +24,10 @@ fn nonterminal( } } -fn binding_cursors_to_strings( - bindings: BTreeMap>, +fn capture_cursors_to_strings( + captures: BTreeMap>, ) -> BTreeMap> { - bindings + captures .into_iter() .map(|(key, values)| { ( @@ -45,62 +45,59 @@ fn binding_cursors_to_strings( macro_rules! cst_tree { ( @inner [ $($child:expr)* ]) => { [ $($child),* ] }; - ( @inner [ $($child:expr)* ] $label:ident : $token_kind:ident $text:literal $(, $($rest:tt)*)? ) => { - cst_tree!(@inner [ $($child)* terminal(Some(EdgeLabel::$label), TerminalKind::$token_kind, $text) ] $($($rest)*)?) + ( @inner [ $($child:expr)* ] $label:ident : $terminal_kind:ident $text:literal $(, $($rest:tt)*)? ) => { + cst_tree!(@inner [ $($child)* terminal(Some(EdgeLabel::$label), TerminalKind::$terminal_kind, $text) ] $($($rest)*)?) }; - ( @inner [ $($child:expr)* ] $token_kind:ident $text:literal $(, $($rest:tt)*)? ) => { - cst_tree!(@inner [ $($child)* terminal(None, TerminalKind::$token_kind, $text) ] $($($rest)*)?) + ( @inner [ $($child:expr)* ] $terminal_kind:ident $text:literal $(, $($rest:tt)*)? ) => { + cst_tree!(@inner [ $($child)* terminal(None, TerminalKind::$terminal_kind, $text) ] $($($rest)*)?) }; - ( @inner [ $($child:expr)* ] $label:ident : $rule_kind:ident [ $($children:tt)* ] $(, $($rest:tt)*)? ) => { - cst_tree!(@inner [ $($child)* nonterminal(Some(NodeLabel::$label), NonTerminalKind::$rule_kind, cst_tree!(@inner [] $($children)*)) ] $($($rest)*)?) + ( @inner [ $($child:expr)* ] $label:ident : $non_terminal_kind:ident [ $($children:tt)* ] $(, $($rest:tt)*)? ) => { + cst_tree!(@inner [ $($child)* nonterminal(Some(EdgeLabel::$label), NonterminalKind::$non_terminal_kind, cst_tree!(@inner [] $($children)*)) ] $($($rest)*)?) }; - ( @inner [ $($child:expr)* ] $rule_kind:ident [ $($children:tt)* ] $(, $($rest:tt)*)? ) => { - cst_tree!(@inner [ $($child)* nonterminal(None, NonTerminalKind::$rule_kind, cst_tree!(@inner [] $($children)*)) ] $($($rest)*)?) + ( @inner [ $($child:expr)* ] $non_terminal_kind:ident [ $($children:tt)* ] $(, $($rest:tt)*)? ) => { + cst_tree!(@inner [ $($child)* nonterminal(None, NonterminalKind::$non_terminal_kind, cst_tree!(@inner [] $($children)*)) ] $($($rest)*)?) }; // Start with a nonterminal - ( $label:ident : $rule_kind:ident [ $($children:tt)* ] ) => { - nonterminal(Some(NodeLabel::$label), NonTerminalKind::$rule_kind, cst_tree!(@inner [] $($children)*)) + ( $label:ident : $non_terminal_kind:ident [ $($children:tt)* ] ) => { + nonterminal(Some(EdgeLabel::$label), NonterminalKind::$non_terminal_kind, cst_tree!(@inner [] $($children)*)) }; - ( $rule_kind:ident [ $($children:tt)* ] ) => { - nonterminal(None, NonTerminalKind::$rule_kind, cst_tree!(@inner [] $($children)*)) + ( $non_terminal_kind:ident [ $($children:tt)* ] ) => { + nonterminal(None, NonterminalKind::$non_terminal_kind, cst_tree!(@inner [] $($children)*)) }; } -macro_rules! query_results { +macro_rules! query_matches { ( $( { $( $key:ident : [ $($value:literal),* ] ),* } )* ) => { vec![ $( { #[allow(unused_mut)] - let mut bindings = BTreeMap::new(); - $( bindings.insert( stringify!($key).to_string(), vec![ $( $value.to_string() ),* ]); )* - bindings + let mut captures = BTreeMap::new(); + $( captures.insert( stringify!($key).to_string(), vec![ $( $value.to_string() ),* ]); )* + captures } ),* ] }; } -fn run_query_test(tree: &Edge, query: &str, results: Vec>>) { +fn run_query_test(tree: &Edge, query: &str, matches: Vec>>) { let cursor = tree.cursor_with_offset(TextIndex::ZERO); let query = vec![Query::parse(query).unwrap()]; - let mut results = results.into_iter(); - for QueryMatch { - captures: bindings, .. - } in cursor.query(query) - { - let bindings = binding_cursors_to_strings(bindings); - if let Some(expected_bindings) = results.next() { - assert_eq!(bindings, expected_bindings); + let mut matches = matches.into_iter(); + for QueryMatch { captures, .. } in cursor.query(query) { + let captures = capture_cursors_to_strings(captures); + if let Some(expected_captures) = matches.next() { + assert_eq!(captures, expected_captures); } else { - panic!("Unexpected query result: {bindings:?}"); + panic!("Unexpected query match: {captures:?}"); } } - if let Some(expected_bindings) = results.next() { - panic!("Missing query result: {expected_bindings:?}"); + if let Some(expected_captures) = matches.next() { + panic!("Missing query match: {expected_captures:?}"); } } @@ -123,7 +120,7 @@ fn test_spread() { run_query_test( &common_test_tree(), "[TreeNode ... @x1 [DelimitedIdentifier] ... @x2 [DelimitedIdentifier] ...]", - query_results! { + query_matches! { {x1: ["A"], x2: ["B"]} {x1: ["A"], x2: ["C"]} {x1: ["B"], x2: ["C"]} @@ -136,7 +133,7 @@ fn test_adjacent() { run_query_test( &common_test_tree(), "[TreeNode ... @y1 [DelimitedIdentifier] @y2 [DelimitedIdentifier] ...]", - query_results! { + query_matches! { {y1: ["A"], y2: ["B"]} {y1: ["B"], y2: ["C"]} }, @@ -148,7 +145,7 @@ fn test_child() { run_query_test( &common_test_tree(), "[TreeNodeChild ... @x [DelimitedIdentifier] ...]", - query_results! { + query_matches! { {x: ["D"]} {x: ["E"]} }, @@ -160,7 +157,7 @@ fn test_parent_and_child() { run_query_test( &common_test_tree(), "[TreeNode ... @p node:[_] ... [TreeNodeChild ... @c [DelimitedIdentifier] ...]]", - query_results! { + query_matches! { {c: ["D"], p: ["A"]} {c: ["E"], p: ["A"]} }, @@ -172,7 +169,7 @@ fn test_named() { run_query_test( &common_test_tree(), "[TreeNode ... @x node:[DelimitedIdentifier] ...]", - query_results! { + query_matches! { {x: ["A"]} }, ); @@ -183,7 +180,7 @@ fn test_multilevel_adjacent() { run_query_test( &common_test_tree(), "[_ ... @x [DelimitedIdentifier] @y [DelimitedIdentifier] ...]", - query_results! { + query_matches! { {x: ["A"], y: ["B"]} {x: ["B"], y: ["C"]} {x: ["D"], y: ["E"]} @@ -196,7 +193,7 @@ fn test_multilevel_named() { run_query_test( &common_test_tree(), "[_ ... @x node:[_] ...]", - query_results! { + query_matches! { {x: ["A"]} {x: ["E"]} }, @@ -208,7 +205,7 @@ fn test_text_value() { run_query_test( &common_test_tree(), r#"[TreeNode ... @z1 [DelimitedIdentifier] ["B"] @z2 [DelimitedIdentifier] ...]"#, - query_results! { + query_matches! { {z1: ["A"], z2: ["C"]} }, ); @@ -219,7 +216,7 @@ fn test_one_or_more() { run_query_test( &common_test_tree(), "[TreeNode ... (@x [DelimitedIdentifier])+ [_] ]", - query_results! { + query_matches! { {x: ["A", "B", "C"]} {x: ["B", "C"]} {x: ["C"]} @@ -232,7 +229,7 @@ fn test_zero_or_more() { run_query_test( &common_test_tree(), "[TreeNode ... (@y [DelimitedIdentifier])* [_] ]", - query_results! { + query_matches! { {y: ["A", "B", "C"]} {y: ["B", "C"]} {y: ["C"]} @@ -246,7 +243,7 @@ fn test_optional() { run_query_test( &common_test_tree(), "[TreeNode ... (@z [DelimitedIdentifier])? [_] ]", - query_results! { + query_matches! { {z: ["C"]} {} }, @@ -258,7 +255,7 @@ fn test_nested() { run_query_test( &common_test_tree(), "@root [TreeNode ... @z [DelimitedIdentifier] [_] ]", - query_results! { + query_matches! { {root: ["ABCDE"], z: ["C"]} }, ); diff --git a/crates/testlang/outputs/cargo/tests/src/query/parser_tests.rs b/crates/testlang/outputs/cargo/tests/src/query/parser_tests.rs index 24ac985de0..efd6fafa9f 100644 --- a/crates/testlang/outputs/cargo/tests/src/query/parser_tests.rs +++ b/crates/testlang/outputs/cargo/tests/src/query/parser_tests.rs @@ -26,7 +26,7 @@ fn test_anonymous() { } #[test] -fn test_root_binding() { +fn test_root_capture() { run_parser_test( r#"@root [DelimitedIdentifier]"#, r#"@root [DelimitedIdentifier]"#, @@ -34,7 +34,7 @@ fn test_root_binding() { } #[test] -fn test_binding() { +fn test_capture() { run_parser_test( r#"[TreeNode @b [DelimitedIdentifier]]"#, r#"[TreeNode @b [DelimitedIdentifier]]"#, 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 2df496e427..177f791aea 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 { NonTerminalNode, TerminalNode } from "../../cst"; -import { NonTerminalKind, TerminalKind } 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 NonTerminalNode), + members: new SourceUnitMembers($members as NonterminalNode), }; }); - public constructor(public readonly cst: NonTerminalNode) { - assertKind(this.cst.kind, NonTerminalKind.SourceUnit); + public constructor(public readonly cst: NonterminalNode) { + assertKind(this.cst.kind, NonterminalKind.SourceUnit); } public get members(): SourceUnitMembers { @@ -34,13 +34,13 @@ export class Tree { return { keyword: $keyword as TerminalNode, name: $name === null ? undefined : ($name as TerminalNode), - node: new TreeNode($node as NonTerminalNode), + node: new TreeNode($node as NonterminalNode), semicolon: $semicolon as TerminalNode, }; }); - public constructor(public readonly cst: NonTerminalNode) { - assertKind(this.cst.kind, NonTerminalKind.Tree); + public constructor(public readonly cst: NonterminalNode) { + assertKind(this.cst.kind, NonterminalKind.Tree); } public get keyword(): TerminalNode { @@ -66,13 +66,13 @@ export class TreeNode { return { openBracket: $openBracket as TerminalNode, - members: new TreeNodeChildren($members as NonTerminalNode), + members: new TreeNodeChildren($members as NonterminalNode), closeBracket: $closeBracket as TerminalNode, }; }); - public constructor(public readonly cst: NonTerminalNode) { - assertKind(this.cst.kind, NonTerminalKind.TreeNode); + public constructor(public readonly cst: NonterminalNode) { + assertKind(this.cst.kind, NonterminalKind.TreeNode); } public get openBracket(): TerminalNode { @@ -93,14 +93,14 @@ export class AdditionExpression { const [$leftOperand, $operator, $rightOperand] = ast_internal.selectSequence(this.cst); return { - leftOperand: new Expression($leftOperand as NonTerminalNode), + leftOperand: new Expression($leftOperand as NonterminalNode), operator: $operator as TerminalNode, - rightOperand: new Expression($rightOperand as NonTerminalNode), + rightOperand: new Expression($rightOperand as NonterminalNode), }; }); - public constructor(public readonly cst: NonTerminalNode) { - assertKind(this.cst.kind, NonTerminalKind.AdditionExpression); + public constructor(public readonly cst: NonterminalNode) { + assertKind(this.cst.kind, NonterminalKind.AdditionExpression); } public get leftOperand(): Expression { @@ -122,12 +122,12 @@ export class NegationExpression { return { operator: $operator as TerminalNode, - operand: new Expression($operand as NonTerminalNode), + operand: new Expression($operand as NonterminalNode), }; }); - public constructor(public readonly cst: NonTerminalNode) { - assertKind(this.cst.kind, NonTerminalKind.NegationExpression); + public constructor(public readonly cst: NonterminalNode) { + assertKind(this.cst.kind, NonterminalKind.NegationExpression); } public get operator(): TerminalNode { @@ -144,14 +144,14 @@ export class MemberAccessExpression { const [$operand, $period, $member] = ast_internal.selectSequence(this.cst); return { - operand: new Expression($operand as NonTerminalNode), + operand: new Expression($operand as NonterminalNode), period: $period as TerminalNode, member: $member as TerminalNode, }; }); - public constructor(public readonly cst: NonTerminalNode) { - assertKind(this.cst.kind, NonTerminalKind.MemberAccessExpression); + public constructor(public readonly cst: NonterminalNode) { + assertKind(this.cst.kind, NonterminalKind.MemberAccessExpression); } public get operand(): Expression { @@ -176,22 +176,22 @@ export class SourceUnitMember { const variant = ast_internal.selectChoice(this.cst); switch (variant.kind) { - 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); + 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: NonTerminalNode) { - assertKind(this.cst.kind, NonTerminalKind.SourceUnitMember); + public constructor(public readonly cst: NonterminalNode) { + assertKind(this.cst.kind, NonterminalKind.SourceUnitMember); } public get variant(): Tree | Expression | SeparatedIdentifiers | Literal { @@ -204,8 +204,8 @@ export class TreeNodeChild { const variant = ast_internal.selectChoice(this.cst); switch (variant.kind) { - case NonTerminalKind.TreeNode: - return new TreeNode(variant as NonTerminalNode); + case NonterminalKind.TreeNode: + return new TreeNode(variant as NonterminalNode); case TerminalKind.DelimitedIdentifier: return variant as TerminalNode; @@ -215,8 +215,8 @@ export class TreeNodeChild { } }); - public constructor(public readonly cst: NonTerminalNode) { - assertKind(this.cst.kind, NonTerminalKind.TreeNodeChild); + public constructor(public readonly cst: NonterminalNode) { + assertKind(this.cst.kind, NonterminalKind.TreeNodeChild); } public get variant(): TreeNode | TerminalNode { @@ -230,12 +230,12 @@ export class Expression { const variant = ast_internal.selectChoice(this.cst); switch (variant.kind) { - 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 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 TerminalKind.StringLiteral: case TerminalKind.Identifier: @@ -247,8 +247,8 @@ export class Expression { }, ); - public constructor(public readonly cst: NonTerminalNode) { - assertKind(this.cst.kind, NonTerminalKind.Expression); + public constructor(public readonly cst: NonterminalNode) { + assertKind(this.cst.kind, NonterminalKind.Expression); } public get variant(): AdditionExpression | NegationExpression | MemberAccessExpression | TerminalNode { @@ -269,8 +269,8 @@ export class Literal { } }); - public constructor(public readonly cst: NonTerminalNode) { - assertKind(this.cst.kind, NonTerminalKind.Literal); + public constructor(public readonly cst: NonterminalNode) { + assertKind(this.cst.kind, NonterminalKind.Literal); } public get variant(): TerminalNode { @@ -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 NonTerminalNode)); + return items.map((item) => new SourceUnitMember(item as NonterminalNode)); }); - public constructor(public readonly cst: NonTerminalNode) { - assertKind(this.cst.kind, NonTerminalKind.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 NonTerminalNode)); + return items.map((item) => new TreeNodeChild(item as NonterminalNode)); }); - public constructor(public readonly cst: NonTerminalNode) { - assertKind(this.cst.kind, NonTerminalKind.TreeNodeChildren); + public constructor(public readonly cst: NonterminalNode) { + assertKind(this.cst.kind, NonterminalKind.TreeNodeChildren); } public get items(): readonly TreeNodeChild[] { @@ -323,8 +323,8 @@ export class SeparatedIdentifiers { return { items: items as TerminalNode[], separators: separators as TerminalNode[] }; }); - public constructor(public readonly cst: NonTerminalNode) { - assertKind(this.cst.kind, NonTerminalKind.SeparatedIdentifiers); + public constructor(public readonly cst: NonterminalNode) { + assertKind(this.cst.kind, NonterminalKind.SeparatedIdentifiers); } public get items(): readonly TerminalNode[] { @@ -350,6 +350,6 @@ function once(factory: () => T): () => T { }; } -function assertKind(actual: NonTerminalKind, expected: NonTerminalKind): 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 bc3e1ec87d..faa7cf9fe8 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 NonTerminalNode = generated.cst.NonTerminalNode; -export type NonTerminalNode = generated.cst.NonTerminalNode; +export const NonterminalNode = generated.cst.NonterminalNode; +export type NonterminalNode = generated.cst.NonterminalNode; 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 b094f4488b..8156168274 100644 --- a/crates/testlang/outputs/npm/package/src/generated/kinds/index.ts +++ b/crates/testlang/outputs/npm/package/src/generated/kinds/index.ts @@ -2,8 +2,8 @@ import * as generated from "../napi-bindings/generated"; -export const NonTerminalKind = generated.kinds.NonTerminalKind; -export type NonTerminalKind = generated.kinds.NonTerminalKind; +export const NonterminalKind = generated.kinds.NonterminalKind; +export type NonterminalKind = generated.kinds.NonterminalKind; export const TerminalKind = generated.kinds.TerminalKind; export type TerminalKind = generated.kinds.TerminalKind; 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 1a57c6d121..086ab591cb 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 NonTerminalKind { + export enum NonterminalKind { AdditionExpression = "AdditionExpression", Expression = "Expression", Literal = "Literal", @@ -67,21 +67,21 @@ export namespace language { constructor(version: string); get version(): string; static supportedVersions(): Array; - parse(kind: kinds.NonTerminalKind, input: string): parse_output.ParseOutput; + parse(kind: kinds.NonterminalKind, input: string): parse_output.ParseOutput; } } export namespace cst { export enum NodeType { - NonTerminal = "NonTerminal", + Nonterminal = "Nonterminal", Terminal = "Terminal", } - export class NonTerminalNode { - get type(): NodeType.NonTerminal; - get kind(): kinds.NonTerminalKind; + 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; - /** Serialize the token node to JSON. */ + /** Serialize the node to JSON. */ toJSON(): string; unparse(): string; } @@ -90,11 +90,7 @@ export namespace cst { get kind(): kinds.TerminalKind; get textLength(): text_index.TextIndex; get text(): string; - /** - * Serialize the terminal node to JSON. - * - * This method is intended for debugging purposes and may not be stable. - */ + /** Serialize the node to JSON. */ toJSON(): string; createCursor(textOffset: text_index.TextIndex): cursor.Cursor; } @@ -111,7 +107,7 @@ export namespace cursor { get textOffset(): text_index.TextIndex; get textRange(): text_index.TextRange; get depth(): number; - ancestors(): Array; + ancestors(): Array; goToNext(): boolean; goToNextNonDescendent(): boolean; goToPrevious(): boolean; @@ -123,10 +119,10 @@ export namespace cursor { goToPreviousSibling(): boolean; goToNextTerminal(): boolean; goToNextTerminalWithKind(kind: kinds.TerminalKind): boolean; - goToNextTokenWithKinds(kinds: Array): boolean; + goToNextTerminalWithKinds(kinds: Array): boolean; goToNextNonterminal(): boolean; - goToNextNonterminalWithKind(kind: kinds.NonTerminalKind): boolean; - goToNextNonterminalWithKinds(kinds: Array): boolean; + goToNextNonterminalWithKind(kind: kinds.NonterminalKind): boolean; + goToNextNonterminalWithKinds(kinds: Array): boolean; query(queries: Array): query.QueryMatchIterator; } } @@ -148,7 +144,7 @@ export namespace parse_output { export namespace query { export interface QueryMatch { queryNumber: number; - bindings: { [key: string]: cursor.Cursor[] }; + captures: { [key: string]: cursor.Cursor[] }; } export class Query { static parse(text: string): Query; @@ -170,12 +166,12 @@ export namespace text_index { } } export namespace ast_internal { - 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 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 = TerminalNode | NonTerminalNode; + 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 2ef2aba34d..92fd6377bc 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 { NonTerminalKind, TerminalKind } from "@slang-private/slang-testlang/kinds"; +import { NonterminalKind, TerminalKind } from "@slang-private/slang-testlang/kinds"; import { AdditionExpression, Expression, @@ -12,7 +12,7 @@ import { TreeNode, TreeNodeChild, } from "@slang-private/slang-testlang/ast"; -import { expectNonTerminal, expectTerminal } from "../utils/cst-helpers"; +import { expectNonterminal, expectTerminal } from "../utils/cst-helpers"; import { TerminalNode } from "@slang-private/slang-testlang/cst"; test("create and use sequence types", () => { @@ -20,14 +20,14 @@ test("create and use sequence types", () => { const language = new Language("1.0.0"); - const parseOutput = language.parse(NonTerminalKind.Tree, source); + const parseOutput = language.parse(NonterminalKind.Tree, source); expect(parseOutput.errors()).toHaveLength(0); const cst = parseOutput.tree(); - expectNonTerminal(cst, NonTerminalKind.Tree); + expectNonterminal(cst, NonterminalKind.Tree); const tree = new Tree(cst); - expectNonTerminal(tree.cst, NonTerminalKind.Tree); + expectNonterminal(tree.cst, NonterminalKind.Tree); expect(tree.name).toBeUndefined(); expect(tree.node.members.items).toHaveLength(3); }); @@ -37,19 +37,19 @@ test("create and use choice types", () => { const language = new Language("1.0.0"); - const parseOutput = language.parse(NonTerminalKind.TreeNodeChild, source); + const parseOutput = language.parse(NonterminalKind.TreeNodeChild, source); expect(parseOutput.errors()).toHaveLength(0); const cst = parseOutput.tree(); - expectNonTerminal(cst, NonTerminalKind.TreeNodeChild); + expectNonterminal(cst, NonterminalKind.TreeNodeChild); const tree_node_child = new TreeNodeChild(cst); - expectNonTerminal(tree_node_child.cst, NonTerminalKind.TreeNodeChild); + expectNonterminal(tree_node_child.cst, NonterminalKind.TreeNodeChild); expect(tree_node_child.variant).toBeInstanceOf(TreeNode); const tree_node = tree_node_child.variant as TreeNode; - expectNonTerminal(tree_node.cst, NonTerminalKind.TreeNode); - expectNonTerminal(tree_node.members.cst, NonTerminalKind.TreeNodeChildren); + 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, "]"); }); @@ -59,14 +59,14 @@ test("create and use repeated types", () => { const language = new Language("1.0.0"); - const parseOutput = language.parse(NonTerminalKind.Tree, source); + const parseOutput = language.parse(NonterminalKind.Tree, source); expect(parseOutput.errors()).toHaveLength(0); const cst = parseOutput.tree(); - expectNonTerminal(cst, NonTerminalKind.Tree); + expectNonterminal(cst, NonterminalKind.Tree); const tree = new Tree(cst); - expectNonTerminal(tree.node.members.cst, NonTerminalKind.TreeNodeChildren); + expectNonterminal(tree.node.members.cst, NonterminalKind.TreeNodeChildren); const names = tree.node.members.items.map((item) => { expect(item.variant).toBeInstanceOf(TerminalNode); @@ -82,14 +82,14 @@ test("create and use separated types", () => { const language = new Language("1.0.0"); - const parseOutput = language.parse(NonTerminalKind.SeparatedIdentifiers, source); + const parseOutput = language.parse(NonterminalKind.SeparatedIdentifiers, source); expect(parseOutput.errors()).toHaveLength(0); const cst = parseOutput.tree(); - expectNonTerminal(cst, NonTerminalKind.SeparatedIdentifiers); + expectNonterminal(cst, NonterminalKind.SeparatedIdentifiers); const separated_identifiers = new SeparatedIdentifiers(cst); - expectNonTerminal(separated_identifiers.cst, NonTerminalKind.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(NonTerminalKind.Tree, source); + const parseOutput = language.parse(NonterminalKind.Tree, source); expect(parseOutput.errors()).toHaveLength(0); const cst = parseOutput.tree(); - expectNonTerminal(cst, NonTerminalKind.Tree); + expectNonterminal(cst, NonterminalKind.Tree); expect(() => new SourceUnit(cst)).toThrowError( "SourceUnit can only be initialized with a CST node of the same kind.", @@ -119,23 +119,23 @@ test("throws an exception on on using an incorrect/incomplete CST node", () => { const language = new Language("1.0.0"); - const parseOutput = language.parse(NonTerminalKind.Tree, source); + const parseOutput = language.parse(NonterminalKind.Tree, source); expect(parseOutput.errors()).toHaveLength(1); const cst = parseOutput.tree(); - expectNonTerminal(cst, NonTerminalKind.Tree); + expectNonterminal(cst, NonterminalKind.Tree); expect(cst.children()).toHaveLength(2); - const [contractKeyword, skippedToken] = cst.children(); + const [contractKeyword, skippedTerminal] = cst.children(); expectTerminal(contractKeyword, TerminalKind.TreeKeyword, "tree"); - expectTerminal(skippedToken, TerminalKind.SKIPPED, ""); + expectTerminal(skippedTerminal, TerminalKind.SKIPPED, ""); // Creating the tree should succeed, as the fields are lazily intialized. const tree = new Tree(cst); - expectNonTerminal(tree.cst, NonTerminalKind.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.", + "Unexpected SKIPPED terminal at index '1'. Creating AST types from incorrect/incomplete CST nodes is not supported yet.", ); }); @@ -144,11 +144,11 @@ test("create and use prefix expressions", () => { const language = new Language("1.0.0"); - const parseOutput = language.parse(NonTerminalKind.Expression, source); + const parseOutput = language.parse(NonterminalKind.Expression, source); expect(parseOutput.errors()).toHaveLength(0); const cst = parseOutput.tree(); - expectNonTerminal(cst, NonTerminalKind.Expression); + expectNonterminal(cst, NonterminalKind.Expression); const expression = new Expression(cst); assert(expression.variant instanceof NegationExpression); @@ -163,11 +163,11 @@ test("create and use postfix expressions", () => { const language = new Language("1.0.0"); - const parseOutput = language.parse(NonTerminalKind.Expression, source); + const parseOutput = language.parse(NonterminalKind.Expression, source); expect(parseOutput.errors()).toHaveLength(0); const cst = parseOutput.tree(); - expectNonTerminal(cst, NonTerminalKind.Expression); + expectNonterminal(cst, NonterminalKind.Expression); const expression = new Expression(cst); assert(expression.variant instanceof MemberAccessExpression); @@ -183,11 +183,11 @@ test("create and use binary expressions", () => { const language = new Language("1.0.0"); - const parseOutput = language.parse(NonTerminalKind.Expression, source); + const parseOutput = language.parse(NonterminalKind.Expression, source); expect(parseOutput.errors()).toHaveLength(0); const cst = parseOutput.tree(); - expectNonTerminal(cst, NonTerminalKind.Expression); + expectNonterminal(cst, NonterminalKind.Expression); const expression = new Expression(cst); assert(expression.variant instanceof AdditionExpression); 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 2799709fc4..05d428694b 100644 --- a/crates/testlang/outputs/npm/tests/src/tests/cst-cursor.ts +++ b/crates/testlang/outputs/npm/tests/src/tests/cst-cursor.ts @@ -1,32 +1,32 @@ import { Language } from "@slang-private/slang-testlang/language"; -import { EdgeLabel, NonTerminalKind, TerminalKind } 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 { expectNonTerminal, expectTerminal } 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(NonTerminalKind.SourceUnit, source); + const parseOutput = language.parse(NonterminalKind.SourceUnit, source); const cursor: Cursor = parseOutput.createTreeCursor(); - expectNonTerminal(cursor.node(), NonTerminalKind.SourceUnit); + expectNonterminal(cursor.node(), NonterminalKind.SourceUnit); expect(cursor.goToNext()).toBe(true); - expectNonTerminal(cursor.node(), NonTerminalKind.SourceUnitMembers); + expectNonterminal(cursor.node(), NonterminalKind.SourceUnitMembers); expect(cursor.goToNext()).toBe(true); - expectNonTerminal(cursor.node(), NonTerminalKind.SourceUnitMember); + expectNonterminal(cursor.node(), NonterminalKind.SourceUnitMember); expect(cursor.goToNext()).toBe(true); - expectNonTerminal(cursor.node(), NonTerminalKind.Tree); + expectNonterminal(cursor.node(), NonterminalKind.Tree); expect(cursor.goToNext()).toBe(true); expectTerminal(cursor.node(), TerminalKind.TreeKeyword, "tree"); expect(cursor.goToNext()).toBe(true); - expectNonTerminal(cursor.node(), NonTerminalKind.TreeNode); + expectNonterminal(cursor.node(), NonterminalKind.TreeNode); expect(cursor.goToNext()).toBe(true); expectTerminal(cursor.node(), TerminalKind.Whitespace, " "); @@ -35,19 +35,19 @@ test("use cursor", () => { expectTerminal(cursor.node(), TerminalKind.OpenBracket, "["); expect(cursor.goToNext()).toBe(true); - expectNonTerminal(cursor.node(), NonTerminalKind.TreeNodeChildren); + expectNonterminal(cursor.node(), NonterminalKind.TreeNodeChildren); expect(cursor.goToNext()).toBe(true); - expectNonTerminal(cursor.node(), NonTerminalKind.TreeNodeChild); + expectNonterminal(cursor.node(), NonterminalKind.TreeNodeChild); expect(cursor.goToNext()).toBe(true); expectTerminal(cursor.node(), TerminalKind.DelimitedIdentifier, "A"); expect(cursor.goToNext()).toBe(true); - expectNonTerminal(cursor.node(), NonTerminalKind.TreeNodeChild); + expectNonterminal(cursor.node(), NonterminalKind.TreeNodeChild); expect(cursor.goToNext()).toBe(true); - expectNonTerminal(cursor.node(), NonTerminalKind.TreeNode); + expectNonterminal(cursor.node(), NonterminalKind.TreeNode); expect(cursor.goToNext()).toBe(true); expectTerminal(cursor.node(), TerminalKind.Whitespace, " "); @@ -56,16 +56,16 @@ test("use cursor", () => { expectTerminal(cursor.node(), TerminalKind.OpenBracket, "["); expect(cursor.goToNext()).toBe(true); - expectNonTerminal(cursor.node(), NonTerminalKind.TreeNodeChildren); + expectNonterminal(cursor.node(), NonterminalKind.TreeNodeChildren); expect(cursor.goToNext()).toBe(true); - expectNonTerminal(cursor.node(), NonTerminalKind.TreeNodeChild); + expectNonterminal(cursor.node(), NonterminalKind.TreeNodeChild); expect(cursor.goToNext()).toBe(true); expectTerminal(cursor.node(), TerminalKind.DelimitedIdentifier, "B"); expect(cursor.goToNext()).toBe(true); - expectNonTerminal(cursor.node(), NonTerminalKind.TreeNodeChild); + expectNonterminal(cursor.node(), NonterminalKind.TreeNodeChild); expect(cursor.goToNext()).toBe(true); expectTerminal(cursor.node(), TerminalKind.Whitespace, " "); @@ -77,7 +77,7 @@ test("use cursor", () => { expectTerminal(cursor.node(), TerminalKind.CloseBracket, "]"); expect(cursor.goToNext()).toBe(true); - expectNonTerminal(cursor.node(), NonTerminalKind.TreeNodeChild); + expectNonterminal(cursor.node(), NonterminalKind.TreeNodeChild); expect(cursor.goToNext()).toBe(true); expectTerminal(cursor.node(), TerminalKind.Whitespace, " "); @@ -96,12 +96,12 @@ test("use cursor", () => { 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(NonTerminalKind.SourceUnit, source); + const parseTree = language.parse(NonterminalKind.SourceUnit, source); const cursor = parseTree.createTreeCursor(); let names: string[] = []; - while (cursor.goToNextNonterminalWithKind(NonTerminalKind.TreeNode)) { + while (cursor.goToNextNonterminalWithKind(NonterminalKind.TreeNode)) { const innerCursor = cursor.spawn(); while (innerCursor.goToNext()) { const node = innerCursor.node(); 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 0eaa47c8af..b4374e585c 100644 --- a/crates/testlang/outputs/npm/tests/src/tests/cst-output.ts +++ b/crates/testlang/outputs/npm/tests/src/tests/cst-output.ts @@ -1,13 +1,13 @@ import { Language } from "@slang-private/slang-testlang/language"; -import { NonTerminalKind, TerminalKind } from "@slang-private/slang-testlang/kinds"; -import { expectNonTerminal, expectTerminal } from "../utils/cst-helpers"; +import { NonterminalKind, TerminalKind } from "@slang-private/slang-testlang/kinds"; +import { expectNonterminal, expectTerminal } from "../utils/cst-helpers"; -test("parse token", () => { +test("parse terminal", () => { const source = "About_time"; const language = new Language("1.0.0"); - const parseTree = language.parse(NonTerminalKind.TreeNodeChild, source).tree(); - expectNonTerminal(parseTree, NonTerminalKind.TreeNodeChild); + const parseTree = language.parse(NonterminalKind.TreeNodeChild, source).tree(); + expectNonterminal(parseTree, NonterminalKind.TreeNodeChild); const children = parseTree.children(); expect(children).toHaveLength(1); @@ -15,26 +15,26 @@ test("parse token", () => { expectTerminal(children[0]!, TerminalKind.DelimitedIdentifier, "About_time"); }); -test("parse rule", () => { +test("parse nonterminal", () => { const source = `tree [A [B C] D];`; const language = new Language("1.0.0"); - const parseTree = language.parse(NonTerminalKind.SourceUnit, source).tree(); - expectNonTerminal(parseTree, NonTerminalKind.SourceUnit); + const parseTree = language.parse(NonterminalKind.SourceUnit, source).tree(); + expectNonterminal(parseTree, NonterminalKind.SourceUnit); const children = parseTree.children(); expect(children).toHaveLength(1); - expectNonTerminal(children[0]!, NonTerminalKind.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(NonTerminalKind.SourceUnit, source); + const parseOutput = language.parse(NonterminalKind.SourceUnit, source); const node = parseOutput.createTreeCursor().node(); - expectNonTerminal(node, NonTerminalKind.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(NonTerminalKind.Literal, source).tree(); - expectNonTerminal(parseTree, NonTerminalKind.Literal); + const parseTree = language.parse(NonterminalKind.Literal, source).tree(); + expectNonterminal(parseTree, NonterminalKind.Literal); expect(parseTree.textLength).toEqual({ line: 0, @@ -57,9 +57,9 @@ test("calculate unicode characters text length", () => { const children = parseTree.children(); expect(children).toHaveLength(1); - const token = children[0]!; - expectTerminal(token, TerminalKind.StringLiteral, `"some 😁 emoji"`); - expect(token.textLength).toEqual({ + const terminal = children[0]!; + expectTerminal(terminal, TerminalKind.StringLiteral, `"some 😁 emoji"`); + expect(terminal.textLength).toEqual({ line: 0, column: 14, utf16: 15, @@ -67,12 +67,12 @@ test("calculate unicode characters text length", () => { }); }); -test("can unparse rule nodes", () => { +test("can unparse nonterminal nodes", () => { const source = `tree [A [B C] D];`; const language = new Language("1.0.0"); - const parseTree = language.parse(NonTerminalKind.SourceUnit, source).tree(); - expectNonTerminal(parseTree, NonTerminalKind.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 f70b4dc4a6..3d2046dea1 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 { NonTerminalKind } 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(NonTerminalKind.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 b02f400213..aa1abab8f7 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 { NonTerminalKind, TerminalKind } 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.NonTerminalKind.SourceUnit).toEqual("SourceUnit"); - expect(slang.kinds.NonTerminalKind.TreeNode).toEqual("TreeNode"); + 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(NonTerminalKind.SourceUnit).toEqual("SourceUnit"); - expect(NonTerminalKind.TreeNode).toEqual("TreeNode"); + 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 c981eb9356..2405e6bacb 100644 --- a/crates/testlang/outputs/npm/tests/src/tests/query.ts +++ b/crates/testlang/outputs/npm/tests/src/tests/query.ts @@ -1,4 +1,4 @@ -import { NonTerminalKind, TerminalKind } 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 { expectTerminal } from "../utils/cst-helpers"; @@ -6,28 +6,28 @@ 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(NonTerminalKind.Tree, tree_source); + const parse_output = language.parse(NonterminalKind.Tree, tree_source); const query_source = `[TreeNodeChild ... @id [DelimitedIdentifier]]`; const query = Query.parse(query_source); - const query_result = parse_output.createTreeCursor().query([query]); + const matches = parse_output.createTreeCursor().query([query]); - const expectNextResult = (name: string) => { - let result = query_result.next(); - expect(result).not.toBeNull(); - expect(Object.keys(result!.bindings)).toStrictEqual(["id"]); - let cursors = result!.bindings["id"]!; + const expectNextMatch = (name: string) => { + let match = matches.next(); + expect(match).not.toBeNull(); + expect(Object.keys(match!.captures)).toStrictEqual(["id"]); + let cursors = match!.captures["id"]!; expect(cursors.length).toEqual(1); expectTerminal(cursors[0]!.node(), TerminalKind.DelimitedIdentifier, name); }; - expectNextResult("A"); - expectNextResult("B"); - expectNextResult("C"); - expectNextResult("D"); + expectNextMatch("A"); + expectNextMatch("B"); + expectNextMatch("C"); + expectNextMatch("D"); - expect(query_result.next()).toBeNull(); + expect(matches.next()).toBeNull(); }); test("parser error", () => { 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 1dff178d7d..8d1e9f5396 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, NonTerminalNode, TerminalNode } from "@slang-private/slang-testlang/cst"; -import { NonTerminalKind, TerminalKind } 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 expectNonTerminal(node: unknown, kind: NonTerminalKind): asserts node is NonTerminalNode { - expect(node).toBeInstanceOf(NonTerminalNode); +export function expectNonterminal(node: unknown, kind: NonterminalKind): asserts node is NonterminalNode { + expect(node).toBeInstanceOf(NonterminalNode); - const rule = node as NonTerminalNode; - expect(rule.type).toEqual(NodeType.NonTerminal); - expect(rule.kind).toEqual(kind); + const nonTerminal = node as NonterminalNode; + expect(nonTerminal.type).toEqual(NodeType.Nonterminal); + expect(nonTerminal.kind).toEqual(kind); } export function expectTerminal(node: unknown, kind: TerminalKind, text: string): asserts node is TerminalNode { expect(node).toBeInstanceOf(TerminalNode); - const token = node as TerminalNode; - expect(token.type).toEqual(NodeType.Terminal); - expect(token.kind).toEqual(kind); - expect(token.text).toEqual(text); + const terminal = node as TerminalNode; + expect(terminal.type).toEqual(NodeType.Terminal); + expect(terminal.kind).toEqual(kind); + expect(terminal.text).toEqual(text); } diff --git a/documentation/public/internals/design-docs/language-definition-v2.md b/documentation/public/internals/design-docs/language-definition-v2.md index 204869547e..e71159d4c7 100644 --- a/documentation/public/internals/design-docs/language-definition-v2.md +++ b/documentation/public/internals/design-docs/language-definition-v2.md @@ -30,7 +30,7 @@ Here is an example of the node type, similar to what we have now: ```rust pub enum Node { Terminal { node: Rc }, - NonTerminal { node: Rc }, + Nonterminal { node: Rc }, } pub struct TerminalNode { @@ -38,8 +38,8 @@ pub struct TerminalNode { pub text: String, } -pub struct NonTerminalNode { - pub kind: NonTerminalKind, +pub struct NonterminalNode { + pub kind: NonterminalKind, pub text_length: TextIndex, pub children: Vec, } @@ -110,7 +110,7 @@ Trivia items are similar tokens, contributing their own `TerminalKind`. They are collecting them in a flat list. Previously, we used to create many `LeadingTrivia` and `TrailingTrivia` nodes that hold whitespace/comments. Not only this -is wasteful memory-wise, it is also unnatural/unexpected to wrap whitespace in non-terminal nodes. Instead, I propose +is wasteful memory-wise, it is also unnatural/unexpected to wrap whitespace in nonterminal nodes. Instead, I propose treating them like any other token, and storing them as siblings to the tokens they belong to (in-order). Not only this is simpler, it is also more efficient, and is natural to how input is consumed and produced. @@ -120,19 +120,19 @@ Fragments are not visible to users, and don't contribute a `TerminalKind`. They common parts of the grammar, and avoid duplication. During processing the language definition, they are inlined wherever they are referenced. -## NonTerminals +## Nonterminals ### Struct Items -Structs represent a flat list (sequence) of typed fields. They are the simplest non-terminal, and generate a `struct` AST type. -Their fields match 1-1 with the item fields. The struct name contributes a `NonTerminalKind`. +Structs represent a flat list (sequence) of typed fields. They are the simplest nonterminal, and generate a `struct` AST type. +Their fields match 1-1 with the item fields. The struct name contributes a `NonterminalKind`. Each field can be either `Required(T)` or `Optional(T)`. Required fields are always present and parsed. Optional fields can be omitted if they don't exist, and are represented with Rust's `Option` type (or TypeScript `T | undefined`). However, optional fields have an additional `enabled` property. After parsing optional fields, we should compare them with the current language version, and produce errors if they don't match, but continue parsing normally. -The type of each field can be a `NonTerminal(T)` or `Terminal(Set)`. A non-terminal field refers to another item, and +The type of each field can be a `Nonterminal(T)` or `Terminal(Set)`. A nonterminal field refers to another item, and holds its type. A terminal field refers to one or more terminal items (all valid in this position), and is of type `TerminalNode`. Additionally, the struct also stores the CST node that holds its contents: @@ -142,7 +142,7 @@ Struct( name = ParametersDeclaration, fields = ( open_paren = Required(Terminal([OpenParen])), - parameters = Required(NonTerminal(Parameters)), + parameters = Required(Nonterminal(Parameters)), close_paren = Required(Terminal([CloseParen])) ) ) @@ -154,14 +154,14 @@ pub struct ParametersDeclaration { pub parameters: Rc, pub close_paren: Rc, - pub cst: Rc, + pub cst: Rc, } ``` ### Enum Items Enums represent an ordered choice operator of multiple variants (possibilities). The enum name itself does NOT contribute -a `NonTerminalKind`, since it will always result in one of its variants (each with a unique `TerminalKind` or a `NonTerminalKind`. +a `NonterminalKind`, since it will always result in one of its variants (each with a unique `TerminalKind` or a `NonterminalKind`. They only exist in the AST, and don't affect the CST at all. We attempt to parse each variant (in-order), and choose the first one that succeeds. However, each variant can have @@ -184,19 +184,19 @@ pub enum FunctionBody { Block { block: Rc, - cst: Rc, + cst: Rc, }, Semicolon { semicolon: Rc, - cst: Rc, + cst: Rc, }, } ``` ### Repeated Items -Repeated items represent a list of items of the same kind. The item name contributes a `NonTerminalKind`. +Repeated items represent a list of items of the same kind. The item name contributes a `NonterminalKind`. The AST type is a wrapper around a `Vec`, with any utilities we need to add for convenience. It has an `allow_empty` boolean property, which allows parsing zero items. If it is `false`, we should still allow parsing @@ -214,14 +214,14 @@ Repeated( pub struct FunctionAttributes { pub items: Vec> - pub cst: Rc, + pub cst: Rc, } ``` ### Separated Items Separated items represent a list of items of the same kind, separated by a delimiter. -The item name contributes a `NonTerminalKind`. The AST type is a wrapper around two `Vec` for items and their delimiters, +The item name contributes a `NonterminalKind`. The AST type is a wrapper around two `Vec` for items and their delimiters, with any utilities we need to add for convenience. For example, we should add APIs to create iterators for only the separated items, the separators, or both (in-order). @@ -243,13 +243,13 @@ pub struct EventParameters { pub items: Vec> pub separators: Vec> - pub cst: Rc, + pub cst: Rc, } ``` ### Precedence Items -This is perhaps the most complex non-terminal. It still uses the same PRATT algorithm from the previous implementation (no changes there), but +This is perhaps the most complex nonterminal. It still uses the same PRATT algorithm from the previous implementation (no changes there), but adapted for the new AST types. It has two lists: First, a list of `precedence_expressions`, with each expression having a list of operators. Each operator has its own @@ -263,7 +263,7 @@ operators with different associativity, but defined in enabled/disabled in diffe Second, a list of `primary_expressions`, with their own versioning (`enabled` property) as well. We should try to parse them as an operator (similar to `EnumItem`), and produce an error if the version doesn't match afterwards. -It is important to note that the item name doesn't contribute a `NonTerminalKind`, but each `PrecedenceExpression` under it contributes one. +It is important to note that the item name doesn't contribute a `NonterminalKind`, but each `PrecedenceExpression` under it contributes one. ```rust title="Definition" Precedence( @@ -282,7 +282,7 @@ Precedence( model = Postfix, fields = ( open_paren = Required(Terminal([OpenParen])), - arguments = Required(NonTerminal(Arguments)), + arguments = Required(Nonterminal(Arguments)), close_paren = Required(Terminal([CloseParen])) ) )] @@ -322,7 +322,7 @@ pub struct AdditionExpression { // 'right_operand' auto-generated (after) because it is a binary expression, and same type as parent pub right_operand: Rc, - pub cst: Rc, + pub cst: Rc, } pub struct FunctionCallExpression { @@ -333,7 +333,7 @@ pub struct FunctionCallExpression { pub arguments: Rc, pub close_paren: Rc, - pub cst: Rc, + pub cst: Rc, } pub struct NegationExpression { @@ -342,7 +342,7 @@ pub struct NegationExpression { // 'operand' auto-generated (after) because it is a prefix expression, and same type as parent pub operand: Rc, - pub cst: Rc, + pub cst: Rc, } ``` @@ -358,11 +358,11 @@ During AST construction, we will simply check for `TerminalKind::UNRECOGNIZED` n Based on the above, I propose the following changes to the current public API: - Rename `TokenKind` to `TerminalKind`, since it will also refer to trivia. -- Rename `RuleKind` to `NonTerminalKind`, since "rule" is ambiguous. +- Rename `RuleKind` to `NonterminalKind`, since "rule" is ambiguous. - Rename `TerminalKind::SKIPPED`to `UNRECOGNIZED` for clarity. - Hide `LexicalContext` and `fn scan(TokenKind)` from the public API, as it is a short-term workaround, and will be replaced later when we have language embedding. -- Remove `ProductionKind` completely, since it is no longer needed. We only need to expose `fn parse(NonTerminalKind)`. +- Remove `ProductionKind` completely, since it is no longer needed. We only need to expose `fn parse(NonterminalKind)`. - Since `EndOFFileTrivia` no longer exists, `ParseResult` should collect any remaining trivia at the end of the input, and include it in the `ParseResult` returned, for any kind of node, not just `SourceUnit`. diff --git a/documentation/public/user-guide/concepts.md b/documentation/public/user-guide/concepts.md index 7004530b17..0ec4e148d3 100644 --- a/documentation/public/user-guide/concepts.md +++ b/documentation/public/user-guide/concepts.md @@ -8,14 +8,14 @@ This is a departure from the classic approach of "black-box" compilers, which ar To use Slang, you start by initializing a `Language` object with a specific version of the language. The earliest Solidity version we support is `0.4.11`, and we plan on supporting all future versions as they are released. -From a `Language` object, you can analyze any source text according to the rules of that specific version. +From a `Language` object, you can analyze any source text according to the nonterminals of that specific version. Providing an accurate language version is important, as it affects the shape of the syntax tree, and possible errors produced. 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 `NonTerminalKind` variant. -This allows callers to parse entire source files (`NonTerminalKind::SourceUnit`), individual contracts (`NonTerminalKind::ContractDefinition`), -methods (`NonTerminalKind::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. @@ -26,13 +26,13 @@ which is a tree structure of the program that also includes things like punctuat This is done by using the (standard) approach of lexical analysis followed by syntax analysis. The source text as a sequence of characters is recognized into a sequence of -tokens (lexical analysis), which then in turn is _parsed_ into the CST. +terminals (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: -- `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. +- `NonterminalNode` represent sub-trees, containing a vector of other `Node` children. +- `TerminalNode` are leaves and represent a terminal (i.e. an identifier, keyword, punctuation) in the source. ## CST Cursors @@ -66,7 +66,7 @@ longest/shortest/first/last match. There is no concept of a 'greedy' operator for example. Query execution is based on `Cursor`s, and the resulting matches and unification -bindings are returned as `Cursor`s as well. This allows you to mix and match +captures are returned as `Cursor`s as well. This allows you to mix and match manual traversal, cursors, and queries. Multiple queries can be executed in a batch, and efficiently traverse the tree @@ -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 `NonTerminalKind` 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, diff --git a/documentation/public/user-guide/introduction.md b/documentation/public/user-guide/introduction.md index fef5e7fd72..231ec50b6d 100644 --- a/documentation/public/user-guide/introduction.md +++ b/documentation/public/user-guide/introduction.md @@ -18,10 +18,10 @@ The Solidity programming language has evolved quite a bit since its inception. S While it's good for a programming language to evolve and better serve the needs of its users, not being able to easily upgrade or re-deploy existing contracts poses a unique challenge. Developer tooling must be able to understand and consume older contracts that are still being used on the blockchain, written in older versions of Solidity. -Because of that, Slang must be able to reason about different versions of Solidity; how the language grammar, name binding rules, and semantics have changed [across different versions](../solidity-specification/supported-versions.md). One of our goals is to document differences as part of our [Solidity Specification](../solidity-specification/index.md). +Because of that, Slang must be able to reason about different versions of Solidity; how the language grammar, name capture rules, and semantics have changed [across different versions](../solidity-specification/supported-versions.md). One of our goals is to document differences as part of our [Solidity Specification](../solidity-specification/index.md). This is why, instead of having to download separate versions of the tool for each Solidity version, you can access the Slang language APIs by simply specifying the Solidity version that you want to work with. ## Distributions -Slang itself is written in Rust and we maintain a public Rust package on [crates.io](https://crates.io/crates/slang_solidity). At the moment, we also distribute it as an [npm package](https://www.npmjs.com/package/@nomicfoundation/slang) with TypeScript interface. In the future, we plan on expanding the language bindings with Python and possibly more. +Slang itself is written in Rust and we maintain a public Rust package on [crates.io](https://crates.io/crates/slang_solidity). At the moment, we also distribute it as an [npm package](https://www.npmjs.com/package/@nomicfoundation/slang) with TypeScript interface. In the future, we plan on expanding the language captures with Python and possibly more. diff --git a/documentation/public/user-guide/npm-package/using-queries.md b/documentation/public/user-guide/npm-package/using-queries.md index 89c25d408b..a3278fe982 100644 --- a/documentation/public/user-guide/npm-package/using-queries.md +++ b/documentation/public/user-guide/npm-package/using-queries.md @@ -10,7 +10,7 @@ If not specified otherwise, let's assume we already parsed a Solidity source and You can create a `Query` object using `Query.parse`, which accepts a string value. These can be then used by `Cursor.query` to execute it. -You can pass multiple queries to a cursor to and efficiently traverse the tree looking for matches. They will be executed concurrently, returning results in the order they appear in input. +You can pass multiple queries to a cursor to and efficiently traverse the tree looking for matches. They will be executed concurrently, returning matches in the order they appear in input. ```{ .ts } --8<-- "crates/solidity/outputs/npm/tests/src/doc-examples/using-queries.ts:creating-a-query" @@ -18,7 +18,7 @@ You can pass multiple queries to a cursor to and efficiently traverse the tree l ## Iterating over node patterns -Queries allow you to iterate over all node patterns that match the query, which can replace your need for manual iteration via cursors or visitors. In order to get a `Cursor` that points to the matched node, you need to capture them with a name binding (`@binding_name`) to a specific node in the query pattern. +Queries allow you to iterate over all node patterns that match the query, which can replace your need for manual iteration via cursors or visitors. In order to get a `Cursor` that points to the matched node, you need to capture them with a name capture (`@capture_name`) to a specific node in the query pattern. Let's use this to list all the contract definitions in the source file: diff --git a/documentation/public/user-guide/npm-package/using-the-parser.md b/documentation/public/user-guide/npm-package/using-the-parser.md index 396b8c36ad..02703e5d40 100644 --- a/documentation/public/user-guide/npm-package/using-the-parser.md +++ b/documentation/public/user-guide/npm-package/using-the-parser.md @@ -1,6 +1,6 @@ # Using the Parser -Using the API directly provides us with a more fine-grained control over the parsing process. It allows us to parse not just the input as a top-level source unit, but also individual rules like contracts, various definitions, and even expressions. +Using the API directly provides us with a more fine-grained control over the parsing process. It allows us to parse not just the input as a top-level source unit, but also individual constructs like contracts, various definitions, and even expressions. ## Parsing Source Files @@ -11,7 +11,7 @@ Let's start with this simple source file, that contains a single contract: ``` We begin by creating a `Language` object with a specified version. This is an entry point for our parser API. -Then we can use it to parse the source file, specifying the top-level rule to parse: +Then we can use it to parse the source file, specifying the top-level nonterminal to parse: ```{ .ts } --8<-- "crates/solidity/outputs/npm/tests/src/doc-examples/using-the-parser.ts:imports" diff --git a/documentation/public/user-guide/rust-crate/using-queries.md b/documentation/public/user-guide/rust-crate/using-queries.md index 16b253d276..2c6e2639f1 100644 --- a/documentation/public/user-guide/rust-crate/using-queries.md +++ b/documentation/public/user-guide/rust-crate/using-queries.md @@ -10,7 +10,7 @@ If not specified otherwise, let's assume we already parsed a Solidity source and You can create a `Query` struct using `Query::parse`, which accepts a `&str`. These can be then used by `Cursor::query` to execute it. -You can pass multiple queries to a cursor to and efficiently traverse the tree looking for matches. They will be executed concurrently, returning results in the order they appear in input. +You can pass multiple queries to a cursor to and efficiently traverse the tree looking for matches. They will be executed concurrently, returning matches in the order they appear in input. ```{ .rust } --8<-- "crates/solidity/outputs/cargo/tests/src/doc_examples/using_queries.rs:creating-a-query" @@ -18,7 +18,7 @@ You can pass multiple queries to a cursor to and efficiently traverse the tree l ## Iterating over node patterns -Queries allow you to iterate over all node patterns that match the query, which can replace your need for manual iteration via cursors or visitors. In order to get a `Cursor` that points to the matched node, you need to capture them with a name binding (`@binding_name`) to a specific node in the query pattern. +Queries allow you to iterate over all node patterns that match the query, which can replace your need for manual iteration via cursors or visitors. In order to get a `Cursor` that points to the matched node, you need to capture them with a name capture (`@capture_name`) to a specific node in the query pattern. Let's use this to list all the contract definitions in the source file: diff --git a/documentation/public/user-guide/rust-crate/using-the-cli.md b/documentation/public/user-guide/rust-crate/using-the-cli.md index 22f08bc770..60ffd5a629 100644 --- a/documentation/public/user-guide/rust-crate/using-the-cli.md +++ b/documentation/public/user-guide/rust-crate/using-the-cli.md @@ -28,21 +28,21 @@ Options: Here is an example of the JSON output it can print: ```json -// A Rule node -"Rule": { - // Name of the rule kind +// A Nonterminal node +"Nonterminal": { + // Name of the nonterminal kind "kind": "SourceUnit", - // Length of the rule in Unicode code points, depending on the encoding used + // Length of the nonterminal in Unicode code points, depending on the encoding used "text_len": { "utf8": 24, "utf16": 24, "char": 24 // de facto utf32 }, - "children": [/* Rule or Token nodes */] + "children": [/* Nonterminal or Terminal nodes */] } -// A Token node -"Token": { - // Name of the token kind +// A Terminal node +"Terminal": { + // Name of the terminal kind "kind": "PragmaKeyword", // Literal value, taken from the source code "text": "pragma" @@ -64,11 +64,11 @@ slang_solidity parse --json --version "0.8.0" "input.sol" > "output.json" Because the resulting structure is well-defined and recursive, we can use the popular `jq` tool to quickly analyze the resulting output: ```bash -JQ_QUERY='recurse | select(.Token?) | .Token' +JQ_QUERY='recurse | select(.Terminal?) | .Terminal' cat output.json | jq "$JQ_QUERY" ``` -This gives us a flat list of the Token nodes: +This gives us a flat list of the Terminal nodes: ```json { @@ -125,7 +125,7 @@ Now, we can adapt the query to select the `text` fields of the nodes and concate which gives us back the reconstructed source code! 🎉 ```bash -$ JQ_QUERY='[recurse | select(.Token?) | .Token.text] | join("")' +$ JQ_QUERY='[recurse | select(.Terminal?) | .Terminal.text] | join("")' $ cat output.json | jq "$JQ_QUERY" "pragma solidity ^0.8.0;\n" diff --git a/documentation/public/user-guide/rust-crate/using-the-parser.md b/documentation/public/user-guide/rust-crate/using-the-parser.md index bf1a201cd3..fc9a3f158c 100644 --- a/documentation/public/user-guide/rust-crate/using-the-parser.md +++ b/documentation/public/user-guide/rust-crate/using-the-parser.md @@ -1,6 +1,6 @@ # Using the Parser -Using the API directly provides us with a more fine-grained control over the parsing process. It allows us to parse not just the input as a top-level source unit, but also individual rules like contracts, various definitions, and even expressions. +Using the API directly provides us with a more fine-grained control over the parsing process. It allows us to parse not just the input as a top-level source unit, but also individual nonterminals like contracts, various definitions, and even expressions. ## Parsing Source Files @@ -11,7 +11,7 @@ Let's start with this simple source file, that contains a single contract: ``` We begin by creating a `Language` object with a specified version. This is an entry point for our parser API. -Then we can use it to parse the source file, specifying the top-level rule to parse: +Then we can use it to parse the source file, specifying the top-level nonterminal to parse: ```{ .rust } --8<-- "crates/solidity/outputs/cargo/tests/src/doc_examples/using_the_parser.rs:imports" diff --git a/documentation/public/user-guide/tree-query-language.md b/documentation/public/user-guide/tree-query-language.md index 65ddc610d9..bfca807e70 100644 --- a/documentation/public/user-guide/tree-query-language.md +++ b/documentation/public/user-guide/tree-query-language.md @@ -102,7 +102,7 @@ In the case of a variable, capture it as `@function`, and in the case of a prope --8<-- "crates/solidity/outputs/cargo/tests/src/doc_examples/tree_query_language.rs:alternations-1" ``` -This pattern would match a set of possible keyword tokens, capturing them as `@keyword`: +This pattern would match a set of possible keyword terminals, capturing them as `@keyword`: ```{ .scheme } --8<-- "crates/solidity/outputs/cargo/tests/src/doc_examples/tree_query_language.rs:alternations-2"