diff --git a/.changeset/breezy-otters-heal.md b/.changeset/breezy-otters-heal.md new file mode 100644 index 0000000000..ad9e88755f --- /dev/null +++ b/.changeset/breezy-otters-heal.md @@ -0,0 +1,5 @@ +--- +"@nomicfoundation/slang": minor +--- + +Remove `ProductionKind` in favor of `RuleKind` diff --git a/.changeset/new-monkeys-scream.md b/.changeset/new-monkeys-scream.md new file mode 100644 index 0000000000..fd91823142 --- /dev/null +++ b/.changeset/new-monkeys-scream.md @@ -0,0 +1,5 @@ +--- +"@nomicfoundation/slang": minor +--- + +Allow parsing individual precedence expressions, like `ShiftExpression` diff --git a/crates/codegen/grammar/src/precedence_parser_definition.rs b/crates/codegen/grammar/src/precedence_parser_definition.rs index 8bff61e939..dcbba9fdad 100644 --- a/crates/codegen/grammar/src/precedence_parser_definition.rs +++ b/crates/codegen/grammar/src/precedence_parser_definition.rs @@ -1,9 +1,7 @@ use std::fmt::Debug; use std::rc::Rc; -use super::{ - GrammarVisitor, ParserDefinitionNode, ParserDefinitionRef, VersionQualityRange, Visitable, -}; +use super::{GrammarVisitor, ParserDefinitionNode, Visitable}; pub trait PrecedenceParserDefinition: Debug { fn name(&self) -> &'static str; @@ -24,11 +22,11 @@ impl Visitable for PrecedenceParserDefinitionRef { pub struct PrecedenceParserDefinitionNode { pub primary_expression: Box, pub operators: Vec<( - Vec, PrecedenceOperatorModel, &'static str, // name - ParserDefinitionRef, + ParserDefinitionNode, )>, + pub precedence_expression_names: Vec<&'static str>, } impl Visitable for PrecedenceParserDefinitionNode { diff --git a/crates/codegen/language/definition/src/compiler/analysis/references.rs b/crates/codegen/language/definition/src/compiler/analysis/references.rs index e7f1afac4b..6cef7a596c 100644 --- a/crates/codegen/language/definition/src/compiler/analysis/references.rs +++ b/crates/codegen/language/definition/src/compiler/analysis/references.rs @@ -171,11 +171,7 @@ fn check_precedence( let enablement = update_enablement(analysis, enablement, enabled); for precedence_expression in precedence_expressions { - let SpannedPrecedenceExpression { - name: _, - rule_name: _, - operators, - } = precedence_expression; + let SpannedPrecedenceExpression { name: _, operators } = precedence_expression; for operator in operators { let SpannedPrecedenceOperator { diff --git a/crates/codegen/language/definition/src/model/non_terminals/precedence.rs b/crates/codegen/language/definition/src/model/non_terminals/precedence.rs index 303462df19..6174e41bd4 100644 --- a/crates/codegen/language/definition/src/model/non_terminals/precedence.rs +++ b/crates/codegen/language/definition/src/model/non_terminals/precedence.rs @@ -20,9 +20,6 @@ pub struct PrecedenceItem { pub struct PrecedenceExpression { pub name: Identifier, - // TODO(#638): Remove this, once we adapt the DSL v1 codegen model to the new v2 definition. - pub rule_name: Identifier, - pub operators: Vec, } @@ -37,7 +34,7 @@ pub struct PrecedenceOperator { pub fields: IndexMap, } -#[derive(Clone, Copy, Debug, Deserialize, Eq, PartialEq, Serialize)] +#[derive(Clone, Copy, Debug, Deserialize, Eq, PartialEq, Hash, PartialOrd, Ord, Serialize)] #[derive_spanned_type(ParseInputTokens, WriteOutputTokens)] pub enum OperatorModel { Prefix, diff --git a/crates/codegen/language/tests/src/fail/definitions/duplicate_expression_name/test.rs b/crates/codegen/language/tests/src/fail/definitions/duplicate_expression_name/test.rs index 1e5c9f00d6..657ba4785c 100644 --- a/crates/codegen/language/tests/src/fail/definitions/duplicate_expression_name/test.rs +++ b/crates/codegen/language/tests/src/fail/definitions/duplicate_expression_name/test.rs @@ -14,9 +14,9 @@ codegen_language_macros::compile!(Language( Precedence( name = Bar, precedence_expressions = [ - PrecedenceExpression(name = Expression1, rule_name = X, operators = []), - PrecedenceExpression(name = Expression2, rule_name = X, operators = []), - PrecedenceExpression(name = Expression1, rule_name = X, operators = []) + PrecedenceExpression(name = Expression1, operators = []), + PrecedenceExpression(name = Expression2, operators = []), + PrecedenceExpression(name = Expression1, operators = []) ], primary_expressions = [PrimaryExpression(reference = Baz)] ), diff --git a/crates/codegen/language/tests/src/fail/definitions/duplicate_expression_name/test.stderr b/crates/codegen/language/tests/src/fail/definitions/duplicate_expression_name/test.stderr index b9f2da2b43..6d6b1ea841 100644 --- a/crates/codegen/language/tests/src/fail/definitions/duplicate_expression_name/test.stderr +++ b/crates/codegen/language/tests/src/fail/definitions/duplicate_expression_name/test.stderr @@ -1,5 +1,5 @@ error: An expression with the name 'Expression1' already exists. --> src/fail/definitions/duplicate_expression_name/test.rs:19:53 | -19 | PrecedenceExpression(name = Expression1, rule_name = X, operators = []) +19 | PrecedenceExpression(name = Expression1, operators = []) | ^^^^^^^^^^^ diff --git a/crates/codegen/parser/generator/src/code_generator.rs b/crates/codegen/parser/generator/src/code_generator.rs index a844940ada..5f7be8c309 100644 --- a/crates/codegen/parser/generator/src/code_generator.rs +++ b/crates/codegen/parser/generator/src/code_generator.rs @@ -7,8 +7,8 @@ use std::{ use anyhow::Result; use codegen_grammar::{ Grammar, GrammarVisitor, ParserDefinitionNode, ParserDefinitionRef, - PrecedenceParserDefinitionNode, PrecedenceParserDefinitionRef, ScannerDefinitionNode, - ScannerDefinitionRef, TriviaParserDefinitionRef, + PrecedenceParserDefinitionRef, ScannerDefinitionNode, ScannerDefinitionRef, + TriviaParserDefinitionRef, }; use infra_utils::{cargo::CargoWorkspace, codegen::Codegen}; use quote::{format_ident, quote}; @@ -27,7 +27,6 @@ pub struct CodeGenerator { rule_kinds: BTreeSet<&'static str>, token_kinds: BTreeSet<&'static str>, - production_kinds: BTreeSet<&'static str>, trivia_kinds: BTreeSet<&'static str>, top_level_scanner_names: BTreeSet<&'static str>, @@ -216,7 +215,6 @@ impl GrammarVisitor for CodeGenerator { fn trivia_parser_definition_enter(&mut self, parser: &TriviaParserDefinitionRef) { self.set_current_context(parser.context()); - self.production_kinds.insert(parser.name()); self.rule_kinds.insert(parser.name()); self.trivia_kinds.insert(parser.name()); self.parser_functions.push(( @@ -234,7 +232,6 @@ impl GrammarVisitor for CodeGenerator { // Have to set this regardless so that we can collect referenced scanners self.set_current_context(parser.context()); if !parser.is_inline() { - self.production_kinds.insert(parser.name()); self.rule_kinds.insert(parser.name()); let code = parser.to_parser_code(); self.parser_functions.push(( @@ -250,11 +247,17 @@ impl GrammarVisitor for CodeGenerator { fn precedence_parser_definition_enter(&mut self, parser: &PrecedenceParserDefinitionRef) { self.set_current_context(parser.context()); - self.production_kinds.insert(parser.name()); self.rule_kinds.insert(parser.name()); - for (_, _, name, _) in &parser.node().operators { + for (_, name, _) in &parser.node().operators { self.rule_kinds.insert(name); } + + // While it's not common to parse a precedence expression as a standalone rule, + // we generate a function for completeness. + for (name, code) in parser.to_precedence_expression_parser_code() { + self.parser_functions.push((name, code.to_string())); + } + self.parser_functions.push(( parser.name(), { @@ -315,12 +318,4 @@ impl GrammarVisitor for CodeGenerator { _ => {} }; } - - fn precedence_parser_definition_node_enter(&mut self, node: &PrecedenceParserDefinitionNode) { - for operator in &node.operators { - for vqr in &operator.0 { - self.referenced_versions.insert(vqr.from.clone()); - } - } - } } diff --git a/crates/codegen/parser/generator/src/parser_definition.rs b/crates/codegen/parser/generator/src/parser_definition.rs index 9771fcacd2..323db87261 100644 --- a/crates/codegen/parser/generator/src/parser_definition.rs +++ b/crates/codegen/parser/generator/src/parser_definition.rs @@ -259,7 +259,6 @@ impl ParserDefinitionNodeExtensions for ParserDefinitionNode { pub trait VersionQualityRangeVecExtensions { fn wrap_code(&self, if_true: TokenStream, if_false: Option) -> TokenStream; - fn disambiguating_name_suffix(&self) -> String; } impl VersionQualityRangeVecExtensions for Vec { @@ -282,15 +281,4 @@ impl VersionQualityRangeVecExtensions for Vec { quote! { if #(#flags)&&* { #if_true } #else_part } } } - - fn disambiguating_name_suffix(&self) -> String { - let mut suffix = String::new(); - for vqr in self { - suffix.push('_'); - suffix.push_str(&vqr.quality.to_string().to_lowercase()); - suffix.push_str("_from_"); - suffix.push_str(&vqr.from.to_string().replace('.', "_")); - } - suffix - } } diff --git a/crates/codegen/parser/generator/src/precedence_parser_definition.rs b/crates/codegen/parser/generator/src/precedence_parser_definition.rs index 220f8e8097..5abba10cb1 100644 --- a/crates/codegen/parser/generator/src/precedence_parser_definition.rs +++ b/crates/codegen/parser/generator/src/precedence_parser_definition.rs @@ -1,32 +1,62 @@ use codegen_grammar::{ PrecedenceOperatorModel, PrecedenceParserDefinitionNode, PrecedenceParserDefinitionRef, - VersionQualityRange, }; use inflector::Inflector; use proc_macro2::{Ident, TokenStream}; use quote::{format_ident, quote}; -use super::parser_definition::{ParserDefinitionNodeExtensions, VersionQualityRangeVecExtensions}; +use super::parser_definition::ParserDefinitionNodeExtensions; pub trait PrecedenceParserDefinitionExtensions { fn to_parser_code(&self) -> TokenStream; + /// Emit a helper parser function for each precedence expression that ensures the main parser + /// identifies a single node of the expected type, with a child node being the expected + /// precedence expression. + fn to_precedence_expression_parser_code(&self) -> Vec<(&'static str, TokenStream)>; } impl PrecedenceParserDefinitionExtensions for PrecedenceParserDefinitionRef { fn to_parser_code(&self) -> TokenStream { self.node().to_parser_code( self.context(), - Some(format_ident!("{name}", name = self.name().to_pascal_case())), + format_ident!("{name}", name = self.name().to_pascal_case()), ) } + + fn to_precedence_expression_parser_code(&self) -> Vec<(&'static str, TokenStream)> { + let mut res = vec![]; + let parser_name = format_ident!("{}", self.name().to_snake_case()); + let rule_name = format_ident!("{}", self.name().to_pascal_case()); + + for name in &self.node().precedence_expression_names { + let op_rule_name = format_ident!("{}", name.to_pascal_case()); + + // Ensure that the parser correctly identifies a single node of the expected type, + // which contains a single child node representing the expected precedence operator. + let code = quote! { + let result = self.#parser_name(input); + 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. + match &r#match.nodes[..] { + [cst::Node::Rule(node)] if node.kind == RuleKind::#rule_name => match &node.children[..] { + [inner @ cst::Node::Rule(rule)] if rule.kind == RuleKind::#op_rule_name => { + ParserResult::r#match(vec![inner.clone()], r#match.expected_tokens.clone()) + } + _ => ParserResult::no_match(vec![]), + } + _ => ParserResult::no_match(vec![]), + } + }; + res.push((*name, code)); + } + res + } } pub trait PrecedenceParserDefinitionNodeExtensions { - fn to_parser_code( - &self, - context_name: &'static str, - expression_kind: Option, - ) -> TokenStream; + fn to_parser_code(&self, context_name: &'static str, expression_kind: Ident) -> TokenStream; } impl PrecedenceParserDefinitionNodeExtensions for PrecedenceParserDefinitionNode { @@ -71,12 +101,7 @@ impl PrecedenceParserDefinitionNodeExtensions for PrecedenceParserDefinitionNode // is independent of the grammar. #[allow(clippy::too_many_lines)] // Repetition-heavy with 4 kinds of precedence operators - fn to_parser_code( - &self, - context_name: &'static str, - expression_kind: Option, - ) -> TokenStream { - type OperatorParser = (TokenStream, Vec); + fn to_parser_code(&self, context_name: &'static str, expression_kind: Ident) -> TokenStream { let mut prefix_operator_parsers: Vec = Vec::new(); let mut postfix_operator_parsers: Vec = Vec::new(); let mut binary_operator_parsers: Vec = Vec::new(); @@ -86,22 +111,19 @@ impl PrecedenceParserDefinitionNodeExtensions for PrecedenceParserDefinitionNode let mut operator_closures = Vec::new(); let mut binding_power = 1u8; - for (version_quality_ranges, model, name, operator_definition) in &self.operators { - let operator_code = operator_definition - .node() - .to_parser_code(context_name, false); + for (model, name, operator_definition) in &self.operators { + let operator_code = operator_definition.to_parser_code(context_name, false); let rule_kind = format_ident!("{}", name); - let closure_name = format_ident!( - // Make a name that won't conflict with the parsers we define below - "parse_{name}{version_tag}", - version_tag = version_quality_ranges.disambiguating_name_suffix(), - name = operator_definition.name().to_snake_case() - ); + let model_name = match model { + PrecedenceOperatorModel::BinaryLeftAssociative => "left", + PrecedenceOperatorModel::BinaryRightAssociative => "right", + PrecedenceOperatorModel::Prefix => "prefix", + PrecedenceOperatorModel::Postfix => "postfix", + }; + let closure_name = + format_ident!("parse_{model_name}_{name}", name = name.to_snake_case()); - let parser = ( - quote! { #closure_name(input) }, - version_quality_ranges.clone(), - ); + let parser = quote! { #closure_name(input) }; match model { PrecedenceOperatorModel::BinaryLeftAssociative => { @@ -155,53 +177,14 @@ impl PrecedenceParserDefinitionNodeExtensions for PrecedenceParserDefinitionNode binding_power += 2; } - // TODO: merge these three functions into parse_definition by changing - // `to_parser_code` to use `(TokenStream, Vec)` as - // the core type i.e. the `OperatorParser` type above - #[allow(clippy::items_after_statements)] - fn make_sequence(parsers: Vec) -> TokenStream { - let parsers = parsers - .into_iter() - .map(|parser| quote! { seq.elem(#parser)?; }) - .collect::>(); - quote! { - SequenceHelper::run(|mut seq| { - #(#parsers)* - seq.finish() - }) - } - } - - #[allow(clippy::items_after_statements)] - fn make_choice(parsers: Vec) -> TokenStream { - let parsers = parsers - .into_iter() - .map(|(parser, version_quality_ranges)| { - version_quality_ranges.wrap_code( - quote! { - let result = #parser; - choice.consider(input, result)?; - }, - None, - ) - }) - .collect::>(); - quote! { - ChoiceHelper::run(input, |mut choice, input| { - #(#parsers)* - choice.finish(input) - }) - } - } - let mut binary_operand_terms = vec![]; + // First, establish the binary operand parser `BinaryOperand ::= PrefixOperator* PrimaryExpression PostfixOperator*` if !prefix_operator_parsers.is_empty() { let prefix_operator_parser = make_choice(prefix_operator_parsers); operator_closures.push(quote! { let prefix_operator_parser = |input: &mut ParserContext<'_>| #prefix_operator_parser; }); - binary_operand_terms.push( - quote! { ZeroOrMoreHelper::run(input, |input| prefix_operator_parser(input)) }, - ); + binary_operand_terms + .push(quote! { ZeroOrMoreHelper::run(input, prefix_operator_parser) }); } let primary_expression_parser = self.primary_expression.to_parser_code(context_name, false); @@ -211,47 +194,76 @@ impl PrecedenceParserDefinitionNodeExtensions for PrecedenceParserDefinitionNode if !postfix_operator_parsers.is_empty() { let postfix_operator_parser = make_choice(postfix_operator_parsers); operator_closures.push(quote! { let postfix_operator_parser = |input: &mut ParserContext<'_>| #postfix_operator_parser; }); - binary_operand_terms.push( - quote! { ZeroOrMoreHelper::run(input, |input| postfix_operator_parser(input)) }, - ); + binary_operand_terms + .push(quote! { ZeroOrMoreHelper::run(input, postfix_operator_parser) }); } let binary_operand_parser = make_sequence(binary_operand_terms); - if binary_operator_parsers.is_empty() { - operator_closures.push(quote! { let linear_expression_parser = |input: &mut ParserContext<'_>| #binary_operand_parser; }); + // Now, establish the linear expression parser `Expression ::= BinaryOperand ( BinaryOperator BinaryOperand )*` + let linear_expression_parser = if binary_operator_parsers.is_empty() { + // No binary operators, so the expression is simply `BinaryOperand` + binary_operand_parser } else { operator_closures.push(quote! { let binary_operand_parser = |input: &mut ParserContext<'_>| #binary_operand_parser; }); let binary_operator_parser = make_choice(binary_operator_parsers); operator_closures.push(quote! { let binary_operator_parser = |input: &mut ParserContext<'_>| #binary_operator_parser; }); - let linear_expression_parser = - make_sequence(vec![quote! { binary_operand_parser(input) }, { - let pairs = make_sequence(vec![ - quote! { binary_operator_parser(input) }, - quote! { binary_operand_parser(input) }, - ]); - quote! { ZeroOrMoreHelper::run(input, |input| #pairs) } - }]); - operator_closures - .push(quote! { let linear_expression_parser = |input: &mut ParserContext<'_>| #linear_expression_parser; }); - } - - let expression_kind_literal = if let Some(kind) = expression_kind { - quote! { Some(RuleKind::#kind) } - } else { - quote! { None } + // `BinaryOperand ( BinaryOperator BinaryOperand )*` + make_sequence(vec![quote! { binary_operand_parser(input) }, { + let pairs = make_sequence(vec![ + quote! { binary_operator_parser(input) }, + quote! { binary_operand_parser(input) }, + ]); + quote! { ZeroOrMoreHelper::run(input, |input| #pairs) } + }]) }; + operator_closures + .push(quote! { let linear_expression_parser = |input: &mut ParserContext<'_>| #linear_expression_parser; }); + quote! { #( - // TODO(#638): remove duplicates once we use DSL v2 versioning schema - #[allow(unused_variables)] #operator_closures )* - PrecedenceHelper::reduce_precedence_result(#expression_kind_literal, linear_expression_parser(input)) + PrecedenceHelper::reduce_precedence_result(RuleKind::#expression_kind, linear_expression_parser(input)) } } } + +// TODO: merge these three functions into parse_definition by changing +// `to_parser_code` to use `TokenStream` +type OperatorParser = TokenStream; + +fn make_sequence(parsers: Vec) -> TokenStream { + let parsers = parsers + .into_iter() + .map(|parser| quote! { seq.elem(#parser)?; }) + .collect::>(); + quote! { + SequenceHelper::run(|mut seq| { + #(#parsers)* + seq.finish() + }) + } +} + +fn make_choice(parsers: Vec) -> TokenStream { + let parsers = parsers + .into_iter() + .map(|parser| { + quote! { + let result = #parser; + choice.consider(input, result)?; + } + }) + .collect::>(); + quote! { + ChoiceHelper::run(input, |mut choice, input| { + #(#parsers)* + choice.finish(input) + }) + } +} diff --git a/crates/codegen/parser/runtime/src/support/precedence_helper.rs b/crates/codegen/parser/runtime/src/support/precedence_helper.rs index bc93d2e7d8..0ebe6f2a24 100644 --- a/crates/codegen/parser/runtime/src/support/precedence_helper.rs +++ b/crates/codegen/parser/runtime/src/support/precedence_helper.rs @@ -58,10 +58,7 @@ impl PrecedenceHelper { } #[allow(clippy::too_many_lines)] // Explicit on purpose, see below. - pub fn reduce_precedence_result( - child_kind: Option, - result: ParserResult, - ) -> ParserResult { + pub fn reduce_precedence_result(child_kind: RuleKind, result: ParserResult) -> ParserResult { // This requires some careful thinking. It could be more compact, // but I'm favouring obviousness here. That is also why there are // so many `unreachable!` - not only should they never be reached, @@ -162,10 +159,8 @@ impl PrecedenceHelper { let wrap_children = |children: Vec| { if children.is_empty() { children - } else if let Some(kind) = child_kind { - vec![cst::Node::rule(kind, children)] } else { - children + vec![cst::Node::rule(child_kind, children)] } }; diff --git a/crates/codegen/parser/runtime/src/templates/kinds.rs.jinja2 b/crates/codegen/parser/runtime/src/templates/kinds.rs.jinja2 index 7ba6bd338d..bf76aa9318 100644 --- a/crates/codegen/parser/runtime/src/templates/kinds.rs.jinja2 +++ b/crates/codegen/parser/runtime/src/templates/kinds.rs.jinja2 @@ -1,26 +1,6 @@ #[cfg(feature = "slang_napi_interfaces")] use {napi::bindgen_prelude::*, napi_derive::napi}; -#[derive( - Debug, - Eq, - Ord, - PartialEq, - PartialOrd, - serde::Serialize, - strum_macros::AsRefStr, - strum_macros::Display, - strum_macros::EnumString, -)] -#[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 ProductionKind { - {%- for variant in code.production_kinds -%} - {# variant.documentation | indent(prefix = "/// ", first = true, blank = true) #} - {{ variant }}, - {%- endfor -%} -} - #[derive( Debug, Eq, diff --git a/crates/codegen/parser/runtime/src/templates/language.rs.jinja2 b/crates/codegen/parser/runtime/src/templates/language.rs.jinja2 index 9615655d9b..08750834a5 100644 --- a/crates/codegen/parser/runtime/src/templates/language.rs.jinja2 +++ b/crates/codegen/parser/runtime/src/templates/language.rs.jinja2 @@ -7,7 +7,8 @@ use {napi::bindgen_prelude::*, napi_derive::napi}; use semver::Version; use super::{ - kinds::{RuleKind, TokenKind, ProductionKind, IsLexicalContext, LexicalContextType}, + cst, + kinds::{RuleKind, TokenKind, IsLexicalContext, LexicalContextType}, lexer::Lexer, parse_output::ParseOutput, support::{ @@ -99,10 +100,10 @@ impl Language { } } - pub fn parse(&self, production_kind: ProductionKind, input: &str) -> ParseOutput { - match production_kind { + pub fn parse(&self, kind: RuleKind, input: &str) -> ParseOutput { + match kind { {%- for function in code.parser_functions -%} - ProductionKind::{{ function.0 }} => Self::{{ function.0 | snake_case }}.parse(self, input), + RuleKind::{{ function.0 }} => Self::{{ function.0 | snake_case }}.parse(self, input), {%- endfor -%} } } @@ -220,10 +221,10 @@ impl Language { #[napi(js_name = "parse", ts_return_type = "parse_output.ParseOutput")] pub fn parse_napi( &self, - #[napi(ts_arg_type = "kinds.ProductionKind")] production_kind: ProductionKind, + #[napi(ts_arg_type = "kinds.RuleKind")] kind: RuleKind, input: String ) -> NAPIParseOutput { - self.parse(production_kind, input.as_str()).into() + self.parse(kind, input.as_str()).into() } } diff --git a/crates/solidity/inputs/language/src/definition.rs b/crates/solidity/inputs/language/src/definition.rs index 141ed6081e..69061efdde 100644 --- a/crates/solidity/inputs/language/src/definition.rs +++ b/crates/solidity/inputs/language/src/definition.rs @@ -126,7 +126,6 @@ codegen_language_macros::compile!(Language( precedence_expressions = [ PrecedenceExpression( name = VersionPragmaOrExpression, - rule_name = VersionPragmaBinaryExpression, operators = [PrecedenceOperator( model = BinaryLeftAssociative, fields = (operator = Required(BarBar)) @@ -134,7 +133,6 @@ codegen_language_macros::compile!(Language( ), PrecedenceExpression( name = VersionPragmaRangeExpression, - rule_name = VersionPragmaBinaryExpression, operators = [PrecedenceOperator( model = BinaryLeftAssociative, fields = (operator = Required(Minus)) @@ -142,7 +140,6 @@ codegen_language_macros::compile!(Language( ), PrecedenceExpression( name = VersionPragmaPrefixExpression, - rule_name = VersionPragmaUnaryExpression, operators = [ PrecedenceOperator( model = Prefix, @@ -2549,7 +2546,6 @@ codegen_language_macros::compile!(Language( name = TypeName, precedence_expressions = [PrecedenceExpression( name = ArrayTypeName, - rule_name = ArrayTypeName, operators = [PrecedenceOperator( model = Postfix, error_recovery = FieldsErrorRecovery( @@ -3040,7 +3036,6 @@ codegen_language_macros::compile!(Language( precedence_expressions = [ PrecedenceExpression( name = AssignmentExpression, - rule_name = BinaryExpression, operators = [ PrecedenceOperator( model = BinaryLeftAssociative, @@ -3096,7 +3091,6 @@ codegen_language_macros::compile!(Language( ), PrecedenceExpression( name = ConditionalExpression, - rule_name = ConditionalExpression, operators = [PrecedenceOperator( model = Postfix, fields = ( @@ -3109,7 +3103,6 @@ codegen_language_macros::compile!(Language( ), PrecedenceExpression( name = OrExpression, - rule_name = BinaryExpression, operators = [PrecedenceOperator( model = BinaryLeftAssociative, fields = (operator = Required(BarBar)) @@ -3117,7 +3110,6 @@ codegen_language_macros::compile!(Language( ), PrecedenceExpression( name = AndExpression, - rule_name = BinaryExpression, operators = [PrecedenceOperator( model = BinaryLeftAssociative, fields = (operator = Required(AmpersandAmpersand)) @@ -3125,7 +3117,6 @@ codegen_language_macros::compile!(Language( ), PrecedenceExpression( name = EqualityExpression, - rule_name = BinaryExpression, operators = [ PrecedenceOperator( model = BinaryLeftAssociative, @@ -3139,7 +3130,6 @@ codegen_language_macros::compile!(Language( ), PrecedenceExpression( name = ComparisonExpression, - rule_name = BinaryExpression, operators = [ PrecedenceOperator( model = BinaryLeftAssociative, @@ -3161,7 +3151,6 @@ codegen_language_macros::compile!(Language( ), PrecedenceExpression( name = BitwiseOrExpression, - rule_name = BinaryExpression, operators = [PrecedenceOperator( model = BinaryLeftAssociative, fields = (operator = Required(Bar)) @@ -3169,7 +3158,6 @@ codegen_language_macros::compile!(Language( ), PrecedenceExpression( name = BitwiseXorExpression, - rule_name = BinaryExpression, operators = [PrecedenceOperator( model = BinaryLeftAssociative, fields = (operator = Required(Caret)) @@ -3177,7 +3165,6 @@ codegen_language_macros::compile!(Language( ), PrecedenceExpression( name = BitwiseAndExpression, - rule_name = BinaryExpression, operators = [PrecedenceOperator( model = BinaryLeftAssociative, fields = (operator = Required(Ampersand)) @@ -3185,7 +3172,6 @@ codegen_language_macros::compile!(Language( ), PrecedenceExpression( name = ShiftExpression, - rule_name = BinaryExpression, operators = [ PrecedenceOperator( model = BinaryLeftAssociative, @@ -3204,7 +3190,6 @@ codegen_language_macros::compile!(Language( ), PrecedenceExpression( name = AdditiveExpression, - rule_name = BinaryExpression, operators = [ PrecedenceOperator( model = BinaryLeftAssociative, @@ -3218,7 +3203,6 @@ codegen_language_macros::compile!(Language( ), PrecedenceExpression( name = MultiplicativeExpression, - rule_name = BinaryExpression, operators = [ PrecedenceOperator( model = BinaryLeftAssociative, @@ -3236,7 +3220,6 @@ codegen_language_macros::compile!(Language( ), PrecedenceExpression( name = ExponentiationExpression, - rule_name = BinaryExpression, operators = [ // Before '0.6.0', it was left-associative: PrecedenceOperator( @@ -3254,7 +3237,6 @@ codegen_language_macros::compile!(Language( ), PrecedenceExpression( name = PostfixExpression, - rule_name = UnaryPostfixExpression, operators = [ PrecedenceOperator( model = Postfix, @@ -3268,7 +3250,6 @@ codegen_language_macros::compile!(Language( ), PrecedenceExpression( name = PrefixExpression, - rule_name = UnaryPrefixExpression, operators = [ PrecedenceOperator( model = Prefix, @@ -3299,7 +3280,6 @@ codegen_language_macros::compile!(Language( ), PrecedenceExpression( name = FunctionCallExpression, - rule_name = FunctionCallExpression, operators = [PrecedenceOperator( model = Postfix, fields = ( @@ -3313,7 +3293,6 @@ codegen_language_macros::compile!(Language( ), PrecedenceExpression( name = MemberAccessExpression, - rule_name = MemberAccessExpression, operators = [PrecedenceOperator( model = Postfix, fields = ( @@ -3324,7 +3303,6 @@ codegen_language_macros::compile!(Language( ), PrecedenceExpression( name = IndexAccessExpression, - rule_name = IndexAccessExpression, operators = [PrecedenceOperator( model = Postfix, error_recovery = FieldsErrorRecovery( @@ -4059,7 +4037,6 @@ codegen_language_macros::compile!(Language( name = YulExpression, precedence_expressions = [PrecedenceExpression( name = YulFunctionCallExpression, - rule_name = YulFunctionCallExpression, operators = [PrecedenceOperator( model = Postfix, error_recovery = FieldsErrorRecovery( diff --git a/crates/solidity/inputs/language/src/grammar.rs b/crates/solidity/inputs/language/src/grammar.rs index 2c8208206c..17e9c83638 100644 --- a/crates/solidity/inputs/language/src/grammar.rs +++ b/crates/solidity/inputs/language/src/grammar.rs @@ -2,7 +2,7 @@ //! (used for generating the parser and the CST). use std::cell::OnceCell; -use std::collections::{BTreeSet, HashMap}; +use std::collections::{BTreeMap, BTreeSet, HashMap}; use std::rc::Rc; use codegen_grammar::Grammar; @@ -742,61 +742,71 @@ fn resolve_precedence( } let mut operators = vec![]; + let mut precedence_expression_names = Vec::with_capacity(item.precedence_expressions.len()); for expr in item.precedence_expressions { let name = expr.name; + // TODO: Don't leak + let leaked_name = name.to_string().leak() as &_; + precedence_expression_names.push(leaked_name); // Register it as a regular parser with a given name, however we need to // define it as a choice over the "operator" sequences // Then, when returning, we should actually return a node ref pointing to that combined parser // And ideally, we shouldn't even use the "enabled" mode of the original DSL let thunk = Rc::new(NamedParserThunk { - name: name.to_string().leak(), + name: leaked_name, context: lex_ctx, - // The operators are inlined but should be exposed under grouping `rule_name` below is_inline: true, def: OnceCell::new(), }); - // NOTE: The DSL v1 model defines operators as having the same body definitions but uses a specific - // versioning mechanism. This is in contrast to the DSL v2, which allows for different body definitions and - // different versions. - // Thus, we shoehorn the v2 model into the first one, by creating a single parser definition node as - // a choice over the different versions of the operator body, but still define it multiple times in the DSL v1 - // model with an explicit version, that the codegen handles for us. + // Each precedence expression can have multiple operators with different modes and versions + // We partition them by model and then resolve each group separately + let mut operators_per_model = BTreeMap::<_, Vec<_>>::new(); for op in &expr.operators { - operators.push(( - op.enabled.clone().map(enabled_to_range).unwrap_or_default(), - model_to_enum(op.model), - // TODO: Don't leak - expr.rule_name.to_string().leak() as &_, - thunk.clone() as Rc, - )); + operators_per_model.entry(op.model).or_default().push(op); } - let defs: Vec<_> = expr - .operators - .into_iter() - .map(|op| resolve_sequence_like(op.enabled, op.fields, op.error_recovery, ctx)) - .collect(); + let mut all_operators = vec![]; + for (model, model_operators) in operators_per_model { + let defs: Vec<_> = model_operators + .into_iter() + .map(ToOwned::to_owned) + .map(|op| resolve_sequence_like(op.enabled, op.fields, op.error_recovery, ctx)) + .collect(); + + let def = match &defs[..] { + // HACK: Despite it being a single definition, we still need to wrap a versioned + // node around the choice for it to emit the version checks for the node. + [ParserDefinitionNode::Versioned(..)] => ParserDefinitionNode::Choice(defs), + [_] => defs.into_iter().next().unwrap(), + _ => ParserDefinitionNode::Choice(defs), + }; - let def = match defs.len() { - 0 => panic!("Precedence operator {name} has no definitions"), - 1 => defs.into_iter().next().unwrap(), - _ => ParserDefinitionNode::Choice(defs), - }; + all_operators.push(def.clone()); + operators.push((model_to_enum(model), leaked_name, def)); + } - thunk.def.set(def).unwrap(); + // Register the combined parser definition to appease the codegen and to mark terminals + // as reachable and ensure we emit a token kind for each + thunk + .def + .set(ParserDefinitionNode::Choice(all_operators)) + .unwrap(); assert!( !ctx.resolved.contains_key(&name), - "Encountered a duplicate Precedence Operator named {name} when resolving" + "Encountered a duplicate Precedence Expression named {name} when resolving" + ); + ctx.resolved.insert( + name.clone(), + GrammarElement::ParserDefinition(thunk.clone()), ); - ctx.resolved - .insert(name.clone(), GrammarElement::ParserDefinition(thunk)); } PrecedenceParserDefinitionNode { primary_expression, operators, + precedence_expression_names, } } diff --git a/crates/solidity/outputs/cargo/crate/src/generated/kinds.rs b/crates/solidity/outputs/cargo/crate/src/generated/kinds.rs index f87c025206..5fd9016364 100644 --- a/crates/solidity/outputs/cargo/crate/src/generated/kinds.rs +++ b/crates/solidity/outputs/cargo/crate/src/generated/kinds.rs @@ -3,209 +3,6 @@ #[cfg(feature = "slang_napi_interfaces")] use {napi::bindgen_prelude::*, napi_derive::napi}; -#[derive( - Debug, - Eq, - Ord, - PartialEq, - PartialOrd, - serde::Serialize, - strum_macros::AsRefStr, - strum_macros::Display, - strum_macros::EnumString, -)] -#[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 ProductionKind { - ABICoderPragma, - AddressType, - ArgumentsDeclaration, - ArrayExpression, - ArrayValues, - AsciiStringLiterals, - AssemblyFlags, - AssemblyFlagsDeclaration, - AssemblyStatement, - Block, - BreakStatement, - CatchClause, - CatchClauseError, - CatchClauses, - ConstantDefinition, - ConstructorAttribute, - ConstructorAttributes, - ConstructorDefinition, - ContinueStatement, - ContractDefinition, - ContractMember, - ContractMembers, - DecimalNumberExpression, - DeleteStatement, - DoWhileStatement, - ElementaryType, - ElseBranch, - EmitStatement, - EndOfFileTrivia, - EnumDefinition, - EnumMembers, - ErrorDefinition, - ErrorParameter, - ErrorParameters, - ErrorParametersDeclaration, - EventDefinition, - EventParameter, - EventParameters, - EventParametersDeclaration, - ExperimentalFeature, - ExperimentalPragma, - Expression, - ExpressionStatement, - FallbackFunctionAttribute, - FallbackFunctionAttributes, - FallbackFunctionDefinition, - ForStatement, - ForStatementCondition, - ForStatementInitialization, - FunctionAttribute, - FunctionAttributes, - FunctionBody, - FunctionCallOptions, - FunctionDefinition, - FunctionName, - FunctionType, - FunctionTypeAttribute, - FunctionTypeAttributes, - HexNumberExpression, - HexStringLiterals, - IdentifierPath, - IfStatement, - ImportAlias, - ImportClause, - ImportDeconstruction, - ImportDeconstructionSymbol, - ImportDeconstructionSymbols, - ImportDirective, - IndexAccessEnd, - InheritanceSpecifier, - InheritanceType, - InheritanceTypes, - InterfaceDefinition, - InterfaceMembers, - LeadingTrivia, - LibraryDefinition, - LibraryMembers, - MappingKey, - MappingKeyType, - MappingType, - MappingValue, - MemberAccess, - ModifierAttribute, - ModifierAttributes, - ModifierDefinition, - ModifierInvocation, - NamedArgument, - NamedArgumentGroup, - NamedArgumentGroups, - NamedArguments, - NamedArgumentsDeclaration, - NamedImport, - NewExpression, - NumberUnit, - OverridePaths, - OverridePathsDeclaration, - OverrideSpecifier, - Parameter, - Parameters, - ParametersDeclaration, - PathImport, - PositionalArguments, - PositionalArgumentsDeclaration, - Pragma, - PragmaDirective, - ReceiveFunctionAttribute, - ReceiveFunctionAttributes, - ReceiveFunctionDefinition, - ReturnStatement, - ReturnsDeclaration, - RevertStatement, - SourceUnit, - SourceUnitMember, - SourceUnitMembers, - StateVariableAttribute, - StateVariableAttributes, - StateVariableDefinition, - StateVariableDefinitionValue, - Statement, - Statements, - StorageLocation, - StringExpression, - StructDefinition, - StructMember, - StructMembers, - ThrowStatement, - TrailingTrivia, - TryStatement, - TupleDeconstructionElement, - TupleDeconstructionElements, - TupleDeconstructionStatement, - TupleExpression, - TupleMember, - TupleValue, - TupleValues, - TypeExpression, - TypeName, - TypedTupleMember, - UncheckedBlock, - UnicodeStringLiterals, - UnnamedFunctionAttribute, - UnnamedFunctionAttributes, - UnnamedFunctionDefinition, - UntypedTupleMember, - UserDefinedValueTypeDefinition, - UsingAlias, - UsingClause, - UsingDeconstruction, - UsingDeconstructionSymbol, - UsingDeconstructionSymbols, - UsingDirective, - UsingOperator, - UsingTarget, - VariableDeclarationStatement, - VariableDeclarationType, - VariableDeclarationValue, - VersionPragma, - VersionPragmaExpression, - VersionPragmaExpressions, - VersionPragmaSpecifier, - WhileStatement, - YulArguments, - YulAssignmentStatement, - YulBlock, - YulBreakStatement, - YulContinueStatement, - YulDefaultCase, - YulExpression, - YulForStatement, - YulFunctionDefinition, - YulIdentifierPath, - YulIdentifierPaths, - YulIfStatement, - YulLeaveStatement, - YulLiteral, - YulParameters, - YulParametersDeclaration, - YulReturnVariables, - YulReturnsDeclaration, - YulStatement, - YulStatements, - YulSwitchCase, - YulSwitchCases, - YulSwitchStatement, - YulValueCase, - YulVariableDeclarationStatement, - YulVariableDeclarationValue, -} - #[derive( Debug, Eq, @@ -221,7 +18,9 @@ pub enum ProductionKind { #[cfg_attr(not(feature = "slang_napi_interfaces"), derive(Clone, Copy))] pub enum RuleKind { ABICoderPragma, + AdditiveExpression, AddressType, + AndExpression, ArgumentsDeclaration, ArrayExpression, ArrayTypeName, @@ -230,12 +29,16 @@ pub enum RuleKind { AssemblyFlags, AssemblyFlagsDeclaration, AssemblyStatement, - BinaryExpression, + AssignmentExpression, + BitwiseAndExpression, + BitwiseOrExpression, + BitwiseXorExpression, Block, BreakStatement, CatchClause, CatchClauseError, CatchClauses, + ComparisonExpression, ConditionalExpression, ConstantDefinition, ConstructorAttribute, @@ -254,6 +57,7 @@ pub enum RuleKind { EndOfFileTrivia, EnumDefinition, EnumMembers, + EqualityExpression, ErrorDefinition, ErrorParameter, ErrorParameters, @@ -264,6 +68,7 @@ pub enum RuleKind { EventParametersDeclaration, ExperimentalFeature, ExperimentalPragma, + ExponentiationExpression, Expression, ExpressionStatement, FallbackFunctionAttribute, @@ -312,6 +117,7 @@ pub enum RuleKind { ModifierAttributes, ModifierDefinition, ModifierInvocation, + MultiplicativeExpression, NamedArgument, NamedArgumentGroup, NamedArgumentGroups, @@ -320,6 +126,7 @@ pub enum RuleKind { NamedImport, NewExpression, NumberUnit, + OrExpression, OverridePaths, OverridePathsDeclaration, OverrideSpecifier, @@ -329,14 +136,17 @@ pub enum RuleKind { PathImport, PositionalArguments, PositionalArgumentsDeclaration, + PostfixExpression, Pragma, PragmaDirective, + PrefixExpression, ReceiveFunctionAttribute, ReceiveFunctionAttributes, ReceiveFunctionDefinition, ReturnStatement, ReturnsDeclaration, RevertStatement, + ShiftExpression, SourceUnit, SourceUnitMember, SourceUnitMembers, @@ -364,8 +174,6 @@ pub enum RuleKind { TypeExpression, TypeName, TypedTupleMember, - UnaryPostfixExpression, - UnaryPrefixExpression, UncheckedBlock, UnicodeStringLiterals, UnnamedFunctionAttribute, @@ -385,11 +193,12 @@ pub enum RuleKind { VariableDeclarationType, VariableDeclarationValue, VersionPragma, - VersionPragmaBinaryExpression, VersionPragmaExpression, VersionPragmaExpressions, + VersionPragmaOrExpression, + VersionPragmaPrefixExpression, + VersionPragmaRangeExpression, VersionPragmaSpecifier, - VersionPragmaUnaryExpression, WhileStatement, YulArguments, YulAssignmentStatement, diff --git a/crates/solidity/outputs/cargo/crate/src/generated/language.rs b/crates/solidity/outputs/cargo/crate/src/generated/language.rs index f36c09558b..1467782a7d 100644 --- a/crates/solidity/outputs/cargo/crate/src/generated/language.rs +++ b/crates/solidity/outputs/cargo/crate/src/generated/language.rs @@ -17,7 +17,8 @@ pub use super::kinds::LexicalContext; #[cfg(feature = "slang_napi_interfaces")] use super::napi::napi_parse_output::ParseOutput as NAPIParseOutput; use super::{ - kinds::{IsLexicalContext, LexicalContextType, ProductionKind, RuleKind, TokenKind}, + cst, + kinds::{IsLexicalContext, LexicalContextType, RuleKind, TokenKind}, lexer::Lexer, parse_output::ParseOutput, support::{ @@ -206,6 +207,27 @@ impl Language { .with_kind(RuleKind::ABICoderPragma) } + #[allow(unused_assignments, unused_parens)] + fn additive_expression(&self, input: &mut ParserContext<'_>) -> ParserResult { + let result = self.expression(input); + let ParserResult::Match(r#match) = &result else { + return result; + }; + match &r#match.nodes[..] { + [cst::Node::Rule(node)] if node.kind == RuleKind::Expression => { + match &node.children[..] { + [inner @ cst::Node::Rule(rule)] + if rule.kind == RuleKind::AdditiveExpression => + { + ParserResult::r#match(vec![inner.clone()], r#match.expected_tokens.clone()) + } + _ => ParserResult::no_match(vec![]), + } + } + _ => ParserResult::no_match(vec![]), + } + } + #[allow(unused_assignments, unused_parens)] fn address_type(&self, input: &mut ParserContext<'_>) -> ParserResult { SequenceHelper::run(|mut seq| { @@ -224,6 +246,25 @@ impl Language { .with_kind(RuleKind::AddressType) } + #[allow(unused_assignments, unused_parens)] + fn and_expression(&self, input: &mut ParserContext<'_>) -> ParserResult { + let result = self.expression(input); + let ParserResult::Match(r#match) = &result else { + return result; + }; + match &r#match.nodes[..] { + [cst::Node::Rule(node)] if node.kind == RuleKind::Expression => { + match &node.children[..] { + [inner @ cst::Node::Rule(rule)] if rule.kind == RuleKind::AndExpression => { + ParserResult::r#match(vec![inner.clone()], r#match.expected_tokens.clone()) + } + _ => ParserResult::no_match(vec![]), + } + } + _ => ParserResult::no_match(vec![]), + } + } + #[allow(unused_assignments, unused_parens)] fn arguments_declaration(&self, input: &mut ParserContext<'_>) -> ParserResult { ChoiceHelper::run(input, |mut choice, input| { @@ -263,6 +304,25 @@ impl Language { .with_kind(RuleKind::ArrayExpression) } + #[allow(unused_assignments, unused_parens)] + fn array_type_name(&self, input: &mut ParserContext<'_>) -> ParserResult { + let result = self.type_name(input); + let ParserResult::Match(r#match) = &result else { + return result; + }; + match &r#match.nodes[..] { + [cst::Node::Rule(node)] if node.kind == RuleKind::TypeName => { + match &node.children[..] { + [inner @ cst::Node::Rule(rule)] if rule.kind == RuleKind::ArrayTypeName => { + ParserResult::r#match(vec![inner.clone()], r#match.expected_tokens.clone()) + } + _ => ParserResult::no_match(vec![]), + } + } + _ => ParserResult::no_match(vec![]), + } + } + #[allow(unused_assignments, unused_parens)] fn array_values(&self, input: &mut ParserContext<'_>) -> ParserResult { SeparatedHelper::run::<_, LexicalContextType::Default>( @@ -350,6 +410,90 @@ impl Language { .with_kind(RuleKind::AssemblyStatement) } + #[allow(unused_assignments, unused_parens)] + fn assignment_expression(&self, input: &mut ParserContext<'_>) -> ParserResult { + let result = self.expression(input); + let ParserResult::Match(r#match) = &result else { + return result; + }; + match &r#match.nodes[..] { + [cst::Node::Rule(node)] if node.kind == RuleKind::Expression => { + match &node.children[..] { + [inner @ cst::Node::Rule(rule)] + if rule.kind == RuleKind::AssignmentExpression => + { + ParserResult::r#match(vec![inner.clone()], r#match.expected_tokens.clone()) + } + _ => ParserResult::no_match(vec![]), + } + } + _ => ParserResult::no_match(vec![]), + } + } + + #[allow(unused_assignments, unused_parens)] + fn bitwise_and_expression(&self, input: &mut ParserContext<'_>) -> ParserResult { + let result = self.expression(input); + let ParserResult::Match(r#match) = &result else { + return result; + }; + match &r#match.nodes[..] { + [cst::Node::Rule(node)] if node.kind == RuleKind::Expression => { + match &node.children[..] { + [inner @ cst::Node::Rule(rule)] + if rule.kind == RuleKind::BitwiseAndExpression => + { + ParserResult::r#match(vec![inner.clone()], r#match.expected_tokens.clone()) + } + _ => ParserResult::no_match(vec![]), + } + } + _ => ParserResult::no_match(vec![]), + } + } + + #[allow(unused_assignments, unused_parens)] + fn bitwise_or_expression(&self, input: &mut ParserContext<'_>) -> ParserResult { + let result = self.expression(input); + let ParserResult::Match(r#match) = &result else { + return result; + }; + match &r#match.nodes[..] { + [cst::Node::Rule(node)] if node.kind == RuleKind::Expression => { + match &node.children[..] { + [inner @ cst::Node::Rule(rule)] + if rule.kind == RuleKind::BitwiseOrExpression => + { + ParserResult::r#match(vec![inner.clone()], r#match.expected_tokens.clone()) + } + _ => ParserResult::no_match(vec![]), + } + } + _ => ParserResult::no_match(vec![]), + } + } + + #[allow(unused_assignments, unused_parens)] + fn bitwise_xor_expression(&self, input: &mut ParserContext<'_>) -> ParserResult { + let result = self.expression(input); + let ParserResult::Match(r#match) = &result else { + return result; + }; + match &r#match.nodes[..] { + [cst::Node::Rule(node)] if node.kind == RuleKind::Expression => { + match &node.children[..] { + [inner @ cst::Node::Rule(rule)] + if rule.kind == RuleKind::BitwiseXorExpression => + { + ParserResult::r#match(vec![inner.clone()], r#match.expected_tokens.clone()) + } + _ => ParserResult::no_match(vec![]), + } + } + _ => ParserResult::no_match(vec![]), + } + } + #[allow(unused_assignments, unused_parens)] fn block(&self, input: &mut ParserContext<'_>) -> ParserResult { SequenceHelper::run(|mut seq| { @@ -448,6 +592,48 @@ impl Language { .with_kind(RuleKind::CatchClauses) } + #[allow(unused_assignments, unused_parens)] + fn comparison_expression(&self, input: &mut ParserContext<'_>) -> ParserResult { + let result = self.expression(input); + let ParserResult::Match(r#match) = &result else { + return result; + }; + match &r#match.nodes[..] { + [cst::Node::Rule(node)] if node.kind == RuleKind::Expression => { + match &node.children[..] { + [inner @ cst::Node::Rule(rule)] + if rule.kind == RuleKind::ComparisonExpression => + { + ParserResult::r#match(vec![inner.clone()], r#match.expected_tokens.clone()) + } + _ => ParserResult::no_match(vec![]), + } + } + _ => ParserResult::no_match(vec![]), + } + } + + #[allow(unused_assignments, unused_parens)] + fn conditional_expression(&self, input: &mut ParserContext<'_>) -> ParserResult { + let result = self.expression(input); + let ParserResult::Match(r#match) = &result else { + return result; + }; + match &r#match.nodes[..] { + [cst::Node::Rule(node)] if node.kind == RuleKind::Expression => { + match &node.children[..] { + [inner @ cst::Node::Rule(rule)] + if rule.kind == RuleKind::ConditionalExpression => + { + ParserResult::r#match(vec![inner.clone()], r#match.expected_tokens.clone()) + } + _ => ParserResult::no_match(vec![]), + } + } + _ => ParserResult::no_match(vec![]), + } + } + #[allow(unused_assignments, unused_parens)] fn constant_definition(&self, input: &mut ParserContext<'_>) -> ParserResult { if self.version_is_at_least_0_7_4 { @@ -948,6 +1134,27 @@ impl Language { .with_kind(RuleKind::EnumMembers) } + #[allow(unused_assignments, unused_parens)] + fn equality_expression(&self, input: &mut ParserContext<'_>) -> ParserResult { + let result = self.expression(input); + let ParserResult::Match(r#match) = &result else { + return result; + }; + match &r#match.nodes[..] { + [cst::Node::Rule(node)] if node.kind == RuleKind::Expression => { + match &node.children[..] { + [inner @ cst::Node::Rule(rule)] + if rule.kind == RuleKind::EqualityExpression => + { + ParserResult::r#match(vec![inner.clone()], r#match.expected_tokens.clone()) + } + _ => ParserResult::no_match(vec![]), + } + } + _ => ParserResult::no_match(vec![]), + } + } + #[allow(unused_assignments, unused_parens)] fn error_definition(&self, input: &mut ParserContext<'_>) -> ParserResult { if self.version_is_at_least_0_8_4 { @@ -1177,12 +1384,32 @@ impl Language { .with_kind(RuleKind::ExperimentalPragma) } + #[allow(unused_assignments, unused_parens)] + fn exponentiation_expression(&self, input: &mut ParserContext<'_>) -> ParserResult { + let result = self.expression(input); + let ParserResult::Match(r#match) = &result else { + return result; + }; + match &r#match.nodes[..] { + [cst::Node::Rule(node)] if node.kind == RuleKind::Expression => { + match &node.children[..] { + [inner @ cst::Node::Rule(rule)] + if rule.kind == RuleKind::ExponentiationExpression => + { + ParserResult::r#match(vec![inner.clone()], r#match.expected_tokens.clone()) + } + _ => ParserResult::no_match(vec![]), + } + } + _ => ParserResult::no_match(vec![]), + } + } + #[allow(unused_assignments, unused_parens)] fn expression(&self, input: &mut ParserContext<'_>) -> ParserResult { - #[allow(unused_variables)] - let parse_assignment_expression = |input: &mut ParserContext<'_>| { + let parse_left_assignment_expression = |input: &mut ParserContext<'_>| { PrecedenceHelper::to_binary_operator( - RuleKind::BinaryExpression, + RuleKind::AssignmentExpression, 1u8, 1u8 + 1, ChoiceHelper::run(input, |mut choice, input| { @@ -1250,1610 +1477,326 @@ impl Language { }), ) }; - #[allow(unused_variables)] - let parse_assignment_expression = |input: &mut ParserContext<'_>| { - PrecedenceHelper::to_binary_operator( - RuleKind::BinaryExpression, + let parse_postfix_conditional_expression = |input: &mut ParserContext<'_>| { + PrecedenceHelper::to_postfix_operator( + RuleKind::ConditionalExpression, 3u8, - 3u8 + 1, - ChoiceHelper::run(input, |mut choice, input| { - let result = self.parse_token_with_trivia::( + SequenceHelper::run(|mut seq| { + seq.elem(self.parse_token_with_trivia::( input, - TokenKind::Equal, - ); - choice.consider(input, result)?; + TokenKind::QuestionMark, + ))?; + seq.elem(self.expression(input))?; + seq.elem(self.parse_token_with_trivia::( + input, + TokenKind::Colon, + ))?; + seq.elem(self.expression(input))?; + seq.finish() + }), + ) + }; + let parse_left_or_expression = |input: &mut ParserContext<'_>| { + PrecedenceHelper::to_binary_operator( + RuleKind::OrExpression, + 5u8, + 5u8 + 1, + self.parse_token_with_trivia::( + input, + TokenKind::BarBar, + ), + ) + }; + let parse_left_and_expression = |input: &mut ParserContext<'_>| { + PrecedenceHelper::to_binary_operator( + RuleKind::AndExpression, + 7u8, + 7u8 + 1, + self.parse_token_with_trivia::( + input, + TokenKind::AmpersandAmpersand, + ), + ) + }; + let parse_left_equality_expression = |input: &mut ParserContext<'_>| { + PrecedenceHelper::to_binary_operator( + RuleKind::EqualityExpression, + 9u8, + 9u8 + 1, + ChoiceHelper::run(input, |mut choice, input| { let result = self.parse_token_with_trivia::( input, - TokenKind::BarEqual, + TokenKind::EqualEqual, ); choice.consider(input, result)?; let result = self.parse_token_with_trivia::( input, - TokenKind::PlusEqual, + TokenKind::BangEqual, ); choice.consider(input, result)?; + choice.finish(input) + }), + ) + }; + let parse_left_comparison_expression = |input: &mut ParserContext<'_>| { + PrecedenceHelper::to_binary_operator( + RuleKind::ComparisonExpression, + 11u8, + 11u8 + 1, + ChoiceHelper::run(input, |mut choice, input| { let result = self.parse_token_with_trivia::( input, - TokenKind::MinusEqual, + TokenKind::LessThan, ); choice.consider(input, result)?; let result = self.parse_token_with_trivia::( input, - TokenKind::CaretEqual, + TokenKind::GreaterThan, ); choice.consider(input, result)?; let result = self.parse_token_with_trivia::( input, - TokenKind::SlashEqual, + TokenKind::LessThanEqual, ); choice.consider(input, result)?; let result = self.parse_token_with_trivia::( input, - TokenKind::PercentEqual, + TokenKind::GreaterThanEqual, ); choice.consider(input, result)?; + choice.finish(input) + }), + ) + }; + let parse_left_bitwise_or_expression = |input: &mut ParserContext<'_>| { + PrecedenceHelper::to_binary_operator( + RuleKind::BitwiseOrExpression, + 13u8, + 13u8 + 1, + self.parse_token_with_trivia::(input, TokenKind::Bar), + ) + }; + let parse_left_bitwise_xor_expression = |input: &mut ParserContext<'_>| { + PrecedenceHelper::to_binary_operator( + RuleKind::BitwiseXorExpression, + 15u8, + 15u8 + 1, + self.parse_token_with_trivia::( + input, + TokenKind::Caret, + ), + ) + }; + let parse_left_bitwise_and_expression = |input: &mut ParserContext<'_>| { + PrecedenceHelper::to_binary_operator( + RuleKind::BitwiseAndExpression, + 17u8, + 17u8 + 1, + self.parse_token_with_trivia::( + input, + TokenKind::Ampersand, + ), + ) + }; + let parse_left_shift_expression = |input: &mut ParserContext<'_>| { + PrecedenceHelper::to_binary_operator( + RuleKind::ShiftExpression, + 19u8, + 19u8 + 1, + ChoiceHelper::run(input, |mut choice, input| { let result = self.parse_token_with_trivia::( input, - TokenKind::AsteriskEqual, + TokenKind::LessThanLessThan, ); choice.consider(input, result)?; let result = self.parse_token_with_trivia::( input, - TokenKind::AmpersandEqual, + TokenKind::GreaterThanGreaterThan, ); choice.consider(input, result)?; let result = self.parse_token_with_trivia::( input, - TokenKind::LessThanLessThanEqual, + TokenKind::GreaterThanGreaterThanGreaterThan, ); choice.consider(input, result)?; + choice.finish(input) + }), + ) + }; + let parse_left_additive_expression = |input: &mut ParserContext<'_>| { + PrecedenceHelper::to_binary_operator( + RuleKind::AdditiveExpression, + 21u8, + 21u8 + 1, + ChoiceHelper::run(input, |mut choice, input| { let result = self.parse_token_with_trivia::( input, - TokenKind::GreaterThanGreaterThanEqual, + TokenKind::Plus, ); choice.consider(input, result)?; let result = self.parse_token_with_trivia::( input, - TokenKind::GreaterThanGreaterThanGreaterThanEqual, + TokenKind::Minus, ); choice.consider(input, result)?; choice.finish(input) }), ) }; - #[allow(unused_variables)] - let parse_assignment_expression = |input: &mut ParserContext<'_>| { + let parse_left_multiplicative_expression = |input: &mut ParserContext<'_>| { PrecedenceHelper::to_binary_operator( - RuleKind::BinaryExpression, - 5u8, - 5u8 + 1, + RuleKind::MultiplicativeExpression, + 23u8, + 23u8 + 1, ChoiceHelper::run(input, |mut choice, input| { let result = self.parse_token_with_trivia::( input, - TokenKind::Equal, + TokenKind::Asterisk, ); choice.consider(input, result)?; let result = self.parse_token_with_trivia::( input, - TokenKind::BarEqual, + TokenKind::Slash, ); choice.consider(input, result)?; let result = self.parse_token_with_trivia::( input, - TokenKind::PlusEqual, + TokenKind::Percent, ); choice.consider(input, result)?; + choice.finish(input) + }), + ) + }; + let parse_left_exponentiation_expression = |input: &mut ParserContext<'_>| { + PrecedenceHelper::to_binary_operator( + RuleKind::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::( + input, + TokenKind::AsteriskAsterisk, + ); + choice.consider(input, result)?; + } + choice.finish(input) + }), + ) + }; + let parse_right_exponentiation_expression = |input: &mut ParserContext<'_>| { + PrecedenceHelper::to_binary_operator( + RuleKind::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::( + input, + TokenKind::AsteriskAsterisk, + ); + choice.consider(input, result)?; + } + choice.finish(input) + }), + ) + }; + let parse_postfix_postfix_expression = |input: &mut ParserContext<'_>| { + PrecedenceHelper::to_postfix_operator( + RuleKind::PostfixExpression, + 29u8, + ChoiceHelper::run(input, |mut choice, input| { let result = self.parse_token_with_trivia::( input, - TokenKind::MinusEqual, + TokenKind::PlusPlus, ); choice.consider(input, result)?; let result = self.parse_token_with_trivia::( input, - TokenKind::CaretEqual, - ); - choice.consider(input, result)?; - let result = self.parse_token_with_trivia::( - input, - TokenKind::SlashEqual, - ); - choice.consider(input, result)?; - let result = self.parse_token_with_trivia::( - input, - TokenKind::PercentEqual, - ); - choice.consider(input, result)?; - let result = self.parse_token_with_trivia::( - input, - TokenKind::AsteriskEqual, - ); - choice.consider(input, result)?; - let result = self.parse_token_with_trivia::( - input, - TokenKind::AmpersandEqual, - ); - choice.consider(input, result)?; - let result = self.parse_token_with_trivia::( - input, - TokenKind::LessThanLessThanEqual, - ); - choice.consider(input, result)?; - let result = self.parse_token_with_trivia::( - input, - TokenKind::GreaterThanGreaterThanEqual, - ); - choice.consider(input, result)?; - let result = self.parse_token_with_trivia::( - input, - TokenKind::GreaterThanGreaterThanGreaterThanEqual, + TokenKind::MinusMinus, ); choice.consider(input, result)?; choice.finish(input) }), ) }; - #[allow(unused_variables)] - let parse_assignment_expression = |input: &mut ParserContext<'_>| { - PrecedenceHelper::to_binary_operator( - RuleKind::BinaryExpression, - 7u8, - 7u8 + 1, + let parse_prefix_prefix_expression = |input: &mut ParserContext<'_>| { + PrecedenceHelper::to_prefix_operator( + RuleKind::PrefixExpression, + 31u8, ChoiceHelper::run(input, |mut choice, input| { let result = self.parse_token_with_trivia::( input, - TokenKind::Equal, - ); - choice.consider(input, result)?; - let result = self.parse_token_with_trivia::( - input, - TokenKind::BarEqual, - ); - choice.consider(input, result)?; - let result = self.parse_token_with_trivia::( - input, - TokenKind::PlusEqual, - ); - choice.consider(input, result)?; - let result = self.parse_token_with_trivia::( - input, - TokenKind::MinusEqual, - ); - choice.consider(input, result)?; - let result = self.parse_token_with_trivia::( - input, - TokenKind::CaretEqual, - ); - choice.consider(input, result)?; - let result = self.parse_token_with_trivia::( - input, - TokenKind::SlashEqual, - ); - choice.consider(input, result)?; - let result = self.parse_token_with_trivia::( - input, - TokenKind::PercentEqual, - ); - choice.consider(input, result)?; - let result = self.parse_token_with_trivia::( - input, - TokenKind::AsteriskEqual, + TokenKind::PlusPlus, ); choice.consider(input, result)?; let result = self.parse_token_with_trivia::( input, - TokenKind::AmpersandEqual, + TokenKind::MinusMinus, ); choice.consider(input, result)?; let result = self.parse_token_with_trivia::( input, - TokenKind::LessThanLessThanEqual, + TokenKind::Tilde, ); choice.consider(input, result)?; let result = self.parse_token_with_trivia::( input, - TokenKind::GreaterThanGreaterThanEqual, + TokenKind::Bang, ); choice.consider(input, result)?; let result = self.parse_token_with_trivia::( input, - TokenKind::GreaterThanGreaterThanGreaterThanEqual, + TokenKind::Minus, ); choice.consider(input, result)?; + if !self.version_is_at_least_0_5_0 { + let result = self.parse_token_with_trivia::( + input, + TokenKind::Plus, + ); + choice.consider(input, result)?; + } choice.finish(input) }), ) }; - #[allow(unused_variables)] - let parse_assignment_expression = |input: &mut ParserContext<'_>| { - PrecedenceHelper::to_binary_operator( - RuleKind::BinaryExpression, - 9u8, - 9u8 + 1, - ChoiceHelper::run(input, |mut choice, input| { - let result = self.parse_token_with_trivia::( - input, - TokenKind::Equal, - ); - choice.consider(input, result)?; - let result = self.parse_token_with_trivia::( - input, - TokenKind::BarEqual, - ); - choice.consider(input, result)?; - let result = self.parse_token_with_trivia::( - input, - TokenKind::PlusEqual, - ); - choice.consider(input, result)?; - let result = self.parse_token_with_trivia::( - input, - TokenKind::MinusEqual, - ); - choice.consider(input, result)?; - let result = self.parse_token_with_trivia::( - input, - TokenKind::CaretEqual, - ); - choice.consider(input, result)?; - let result = self.parse_token_with_trivia::( - input, - TokenKind::SlashEqual, - ); - choice.consider(input, result)?; - let result = self.parse_token_with_trivia::( - input, - TokenKind::PercentEqual, - ); - choice.consider(input, result)?; - let result = self.parse_token_with_trivia::( - input, - TokenKind::AsteriskEqual, - ); - choice.consider(input, result)?; - let result = self.parse_token_with_trivia::( - input, - TokenKind::AmpersandEqual, - ); - choice.consider(input, result)?; - let result = self.parse_token_with_trivia::( - input, - TokenKind::LessThanLessThanEqual, - ); - choice.consider(input, result)?; - let result = self.parse_token_with_trivia::( - input, - TokenKind::GreaterThanGreaterThanEqual, - ); - choice.consider(input, result)?; - let result = self.parse_token_with_trivia::( - input, - TokenKind::GreaterThanGreaterThanGreaterThanEqual, - ); - choice.consider(input, result)?; - choice.finish(input) + let parse_postfix_function_call_expression = |input: &mut ParserContext<'_>| { + PrecedenceHelper::to_postfix_operator( + RuleKind::FunctionCallExpression, + 33u8, + SequenceHelper::run(|mut seq| { + if self.version_is_at_least_0_6_2 { + seq.elem(OptionalHelper::transform(self.function_call_options(input)))?; + } + seq.elem(self.arguments_declaration(input))?; + seq.finish() }), ) }; - #[allow(unused_variables)] - let parse_assignment_expression = |input: &mut ParserContext<'_>| { - PrecedenceHelper::to_binary_operator( - RuleKind::BinaryExpression, - 11u8, - 11u8 + 1, - ChoiceHelper::run(input, |mut choice, input| { - let result = self.parse_token_with_trivia::( - input, - TokenKind::Equal, - ); - choice.consider(input, result)?; - let result = self.parse_token_with_trivia::( - input, - TokenKind::BarEqual, - ); - choice.consider(input, result)?; - let result = self.parse_token_with_trivia::( - input, - TokenKind::PlusEqual, - ); - choice.consider(input, result)?; - let result = self.parse_token_with_trivia::( - input, - TokenKind::MinusEqual, - ); - choice.consider(input, result)?; - let result = self.parse_token_with_trivia::( - input, - TokenKind::CaretEqual, - ); - choice.consider(input, result)?; - let result = self.parse_token_with_trivia::( - input, - TokenKind::SlashEqual, - ); - choice.consider(input, result)?; - let result = self.parse_token_with_trivia::( - input, - TokenKind::PercentEqual, - ); - choice.consider(input, result)?; - let result = self.parse_token_with_trivia::( - input, - TokenKind::AsteriskEqual, - ); - choice.consider(input, result)?; - let result = self.parse_token_with_trivia::( - input, - TokenKind::AmpersandEqual, - ); - choice.consider(input, result)?; - let result = self.parse_token_with_trivia::( - input, - TokenKind::LessThanLessThanEqual, - ); - choice.consider(input, result)?; - let result = self.parse_token_with_trivia::( - input, - TokenKind::GreaterThanGreaterThanEqual, - ); - choice.consider(input, result)?; - let result = self.parse_token_with_trivia::( + let parse_postfix_member_access_expression = |input: &mut ParserContext<'_>| { + PrecedenceHelper::to_postfix_operator( + RuleKind::MemberAccessExpression, + 35u8, + SequenceHelper::run(|mut seq| { + seq.elem(self.parse_token_with_trivia::( input, - TokenKind::GreaterThanGreaterThanGreaterThanEqual, - ); - choice.consider(input, result)?; - choice.finish(input) + TokenKind::Period, + ))?; + seq.elem(self.member_access(input))?; + seq.finish() }), ) }; - #[allow(unused_variables)] - let parse_assignment_expression = |input: &mut ParserContext<'_>| { - PrecedenceHelper::to_binary_operator( - RuleKind::BinaryExpression, - 13u8, - 13u8 + 1, - ChoiceHelper::run(input, |mut choice, input| { - let result = self.parse_token_with_trivia::( - input, - TokenKind::Equal, - ); - choice.consider(input, result)?; - let result = self.parse_token_with_trivia::( - input, - TokenKind::BarEqual, - ); - choice.consider(input, result)?; - let result = self.parse_token_with_trivia::( - input, - TokenKind::PlusEqual, - ); - choice.consider(input, result)?; - let result = self.parse_token_with_trivia::( - input, - TokenKind::MinusEqual, - ); - choice.consider(input, result)?; - let result = self.parse_token_with_trivia::( - input, - TokenKind::CaretEqual, - ); - choice.consider(input, result)?; - let result = self.parse_token_with_trivia::( - input, - TokenKind::SlashEqual, - ); - choice.consider(input, result)?; - let result = self.parse_token_with_trivia::( - input, - TokenKind::PercentEqual, - ); - choice.consider(input, result)?; - let result = self.parse_token_with_trivia::( - input, - TokenKind::AsteriskEqual, - ); - choice.consider(input, result)?; - let result = self.parse_token_with_trivia::( - input, - TokenKind::AmpersandEqual, - ); - choice.consider(input, result)?; - let result = self.parse_token_with_trivia::( - input, - TokenKind::LessThanLessThanEqual, - ); - choice.consider(input, result)?; - let result = self.parse_token_with_trivia::( - input, - TokenKind::GreaterThanGreaterThanEqual, - ); - choice.consider(input, result)?; - let result = self.parse_token_with_trivia::( - input, - TokenKind::GreaterThanGreaterThanGreaterThanEqual, - ); - choice.consider(input, result)?; - choice.finish(input) - }), - ) - }; - #[allow(unused_variables)] - let parse_assignment_expression = |input: &mut ParserContext<'_>| { - PrecedenceHelper::to_binary_operator( - RuleKind::BinaryExpression, - 15u8, - 15u8 + 1, - ChoiceHelper::run(input, |mut choice, input| { - let result = self.parse_token_with_trivia::( - input, - TokenKind::Equal, - ); - choice.consider(input, result)?; - let result = self.parse_token_with_trivia::( - input, - TokenKind::BarEqual, - ); - choice.consider(input, result)?; - let result = self.parse_token_with_trivia::( - input, - TokenKind::PlusEqual, - ); - choice.consider(input, result)?; - let result = self.parse_token_with_trivia::( - input, - TokenKind::MinusEqual, - ); - choice.consider(input, result)?; - let result = self.parse_token_with_trivia::( - input, - TokenKind::CaretEqual, - ); - choice.consider(input, result)?; - let result = self.parse_token_with_trivia::( - input, - TokenKind::SlashEqual, - ); - choice.consider(input, result)?; - let result = self.parse_token_with_trivia::( - input, - TokenKind::PercentEqual, - ); - choice.consider(input, result)?; - let result = self.parse_token_with_trivia::( - input, - TokenKind::AsteriskEqual, - ); - choice.consider(input, result)?; - let result = self.parse_token_with_trivia::( - input, - TokenKind::AmpersandEqual, - ); - choice.consider(input, result)?; - let result = self.parse_token_with_trivia::( - input, - TokenKind::LessThanLessThanEqual, - ); - choice.consider(input, result)?; - let result = self.parse_token_with_trivia::( - input, - TokenKind::GreaterThanGreaterThanEqual, - ); - choice.consider(input, result)?; - let result = self.parse_token_with_trivia::( - input, - TokenKind::GreaterThanGreaterThanGreaterThanEqual, - ); - choice.consider(input, result)?; - choice.finish(input) - }), - ) - }; - #[allow(unused_variables)] - let parse_assignment_expression = |input: &mut ParserContext<'_>| { - PrecedenceHelper::to_binary_operator( - RuleKind::BinaryExpression, - 17u8, - 17u8 + 1, - ChoiceHelper::run(input, |mut choice, input| { - let result = self.parse_token_with_trivia::( - input, - TokenKind::Equal, - ); - choice.consider(input, result)?; - let result = self.parse_token_with_trivia::( - input, - TokenKind::BarEqual, - ); - choice.consider(input, result)?; - let result = self.parse_token_with_trivia::( - input, - TokenKind::PlusEqual, - ); - choice.consider(input, result)?; - let result = self.parse_token_with_trivia::( - input, - TokenKind::MinusEqual, - ); - choice.consider(input, result)?; - let result = self.parse_token_with_trivia::( - input, - TokenKind::CaretEqual, - ); - choice.consider(input, result)?; - let result = self.parse_token_with_trivia::( - input, - TokenKind::SlashEqual, - ); - choice.consider(input, result)?; - let result = self.parse_token_with_trivia::( - input, - TokenKind::PercentEqual, - ); - choice.consider(input, result)?; - let result = self.parse_token_with_trivia::( - input, - TokenKind::AsteriskEqual, - ); - choice.consider(input, result)?; - let result = self.parse_token_with_trivia::( - input, - TokenKind::AmpersandEqual, - ); - choice.consider(input, result)?; - let result = self.parse_token_with_trivia::( - input, - TokenKind::LessThanLessThanEqual, - ); - choice.consider(input, result)?; - let result = self.parse_token_with_trivia::( - input, - TokenKind::GreaterThanGreaterThanEqual, - ); - choice.consider(input, result)?; - let result = self.parse_token_with_trivia::( - input, - TokenKind::GreaterThanGreaterThanGreaterThanEqual, - ); - choice.consider(input, result)?; - choice.finish(input) - }), - ) - }; - #[allow(unused_variables)] - let parse_assignment_expression = |input: &mut ParserContext<'_>| { - PrecedenceHelper::to_binary_operator( - RuleKind::BinaryExpression, - 19u8, - 19u8 + 1, - ChoiceHelper::run(input, |mut choice, input| { - let result = self.parse_token_with_trivia::( - input, - TokenKind::Equal, - ); - choice.consider(input, result)?; - let result = self.parse_token_with_trivia::( - input, - TokenKind::BarEqual, - ); - choice.consider(input, result)?; - let result = self.parse_token_with_trivia::( - input, - TokenKind::PlusEqual, - ); - choice.consider(input, result)?; - let result = self.parse_token_with_trivia::( - input, - TokenKind::MinusEqual, - ); - choice.consider(input, result)?; - let result = self.parse_token_with_trivia::( - input, - TokenKind::CaretEqual, - ); - choice.consider(input, result)?; - let result = self.parse_token_with_trivia::( - input, - TokenKind::SlashEqual, - ); - choice.consider(input, result)?; - let result = self.parse_token_with_trivia::( - input, - TokenKind::PercentEqual, - ); - choice.consider(input, result)?; - let result = self.parse_token_with_trivia::( - input, - TokenKind::AsteriskEqual, - ); - choice.consider(input, result)?; - let result = self.parse_token_with_trivia::( - input, - TokenKind::AmpersandEqual, - ); - choice.consider(input, result)?; - let result = self.parse_token_with_trivia::( - input, - TokenKind::LessThanLessThanEqual, - ); - choice.consider(input, result)?; - let result = self.parse_token_with_trivia::( - input, - TokenKind::GreaterThanGreaterThanEqual, - ); - choice.consider(input, result)?; - let result = self.parse_token_with_trivia::( - input, - TokenKind::GreaterThanGreaterThanGreaterThanEqual, - ); - choice.consider(input, result)?; - choice.finish(input) - }), - ) - }; - #[allow(unused_variables)] - let parse_assignment_expression = |input: &mut ParserContext<'_>| { - PrecedenceHelper::to_binary_operator( - RuleKind::BinaryExpression, - 21u8, - 21u8 + 1, - ChoiceHelper::run(input, |mut choice, input| { - let result = self.parse_token_with_trivia::( - input, - TokenKind::Equal, - ); - choice.consider(input, result)?; - let result = self.parse_token_with_trivia::( - input, - TokenKind::BarEqual, - ); - choice.consider(input, result)?; - let result = self.parse_token_with_trivia::( - input, - TokenKind::PlusEqual, - ); - choice.consider(input, result)?; - let result = self.parse_token_with_trivia::( - input, - TokenKind::MinusEqual, - ); - choice.consider(input, result)?; - let result = self.parse_token_with_trivia::( - input, - TokenKind::CaretEqual, - ); - choice.consider(input, result)?; - let result = self.parse_token_with_trivia::( - input, - TokenKind::SlashEqual, - ); - choice.consider(input, result)?; - let result = self.parse_token_with_trivia::( - input, - TokenKind::PercentEqual, - ); - choice.consider(input, result)?; - let result = self.parse_token_with_trivia::( - input, - TokenKind::AsteriskEqual, - ); - choice.consider(input, result)?; - let result = self.parse_token_with_trivia::( - input, - TokenKind::AmpersandEqual, - ); - choice.consider(input, result)?; - let result = self.parse_token_with_trivia::( - input, - TokenKind::LessThanLessThanEqual, - ); - choice.consider(input, result)?; - let result = self.parse_token_with_trivia::( - input, - TokenKind::GreaterThanGreaterThanEqual, - ); - choice.consider(input, result)?; - let result = self.parse_token_with_trivia::( - input, - TokenKind::GreaterThanGreaterThanGreaterThanEqual, - ); - choice.consider(input, result)?; - choice.finish(input) - }), - ) - }; - #[allow(unused_variables)] - let parse_assignment_expression = |input: &mut ParserContext<'_>| { - PrecedenceHelper::to_binary_operator( - RuleKind::BinaryExpression, - 23u8, - 23u8 + 1, - ChoiceHelper::run(input, |mut choice, input| { - let result = self.parse_token_with_trivia::( - input, - TokenKind::Equal, - ); - choice.consider(input, result)?; - let result = self.parse_token_with_trivia::( - input, - TokenKind::BarEqual, - ); - choice.consider(input, result)?; - let result = self.parse_token_with_trivia::( - input, - TokenKind::PlusEqual, - ); - choice.consider(input, result)?; - let result = self.parse_token_with_trivia::( - input, - TokenKind::MinusEqual, - ); - choice.consider(input, result)?; - let result = self.parse_token_with_trivia::( - input, - TokenKind::CaretEqual, - ); - choice.consider(input, result)?; - let result = self.parse_token_with_trivia::( - input, - TokenKind::SlashEqual, - ); - choice.consider(input, result)?; - let result = self.parse_token_with_trivia::( - input, - TokenKind::PercentEqual, - ); - choice.consider(input, result)?; - let result = self.parse_token_with_trivia::( - input, - TokenKind::AsteriskEqual, - ); - choice.consider(input, result)?; - let result = self.parse_token_with_trivia::( - input, - TokenKind::AmpersandEqual, - ); - choice.consider(input, result)?; - let result = self.parse_token_with_trivia::( - input, - TokenKind::LessThanLessThanEqual, - ); - choice.consider(input, result)?; - let result = self.parse_token_with_trivia::( - input, - TokenKind::GreaterThanGreaterThanEqual, - ); - choice.consider(input, result)?; - let result = self.parse_token_with_trivia::( - input, - TokenKind::GreaterThanGreaterThanGreaterThanEqual, - ); - choice.consider(input, result)?; - choice.finish(input) - }), - ) - }; - #[allow(unused_variables)] - let parse_conditional_expression = |input: &mut ParserContext<'_>| { - PrecedenceHelper::to_postfix_operator( - RuleKind::ConditionalExpression, - 25u8, - SequenceHelper::run(|mut seq| { - seq.elem(self.parse_token_with_trivia::( - input, - TokenKind::QuestionMark, - ))?; - seq.elem(self.expression(input))?; - seq.elem(self.parse_token_with_trivia::( - input, - TokenKind::Colon, - ))?; - seq.elem(self.expression(input))?; - seq.finish() - }), - ) - }; - #[allow(unused_variables)] - let parse_or_expression = |input: &mut ParserContext<'_>| { - PrecedenceHelper::to_binary_operator( - RuleKind::BinaryExpression, - 27u8, - 27u8 + 1, - self.parse_token_with_trivia::( - input, - TokenKind::BarBar, - ), - ) - }; - #[allow(unused_variables)] - let parse_and_expression = |input: &mut ParserContext<'_>| { - PrecedenceHelper::to_binary_operator( - RuleKind::BinaryExpression, - 29u8, - 29u8 + 1, - self.parse_token_with_trivia::( - input, - TokenKind::AmpersandAmpersand, - ), - ) - }; - #[allow(unused_variables)] - let parse_equality_expression = |input: &mut ParserContext<'_>| { - PrecedenceHelper::to_binary_operator( - RuleKind::BinaryExpression, - 31u8, - 31u8 + 1, - ChoiceHelper::run(input, |mut choice, input| { - let result = self.parse_token_with_trivia::( - input, - TokenKind::EqualEqual, - ); - choice.consider(input, result)?; - let result = self.parse_token_with_trivia::( - input, - TokenKind::BangEqual, - ); - choice.consider(input, result)?; - choice.finish(input) - }), - ) - }; - #[allow(unused_variables)] - let parse_equality_expression = |input: &mut ParserContext<'_>| { - PrecedenceHelper::to_binary_operator( - RuleKind::BinaryExpression, - 33u8, - 33u8 + 1, - ChoiceHelper::run(input, |mut choice, input| { - let result = self.parse_token_with_trivia::( - input, - TokenKind::EqualEqual, - ); - choice.consider(input, result)?; - let result = self.parse_token_with_trivia::( - input, - TokenKind::BangEqual, - ); - choice.consider(input, result)?; - choice.finish(input) - }), - ) - }; - #[allow(unused_variables)] - let parse_comparison_expression = |input: &mut ParserContext<'_>| { - PrecedenceHelper::to_binary_operator( - RuleKind::BinaryExpression, - 35u8, - 35u8 + 1, - ChoiceHelper::run(input, |mut choice, input| { - let result = self.parse_token_with_trivia::( - input, - TokenKind::LessThan, - ); - choice.consider(input, result)?; - let result = self.parse_token_with_trivia::( - input, - TokenKind::GreaterThan, - ); - choice.consider(input, result)?; - let result = self.parse_token_with_trivia::( - input, - TokenKind::LessThanEqual, - ); - choice.consider(input, result)?; - let result = self.parse_token_with_trivia::( - input, - TokenKind::GreaterThanEqual, - ); - choice.consider(input, result)?; - choice.finish(input) - }), - ) - }; - #[allow(unused_variables)] - let parse_comparison_expression = |input: &mut ParserContext<'_>| { - PrecedenceHelper::to_binary_operator( - RuleKind::BinaryExpression, - 37u8, - 37u8 + 1, - ChoiceHelper::run(input, |mut choice, input| { - let result = self.parse_token_with_trivia::( - input, - TokenKind::LessThan, - ); - choice.consider(input, result)?; - let result = self.parse_token_with_trivia::( - input, - TokenKind::GreaterThan, - ); - choice.consider(input, result)?; - let result = self.parse_token_with_trivia::( - input, - TokenKind::LessThanEqual, - ); - choice.consider(input, result)?; - let result = self.parse_token_with_trivia::( - input, - TokenKind::GreaterThanEqual, - ); - choice.consider(input, result)?; - choice.finish(input) - }), - ) - }; - #[allow(unused_variables)] - let parse_comparison_expression = |input: &mut ParserContext<'_>| { - PrecedenceHelper::to_binary_operator( - RuleKind::BinaryExpression, - 39u8, - 39u8 + 1, - ChoiceHelper::run(input, |mut choice, input| { - let result = self.parse_token_with_trivia::( - input, - TokenKind::LessThan, - ); - choice.consider(input, result)?; - let result = self.parse_token_with_trivia::( - input, - TokenKind::GreaterThan, - ); - choice.consider(input, result)?; - let result = self.parse_token_with_trivia::( - input, - TokenKind::LessThanEqual, - ); - choice.consider(input, result)?; - let result = self.parse_token_with_trivia::( - input, - TokenKind::GreaterThanEqual, - ); - choice.consider(input, result)?; - choice.finish(input) - }), - ) - }; - #[allow(unused_variables)] - let parse_comparison_expression = |input: &mut ParserContext<'_>| { - PrecedenceHelper::to_binary_operator( - RuleKind::BinaryExpression, - 41u8, - 41u8 + 1, - ChoiceHelper::run(input, |mut choice, input| { - let result = self.parse_token_with_trivia::( - input, - TokenKind::LessThan, - ); - choice.consider(input, result)?; - let result = self.parse_token_with_trivia::( - input, - TokenKind::GreaterThan, - ); - choice.consider(input, result)?; - let result = self.parse_token_with_trivia::( - input, - TokenKind::LessThanEqual, - ); - choice.consider(input, result)?; - let result = self.parse_token_with_trivia::( - input, - TokenKind::GreaterThanEqual, - ); - choice.consider(input, result)?; - choice.finish(input) - }), - ) - }; - #[allow(unused_variables)] - let parse_bitwise_or_expression = |input: &mut ParserContext<'_>| { - PrecedenceHelper::to_binary_operator( - RuleKind::BinaryExpression, - 43u8, - 43u8 + 1, - self.parse_token_with_trivia::(input, TokenKind::Bar), - ) - }; - #[allow(unused_variables)] - let parse_bitwise_xor_expression = |input: &mut ParserContext<'_>| { - PrecedenceHelper::to_binary_operator( - RuleKind::BinaryExpression, - 45u8, - 45u8 + 1, - self.parse_token_with_trivia::( - input, - TokenKind::Caret, - ), - ) - }; - #[allow(unused_variables)] - let parse_bitwise_and_expression = |input: &mut ParserContext<'_>| { - PrecedenceHelper::to_binary_operator( - RuleKind::BinaryExpression, - 47u8, - 47u8 + 1, - self.parse_token_with_trivia::( - input, - TokenKind::Ampersand, - ), - ) - }; - #[allow(unused_variables)] - let parse_shift_expression = |input: &mut ParserContext<'_>| { - PrecedenceHelper::to_binary_operator( - RuleKind::BinaryExpression, - 49u8, - 49u8 + 1, - ChoiceHelper::run(input, |mut choice, input| { - let result = self.parse_token_with_trivia::( - input, - TokenKind::LessThanLessThan, - ); - choice.consider(input, result)?; - let result = self.parse_token_with_trivia::( - input, - TokenKind::GreaterThanGreaterThan, - ); - choice.consider(input, result)?; - let result = self.parse_token_with_trivia::( - input, - TokenKind::GreaterThanGreaterThanGreaterThan, - ); - choice.consider(input, result)?; - choice.finish(input) - }), - ) - }; - #[allow(unused_variables)] - let parse_shift_expression = |input: &mut ParserContext<'_>| { - PrecedenceHelper::to_binary_operator( - RuleKind::BinaryExpression, - 51u8, - 51u8 + 1, - ChoiceHelper::run(input, |mut choice, input| { - let result = self.parse_token_with_trivia::( - input, - TokenKind::LessThanLessThan, - ); - choice.consider(input, result)?; - let result = self.parse_token_with_trivia::( - input, - TokenKind::GreaterThanGreaterThan, - ); - choice.consider(input, result)?; - let result = self.parse_token_with_trivia::( - input, - TokenKind::GreaterThanGreaterThanGreaterThan, - ); - choice.consider(input, result)?; - choice.finish(input) - }), - ) - }; - #[allow(unused_variables)] - let parse_shift_expression = |input: &mut ParserContext<'_>| { - PrecedenceHelper::to_binary_operator( - RuleKind::BinaryExpression, - 53u8, - 53u8 + 1, - ChoiceHelper::run(input, |mut choice, input| { - let result = self.parse_token_with_trivia::( - input, - TokenKind::LessThanLessThan, - ); - choice.consider(input, result)?; - let result = self.parse_token_with_trivia::( - input, - TokenKind::GreaterThanGreaterThan, - ); - choice.consider(input, result)?; - let result = self.parse_token_with_trivia::( - input, - TokenKind::GreaterThanGreaterThanGreaterThan, - ); - choice.consider(input, result)?; - choice.finish(input) - }), - ) - }; - #[allow(unused_variables)] - let parse_additive_expression = |input: &mut ParserContext<'_>| { - PrecedenceHelper::to_binary_operator( - RuleKind::BinaryExpression, - 55u8, - 55u8 + 1, - ChoiceHelper::run(input, |mut choice, input| { - let result = self.parse_token_with_trivia::( - input, - TokenKind::Plus, - ); - choice.consider(input, result)?; - let result = self.parse_token_with_trivia::( - input, - TokenKind::Minus, - ); - choice.consider(input, result)?; - choice.finish(input) - }), - ) - }; - #[allow(unused_variables)] - let parse_additive_expression = |input: &mut ParserContext<'_>| { - PrecedenceHelper::to_binary_operator( - RuleKind::BinaryExpression, - 57u8, - 57u8 + 1, - ChoiceHelper::run(input, |mut choice, input| { - let result = self.parse_token_with_trivia::( - input, - TokenKind::Plus, - ); - choice.consider(input, result)?; - let result = self.parse_token_with_trivia::( - input, - TokenKind::Minus, - ); - choice.consider(input, result)?; - choice.finish(input) - }), - ) - }; - #[allow(unused_variables)] - let parse_multiplicative_expression = |input: &mut ParserContext<'_>| { - PrecedenceHelper::to_binary_operator( - RuleKind::BinaryExpression, - 59u8, - 59u8 + 1, - ChoiceHelper::run(input, |mut choice, input| { - let result = self.parse_token_with_trivia::( - input, - TokenKind::Asterisk, - ); - choice.consider(input, result)?; - let result = self.parse_token_with_trivia::( - input, - TokenKind::Slash, - ); - choice.consider(input, result)?; - let result = self.parse_token_with_trivia::( - input, - TokenKind::Percent, - ); - choice.consider(input, result)?; - choice.finish(input) - }), - ) - }; - #[allow(unused_variables)] - let parse_multiplicative_expression = |input: &mut ParserContext<'_>| { - PrecedenceHelper::to_binary_operator( - RuleKind::BinaryExpression, - 61u8, - 61u8 + 1, - ChoiceHelper::run(input, |mut choice, input| { - let result = self.parse_token_with_trivia::( - input, - TokenKind::Asterisk, - ); - choice.consider(input, result)?; - let result = self.parse_token_with_trivia::( - input, - TokenKind::Slash, - ); - choice.consider(input, result)?; - let result = self.parse_token_with_trivia::( - input, - TokenKind::Percent, - ); - choice.consider(input, result)?; - choice.finish(input) - }), - ) - }; - #[allow(unused_variables)] - let parse_multiplicative_expression = |input: &mut ParserContext<'_>| { - PrecedenceHelper::to_binary_operator( - RuleKind::BinaryExpression, - 63u8, - 63u8 + 1, - ChoiceHelper::run(input, |mut choice, input| { - let result = self.parse_token_with_trivia::( - input, - TokenKind::Asterisk, - ); - choice.consider(input, result)?; - let result = self.parse_token_with_trivia::( - input, - TokenKind::Slash, - ); - choice.consider(input, result)?; - let result = self.parse_token_with_trivia::( - input, - TokenKind::Percent, - ); - choice.consider(input, result)?; - choice.finish(input) - }), - ) - }; - #[allow(unused_variables)] - let parse_exponentiation_expression_removed_from_0_6_0 = |input: &mut ParserContext<'_>| { - PrecedenceHelper::to_binary_operator( - RuleKind::BinaryExpression, - 65u8, - 65u8 + 1, - ChoiceHelper::run(input, |mut choice, input| { - if !self.version_is_at_least_0_6_0 { - let result = self.parse_token_with_trivia::( - input, - TokenKind::AsteriskAsterisk, - ); - choice.consider(input, result)?; - } - if self.version_is_at_least_0_6_0 { - let result = self.parse_token_with_trivia::( - input, - TokenKind::AsteriskAsterisk, - ); - choice.consider(input, result)?; - } - choice.finish(input) - }), - ) - }; - #[allow(unused_variables)] - let parse_exponentiation_expression_introduced_from_0_6_0 = |input: &mut ParserContext< - '_, - >| { - PrecedenceHelper::to_binary_operator( - RuleKind::BinaryExpression, - 67u8 + 1, - 67u8, - ChoiceHelper::run(input, |mut choice, input| { - if !self.version_is_at_least_0_6_0 { - let result = self.parse_token_with_trivia::( - input, - TokenKind::AsteriskAsterisk, - ); - choice.consider(input, result)?; - } - if self.version_is_at_least_0_6_0 { - let result = self.parse_token_with_trivia::( - input, - TokenKind::AsteriskAsterisk, - ); - choice.consider(input, result)?; - } - choice.finish(input) - }), - ) - }; - #[allow(unused_variables)] - let parse_postfix_expression = |input: &mut ParserContext<'_>| { - PrecedenceHelper::to_postfix_operator( - RuleKind::UnaryPostfixExpression, - 69u8, - ChoiceHelper::run(input, |mut choice, input| { - let result = self.parse_token_with_trivia::( - input, - TokenKind::PlusPlus, - ); - choice.consider(input, result)?; - let result = self.parse_token_with_trivia::( - input, - TokenKind::MinusMinus, - ); - choice.consider(input, result)?; - choice.finish(input) - }), - ) - }; - #[allow(unused_variables)] - let parse_postfix_expression = |input: &mut ParserContext<'_>| { - PrecedenceHelper::to_postfix_operator( - RuleKind::UnaryPostfixExpression, - 71u8, - ChoiceHelper::run(input, |mut choice, input| { - let result = self.parse_token_with_trivia::( - input, - TokenKind::PlusPlus, - ); - choice.consider(input, result)?; - let result = self.parse_token_with_trivia::( - input, - TokenKind::MinusMinus, - ); - choice.consider(input, result)?; - choice.finish(input) - }), - ) - }; - #[allow(unused_variables)] - let parse_prefix_expression = |input: &mut ParserContext<'_>| { - PrecedenceHelper::to_prefix_operator( - RuleKind::UnaryPrefixExpression, - 73u8, - ChoiceHelper::run(input, |mut choice, input| { - let result = self.parse_token_with_trivia::( - input, - TokenKind::PlusPlus, - ); - choice.consider(input, result)?; - let result = self.parse_token_with_trivia::( - input, - TokenKind::MinusMinus, - ); - choice.consider(input, result)?; - let result = self.parse_token_with_trivia::( - input, - TokenKind::Tilde, - ); - choice.consider(input, result)?; - let result = self.parse_token_with_trivia::( - input, - TokenKind::Bang, - ); - choice.consider(input, result)?; - let result = self.parse_token_with_trivia::( - input, - TokenKind::Minus, - ); - choice.consider(input, result)?; - if !self.version_is_at_least_0_5_0 { - let result = self.parse_token_with_trivia::( - input, - TokenKind::Plus, - ); - choice.consider(input, result)?; - } - choice.finish(input) - }), - ) - }; - #[allow(unused_variables)] - let parse_prefix_expression = |input: &mut ParserContext<'_>| { - PrecedenceHelper::to_prefix_operator( - RuleKind::UnaryPrefixExpression, - 75u8, - ChoiceHelper::run(input, |mut choice, input| { - let result = self.parse_token_with_trivia::( - input, - TokenKind::PlusPlus, - ); - choice.consider(input, result)?; - let result = self.parse_token_with_trivia::( - input, - TokenKind::MinusMinus, - ); - choice.consider(input, result)?; - let result = self.parse_token_with_trivia::( - input, - TokenKind::Tilde, - ); - choice.consider(input, result)?; - let result = self.parse_token_with_trivia::( - input, - TokenKind::Bang, - ); - choice.consider(input, result)?; - let result = self.parse_token_with_trivia::( - input, - TokenKind::Minus, - ); - choice.consider(input, result)?; - if !self.version_is_at_least_0_5_0 { - let result = self.parse_token_with_trivia::( - input, - TokenKind::Plus, - ); - choice.consider(input, result)?; - } - choice.finish(input) - }), - ) - }; - #[allow(unused_variables)] - let parse_prefix_expression = |input: &mut ParserContext<'_>| { - PrecedenceHelper::to_prefix_operator( - RuleKind::UnaryPrefixExpression, - 77u8, - ChoiceHelper::run(input, |mut choice, input| { - let result = self.parse_token_with_trivia::( - input, - TokenKind::PlusPlus, - ); - choice.consider(input, result)?; - let result = self.parse_token_with_trivia::( - input, - TokenKind::MinusMinus, - ); - choice.consider(input, result)?; - let result = self.parse_token_with_trivia::( - input, - TokenKind::Tilde, - ); - choice.consider(input, result)?; - let result = self.parse_token_with_trivia::( - input, - TokenKind::Bang, - ); - choice.consider(input, result)?; - let result = self.parse_token_with_trivia::( - input, - TokenKind::Minus, - ); - choice.consider(input, result)?; - if !self.version_is_at_least_0_5_0 { - let result = self.parse_token_with_trivia::( - input, - TokenKind::Plus, - ); - choice.consider(input, result)?; - } - choice.finish(input) - }), - ) - }; - #[allow(unused_variables)] - let parse_prefix_expression = |input: &mut ParserContext<'_>| { - PrecedenceHelper::to_prefix_operator( - RuleKind::UnaryPrefixExpression, - 79u8, - ChoiceHelper::run(input, |mut choice, input| { - let result = self.parse_token_with_trivia::( - input, - TokenKind::PlusPlus, - ); - choice.consider(input, result)?; - let result = self.parse_token_with_trivia::( - input, - TokenKind::MinusMinus, - ); - choice.consider(input, result)?; - let result = self.parse_token_with_trivia::( - input, - TokenKind::Tilde, - ); - choice.consider(input, result)?; - let result = self.parse_token_with_trivia::( - input, - TokenKind::Bang, - ); - choice.consider(input, result)?; - let result = self.parse_token_with_trivia::( - input, - TokenKind::Minus, - ); - choice.consider(input, result)?; - if !self.version_is_at_least_0_5_0 { - let result = self.parse_token_with_trivia::( - input, - TokenKind::Plus, - ); - choice.consider(input, result)?; - } - choice.finish(input) - }), - ) - }; - #[allow(unused_variables)] - let parse_prefix_expression = |input: &mut ParserContext<'_>| { - PrecedenceHelper::to_prefix_operator( - RuleKind::UnaryPrefixExpression, - 81u8, - ChoiceHelper::run(input, |mut choice, input| { - let result = self.parse_token_with_trivia::( - input, - TokenKind::PlusPlus, - ); - choice.consider(input, result)?; - let result = self.parse_token_with_trivia::( - input, - TokenKind::MinusMinus, - ); - choice.consider(input, result)?; - let result = self.parse_token_with_trivia::( - input, - TokenKind::Tilde, - ); - choice.consider(input, result)?; - let result = self.parse_token_with_trivia::( - input, - TokenKind::Bang, - ); - choice.consider(input, result)?; - let result = self.parse_token_with_trivia::( - input, - TokenKind::Minus, - ); - choice.consider(input, result)?; - if !self.version_is_at_least_0_5_0 { - let result = self.parse_token_with_trivia::( - input, - TokenKind::Plus, - ); - choice.consider(input, result)?; - } - choice.finish(input) - }), - ) - }; - #[allow(unused_variables)] - let parse_prefix_expression_removed_from_0_5_0 = |input: &mut ParserContext<'_>| { - PrecedenceHelper::to_prefix_operator( - RuleKind::UnaryPrefixExpression, - 83u8, - ChoiceHelper::run(input, |mut choice, input| { - let result = self.parse_token_with_trivia::( - input, - TokenKind::PlusPlus, - ); - choice.consider(input, result)?; - let result = self.parse_token_with_trivia::( - input, - TokenKind::MinusMinus, - ); - choice.consider(input, result)?; - let result = self.parse_token_with_trivia::( - input, - TokenKind::Tilde, - ); - choice.consider(input, result)?; - let result = self.parse_token_with_trivia::( - input, - TokenKind::Bang, - ); - choice.consider(input, result)?; - let result = self.parse_token_with_trivia::( - input, - TokenKind::Minus, - ); - choice.consider(input, result)?; - if !self.version_is_at_least_0_5_0 { - let result = self.parse_token_with_trivia::( - input, - TokenKind::Plus, - ); - choice.consider(input, result)?; - } - choice.finish(input) - }), - ) - }; - #[allow(unused_variables)] - let parse_function_call_expression = |input: &mut ParserContext<'_>| { - PrecedenceHelper::to_postfix_operator( - RuleKind::FunctionCallExpression, - 85u8, - SequenceHelper::run(|mut seq| { - if self.version_is_at_least_0_6_2 { - seq.elem(OptionalHelper::transform(self.function_call_options(input)))?; - } - seq.elem(self.arguments_declaration(input))?; - seq.finish() - }), - ) - }; - #[allow(unused_variables)] - let parse_member_access_expression = |input: &mut ParserContext<'_>| { - PrecedenceHelper::to_postfix_operator( - RuleKind::MemberAccessExpression, - 87u8, - SequenceHelper::run(|mut seq| { - seq.elem(self.parse_token_with_trivia::( - input, - TokenKind::Period, - ))?; - seq.elem(self.member_access(input))?; - seq.finish() - }), - ) - }; - #[allow(unused_variables)] - let parse_index_access_expression = |input: &mut ParserContext<'_>| { - PrecedenceHelper::to_postfix_operator( - RuleKind::IndexAccessExpression, - 89u8, - SequenceHelper::run(|mut seq| { - let mut delim_guard = input.open_delim(TokenKind::CloseBracket); - let input = delim_guard.ctx(); - seq.elem(self.parse_token_with_trivia::( + let parse_postfix_index_access_expression = |input: &mut ParserContext<'_>| { + PrecedenceHelper::to_postfix_operator( + RuleKind::IndexAccessExpression, + 37u8, + SequenceHelper::run(|mut seq| { + let mut delim_guard = input.open_delim(TokenKind::CloseBracket); + let input = delim_guard.ctx(); + seq.elem(self.parse_token_with_trivia::( input, TokenKind::OpenBracket, ))?; @@ -2878,27 +1821,13 @@ impl Language { }), ) }; - #[allow(unused_variables)] let prefix_operator_parser = |input: &mut ParserContext<'_>| { ChoiceHelper::run(input, |mut choice, input| { - let result = parse_prefix_expression(input); - choice.consider(input, result)?; - let result = parse_prefix_expression(input); - choice.consider(input, result)?; - let result = parse_prefix_expression(input); + let result = parse_prefix_prefix_expression(input); choice.consider(input, result)?; - let result = parse_prefix_expression(input); - choice.consider(input, result)?; - let result = parse_prefix_expression(input); - choice.consider(input, result)?; - if !self.version_is_at_least_0_5_0 { - let result = parse_prefix_expression_removed_from_0_5_0(input); - choice.consider(input, result)?; - } choice.finish(input) }) }; - #[allow(unused_variables)] let primary_expression_parser = |input: &mut ParserContext<'_>| { ChoiceHelper::run(input, |mut choice, input| { let result = self.new_expression(input); @@ -2937,114 +1866,60 @@ impl Language { choice.finish(input) }) }; - #[allow(unused_variables)] - let postfix_operator_parser = |input: &mut ParserContext<'_>| { - ChoiceHelper::run(input, |mut choice, input| { - let result = parse_conditional_expression(input); - choice.consider(input, result)?; - let result = parse_postfix_expression(input); - choice.consider(input, result)?; - let result = parse_postfix_expression(input); - choice.consider(input, result)?; - let result = parse_function_call_expression(input); - choice.consider(input, result)?; - let result = parse_member_access_expression(input); - choice.consider(input, result)?; - let result = parse_index_access_expression(input); - choice.consider(input, result)?; - choice.finish(input) - }) - }; - #[allow(unused_variables)] - let binary_operand_parser = |input: &mut ParserContext<'_>| { - SequenceHelper::run(|mut seq| { - seq.elem(ZeroOrMoreHelper::run(input, |input| { - prefix_operator_parser(input) - }))?; - seq.elem(primary_expression_parser(input))?; - seq.elem(ZeroOrMoreHelper::run(input, |input| { - postfix_operator_parser(input) - }))?; - seq.finish() - }) - }; - #[allow(unused_variables)] - let binary_operator_parser = |input: &mut ParserContext<'_>| { - ChoiceHelper::run(input, |mut choice, input| { - let result = parse_assignment_expression(input); - choice.consider(input, result)?; - let result = parse_assignment_expression(input); - choice.consider(input, result)?; - let result = parse_assignment_expression(input); - choice.consider(input, result)?; - let result = parse_assignment_expression(input); - choice.consider(input, result)?; - let result = parse_assignment_expression(input); - choice.consider(input, result)?; - let result = parse_assignment_expression(input); - choice.consider(input, result)?; - let result = parse_assignment_expression(input); - choice.consider(input, result)?; - let result = parse_assignment_expression(input); - choice.consider(input, result)?; - let result = parse_assignment_expression(input); - choice.consider(input, result)?; - let result = parse_assignment_expression(input); - choice.consider(input, result)?; - let result = parse_assignment_expression(input); - choice.consider(input, result)?; - let result = parse_assignment_expression(input); - choice.consider(input, result)?; - let result = parse_or_expression(input); - choice.consider(input, result)?; - let result = parse_and_expression(input); + let postfix_operator_parser = |input: &mut ParserContext<'_>| { + ChoiceHelper::run(input, |mut choice, input| { + let result = parse_postfix_conditional_expression(input); choice.consider(input, result)?; - let result = parse_equality_expression(input); + let result = parse_postfix_postfix_expression(input); choice.consider(input, result)?; - let result = parse_equality_expression(input); + let result = parse_postfix_function_call_expression(input); choice.consider(input, result)?; - let result = parse_comparison_expression(input); + let result = parse_postfix_member_access_expression(input); choice.consider(input, result)?; - let result = parse_comparison_expression(input); + let result = parse_postfix_index_access_expression(input); choice.consider(input, result)?; - let result = parse_comparison_expression(input); + choice.finish(input) + }) + }; + let binary_operand_parser = |input: &mut ParserContext<'_>| { + SequenceHelper::run(|mut seq| { + seq.elem(ZeroOrMoreHelper::run(input, prefix_operator_parser))?; + seq.elem(primary_expression_parser(input))?; + seq.elem(ZeroOrMoreHelper::run(input, postfix_operator_parser))?; + seq.finish() + }) + }; + let binary_operator_parser = |input: &mut ParserContext<'_>| { + ChoiceHelper::run(input, |mut choice, input| { + let result = parse_left_assignment_expression(input); choice.consider(input, result)?; - let result = parse_comparison_expression(input); + let result = parse_left_or_expression(input); choice.consider(input, result)?; - let result = parse_bitwise_or_expression(input); + let result = parse_left_and_expression(input); choice.consider(input, result)?; - let result = parse_bitwise_xor_expression(input); + let result = parse_left_equality_expression(input); choice.consider(input, result)?; - let result = parse_bitwise_and_expression(input); + let result = parse_left_comparison_expression(input); choice.consider(input, result)?; - let result = parse_shift_expression(input); + let result = parse_left_bitwise_or_expression(input); choice.consider(input, result)?; - let result = parse_shift_expression(input); + let result = parse_left_bitwise_xor_expression(input); choice.consider(input, result)?; - let result = parse_shift_expression(input); + let result = parse_left_bitwise_and_expression(input); choice.consider(input, result)?; - let result = parse_additive_expression(input); + let result = parse_left_shift_expression(input); choice.consider(input, result)?; - let result = parse_additive_expression(input); + let result = parse_left_additive_expression(input); choice.consider(input, result)?; - let result = parse_multiplicative_expression(input); + let result = parse_left_multiplicative_expression(input); choice.consider(input, result)?; - let result = parse_multiplicative_expression(input); + let result = parse_left_exponentiation_expression(input); choice.consider(input, result)?; - let result = parse_multiplicative_expression(input); + let result = parse_right_exponentiation_expression(input); choice.consider(input, result)?; - if !self.version_is_at_least_0_6_0 { - let result = parse_exponentiation_expression_removed_from_0_6_0(input); - choice.consider(input, result)?; - } - if self.version_is_at_least_0_6_0 { - let result = parse_exponentiation_expression_introduced_from_0_6_0(input); - choice.consider(input, result)?; - } choice.finish(input) }) }; - #[allow(unused_variables)] let linear_expression_parser = |input: &mut ParserContext<'_>| { SequenceHelper::run(|mut seq| { seq.elem(binary_operand_parser(input))?; @@ -3059,7 +1934,7 @@ impl Language { }) }; PrecedenceHelper::reduce_precedence_result( - Some(RuleKind::Expression), + RuleKind::Expression, linear_expression_parser(input), ) .with_kind(RuleKind::Expression) @@ -3315,6 +2190,27 @@ impl Language { .with_kind(RuleKind::FunctionBody) } + #[allow(unused_assignments, unused_parens)] + fn function_call_expression(&self, input: &mut ParserContext<'_>) -> ParserResult { + let result = self.expression(input); + let ParserResult::Match(r#match) = &result else { + return result; + }; + match &r#match.nodes[..] { + [cst::Node::Rule(node)] if node.kind == RuleKind::Expression => { + match &node.children[..] { + [inner @ cst::Node::Rule(rule)] + if rule.kind == RuleKind::FunctionCallExpression => + { + ParserResult::r#match(vec![inner.clone()], r#match.expected_tokens.clone()) + } + _ => ParserResult::no_match(vec![]), + } + } + _ => ParserResult::no_match(vec![]), + } + } + #[allow(unused_assignments, unused_parens)] fn function_call_options(&self, input: &mut ParserContext<'_>) -> ParserResult { if self.version_is_at_least_0_6_2 { @@ -3654,6 +2550,27 @@ impl Language { .with_kind(RuleKind::IndexAccessEnd) } + #[allow(unused_assignments, unused_parens)] + fn index_access_expression(&self, input: &mut ParserContext<'_>) -> ParserResult { + let result = self.expression(input); + let ParserResult::Match(r#match) = &result else { + return result; + }; + match &r#match.nodes[..] { + [cst::Node::Rule(node)] if node.kind == RuleKind::Expression => { + match &node.children[..] { + [inner @ cst::Node::Rule(rule)] + if rule.kind == RuleKind::IndexAccessExpression => + { + ParserResult::r#match(vec![inner.clone()], r#match.expected_tokens.clone()) + } + _ => ParserResult::no_match(vec![]), + } + } + _ => ParserResult::no_match(vec![]), + } + } + #[allow(unused_assignments, unused_parens)] fn inheritance_specifier(&self, input: &mut ParserContext<'_>) -> ParserResult { SequenceHelper::run(|mut seq| { @@ -3907,6 +2824,27 @@ impl Language { .with_kind(RuleKind::MemberAccess) } + #[allow(unused_assignments, unused_parens)] + fn member_access_expression(&self, input: &mut ParserContext<'_>) -> ParserResult { + let result = self.expression(input); + let ParserResult::Match(r#match) = &result else { + return result; + }; + match &r#match.nodes[..] { + [cst::Node::Rule(node)] if node.kind == RuleKind::Expression => { + match &node.children[..] { + [inner @ cst::Node::Rule(rule)] + if rule.kind == RuleKind::MemberAccessExpression => + { + ParserResult::r#match(vec![inner.clone()], r#match.expected_tokens.clone()) + } + _ => ParserResult::no_match(vec![]), + } + } + _ => ParserResult::no_match(vec![]), + } + } + #[allow(unused_assignments, unused_parens)] fn modifier_attribute(&self, input: &mut ParserContext<'_>) -> ParserResult { ChoiceHelper::run(input, |mut choice, input| { @@ -3961,6 +2899,27 @@ impl Language { .with_kind(RuleKind::ModifierInvocation) } + #[allow(unused_assignments, unused_parens)] + fn multiplicative_expression(&self, input: &mut ParserContext<'_>) -> ParserResult { + let result = self.expression(input); + let ParserResult::Match(r#match) = &result else { + return result; + }; + match &r#match.nodes[..] { + [cst::Node::Rule(node)] if node.kind == RuleKind::Expression => { + match &node.children[..] { + [inner @ cst::Node::Rule(rule)] + if rule.kind == RuleKind::MultiplicativeExpression => + { + ParserResult::r#match(vec![inner.clone()], r#match.expected_tokens.clone()) + } + _ => ParserResult::no_match(vec![]), + } + } + _ => ParserResult::no_match(vec![]), + } + } + #[allow(unused_assignments, unused_parens)] fn named_argument(&self, input: &mut ParserContext<'_>) -> ParserResult { SequenceHelper::run(|mut seq| { @@ -4160,6 +3119,25 @@ impl Language { .with_kind(RuleKind::NumberUnit) } + #[allow(unused_assignments, unused_parens)] + fn or_expression(&self, input: &mut ParserContext<'_>) -> ParserResult { + let result = self.expression(input); + let ParserResult::Match(r#match) = &result else { + return result; + }; + match &r#match.nodes[..] { + [cst::Node::Rule(node)] if node.kind == RuleKind::Expression => { + match &node.children[..] { + [inner @ cst::Node::Rule(rule)] if rule.kind == RuleKind::OrExpression => { + ParserResult::r#match(vec![inner.clone()], r#match.expected_tokens.clone()) + } + _ => ParserResult::no_match(vec![]), + } + } + _ => ParserResult::no_match(vec![]), + } + } + #[allow(unused_assignments, unused_parens)] fn override_paths(&self, input: &mut ParserContext<'_>) -> ParserResult { SeparatedHelper::run::<_, LexicalContextType::Default>( @@ -4318,6 +3296,25 @@ impl Language { .with_kind(RuleKind::PositionalArgumentsDeclaration) } + #[allow(unused_assignments, unused_parens)] + fn postfix_expression(&self, input: &mut ParserContext<'_>) -> ParserResult { + let result = self.expression(input); + let ParserResult::Match(r#match) = &result else { + return result; + }; + match &r#match.nodes[..] { + [cst::Node::Rule(node)] if node.kind == RuleKind::Expression => { + match &node.children[..] { + [inner @ cst::Node::Rule(rule)] if rule.kind == RuleKind::PostfixExpression => { + ParserResult::r#match(vec![inner.clone()], r#match.expected_tokens.clone()) + } + _ => ParserResult::no_match(vec![]), + } + } + _ => ParserResult::no_match(vec![]), + } + } + #[allow(unused_assignments, unused_parens)] fn pragma(&self, input: &mut ParserContext<'_>) -> ParserResult { ChoiceHelper::run(input, |mut choice, input| { @@ -4360,6 +3357,25 @@ impl Language { .with_kind(RuleKind::PragmaDirective) } + #[allow(unused_assignments, unused_parens)] + fn prefix_expression(&self, input: &mut ParserContext<'_>) -> ParserResult { + let result = self.expression(input); + let ParserResult::Match(r#match) = &result else { + return result; + }; + match &r#match.nodes[..] { + [cst::Node::Rule(node)] if node.kind == RuleKind::Expression => { + match &node.children[..] { + [inner @ cst::Node::Rule(rule)] if rule.kind == RuleKind::PrefixExpression => { + ParserResult::r#match(vec![inner.clone()], r#match.expected_tokens.clone()) + } + _ => ParserResult::no_match(vec![]), + } + } + _ => ParserResult::no_match(vec![]), + } + } + #[allow(unused_assignments, unused_parens)] fn receive_function_attribute(&self, input: &mut ParserContext<'_>) -> ParserResult { if self.version_is_at_least_0_6_0 { @@ -4496,6 +3512,25 @@ impl Language { .with_kind(RuleKind::RevertStatement) } + #[allow(unused_assignments, unused_parens)] + fn shift_expression(&self, input: &mut ParserContext<'_>) -> ParserResult { + let result = self.expression(input); + let ParserResult::Match(r#match) = &result else { + return result; + }; + match &r#match.nodes[..] { + [cst::Node::Rule(node)] if node.kind == RuleKind::Expression => { + match &node.children[..] { + [inner @ cst::Node::Rule(rule)] if rule.kind == RuleKind::ShiftExpression => { + ParserResult::r#match(vec![inner.clone()], r#match.expected_tokens.clone()) + } + _ => ParserResult::no_match(vec![]), + } + } + _ => ParserResult::no_match(vec![]), + } + } + #[allow(unused_assignments, unused_parens)] fn source_unit(&self, input: &mut ParserContext<'_>) -> ParserResult { SequenceHelper::run(|mut seq| { @@ -5054,8 +4089,7 @@ impl Language { #[allow(unused_assignments, unused_parens)] fn type_name(&self, input: &mut ParserContext<'_>) -> ParserResult { - #[allow(unused_variables)] - let parse_array_type_name = |input: &mut ParserContext<'_>| { + let parse_postfix_array_type_name = |input: &mut ParserContext<'_>| { PrecedenceHelper::to_postfix_operator( RuleKind::ArrayTypeName, 1u8, @@ -5083,7 +4117,6 @@ impl Language { }), ) }; - #[allow(unused_variables)] let primary_expression_parser = |input: &mut ParserContext<'_>| { ChoiceHelper::run(input, |mut choice, input| { let result = self.function_type(input); @@ -5097,26 +4130,22 @@ impl Language { choice.finish(input) }) }; - #[allow(unused_variables)] let postfix_operator_parser = |input: &mut ParserContext<'_>| { ChoiceHelper::run(input, |mut choice, input| { - let result = parse_array_type_name(input); + let result = parse_postfix_array_type_name(input); choice.consider(input, result)?; choice.finish(input) }) }; - #[allow(unused_variables)] let linear_expression_parser = |input: &mut ParserContext<'_>| { SequenceHelper::run(|mut seq| { seq.elem(primary_expression_parser(input))?; - seq.elem(ZeroOrMoreHelper::run(input, |input| { - postfix_operator_parser(input) - }))?; + seq.elem(ZeroOrMoreHelper::run(input, postfix_operator_parser))?; seq.finish() }) }; PrecedenceHelper::reduce_precedence_result( - Some(RuleKind::TypeName), + RuleKind::TypeName, linear_expression_parser(input), ) .with_kind(RuleKind::TypeName) @@ -5413,486 +4442,213 @@ impl Language { RecoverFromNoMatch::No, ), )?; - seq.elem(self.parse_token_with_trivia::( - input, - TokenKind::Semicolon, - ))?; - seq.finish() - }) - .with_kind(RuleKind::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::( - input, - TokenKind::Ampersand, - ); - choice.consider(input, result)?; - let result = self.parse_token_with_trivia::( - input, - TokenKind::Asterisk, - ); - choice.consider(input, result)?; - let result = self.parse_token_with_trivia::( - input, - TokenKind::BangEqual, - ); - choice.consider(input, result)?; - let result = self - .parse_token_with_trivia::(input, TokenKind::Bar); - choice.consider(input, result)?; - let result = self.parse_token_with_trivia::( - input, - TokenKind::Caret, - ); - choice.consider(input, result)?; - let result = self.parse_token_with_trivia::( - input, - TokenKind::EqualEqual, - ); - choice.consider(input, result)?; - let result = self.parse_token_with_trivia::( - input, - TokenKind::GreaterThan, - ); - choice.consider(input, result)?; - let result = self.parse_token_with_trivia::( - input, - TokenKind::GreaterThanEqual, - ); - choice.consider(input, result)?; - let result = self.parse_token_with_trivia::( - input, - TokenKind::LessThan, - ); - choice.consider(input, result)?; - let result = self.parse_token_with_trivia::( - input, - TokenKind::LessThanEqual, - ); - choice.consider(input, result)?; - let result = self.parse_token_with_trivia::( - input, - TokenKind::Minus, - ); - choice.consider(input, result)?; - let result = self.parse_token_with_trivia::( - input, - TokenKind::Percent, - ); - choice.consider(input, result)?; - let result = self - .parse_token_with_trivia::(input, TokenKind::Plus); - choice.consider(input, result)?; - let result = self.parse_token_with_trivia::( - input, - TokenKind::Slash, - ); - choice.consider(input, result)?; - let result = self.parse_token_with_trivia::( - input, - TokenKind::Tilde, - ); - choice.consider(input, result)?; - choice.finish(input) - }) - } else { - ParserResult::disabled() - } - .with_kind(RuleKind::UsingOperator) - } - - #[allow(unused_assignments, unused_parens)] - fn using_target(&self, input: &mut ParserContext<'_>) -> ParserResult { - ChoiceHelper::run(input, |mut choice, input| { - let result = self.type_name(input); - choice.consider(input, result)?; - let result = self - .parse_token_with_trivia::(input, TokenKind::Asterisk); - choice.consider(input, result)?; - choice.finish(input) - }) - .with_kind(RuleKind::UsingTarget) - } - - #[allow(unused_assignments, unused_parens)] - fn variable_declaration_statement(&self, input: &mut ParserContext<'_>) -> ParserResult { - SequenceHelper::run(|mut seq| { - seq.elem( - SequenceHelper::run(|mut seq| { - seq.elem(self.variable_declaration_type(input))?; - seq.elem(OptionalHelper::transform(self.storage_location(input)))?; - seq.elem(self.parse_token_with_trivia::( - input, - TokenKind::Identifier, - ))?; - seq.elem(OptionalHelper::transform( - self.variable_declaration_value(input), - ))?; - seq.finish() - }) - .recover_until_with_nested_delims::<_, LexicalContextType::Default>( - input, - self, - TokenKind::Semicolon, - RecoverFromNoMatch::No, - ), - )?; - seq.elem(self.parse_token_with_trivia::( - input, - TokenKind::Semicolon, - ))?; - seq.finish() - }) - .with_kind(RuleKind::VariableDeclarationStatement) - } - - #[allow(unused_assignments, unused_parens)] - fn variable_declaration_type(&self, input: &mut ParserContext<'_>) -> ParserResult { - ChoiceHelper::run(input, |mut choice, input| { - 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::( - input, - TokenKind::VarKeyword, - ); - choice.consider(input, result)?; - } - choice.finish(input) - }) - .with_kind(RuleKind::VariableDeclarationType) - } - - #[allow(unused_assignments, unused_parens)] - fn variable_declaration_value(&self, input: &mut ParserContext<'_>) -> ParserResult { - SequenceHelper::run(|mut seq| { - seq.elem( - self.parse_token_with_trivia::( - input, - TokenKind::Equal, - ), - )?; - seq.elem(self.expression(input))?; - seq.finish() - }) - .with_kind(RuleKind::VariableDeclarationValue) - } - - #[allow(unused_assignments, unused_parens)] - fn version_pragma(&self, input: &mut ParserContext<'_>) -> ParserResult { - SequenceHelper::run(|mut seq| { - seq.elem(self.parse_token_with_trivia::( + seq.elem(self.parse_token_with_trivia::( input, - TokenKind::SolidityKeyword, + TokenKind::Semicolon, ))?; - seq.elem(self.version_pragma_expressions(input))?; seq.finish() }) - .with_kind(RuleKind::VersionPragma) + .with_kind(RuleKind::UsingDirective) } #[allow(unused_assignments, unused_parens)] - fn version_pragma_expression(&self, input: &mut ParserContext<'_>) -> ParserResult { - #[allow(unused_variables)] - let parse_version_pragma_or_expression = |input: &mut ParserContext<'_>| { - PrecedenceHelper::to_binary_operator( - RuleKind::VersionPragmaBinaryExpression, - 1u8, - 1u8 + 1, - self.parse_token_with_trivia::( + 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::( input, - TokenKind::BarBar, - ), - ) - }; - #[allow(unused_variables)] - let parse_version_pragma_range_expression = |input: &mut ParserContext<'_>| { - PrecedenceHelper::to_binary_operator( - RuleKind::VersionPragmaBinaryExpression, - 3u8, - 3u8 + 1, - self.parse_token_with_trivia::(input, TokenKind::Minus), - ) - }; - #[allow(unused_variables)] - let parse_version_pragma_prefix_expression = |input: &mut ParserContext<'_>| { - PrecedenceHelper::to_prefix_operator( - RuleKind::VersionPragmaUnaryExpression, - 5u8, - ChoiceHelper::run(input, |mut choice, input| { - let result = self.parse_token_with_trivia::( - input, - TokenKind::Caret, - ); - choice.consider(input, result)?; - let result = self.parse_token_with_trivia::( - input, - TokenKind::Tilde, - ); - choice.consider(input, result)?; - let result = self.parse_token_with_trivia::( - input, - TokenKind::Equal, - ); - choice.consider(input, result)?; - let result = self.parse_token_with_trivia::( - input, - TokenKind::LessThan, - ); - choice.consider(input, result)?; - let result = self.parse_token_with_trivia::( - input, - TokenKind::GreaterThan, - ); - choice.consider(input, result)?; - let result = self.parse_token_with_trivia::( - input, - TokenKind::LessThanEqual, - ); - choice.consider(input, result)?; - let result = self.parse_token_with_trivia::( - input, - TokenKind::GreaterThanEqual, - ); - choice.consider(input, result)?; - choice.finish(input) - }), - ) - }; - #[allow(unused_variables)] - let parse_version_pragma_prefix_expression = |input: &mut ParserContext<'_>| { - PrecedenceHelper::to_prefix_operator( - RuleKind::VersionPragmaUnaryExpression, - 7u8, - ChoiceHelper::run(input, |mut choice, input| { - let result = self.parse_token_with_trivia::( - input, - TokenKind::Caret, - ); - choice.consider(input, result)?; - let result = self.parse_token_with_trivia::( - input, - TokenKind::Tilde, - ); - choice.consider(input, result)?; - let result = self.parse_token_with_trivia::( - input, - TokenKind::Equal, - ); - choice.consider(input, result)?; - let result = self.parse_token_with_trivia::( - input, - TokenKind::LessThan, - ); - choice.consider(input, result)?; - let result = self.parse_token_with_trivia::( - input, - TokenKind::GreaterThan, - ); - choice.consider(input, result)?; - let result = self.parse_token_with_trivia::( - input, - TokenKind::LessThanEqual, - ); - choice.consider(input, result)?; - let result = self.parse_token_with_trivia::( - input, - TokenKind::GreaterThanEqual, - ); - choice.consider(input, result)?; - choice.finish(input) - }), - ) - }; - #[allow(unused_variables)] - let parse_version_pragma_prefix_expression = |input: &mut ParserContext<'_>| { - PrecedenceHelper::to_prefix_operator( - RuleKind::VersionPragmaUnaryExpression, - 9u8, - ChoiceHelper::run(input, |mut choice, input| { - let result = self.parse_token_with_trivia::( - input, - TokenKind::Caret, - ); - choice.consider(input, result)?; - let result = self.parse_token_with_trivia::( - input, - TokenKind::Tilde, - ); - choice.consider(input, result)?; - let result = self.parse_token_with_trivia::( - input, - TokenKind::Equal, - ); - choice.consider(input, result)?; - let result = self.parse_token_with_trivia::( - input, - TokenKind::LessThan, - ); - choice.consider(input, result)?; - let result = self.parse_token_with_trivia::( - input, - TokenKind::GreaterThan, - ); - choice.consider(input, result)?; - let result = self.parse_token_with_trivia::( - input, - TokenKind::LessThanEqual, - ); - choice.consider(input, result)?; - let result = self.parse_token_with_trivia::( - input, - TokenKind::GreaterThanEqual, - ); - choice.consider(input, result)?; - choice.finish(input) - }), - ) - }; - #[allow(unused_variables)] - let parse_version_pragma_prefix_expression = |input: &mut ParserContext<'_>| { - PrecedenceHelper::to_prefix_operator( - RuleKind::VersionPragmaUnaryExpression, - 11u8, - ChoiceHelper::run(input, |mut choice, input| { - let result = self.parse_token_with_trivia::( - input, - TokenKind::Caret, - ); - choice.consider(input, result)?; - let result = self.parse_token_with_trivia::( - input, - TokenKind::Tilde, - ); - choice.consider(input, result)?; - let result = self.parse_token_with_trivia::( - input, - TokenKind::Equal, - ); - choice.consider(input, result)?; - let result = self.parse_token_with_trivia::( - input, - TokenKind::LessThan, - ); - choice.consider(input, result)?; - let result = self.parse_token_with_trivia::( - input, - TokenKind::GreaterThan, - ); - choice.consider(input, result)?; - let result = self.parse_token_with_trivia::( - input, - TokenKind::LessThanEqual, - ); - choice.consider(input, result)?; - let result = self.parse_token_with_trivia::( - input, - TokenKind::GreaterThanEqual, - ); - choice.consider(input, result)?; - choice.finish(input) - }), - ) - }; - #[allow(unused_variables)] - let parse_version_pragma_prefix_expression = |input: &mut ParserContext<'_>| { - PrecedenceHelper::to_prefix_operator( - RuleKind::VersionPragmaUnaryExpression, - 13u8, - ChoiceHelper::run(input, |mut choice, input| { - let result = self.parse_token_with_trivia::( - input, - TokenKind::Caret, - ); - choice.consider(input, result)?; - let result = self.parse_token_with_trivia::( - input, - TokenKind::Tilde, - ); - choice.consider(input, result)?; - let result = self.parse_token_with_trivia::( - input, - TokenKind::Equal, - ); - choice.consider(input, result)?; - let result = self.parse_token_with_trivia::( - input, - TokenKind::LessThan, - ); - choice.consider(input, result)?; - let result = self.parse_token_with_trivia::( - input, - TokenKind::GreaterThan, - ); - choice.consider(input, result)?; - let result = self.parse_token_with_trivia::( - input, - TokenKind::LessThanEqual, - ); - choice.consider(input, result)?; - let result = self.parse_token_with_trivia::( + TokenKind::Ampersand, + ); + choice.consider(input, result)?; + let result = self.parse_token_with_trivia::( + input, + TokenKind::Asterisk, + ); + choice.consider(input, result)?; + let result = self.parse_token_with_trivia::( + input, + TokenKind::BangEqual, + ); + choice.consider(input, result)?; + let result = self + .parse_token_with_trivia::(input, TokenKind::Bar); + choice.consider(input, result)?; + let result = self.parse_token_with_trivia::( + input, + TokenKind::Caret, + ); + choice.consider(input, result)?; + let result = self.parse_token_with_trivia::( + input, + TokenKind::EqualEqual, + ); + choice.consider(input, result)?; + let result = self.parse_token_with_trivia::( + input, + TokenKind::GreaterThan, + ); + choice.consider(input, result)?; + let result = self.parse_token_with_trivia::( + input, + TokenKind::GreaterThanEqual, + ); + choice.consider(input, result)?; + let result = self.parse_token_with_trivia::( + input, + TokenKind::LessThan, + ); + choice.consider(input, result)?; + let result = self.parse_token_with_trivia::( + input, + TokenKind::LessThanEqual, + ); + choice.consider(input, result)?; + let result = self.parse_token_with_trivia::( + input, + TokenKind::Minus, + ); + choice.consider(input, result)?; + let result = self.parse_token_with_trivia::( + input, + TokenKind::Percent, + ); + choice.consider(input, result)?; + let result = self + .parse_token_with_trivia::(input, TokenKind::Plus); + choice.consider(input, result)?; + let result = self.parse_token_with_trivia::( + input, + TokenKind::Slash, + ); + choice.consider(input, result)?; + let result = self.parse_token_with_trivia::( + input, + TokenKind::Tilde, + ); + choice.consider(input, result)?; + choice.finish(input) + }) + } else { + ParserResult::disabled() + } + .with_kind(RuleKind::UsingOperator) + } + + #[allow(unused_assignments, unused_parens)] + fn using_target(&self, input: &mut ParserContext<'_>) -> ParserResult { + ChoiceHelper::run(input, |mut choice, input| { + let result = self.type_name(input); + choice.consider(input, result)?; + let result = self + .parse_token_with_trivia::(input, TokenKind::Asterisk); + choice.consider(input, result)?; + choice.finish(input) + }) + .with_kind(RuleKind::UsingTarget) + } + + #[allow(unused_assignments, unused_parens)] + fn variable_declaration_statement(&self, input: &mut ParserContext<'_>) -> ParserResult { + SequenceHelper::run(|mut seq| { + seq.elem( + SequenceHelper::run(|mut seq| { + seq.elem(self.variable_declaration_type(input))?; + seq.elem(OptionalHelper::transform(self.storage_location(input)))?; + seq.elem(self.parse_token_with_trivia::( input, - TokenKind::GreaterThanEqual, - ); - choice.consider(input, result)?; - choice.finish(input) - }), + TokenKind::Identifier, + ))?; + seq.elem(OptionalHelper::transform( + self.variable_declaration_value(input), + ))?; + seq.finish() + }) + .recover_until_with_nested_delims::<_, LexicalContextType::Default>( + input, + self, + TokenKind::Semicolon, + RecoverFromNoMatch::No, + ), + )?; + seq.elem(self.parse_token_with_trivia::( + input, + TokenKind::Semicolon, + ))?; + seq.finish() + }) + .with_kind(RuleKind::VariableDeclarationStatement) + } + + #[allow(unused_assignments, unused_parens)] + fn variable_declaration_type(&self, input: &mut ParserContext<'_>) -> ParserResult { + ChoiceHelper::run(input, |mut choice, input| { + 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::( + input, + TokenKind::VarKeyword, + ); + choice.consider(input, result)?; + } + choice.finish(input) + }) + .with_kind(RuleKind::VariableDeclarationType) + } + + #[allow(unused_assignments, unused_parens)] + fn variable_declaration_value(&self, input: &mut ParserContext<'_>) -> ParserResult { + SequenceHelper::run(|mut seq| { + seq.elem( + self.parse_token_with_trivia::( + input, + TokenKind::Equal, + ), + )?; + seq.elem(self.expression(input))?; + seq.finish() + }) + .with_kind(RuleKind::VariableDeclarationValue) + } + + #[allow(unused_assignments, unused_parens)] + fn version_pragma(&self, input: &mut ParserContext<'_>) -> ParserResult { + SequenceHelper::run(|mut seq| { + seq.elem(self.parse_token_with_trivia::( + input, + TokenKind::SolidityKeyword, + ))?; + seq.elem(self.version_pragma_expressions(input))?; + seq.finish() + }) + .with_kind(RuleKind::VersionPragma) + } + + #[allow(unused_assignments, unused_parens)] + fn version_pragma_expression(&self, input: &mut ParserContext<'_>) -> ParserResult { + let parse_left_version_pragma_or_expression = |input: &mut ParserContext<'_>| { + PrecedenceHelper::to_binary_operator( + RuleKind::VersionPragmaOrExpression, + 1u8, + 1u8 + 1, + self.parse_token_with_trivia::( + input, + TokenKind::BarBar, + ), ) }; - #[allow(unused_variables)] - let parse_version_pragma_prefix_expression = |input: &mut ParserContext<'_>| { - PrecedenceHelper::to_prefix_operator( - RuleKind::VersionPragmaUnaryExpression, - 15u8, - ChoiceHelper::run(input, |mut choice, input| { - let result = self.parse_token_with_trivia::( - input, - TokenKind::Caret, - ); - choice.consider(input, result)?; - let result = self.parse_token_with_trivia::( - input, - TokenKind::Tilde, - ); - choice.consider(input, result)?; - let result = self.parse_token_with_trivia::( - input, - TokenKind::Equal, - ); - choice.consider(input, result)?; - let result = self.parse_token_with_trivia::( - input, - TokenKind::LessThan, - ); - choice.consider(input, result)?; - let result = self.parse_token_with_trivia::( - input, - TokenKind::GreaterThan, - ); - choice.consider(input, result)?; - let result = self.parse_token_with_trivia::( - input, - TokenKind::LessThanEqual, - ); - choice.consider(input, result)?; - let result = self.parse_token_with_trivia::( - input, - TokenKind::GreaterThanEqual, - ); - choice.consider(input, result)?; - choice.finish(input) - }), + let parse_left_version_pragma_range_expression = |input: &mut ParserContext<'_>| { + PrecedenceHelper::to_binary_operator( + RuleKind::VersionPragmaRangeExpression, + 3u8, + 3u8 + 1, + self.parse_token_with_trivia::(input, TokenKind::Minus), ) }; - #[allow(unused_variables)] - let parse_version_pragma_prefix_expression = |input: &mut ParserContext<'_>| { + let parse_prefix_version_pragma_prefix_expression = |input: &mut ParserContext<'_>| { PrecedenceHelper::to_prefix_operator( - RuleKind::VersionPragmaUnaryExpression, - 17u8, + RuleKind::VersionPragmaPrefixExpression, + 5u8, ChoiceHelper::run(input, |mut choice, input| { let result = self.parse_token_with_trivia::( input, @@ -5933,50 +4689,31 @@ impl Language { }), ) }; - #[allow(unused_variables)] let prefix_operator_parser = |input: &mut ParserContext<'_>| { ChoiceHelper::run(input, |mut choice, input| { - let result = parse_version_pragma_prefix_expression(input); - choice.consider(input, result)?; - let result = parse_version_pragma_prefix_expression(input); - choice.consider(input, result)?; - let result = parse_version_pragma_prefix_expression(input); - choice.consider(input, result)?; - let result = parse_version_pragma_prefix_expression(input); - choice.consider(input, result)?; - let result = parse_version_pragma_prefix_expression(input); - choice.consider(input, result)?; - let result = parse_version_pragma_prefix_expression(input); - choice.consider(input, result)?; - let result = parse_version_pragma_prefix_expression(input); + let result = parse_prefix_version_pragma_prefix_expression(input); choice.consider(input, result)?; choice.finish(input) }) }; - #[allow(unused_variables)] let primary_expression_parser = |input: &mut ParserContext<'_>| self.version_pragma_specifier(input); - #[allow(unused_variables)] let binary_operand_parser = |input: &mut ParserContext<'_>| { SequenceHelper::run(|mut seq| { - seq.elem(ZeroOrMoreHelper::run(input, |input| { - prefix_operator_parser(input) - }))?; + seq.elem(ZeroOrMoreHelper::run(input, prefix_operator_parser))?; seq.elem(primary_expression_parser(input))?; seq.finish() }) }; - #[allow(unused_variables)] let binary_operator_parser = |input: &mut ParserContext<'_>| { ChoiceHelper::run(input, |mut choice, input| { - let result = parse_version_pragma_or_expression(input); + let result = parse_left_version_pragma_or_expression(input); choice.consider(input, result)?; - let result = parse_version_pragma_range_expression(input); + let result = parse_left_version_pragma_range_expression(input); choice.consider(input, result)?; choice.finish(input) }) }; - #[allow(unused_variables)] let linear_expression_parser = |input: &mut ParserContext<'_>| { SequenceHelper::run(|mut seq| { seq.elem(binary_operand_parser(input))?; @@ -5991,7 +4728,7 @@ impl Language { }) }; PrecedenceHelper::reduce_precedence_result( - Some(RuleKind::VersionPragmaExpression), + RuleKind::VersionPragmaExpression, linear_expression_parser(input), ) .with_kind(RuleKind::VersionPragmaExpression) @@ -6003,6 +4740,69 @@ impl Language { .with_kind(RuleKind::VersionPragmaExpressions) } + #[allow(unused_assignments, unused_parens)] + fn version_pragma_or_expression(&self, input: &mut ParserContext<'_>) -> ParserResult { + let result = self.version_pragma_expression(input); + let ParserResult::Match(r#match) = &result else { + return result; + }; + match &r#match.nodes[..] { + [cst::Node::Rule(node)] if node.kind == RuleKind::VersionPragmaExpression => { + match &node.children[..] { + [inner @ cst::Node::Rule(rule)] + if rule.kind == RuleKind::VersionPragmaOrExpression => + { + ParserResult::r#match(vec![inner.clone()], r#match.expected_tokens.clone()) + } + _ => ParserResult::no_match(vec![]), + } + } + _ => ParserResult::no_match(vec![]), + } + } + + #[allow(unused_assignments, unused_parens)] + fn version_pragma_prefix_expression(&self, input: &mut ParserContext<'_>) -> ParserResult { + let result = self.version_pragma_expression(input); + let ParserResult::Match(r#match) = &result else { + return result; + }; + match &r#match.nodes[..] { + [cst::Node::Rule(node)] if node.kind == RuleKind::VersionPragmaExpression => { + match &node.children[..] { + [inner @ cst::Node::Rule(rule)] + if rule.kind == RuleKind::VersionPragmaPrefixExpression => + { + ParserResult::r#match(vec![inner.clone()], r#match.expected_tokens.clone()) + } + _ => ParserResult::no_match(vec![]), + } + } + _ => ParserResult::no_match(vec![]), + } + } + + #[allow(unused_assignments, unused_parens)] + fn version_pragma_range_expression(&self, input: &mut ParserContext<'_>) -> ParserResult { + let result = self.version_pragma_expression(input); + let ParserResult::Match(r#match) = &result else { + return result; + }; + match &r#match.nodes[..] { + [cst::Node::Rule(node)] if node.kind == RuleKind::VersionPragmaExpression => { + match &node.children[..] { + [inner @ cst::Node::Rule(rule)] + if rule.kind == RuleKind::VersionPragmaRangeExpression => + { + ParserResult::r#match(vec![inner.clone()], r#match.expected_tokens.clone()) + } + _ => ParserResult::no_match(vec![]), + } + } + _ => ParserResult::no_match(vec![]), + } + } + #[allow(unused_assignments, unused_parens)] fn version_pragma_specifier(&self, input: &mut ParserContext<'_>) -> ParserResult { SeparatedHelper::run::<_, LexicalContextType::Pragma>( @@ -6142,8 +4942,7 @@ impl Language { #[allow(unused_assignments, unused_parens)] fn yul_expression(&self, input: &mut ParserContext<'_>) -> ParserResult { - #[allow(unused_variables)] - let parse_yul_function_call_expression = |input: &mut ParserContext<'_>| { + let parse_postfix_yul_function_call_expression = |input: &mut ParserContext<'_>| { PrecedenceHelper::to_postfix_operator( RuleKind::YulFunctionCallExpression, 1u8, @@ -6171,7 +4970,6 @@ impl Language { }), ) }; - #[allow(unused_variables)] let primary_expression_parser = |input: &mut ParserContext<'_>| { ChoiceHelper::run(input, |mut choice, input| { let result = self.yul_literal(input); @@ -6181,26 +4979,22 @@ impl Language { choice.finish(input) }) }; - #[allow(unused_variables)] let postfix_operator_parser = |input: &mut ParserContext<'_>| { ChoiceHelper::run(input, |mut choice, input| { - let result = parse_yul_function_call_expression(input); + let result = parse_postfix_yul_function_call_expression(input); choice.consider(input, result)?; choice.finish(input) }) }; - #[allow(unused_variables)] let linear_expression_parser = |input: &mut ParserContext<'_>| { SequenceHelper::run(|mut seq| { seq.elem(primary_expression_parser(input))?; - seq.elem(ZeroOrMoreHelper::run(input, |input| { - postfix_operator_parser(input) - }))?; + seq.elem(ZeroOrMoreHelper::run(input, postfix_operator_parser))?; seq.finish() }) }; PrecedenceHelper::reduce_precedence_result( - Some(RuleKind::YulExpression), + RuleKind::YulExpression, linear_expression_parser(input), ) .with_kind(RuleKind::YulExpression) @@ -6222,6 +5016,27 @@ impl Language { .with_kind(RuleKind::YulForStatement) } + #[allow(unused_assignments, unused_parens)] + fn yul_function_call_expression(&self, input: &mut ParserContext<'_>) -> ParserResult { + let result = self.yul_expression(input); + let ParserResult::Match(r#match) = &result else { + return result; + }; + match &r#match.nodes[..] { + [cst::Node::Rule(node)] if node.kind == RuleKind::YulExpression => { + match &node.children[..] { + [inner @ cst::Node::Rule(rule)] + if rule.kind == RuleKind::YulFunctionCallExpression => + { + ParserResult::r#match(vec![inner.clone()], r#match.expected_tokens.clone()) + } + _ => ParserResult::no_match(vec![]), + } + } + _ => ParserResult::no_match(vec![]), + } + } + #[allow(unused_assignments, unused_parens)] fn yul_function_definition(&self, input: &mut ParserContext<'_>) -> ParserResult { SequenceHelper::run(|mut seq| { @@ -8424,289 +7239,290 @@ impl Language { } } - pub fn parse(&self, production_kind: ProductionKind, input: &str) -> ParseOutput { - match production_kind { - ProductionKind::ABICoderPragma => Self::abi_coder_pragma.parse(self, input), - ProductionKind::AddressType => Self::address_type.parse(self, input), - ProductionKind::ArgumentsDeclaration => Self::arguments_declaration.parse(self, input), - ProductionKind::ArrayExpression => Self::array_expression.parse(self, input), - ProductionKind::ArrayValues => Self::array_values.parse(self, input), - ProductionKind::AsciiStringLiterals => Self::ascii_string_literals.parse(self, input), - ProductionKind::AssemblyFlags => Self::assembly_flags.parse(self, input), - ProductionKind::AssemblyFlagsDeclaration => { + pub fn parse(&self, kind: RuleKind, input: &str) -> ParseOutput { + match kind { + RuleKind::ABICoderPragma => Self::abi_coder_pragma.parse(self, input), + RuleKind::AdditiveExpression => Self::additive_expression.parse(self, input), + RuleKind::AddressType => Self::address_type.parse(self, input), + RuleKind::AndExpression => Self::and_expression.parse(self, input), + RuleKind::ArgumentsDeclaration => Self::arguments_declaration.parse(self, input), + RuleKind::ArrayExpression => Self::array_expression.parse(self, input), + RuleKind::ArrayTypeName => Self::array_type_name.parse(self, input), + RuleKind::ArrayValues => Self::array_values.parse(self, input), + RuleKind::AsciiStringLiterals => Self::ascii_string_literals.parse(self, input), + RuleKind::AssemblyFlags => Self::assembly_flags.parse(self, input), + RuleKind::AssemblyFlagsDeclaration => { Self::assembly_flags_declaration.parse(self, input) } - ProductionKind::AssemblyStatement => Self::assembly_statement.parse(self, input), - ProductionKind::Block => Self::block.parse(self, input), - ProductionKind::BreakStatement => Self::break_statement.parse(self, input), - ProductionKind::CatchClause => Self::catch_clause.parse(self, input), - ProductionKind::CatchClauseError => Self::catch_clause_error.parse(self, input), - ProductionKind::CatchClauses => Self::catch_clauses.parse(self, input), - ProductionKind::ConstantDefinition => Self::constant_definition.parse(self, input), - ProductionKind::ConstructorAttribute => Self::constructor_attribute.parse(self, input), - ProductionKind::ConstructorAttributes => { - Self::constructor_attributes.parse(self, input) - } - ProductionKind::ConstructorDefinition => { - Self::constructor_definition.parse(self, input) - } - ProductionKind::ContinueStatement => Self::continue_statement.parse(self, input), - ProductionKind::ContractDefinition => Self::contract_definition.parse(self, input), - ProductionKind::ContractMember => Self::contract_member.parse(self, input), - ProductionKind::ContractMembers => Self::contract_members.parse(self, input), - ProductionKind::DecimalNumberExpression => { - Self::decimal_number_expression.parse(self, input) - } - ProductionKind::DeleteStatement => Self::delete_statement.parse(self, input), - ProductionKind::DoWhileStatement => Self::do_while_statement.parse(self, input), - ProductionKind::ElementaryType => Self::elementary_type.parse(self, input), - ProductionKind::ElseBranch => Self::else_branch.parse(self, input), - ProductionKind::EmitStatement => Self::emit_statement.parse(self, input), - ProductionKind::EndOfFileTrivia => Self::end_of_file_trivia.parse(self, input), - ProductionKind::EnumDefinition => Self::enum_definition.parse(self, input), - ProductionKind::EnumMembers => Self::enum_members.parse(self, input), - ProductionKind::ErrorDefinition => Self::error_definition.parse(self, input), - ProductionKind::ErrorParameter => Self::error_parameter.parse(self, input), - ProductionKind::ErrorParameters => Self::error_parameters.parse(self, input), - ProductionKind::ErrorParametersDeclaration => { + RuleKind::AssemblyStatement => Self::assembly_statement.parse(self, input), + RuleKind::AssignmentExpression => Self::assignment_expression.parse(self, input), + RuleKind::BitwiseAndExpression => Self::bitwise_and_expression.parse(self, input), + RuleKind::BitwiseOrExpression => Self::bitwise_or_expression.parse(self, input), + RuleKind::BitwiseXorExpression => Self::bitwise_xor_expression.parse(self, input), + RuleKind::Block => Self::block.parse(self, input), + RuleKind::BreakStatement => Self::break_statement.parse(self, input), + RuleKind::CatchClause => Self::catch_clause.parse(self, input), + RuleKind::CatchClauseError => Self::catch_clause_error.parse(self, input), + RuleKind::CatchClauses => Self::catch_clauses.parse(self, input), + RuleKind::ComparisonExpression => Self::comparison_expression.parse(self, input), + RuleKind::ConditionalExpression => Self::conditional_expression.parse(self, input), + RuleKind::ConstantDefinition => Self::constant_definition.parse(self, input), + RuleKind::ConstructorAttribute => Self::constructor_attribute.parse(self, input), + RuleKind::ConstructorAttributes => Self::constructor_attributes.parse(self, input), + RuleKind::ConstructorDefinition => Self::constructor_definition.parse(self, input), + RuleKind::ContinueStatement => Self::continue_statement.parse(self, input), + RuleKind::ContractDefinition => Self::contract_definition.parse(self, input), + RuleKind::ContractMember => Self::contract_member.parse(self, input), + RuleKind::ContractMembers => Self::contract_members.parse(self, input), + RuleKind::DecimalNumberExpression => Self::decimal_number_expression.parse(self, input), + RuleKind::DeleteStatement => Self::delete_statement.parse(self, input), + RuleKind::DoWhileStatement => Self::do_while_statement.parse(self, input), + RuleKind::ElementaryType => Self::elementary_type.parse(self, input), + RuleKind::ElseBranch => Self::else_branch.parse(self, input), + RuleKind::EmitStatement => Self::emit_statement.parse(self, input), + RuleKind::EndOfFileTrivia => Self::end_of_file_trivia.parse(self, input), + RuleKind::EnumDefinition => Self::enum_definition.parse(self, input), + RuleKind::EnumMembers => Self::enum_members.parse(self, input), + RuleKind::EqualityExpression => Self::equality_expression.parse(self, input), + RuleKind::ErrorDefinition => Self::error_definition.parse(self, input), + RuleKind::ErrorParameter => Self::error_parameter.parse(self, input), + RuleKind::ErrorParameters => Self::error_parameters.parse(self, input), + RuleKind::ErrorParametersDeclaration => { Self::error_parameters_declaration.parse(self, input) } - ProductionKind::EventDefinition => Self::event_definition.parse(self, input), - ProductionKind::EventParameter => Self::event_parameter.parse(self, input), - ProductionKind::EventParameters => Self::event_parameters.parse(self, input), - ProductionKind::EventParametersDeclaration => { + RuleKind::EventDefinition => Self::event_definition.parse(self, input), + RuleKind::EventParameter => Self::event_parameter.parse(self, input), + RuleKind::EventParameters => Self::event_parameters.parse(self, input), + RuleKind::EventParametersDeclaration => { Self::event_parameters_declaration.parse(self, input) } - ProductionKind::ExperimentalFeature => Self::experimental_feature.parse(self, input), - ProductionKind::ExperimentalPragma => Self::experimental_pragma.parse(self, input), - ProductionKind::Expression => Self::expression.parse(self, input), - ProductionKind::ExpressionStatement => Self::expression_statement.parse(self, input), - ProductionKind::FallbackFunctionAttribute => { + RuleKind::ExperimentalFeature => Self::experimental_feature.parse(self, input), + RuleKind::ExperimentalPragma => Self::experimental_pragma.parse(self, input), + RuleKind::ExponentiationExpression => { + Self::exponentiation_expression.parse(self, input) + } + RuleKind::Expression => Self::expression.parse(self, input), + RuleKind::ExpressionStatement => Self::expression_statement.parse(self, input), + RuleKind::FallbackFunctionAttribute => { Self::fallback_function_attribute.parse(self, input) } - ProductionKind::FallbackFunctionAttributes => { + RuleKind::FallbackFunctionAttributes => { Self::fallback_function_attributes.parse(self, input) } - ProductionKind::FallbackFunctionDefinition => { + RuleKind::FallbackFunctionDefinition => { Self::fallback_function_definition.parse(self, input) } - ProductionKind::ForStatement => Self::for_statement.parse(self, input), - ProductionKind::ForStatementCondition => { - Self::for_statement_condition.parse(self, input) - } - ProductionKind::ForStatementInitialization => { + RuleKind::ForStatement => Self::for_statement.parse(self, input), + RuleKind::ForStatementCondition => Self::for_statement_condition.parse(self, input), + RuleKind::ForStatementInitialization => { Self::for_statement_initialization.parse(self, input) } - ProductionKind::FunctionAttribute => Self::function_attribute.parse(self, input), - ProductionKind::FunctionAttributes => Self::function_attributes.parse(self, input), - ProductionKind::FunctionBody => Self::function_body.parse(self, input), - ProductionKind::FunctionCallOptions => Self::function_call_options.parse(self, input), - ProductionKind::FunctionDefinition => Self::function_definition.parse(self, input), - ProductionKind::FunctionName => Self::function_name.parse(self, input), - ProductionKind::FunctionType => Self::function_type.parse(self, input), - ProductionKind::FunctionTypeAttribute => { - Self::function_type_attribute.parse(self, input) - } - ProductionKind::FunctionTypeAttributes => { - Self::function_type_attributes.parse(self, input) - } - ProductionKind::HexNumberExpression => Self::hex_number_expression.parse(self, input), - ProductionKind::HexStringLiterals => Self::hex_string_literals.parse(self, input), - ProductionKind::IdentifierPath => Self::identifier_path.parse(self, input), - ProductionKind::IfStatement => Self::if_statement.parse(self, input), - ProductionKind::ImportAlias => Self::import_alias.parse(self, input), - ProductionKind::ImportClause => Self::import_clause.parse(self, input), - ProductionKind::ImportDeconstruction => Self::import_deconstruction.parse(self, input), - ProductionKind::ImportDeconstructionSymbol => { + RuleKind::FunctionAttribute => Self::function_attribute.parse(self, input), + RuleKind::FunctionAttributes => Self::function_attributes.parse(self, input), + RuleKind::FunctionBody => Self::function_body.parse(self, input), + RuleKind::FunctionCallExpression => Self::function_call_expression.parse(self, input), + RuleKind::FunctionCallOptions => Self::function_call_options.parse(self, input), + RuleKind::FunctionDefinition => Self::function_definition.parse(self, input), + RuleKind::FunctionName => Self::function_name.parse(self, input), + RuleKind::FunctionType => Self::function_type.parse(self, input), + RuleKind::FunctionTypeAttribute => Self::function_type_attribute.parse(self, input), + RuleKind::FunctionTypeAttributes => Self::function_type_attributes.parse(self, input), + RuleKind::HexNumberExpression => Self::hex_number_expression.parse(self, input), + RuleKind::HexStringLiterals => Self::hex_string_literals.parse(self, input), + RuleKind::IdentifierPath => Self::identifier_path.parse(self, input), + RuleKind::IfStatement => Self::if_statement.parse(self, input), + RuleKind::ImportAlias => Self::import_alias.parse(self, input), + RuleKind::ImportClause => Self::import_clause.parse(self, input), + RuleKind::ImportDeconstruction => Self::import_deconstruction.parse(self, input), + RuleKind::ImportDeconstructionSymbol => { Self::import_deconstruction_symbol.parse(self, input) } - ProductionKind::ImportDeconstructionSymbols => { + RuleKind::ImportDeconstructionSymbols => { Self::import_deconstruction_symbols.parse(self, input) } - ProductionKind::ImportDirective => Self::import_directive.parse(self, input), - ProductionKind::IndexAccessEnd => Self::index_access_end.parse(self, input), - ProductionKind::InheritanceSpecifier => Self::inheritance_specifier.parse(self, input), - ProductionKind::InheritanceType => Self::inheritance_type.parse(self, input), - ProductionKind::InheritanceTypes => Self::inheritance_types.parse(self, input), - ProductionKind::InterfaceDefinition => Self::interface_definition.parse(self, input), - ProductionKind::InterfaceMembers => Self::interface_members.parse(self, input), - ProductionKind::LeadingTrivia => Self::leading_trivia.parse(self, input), - ProductionKind::LibraryDefinition => Self::library_definition.parse(self, input), - ProductionKind::LibraryMembers => Self::library_members.parse(self, input), - ProductionKind::MappingKey => Self::mapping_key.parse(self, input), - ProductionKind::MappingKeyType => Self::mapping_key_type.parse(self, input), - ProductionKind::MappingType => Self::mapping_type.parse(self, input), - ProductionKind::MappingValue => Self::mapping_value.parse(self, input), - ProductionKind::MemberAccess => Self::member_access.parse(self, input), - ProductionKind::ModifierAttribute => Self::modifier_attribute.parse(self, input), - ProductionKind::ModifierAttributes => Self::modifier_attributes.parse(self, input), - ProductionKind::ModifierDefinition => Self::modifier_definition.parse(self, input), - ProductionKind::ModifierInvocation => Self::modifier_invocation.parse(self, input), - ProductionKind::NamedArgument => Self::named_argument.parse(self, input), - ProductionKind::NamedArgumentGroup => Self::named_argument_group.parse(self, input), - ProductionKind::NamedArgumentGroups => Self::named_argument_groups.parse(self, input), - ProductionKind::NamedArguments => Self::named_arguments.parse(self, input), - ProductionKind::NamedArgumentsDeclaration => { + RuleKind::ImportDirective => Self::import_directive.parse(self, input), + RuleKind::IndexAccessEnd => Self::index_access_end.parse(self, input), + RuleKind::IndexAccessExpression => Self::index_access_expression.parse(self, input), + RuleKind::InheritanceSpecifier => Self::inheritance_specifier.parse(self, input), + RuleKind::InheritanceType => Self::inheritance_type.parse(self, input), + RuleKind::InheritanceTypes => Self::inheritance_types.parse(self, input), + RuleKind::InterfaceDefinition => Self::interface_definition.parse(self, input), + RuleKind::InterfaceMembers => Self::interface_members.parse(self, input), + RuleKind::LeadingTrivia => Self::leading_trivia.parse(self, input), + RuleKind::LibraryDefinition => Self::library_definition.parse(self, input), + RuleKind::LibraryMembers => Self::library_members.parse(self, input), + RuleKind::MappingKey => Self::mapping_key.parse(self, input), + RuleKind::MappingKeyType => Self::mapping_key_type.parse(self, input), + RuleKind::MappingType => Self::mapping_type.parse(self, input), + RuleKind::MappingValue => Self::mapping_value.parse(self, input), + RuleKind::MemberAccess => Self::member_access.parse(self, input), + RuleKind::MemberAccessExpression => Self::member_access_expression.parse(self, input), + RuleKind::ModifierAttribute => Self::modifier_attribute.parse(self, input), + RuleKind::ModifierAttributes => Self::modifier_attributes.parse(self, input), + RuleKind::ModifierDefinition => Self::modifier_definition.parse(self, input), + RuleKind::ModifierInvocation => Self::modifier_invocation.parse(self, input), + RuleKind::MultiplicativeExpression => { + Self::multiplicative_expression.parse(self, input) + } + RuleKind::NamedArgument => Self::named_argument.parse(self, input), + RuleKind::NamedArgumentGroup => Self::named_argument_group.parse(self, input), + RuleKind::NamedArgumentGroups => Self::named_argument_groups.parse(self, input), + RuleKind::NamedArguments => Self::named_arguments.parse(self, input), + RuleKind::NamedArgumentsDeclaration => { Self::named_arguments_declaration.parse(self, input) } - ProductionKind::NamedImport => Self::named_import.parse(self, input), - ProductionKind::NewExpression => Self::new_expression.parse(self, input), - ProductionKind::NumberUnit => Self::number_unit.parse(self, input), - ProductionKind::OverridePaths => Self::override_paths.parse(self, input), - ProductionKind::OverridePathsDeclaration => { + RuleKind::NamedImport => Self::named_import.parse(self, input), + RuleKind::NewExpression => Self::new_expression.parse(self, input), + RuleKind::NumberUnit => Self::number_unit.parse(self, input), + RuleKind::OrExpression => Self::or_expression.parse(self, input), + RuleKind::OverridePaths => Self::override_paths.parse(self, input), + RuleKind::OverridePathsDeclaration => { Self::override_paths_declaration.parse(self, input) } - ProductionKind::OverrideSpecifier => Self::override_specifier.parse(self, input), - ProductionKind::Parameter => Self::parameter.parse(self, input), - ProductionKind::Parameters => Self::parameters.parse(self, input), - ProductionKind::ParametersDeclaration => { - Self::parameters_declaration.parse(self, input) - } - ProductionKind::PathImport => Self::path_import.parse(self, input), - ProductionKind::PositionalArguments => Self::positional_arguments.parse(self, input), - ProductionKind::PositionalArgumentsDeclaration => { + RuleKind::OverrideSpecifier => Self::override_specifier.parse(self, input), + RuleKind::Parameter => Self::parameter.parse(self, input), + RuleKind::Parameters => Self::parameters.parse(self, input), + RuleKind::ParametersDeclaration => Self::parameters_declaration.parse(self, input), + RuleKind::PathImport => Self::path_import.parse(self, input), + RuleKind::PositionalArguments => Self::positional_arguments.parse(self, input), + RuleKind::PositionalArgumentsDeclaration => { Self::positional_arguments_declaration.parse(self, input) } - ProductionKind::Pragma => Self::pragma.parse(self, input), - ProductionKind::PragmaDirective => Self::pragma_directive.parse(self, input), - ProductionKind::ReceiveFunctionAttribute => { + RuleKind::PostfixExpression => Self::postfix_expression.parse(self, input), + RuleKind::Pragma => Self::pragma.parse(self, input), + RuleKind::PragmaDirective => Self::pragma_directive.parse(self, input), + RuleKind::PrefixExpression => Self::prefix_expression.parse(self, input), + RuleKind::ReceiveFunctionAttribute => { Self::receive_function_attribute.parse(self, input) } - ProductionKind::ReceiveFunctionAttributes => { + RuleKind::ReceiveFunctionAttributes => { Self::receive_function_attributes.parse(self, input) } - ProductionKind::ReceiveFunctionDefinition => { + RuleKind::ReceiveFunctionDefinition => { Self::receive_function_definition.parse(self, input) } - ProductionKind::ReturnStatement => Self::return_statement.parse(self, input), - ProductionKind::ReturnsDeclaration => Self::returns_declaration.parse(self, input), - ProductionKind::RevertStatement => Self::revert_statement.parse(self, input), - ProductionKind::SourceUnit => Self::source_unit.parse(self, input), - ProductionKind::SourceUnitMember => Self::source_unit_member.parse(self, input), - ProductionKind::SourceUnitMembers => Self::source_unit_members.parse(self, input), - ProductionKind::StateVariableAttribute => { - Self::state_variable_attribute.parse(self, input) - } - ProductionKind::StateVariableAttributes => { - Self::state_variable_attributes.parse(self, input) - } - ProductionKind::StateVariableDefinition => { - Self::state_variable_definition.parse(self, input) - } - ProductionKind::StateVariableDefinitionValue => { + RuleKind::ReturnStatement => Self::return_statement.parse(self, input), + RuleKind::ReturnsDeclaration => Self::returns_declaration.parse(self, input), + RuleKind::RevertStatement => Self::revert_statement.parse(self, input), + RuleKind::ShiftExpression => Self::shift_expression.parse(self, input), + RuleKind::SourceUnit => Self::source_unit.parse(self, input), + RuleKind::SourceUnitMember => Self::source_unit_member.parse(self, input), + RuleKind::SourceUnitMembers => Self::source_unit_members.parse(self, input), + RuleKind::StateVariableAttribute => Self::state_variable_attribute.parse(self, input), + RuleKind::StateVariableAttributes => Self::state_variable_attributes.parse(self, input), + RuleKind::StateVariableDefinition => Self::state_variable_definition.parse(self, input), + RuleKind::StateVariableDefinitionValue => { Self::state_variable_definition_value.parse(self, input) } - ProductionKind::Statement => Self::statement.parse(self, input), - ProductionKind::Statements => Self::statements.parse(self, input), - ProductionKind::StorageLocation => Self::storage_location.parse(self, input), - ProductionKind::StringExpression => Self::string_expression.parse(self, input), - ProductionKind::StructDefinition => Self::struct_definition.parse(self, input), - ProductionKind::StructMember => Self::struct_member.parse(self, input), - ProductionKind::StructMembers => Self::struct_members.parse(self, input), - ProductionKind::ThrowStatement => Self::throw_statement.parse(self, input), - ProductionKind::TrailingTrivia => Self::trailing_trivia.parse(self, input), - ProductionKind::TryStatement => Self::try_statement.parse(self, input), - ProductionKind::TupleDeconstructionElement => { + RuleKind::Statement => Self::statement.parse(self, input), + RuleKind::Statements => Self::statements.parse(self, input), + RuleKind::StorageLocation => Self::storage_location.parse(self, input), + RuleKind::StringExpression => Self::string_expression.parse(self, input), + RuleKind::StructDefinition => Self::struct_definition.parse(self, input), + RuleKind::StructMember => Self::struct_member.parse(self, input), + RuleKind::StructMembers => Self::struct_members.parse(self, input), + RuleKind::ThrowStatement => Self::throw_statement.parse(self, input), + RuleKind::TrailingTrivia => Self::trailing_trivia.parse(self, input), + RuleKind::TryStatement => Self::try_statement.parse(self, input), + RuleKind::TupleDeconstructionElement => { Self::tuple_deconstruction_element.parse(self, input) } - ProductionKind::TupleDeconstructionElements => { + RuleKind::TupleDeconstructionElements => { Self::tuple_deconstruction_elements.parse(self, input) } - ProductionKind::TupleDeconstructionStatement => { + RuleKind::TupleDeconstructionStatement => { Self::tuple_deconstruction_statement.parse(self, input) } - ProductionKind::TupleExpression => Self::tuple_expression.parse(self, input), - ProductionKind::TupleMember => Self::tuple_member.parse(self, input), - ProductionKind::TupleValue => Self::tuple_value.parse(self, input), - ProductionKind::TupleValues => Self::tuple_values.parse(self, input), - ProductionKind::TypeExpression => Self::type_expression.parse(self, input), - ProductionKind::TypeName => Self::type_name.parse(self, input), - ProductionKind::TypedTupleMember => Self::typed_tuple_member.parse(self, input), - ProductionKind::UncheckedBlock => Self::unchecked_block.parse(self, input), - ProductionKind::UnicodeStringLiterals => { - Self::unicode_string_literals.parse(self, input) - } - ProductionKind::UnnamedFunctionAttribute => { + RuleKind::TupleExpression => Self::tuple_expression.parse(self, input), + RuleKind::TupleMember => Self::tuple_member.parse(self, input), + RuleKind::TupleValue => Self::tuple_value.parse(self, input), + RuleKind::TupleValues => Self::tuple_values.parse(self, input), + RuleKind::TypeExpression => Self::type_expression.parse(self, input), + RuleKind::TypeName => Self::type_name.parse(self, input), + RuleKind::TypedTupleMember => Self::typed_tuple_member.parse(self, input), + RuleKind::UncheckedBlock => Self::unchecked_block.parse(self, input), + RuleKind::UnicodeStringLiterals => Self::unicode_string_literals.parse(self, input), + RuleKind::UnnamedFunctionAttribute => { Self::unnamed_function_attribute.parse(self, input) } - ProductionKind::UnnamedFunctionAttributes => { + RuleKind::UnnamedFunctionAttributes => { Self::unnamed_function_attributes.parse(self, input) } - ProductionKind::UnnamedFunctionDefinition => { + RuleKind::UnnamedFunctionDefinition => { Self::unnamed_function_definition.parse(self, input) } - ProductionKind::UntypedTupleMember => Self::untyped_tuple_member.parse(self, input), - ProductionKind::UserDefinedValueTypeDefinition => { + RuleKind::UntypedTupleMember => Self::untyped_tuple_member.parse(self, input), + RuleKind::UserDefinedValueTypeDefinition => { Self::user_defined_value_type_definition.parse(self, input) } - ProductionKind::UsingAlias => Self::using_alias.parse(self, input), - ProductionKind::UsingClause => Self::using_clause.parse(self, input), - ProductionKind::UsingDeconstruction => Self::using_deconstruction.parse(self, input), - ProductionKind::UsingDeconstructionSymbol => { + RuleKind::UsingAlias => Self::using_alias.parse(self, input), + RuleKind::UsingClause => Self::using_clause.parse(self, input), + RuleKind::UsingDeconstruction => Self::using_deconstruction.parse(self, input), + RuleKind::UsingDeconstructionSymbol => { Self::using_deconstruction_symbol.parse(self, input) } - ProductionKind::UsingDeconstructionSymbols => { + RuleKind::UsingDeconstructionSymbols => { Self::using_deconstruction_symbols.parse(self, input) } - ProductionKind::UsingDirective => Self::using_directive.parse(self, input), - ProductionKind::UsingOperator => Self::using_operator.parse(self, input), - ProductionKind::UsingTarget => Self::using_target.parse(self, input), - ProductionKind::VariableDeclarationStatement => { + RuleKind::UsingDirective => Self::using_directive.parse(self, input), + RuleKind::UsingOperator => Self::using_operator.parse(self, input), + RuleKind::UsingTarget => Self::using_target.parse(self, input), + RuleKind::VariableDeclarationStatement => { Self::variable_declaration_statement.parse(self, input) } - ProductionKind::VariableDeclarationType => { - Self::variable_declaration_type.parse(self, input) - } - ProductionKind::VariableDeclarationValue => { + RuleKind::VariableDeclarationType => Self::variable_declaration_type.parse(self, input), + RuleKind::VariableDeclarationValue => { Self::variable_declaration_value.parse(self, input) } - ProductionKind::VersionPragma => Self::version_pragma.parse(self, input), - ProductionKind::VersionPragmaExpression => { - Self::version_pragma_expression.parse(self, input) - } - ProductionKind::VersionPragmaExpressions => { + RuleKind::VersionPragma => Self::version_pragma.parse(self, input), + RuleKind::VersionPragmaExpression => Self::version_pragma_expression.parse(self, input), + RuleKind::VersionPragmaExpressions => { Self::version_pragma_expressions.parse(self, input) } - ProductionKind::VersionPragmaSpecifier => { - Self::version_pragma_specifier.parse(self, input) + RuleKind::VersionPragmaOrExpression => { + Self::version_pragma_or_expression.parse(self, input) } - ProductionKind::WhileStatement => Self::while_statement.parse(self, input), - ProductionKind::YulArguments => Self::yul_arguments.parse(self, input), - ProductionKind::YulAssignmentStatement => { - Self::yul_assignment_statement.parse(self, input) + RuleKind::VersionPragmaPrefixExpression => { + Self::version_pragma_prefix_expression.parse(self, input) } - ProductionKind::YulBlock => Self::yul_block.parse(self, input), - ProductionKind::YulBreakStatement => Self::yul_break_statement.parse(self, input), - ProductionKind::YulContinueStatement => Self::yul_continue_statement.parse(self, input), - ProductionKind::YulDefaultCase => Self::yul_default_case.parse(self, input), - ProductionKind::YulExpression => Self::yul_expression.parse(self, input), - ProductionKind::YulForStatement => Self::yul_for_statement.parse(self, input), - ProductionKind::YulFunctionDefinition => { - Self::yul_function_definition.parse(self, input) + RuleKind::VersionPragmaRangeExpression => { + Self::version_pragma_range_expression.parse(self, input) } - ProductionKind::YulIdentifierPath => Self::yul_identifier_path.parse(self, input), - ProductionKind::YulIdentifierPaths => Self::yul_identifier_paths.parse(self, input), - ProductionKind::YulIfStatement => Self::yul_if_statement.parse(self, input), - ProductionKind::YulLeaveStatement => Self::yul_leave_statement.parse(self, input), - ProductionKind::YulLiteral => Self::yul_literal.parse(self, input), - ProductionKind::YulParameters => Self::yul_parameters.parse(self, input), - ProductionKind::YulParametersDeclaration => { - Self::yul_parameters_declaration.parse(self, input) + RuleKind::VersionPragmaSpecifier => Self::version_pragma_specifier.parse(self, input), + RuleKind::WhileStatement => Self::while_statement.parse(self, input), + RuleKind::YulArguments => Self::yul_arguments.parse(self, input), + RuleKind::YulAssignmentStatement => Self::yul_assignment_statement.parse(self, input), + RuleKind::YulBlock => Self::yul_block.parse(self, input), + RuleKind::YulBreakStatement => Self::yul_break_statement.parse(self, input), + RuleKind::YulContinueStatement => Self::yul_continue_statement.parse(self, input), + RuleKind::YulDefaultCase => Self::yul_default_case.parse(self, input), + RuleKind::YulExpression => Self::yul_expression.parse(self, input), + RuleKind::YulForStatement => Self::yul_for_statement.parse(self, input), + RuleKind::YulFunctionCallExpression => { + Self::yul_function_call_expression.parse(self, input) } - ProductionKind::YulReturnVariables => Self::yul_return_variables.parse(self, input), - ProductionKind::YulReturnsDeclaration => { - Self::yul_returns_declaration.parse(self, input) + RuleKind::YulFunctionDefinition => Self::yul_function_definition.parse(self, input), + RuleKind::YulIdentifierPath => Self::yul_identifier_path.parse(self, input), + RuleKind::YulIdentifierPaths => Self::yul_identifier_paths.parse(self, input), + RuleKind::YulIfStatement => Self::yul_if_statement.parse(self, input), + RuleKind::YulLeaveStatement => Self::yul_leave_statement.parse(self, input), + RuleKind::YulLiteral => Self::yul_literal.parse(self, input), + RuleKind::YulParameters => Self::yul_parameters.parse(self, input), + RuleKind::YulParametersDeclaration => { + Self::yul_parameters_declaration.parse(self, input) } - ProductionKind::YulStatement => Self::yul_statement.parse(self, input), - ProductionKind::YulStatements => Self::yul_statements.parse(self, input), - ProductionKind::YulSwitchCase => Self::yul_switch_case.parse(self, input), - ProductionKind::YulSwitchCases => Self::yul_switch_cases.parse(self, input), - ProductionKind::YulSwitchStatement => Self::yul_switch_statement.parse(self, input), - ProductionKind::YulValueCase => Self::yul_value_case.parse(self, input), - ProductionKind::YulVariableDeclarationStatement => { + RuleKind::YulReturnVariables => Self::yul_return_variables.parse(self, input), + RuleKind::YulReturnsDeclaration => Self::yul_returns_declaration.parse(self, input), + RuleKind::YulStatement => Self::yul_statement.parse(self, input), + RuleKind::YulStatements => Self::yul_statements.parse(self, input), + RuleKind::YulSwitchCase => Self::yul_switch_case.parse(self, input), + RuleKind::YulSwitchCases => Self::yul_switch_cases.parse(self, input), + RuleKind::YulSwitchStatement => Self::yul_switch_statement.parse(self, input), + RuleKind::YulValueCase => Self::yul_value_case.parse(self, input), + RuleKind::YulVariableDeclarationStatement => { Self::yul_variable_declaration_statement.parse(self, input) } - ProductionKind::YulVariableDeclarationValue => { + RuleKind::YulVariableDeclarationValue => { Self::yul_variable_declaration_value.parse(self, input) } } @@ -10960,9 +9776,9 @@ impl Language { #[napi(js_name = "parse", ts_return_type = "parse_output.ParseOutput")] pub fn parse_napi( &self, - #[napi(ts_arg_type = "kinds.ProductionKind")] production_kind: ProductionKind, + #[napi(ts_arg_type = "kinds.RuleKind")] kind: RuleKind, input: String, ) -> NAPIParseOutput { - self.parse(production_kind, input.as_str()).into() + self.parse(kind, input.as_str()).into() } } diff --git a/crates/solidity/outputs/cargo/crate/src/generated/support/precedence_helper.rs b/crates/solidity/outputs/cargo/crate/src/generated/support/precedence_helper.rs index 0ee251bda3..175b2c538e 100644 --- a/crates/solidity/outputs/cargo/crate/src/generated/support/precedence_helper.rs +++ b/crates/solidity/outputs/cargo/crate/src/generated/support/precedence_helper.rs @@ -60,10 +60,7 @@ impl PrecedenceHelper { } #[allow(clippy::too_many_lines)] // Explicit on purpose, see below. - pub fn reduce_precedence_result( - child_kind: Option, - result: ParserResult, - ) -> ParserResult { + pub fn reduce_precedence_result(child_kind: RuleKind, result: ParserResult) -> ParserResult { // This requires some careful thinking. It could be more compact, // but I'm favouring obviousness here. That is also why there are // so many `unreachable!` - not only should they never be reached, @@ -164,10 +161,8 @@ impl PrecedenceHelper { let wrap_children = |children: Vec| { if children.is_empty() { children - } else if let Some(kind) = child_kind { - vec![cst::Node::rule(kind, children)] } else { - children + vec![cst::Node::rule(child_kind, children)] } }; diff --git a/crates/solidity/outputs/cargo/crate/src/main.rs b/crates/solidity/outputs/cargo/crate/src/main.rs index 54d31402e2..1b6f94a5c7 100644 --- a/crates/solidity/outputs/cargo/crate/src/main.rs +++ b/crates/solidity/outputs/cargo/crate/src/main.rs @@ -3,7 +3,7 @@ use std::{fs, path::PathBuf, process::ExitCode}; use anyhow::{Context, Result}; use clap::{Parser as ClapParser, Subcommand}; use semver::Version; -use slang_solidity::{kinds::ProductionKind, language::Language}; +use slang_solidity::{kinds::RuleKind, language::Language}; // Below are dependencies used by the API `lib.rs`, but not the CLI "main.rs". // However, we need to add a fake usage to suppress Cargo warnings about unused dependencies. @@ -59,7 +59,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(ProductionKind::SourceUnit, &input); + let output = language.parse(RuleKind::SourceUnit, &input); let errors = output.errors(); for error in errors { diff --git a/crates/solidity/outputs/cargo/tests/src/cst_output/generated/ConditionalExpression.rs b/crates/solidity/outputs/cargo/tests/src/cst_output/generated/ConditionalExpression.rs new file mode 100644 index 0000000000..c3907194a5 --- /dev/null +++ b/crates/solidity/outputs/cargo/tests/src/cst_output/generated/ConditionalExpression.rs @@ -0,0 +1,25 @@ +// This file is generated automatically by infrastructure scripts. Please don't edit by hand. + +use anyhow::Result; + +use crate::cst_output::runner::run; + +#[test] +fn identifier_base() -> Result<()> { + run("ConditionalExpression", "identifier_base") +} + +#[test] +fn nested_base() -> Result<()> { + run("ConditionalExpression", "nested_base") +} + +#[test] +fn nested_conditions() -> Result<()> { + run("ConditionalExpression", "nested_conditions") +} + +#[test] +fn recursive() -> Result<()> { + run("ConditionalExpression", "recursive") +} diff --git a/crates/solidity/outputs/cargo/tests/src/cst_output/generated/ExponentiationExpression.rs b/crates/solidity/outputs/cargo/tests/src/cst_output/generated/ExponentiationExpression.rs new file mode 100644 index 0000000000..832ccb2ea1 --- /dev/null +++ b/crates/solidity/outputs/cargo/tests/src/cst_output/generated/ExponentiationExpression.rs @@ -0,0 +1,10 @@ +// This file is generated automatically by infrastructure scripts. Please don't edit by hand. + +use anyhow::Result; + +use crate::cst_output::runner::run; + +#[test] +fn associativity() -> Result<()> { + run("ExponentiationExpression", "associativity") +} diff --git a/crates/solidity/outputs/cargo/tests/src/cst_output/generated/Expression.rs b/crates/solidity/outputs/cargo/tests/src/cst_output/generated/Expression.rs index c28721e89a..2560b6da8d 100644 --- a/crates/solidity/outputs/cargo/tests/src/cst_output/generated/Expression.rs +++ b/crates/solidity/outputs/cargo/tests/src/cst_output/generated/Expression.rs @@ -34,31 +34,6 @@ fn areturn() -> Result<()> { run("Expression", "areturn") } -#[test] -fn conditional_expression_identifier_base() -> Result<()> { - run("Expression", "conditional_expression_identifier_base") -} - -#[test] -fn conditional_expression_nested_base() -> Result<()> { - run("Expression", "conditional_expression_nested_base") -} - -#[test] -fn conditional_expression_nested_conditions() -> Result<()> { - run("Expression", "conditional_expression_nested_conditions") -} - -#[test] -fn conditional_expression_recursive() -> Result<()> { - run("Expression", "conditional_expression_recursive") -} - -#[test] -fn exponentiation_operator_associativity() -> Result<()> { - run("Expression", "exponentiation_operator_associativity") -} - #[test] fn function_call() -> Result<()> { run("Expression", "function_call") diff --git a/crates/solidity/outputs/cargo/tests/src/cst_output/generated/mod.rs b/crates/solidity/outputs/cargo/tests/src/cst_output/generated/mod.rs index 814f882d1d..bcfd0280bf 100644 --- a/crates/solidity/outputs/cargo/tests/src/cst_output/generated/mod.rs +++ b/crates/solidity/outputs/cargo/tests/src/cst_output/generated/mod.rs @@ -10,6 +10,8 @@ mod Block; #[allow(non_snake_case)] mod BreakStatement; #[allow(non_snake_case)] +mod ConditionalExpression; +#[allow(non_snake_case)] mod ConstantDefinition; #[allow(non_snake_case)] mod ConstructorDefinition; @@ -28,6 +30,8 @@ mod ErrorDefinition; #[allow(non_snake_case)] mod EventDefinition; #[allow(non_snake_case)] +mod ExponentiationExpression; +#[allow(non_snake_case)] mod Expression; #[allow(non_snake_case)] mod FallbackFunctionDefinition; 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 12386de627..dc1c2ed6d2 100644 --- a/crates/solidity/outputs/cargo/tests/src/cst_output/runner.rs +++ b/crates/solidity/outputs/cargo/tests/src/cst_output/runner.rs @@ -2,7 +2,7 @@ use std::str::FromStr; use anyhow::Result; use infra_utils::{cargo::CargoWorkspace, codegen::Codegen, paths::PathExtensions}; -use slang_solidity::{kinds::ProductionKind, language::Language}; +use slang_solidity::{kinds::RuleKind, language::Language}; use solidity_testing_utils::cst_snapshots::CstSnapshots; use strum_macros::Display; @@ -31,10 +31,10 @@ pub fn run(parser_name: &str, test_name: &str) -> Result<()> { let mut last_output = None; for version in VERSION_BREAKS { - let production_kind = ProductionKind::from_str(parser_name) + let rule_kind = RuleKind::from_str(parser_name) .unwrap_or_else(|_| panic!("No such parser: {parser_name}")); - let output = Language::new(version.clone())?.parse(production_kind, &source); + let output = Language::new(version.clone())?.parse(rule_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/cursor_api.rs b/crates/solidity/outputs/cargo/tests/src/doc_examples/cursor_api.rs index 98bb33e273..4937c037cf 100644 --- a/crates/solidity/outputs/cargo/tests/src/doc_examples/cursor_api.rs +++ b/crates/solidity/outputs/cargo/tests/src/doc_examples/cursor_api.rs @@ -1,7 +1,7 @@ use anyhow::Result; use semver::Version; use slang_solidity::{ - kinds::{ProductionKind, RuleKind, TokenKind}, + kinds::{RuleKind, TokenKind}, language::Language, }; @@ -14,7 +14,7 @@ const SOURCE: &str = " #[test] fn using_cursor_api() -> Result<()> { let language = Language::new(Version::parse("0.8.0")?)?; - let parse_output = language.parse(ProductionKind::SourceUnit, SOURCE); + let parse_output = language.parse(RuleKind::SourceUnit, SOURCE); let mut contract_names = Vec::new(); let mut cursor = parse_output.create_tree_cursor(); @@ -37,7 +37,7 @@ fn using_cursor_api() -> Result<()> { #[test] fn using_spawn() -> Result<()> { let language = Language::new(Version::parse("0.8.0")?)?; - let parse_output = language.parse(ProductionKind::SourceUnit, SOURCE); + let parse_output = language.parse(RuleKind::SourceUnit, SOURCE); let mut contract_names = Vec::new(); let mut cursor = parse_output.create_tree_cursor(); @@ -61,7 +61,7 @@ fn using_spawn() -> Result<()> { #[test] fn using_iter() -> Result<()> { let language = Language::new(Version::parse("0.8.0")?)?; - let parse_output = language.parse(ProductionKind::SourceUnit, SOURCE); + let parse_output = language.parse(RuleKind::SourceUnit, SOURCE); let mut contract_names = Vec::new(); let mut cursor = parse_output.create_tree_cursor(); @@ -86,7 +86,7 @@ fn using_iter() -> Result<()> { #[test] fn using_iter_combinators() -> Result<()> { let language = Language::new(Version::parse("0.8.0")?)?; - let parse_output = language.parse(ProductionKind::SourceUnit, SOURCE); + let parse_output = language.parse(RuleKind::SourceUnit, SOURCE); let contract_names: Vec<_> = parse_output .create_tree_cursor() diff --git a/crates/solidity/outputs/cargo/tests/src/doc_examples/simple_contract.rs b/crates/solidity/outputs/cargo/tests/src/doc_examples/simple_contract.rs index 46ca12b1df..6a64416caf 100644 --- a/crates/solidity/outputs/cargo/tests/src/doc_examples/simple_contract.rs +++ b/crates/solidity/outputs/cargo/tests/src/doc_examples/simple_contract.rs @@ -2,14 +2,14 @@ use anyhow::Result; use semver::Version; use slang_solidity::{ cst::Node, - kinds::{ProductionKind, RuleKind, TokenKind}, + kinds::{RuleKind, TokenKind}, language::Language, }; #[test] fn simple_contract() -> Result<()> { let language = Language::new(Version::parse("0.8.0")?)?; - let parse_output = language.parse(ProductionKind::ContractDefinition, "contract Foo {}"); + let parse_output = language.parse(RuleKind::ContractDefinition, "contract Foo {}"); let parse_tree = parse_output.tree(); let rule = parse_tree diff --git a/crates/solidity/outputs/npm/crate/src/generated/kinds.rs b/crates/solidity/outputs/npm/crate/src/generated/kinds.rs index f87c025206..5fd9016364 100644 --- a/crates/solidity/outputs/npm/crate/src/generated/kinds.rs +++ b/crates/solidity/outputs/npm/crate/src/generated/kinds.rs @@ -3,209 +3,6 @@ #[cfg(feature = "slang_napi_interfaces")] use {napi::bindgen_prelude::*, napi_derive::napi}; -#[derive( - Debug, - Eq, - Ord, - PartialEq, - PartialOrd, - serde::Serialize, - strum_macros::AsRefStr, - strum_macros::Display, - strum_macros::EnumString, -)] -#[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 ProductionKind { - ABICoderPragma, - AddressType, - ArgumentsDeclaration, - ArrayExpression, - ArrayValues, - AsciiStringLiterals, - AssemblyFlags, - AssemblyFlagsDeclaration, - AssemblyStatement, - Block, - BreakStatement, - CatchClause, - CatchClauseError, - CatchClauses, - ConstantDefinition, - ConstructorAttribute, - ConstructorAttributes, - ConstructorDefinition, - ContinueStatement, - ContractDefinition, - ContractMember, - ContractMembers, - DecimalNumberExpression, - DeleteStatement, - DoWhileStatement, - ElementaryType, - ElseBranch, - EmitStatement, - EndOfFileTrivia, - EnumDefinition, - EnumMembers, - ErrorDefinition, - ErrorParameter, - ErrorParameters, - ErrorParametersDeclaration, - EventDefinition, - EventParameter, - EventParameters, - EventParametersDeclaration, - ExperimentalFeature, - ExperimentalPragma, - Expression, - ExpressionStatement, - FallbackFunctionAttribute, - FallbackFunctionAttributes, - FallbackFunctionDefinition, - ForStatement, - ForStatementCondition, - ForStatementInitialization, - FunctionAttribute, - FunctionAttributes, - FunctionBody, - FunctionCallOptions, - FunctionDefinition, - FunctionName, - FunctionType, - FunctionTypeAttribute, - FunctionTypeAttributes, - HexNumberExpression, - HexStringLiterals, - IdentifierPath, - IfStatement, - ImportAlias, - ImportClause, - ImportDeconstruction, - ImportDeconstructionSymbol, - ImportDeconstructionSymbols, - ImportDirective, - IndexAccessEnd, - InheritanceSpecifier, - InheritanceType, - InheritanceTypes, - InterfaceDefinition, - InterfaceMembers, - LeadingTrivia, - LibraryDefinition, - LibraryMembers, - MappingKey, - MappingKeyType, - MappingType, - MappingValue, - MemberAccess, - ModifierAttribute, - ModifierAttributes, - ModifierDefinition, - ModifierInvocation, - NamedArgument, - NamedArgumentGroup, - NamedArgumentGroups, - NamedArguments, - NamedArgumentsDeclaration, - NamedImport, - NewExpression, - NumberUnit, - OverridePaths, - OverridePathsDeclaration, - OverrideSpecifier, - Parameter, - Parameters, - ParametersDeclaration, - PathImport, - PositionalArguments, - PositionalArgumentsDeclaration, - Pragma, - PragmaDirective, - ReceiveFunctionAttribute, - ReceiveFunctionAttributes, - ReceiveFunctionDefinition, - ReturnStatement, - ReturnsDeclaration, - RevertStatement, - SourceUnit, - SourceUnitMember, - SourceUnitMembers, - StateVariableAttribute, - StateVariableAttributes, - StateVariableDefinition, - StateVariableDefinitionValue, - Statement, - Statements, - StorageLocation, - StringExpression, - StructDefinition, - StructMember, - StructMembers, - ThrowStatement, - TrailingTrivia, - TryStatement, - TupleDeconstructionElement, - TupleDeconstructionElements, - TupleDeconstructionStatement, - TupleExpression, - TupleMember, - TupleValue, - TupleValues, - TypeExpression, - TypeName, - TypedTupleMember, - UncheckedBlock, - UnicodeStringLiterals, - UnnamedFunctionAttribute, - UnnamedFunctionAttributes, - UnnamedFunctionDefinition, - UntypedTupleMember, - UserDefinedValueTypeDefinition, - UsingAlias, - UsingClause, - UsingDeconstruction, - UsingDeconstructionSymbol, - UsingDeconstructionSymbols, - UsingDirective, - UsingOperator, - UsingTarget, - VariableDeclarationStatement, - VariableDeclarationType, - VariableDeclarationValue, - VersionPragma, - VersionPragmaExpression, - VersionPragmaExpressions, - VersionPragmaSpecifier, - WhileStatement, - YulArguments, - YulAssignmentStatement, - YulBlock, - YulBreakStatement, - YulContinueStatement, - YulDefaultCase, - YulExpression, - YulForStatement, - YulFunctionDefinition, - YulIdentifierPath, - YulIdentifierPaths, - YulIfStatement, - YulLeaveStatement, - YulLiteral, - YulParameters, - YulParametersDeclaration, - YulReturnVariables, - YulReturnsDeclaration, - YulStatement, - YulStatements, - YulSwitchCase, - YulSwitchCases, - YulSwitchStatement, - YulValueCase, - YulVariableDeclarationStatement, - YulVariableDeclarationValue, -} - #[derive( Debug, Eq, @@ -221,7 +18,9 @@ pub enum ProductionKind { #[cfg_attr(not(feature = "slang_napi_interfaces"), derive(Clone, Copy))] pub enum RuleKind { ABICoderPragma, + AdditiveExpression, AddressType, + AndExpression, ArgumentsDeclaration, ArrayExpression, ArrayTypeName, @@ -230,12 +29,16 @@ pub enum RuleKind { AssemblyFlags, AssemblyFlagsDeclaration, AssemblyStatement, - BinaryExpression, + AssignmentExpression, + BitwiseAndExpression, + BitwiseOrExpression, + BitwiseXorExpression, Block, BreakStatement, CatchClause, CatchClauseError, CatchClauses, + ComparisonExpression, ConditionalExpression, ConstantDefinition, ConstructorAttribute, @@ -254,6 +57,7 @@ pub enum RuleKind { EndOfFileTrivia, EnumDefinition, EnumMembers, + EqualityExpression, ErrorDefinition, ErrorParameter, ErrorParameters, @@ -264,6 +68,7 @@ pub enum RuleKind { EventParametersDeclaration, ExperimentalFeature, ExperimentalPragma, + ExponentiationExpression, Expression, ExpressionStatement, FallbackFunctionAttribute, @@ -312,6 +117,7 @@ pub enum RuleKind { ModifierAttributes, ModifierDefinition, ModifierInvocation, + MultiplicativeExpression, NamedArgument, NamedArgumentGroup, NamedArgumentGroups, @@ -320,6 +126,7 @@ pub enum RuleKind { NamedImport, NewExpression, NumberUnit, + OrExpression, OverridePaths, OverridePathsDeclaration, OverrideSpecifier, @@ -329,14 +136,17 @@ pub enum RuleKind { PathImport, PositionalArguments, PositionalArgumentsDeclaration, + PostfixExpression, Pragma, PragmaDirective, + PrefixExpression, ReceiveFunctionAttribute, ReceiveFunctionAttributes, ReceiveFunctionDefinition, ReturnStatement, ReturnsDeclaration, RevertStatement, + ShiftExpression, SourceUnit, SourceUnitMember, SourceUnitMembers, @@ -364,8 +174,6 @@ pub enum RuleKind { TypeExpression, TypeName, TypedTupleMember, - UnaryPostfixExpression, - UnaryPrefixExpression, UncheckedBlock, UnicodeStringLiterals, UnnamedFunctionAttribute, @@ -385,11 +193,12 @@ pub enum RuleKind { VariableDeclarationType, VariableDeclarationValue, VersionPragma, - VersionPragmaBinaryExpression, VersionPragmaExpression, VersionPragmaExpressions, + VersionPragmaOrExpression, + VersionPragmaPrefixExpression, + VersionPragmaRangeExpression, VersionPragmaSpecifier, - VersionPragmaUnaryExpression, WhileStatement, YulArguments, YulAssignmentStatement, diff --git a/crates/solidity/outputs/npm/crate/src/generated/language.rs b/crates/solidity/outputs/npm/crate/src/generated/language.rs index f36c09558b..1467782a7d 100644 --- a/crates/solidity/outputs/npm/crate/src/generated/language.rs +++ b/crates/solidity/outputs/npm/crate/src/generated/language.rs @@ -17,7 +17,8 @@ pub use super::kinds::LexicalContext; #[cfg(feature = "slang_napi_interfaces")] use super::napi::napi_parse_output::ParseOutput as NAPIParseOutput; use super::{ - kinds::{IsLexicalContext, LexicalContextType, ProductionKind, RuleKind, TokenKind}, + cst, + kinds::{IsLexicalContext, LexicalContextType, RuleKind, TokenKind}, lexer::Lexer, parse_output::ParseOutput, support::{ @@ -206,6 +207,27 @@ impl Language { .with_kind(RuleKind::ABICoderPragma) } + #[allow(unused_assignments, unused_parens)] + fn additive_expression(&self, input: &mut ParserContext<'_>) -> ParserResult { + let result = self.expression(input); + let ParserResult::Match(r#match) = &result else { + return result; + }; + match &r#match.nodes[..] { + [cst::Node::Rule(node)] if node.kind == RuleKind::Expression => { + match &node.children[..] { + [inner @ cst::Node::Rule(rule)] + if rule.kind == RuleKind::AdditiveExpression => + { + ParserResult::r#match(vec![inner.clone()], r#match.expected_tokens.clone()) + } + _ => ParserResult::no_match(vec![]), + } + } + _ => ParserResult::no_match(vec![]), + } + } + #[allow(unused_assignments, unused_parens)] fn address_type(&self, input: &mut ParserContext<'_>) -> ParserResult { SequenceHelper::run(|mut seq| { @@ -224,6 +246,25 @@ impl Language { .with_kind(RuleKind::AddressType) } + #[allow(unused_assignments, unused_parens)] + fn and_expression(&self, input: &mut ParserContext<'_>) -> ParserResult { + let result = self.expression(input); + let ParserResult::Match(r#match) = &result else { + return result; + }; + match &r#match.nodes[..] { + [cst::Node::Rule(node)] if node.kind == RuleKind::Expression => { + match &node.children[..] { + [inner @ cst::Node::Rule(rule)] if rule.kind == RuleKind::AndExpression => { + ParserResult::r#match(vec![inner.clone()], r#match.expected_tokens.clone()) + } + _ => ParserResult::no_match(vec![]), + } + } + _ => ParserResult::no_match(vec![]), + } + } + #[allow(unused_assignments, unused_parens)] fn arguments_declaration(&self, input: &mut ParserContext<'_>) -> ParserResult { ChoiceHelper::run(input, |mut choice, input| { @@ -263,6 +304,25 @@ impl Language { .with_kind(RuleKind::ArrayExpression) } + #[allow(unused_assignments, unused_parens)] + fn array_type_name(&self, input: &mut ParserContext<'_>) -> ParserResult { + let result = self.type_name(input); + let ParserResult::Match(r#match) = &result else { + return result; + }; + match &r#match.nodes[..] { + [cst::Node::Rule(node)] if node.kind == RuleKind::TypeName => { + match &node.children[..] { + [inner @ cst::Node::Rule(rule)] if rule.kind == RuleKind::ArrayTypeName => { + ParserResult::r#match(vec![inner.clone()], r#match.expected_tokens.clone()) + } + _ => ParserResult::no_match(vec![]), + } + } + _ => ParserResult::no_match(vec![]), + } + } + #[allow(unused_assignments, unused_parens)] fn array_values(&self, input: &mut ParserContext<'_>) -> ParserResult { SeparatedHelper::run::<_, LexicalContextType::Default>( @@ -350,6 +410,90 @@ impl Language { .with_kind(RuleKind::AssemblyStatement) } + #[allow(unused_assignments, unused_parens)] + fn assignment_expression(&self, input: &mut ParserContext<'_>) -> ParserResult { + let result = self.expression(input); + let ParserResult::Match(r#match) = &result else { + return result; + }; + match &r#match.nodes[..] { + [cst::Node::Rule(node)] if node.kind == RuleKind::Expression => { + match &node.children[..] { + [inner @ cst::Node::Rule(rule)] + if rule.kind == RuleKind::AssignmentExpression => + { + ParserResult::r#match(vec![inner.clone()], r#match.expected_tokens.clone()) + } + _ => ParserResult::no_match(vec![]), + } + } + _ => ParserResult::no_match(vec![]), + } + } + + #[allow(unused_assignments, unused_parens)] + fn bitwise_and_expression(&self, input: &mut ParserContext<'_>) -> ParserResult { + let result = self.expression(input); + let ParserResult::Match(r#match) = &result else { + return result; + }; + match &r#match.nodes[..] { + [cst::Node::Rule(node)] if node.kind == RuleKind::Expression => { + match &node.children[..] { + [inner @ cst::Node::Rule(rule)] + if rule.kind == RuleKind::BitwiseAndExpression => + { + ParserResult::r#match(vec![inner.clone()], r#match.expected_tokens.clone()) + } + _ => ParserResult::no_match(vec![]), + } + } + _ => ParserResult::no_match(vec![]), + } + } + + #[allow(unused_assignments, unused_parens)] + fn bitwise_or_expression(&self, input: &mut ParserContext<'_>) -> ParserResult { + let result = self.expression(input); + let ParserResult::Match(r#match) = &result else { + return result; + }; + match &r#match.nodes[..] { + [cst::Node::Rule(node)] if node.kind == RuleKind::Expression => { + match &node.children[..] { + [inner @ cst::Node::Rule(rule)] + if rule.kind == RuleKind::BitwiseOrExpression => + { + ParserResult::r#match(vec![inner.clone()], r#match.expected_tokens.clone()) + } + _ => ParserResult::no_match(vec![]), + } + } + _ => ParserResult::no_match(vec![]), + } + } + + #[allow(unused_assignments, unused_parens)] + fn bitwise_xor_expression(&self, input: &mut ParserContext<'_>) -> ParserResult { + let result = self.expression(input); + let ParserResult::Match(r#match) = &result else { + return result; + }; + match &r#match.nodes[..] { + [cst::Node::Rule(node)] if node.kind == RuleKind::Expression => { + match &node.children[..] { + [inner @ cst::Node::Rule(rule)] + if rule.kind == RuleKind::BitwiseXorExpression => + { + ParserResult::r#match(vec![inner.clone()], r#match.expected_tokens.clone()) + } + _ => ParserResult::no_match(vec![]), + } + } + _ => ParserResult::no_match(vec![]), + } + } + #[allow(unused_assignments, unused_parens)] fn block(&self, input: &mut ParserContext<'_>) -> ParserResult { SequenceHelper::run(|mut seq| { @@ -448,6 +592,48 @@ impl Language { .with_kind(RuleKind::CatchClauses) } + #[allow(unused_assignments, unused_parens)] + fn comparison_expression(&self, input: &mut ParserContext<'_>) -> ParserResult { + let result = self.expression(input); + let ParserResult::Match(r#match) = &result else { + return result; + }; + match &r#match.nodes[..] { + [cst::Node::Rule(node)] if node.kind == RuleKind::Expression => { + match &node.children[..] { + [inner @ cst::Node::Rule(rule)] + if rule.kind == RuleKind::ComparisonExpression => + { + ParserResult::r#match(vec![inner.clone()], r#match.expected_tokens.clone()) + } + _ => ParserResult::no_match(vec![]), + } + } + _ => ParserResult::no_match(vec![]), + } + } + + #[allow(unused_assignments, unused_parens)] + fn conditional_expression(&self, input: &mut ParserContext<'_>) -> ParserResult { + let result = self.expression(input); + let ParserResult::Match(r#match) = &result else { + return result; + }; + match &r#match.nodes[..] { + [cst::Node::Rule(node)] if node.kind == RuleKind::Expression => { + match &node.children[..] { + [inner @ cst::Node::Rule(rule)] + if rule.kind == RuleKind::ConditionalExpression => + { + ParserResult::r#match(vec![inner.clone()], r#match.expected_tokens.clone()) + } + _ => ParserResult::no_match(vec![]), + } + } + _ => ParserResult::no_match(vec![]), + } + } + #[allow(unused_assignments, unused_parens)] fn constant_definition(&self, input: &mut ParserContext<'_>) -> ParserResult { if self.version_is_at_least_0_7_4 { @@ -948,6 +1134,27 @@ impl Language { .with_kind(RuleKind::EnumMembers) } + #[allow(unused_assignments, unused_parens)] + fn equality_expression(&self, input: &mut ParserContext<'_>) -> ParserResult { + let result = self.expression(input); + let ParserResult::Match(r#match) = &result else { + return result; + }; + match &r#match.nodes[..] { + [cst::Node::Rule(node)] if node.kind == RuleKind::Expression => { + match &node.children[..] { + [inner @ cst::Node::Rule(rule)] + if rule.kind == RuleKind::EqualityExpression => + { + ParserResult::r#match(vec![inner.clone()], r#match.expected_tokens.clone()) + } + _ => ParserResult::no_match(vec![]), + } + } + _ => ParserResult::no_match(vec![]), + } + } + #[allow(unused_assignments, unused_parens)] fn error_definition(&self, input: &mut ParserContext<'_>) -> ParserResult { if self.version_is_at_least_0_8_4 { @@ -1177,12 +1384,32 @@ impl Language { .with_kind(RuleKind::ExperimentalPragma) } + #[allow(unused_assignments, unused_parens)] + fn exponentiation_expression(&self, input: &mut ParserContext<'_>) -> ParserResult { + let result = self.expression(input); + let ParserResult::Match(r#match) = &result else { + return result; + }; + match &r#match.nodes[..] { + [cst::Node::Rule(node)] if node.kind == RuleKind::Expression => { + match &node.children[..] { + [inner @ cst::Node::Rule(rule)] + if rule.kind == RuleKind::ExponentiationExpression => + { + ParserResult::r#match(vec![inner.clone()], r#match.expected_tokens.clone()) + } + _ => ParserResult::no_match(vec![]), + } + } + _ => ParserResult::no_match(vec![]), + } + } + #[allow(unused_assignments, unused_parens)] fn expression(&self, input: &mut ParserContext<'_>) -> ParserResult { - #[allow(unused_variables)] - let parse_assignment_expression = |input: &mut ParserContext<'_>| { + let parse_left_assignment_expression = |input: &mut ParserContext<'_>| { PrecedenceHelper::to_binary_operator( - RuleKind::BinaryExpression, + RuleKind::AssignmentExpression, 1u8, 1u8 + 1, ChoiceHelper::run(input, |mut choice, input| { @@ -1250,1610 +1477,326 @@ impl Language { }), ) }; - #[allow(unused_variables)] - let parse_assignment_expression = |input: &mut ParserContext<'_>| { - PrecedenceHelper::to_binary_operator( - RuleKind::BinaryExpression, + let parse_postfix_conditional_expression = |input: &mut ParserContext<'_>| { + PrecedenceHelper::to_postfix_operator( + RuleKind::ConditionalExpression, 3u8, - 3u8 + 1, - ChoiceHelper::run(input, |mut choice, input| { - let result = self.parse_token_with_trivia::( + SequenceHelper::run(|mut seq| { + seq.elem(self.parse_token_with_trivia::( input, - TokenKind::Equal, - ); - choice.consider(input, result)?; + TokenKind::QuestionMark, + ))?; + seq.elem(self.expression(input))?; + seq.elem(self.parse_token_with_trivia::( + input, + TokenKind::Colon, + ))?; + seq.elem(self.expression(input))?; + seq.finish() + }), + ) + }; + let parse_left_or_expression = |input: &mut ParserContext<'_>| { + PrecedenceHelper::to_binary_operator( + RuleKind::OrExpression, + 5u8, + 5u8 + 1, + self.parse_token_with_trivia::( + input, + TokenKind::BarBar, + ), + ) + }; + let parse_left_and_expression = |input: &mut ParserContext<'_>| { + PrecedenceHelper::to_binary_operator( + RuleKind::AndExpression, + 7u8, + 7u8 + 1, + self.parse_token_with_trivia::( + input, + TokenKind::AmpersandAmpersand, + ), + ) + }; + let parse_left_equality_expression = |input: &mut ParserContext<'_>| { + PrecedenceHelper::to_binary_operator( + RuleKind::EqualityExpression, + 9u8, + 9u8 + 1, + ChoiceHelper::run(input, |mut choice, input| { let result = self.parse_token_with_trivia::( input, - TokenKind::BarEqual, + TokenKind::EqualEqual, ); choice.consider(input, result)?; let result = self.parse_token_with_trivia::( input, - TokenKind::PlusEqual, + TokenKind::BangEqual, ); choice.consider(input, result)?; + choice.finish(input) + }), + ) + }; + let parse_left_comparison_expression = |input: &mut ParserContext<'_>| { + PrecedenceHelper::to_binary_operator( + RuleKind::ComparisonExpression, + 11u8, + 11u8 + 1, + ChoiceHelper::run(input, |mut choice, input| { let result = self.parse_token_with_trivia::( input, - TokenKind::MinusEqual, + TokenKind::LessThan, ); choice.consider(input, result)?; let result = self.parse_token_with_trivia::( input, - TokenKind::CaretEqual, + TokenKind::GreaterThan, ); choice.consider(input, result)?; let result = self.parse_token_with_trivia::( input, - TokenKind::SlashEqual, + TokenKind::LessThanEqual, ); choice.consider(input, result)?; let result = self.parse_token_with_trivia::( input, - TokenKind::PercentEqual, + TokenKind::GreaterThanEqual, ); choice.consider(input, result)?; + choice.finish(input) + }), + ) + }; + let parse_left_bitwise_or_expression = |input: &mut ParserContext<'_>| { + PrecedenceHelper::to_binary_operator( + RuleKind::BitwiseOrExpression, + 13u8, + 13u8 + 1, + self.parse_token_with_trivia::(input, TokenKind::Bar), + ) + }; + let parse_left_bitwise_xor_expression = |input: &mut ParserContext<'_>| { + PrecedenceHelper::to_binary_operator( + RuleKind::BitwiseXorExpression, + 15u8, + 15u8 + 1, + self.parse_token_with_trivia::( + input, + TokenKind::Caret, + ), + ) + }; + let parse_left_bitwise_and_expression = |input: &mut ParserContext<'_>| { + PrecedenceHelper::to_binary_operator( + RuleKind::BitwiseAndExpression, + 17u8, + 17u8 + 1, + self.parse_token_with_trivia::( + input, + TokenKind::Ampersand, + ), + ) + }; + let parse_left_shift_expression = |input: &mut ParserContext<'_>| { + PrecedenceHelper::to_binary_operator( + RuleKind::ShiftExpression, + 19u8, + 19u8 + 1, + ChoiceHelper::run(input, |mut choice, input| { let result = self.parse_token_with_trivia::( input, - TokenKind::AsteriskEqual, + TokenKind::LessThanLessThan, ); choice.consider(input, result)?; let result = self.parse_token_with_trivia::( input, - TokenKind::AmpersandEqual, + TokenKind::GreaterThanGreaterThan, ); choice.consider(input, result)?; let result = self.parse_token_with_trivia::( input, - TokenKind::LessThanLessThanEqual, + TokenKind::GreaterThanGreaterThanGreaterThan, ); choice.consider(input, result)?; + choice.finish(input) + }), + ) + }; + let parse_left_additive_expression = |input: &mut ParserContext<'_>| { + PrecedenceHelper::to_binary_operator( + RuleKind::AdditiveExpression, + 21u8, + 21u8 + 1, + ChoiceHelper::run(input, |mut choice, input| { let result = self.parse_token_with_trivia::( input, - TokenKind::GreaterThanGreaterThanEqual, + TokenKind::Plus, ); choice.consider(input, result)?; let result = self.parse_token_with_trivia::( input, - TokenKind::GreaterThanGreaterThanGreaterThanEqual, + TokenKind::Minus, ); choice.consider(input, result)?; choice.finish(input) }), ) }; - #[allow(unused_variables)] - let parse_assignment_expression = |input: &mut ParserContext<'_>| { + let parse_left_multiplicative_expression = |input: &mut ParserContext<'_>| { PrecedenceHelper::to_binary_operator( - RuleKind::BinaryExpression, - 5u8, - 5u8 + 1, + RuleKind::MultiplicativeExpression, + 23u8, + 23u8 + 1, ChoiceHelper::run(input, |mut choice, input| { let result = self.parse_token_with_trivia::( input, - TokenKind::Equal, + TokenKind::Asterisk, ); choice.consider(input, result)?; let result = self.parse_token_with_trivia::( input, - TokenKind::BarEqual, + TokenKind::Slash, ); choice.consider(input, result)?; let result = self.parse_token_with_trivia::( input, - TokenKind::PlusEqual, + TokenKind::Percent, ); choice.consider(input, result)?; + choice.finish(input) + }), + ) + }; + let parse_left_exponentiation_expression = |input: &mut ParserContext<'_>| { + PrecedenceHelper::to_binary_operator( + RuleKind::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::( + input, + TokenKind::AsteriskAsterisk, + ); + choice.consider(input, result)?; + } + choice.finish(input) + }), + ) + }; + let parse_right_exponentiation_expression = |input: &mut ParserContext<'_>| { + PrecedenceHelper::to_binary_operator( + RuleKind::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::( + input, + TokenKind::AsteriskAsterisk, + ); + choice.consider(input, result)?; + } + choice.finish(input) + }), + ) + }; + let parse_postfix_postfix_expression = |input: &mut ParserContext<'_>| { + PrecedenceHelper::to_postfix_operator( + RuleKind::PostfixExpression, + 29u8, + ChoiceHelper::run(input, |mut choice, input| { let result = self.parse_token_with_trivia::( input, - TokenKind::MinusEqual, + TokenKind::PlusPlus, ); choice.consider(input, result)?; let result = self.parse_token_with_trivia::( input, - TokenKind::CaretEqual, - ); - choice.consider(input, result)?; - let result = self.parse_token_with_trivia::( - input, - TokenKind::SlashEqual, - ); - choice.consider(input, result)?; - let result = self.parse_token_with_trivia::( - input, - TokenKind::PercentEqual, - ); - choice.consider(input, result)?; - let result = self.parse_token_with_trivia::( - input, - TokenKind::AsteriskEqual, - ); - choice.consider(input, result)?; - let result = self.parse_token_with_trivia::( - input, - TokenKind::AmpersandEqual, - ); - choice.consider(input, result)?; - let result = self.parse_token_with_trivia::( - input, - TokenKind::LessThanLessThanEqual, - ); - choice.consider(input, result)?; - let result = self.parse_token_with_trivia::( - input, - TokenKind::GreaterThanGreaterThanEqual, - ); - choice.consider(input, result)?; - let result = self.parse_token_with_trivia::( - input, - TokenKind::GreaterThanGreaterThanGreaterThanEqual, + TokenKind::MinusMinus, ); choice.consider(input, result)?; choice.finish(input) }), ) }; - #[allow(unused_variables)] - let parse_assignment_expression = |input: &mut ParserContext<'_>| { - PrecedenceHelper::to_binary_operator( - RuleKind::BinaryExpression, - 7u8, - 7u8 + 1, + let parse_prefix_prefix_expression = |input: &mut ParserContext<'_>| { + PrecedenceHelper::to_prefix_operator( + RuleKind::PrefixExpression, + 31u8, ChoiceHelper::run(input, |mut choice, input| { let result = self.parse_token_with_trivia::( input, - TokenKind::Equal, - ); - choice.consider(input, result)?; - let result = self.parse_token_with_trivia::( - input, - TokenKind::BarEqual, - ); - choice.consider(input, result)?; - let result = self.parse_token_with_trivia::( - input, - TokenKind::PlusEqual, - ); - choice.consider(input, result)?; - let result = self.parse_token_with_trivia::( - input, - TokenKind::MinusEqual, - ); - choice.consider(input, result)?; - let result = self.parse_token_with_trivia::( - input, - TokenKind::CaretEqual, - ); - choice.consider(input, result)?; - let result = self.parse_token_with_trivia::( - input, - TokenKind::SlashEqual, - ); - choice.consider(input, result)?; - let result = self.parse_token_with_trivia::( - input, - TokenKind::PercentEqual, - ); - choice.consider(input, result)?; - let result = self.parse_token_with_trivia::( - input, - TokenKind::AsteriskEqual, + TokenKind::PlusPlus, ); choice.consider(input, result)?; let result = self.parse_token_with_trivia::( input, - TokenKind::AmpersandEqual, + TokenKind::MinusMinus, ); choice.consider(input, result)?; let result = self.parse_token_with_trivia::( input, - TokenKind::LessThanLessThanEqual, + TokenKind::Tilde, ); choice.consider(input, result)?; let result = self.parse_token_with_trivia::( input, - TokenKind::GreaterThanGreaterThanEqual, + TokenKind::Bang, ); choice.consider(input, result)?; let result = self.parse_token_with_trivia::( input, - TokenKind::GreaterThanGreaterThanGreaterThanEqual, + TokenKind::Minus, ); choice.consider(input, result)?; + if !self.version_is_at_least_0_5_0 { + let result = self.parse_token_with_trivia::( + input, + TokenKind::Plus, + ); + choice.consider(input, result)?; + } choice.finish(input) }), ) }; - #[allow(unused_variables)] - let parse_assignment_expression = |input: &mut ParserContext<'_>| { - PrecedenceHelper::to_binary_operator( - RuleKind::BinaryExpression, - 9u8, - 9u8 + 1, - ChoiceHelper::run(input, |mut choice, input| { - let result = self.parse_token_with_trivia::( - input, - TokenKind::Equal, - ); - choice.consider(input, result)?; - let result = self.parse_token_with_trivia::( - input, - TokenKind::BarEqual, - ); - choice.consider(input, result)?; - let result = self.parse_token_with_trivia::( - input, - TokenKind::PlusEqual, - ); - choice.consider(input, result)?; - let result = self.parse_token_with_trivia::( - input, - TokenKind::MinusEqual, - ); - choice.consider(input, result)?; - let result = self.parse_token_with_trivia::( - input, - TokenKind::CaretEqual, - ); - choice.consider(input, result)?; - let result = self.parse_token_with_trivia::( - input, - TokenKind::SlashEqual, - ); - choice.consider(input, result)?; - let result = self.parse_token_with_trivia::( - input, - TokenKind::PercentEqual, - ); - choice.consider(input, result)?; - let result = self.parse_token_with_trivia::( - input, - TokenKind::AsteriskEqual, - ); - choice.consider(input, result)?; - let result = self.parse_token_with_trivia::( - input, - TokenKind::AmpersandEqual, - ); - choice.consider(input, result)?; - let result = self.parse_token_with_trivia::( - input, - TokenKind::LessThanLessThanEqual, - ); - choice.consider(input, result)?; - let result = self.parse_token_with_trivia::( - input, - TokenKind::GreaterThanGreaterThanEqual, - ); - choice.consider(input, result)?; - let result = self.parse_token_with_trivia::( - input, - TokenKind::GreaterThanGreaterThanGreaterThanEqual, - ); - choice.consider(input, result)?; - choice.finish(input) + let parse_postfix_function_call_expression = |input: &mut ParserContext<'_>| { + PrecedenceHelper::to_postfix_operator( + RuleKind::FunctionCallExpression, + 33u8, + SequenceHelper::run(|mut seq| { + if self.version_is_at_least_0_6_2 { + seq.elem(OptionalHelper::transform(self.function_call_options(input)))?; + } + seq.elem(self.arguments_declaration(input))?; + seq.finish() }), ) }; - #[allow(unused_variables)] - let parse_assignment_expression = |input: &mut ParserContext<'_>| { - PrecedenceHelper::to_binary_operator( - RuleKind::BinaryExpression, - 11u8, - 11u8 + 1, - ChoiceHelper::run(input, |mut choice, input| { - let result = self.parse_token_with_trivia::( - input, - TokenKind::Equal, - ); - choice.consider(input, result)?; - let result = self.parse_token_with_trivia::( - input, - TokenKind::BarEqual, - ); - choice.consider(input, result)?; - let result = self.parse_token_with_trivia::( - input, - TokenKind::PlusEqual, - ); - choice.consider(input, result)?; - let result = self.parse_token_with_trivia::( - input, - TokenKind::MinusEqual, - ); - choice.consider(input, result)?; - let result = self.parse_token_with_trivia::( - input, - TokenKind::CaretEqual, - ); - choice.consider(input, result)?; - let result = self.parse_token_with_trivia::( - input, - TokenKind::SlashEqual, - ); - choice.consider(input, result)?; - let result = self.parse_token_with_trivia::( - input, - TokenKind::PercentEqual, - ); - choice.consider(input, result)?; - let result = self.parse_token_with_trivia::( - input, - TokenKind::AsteriskEqual, - ); - choice.consider(input, result)?; - let result = self.parse_token_with_trivia::( - input, - TokenKind::AmpersandEqual, - ); - choice.consider(input, result)?; - let result = self.parse_token_with_trivia::( - input, - TokenKind::LessThanLessThanEqual, - ); - choice.consider(input, result)?; - let result = self.parse_token_with_trivia::( - input, - TokenKind::GreaterThanGreaterThanEqual, - ); - choice.consider(input, result)?; - let result = self.parse_token_with_trivia::( + let parse_postfix_member_access_expression = |input: &mut ParserContext<'_>| { + PrecedenceHelper::to_postfix_operator( + RuleKind::MemberAccessExpression, + 35u8, + SequenceHelper::run(|mut seq| { + seq.elem(self.parse_token_with_trivia::( input, - TokenKind::GreaterThanGreaterThanGreaterThanEqual, - ); - choice.consider(input, result)?; - choice.finish(input) + TokenKind::Period, + ))?; + seq.elem(self.member_access(input))?; + seq.finish() }), ) }; - #[allow(unused_variables)] - let parse_assignment_expression = |input: &mut ParserContext<'_>| { - PrecedenceHelper::to_binary_operator( - RuleKind::BinaryExpression, - 13u8, - 13u8 + 1, - ChoiceHelper::run(input, |mut choice, input| { - let result = self.parse_token_with_trivia::( - input, - TokenKind::Equal, - ); - choice.consider(input, result)?; - let result = self.parse_token_with_trivia::( - input, - TokenKind::BarEqual, - ); - choice.consider(input, result)?; - let result = self.parse_token_with_trivia::( - input, - TokenKind::PlusEqual, - ); - choice.consider(input, result)?; - let result = self.parse_token_with_trivia::( - input, - TokenKind::MinusEqual, - ); - choice.consider(input, result)?; - let result = self.parse_token_with_trivia::( - input, - TokenKind::CaretEqual, - ); - choice.consider(input, result)?; - let result = self.parse_token_with_trivia::( - input, - TokenKind::SlashEqual, - ); - choice.consider(input, result)?; - let result = self.parse_token_with_trivia::( - input, - TokenKind::PercentEqual, - ); - choice.consider(input, result)?; - let result = self.parse_token_with_trivia::( - input, - TokenKind::AsteriskEqual, - ); - choice.consider(input, result)?; - let result = self.parse_token_with_trivia::( - input, - TokenKind::AmpersandEqual, - ); - choice.consider(input, result)?; - let result = self.parse_token_with_trivia::( - input, - TokenKind::LessThanLessThanEqual, - ); - choice.consider(input, result)?; - let result = self.parse_token_with_trivia::( - input, - TokenKind::GreaterThanGreaterThanEqual, - ); - choice.consider(input, result)?; - let result = self.parse_token_with_trivia::( - input, - TokenKind::GreaterThanGreaterThanGreaterThanEqual, - ); - choice.consider(input, result)?; - choice.finish(input) - }), - ) - }; - #[allow(unused_variables)] - let parse_assignment_expression = |input: &mut ParserContext<'_>| { - PrecedenceHelper::to_binary_operator( - RuleKind::BinaryExpression, - 15u8, - 15u8 + 1, - ChoiceHelper::run(input, |mut choice, input| { - let result = self.parse_token_with_trivia::( - input, - TokenKind::Equal, - ); - choice.consider(input, result)?; - let result = self.parse_token_with_trivia::( - input, - TokenKind::BarEqual, - ); - choice.consider(input, result)?; - let result = self.parse_token_with_trivia::( - input, - TokenKind::PlusEqual, - ); - choice.consider(input, result)?; - let result = self.parse_token_with_trivia::( - input, - TokenKind::MinusEqual, - ); - choice.consider(input, result)?; - let result = self.parse_token_with_trivia::( - input, - TokenKind::CaretEqual, - ); - choice.consider(input, result)?; - let result = self.parse_token_with_trivia::( - input, - TokenKind::SlashEqual, - ); - choice.consider(input, result)?; - let result = self.parse_token_with_trivia::( - input, - TokenKind::PercentEqual, - ); - choice.consider(input, result)?; - let result = self.parse_token_with_trivia::( - input, - TokenKind::AsteriskEqual, - ); - choice.consider(input, result)?; - let result = self.parse_token_with_trivia::( - input, - TokenKind::AmpersandEqual, - ); - choice.consider(input, result)?; - let result = self.parse_token_with_trivia::( - input, - TokenKind::LessThanLessThanEqual, - ); - choice.consider(input, result)?; - let result = self.parse_token_with_trivia::( - input, - TokenKind::GreaterThanGreaterThanEqual, - ); - choice.consider(input, result)?; - let result = self.parse_token_with_trivia::( - input, - TokenKind::GreaterThanGreaterThanGreaterThanEqual, - ); - choice.consider(input, result)?; - choice.finish(input) - }), - ) - }; - #[allow(unused_variables)] - let parse_assignment_expression = |input: &mut ParserContext<'_>| { - PrecedenceHelper::to_binary_operator( - RuleKind::BinaryExpression, - 17u8, - 17u8 + 1, - ChoiceHelper::run(input, |mut choice, input| { - let result = self.parse_token_with_trivia::( - input, - TokenKind::Equal, - ); - choice.consider(input, result)?; - let result = self.parse_token_with_trivia::( - input, - TokenKind::BarEqual, - ); - choice.consider(input, result)?; - let result = self.parse_token_with_trivia::( - input, - TokenKind::PlusEqual, - ); - choice.consider(input, result)?; - let result = self.parse_token_with_trivia::( - input, - TokenKind::MinusEqual, - ); - choice.consider(input, result)?; - let result = self.parse_token_with_trivia::( - input, - TokenKind::CaretEqual, - ); - choice.consider(input, result)?; - let result = self.parse_token_with_trivia::( - input, - TokenKind::SlashEqual, - ); - choice.consider(input, result)?; - let result = self.parse_token_with_trivia::( - input, - TokenKind::PercentEqual, - ); - choice.consider(input, result)?; - let result = self.parse_token_with_trivia::( - input, - TokenKind::AsteriskEqual, - ); - choice.consider(input, result)?; - let result = self.parse_token_with_trivia::( - input, - TokenKind::AmpersandEqual, - ); - choice.consider(input, result)?; - let result = self.parse_token_with_trivia::( - input, - TokenKind::LessThanLessThanEqual, - ); - choice.consider(input, result)?; - let result = self.parse_token_with_trivia::( - input, - TokenKind::GreaterThanGreaterThanEqual, - ); - choice.consider(input, result)?; - let result = self.parse_token_with_trivia::( - input, - TokenKind::GreaterThanGreaterThanGreaterThanEqual, - ); - choice.consider(input, result)?; - choice.finish(input) - }), - ) - }; - #[allow(unused_variables)] - let parse_assignment_expression = |input: &mut ParserContext<'_>| { - PrecedenceHelper::to_binary_operator( - RuleKind::BinaryExpression, - 19u8, - 19u8 + 1, - ChoiceHelper::run(input, |mut choice, input| { - let result = self.parse_token_with_trivia::( - input, - TokenKind::Equal, - ); - choice.consider(input, result)?; - let result = self.parse_token_with_trivia::( - input, - TokenKind::BarEqual, - ); - choice.consider(input, result)?; - let result = self.parse_token_with_trivia::( - input, - TokenKind::PlusEqual, - ); - choice.consider(input, result)?; - let result = self.parse_token_with_trivia::( - input, - TokenKind::MinusEqual, - ); - choice.consider(input, result)?; - let result = self.parse_token_with_trivia::( - input, - TokenKind::CaretEqual, - ); - choice.consider(input, result)?; - let result = self.parse_token_with_trivia::( - input, - TokenKind::SlashEqual, - ); - choice.consider(input, result)?; - let result = self.parse_token_with_trivia::( - input, - TokenKind::PercentEqual, - ); - choice.consider(input, result)?; - let result = self.parse_token_with_trivia::( - input, - TokenKind::AsteriskEqual, - ); - choice.consider(input, result)?; - let result = self.parse_token_with_trivia::( - input, - TokenKind::AmpersandEqual, - ); - choice.consider(input, result)?; - let result = self.parse_token_with_trivia::( - input, - TokenKind::LessThanLessThanEqual, - ); - choice.consider(input, result)?; - let result = self.parse_token_with_trivia::( - input, - TokenKind::GreaterThanGreaterThanEqual, - ); - choice.consider(input, result)?; - let result = self.parse_token_with_trivia::( - input, - TokenKind::GreaterThanGreaterThanGreaterThanEqual, - ); - choice.consider(input, result)?; - choice.finish(input) - }), - ) - }; - #[allow(unused_variables)] - let parse_assignment_expression = |input: &mut ParserContext<'_>| { - PrecedenceHelper::to_binary_operator( - RuleKind::BinaryExpression, - 21u8, - 21u8 + 1, - ChoiceHelper::run(input, |mut choice, input| { - let result = self.parse_token_with_trivia::( - input, - TokenKind::Equal, - ); - choice.consider(input, result)?; - let result = self.parse_token_with_trivia::( - input, - TokenKind::BarEqual, - ); - choice.consider(input, result)?; - let result = self.parse_token_with_trivia::( - input, - TokenKind::PlusEqual, - ); - choice.consider(input, result)?; - let result = self.parse_token_with_trivia::( - input, - TokenKind::MinusEqual, - ); - choice.consider(input, result)?; - let result = self.parse_token_with_trivia::( - input, - TokenKind::CaretEqual, - ); - choice.consider(input, result)?; - let result = self.parse_token_with_trivia::( - input, - TokenKind::SlashEqual, - ); - choice.consider(input, result)?; - let result = self.parse_token_with_trivia::( - input, - TokenKind::PercentEqual, - ); - choice.consider(input, result)?; - let result = self.parse_token_with_trivia::( - input, - TokenKind::AsteriskEqual, - ); - choice.consider(input, result)?; - let result = self.parse_token_with_trivia::( - input, - TokenKind::AmpersandEqual, - ); - choice.consider(input, result)?; - let result = self.parse_token_with_trivia::( - input, - TokenKind::LessThanLessThanEqual, - ); - choice.consider(input, result)?; - let result = self.parse_token_with_trivia::( - input, - TokenKind::GreaterThanGreaterThanEqual, - ); - choice.consider(input, result)?; - let result = self.parse_token_with_trivia::( - input, - TokenKind::GreaterThanGreaterThanGreaterThanEqual, - ); - choice.consider(input, result)?; - choice.finish(input) - }), - ) - }; - #[allow(unused_variables)] - let parse_assignment_expression = |input: &mut ParserContext<'_>| { - PrecedenceHelper::to_binary_operator( - RuleKind::BinaryExpression, - 23u8, - 23u8 + 1, - ChoiceHelper::run(input, |mut choice, input| { - let result = self.parse_token_with_trivia::( - input, - TokenKind::Equal, - ); - choice.consider(input, result)?; - let result = self.parse_token_with_trivia::( - input, - TokenKind::BarEqual, - ); - choice.consider(input, result)?; - let result = self.parse_token_with_trivia::( - input, - TokenKind::PlusEqual, - ); - choice.consider(input, result)?; - let result = self.parse_token_with_trivia::( - input, - TokenKind::MinusEqual, - ); - choice.consider(input, result)?; - let result = self.parse_token_with_trivia::( - input, - TokenKind::CaretEqual, - ); - choice.consider(input, result)?; - let result = self.parse_token_with_trivia::( - input, - TokenKind::SlashEqual, - ); - choice.consider(input, result)?; - let result = self.parse_token_with_trivia::( - input, - TokenKind::PercentEqual, - ); - choice.consider(input, result)?; - let result = self.parse_token_with_trivia::( - input, - TokenKind::AsteriskEqual, - ); - choice.consider(input, result)?; - let result = self.parse_token_with_trivia::( - input, - TokenKind::AmpersandEqual, - ); - choice.consider(input, result)?; - let result = self.parse_token_with_trivia::( - input, - TokenKind::LessThanLessThanEqual, - ); - choice.consider(input, result)?; - let result = self.parse_token_with_trivia::( - input, - TokenKind::GreaterThanGreaterThanEqual, - ); - choice.consider(input, result)?; - let result = self.parse_token_with_trivia::( - input, - TokenKind::GreaterThanGreaterThanGreaterThanEqual, - ); - choice.consider(input, result)?; - choice.finish(input) - }), - ) - }; - #[allow(unused_variables)] - let parse_conditional_expression = |input: &mut ParserContext<'_>| { - PrecedenceHelper::to_postfix_operator( - RuleKind::ConditionalExpression, - 25u8, - SequenceHelper::run(|mut seq| { - seq.elem(self.parse_token_with_trivia::( - input, - TokenKind::QuestionMark, - ))?; - seq.elem(self.expression(input))?; - seq.elem(self.parse_token_with_trivia::( - input, - TokenKind::Colon, - ))?; - seq.elem(self.expression(input))?; - seq.finish() - }), - ) - }; - #[allow(unused_variables)] - let parse_or_expression = |input: &mut ParserContext<'_>| { - PrecedenceHelper::to_binary_operator( - RuleKind::BinaryExpression, - 27u8, - 27u8 + 1, - self.parse_token_with_trivia::( - input, - TokenKind::BarBar, - ), - ) - }; - #[allow(unused_variables)] - let parse_and_expression = |input: &mut ParserContext<'_>| { - PrecedenceHelper::to_binary_operator( - RuleKind::BinaryExpression, - 29u8, - 29u8 + 1, - self.parse_token_with_trivia::( - input, - TokenKind::AmpersandAmpersand, - ), - ) - }; - #[allow(unused_variables)] - let parse_equality_expression = |input: &mut ParserContext<'_>| { - PrecedenceHelper::to_binary_operator( - RuleKind::BinaryExpression, - 31u8, - 31u8 + 1, - ChoiceHelper::run(input, |mut choice, input| { - let result = self.parse_token_with_trivia::( - input, - TokenKind::EqualEqual, - ); - choice.consider(input, result)?; - let result = self.parse_token_with_trivia::( - input, - TokenKind::BangEqual, - ); - choice.consider(input, result)?; - choice.finish(input) - }), - ) - }; - #[allow(unused_variables)] - let parse_equality_expression = |input: &mut ParserContext<'_>| { - PrecedenceHelper::to_binary_operator( - RuleKind::BinaryExpression, - 33u8, - 33u8 + 1, - ChoiceHelper::run(input, |mut choice, input| { - let result = self.parse_token_with_trivia::( - input, - TokenKind::EqualEqual, - ); - choice.consider(input, result)?; - let result = self.parse_token_with_trivia::( - input, - TokenKind::BangEqual, - ); - choice.consider(input, result)?; - choice.finish(input) - }), - ) - }; - #[allow(unused_variables)] - let parse_comparison_expression = |input: &mut ParserContext<'_>| { - PrecedenceHelper::to_binary_operator( - RuleKind::BinaryExpression, - 35u8, - 35u8 + 1, - ChoiceHelper::run(input, |mut choice, input| { - let result = self.parse_token_with_trivia::( - input, - TokenKind::LessThan, - ); - choice.consider(input, result)?; - let result = self.parse_token_with_trivia::( - input, - TokenKind::GreaterThan, - ); - choice.consider(input, result)?; - let result = self.parse_token_with_trivia::( - input, - TokenKind::LessThanEqual, - ); - choice.consider(input, result)?; - let result = self.parse_token_with_trivia::( - input, - TokenKind::GreaterThanEqual, - ); - choice.consider(input, result)?; - choice.finish(input) - }), - ) - }; - #[allow(unused_variables)] - let parse_comparison_expression = |input: &mut ParserContext<'_>| { - PrecedenceHelper::to_binary_operator( - RuleKind::BinaryExpression, - 37u8, - 37u8 + 1, - ChoiceHelper::run(input, |mut choice, input| { - let result = self.parse_token_with_trivia::( - input, - TokenKind::LessThan, - ); - choice.consider(input, result)?; - let result = self.parse_token_with_trivia::( - input, - TokenKind::GreaterThan, - ); - choice.consider(input, result)?; - let result = self.parse_token_with_trivia::( - input, - TokenKind::LessThanEqual, - ); - choice.consider(input, result)?; - let result = self.parse_token_with_trivia::( - input, - TokenKind::GreaterThanEqual, - ); - choice.consider(input, result)?; - choice.finish(input) - }), - ) - }; - #[allow(unused_variables)] - let parse_comparison_expression = |input: &mut ParserContext<'_>| { - PrecedenceHelper::to_binary_operator( - RuleKind::BinaryExpression, - 39u8, - 39u8 + 1, - ChoiceHelper::run(input, |mut choice, input| { - let result = self.parse_token_with_trivia::( - input, - TokenKind::LessThan, - ); - choice.consider(input, result)?; - let result = self.parse_token_with_trivia::( - input, - TokenKind::GreaterThan, - ); - choice.consider(input, result)?; - let result = self.parse_token_with_trivia::( - input, - TokenKind::LessThanEqual, - ); - choice.consider(input, result)?; - let result = self.parse_token_with_trivia::( - input, - TokenKind::GreaterThanEqual, - ); - choice.consider(input, result)?; - choice.finish(input) - }), - ) - }; - #[allow(unused_variables)] - let parse_comparison_expression = |input: &mut ParserContext<'_>| { - PrecedenceHelper::to_binary_operator( - RuleKind::BinaryExpression, - 41u8, - 41u8 + 1, - ChoiceHelper::run(input, |mut choice, input| { - let result = self.parse_token_with_trivia::( - input, - TokenKind::LessThan, - ); - choice.consider(input, result)?; - let result = self.parse_token_with_trivia::( - input, - TokenKind::GreaterThan, - ); - choice.consider(input, result)?; - let result = self.parse_token_with_trivia::( - input, - TokenKind::LessThanEqual, - ); - choice.consider(input, result)?; - let result = self.parse_token_with_trivia::( - input, - TokenKind::GreaterThanEqual, - ); - choice.consider(input, result)?; - choice.finish(input) - }), - ) - }; - #[allow(unused_variables)] - let parse_bitwise_or_expression = |input: &mut ParserContext<'_>| { - PrecedenceHelper::to_binary_operator( - RuleKind::BinaryExpression, - 43u8, - 43u8 + 1, - self.parse_token_with_trivia::(input, TokenKind::Bar), - ) - }; - #[allow(unused_variables)] - let parse_bitwise_xor_expression = |input: &mut ParserContext<'_>| { - PrecedenceHelper::to_binary_operator( - RuleKind::BinaryExpression, - 45u8, - 45u8 + 1, - self.parse_token_with_trivia::( - input, - TokenKind::Caret, - ), - ) - }; - #[allow(unused_variables)] - let parse_bitwise_and_expression = |input: &mut ParserContext<'_>| { - PrecedenceHelper::to_binary_operator( - RuleKind::BinaryExpression, - 47u8, - 47u8 + 1, - self.parse_token_with_trivia::( - input, - TokenKind::Ampersand, - ), - ) - }; - #[allow(unused_variables)] - let parse_shift_expression = |input: &mut ParserContext<'_>| { - PrecedenceHelper::to_binary_operator( - RuleKind::BinaryExpression, - 49u8, - 49u8 + 1, - ChoiceHelper::run(input, |mut choice, input| { - let result = self.parse_token_with_trivia::( - input, - TokenKind::LessThanLessThan, - ); - choice.consider(input, result)?; - let result = self.parse_token_with_trivia::( - input, - TokenKind::GreaterThanGreaterThan, - ); - choice.consider(input, result)?; - let result = self.parse_token_with_trivia::( - input, - TokenKind::GreaterThanGreaterThanGreaterThan, - ); - choice.consider(input, result)?; - choice.finish(input) - }), - ) - }; - #[allow(unused_variables)] - let parse_shift_expression = |input: &mut ParserContext<'_>| { - PrecedenceHelper::to_binary_operator( - RuleKind::BinaryExpression, - 51u8, - 51u8 + 1, - ChoiceHelper::run(input, |mut choice, input| { - let result = self.parse_token_with_trivia::( - input, - TokenKind::LessThanLessThan, - ); - choice.consider(input, result)?; - let result = self.parse_token_with_trivia::( - input, - TokenKind::GreaterThanGreaterThan, - ); - choice.consider(input, result)?; - let result = self.parse_token_with_trivia::( - input, - TokenKind::GreaterThanGreaterThanGreaterThan, - ); - choice.consider(input, result)?; - choice.finish(input) - }), - ) - }; - #[allow(unused_variables)] - let parse_shift_expression = |input: &mut ParserContext<'_>| { - PrecedenceHelper::to_binary_operator( - RuleKind::BinaryExpression, - 53u8, - 53u8 + 1, - ChoiceHelper::run(input, |mut choice, input| { - let result = self.parse_token_with_trivia::( - input, - TokenKind::LessThanLessThan, - ); - choice.consider(input, result)?; - let result = self.parse_token_with_trivia::( - input, - TokenKind::GreaterThanGreaterThan, - ); - choice.consider(input, result)?; - let result = self.parse_token_with_trivia::( - input, - TokenKind::GreaterThanGreaterThanGreaterThan, - ); - choice.consider(input, result)?; - choice.finish(input) - }), - ) - }; - #[allow(unused_variables)] - let parse_additive_expression = |input: &mut ParserContext<'_>| { - PrecedenceHelper::to_binary_operator( - RuleKind::BinaryExpression, - 55u8, - 55u8 + 1, - ChoiceHelper::run(input, |mut choice, input| { - let result = self.parse_token_with_trivia::( - input, - TokenKind::Plus, - ); - choice.consider(input, result)?; - let result = self.parse_token_with_trivia::( - input, - TokenKind::Minus, - ); - choice.consider(input, result)?; - choice.finish(input) - }), - ) - }; - #[allow(unused_variables)] - let parse_additive_expression = |input: &mut ParserContext<'_>| { - PrecedenceHelper::to_binary_operator( - RuleKind::BinaryExpression, - 57u8, - 57u8 + 1, - ChoiceHelper::run(input, |mut choice, input| { - let result = self.parse_token_with_trivia::( - input, - TokenKind::Plus, - ); - choice.consider(input, result)?; - let result = self.parse_token_with_trivia::( - input, - TokenKind::Minus, - ); - choice.consider(input, result)?; - choice.finish(input) - }), - ) - }; - #[allow(unused_variables)] - let parse_multiplicative_expression = |input: &mut ParserContext<'_>| { - PrecedenceHelper::to_binary_operator( - RuleKind::BinaryExpression, - 59u8, - 59u8 + 1, - ChoiceHelper::run(input, |mut choice, input| { - let result = self.parse_token_with_trivia::( - input, - TokenKind::Asterisk, - ); - choice.consider(input, result)?; - let result = self.parse_token_with_trivia::( - input, - TokenKind::Slash, - ); - choice.consider(input, result)?; - let result = self.parse_token_with_trivia::( - input, - TokenKind::Percent, - ); - choice.consider(input, result)?; - choice.finish(input) - }), - ) - }; - #[allow(unused_variables)] - let parse_multiplicative_expression = |input: &mut ParserContext<'_>| { - PrecedenceHelper::to_binary_operator( - RuleKind::BinaryExpression, - 61u8, - 61u8 + 1, - ChoiceHelper::run(input, |mut choice, input| { - let result = self.parse_token_with_trivia::( - input, - TokenKind::Asterisk, - ); - choice.consider(input, result)?; - let result = self.parse_token_with_trivia::( - input, - TokenKind::Slash, - ); - choice.consider(input, result)?; - let result = self.parse_token_with_trivia::( - input, - TokenKind::Percent, - ); - choice.consider(input, result)?; - choice.finish(input) - }), - ) - }; - #[allow(unused_variables)] - let parse_multiplicative_expression = |input: &mut ParserContext<'_>| { - PrecedenceHelper::to_binary_operator( - RuleKind::BinaryExpression, - 63u8, - 63u8 + 1, - ChoiceHelper::run(input, |mut choice, input| { - let result = self.parse_token_with_trivia::( - input, - TokenKind::Asterisk, - ); - choice.consider(input, result)?; - let result = self.parse_token_with_trivia::( - input, - TokenKind::Slash, - ); - choice.consider(input, result)?; - let result = self.parse_token_with_trivia::( - input, - TokenKind::Percent, - ); - choice.consider(input, result)?; - choice.finish(input) - }), - ) - }; - #[allow(unused_variables)] - let parse_exponentiation_expression_removed_from_0_6_0 = |input: &mut ParserContext<'_>| { - PrecedenceHelper::to_binary_operator( - RuleKind::BinaryExpression, - 65u8, - 65u8 + 1, - ChoiceHelper::run(input, |mut choice, input| { - if !self.version_is_at_least_0_6_0 { - let result = self.parse_token_with_trivia::( - input, - TokenKind::AsteriskAsterisk, - ); - choice.consider(input, result)?; - } - if self.version_is_at_least_0_6_0 { - let result = self.parse_token_with_trivia::( - input, - TokenKind::AsteriskAsterisk, - ); - choice.consider(input, result)?; - } - choice.finish(input) - }), - ) - }; - #[allow(unused_variables)] - let parse_exponentiation_expression_introduced_from_0_6_0 = |input: &mut ParserContext< - '_, - >| { - PrecedenceHelper::to_binary_operator( - RuleKind::BinaryExpression, - 67u8 + 1, - 67u8, - ChoiceHelper::run(input, |mut choice, input| { - if !self.version_is_at_least_0_6_0 { - let result = self.parse_token_with_trivia::( - input, - TokenKind::AsteriskAsterisk, - ); - choice.consider(input, result)?; - } - if self.version_is_at_least_0_6_0 { - let result = self.parse_token_with_trivia::( - input, - TokenKind::AsteriskAsterisk, - ); - choice.consider(input, result)?; - } - choice.finish(input) - }), - ) - }; - #[allow(unused_variables)] - let parse_postfix_expression = |input: &mut ParserContext<'_>| { - PrecedenceHelper::to_postfix_operator( - RuleKind::UnaryPostfixExpression, - 69u8, - ChoiceHelper::run(input, |mut choice, input| { - let result = self.parse_token_with_trivia::( - input, - TokenKind::PlusPlus, - ); - choice.consider(input, result)?; - let result = self.parse_token_with_trivia::( - input, - TokenKind::MinusMinus, - ); - choice.consider(input, result)?; - choice.finish(input) - }), - ) - }; - #[allow(unused_variables)] - let parse_postfix_expression = |input: &mut ParserContext<'_>| { - PrecedenceHelper::to_postfix_operator( - RuleKind::UnaryPostfixExpression, - 71u8, - ChoiceHelper::run(input, |mut choice, input| { - let result = self.parse_token_with_trivia::( - input, - TokenKind::PlusPlus, - ); - choice.consider(input, result)?; - let result = self.parse_token_with_trivia::( - input, - TokenKind::MinusMinus, - ); - choice.consider(input, result)?; - choice.finish(input) - }), - ) - }; - #[allow(unused_variables)] - let parse_prefix_expression = |input: &mut ParserContext<'_>| { - PrecedenceHelper::to_prefix_operator( - RuleKind::UnaryPrefixExpression, - 73u8, - ChoiceHelper::run(input, |mut choice, input| { - let result = self.parse_token_with_trivia::( - input, - TokenKind::PlusPlus, - ); - choice.consider(input, result)?; - let result = self.parse_token_with_trivia::( - input, - TokenKind::MinusMinus, - ); - choice.consider(input, result)?; - let result = self.parse_token_with_trivia::( - input, - TokenKind::Tilde, - ); - choice.consider(input, result)?; - let result = self.parse_token_with_trivia::( - input, - TokenKind::Bang, - ); - choice.consider(input, result)?; - let result = self.parse_token_with_trivia::( - input, - TokenKind::Minus, - ); - choice.consider(input, result)?; - if !self.version_is_at_least_0_5_0 { - let result = self.parse_token_with_trivia::( - input, - TokenKind::Plus, - ); - choice.consider(input, result)?; - } - choice.finish(input) - }), - ) - }; - #[allow(unused_variables)] - let parse_prefix_expression = |input: &mut ParserContext<'_>| { - PrecedenceHelper::to_prefix_operator( - RuleKind::UnaryPrefixExpression, - 75u8, - ChoiceHelper::run(input, |mut choice, input| { - let result = self.parse_token_with_trivia::( - input, - TokenKind::PlusPlus, - ); - choice.consider(input, result)?; - let result = self.parse_token_with_trivia::( - input, - TokenKind::MinusMinus, - ); - choice.consider(input, result)?; - let result = self.parse_token_with_trivia::( - input, - TokenKind::Tilde, - ); - choice.consider(input, result)?; - let result = self.parse_token_with_trivia::( - input, - TokenKind::Bang, - ); - choice.consider(input, result)?; - let result = self.parse_token_with_trivia::( - input, - TokenKind::Minus, - ); - choice.consider(input, result)?; - if !self.version_is_at_least_0_5_0 { - let result = self.parse_token_with_trivia::( - input, - TokenKind::Plus, - ); - choice.consider(input, result)?; - } - choice.finish(input) - }), - ) - }; - #[allow(unused_variables)] - let parse_prefix_expression = |input: &mut ParserContext<'_>| { - PrecedenceHelper::to_prefix_operator( - RuleKind::UnaryPrefixExpression, - 77u8, - ChoiceHelper::run(input, |mut choice, input| { - let result = self.parse_token_with_trivia::( - input, - TokenKind::PlusPlus, - ); - choice.consider(input, result)?; - let result = self.parse_token_with_trivia::( - input, - TokenKind::MinusMinus, - ); - choice.consider(input, result)?; - let result = self.parse_token_with_trivia::( - input, - TokenKind::Tilde, - ); - choice.consider(input, result)?; - let result = self.parse_token_with_trivia::( - input, - TokenKind::Bang, - ); - choice.consider(input, result)?; - let result = self.parse_token_with_trivia::( - input, - TokenKind::Minus, - ); - choice.consider(input, result)?; - if !self.version_is_at_least_0_5_0 { - let result = self.parse_token_with_trivia::( - input, - TokenKind::Plus, - ); - choice.consider(input, result)?; - } - choice.finish(input) - }), - ) - }; - #[allow(unused_variables)] - let parse_prefix_expression = |input: &mut ParserContext<'_>| { - PrecedenceHelper::to_prefix_operator( - RuleKind::UnaryPrefixExpression, - 79u8, - ChoiceHelper::run(input, |mut choice, input| { - let result = self.parse_token_with_trivia::( - input, - TokenKind::PlusPlus, - ); - choice.consider(input, result)?; - let result = self.parse_token_with_trivia::( - input, - TokenKind::MinusMinus, - ); - choice.consider(input, result)?; - let result = self.parse_token_with_trivia::( - input, - TokenKind::Tilde, - ); - choice.consider(input, result)?; - let result = self.parse_token_with_trivia::( - input, - TokenKind::Bang, - ); - choice.consider(input, result)?; - let result = self.parse_token_with_trivia::( - input, - TokenKind::Minus, - ); - choice.consider(input, result)?; - if !self.version_is_at_least_0_5_0 { - let result = self.parse_token_with_trivia::( - input, - TokenKind::Plus, - ); - choice.consider(input, result)?; - } - choice.finish(input) - }), - ) - }; - #[allow(unused_variables)] - let parse_prefix_expression = |input: &mut ParserContext<'_>| { - PrecedenceHelper::to_prefix_operator( - RuleKind::UnaryPrefixExpression, - 81u8, - ChoiceHelper::run(input, |mut choice, input| { - let result = self.parse_token_with_trivia::( - input, - TokenKind::PlusPlus, - ); - choice.consider(input, result)?; - let result = self.parse_token_with_trivia::( - input, - TokenKind::MinusMinus, - ); - choice.consider(input, result)?; - let result = self.parse_token_with_trivia::( - input, - TokenKind::Tilde, - ); - choice.consider(input, result)?; - let result = self.parse_token_with_trivia::( - input, - TokenKind::Bang, - ); - choice.consider(input, result)?; - let result = self.parse_token_with_trivia::( - input, - TokenKind::Minus, - ); - choice.consider(input, result)?; - if !self.version_is_at_least_0_5_0 { - let result = self.parse_token_with_trivia::( - input, - TokenKind::Plus, - ); - choice.consider(input, result)?; - } - choice.finish(input) - }), - ) - }; - #[allow(unused_variables)] - let parse_prefix_expression_removed_from_0_5_0 = |input: &mut ParserContext<'_>| { - PrecedenceHelper::to_prefix_operator( - RuleKind::UnaryPrefixExpression, - 83u8, - ChoiceHelper::run(input, |mut choice, input| { - let result = self.parse_token_with_trivia::( - input, - TokenKind::PlusPlus, - ); - choice.consider(input, result)?; - let result = self.parse_token_with_trivia::( - input, - TokenKind::MinusMinus, - ); - choice.consider(input, result)?; - let result = self.parse_token_with_trivia::( - input, - TokenKind::Tilde, - ); - choice.consider(input, result)?; - let result = self.parse_token_with_trivia::( - input, - TokenKind::Bang, - ); - choice.consider(input, result)?; - let result = self.parse_token_with_trivia::( - input, - TokenKind::Minus, - ); - choice.consider(input, result)?; - if !self.version_is_at_least_0_5_0 { - let result = self.parse_token_with_trivia::( - input, - TokenKind::Plus, - ); - choice.consider(input, result)?; - } - choice.finish(input) - }), - ) - }; - #[allow(unused_variables)] - let parse_function_call_expression = |input: &mut ParserContext<'_>| { - PrecedenceHelper::to_postfix_operator( - RuleKind::FunctionCallExpression, - 85u8, - SequenceHelper::run(|mut seq| { - if self.version_is_at_least_0_6_2 { - seq.elem(OptionalHelper::transform(self.function_call_options(input)))?; - } - seq.elem(self.arguments_declaration(input))?; - seq.finish() - }), - ) - }; - #[allow(unused_variables)] - let parse_member_access_expression = |input: &mut ParserContext<'_>| { - PrecedenceHelper::to_postfix_operator( - RuleKind::MemberAccessExpression, - 87u8, - SequenceHelper::run(|mut seq| { - seq.elem(self.parse_token_with_trivia::( - input, - TokenKind::Period, - ))?; - seq.elem(self.member_access(input))?; - seq.finish() - }), - ) - }; - #[allow(unused_variables)] - let parse_index_access_expression = |input: &mut ParserContext<'_>| { - PrecedenceHelper::to_postfix_operator( - RuleKind::IndexAccessExpression, - 89u8, - SequenceHelper::run(|mut seq| { - let mut delim_guard = input.open_delim(TokenKind::CloseBracket); - let input = delim_guard.ctx(); - seq.elem(self.parse_token_with_trivia::( + let parse_postfix_index_access_expression = |input: &mut ParserContext<'_>| { + PrecedenceHelper::to_postfix_operator( + RuleKind::IndexAccessExpression, + 37u8, + SequenceHelper::run(|mut seq| { + let mut delim_guard = input.open_delim(TokenKind::CloseBracket); + let input = delim_guard.ctx(); + seq.elem(self.parse_token_with_trivia::( input, TokenKind::OpenBracket, ))?; @@ -2878,27 +1821,13 @@ impl Language { }), ) }; - #[allow(unused_variables)] let prefix_operator_parser = |input: &mut ParserContext<'_>| { ChoiceHelper::run(input, |mut choice, input| { - let result = parse_prefix_expression(input); - choice.consider(input, result)?; - let result = parse_prefix_expression(input); - choice.consider(input, result)?; - let result = parse_prefix_expression(input); + let result = parse_prefix_prefix_expression(input); choice.consider(input, result)?; - let result = parse_prefix_expression(input); - choice.consider(input, result)?; - let result = parse_prefix_expression(input); - choice.consider(input, result)?; - if !self.version_is_at_least_0_5_0 { - let result = parse_prefix_expression_removed_from_0_5_0(input); - choice.consider(input, result)?; - } choice.finish(input) }) }; - #[allow(unused_variables)] let primary_expression_parser = |input: &mut ParserContext<'_>| { ChoiceHelper::run(input, |mut choice, input| { let result = self.new_expression(input); @@ -2937,114 +1866,60 @@ impl Language { choice.finish(input) }) }; - #[allow(unused_variables)] - let postfix_operator_parser = |input: &mut ParserContext<'_>| { - ChoiceHelper::run(input, |mut choice, input| { - let result = parse_conditional_expression(input); - choice.consider(input, result)?; - let result = parse_postfix_expression(input); - choice.consider(input, result)?; - let result = parse_postfix_expression(input); - choice.consider(input, result)?; - let result = parse_function_call_expression(input); - choice.consider(input, result)?; - let result = parse_member_access_expression(input); - choice.consider(input, result)?; - let result = parse_index_access_expression(input); - choice.consider(input, result)?; - choice.finish(input) - }) - }; - #[allow(unused_variables)] - let binary_operand_parser = |input: &mut ParserContext<'_>| { - SequenceHelper::run(|mut seq| { - seq.elem(ZeroOrMoreHelper::run(input, |input| { - prefix_operator_parser(input) - }))?; - seq.elem(primary_expression_parser(input))?; - seq.elem(ZeroOrMoreHelper::run(input, |input| { - postfix_operator_parser(input) - }))?; - seq.finish() - }) - }; - #[allow(unused_variables)] - let binary_operator_parser = |input: &mut ParserContext<'_>| { - ChoiceHelper::run(input, |mut choice, input| { - let result = parse_assignment_expression(input); - choice.consider(input, result)?; - let result = parse_assignment_expression(input); - choice.consider(input, result)?; - let result = parse_assignment_expression(input); - choice.consider(input, result)?; - let result = parse_assignment_expression(input); - choice.consider(input, result)?; - let result = parse_assignment_expression(input); - choice.consider(input, result)?; - let result = parse_assignment_expression(input); - choice.consider(input, result)?; - let result = parse_assignment_expression(input); - choice.consider(input, result)?; - let result = parse_assignment_expression(input); - choice.consider(input, result)?; - let result = parse_assignment_expression(input); - choice.consider(input, result)?; - let result = parse_assignment_expression(input); - choice.consider(input, result)?; - let result = parse_assignment_expression(input); - choice.consider(input, result)?; - let result = parse_assignment_expression(input); - choice.consider(input, result)?; - let result = parse_or_expression(input); - choice.consider(input, result)?; - let result = parse_and_expression(input); + let postfix_operator_parser = |input: &mut ParserContext<'_>| { + ChoiceHelper::run(input, |mut choice, input| { + let result = parse_postfix_conditional_expression(input); choice.consider(input, result)?; - let result = parse_equality_expression(input); + let result = parse_postfix_postfix_expression(input); choice.consider(input, result)?; - let result = parse_equality_expression(input); + let result = parse_postfix_function_call_expression(input); choice.consider(input, result)?; - let result = parse_comparison_expression(input); + let result = parse_postfix_member_access_expression(input); choice.consider(input, result)?; - let result = parse_comparison_expression(input); + let result = parse_postfix_index_access_expression(input); choice.consider(input, result)?; - let result = parse_comparison_expression(input); + choice.finish(input) + }) + }; + let binary_operand_parser = |input: &mut ParserContext<'_>| { + SequenceHelper::run(|mut seq| { + seq.elem(ZeroOrMoreHelper::run(input, prefix_operator_parser))?; + seq.elem(primary_expression_parser(input))?; + seq.elem(ZeroOrMoreHelper::run(input, postfix_operator_parser))?; + seq.finish() + }) + }; + let binary_operator_parser = |input: &mut ParserContext<'_>| { + ChoiceHelper::run(input, |mut choice, input| { + let result = parse_left_assignment_expression(input); choice.consider(input, result)?; - let result = parse_comparison_expression(input); + let result = parse_left_or_expression(input); choice.consider(input, result)?; - let result = parse_bitwise_or_expression(input); + let result = parse_left_and_expression(input); choice.consider(input, result)?; - let result = parse_bitwise_xor_expression(input); + let result = parse_left_equality_expression(input); choice.consider(input, result)?; - let result = parse_bitwise_and_expression(input); + let result = parse_left_comparison_expression(input); choice.consider(input, result)?; - let result = parse_shift_expression(input); + let result = parse_left_bitwise_or_expression(input); choice.consider(input, result)?; - let result = parse_shift_expression(input); + let result = parse_left_bitwise_xor_expression(input); choice.consider(input, result)?; - let result = parse_shift_expression(input); + let result = parse_left_bitwise_and_expression(input); choice.consider(input, result)?; - let result = parse_additive_expression(input); + let result = parse_left_shift_expression(input); choice.consider(input, result)?; - let result = parse_additive_expression(input); + let result = parse_left_additive_expression(input); choice.consider(input, result)?; - let result = parse_multiplicative_expression(input); + let result = parse_left_multiplicative_expression(input); choice.consider(input, result)?; - let result = parse_multiplicative_expression(input); + let result = parse_left_exponentiation_expression(input); choice.consider(input, result)?; - let result = parse_multiplicative_expression(input); + let result = parse_right_exponentiation_expression(input); choice.consider(input, result)?; - if !self.version_is_at_least_0_6_0 { - let result = parse_exponentiation_expression_removed_from_0_6_0(input); - choice.consider(input, result)?; - } - if self.version_is_at_least_0_6_0 { - let result = parse_exponentiation_expression_introduced_from_0_6_0(input); - choice.consider(input, result)?; - } choice.finish(input) }) }; - #[allow(unused_variables)] let linear_expression_parser = |input: &mut ParserContext<'_>| { SequenceHelper::run(|mut seq| { seq.elem(binary_operand_parser(input))?; @@ -3059,7 +1934,7 @@ impl Language { }) }; PrecedenceHelper::reduce_precedence_result( - Some(RuleKind::Expression), + RuleKind::Expression, linear_expression_parser(input), ) .with_kind(RuleKind::Expression) @@ -3315,6 +2190,27 @@ impl Language { .with_kind(RuleKind::FunctionBody) } + #[allow(unused_assignments, unused_parens)] + fn function_call_expression(&self, input: &mut ParserContext<'_>) -> ParserResult { + let result = self.expression(input); + let ParserResult::Match(r#match) = &result else { + return result; + }; + match &r#match.nodes[..] { + [cst::Node::Rule(node)] if node.kind == RuleKind::Expression => { + match &node.children[..] { + [inner @ cst::Node::Rule(rule)] + if rule.kind == RuleKind::FunctionCallExpression => + { + ParserResult::r#match(vec![inner.clone()], r#match.expected_tokens.clone()) + } + _ => ParserResult::no_match(vec![]), + } + } + _ => ParserResult::no_match(vec![]), + } + } + #[allow(unused_assignments, unused_parens)] fn function_call_options(&self, input: &mut ParserContext<'_>) -> ParserResult { if self.version_is_at_least_0_6_2 { @@ -3654,6 +2550,27 @@ impl Language { .with_kind(RuleKind::IndexAccessEnd) } + #[allow(unused_assignments, unused_parens)] + fn index_access_expression(&self, input: &mut ParserContext<'_>) -> ParserResult { + let result = self.expression(input); + let ParserResult::Match(r#match) = &result else { + return result; + }; + match &r#match.nodes[..] { + [cst::Node::Rule(node)] if node.kind == RuleKind::Expression => { + match &node.children[..] { + [inner @ cst::Node::Rule(rule)] + if rule.kind == RuleKind::IndexAccessExpression => + { + ParserResult::r#match(vec![inner.clone()], r#match.expected_tokens.clone()) + } + _ => ParserResult::no_match(vec![]), + } + } + _ => ParserResult::no_match(vec![]), + } + } + #[allow(unused_assignments, unused_parens)] fn inheritance_specifier(&self, input: &mut ParserContext<'_>) -> ParserResult { SequenceHelper::run(|mut seq| { @@ -3907,6 +2824,27 @@ impl Language { .with_kind(RuleKind::MemberAccess) } + #[allow(unused_assignments, unused_parens)] + fn member_access_expression(&self, input: &mut ParserContext<'_>) -> ParserResult { + let result = self.expression(input); + let ParserResult::Match(r#match) = &result else { + return result; + }; + match &r#match.nodes[..] { + [cst::Node::Rule(node)] if node.kind == RuleKind::Expression => { + match &node.children[..] { + [inner @ cst::Node::Rule(rule)] + if rule.kind == RuleKind::MemberAccessExpression => + { + ParserResult::r#match(vec![inner.clone()], r#match.expected_tokens.clone()) + } + _ => ParserResult::no_match(vec![]), + } + } + _ => ParserResult::no_match(vec![]), + } + } + #[allow(unused_assignments, unused_parens)] fn modifier_attribute(&self, input: &mut ParserContext<'_>) -> ParserResult { ChoiceHelper::run(input, |mut choice, input| { @@ -3961,6 +2899,27 @@ impl Language { .with_kind(RuleKind::ModifierInvocation) } + #[allow(unused_assignments, unused_parens)] + fn multiplicative_expression(&self, input: &mut ParserContext<'_>) -> ParserResult { + let result = self.expression(input); + let ParserResult::Match(r#match) = &result else { + return result; + }; + match &r#match.nodes[..] { + [cst::Node::Rule(node)] if node.kind == RuleKind::Expression => { + match &node.children[..] { + [inner @ cst::Node::Rule(rule)] + if rule.kind == RuleKind::MultiplicativeExpression => + { + ParserResult::r#match(vec![inner.clone()], r#match.expected_tokens.clone()) + } + _ => ParserResult::no_match(vec![]), + } + } + _ => ParserResult::no_match(vec![]), + } + } + #[allow(unused_assignments, unused_parens)] fn named_argument(&self, input: &mut ParserContext<'_>) -> ParserResult { SequenceHelper::run(|mut seq| { @@ -4160,6 +3119,25 @@ impl Language { .with_kind(RuleKind::NumberUnit) } + #[allow(unused_assignments, unused_parens)] + fn or_expression(&self, input: &mut ParserContext<'_>) -> ParserResult { + let result = self.expression(input); + let ParserResult::Match(r#match) = &result else { + return result; + }; + match &r#match.nodes[..] { + [cst::Node::Rule(node)] if node.kind == RuleKind::Expression => { + match &node.children[..] { + [inner @ cst::Node::Rule(rule)] if rule.kind == RuleKind::OrExpression => { + ParserResult::r#match(vec![inner.clone()], r#match.expected_tokens.clone()) + } + _ => ParserResult::no_match(vec![]), + } + } + _ => ParserResult::no_match(vec![]), + } + } + #[allow(unused_assignments, unused_parens)] fn override_paths(&self, input: &mut ParserContext<'_>) -> ParserResult { SeparatedHelper::run::<_, LexicalContextType::Default>( @@ -4318,6 +3296,25 @@ impl Language { .with_kind(RuleKind::PositionalArgumentsDeclaration) } + #[allow(unused_assignments, unused_parens)] + fn postfix_expression(&self, input: &mut ParserContext<'_>) -> ParserResult { + let result = self.expression(input); + let ParserResult::Match(r#match) = &result else { + return result; + }; + match &r#match.nodes[..] { + [cst::Node::Rule(node)] if node.kind == RuleKind::Expression => { + match &node.children[..] { + [inner @ cst::Node::Rule(rule)] if rule.kind == RuleKind::PostfixExpression => { + ParserResult::r#match(vec![inner.clone()], r#match.expected_tokens.clone()) + } + _ => ParserResult::no_match(vec![]), + } + } + _ => ParserResult::no_match(vec![]), + } + } + #[allow(unused_assignments, unused_parens)] fn pragma(&self, input: &mut ParserContext<'_>) -> ParserResult { ChoiceHelper::run(input, |mut choice, input| { @@ -4360,6 +3357,25 @@ impl Language { .with_kind(RuleKind::PragmaDirective) } + #[allow(unused_assignments, unused_parens)] + fn prefix_expression(&self, input: &mut ParserContext<'_>) -> ParserResult { + let result = self.expression(input); + let ParserResult::Match(r#match) = &result else { + return result; + }; + match &r#match.nodes[..] { + [cst::Node::Rule(node)] if node.kind == RuleKind::Expression => { + match &node.children[..] { + [inner @ cst::Node::Rule(rule)] if rule.kind == RuleKind::PrefixExpression => { + ParserResult::r#match(vec![inner.clone()], r#match.expected_tokens.clone()) + } + _ => ParserResult::no_match(vec![]), + } + } + _ => ParserResult::no_match(vec![]), + } + } + #[allow(unused_assignments, unused_parens)] fn receive_function_attribute(&self, input: &mut ParserContext<'_>) -> ParserResult { if self.version_is_at_least_0_6_0 { @@ -4496,6 +3512,25 @@ impl Language { .with_kind(RuleKind::RevertStatement) } + #[allow(unused_assignments, unused_parens)] + fn shift_expression(&self, input: &mut ParserContext<'_>) -> ParserResult { + let result = self.expression(input); + let ParserResult::Match(r#match) = &result else { + return result; + }; + match &r#match.nodes[..] { + [cst::Node::Rule(node)] if node.kind == RuleKind::Expression => { + match &node.children[..] { + [inner @ cst::Node::Rule(rule)] if rule.kind == RuleKind::ShiftExpression => { + ParserResult::r#match(vec![inner.clone()], r#match.expected_tokens.clone()) + } + _ => ParserResult::no_match(vec![]), + } + } + _ => ParserResult::no_match(vec![]), + } + } + #[allow(unused_assignments, unused_parens)] fn source_unit(&self, input: &mut ParserContext<'_>) -> ParserResult { SequenceHelper::run(|mut seq| { @@ -5054,8 +4089,7 @@ impl Language { #[allow(unused_assignments, unused_parens)] fn type_name(&self, input: &mut ParserContext<'_>) -> ParserResult { - #[allow(unused_variables)] - let parse_array_type_name = |input: &mut ParserContext<'_>| { + let parse_postfix_array_type_name = |input: &mut ParserContext<'_>| { PrecedenceHelper::to_postfix_operator( RuleKind::ArrayTypeName, 1u8, @@ -5083,7 +4117,6 @@ impl Language { }), ) }; - #[allow(unused_variables)] let primary_expression_parser = |input: &mut ParserContext<'_>| { ChoiceHelper::run(input, |mut choice, input| { let result = self.function_type(input); @@ -5097,26 +4130,22 @@ impl Language { choice.finish(input) }) }; - #[allow(unused_variables)] let postfix_operator_parser = |input: &mut ParserContext<'_>| { ChoiceHelper::run(input, |mut choice, input| { - let result = parse_array_type_name(input); + let result = parse_postfix_array_type_name(input); choice.consider(input, result)?; choice.finish(input) }) }; - #[allow(unused_variables)] let linear_expression_parser = |input: &mut ParserContext<'_>| { SequenceHelper::run(|mut seq| { seq.elem(primary_expression_parser(input))?; - seq.elem(ZeroOrMoreHelper::run(input, |input| { - postfix_operator_parser(input) - }))?; + seq.elem(ZeroOrMoreHelper::run(input, postfix_operator_parser))?; seq.finish() }) }; PrecedenceHelper::reduce_precedence_result( - Some(RuleKind::TypeName), + RuleKind::TypeName, linear_expression_parser(input), ) .with_kind(RuleKind::TypeName) @@ -5413,486 +4442,213 @@ impl Language { RecoverFromNoMatch::No, ), )?; - seq.elem(self.parse_token_with_trivia::( - input, - TokenKind::Semicolon, - ))?; - seq.finish() - }) - .with_kind(RuleKind::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::( - input, - TokenKind::Ampersand, - ); - choice.consider(input, result)?; - let result = self.parse_token_with_trivia::( - input, - TokenKind::Asterisk, - ); - choice.consider(input, result)?; - let result = self.parse_token_with_trivia::( - input, - TokenKind::BangEqual, - ); - choice.consider(input, result)?; - let result = self - .parse_token_with_trivia::(input, TokenKind::Bar); - choice.consider(input, result)?; - let result = self.parse_token_with_trivia::( - input, - TokenKind::Caret, - ); - choice.consider(input, result)?; - let result = self.parse_token_with_trivia::( - input, - TokenKind::EqualEqual, - ); - choice.consider(input, result)?; - let result = self.parse_token_with_trivia::( - input, - TokenKind::GreaterThan, - ); - choice.consider(input, result)?; - let result = self.parse_token_with_trivia::( - input, - TokenKind::GreaterThanEqual, - ); - choice.consider(input, result)?; - let result = self.parse_token_with_trivia::( - input, - TokenKind::LessThan, - ); - choice.consider(input, result)?; - let result = self.parse_token_with_trivia::( - input, - TokenKind::LessThanEqual, - ); - choice.consider(input, result)?; - let result = self.parse_token_with_trivia::( - input, - TokenKind::Minus, - ); - choice.consider(input, result)?; - let result = self.parse_token_with_trivia::( - input, - TokenKind::Percent, - ); - choice.consider(input, result)?; - let result = self - .parse_token_with_trivia::(input, TokenKind::Plus); - choice.consider(input, result)?; - let result = self.parse_token_with_trivia::( - input, - TokenKind::Slash, - ); - choice.consider(input, result)?; - let result = self.parse_token_with_trivia::( - input, - TokenKind::Tilde, - ); - choice.consider(input, result)?; - choice.finish(input) - }) - } else { - ParserResult::disabled() - } - .with_kind(RuleKind::UsingOperator) - } - - #[allow(unused_assignments, unused_parens)] - fn using_target(&self, input: &mut ParserContext<'_>) -> ParserResult { - ChoiceHelper::run(input, |mut choice, input| { - let result = self.type_name(input); - choice.consider(input, result)?; - let result = self - .parse_token_with_trivia::(input, TokenKind::Asterisk); - choice.consider(input, result)?; - choice.finish(input) - }) - .with_kind(RuleKind::UsingTarget) - } - - #[allow(unused_assignments, unused_parens)] - fn variable_declaration_statement(&self, input: &mut ParserContext<'_>) -> ParserResult { - SequenceHelper::run(|mut seq| { - seq.elem( - SequenceHelper::run(|mut seq| { - seq.elem(self.variable_declaration_type(input))?; - seq.elem(OptionalHelper::transform(self.storage_location(input)))?; - seq.elem(self.parse_token_with_trivia::( - input, - TokenKind::Identifier, - ))?; - seq.elem(OptionalHelper::transform( - self.variable_declaration_value(input), - ))?; - seq.finish() - }) - .recover_until_with_nested_delims::<_, LexicalContextType::Default>( - input, - self, - TokenKind::Semicolon, - RecoverFromNoMatch::No, - ), - )?; - seq.elem(self.parse_token_with_trivia::( - input, - TokenKind::Semicolon, - ))?; - seq.finish() - }) - .with_kind(RuleKind::VariableDeclarationStatement) - } - - #[allow(unused_assignments, unused_parens)] - fn variable_declaration_type(&self, input: &mut ParserContext<'_>) -> ParserResult { - ChoiceHelper::run(input, |mut choice, input| { - 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::( - input, - TokenKind::VarKeyword, - ); - choice.consider(input, result)?; - } - choice.finish(input) - }) - .with_kind(RuleKind::VariableDeclarationType) - } - - #[allow(unused_assignments, unused_parens)] - fn variable_declaration_value(&self, input: &mut ParserContext<'_>) -> ParserResult { - SequenceHelper::run(|mut seq| { - seq.elem( - self.parse_token_with_trivia::( - input, - TokenKind::Equal, - ), - )?; - seq.elem(self.expression(input))?; - seq.finish() - }) - .with_kind(RuleKind::VariableDeclarationValue) - } - - #[allow(unused_assignments, unused_parens)] - fn version_pragma(&self, input: &mut ParserContext<'_>) -> ParserResult { - SequenceHelper::run(|mut seq| { - seq.elem(self.parse_token_with_trivia::( + seq.elem(self.parse_token_with_trivia::( input, - TokenKind::SolidityKeyword, + TokenKind::Semicolon, ))?; - seq.elem(self.version_pragma_expressions(input))?; seq.finish() }) - .with_kind(RuleKind::VersionPragma) + .with_kind(RuleKind::UsingDirective) } #[allow(unused_assignments, unused_parens)] - fn version_pragma_expression(&self, input: &mut ParserContext<'_>) -> ParserResult { - #[allow(unused_variables)] - let parse_version_pragma_or_expression = |input: &mut ParserContext<'_>| { - PrecedenceHelper::to_binary_operator( - RuleKind::VersionPragmaBinaryExpression, - 1u8, - 1u8 + 1, - self.parse_token_with_trivia::( + 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::( input, - TokenKind::BarBar, - ), - ) - }; - #[allow(unused_variables)] - let parse_version_pragma_range_expression = |input: &mut ParserContext<'_>| { - PrecedenceHelper::to_binary_operator( - RuleKind::VersionPragmaBinaryExpression, - 3u8, - 3u8 + 1, - self.parse_token_with_trivia::(input, TokenKind::Minus), - ) - }; - #[allow(unused_variables)] - let parse_version_pragma_prefix_expression = |input: &mut ParserContext<'_>| { - PrecedenceHelper::to_prefix_operator( - RuleKind::VersionPragmaUnaryExpression, - 5u8, - ChoiceHelper::run(input, |mut choice, input| { - let result = self.parse_token_with_trivia::( - input, - TokenKind::Caret, - ); - choice.consider(input, result)?; - let result = self.parse_token_with_trivia::( - input, - TokenKind::Tilde, - ); - choice.consider(input, result)?; - let result = self.parse_token_with_trivia::( - input, - TokenKind::Equal, - ); - choice.consider(input, result)?; - let result = self.parse_token_with_trivia::( - input, - TokenKind::LessThan, - ); - choice.consider(input, result)?; - let result = self.parse_token_with_trivia::( - input, - TokenKind::GreaterThan, - ); - choice.consider(input, result)?; - let result = self.parse_token_with_trivia::( - input, - TokenKind::LessThanEqual, - ); - choice.consider(input, result)?; - let result = self.parse_token_with_trivia::( - input, - TokenKind::GreaterThanEqual, - ); - choice.consider(input, result)?; - choice.finish(input) - }), - ) - }; - #[allow(unused_variables)] - let parse_version_pragma_prefix_expression = |input: &mut ParserContext<'_>| { - PrecedenceHelper::to_prefix_operator( - RuleKind::VersionPragmaUnaryExpression, - 7u8, - ChoiceHelper::run(input, |mut choice, input| { - let result = self.parse_token_with_trivia::( - input, - TokenKind::Caret, - ); - choice.consider(input, result)?; - let result = self.parse_token_with_trivia::( - input, - TokenKind::Tilde, - ); - choice.consider(input, result)?; - let result = self.parse_token_with_trivia::( - input, - TokenKind::Equal, - ); - choice.consider(input, result)?; - let result = self.parse_token_with_trivia::( - input, - TokenKind::LessThan, - ); - choice.consider(input, result)?; - let result = self.parse_token_with_trivia::( - input, - TokenKind::GreaterThan, - ); - choice.consider(input, result)?; - let result = self.parse_token_with_trivia::( - input, - TokenKind::LessThanEqual, - ); - choice.consider(input, result)?; - let result = self.parse_token_with_trivia::( - input, - TokenKind::GreaterThanEqual, - ); - choice.consider(input, result)?; - choice.finish(input) - }), - ) - }; - #[allow(unused_variables)] - let parse_version_pragma_prefix_expression = |input: &mut ParserContext<'_>| { - PrecedenceHelper::to_prefix_operator( - RuleKind::VersionPragmaUnaryExpression, - 9u8, - ChoiceHelper::run(input, |mut choice, input| { - let result = self.parse_token_with_trivia::( - input, - TokenKind::Caret, - ); - choice.consider(input, result)?; - let result = self.parse_token_with_trivia::( - input, - TokenKind::Tilde, - ); - choice.consider(input, result)?; - let result = self.parse_token_with_trivia::( - input, - TokenKind::Equal, - ); - choice.consider(input, result)?; - let result = self.parse_token_with_trivia::( - input, - TokenKind::LessThan, - ); - choice.consider(input, result)?; - let result = self.parse_token_with_trivia::( - input, - TokenKind::GreaterThan, - ); - choice.consider(input, result)?; - let result = self.parse_token_with_trivia::( - input, - TokenKind::LessThanEqual, - ); - choice.consider(input, result)?; - let result = self.parse_token_with_trivia::( - input, - TokenKind::GreaterThanEqual, - ); - choice.consider(input, result)?; - choice.finish(input) - }), - ) - }; - #[allow(unused_variables)] - let parse_version_pragma_prefix_expression = |input: &mut ParserContext<'_>| { - PrecedenceHelper::to_prefix_operator( - RuleKind::VersionPragmaUnaryExpression, - 11u8, - ChoiceHelper::run(input, |mut choice, input| { - let result = self.parse_token_with_trivia::( - input, - TokenKind::Caret, - ); - choice.consider(input, result)?; - let result = self.parse_token_with_trivia::( - input, - TokenKind::Tilde, - ); - choice.consider(input, result)?; - let result = self.parse_token_with_trivia::( - input, - TokenKind::Equal, - ); - choice.consider(input, result)?; - let result = self.parse_token_with_trivia::( - input, - TokenKind::LessThan, - ); - choice.consider(input, result)?; - let result = self.parse_token_with_trivia::( - input, - TokenKind::GreaterThan, - ); - choice.consider(input, result)?; - let result = self.parse_token_with_trivia::( - input, - TokenKind::LessThanEqual, - ); - choice.consider(input, result)?; - let result = self.parse_token_with_trivia::( - input, - TokenKind::GreaterThanEqual, - ); - choice.consider(input, result)?; - choice.finish(input) - }), - ) - }; - #[allow(unused_variables)] - let parse_version_pragma_prefix_expression = |input: &mut ParserContext<'_>| { - PrecedenceHelper::to_prefix_operator( - RuleKind::VersionPragmaUnaryExpression, - 13u8, - ChoiceHelper::run(input, |mut choice, input| { - let result = self.parse_token_with_trivia::( - input, - TokenKind::Caret, - ); - choice.consider(input, result)?; - let result = self.parse_token_with_trivia::( - input, - TokenKind::Tilde, - ); - choice.consider(input, result)?; - let result = self.parse_token_with_trivia::( - input, - TokenKind::Equal, - ); - choice.consider(input, result)?; - let result = self.parse_token_with_trivia::( - input, - TokenKind::LessThan, - ); - choice.consider(input, result)?; - let result = self.parse_token_with_trivia::( - input, - TokenKind::GreaterThan, - ); - choice.consider(input, result)?; - let result = self.parse_token_with_trivia::( - input, - TokenKind::LessThanEqual, - ); - choice.consider(input, result)?; - let result = self.parse_token_with_trivia::( + TokenKind::Ampersand, + ); + choice.consider(input, result)?; + let result = self.parse_token_with_trivia::( + input, + TokenKind::Asterisk, + ); + choice.consider(input, result)?; + let result = self.parse_token_with_trivia::( + input, + TokenKind::BangEqual, + ); + choice.consider(input, result)?; + let result = self + .parse_token_with_trivia::(input, TokenKind::Bar); + choice.consider(input, result)?; + let result = self.parse_token_with_trivia::( + input, + TokenKind::Caret, + ); + choice.consider(input, result)?; + let result = self.parse_token_with_trivia::( + input, + TokenKind::EqualEqual, + ); + choice.consider(input, result)?; + let result = self.parse_token_with_trivia::( + input, + TokenKind::GreaterThan, + ); + choice.consider(input, result)?; + let result = self.parse_token_with_trivia::( + input, + TokenKind::GreaterThanEqual, + ); + choice.consider(input, result)?; + let result = self.parse_token_with_trivia::( + input, + TokenKind::LessThan, + ); + choice.consider(input, result)?; + let result = self.parse_token_with_trivia::( + input, + TokenKind::LessThanEqual, + ); + choice.consider(input, result)?; + let result = self.parse_token_with_trivia::( + input, + TokenKind::Minus, + ); + choice.consider(input, result)?; + let result = self.parse_token_with_trivia::( + input, + TokenKind::Percent, + ); + choice.consider(input, result)?; + let result = self + .parse_token_with_trivia::(input, TokenKind::Plus); + choice.consider(input, result)?; + let result = self.parse_token_with_trivia::( + input, + TokenKind::Slash, + ); + choice.consider(input, result)?; + let result = self.parse_token_with_trivia::( + input, + TokenKind::Tilde, + ); + choice.consider(input, result)?; + choice.finish(input) + }) + } else { + ParserResult::disabled() + } + .with_kind(RuleKind::UsingOperator) + } + + #[allow(unused_assignments, unused_parens)] + fn using_target(&self, input: &mut ParserContext<'_>) -> ParserResult { + ChoiceHelper::run(input, |mut choice, input| { + let result = self.type_name(input); + choice.consider(input, result)?; + let result = self + .parse_token_with_trivia::(input, TokenKind::Asterisk); + choice.consider(input, result)?; + choice.finish(input) + }) + .with_kind(RuleKind::UsingTarget) + } + + #[allow(unused_assignments, unused_parens)] + fn variable_declaration_statement(&self, input: &mut ParserContext<'_>) -> ParserResult { + SequenceHelper::run(|mut seq| { + seq.elem( + SequenceHelper::run(|mut seq| { + seq.elem(self.variable_declaration_type(input))?; + seq.elem(OptionalHelper::transform(self.storage_location(input)))?; + seq.elem(self.parse_token_with_trivia::( input, - TokenKind::GreaterThanEqual, - ); - choice.consider(input, result)?; - choice.finish(input) - }), + TokenKind::Identifier, + ))?; + seq.elem(OptionalHelper::transform( + self.variable_declaration_value(input), + ))?; + seq.finish() + }) + .recover_until_with_nested_delims::<_, LexicalContextType::Default>( + input, + self, + TokenKind::Semicolon, + RecoverFromNoMatch::No, + ), + )?; + seq.elem(self.parse_token_with_trivia::( + input, + TokenKind::Semicolon, + ))?; + seq.finish() + }) + .with_kind(RuleKind::VariableDeclarationStatement) + } + + #[allow(unused_assignments, unused_parens)] + fn variable_declaration_type(&self, input: &mut ParserContext<'_>) -> ParserResult { + ChoiceHelper::run(input, |mut choice, input| { + 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::( + input, + TokenKind::VarKeyword, + ); + choice.consider(input, result)?; + } + choice.finish(input) + }) + .with_kind(RuleKind::VariableDeclarationType) + } + + #[allow(unused_assignments, unused_parens)] + fn variable_declaration_value(&self, input: &mut ParserContext<'_>) -> ParserResult { + SequenceHelper::run(|mut seq| { + seq.elem( + self.parse_token_with_trivia::( + input, + TokenKind::Equal, + ), + )?; + seq.elem(self.expression(input))?; + seq.finish() + }) + .with_kind(RuleKind::VariableDeclarationValue) + } + + #[allow(unused_assignments, unused_parens)] + fn version_pragma(&self, input: &mut ParserContext<'_>) -> ParserResult { + SequenceHelper::run(|mut seq| { + seq.elem(self.parse_token_with_trivia::( + input, + TokenKind::SolidityKeyword, + ))?; + seq.elem(self.version_pragma_expressions(input))?; + seq.finish() + }) + .with_kind(RuleKind::VersionPragma) + } + + #[allow(unused_assignments, unused_parens)] + fn version_pragma_expression(&self, input: &mut ParserContext<'_>) -> ParserResult { + let parse_left_version_pragma_or_expression = |input: &mut ParserContext<'_>| { + PrecedenceHelper::to_binary_operator( + RuleKind::VersionPragmaOrExpression, + 1u8, + 1u8 + 1, + self.parse_token_with_trivia::( + input, + TokenKind::BarBar, + ), ) }; - #[allow(unused_variables)] - let parse_version_pragma_prefix_expression = |input: &mut ParserContext<'_>| { - PrecedenceHelper::to_prefix_operator( - RuleKind::VersionPragmaUnaryExpression, - 15u8, - ChoiceHelper::run(input, |mut choice, input| { - let result = self.parse_token_with_trivia::( - input, - TokenKind::Caret, - ); - choice.consider(input, result)?; - let result = self.parse_token_with_trivia::( - input, - TokenKind::Tilde, - ); - choice.consider(input, result)?; - let result = self.parse_token_with_trivia::( - input, - TokenKind::Equal, - ); - choice.consider(input, result)?; - let result = self.parse_token_with_trivia::( - input, - TokenKind::LessThan, - ); - choice.consider(input, result)?; - let result = self.parse_token_with_trivia::( - input, - TokenKind::GreaterThan, - ); - choice.consider(input, result)?; - let result = self.parse_token_with_trivia::( - input, - TokenKind::LessThanEqual, - ); - choice.consider(input, result)?; - let result = self.parse_token_with_trivia::( - input, - TokenKind::GreaterThanEqual, - ); - choice.consider(input, result)?; - choice.finish(input) - }), + let parse_left_version_pragma_range_expression = |input: &mut ParserContext<'_>| { + PrecedenceHelper::to_binary_operator( + RuleKind::VersionPragmaRangeExpression, + 3u8, + 3u8 + 1, + self.parse_token_with_trivia::(input, TokenKind::Minus), ) }; - #[allow(unused_variables)] - let parse_version_pragma_prefix_expression = |input: &mut ParserContext<'_>| { + let parse_prefix_version_pragma_prefix_expression = |input: &mut ParserContext<'_>| { PrecedenceHelper::to_prefix_operator( - RuleKind::VersionPragmaUnaryExpression, - 17u8, + RuleKind::VersionPragmaPrefixExpression, + 5u8, ChoiceHelper::run(input, |mut choice, input| { let result = self.parse_token_with_trivia::( input, @@ -5933,50 +4689,31 @@ impl Language { }), ) }; - #[allow(unused_variables)] let prefix_operator_parser = |input: &mut ParserContext<'_>| { ChoiceHelper::run(input, |mut choice, input| { - let result = parse_version_pragma_prefix_expression(input); - choice.consider(input, result)?; - let result = parse_version_pragma_prefix_expression(input); - choice.consider(input, result)?; - let result = parse_version_pragma_prefix_expression(input); - choice.consider(input, result)?; - let result = parse_version_pragma_prefix_expression(input); - choice.consider(input, result)?; - let result = parse_version_pragma_prefix_expression(input); - choice.consider(input, result)?; - let result = parse_version_pragma_prefix_expression(input); - choice.consider(input, result)?; - let result = parse_version_pragma_prefix_expression(input); + let result = parse_prefix_version_pragma_prefix_expression(input); choice.consider(input, result)?; choice.finish(input) }) }; - #[allow(unused_variables)] let primary_expression_parser = |input: &mut ParserContext<'_>| self.version_pragma_specifier(input); - #[allow(unused_variables)] let binary_operand_parser = |input: &mut ParserContext<'_>| { SequenceHelper::run(|mut seq| { - seq.elem(ZeroOrMoreHelper::run(input, |input| { - prefix_operator_parser(input) - }))?; + seq.elem(ZeroOrMoreHelper::run(input, prefix_operator_parser))?; seq.elem(primary_expression_parser(input))?; seq.finish() }) }; - #[allow(unused_variables)] let binary_operator_parser = |input: &mut ParserContext<'_>| { ChoiceHelper::run(input, |mut choice, input| { - let result = parse_version_pragma_or_expression(input); + let result = parse_left_version_pragma_or_expression(input); choice.consider(input, result)?; - let result = parse_version_pragma_range_expression(input); + let result = parse_left_version_pragma_range_expression(input); choice.consider(input, result)?; choice.finish(input) }) }; - #[allow(unused_variables)] let linear_expression_parser = |input: &mut ParserContext<'_>| { SequenceHelper::run(|mut seq| { seq.elem(binary_operand_parser(input))?; @@ -5991,7 +4728,7 @@ impl Language { }) }; PrecedenceHelper::reduce_precedence_result( - Some(RuleKind::VersionPragmaExpression), + RuleKind::VersionPragmaExpression, linear_expression_parser(input), ) .with_kind(RuleKind::VersionPragmaExpression) @@ -6003,6 +4740,69 @@ impl Language { .with_kind(RuleKind::VersionPragmaExpressions) } + #[allow(unused_assignments, unused_parens)] + fn version_pragma_or_expression(&self, input: &mut ParserContext<'_>) -> ParserResult { + let result = self.version_pragma_expression(input); + let ParserResult::Match(r#match) = &result else { + return result; + }; + match &r#match.nodes[..] { + [cst::Node::Rule(node)] if node.kind == RuleKind::VersionPragmaExpression => { + match &node.children[..] { + [inner @ cst::Node::Rule(rule)] + if rule.kind == RuleKind::VersionPragmaOrExpression => + { + ParserResult::r#match(vec![inner.clone()], r#match.expected_tokens.clone()) + } + _ => ParserResult::no_match(vec![]), + } + } + _ => ParserResult::no_match(vec![]), + } + } + + #[allow(unused_assignments, unused_parens)] + fn version_pragma_prefix_expression(&self, input: &mut ParserContext<'_>) -> ParserResult { + let result = self.version_pragma_expression(input); + let ParserResult::Match(r#match) = &result else { + return result; + }; + match &r#match.nodes[..] { + [cst::Node::Rule(node)] if node.kind == RuleKind::VersionPragmaExpression => { + match &node.children[..] { + [inner @ cst::Node::Rule(rule)] + if rule.kind == RuleKind::VersionPragmaPrefixExpression => + { + ParserResult::r#match(vec![inner.clone()], r#match.expected_tokens.clone()) + } + _ => ParserResult::no_match(vec![]), + } + } + _ => ParserResult::no_match(vec![]), + } + } + + #[allow(unused_assignments, unused_parens)] + fn version_pragma_range_expression(&self, input: &mut ParserContext<'_>) -> ParserResult { + let result = self.version_pragma_expression(input); + let ParserResult::Match(r#match) = &result else { + return result; + }; + match &r#match.nodes[..] { + [cst::Node::Rule(node)] if node.kind == RuleKind::VersionPragmaExpression => { + match &node.children[..] { + [inner @ cst::Node::Rule(rule)] + if rule.kind == RuleKind::VersionPragmaRangeExpression => + { + ParserResult::r#match(vec![inner.clone()], r#match.expected_tokens.clone()) + } + _ => ParserResult::no_match(vec![]), + } + } + _ => ParserResult::no_match(vec![]), + } + } + #[allow(unused_assignments, unused_parens)] fn version_pragma_specifier(&self, input: &mut ParserContext<'_>) -> ParserResult { SeparatedHelper::run::<_, LexicalContextType::Pragma>( @@ -6142,8 +4942,7 @@ impl Language { #[allow(unused_assignments, unused_parens)] fn yul_expression(&self, input: &mut ParserContext<'_>) -> ParserResult { - #[allow(unused_variables)] - let parse_yul_function_call_expression = |input: &mut ParserContext<'_>| { + let parse_postfix_yul_function_call_expression = |input: &mut ParserContext<'_>| { PrecedenceHelper::to_postfix_operator( RuleKind::YulFunctionCallExpression, 1u8, @@ -6171,7 +4970,6 @@ impl Language { }), ) }; - #[allow(unused_variables)] let primary_expression_parser = |input: &mut ParserContext<'_>| { ChoiceHelper::run(input, |mut choice, input| { let result = self.yul_literal(input); @@ -6181,26 +4979,22 @@ impl Language { choice.finish(input) }) }; - #[allow(unused_variables)] let postfix_operator_parser = |input: &mut ParserContext<'_>| { ChoiceHelper::run(input, |mut choice, input| { - let result = parse_yul_function_call_expression(input); + let result = parse_postfix_yul_function_call_expression(input); choice.consider(input, result)?; choice.finish(input) }) }; - #[allow(unused_variables)] let linear_expression_parser = |input: &mut ParserContext<'_>| { SequenceHelper::run(|mut seq| { seq.elem(primary_expression_parser(input))?; - seq.elem(ZeroOrMoreHelper::run(input, |input| { - postfix_operator_parser(input) - }))?; + seq.elem(ZeroOrMoreHelper::run(input, postfix_operator_parser))?; seq.finish() }) }; PrecedenceHelper::reduce_precedence_result( - Some(RuleKind::YulExpression), + RuleKind::YulExpression, linear_expression_parser(input), ) .with_kind(RuleKind::YulExpression) @@ -6222,6 +5016,27 @@ impl Language { .with_kind(RuleKind::YulForStatement) } + #[allow(unused_assignments, unused_parens)] + fn yul_function_call_expression(&self, input: &mut ParserContext<'_>) -> ParserResult { + let result = self.yul_expression(input); + let ParserResult::Match(r#match) = &result else { + return result; + }; + match &r#match.nodes[..] { + [cst::Node::Rule(node)] if node.kind == RuleKind::YulExpression => { + match &node.children[..] { + [inner @ cst::Node::Rule(rule)] + if rule.kind == RuleKind::YulFunctionCallExpression => + { + ParserResult::r#match(vec![inner.clone()], r#match.expected_tokens.clone()) + } + _ => ParserResult::no_match(vec![]), + } + } + _ => ParserResult::no_match(vec![]), + } + } + #[allow(unused_assignments, unused_parens)] fn yul_function_definition(&self, input: &mut ParserContext<'_>) -> ParserResult { SequenceHelper::run(|mut seq| { @@ -8424,289 +7239,290 @@ impl Language { } } - pub fn parse(&self, production_kind: ProductionKind, input: &str) -> ParseOutput { - match production_kind { - ProductionKind::ABICoderPragma => Self::abi_coder_pragma.parse(self, input), - ProductionKind::AddressType => Self::address_type.parse(self, input), - ProductionKind::ArgumentsDeclaration => Self::arguments_declaration.parse(self, input), - ProductionKind::ArrayExpression => Self::array_expression.parse(self, input), - ProductionKind::ArrayValues => Self::array_values.parse(self, input), - ProductionKind::AsciiStringLiterals => Self::ascii_string_literals.parse(self, input), - ProductionKind::AssemblyFlags => Self::assembly_flags.parse(self, input), - ProductionKind::AssemblyFlagsDeclaration => { + pub fn parse(&self, kind: RuleKind, input: &str) -> ParseOutput { + match kind { + RuleKind::ABICoderPragma => Self::abi_coder_pragma.parse(self, input), + RuleKind::AdditiveExpression => Self::additive_expression.parse(self, input), + RuleKind::AddressType => Self::address_type.parse(self, input), + RuleKind::AndExpression => Self::and_expression.parse(self, input), + RuleKind::ArgumentsDeclaration => Self::arguments_declaration.parse(self, input), + RuleKind::ArrayExpression => Self::array_expression.parse(self, input), + RuleKind::ArrayTypeName => Self::array_type_name.parse(self, input), + RuleKind::ArrayValues => Self::array_values.parse(self, input), + RuleKind::AsciiStringLiterals => Self::ascii_string_literals.parse(self, input), + RuleKind::AssemblyFlags => Self::assembly_flags.parse(self, input), + RuleKind::AssemblyFlagsDeclaration => { Self::assembly_flags_declaration.parse(self, input) } - ProductionKind::AssemblyStatement => Self::assembly_statement.parse(self, input), - ProductionKind::Block => Self::block.parse(self, input), - ProductionKind::BreakStatement => Self::break_statement.parse(self, input), - ProductionKind::CatchClause => Self::catch_clause.parse(self, input), - ProductionKind::CatchClauseError => Self::catch_clause_error.parse(self, input), - ProductionKind::CatchClauses => Self::catch_clauses.parse(self, input), - ProductionKind::ConstantDefinition => Self::constant_definition.parse(self, input), - ProductionKind::ConstructorAttribute => Self::constructor_attribute.parse(self, input), - ProductionKind::ConstructorAttributes => { - Self::constructor_attributes.parse(self, input) - } - ProductionKind::ConstructorDefinition => { - Self::constructor_definition.parse(self, input) - } - ProductionKind::ContinueStatement => Self::continue_statement.parse(self, input), - ProductionKind::ContractDefinition => Self::contract_definition.parse(self, input), - ProductionKind::ContractMember => Self::contract_member.parse(self, input), - ProductionKind::ContractMembers => Self::contract_members.parse(self, input), - ProductionKind::DecimalNumberExpression => { - Self::decimal_number_expression.parse(self, input) - } - ProductionKind::DeleteStatement => Self::delete_statement.parse(self, input), - ProductionKind::DoWhileStatement => Self::do_while_statement.parse(self, input), - ProductionKind::ElementaryType => Self::elementary_type.parse(self, input), - ProductionKind::ElseBranch => Self::else_branch.parse(self, input), - ProductionKind::EmitStatement => Self::emit_statement.parse(self, input), - ProductionKind::EndOfFileTrivia => Self::end_of_file_trivia.parse(self, input), - ProductionKind::EnumDefinition => Self::enum_definition.parse(self, input), - ProductionKind::EnumMembers => Self::enum_members.parse(self, input), - ProductionKind::ErrorDefinition => Self::error_definition.parse(self, input), - ProductionKind::ErrorParameter => Self::error_parameter.parse(self, input), - ProductionKind::ErrorParameters => Self::error_parameters.parse(self, input), - ProductionKind::ErrorParametersDeclaration => { + RuleKind::AssemblyStatement => Self::assembly_statement.parse(self, input), + RuleKind::AssignmentExpression => Self::assignment_expression.parse(self, input), + RuleKind::BitwiseAndExpression => Self::bitwise_and_expression.parse(self, input), + RuleKind::BitwiseOrExpression => Self::bitwise_or_expression.parse(self, input), + RuleKind::BitwiseXorExpression => Self::bitwise_xor_expression.parse(self, input), + RuleKind::Block => Self::block.parse(self, input), + RuleKind::BreakStatement => Self::break_statement.parse(self, input), + RuleKind::CatchClause => Self::catch_clause.parse(self, input), + RuleKind::CatchClauseError => Self::catch_clause_error.parse(self, input), + RuleKind::CatchClauses => Self::catch_clauses.parse(self, input), + RuleKind::ComparisonExpression => Self::comparison_expression.parse(self, input), + RuleKind::ConditionalExpression => Self::conditional_expression.parse(self, input), + RuleKind::ConstantDefinition => Self::constant_definition.parse(self, input), + RuleKind::ConstructorAttribute => Self::constructor_attribute.parse(self, input), + RuleKind::ConstructorAttributes => Self::constructor_attributes.parse(self, input), + RuleKind::ConstructorDefinition => Self::constructor_definition.parse(self, input), + RuleKind::ContinueStatement => Self::continue_statement.parse(self, input), + RuleKind::ContractDefinition => Self::contract_definition.parse(self, input), + RuleKind::ContractMember => Self::contract_member.parse(self, input), + RuleKind::ContractMembers => Self::contract_members.parse(self, input), + RuleKind::DecimalNumberExpression => Self::decimal_number_expression.parse(self, input), + RuleKind::DeleteStatement => Self::delete_statement.parse(self, input), + RuleKind::DoWhileStatement => Self::do_while_statement.parse(self, input), + RuleKind::ElementaryType => Self::elementary_type.parse(self, input), + RuleKind::ElseBranch => Self::else_branch.parse(self, input), + RuleKind::EmitStatement => Self::emit_statement.parse(self, input), + RuleKind::EndOfFileTrivia => Self::end_of_file_trivia.parse(self, input), + RuleKind::EnumDefinition => Self::enum_definition.parse(self, input), + RuleKind::EnumMembers => Self::enum_members.parse(self, input), + RuleKind::EqualityExpression => Self::equality_expression.parse(self, input), + RuleKind::ErrorDefinition => Self::error_definition.parse(self, input), + RuleKind::ErrorParameter => Self::error_parameter.parse(self, input), + RuleKind::ErrorParameters => Self::error_parameters.parse(self, input), + RuleKind::ErrorParametersDeclaration => { Self::error_parameters_declaration.parse(self, input) } - ProductionKind::EventDefinition => Self::event_definition.parse(self, input), - ProductionKind::EventParameter => Self::event_parameter.parse(self, input), - ProductionKind::EventParameters => Self::event_parameters.parse(self, input), - ProductionKind::EventParametersDeclaration => { + RuleKind::EventDefinition => Self::event_definition.parse(self, input), + RuleKind::EventParameter => Self::event_parameter.parse(self, input), + RuleKind::EventParameters => Self::event_parameters.parse(self, input), + RuleKind::EventParametersDeclaration => { Self::event_parameters_declaration.parse(self, input) } - ProductionKind::ExperimentalFeature => Self::experimental_feature.parse(self, input), - ProductionKind::ExperimentalPragma => Self::experimental_pragma.parse(self, input), - ProductionKind::Expression => Self::expression.parse(self, input), - ProductionKind::ExpressionStatement => Self::expression_statement.parse(self, input), - ProductionKind::FallbackFunctionAttribute => { + RuleKind::ExperimentalFeature => Self::experimental_feature.parse(self, input), + RuleKind::ExperimentalPragma => Self::experimental_pragma.parse(self, input), + RuleKind::ExponentiationExpression => { + Self::exponentiation_expression.parse(self, input) + } + RuleKind::Expression => Self::expression.parse(self, input), + RuleKind::ExpressionStatement => Self::expression_statement.parse(self, input), + RuleKind::FallbackFunctionAttribute => { Self::fallback_function_attribute.parse(self, input) } - ProductionKind::FallbackFunctionAttributes => { + RuleKind::FallbackFunctionAttributes => { Self::fallback_function_attributes.parse(self, input) } - ProductionKind::FallbackFunctionDefinition => { + RuleKind::FallbackFunctionDefinition => { Self::fallback_function_definition.parse(self, input) } - ProductionKind::ForStatement => Self::for_statement.parse(self, input), - ProductionKind::ForStatementCondition => { - Self::for_statement_condition.parse(self, input) - } - ProductionKind::ForStatementInitialization => { + RuleKind::ForStatement => Self::for_statement.parse(self, input), + RuleKind::ForStatementCondition => Self::for_statement_condition.parse(self, input), + RuleKind::ForStatementInitialization => { Self::for_statement_initialization.parse(self, input) } - ProductionKind::FunctionAttribute => Self::function_attribute.parse(self, input), - ProductionKind::FunctionAttributes => Self::function_attributes.parse(self, input), - ProductionKind::FunctionBody => Self::function_body.parse(self, input), - ProductionKind::FunctionCallOptions => Self::function_call_options.parse(self, input), - ProductionKind::FunctionDefinition => Self::function_definition.parse(self, input), - ProductionKind::FunctionName => Self::function_name.parse(self, input), - ProductionKind::FunctionType => Self::function_type.parse(self, input), - ProductionKind::FunctionTypeAttribute => { - Self::function_type_attribute.parse(self, input) - } - ProductionKind::FunctionTypeAttributes => { - Self::function_type_attributes.parse(self, input) - } - ProductionKind::HexNumberExpression => Self::hex_number_expression.parse(self, input), - ProductionKind::HexStringLiterals => Self::hex_string_literals.parse(self, input), - ProductionKind::IdentifierPath => Self::identifier_path.parse(self, input), - ProductionKind::IfStatement => Self::if_statement.parse(self, input), - ProductionKind::ImportAlias => Self::import_alias.parse(self, input), - ProductionKind::ImportClause => Self::import_clause.parse(self, input), - ProductionKind::ImportDeconstruction => Self::import_deconstruction.parse(self, input), - ProductionKind::ImportDeconstructionSymbol => { + RuleKind::FunctionAttribute => Self::function_attribute.parse(self, input), + RuleKind::FunctionAttributes => Self::function_attributes.parse(self, input), + RuleKind::FunctionBody => Self::function_body.parse(self, input), + RuleKind::FunctionCallExpression => Self::function_call_expression.parse(self, input), + RuleKind::FunctionCallOptions => Self::function_call_options.parse(self, input), + RuleKind::FunctionDefinition => Self::function_definition.parse(self, input), + RuleKind::FunctionName => Self::function_name.parse(self, input), + RuleKind::FunctionType => Self::function_type.parse(self, input), + RuleKind::FunctionTypeAttribute => Self::function_type_attribute.parse(self, input), + RuleKind::FunctionTypeAttributes => Self::function_type_attributes.parse(self, input), + RuleKind::HexNumberExpression => Self::hex_number_expression.parse(self, input), + RuleKind::HexStringLiterals => Self::hex_string_literals.parse(self, input), + RuleKind::IdentifierPath => Self::identifier_path.parse(self, input), + RuleKind::IfStatement => Self::if_statement.parse(self, input), + RuleKind::ImportAlias => Self::import_alias.parse(self, input), + RuleKind::ImportClause => Self::import_clause.parse(self, input), + RuleKind::ImportDeconstruction => Self::import_deconstruction.parse(self, input), + RuleKind::ImportDeconstructionSymbol => { Self::import_deconstruction_symbol.parse(self, input) } - ProductionKind::ImportDeconstructionSymbols => { + RuleKind::ImportDeconstructionSymbols => { Self::import_deconstruction_symbols.parse(self, input) } - ProductionKind::ImportDirective => Self::import_directive.parse(self, input), - ProductionKind::IndexAccessEnd => Self::index_access_end.parse(self, input), - ProductionKind::InheritanceSpecifier => Self::inheritance_specifier.parse(self, input), - ProductionKind::InheritanceType => Self::inheritance_type.parse(self, input), - ProductionKind::InheritanceTypes => Self::inheritance_types.parse(self, input), - ProductionKind::InterfaceDefinition => Self::interface_definition.parse(self, input), - ProductionKind::InterfaceMembers => Self::interface_members.parse(self, input), - ProductionKind::LeadingTrivia => Self::leading_trivia.parse(self, input), - ProductionKind::LibraryDefinition => Self::library_definition.parse(self, input), - ProductionKind::LibraryMembers => Self::library_members.parse(self, input), - ProductionKind::MappingKey => Self::mapping_key.parse(self, input), - ProductionKind::MappingKeyType => Self::mapping_key_type.parse(self, input), - ProductionKind::MappingType => Self::mapping_type.parse(self, input), - ProductionKind::MappingValue => Self::mapping_value.parse(self, input), - ProductionKind::MemberAccess => Self::member_access.parse(self, input), - ProductionKind::ModifierAttribute => Self::modifier_attribute.parse(self, input), - ProductionKind::ModifierAttributes => Self::modifier_attributes.parse(self, input), - ProductionKind::ModifierDefinition => Self::modifier_definition.parse(self, input), - ProductionKind::ModifierInvocation => Self::modifier_invocation.parse(self, input), - ProductionKind::NamedArgument => Self::named_argument.parse(self, input), - ProductionKind::NamedArgumentGroup => Self::named_argument_group.parse(self, input), - ProductionKind::NamedArgumentGroups => Self::named_argument_groups.parse(self, input), - ProductionKind::NamedArguments => Self::named_arguments.parse(self, input), - ProductionKind::NamedArgumentsDeclaration => { + RuleKind::ImportDirective => Self::import_directive.parse(self, input), + RuleKind::IndexAccessEnd => Self::index_access_end.parse(self, input), + RuleKind::IndexAccessExpression => Self::index_access_expression.parse(self, input), + RuleKind::InheritanceSpecifier => Self::inheritance_specifier.parse(self, input), + RuleKind::InheritanceType => Self::inheritance_type.parse(self, input), + RuleKind::InheritanceTypes => Self::inheritance_types.parse(self, input), + RuleKind::InterfaceDefinition => Self::interface_definition.parse(self, input), + RuleKind::InterfaceMembers => Self::interface_members.parse(self, input), + RuleKind::LeadingTrivia => Self::leading_trivia.parse(self, input), + RuleKind::LibraryDefinition => Self::library_definition.parse(self, input), + RuleKind::LibraryMembers => Self::library_members.parse(self, input), + RuleKind::MappingKey => Self::mapping_key.parse(self, input), + RuleKind::MappingKeyType => Self::mapping_key_type.parse(self, input), + RuleKind::MappingType => Self::mapping_type.parse(self, input), + RuleKind::MappingValue => Self::mapping_value.parse(self, input), + RuleKind::MemberAccess => Self::member_access.parse(self, input), + RuleKind::MemberAccessExpression => Self::member_access_expression.parse(self, input), + RuleKind::ModifierAttribute => Self::modifier_attribute.parse(self, input), + RuleKind::ModifierAttributes => Self::modifier_attributes.parse(self, input), + RuleKind::ModifierDefinition => Self::modifier_definition.parse(self, input), + RuleKind::ModifierInvocation => Self::modifier_invocation.parse(self, input), + RuleKind::MultiplicativeExpression => { + Self::multiplicative_expression.parse(self, input) + } + RuleKind::NamedArgument => Self::named_argument.parse(self, input), + RuleKind::NamedArgumentGroup => Self::named_argument_group.parse(self, input), + RuleKind::NamedArgumentGroups => Self::named_argument_groups.parse(self, input), + RuleKind::NamedArguments => Self::named_arguments.parse(self, input), + RuleKind::NamedArgumentsDeclaration => { Self::named_arguments_declaration.parse(self, input) } - ProductionKind::NamedImport => Self::named_import.parse(self, input), - ProductionKind::NewExpression => Self::new_expression.parse(self, input), - ProductionKind::NumberUnit => Self::number_unit.parse(self, input), - ProductionKind::OverridePaths => Self::override_paths.parse(self, input), - ProductionKind::OverridePathsDeclaration => { + RuleKind::NamedImport => Self::named_import.parse(self, input), + RuleKind::NewExpression => Self::new_expression.parse(self, input), + RuleKind::NumberUnit => Self::number_unit.parse(self, input), + RuleKind::OrExpression => Self::or_expression.parse(self, input), + RuleKind::OverridePaths => Self::override_paths.parse(self, input), + RuleKind::OverridePathsDeclaration => { Self::override_paths_declaration.parse(self, input) } - ProductionKind::OverrideSpecifier => Self::override_specifier.parse(self, input), - ProductionKind::Parameter => Self::parameter.parse(self, input), - ProductionKind::Parameters => Self::parameters.parse(self, input), - ProductionKind::ParametersDeclaration => { - Self::parameters_declaration.parse(self, input) - } - ProductionKind::PathImport => Self::path_import.parse(self, input), - ProductionKind::PositionalArguments => Self::positional_arguments.parse(self, input), - ProductionKind::PositionalArgumentsDeclaration => { + RuleKind::OverrideSpecifier => Self::override_specifier.parse(self, input), + RuleKind::Parameter => Self::parameter.parse(self, input), + RuleKind::Parameters => Self::parameters.parse(self, input), + RuleKind::ParametersDeclaration => Self::parameters_declaration.parse(self, input), + RuleKind::PathImport => Self::path_import.parse(self, input), + RuleKind::PositionalArguments => Self::positional_arguments.parse(self, input), + RuleKind::PositionalArgumentsDeclaration => { Self::positional_arguments_declaration.parse(self, input) } - ProductionKind::Pragma => Self::pragma.parse(self, input), - ProductionKind::PragmaDirective => Self::pragma_directive.parse(self, input), - ProductionKind::ReceiveFunctionAttribute => { + RuleKind::PostfixExpression => Self::postfix_expression.parse(self, input), + RuleKind::Pragma => Self::pragma.parse(self, input), + RuleKind::PragmaDirective => Self::pragma_directive.parse(self, input), + RuleKind::PrefixExpression => Self::prefix_expression.parse(self, input), + RuleKind::ReceiveFunctionAttribute => { Self::receive_function_attribute.parse(self, input) } - ProductionKind::ReceiveFunctionAttributes => { + RuleKind::ReceiveFunctionAttributes => { Self::receive_function_attributes.parse(self, input) } - ProductionKind::ReceiveFunctionDefinition => { + RuleKind::ReceiveFunctionDefinition => { Self::receive_function_definition.parse(self, input) } - ProductionKind::ReturnStatement => Self::return_statement.parse(self, input), - ProductionKind::ReturnsDeclaration => Self::returns_declaration.parse(self, input), - ProductionKind::RevertStatement => Self::revert_statement.parse(self, input), - ProductionKind::SourceUnit => Self::source_unit.parse(self, input), - ProductionKind::SourceUnitMember => Self::source_unit_member.parse(self, input), - ProductionKind::SourceUnitMembers => Self::source_unit_members.parse(self, input), - ProductionKind::StateVariableAttribute => { - Self::state_variable_attribute.parse(self, input) - } - ProductionKind::StateVariableAttributes => { - Self::state_variable_attributes.parse(self, input) - } - ProductionKind::StateVariableDefinition => { - Self::state_variable_definition.parse(self, input) - } - ProductionKind::StateVariableDefinitionValue => { + RuleKind::ReturnStatement => Self::return_statement.parse(self, input), + RuleKind::ReturnsDeclaration => Self::returns_declaration.parse(self, input), + RuleKind::RevertStatement => Self::revert_statement.parse(self, input), + RuleKind::ShiftExpression => Self::shift_expression.parse(self, input), + RuleKind::SourceUnit => Self::source_unit.parse(self, input), + RuleKind::SourceUnitMember => Self::source_unit_member.parse(self, input), + RuleKind::SourceUnitMembers => Self::source_unit_members.parse(self, input), + RuleKind::StateVariableAttribute => Self::state_variable_attribute.parse(self, input), + RuleKind::StateVariableAttributes => Self::state_variable_attributes.parse(self, input), + RuleKind::StateVariableDefinition => Self::state_variable_definition.parse(self, input), + RuleKind::StateVariableDefinitionValue => { Self::state_variable_definition_value.parse(self, input) } - ProductionKind::Statement => Self::statement.parse(self, input), - ProductionKind::Statements => Self::statements.parse(self, input), - ProductionKind::StorageLocation => Self::storage_location.parse(self, input), - ProductionKind::StringExpression => Self::string_expression.parse(self, input), - ProductionKind::StructDefinition => Self::struct_definition.parse(self, input), - ProductionKind::StructMember => Self::struct_member.parse(self, input), - ProductionKind::StructMembers => Self::struct_members.parse(self, input), - ProductionKind::ThrowStatement => Self::throw_statement.parse(self, input), - ProductionKind::TrailingTrivia => Self::trailing_trivia.parse(self, input), - ProductionKind::TryStatement => Self::try_statement.parse(self, input), - ProductionKind::TupleDeconstructionElement => { + RuleKind::Statement => Self::statement.parse(self, input), + RuleKind::Statements => Self::statements.parse(self, input), + RuleKind::StorageLocation => Self::storage_location.parse(self, input), + RuleKind::StringExpression => Self::string_expression.parse(self, input), + RuleKind::StructDefinition => Self::struct_definition.parse(self, input), + RuleKind::StructMember => Self::struct_member.parse(self, input), + RuleKind::StructMembers => Self::struct_members.parse(self, input), + RuleKind::ThrowStatement => Self::throw_statement.parse(self, input), + RuleKind::TrailingTrivia => Self::trailing_trivia.parse(self, input), + RuleKind::TryStatement => Self::try_statement.parse(self, input), + RuleKind::TupleDeconstructionElement => { Self::tuple_deconstruction_element.parse(self, input) } - ProductionKind::TupleDeconstructionElements => { + RuleKind::TupleDeconstructionElements => { Self::tuple_deconstruction_elements.parse(self, input) } - ProductionKind::TupleDeconstructionStatement => { + RuleKind::TupleDeconstructionStatement => { Self::tuple_deconstruction_statement.parse(self, input) } - ProductionKind::TupleExpression => Self::tuple_expression.parse(self, input), - ProductionKind::TupleMember => Self::tuple_member.parse(self, input), - ProductionKind::TupleValue => Self::tuple_value.parse(self, input), - ProductionKind::TupleValues => Self::tuple_values.parse(self, input), - ProductionKind::TypeExpression => Self::type_expression.parse(self, input), - ProductionKind::TypeName => Self::type_name.parse(self, input), - ProductionKind::TypedTupleMember => Self::typed_tuple_member.parse(self, input), - ProductionKind::UncheckedBlock => Self::unchecked_block.parse(self, input), - ProductionKind::UnicodeStringLiterals => { - Self::unicode_string_literals.parse(self, input) - } - ProductionKind::UnnamedFunctionAttribute => { + RuleKind::TupleExpression => Self::tuple_expression.parse(self, input), + RuleKind::TupleMember => Self::tuple_member.parse(self, input), + RuleKind::TupleValue => Self::tuple_value.parse(self, input), + RuleKind::TupleValues => Self::tuple_values.parse(self, input), + RuleKind::TypeExpression => Self::type_expression.parse(self, input), + RuleKind::TypeName => Self::type_name.parse(self, input), + RuleKind::TypedTupleMember => Self::typed_tuple_member.parse(self, input), + RuleKind::UncheckedBlock => Self::unchecked_block.parse(self, input), + RuleKind::UnicodeStringLiterals => Self::unicode_string_literals.parse(self, input), + RuleKind::UnnamedFunctionAttribute => { Self::unnamed_function_attribute.parse(self, input) } - ProductionKind::UnnamedFunctionAttributes => { + RuleKind::UnnamedFunctionAttributes => { Self::unnamed_function_attributes.parse(self, input) } - ProductionKind::UnnamedFunctionDefinition => { + RuleKind::UnnamedFunctionDefinition => { Self::unnamed_function_definition.parse(self, input) } - ProductionKind::UntypedTupleMember => Self::untyped_tuple_member.parse(self, input), - ProductionKind::UserDefinedValueTypeDefinition => { + RuleKind::UntypedTupleMember => Self::untyped_tuple_member.parse(self, input), + RuleKind::UserDefinedValueTypeDefinition => { Self::user_defined_value_type_definition.parse(self, input) } - ProductionKind::UsingAlias => Self::using_alias.parse(self, input), - ProductionKind::UsingClause => Self::using_clause.parse(self, input), - ProductionKind::UsingDeconstruction => Self::using_deconstruction.parse(self, input), - ProductionKind::UsingDeconstructionSymbol => { + RuleKind::UsingAlias => Self::using_alias.parse(self, input), + RuleKind::UsingClause => Self::using_clause.parse(self, input), + RuleKind::UsingDeconstruction => Self::using_deconstruction.parse(self, input), + RuleKind::UsingDeconstructionSymbol => { Self::using_deconstruction_symbol.parse(self, input) } - ProductionKind::UsingDeconstructionSymbols => { + RuleKind::UsingDeconstructionSymbols => { Self::using_deconstruction_symbols.parse(self, input) } - ProductionKind::UsingDirective => Self::using_directive.parse(self, input), - ProductionKind::UsingOperator => Self::using_operator.parse(self, input), - ProductionKind::UsingTarget => Self::using_target.parse(self, input), - ProductionKind::VariableDeclarationStatement => { + RuleKind::UsingDirective => Self::using_directive.parse(self, input), + RuleKind::UsingOperator => Self::using_operator.parse(self, input), + RuleKind::UsingTarget => Self::using_target.parse(self, input), + RuleKind::VariableDeclarationStatement => { Self::variable_declaration_statement.parse(self, input) } - ProductionKind::VariableDeclarationType => { - Self::variable_declaration_type.parse(self, input) - } - ProductionKind::VariableDeclarationValue => { + RuleKind::VariableDeclarationType => Self::variable_declaration_type.parse(self, input), + RuleKind::VariableDeclarationValue => { Self::variable_declaration_value.parse(self, input) } - ProductionKind::VersionPragma => Self::version_pragma.parse(self, input), - ProductionKind::VersionPragmaExpression => { - Self::version_pragma_expression.parse(self, input) - } - ProductionKind::VersionPragmaExpressions => { + RuleKind::VersionPragma => Self::version_pragma.parse(self, input), + RuleKind::VersionPragmaExpression => Self::version_pragma_expression.parse(self, input), + RuleKind::VersionPragmaExpressions => { Self::version_pragma_expressions.parse(self, input) } - ProductionKind::VersionPragmaSpecifier => { - Self::version_pragma_specifier.parse(self, input) + RuleKind::VersionPragmaOrExpression => { + Self::version_pragma_or_expression.parse(self, input) } - ProductionKind::WhileStatement => Self::while_statement.parse(self, input), - ProductionKind::YulArguments => Self::yul_arguments.parse(self, input), - ProductionKind::YulAssignmentStatement => { - Self::yul_assignment_statement.parse(self, input) + RuleKind::VersionPragmaPrefixExpression => { + Self::version_pragma_prefix_expression.parse(self, input) } - ProductionKind::YulBlock => Self::yul_block.parse(self, input), - ProductionKind::YulBreakStatement => Self::yul_break_statement.parse(self, input), - ProductionKind::YulContinueStatement => Self::yul_continue_statement.parse(self, input), - ProductionKind::YulDefaultCase => Self::yul_default_case.parse(self, input), - ProductionKind::YulExpression => Self::yul_expression.parse(self, input), - ProductionKind::YulForStatement => Self::yul_for_statement.parse(self, input), - ProductionKind::YulFunctionDefinition => { - Self::yul_function_definition.parse(self, input) + RuleKind::VersionPragmaRangeExpression => { + Self::version_pragma_range_expression.parse(self, input) } - ProductionKind::YulIdentifierPath => Self::yul_identifier_path.parse(self, input), - ProductionKind::YulIdentifierPaths => Self::yul_identifier_paths.parse(self, input), - ProductionKind::YulIfStatement => Self::yul_if_statement.parse(self, input), - ProductionKind::YulLeaveStatement => Self::yul_leave_statement.parse(self, input), - ProductionKind::YulLiteral => Self::yul_literal.parse(self, input), - ProductionKind::YulParameters => Self::yul_parameters.parse(self, input), - ProductionKind::YulParametersDeclaration => { - Self::yul_parameters_declaration.parse(self, input) + RuleKind::VersionPragmaSpecifier => Self::version_pragma_specifier.parse(self, input), + RuleKind::WhileStatement => Self::while_statement.parse(self, input), + RuleKind::YulArguments => Self::yul_arguments.parse(self, input), + RuleKind::YulAssignmentStatement => Self::yul_assignment_statement.parse(self, input), + RuleKind::YulBlock => Self::yul_block.parse(self, input), + RuleKind::YulBreakStatement => Self::yul_break_statement.parse(self, input), + RuleKind::YulContinueStatement => Self::yul_continue_statement.parse(self, input), + RuleKind::YulDefaultCase => Self::yul_default_case.parse(self, input), + RuleKind::YulExpression => Self::yul_expression.parse(self, input), + RuleKind::YulForStatement => Self::yul_for_statement.parse(self, input), + RuleKind::YulFunctionCallExpression => { + Self::yul_function_call_expression.parse(self, input) } - ProductionKind::YulReturnVariables => Self::yul_return_variables.parse(self, input), - ProductionKind::YulReturnsDeclaration => { - Self::yul_returns_declaration.parse(self, input) + RuleKind::YulFunctionDefinition => Self::yul_function_definition.parse(self, input), + RuleKind::YulIdentifierPath => Self::yul_identifier_path.parse(self, input), + RuleKind::YulIdentifierPaths => Self::yul_identifier_paths.parse(self, input), + RuleKind::YulIfStatement => Self::yul_if_statement.parse(self, input), + RuleKind::YulLeaveStatement => Self::yul_leave_statement.parse(self, input), + RuleKind::YulLiteral => Self::yul_literal.parse(self, input), + RuleKind::YulParameters => Self::yul_parameters.parse(self, input), + RuleKind::YulParametersDeclaration => { + Self::yul_parameters_declaration.parse(self, input) } - ProductionKind::YulStatement => Self::yul_statement.parse(self, input), - ProductionKind::YulStatements => Self::yul_statements.parse(self, input), - ProductionKind::YulSwitchCase => Self::yul_switch_case.parse(self, input), - ProductionKind::YulSwitchCases => Self::yul_switch_cases.parse(self, input), - ProductionKind::YulSwitchStatement => Self::yul_switch_statement.parse(self, input), - ProductionKind::YulValueCase => Self::yul_value_case.parse(self, input), - ProductionKind::YulVariableDeclarationStatement => { + RuleKind::YulReturnVariables => Self::yul_return_variables.parse(self, input), + RuleKind::YulReturnsDeclaration => Self::yul_returns_declaration.parse(self, input), + RuleKind::YulStatement => Self::yul_statement.parse(self, input), + RuleKind::YulStatements => Self::yul_statements.parse(self, input), + RuleKind::YulSwitchCase => Self::yul_switch_case.parse(self, input), + RuleKind::YulSwitchCases => Self::yul_switch_cases.parse(self, input), + RuleKind::YulSwitchStatement => Self::yul_switch_statement.parse(self, input), + RuleKind::YulValueCase => Self::yul_value_case.parse(self, input), + RuleKind::YulVariableDeclarationStatement => { Self::yul_variable_declaration_statement.parse(self, input) } - ProductionKind::YulVariableDeclarationValue => { + RuleKind::YulVariableDeclarationValue => { Self::yul_variable_declaration_value.parse(self, input) } } @@ -10960,9 +9776,9 @@ impl Language { #[napi(js_name = "parse", ts_return_type = "parse_output.ParseOutput")] pub fn parse_napi( &self, - #[napi(ts_arg_type = "kinds.ProductionKind")] production_kind: ProductionKind, + #[napi(ts_arg_type = "kinds.RuleKind")] kind: RuleKind, input: String, ) -> NAPIParseOutput { - self.parse(production_kind, input.as_str()).into() + self.parse(kind, input.as_str()).into() } } diff --git a/crates/solidity/outputs/npm/crate/src/generated/support/precedence_helper.rs b/crates/solidity/outputs/npm/crate/src/generated/support/precedence_helper.rs index 0ee251bda3..175b2c538e 100644 --- a/crates/solidity/outputs/npm/crate/src/generated/support/precedence_helper.rs +++ b/crates/solidity/outputs/npm/crate/src/generated/support/precedence_helper.rs @@ -60,10 +60,7 @@ impl PrecedenceHelper { } #[allow(clippy::too_many_lines)] // Explicit on purpose, see below. - pub fn reduce_precedence_result( - child_kind: Option, - result: ParserResult, - ) -> ParserResult { + pub fn reduce_precedence_result(child_kind: RuleKind, result: ParserResult) -> ParserResult { // This requires some careful thinking. It could be more compact, // but I'm favouring obviousness here. That is also why there are // so many `unreachable!` - not only should they never be reached, @@ -164,10 +161,8 @@ impl PrecedenceHelper { let wrap_children = |children: Vec| { if children.is_empty() { children - } else if let Some(kind) = child_kind { - vec![cst::Node::rule(kind, children)] } else { - children + vec![cst::Node::rule(child_kind, children)] } }; diff --git a/crates/solidity/outputs/npm/package/src/generated/index.d.ts b/crates/solidity/outputs/npm/package/src/generated/index.d.ts index 563bc2caa8..93b799da0b 100644 --- a/crates/solidity/outputs/npm/package/src/generated/index.d.ts +++ b/crates/solidity/outputs/npm/package/src/generated/index.d.ts @@ -9,198 +9,11 @@ /* auto-generated by NAPI-RS */ export namespace kinds { - export enum ProductionKind { - ABICoderPragma = "ABICoderPragma", - AddressType = "AddressType", - ArgumentsDeclaration = "ArgumentsDeclaration", - ArrayExpression = "ArrayExpression", - ArrayValues = "ArrayValues", - AsciiStringLiterals = "AsciiStringLiterals", - AssemblyFlags = "AssemblyFlags", - AssemblyFlagsDeclaration = "AssemblyFlagsDeclaration", - AssemblyStatement = "AssemblyStatement", - Block = "Block", - BreakStatement = "BreakStatement", - CatchClause = "CatchClause", - CatchClauseError = "CatchClauseError", - CatchClauses = "CatchClauses", - ConstantDefinition = "ConstantDefinition", - ConstructorAttribute = "ConstructorAttribute", - ConstructorAttributes = "ConstructorAttributes", - ConstructorDefinition = "ConstructorDefinition", - ContinueStatement = "ContinueStatement", - ContractDefinition = "ContractDefinition", - ContractMember = "ContractMember", - ContractMembers = "ContractMembers", - DecimalNumberExpression = "DecimalNumberExpression", - DeleteStatement = "DeleteStatement", - DoWhileStatement = "DoWhileStatement", - ElementaryType = "ElementaryType", - ElseBranch = "ElseBranch", - EmitStatement = "EmitStatement", - EndOfFileTrivia = "EndOfFileTrivia", - EnumDefinition = "EnumDefinition", - EnumMembers = "EnumMembers", - ErrorDefinition = "ErrorDefinition", - ErrorParameter = "ErrorParameter", - ErrorParameters = "ErrorParameters", - ErrorParametersDeclaration = "ErrorParametersDeclaration", - EventDefinition = "EventDefinition", - EventParameter = "EventParameter", - EventParameters = "EventParameters", - EventParametersDeclaration = "EventParametersDeclaration", - ExperimentalFeature = "ExperimentalFeature", - ExperimentalPragma = "ExperimentalPragma", - Expression = "Expression", - ExpressionStatement = "ExpressionStatement", - FallbackFunctionAttribute = "FallbackFunctionAttribute", - FallbackFunctionAttributes = "FallbackFunctionAttributes", - FallbackFunctionDefinition = "FallbackFunctionDefinition", - ForStatement = "ForStatement", - ForStatementCondition = "ForStatementCondition", - ForStatementInitialization = "ForStatementInitialization", - FunctionAttribute = "FunctionAttribute", - FunctionAttributes = "FunctionAttributes", - FunctionBody = "FunctionBody", - FunctionCallOptions = "FunctionCallOptions", - FunctionDefinition = "FunctionDefinition", - FunctionName = "FunctionName", - FunctionType = "FunctionType", - FunctionTypeAttribute = "FunctionTypeAttribute", - FunctionTypeAttributes = "FunctionTypeAttributes", - HexNumberExpression = "HexNumberExpression", - HexStringLiterals = "HexStringLiterals", - IdentifierPath = "IdentifierPath", - IfStatement = "IfStatement", - ImportAlias = "ImportAlias", - ImportClause = "ImportClause", - ImportDeconstruction = "ImportDeconstruction", - ImportDeconstructionSymbol = "ImportDeconstructionSymbol", - ImportDeconstructionSymbols = "ImportDeconstructionSymbols", - ImportDirective = "ImportDirective", - IndexAccessEnd = "IndexAccessEnd", - InheritanceSpecifier = "InheritanceSpecifier", - InheritanceType = "InheritanceType", - InheritanceTypes = "InheritanceTypes", - InterfaceDefinition = "InterfaceDefinition", - InterfaceMembers = "InterfaceMembers", - LeadingTrivia = "LeadingTrivia", - LibraryDefinition = "LibraryDefinition", - LibraryMembers = "LibraryMembers", - MappingKey = "MappingKey", - MappingKeyType = "MappingKeyType", - MappingType = "MappingType", - MappingValue = "MappingValue", - MemberAccess = "MemberAccess", - ModifierAttribute = "ModifierAttribute", - ModifierAttributes = "ModifierAttributes", - ModifierDefinition = "ModifierDefinition", - ModifierInvocation = "ModifierInvocation", - NamedArgument = "NamedArgument", - NamedArgumentGroup = "NamedArgumentGroup", - NamedArgumentGroups = "NamedArgumentGroups", - NamedArguments = "NamedArguments", - NamedArgumentsDeclaration = "NamedArgumentsDeclaration", - NamedImport = "NamedImport", - NewExpression = "NewExpression", - NumberUnit = "NumberUnit", - OverridePaths = "OverridePaths", - OverridePathsDeclaration = "OverridePathsDeclaration", - OverrideSpecifier = "OverrideSpecifier", - Parameter = "Parameter", - Parameters = "Parameters", - ParametersDeclaration = "ParametersDeclaration", - PathImport = "PathImport", - PositionalArguments = "PositionalArguments", - PositionalArgumentsDeclaration = "PositionalArgumentsDeclaration", - Pragma = "Pragma", - PragmaDirective = "PragmaDirective", - ReceiveFunctionAttribute = "ReceiveFunctionAttribute", - ReceiveFunctionAttributes = "ReceiveFunctionAttributes", - ReceiveFunctionDefinition = "ReceiveFunctionDefinition", - ReturnStatement = "ReturnStatement", - ReturnsDeclaration = "ReturnsDeclaration", - RevertStatement = "RevertStatement", - SourceUnit = "SourceUnit", - SourceUnitMember = "SourceUnitMember", - SourceUnitMembers = "SourceUnitMembers", - StateVariableAttribute = "StateVariableAttribute", - StateVariableAttributes = "StateVariableAttributes", - StateVariableDefinition = "StateVariableDefinition", - StateVariableDefinitionValue = "StateVariableDefinitionValue", - Statement = "Statement", - Statements = "Statements", - StorageLocation = "StorageLocation", - StringExpression = "StringExpression", - StructDefinition = "StructDefinition", - StructMember = "StructMember", - StructMembers = "StructMembers", - ThrowStatement = "ThrowStatement", - TrailingTrivia = "TrailingTrivia", - TryStatement = "TryStatement", - TupleDeconstructionElement = "TupleDeconstructionElement", - TupleDeconstructionElements = "TupleDeconstructionElements", - TupleDeconstructionStatement = "TupleDeconstructionStatement", - TupleExpression = "TupleExpression", - TupleMember = "TupleMember", - TupleValue = "TupleValue", - TupleValues = "TupleValues", - TypeExpression = "TypeExpression", - TypeName = "TypeName", - TypedTupleMember = "TypedTupleMember", - UncheckedBlock = "UncheckedBlock", - UnicodeStringLiterals = "UnicodeStringLiterals", - UnnamedFunctionAttribute = "UnnamedFunctionAttribute", - UnnamedFunctionAttributes = "UnnamedFunctionAttributes", - UnnamedFunctionDefinition = "UnnamedFunctionDefinition", - UntypedTupleMember = "UntypedTupleMember", - UserDefinedValueTypeDefinition = "UserDefinedValueTypeDefinition", - UsingAlias = "UsingAlias", - UsingClause = "UsingClause", - UsingDeconstruction = "UsingDeconstruction", - UsingDeconstructionSymbol = "UsingDeconstructionSymbol", - UsingDeconstructionSymbols = "UsingDeconstructionSymbols", - UsingDirective = "UsingDirective", - UsingOperator = "UsingOperator", - UsingTarget = "UsingTarget", - VariableDeclarationStatement = "VariableDeclarationStatement", - VariableDeclarationType = "VariableDeclarationType", - VariableDeclarationValue = "VariableDeclarationValue", - VersionPragma = "VersionPragma", - VersionPragmaExpression = "VersionPragmaExpression", - VersionPragmaExpressions = "VersionPragmaExpressions", - VersionPragmaSpecifier = "VersionPragmaSpecifier", - WhileStatement = "WhileStatement", - YulArguments = "YulArguments", - YulAssignmentStatement = "YulAssignmentStatement", - YulBlock = "YulBlock", - YulBreakStatement = "YulBreakStatement", - YulContinueStatement = "YulContinueStatement", - YulDefaultCase = "YulDefaultCase", - YulExpression = "YulExpression", - YulForStatement = "YulForStatement", - YulFunctionDefinition = "YulFunctionDefinition", - YulIdentifierPath = "YulIdentifierPath", - YulIdentifierPaths = "YulIdentifierPaths", - YulIfStatement = "YulIfStatement", - YulLeaveStatement = "YulLeaveStatement", - YulLiteral = "YulLiteral", - YulParameters = "YulParameters", - YulParametersDeclaration = "YulParametersDeclaration", - YulReturnVariables = "YulReturnVariables", - YulReturnsDeclaration = "YulReturnsDeclaration", - YulStatement = "YulStatement", - YulStatements = "YulStatements", - YulSwitchCase = "YulSwitchCase", - YulSwitchCases = "YulSwitchCases", - YulSwitchStatement = "YulSwitchStatement", - YulValueCase = "YulValueCase", - YulVariableDeclarationStatement = "YulVariableDeclarationStatement", - YulVariableDeclarationValue = "YulVariableDeclarationValue", - } export enum RuleKind { ABICoderPragma = "ABICoderPragma", + AdditiveExpression = "AdditiveExpression", AddressType = "AddressType", + AndExpression = "AndExpression", ArgumentsDeclaration = "ArgumentsDeclaration", ArrayExpression = "ArrayExpression", ArrayTypeName = "ArrayTypeName", @@ -209,12 +22,16 @@ export namespace kinds { AssemblyFlags = "AssemblyFlags", AssemblyFlagsDeclaration = "AssemblyFlagsDeclaration", AssemblyStatement = "AssemblyStatement", - BinaryExpression = "BinaryExpression", + AssignmentExpression = "AssignmentExpression", + BitwiseAndExpression = "BitwiseAndExpression", + BitwiseOrExpression = "BitwiseOrExpression", + BitwiseXorExpression = "BitwiseXorExpression", Block = "Block", BreakStatement = "BreakStatement", CatchClause = "CatchClause", CatchClauseError = "CatchClauseError", CatchClauses = "CatchClauses", + ComparisonExpression = "ComparisonExpression", ConditionalExpression = "ConditionalExpression", ConstantDefinition = "ConstantDefinition", ConstructorAttribute = "ConstructorAttribute", @@ -233,6 +50,7 @@ export namespace kinds { EndOfFileTrivia = "EndOfFileTrivia", EnumDefinition = "EnumDefinition", EnumMembers = "EnumMembers", + EqualityExpression = "EqualityExpression", ErrorDefinition = "ErrorDefinition", ErrorParameter = "ErrorParameter", ErrorParameters = "ErrorParameters", @@ -243,6 +61,7 @@ export namespace kinds { EventParametersDeclaration = "EventParametersDeclaration", ExperimentalFeature = "ExperimentalFeature", ExperimentalPragma = "ExperimentalPragma", + ExponentiationExpression = "ExponentiationExpression", Expression = "Expression", ExpressionStatement = "ExpressionStatement", FallbackFunctionAttribute = "FallbackFunctionAttribute", @@ -291,6 +110,7 @@ export namespace kinds { ModifierAttributes = "ModifierAttributes", ModifierDefinition = "ModifierDefinition", ModifierInvocation = "ModifierInvocation", + MultiplicativeExpression = "MultiplicativeExpression", NamedArgument = "NamedArgument", NamedArgumentGroup = "NamedArgumentGroup", NamedArgumentGroups = "NamedArgumentGroups", @@ -299,6 +119,7 @@ export namespace kinds { NamedImport = "NamedImport", NewExpression = "NewExpression", NumberUnit = "NumberUnit", + OrExpression = "OrExpression", OverridePaths = "OverridePaths", OverridePathsDeclaration = "OverridePathsDeclaration", OverrideSpecifier = "OverrideSpecifier", @@ -308,14 +129,17 @@ export namespace kinds { PathImport = "PathImport", PositionalArguments = "PositionalArguments", PositionalArgumentsDeclaration = "PositionalArgumentsDeclaration", + PostfixExpression = "PostfixExpression", Pragma = "Pragma", PragmaDirective = "PragmaDirective", + PrefixExpression = "PrefixExpression", ReceiveFunctionAttribute = "ReceiveFunctionAttribute", ReceiveFunctionAttributes = "ReceiveFunctionAttributes", ReceiveFunctionDefinition = "ReceiveFunctionDefinition", ReturnStatement = "ReturnStatement", ReturnsDeclaration = "ReturnsDeclaration", RevertStatement = "RevertStatement", + ShiftExpression = "ShiftExpression", SourceUnit = "SourceUnit", SourceUnitMember = "SourceUnitMember", SourceUnitMembers = "SourceUnitMembers", @@ -343,8 +167,6 @@ export namespace kinds { TypeExpression = "TypeExpression", TypeName = "TypeName", TypedTupleMember = "TypedTupleMember", - UnaryPostfixExpression = "UnaryPostfixExpression", - UnaryPrefixExpression = "UnaryPrefixExpression", UncheckedBlock = "UncheckedBlock", UnicodeStringLiterals = "UnicodeStringLiterals", UnnamedFunctionAttribute = "UnnamedFunctionAttribute", @@ -364,11 +186,12 @@ export namespace kinds { VariableDeclarationType = "VariableDeclarationType", VariableDeclarationValue = "VariableDeclarationValue", VersionPragma = "VersionPragma", - VersionPragmaBinaryExpression = "VersionPragmaBinaryExpression", VersionPragmaExpression = "VersionPragmaExpression", VersionPragmaExpressions = "VersionPragmaExpressions", + VersionPragmaOrExpression = "VersionPragmaOrExpression", + VersionPragmaPrefixExpression = "VersionPragmaPrefixExpression", + VersionPragmaRangeExpression = "VersionPragmaRangeExpression", VersionPragmaSpecifier = "VersionPragmaSpecifier", - VersionPragmaUnaryExpression = "VersionPragmaUnaryExpression", WhileStatement = "WhileStatement", YulArguments = "YulArguments", YulAssignmentStatement = "YulAssignmentStatement", @@ -697,7 +520,7 @@ export namespace language { get version(): string; static supportedVersions(): Array; scan(lexicalContext: LexicalContext, input: string): kinds.TokenKind | null; - parse(productionKind: kinds.ProductionKind, input: string): parse_output.ParseOutput; + parse(kind: kinds.RuleKind, input: string): parse_output.ParseOutput; } } export namespace cst { diff --git a/crates/solidity/outputs/npm/package/src/kinds/index.ts b/crates/solidity/outputs/npm/package/src/kinds/index.ts index 6ac7e61c7f..24d203adb0 100644 --- a/crates/solidity/outputs/npm/package/src/kinds/index.ts +++ b/crates/solidity/outputs/npm/package/src/kinds/index.ts @@ -1,8 +1,5 @@ import * as generated from "../generated"; -export const ProductionKind = generated.kinds.ProductionKind; -export type ProductionKind = generated.kinds.ProductionKind; - export const RuleKind = generated.kinds.RuleKind; export type RuleKind = generated.kinds.RuleKind; diff --git a/crates/solidity/outputs/npm/tests/src/doc-examples/simple-contract.ts b/crates/solidity/outputs/npm/tests/src/doc-examples/simple-contract.ts index 4a0c29eabf..3fe7208c3b 100644 --- a/crates/solidity/outputs/npm/tests/src/doc-examples/simple-contract.ts +++ b/crates/solidity/outputs/npm/tests/src/doc-examples/simple-contract.ts @@ -1,10 +1,10 @@ import { Language } from "@nomicfoundation/slang/language"; import { RuleNode, TokenNode } from "@nomicfoundation/slang/cst"; -import { ProductionKind, RuleKind, TokenKind } from "@nomicfoundation/slang/kinds"; +import { RuleKind, TokenKind } from "@nomicfoundation/slang/kinds"; test("simple contract", () => { const language = new Language("0.8.0"); - const parseOutput = language.parse(ProductionKind.ContractDefinition, "contract Foo {}"); + const parseOutput = language.parse(RuleKind.ContractDefinition, "contract Foo {}"); const parseTree = parseOutput.tree() as RuleNode; expect(parseTree.kind).toEqual(RuleKind.ContractDefinition); diff --git a/crates/solidity/outputs/npm/tests/src/tests/cst-cursor.ts b/crates/solidity/outputs/npm/tests/src/tests/cst-cursor.ts index f4795d81e5..58a2fb06b3 100644 --- a/crates/solidity/outputs/npm/tests/src/tests/cst-cursor.ts +++ b/crates/solidity/outputs/npm/tests/src/tests/cst-cursor.ts @@ -1,5 +1,5 @@ import { Language } from "@nomicfoundation/slang/language"; -import { ProductionKind, RuleKind, TokenKind } from "@nomicfoundation/slang/kinds"; +import { RuleKind, TokenKind } from "@nomicfoundation/slang/kinds"; import { Cursor } from "@nomicfoundation/slang/cursor"; import { expectRule, expectToken } from "../utils/cst-helpers"; @@ -7,7 +7,7 @@ test("use cursor", () => { const source = "int256 constant z = 1 + 2;"; const language = new Language("0.8.1"); - const parseOutput = language.parse(ProductionKind.SourceUnit, source); + const parseOutput = language.parse(RuleKind.SourceUnit, source); const cursor: Cursor = parseOutput.createTreeCursor(); expectRule(cursor.node(), RuleKind.SourceUnit); @@ -61,7 +61,7 @@ test("use cursor", () => { expectRule(cursor.node(), RuleKind.Expression); expect(cursor.goToNext()).toBe(true); - expectRule(cursor.node(), RuleKind.BinaryExpression); + expectRule(cursor.node(), RuleKind.AdditiveExpression); expect(cursor.goToNext()).toBe(true); expectRule(cursor.node(), RuleKind.Expression); diff --git a/crates/solidity/outputs/npm/tests/src/tests/cst-output.ts b/crates/solidity/outputs/npm/tests/src/tests/cst-output.ts index 9c65995592..de42cfc6c1 100644 --- a/crates/solidity/outputs/npm/tests/src/tests/cst-output.ts +++ b/crates/solidity/outputs/npm/tests/src/tests/cst-output.ts @@ -1,12 +1,12 @@ import { Language } from "@nomicfoundation/slang/language"; -import { ProductionKind, RuleKind, TokenKind } from "@nomicfoundation/slang/kinds"; +import { RuleKind, TokenKind } from "@nomicfoundation/slang/kinds"; import { expectRule, expectToken } from "../utils/cst-helpers"; test("parse token", () => { const source = "5_286_981"; const language = new Language("0.8.1"); - const parseTree = language.parse(ProductionKind.DecimalNumberExpression, source).tree(); + const parseTree = language.parse(RuleKind.DecimalNumberExpression, source).tree(); expectRule(parseTree, RuleKind.DecimalNumberExpression); const children = parseTree.children(); @@ -19,7 +19,7 @@ test("parse rule", () => { const source = "int256 constant z = 1**2**3;"; const language = new Language("0.8.1"); - const parseTree = language.parse(ProductionKind.SourceUnit, source).tree(); + const parseTree = language.parse(RuleKind.SourceUnit, source).tree(); expectRule(parseTree, RuleKind.SourceUnit); const children = parseTree.children(); @@ -32,7 +32,7 @@ test("trivial cursor access", () => { const source = "int256 constant z = 1**2**3;"; const language = new Language("0.8.1"); - const parseOutput = language.parse(ProductionKind.SourceUnit, source); + const parseOutput = language.parse(RuleKind.SourceUnit, source); const node = parseOutput.createTreeCursor().node(); expectRule(node, RuleKind.SourceUnit); @@ -44,7 +44,7 @@ test("calculate unicode characters text length", () => { const source = `unicode"some 😁 emoji"`; const language = new Language("0.8.1"); - const parseTree = language.parse(ProductionKind.UnicodeStringLiterals, source).tree(); + const parseTree = language.parse(RuleKind.UnicodeStringLiterals, source).tree(); expectRule(parseTree, RuleKind.UnicodeStringLiterals); expect(parseTree.textLength).toEqual({ diff --git a/crates/solidity/outputs/npm/tests/src/tests/errors.ts b/crates/solidity/outputs/npm/tests/src/tests/errors.ts index 02f07a84db..afadec9043 100644 --- a/crates/solidity/outputs/npm/tests/src/tests/errors.ts +++ b/crates/solidity/outputs/npm/tests/src/tests/errors.ts @@ -1,11 +1,11 @@ import { Language } from "@nomicfoundation/slang/language"; -import { ProductionKind } from "@nomicfoundation/slang/kinds"; +import { RuleKind } from "@nomicfoundation/slang/kinds"; test("render error reports", () => { const source = "int256 constant"; const language = new Language("0.8.1"); - const errors = language.parse(ProductionKind.SourceUnit, source).errors(); + const errors = language.parse(RuleKind.SourceUnit, source).errors(); expect(errors).toHaveLength(1); const report = errors[0]!.toErrorReport("test.sol", source, /* withColor */ false); diff --git a/crates/solidity/outputs/npm/tests/src/tests/public-api.ts b/crates/solidity/outputs/npm/tests/src/tests/public-api.ts index a33aa90d40..45616b0afa 100644 --- a/crates/solidity/outputs/npm/tests/src/tests/public-api.ts +++ b/crates/solidity/outputs/npm/tests/src/tests/public-api.ts @@ -1,14 +1,14 @@ import * as slang from "@nomicfoundation/slang"; -import { ProductionKind, RuleKind, TokenKind } from "@nomicfoundation/slang/kinds"; +import { RuleKind, TokenKind } from "@nomicfoundation/slang/kinds"; test("use namespace imports of the API", () => { - expect(slang.kinds.ProductionKind.SourceUnit).toEqual("SourceUnit"); + expect(slang.kinds.RuleKind.SourceUnit).toEqual("SourceUnit"); expect(slang.kinds.RuleKind.ContractDefinition).toEqual("ContractDefinition"); expect(slang.kinds.TokenKind.IfKeyword).toEqual("IfKeyword"); }); test("use nested imports of the API", () => { - expect(ProductionKind.SourceUnit).toEqual("SourceUnit"); + expect(RuleKind.SourceUnit).toEqual("SourceUnit"); expect(RuleKind.ContractDefinition).toEqual("ContractDefinition"); expect(TokenKind.IfKeyword).toEqual("IfKeyword"); }); diff --git a/crates/solidity/testing/sanctuary/src/main.rs b/crates/solidity/testing/sanctuary/src/main.rs index 8686223481..c190e089ee 100644 --- a/crates/solidity/testing/sanctuary/src/main.rs +++ b/crates/solidity/testing/sanctuary/src/main.rs @@ -7,7 +7,7 @@ use anyhow::Result; use infra_utils::paths::PathExtensions; use rayon::prelude::{IntoParallelRefIterator, ParallelIterator}; use semver::Version; -use slang_solidity::{kinds::ProductionKind, language::Language}; +use slang_solidity::{kinds::RuleKind, language::Language}; use solidity_language::SolidityDefinition; use solidity_testing_utils::version_pragmas::extract_version_pragmas; @@ -95,7 +95,7 @@ fn process_source_file( } let language = Language::new(version.to_owned())?; - let output = language.parse(ProductionKind::SourceUnit, source); + let output = language.parse(RuleKind::SourceUnit, source); reporter.report_test_result(source_id, source, version, &output); } diff --git a/crates/solidity/testing/snapshots/cst_output/Block/unchecked/generated/0.8.0-success.yml b/crates/solidity/testing/snapshots/cst_output/Block/unchecked/generated/0.8.0-success.yml index e54c525bb5..33c20a7cfc 100644 --- a/crates/solidity/testing/snapshots/cst_output/Block/unchecked/generated/0.8.0-success.yml +++ b/crates/solidity/testing/snapshots/cst_output/Block/unchecked/generated/0.8.0-success.yml @@ -18,7 +18,7 @@ Tree: - Statement (Rule): # 13..20 " x = 1;" - ExpressionStatement (Rule): # 13..20 " x = 1;" - Expression (Rule): # 13..19 " x = 1" - - BinaryExpression (Rule): # 13..19 " x = 1" + - AssignmentExpression (Rule): # 13..19 " x = 1" - Expression (Rule): # 13..15 " x" - Identifier (Token): "x" # 14..15 - Equal (Token): "=" # 16..17 diff --git a/crates/solidity/testing/snapshots/cst_output/ConditionalExpression/identifier_base/generated/0.4.11-success.yml b/crates/solidity/testing/snapshots/cst_output/ConditionalExpression/identifier_base/generated/0.4.11-success.yml new file mode 100644 index 0000000000..8de08367fc --- /dev/null +++ b/crates/solidity/testing/snapshots/cst_output/ConditionalExpression/identifier_base/generated/0.4.11-success.yml @@ -0,0 +1,17 @@ +# This file is generated automatically by infrastructure scripts. Please don't edit by hand. + +Source: > + 1 │ foo ? true : false │ 0..18 + +Errors: [] + +Tree: + - ConditionalExpression (Rule): # 0..18 "foo ? true : false" + - Expression (Rule): # 0..3 "foo" + - Identifier (Token): "foo" # 0..3 + - QuestionMark (Token): "?" # 4..5 + - Expression (Rule): # 5..10 " true" + - TrueKeyword (Token): "true" # 6..10 + - Colon (Token): ":" # 11..12 + - Expression (Rule): # 12..18 " false" + - FalseKeyword (Token): "false" # 13..18 diff --git a/crates/solidity/testing/snapshots/cst_output/Expression/conditional_expression_identifier_base/input.sol b/crates/solidity/testing/snapshots/cst_output/ConditionalExpression/identifier_base/input.sol similarity index 100% rename from crates/solidity/testing/snapshots/cst_output/Expression/conditional_expression_identifier_base/input.sol rename to crates/solidity/testing/snapshots/cst_output/ConditionalExpression/identifier_base/input.sol diff --git a/crates/solidity/testing/snapshots/cst_output/ConditionalExpression/nested_base/generated/0.4.11-success.yml b/crates/solidity/testing/snapshots/cst_output/ConditionalExpression/nested_base/generated/0.4.11-success.yml new file mode 100644 index 0000000000..767918501f --- /dev/null +++ b/crates/solidity/testing/snapshots/cst_output/ConditionalExpression/nested_base/generated/0.4.11-success.yml @@ -0,0 +1,28 @@ +# This file is generated automatically by infrastructure scripts. Please don't edit by hand. + +Source: > + 1 │ (foo == bar) ? true : false │ 0..27 + +Errors: [] + +Tree: + - ConditionalExpression (Rule): # 0..27 "(foo == bar) ? true : false" + - Expression (Rule): # 0..12 "(foo == bar)" + - TupleExpression (Rule): # 0..12 "(foo == bar)" + - OpenParen (Token): "(" # 0..1 + - TupleValues (Rule): # 1..11 "foo == bar" + - TupleValue (Rule): # 1..11 "foo == bar" + - Expression (Rule): # 1..11 "foo == bar" + - EqualityExpression (Rule): # 1..11 "foo == bar" + - Expression (Rule): # 1..4 "foo" + - Identifier (Token): "foo" # 1..4 + - EqualEqual (Token): "==" # 5..7 + - Expression (Rule): # 7..11 " bar" + - Identifier (Token): "bar" # 8..11 + - CloseParen (Token): ")" # 11..12 + - QuestionMark (Token): "?" # 13..14 + - Expression (Rule): # 14..19 " true" + - TrueKeyword (Token): "true" # 15..19 + - Colon (Token): ":" # 20..21 + - Expression (Rule): # 21..27 " false" + - FalseKeyword (Token): "false" # 22..27 diff --git a/crates/solidity/testing/snapshots/cst_output/Expression/conditional_expression_nested_base/input.sol b/crates/solidity/testing/snapshots/cst_output/ConditionalExpression/nested_base/input.sol similarity index 100% rename from crates/solidity/testing/snapshots/cst_output/Expression/conditional_expression_nested_base/input.sol rename to crates/solidity/testing/snapshots/cst_output/ConditionalExpression/nested_base/input.sol diff --git a/crates/solidity/testing/snapshots/cst_output/ConditionalExpression/nested_conditions/generated/0.4.11-success.yml b/crates/solidity/testing/snapshots/cst_output/ConditionalExpression/nested_conditions/generated/0.4.11-success.yml new file mode 100644 index 0000000000..7670b903e0 --- /dev/null +++ b/crates/solidity/testing/snapshots/cst_output/ConditionalExpression/nested_conditions/generated/0.4.11-success.yml @@ -0,0 +1,39 @@ +# This file is generated automatically by infrastructure scripts. Please don't edit by hand. + +Source: > + 1 │ foo ? (a + b) : (c + d) │ 0..23 + +Errors: [] + +Tree: + - ConditionalExpression (Rule): # 0..23 "foo ? (a + b) : (c + d)" + - Expression (Rule): # 0..3 "foo" + - Identifier (Token): "foo" # 0..3 + - QuestionMark (Token): "?" # 4..5 + - Expression (Rule): # 5..13 " (a + b)" + - TupleExpression (Rule): # 5..13 " (a + b)" + - OpenParen (Token): "(" # 6..7 + - TupleValues (Rule): # 7..12 "a + b" + - TupleValue (Rule): # 7..12 "a + b" + - Expression (Rule): # 7..12 "a + b" + - AdditiveExpression (Rule): # 7..12 "a + b" + - Expression (Rule): # 7..8 "a" + - Identifier (Token): "a" # 7..8 + - Plus (Token): "+" # 9..10 + - Expression (Rule): # 10..12 " b" + - Identifier (Token): "b" # 11..12 + - CloseParen (Token): ")" # 12..13 + - Colon (Token): ":" # 14..15 + - Expression (Rule): # 15..23 " (c + d)" + - TupleExpression (Rule): # 15..23 " (c + d)" + - OpenParen (Token): "(" # 16..17 + - TupleValues (Rule): # 17..22 "c + d" + - TupleValue (Rule): # 17..22 "c + d" + - Expression (Rule): # 17..22 "c + d" + - AdditiveExpression (Rule): # 17..22 "c + d" + - Expression (Rule): # 17..18 "c" + - Identifier (Token): "c" # 17..18 + - Plus (Token): "+" # 19..20 + - Expression (Rule): # 20..22 " d" + - Identifier (Token): "d" # 21..22 + - CloseParen (Token): ")" # 22..23 diff --git a/crates/solidity/testing/snapshots/cst_output/Expression/conditional_expression_nested_conditions/input.sol b/crates/solidity/testing/snapshots/cst_output/ConditionalExpression/nested_conditions/input.sol similarity index 100% rename from crates/solidity/testing/snapshots/cst_output/Expression/conditional_expression_nested_conditions/input.sol rename to crates/solidity/testing/snapshots/cst_output/ConditionalExpression/nested_conditions/input.sol diff --git a/crates/solidity/testing/snapshots/cst_output/ConditionalExpression/recursive/generated/0.4.11-success.yml b/crates/solidity/testing/snapshots/cst_output/ConditionalExpression/recursive/generated/0.4.11-success.yml new file mode 100644 index 0000000000..f902117f92 --- /dev/null +++ b/crates/solidity/testing/snapshots/cst_output/ConditionalExpression/recursive/generated/0.4.11-success.yml @@ -0,0 +1,76 @@ +# This file is generated automatically by infrastructure scripts. Please don't edit by hand. + +Source: > + 1 │ foo ? a == b ? a + b * c : a + b * c + d : !bar ? e + f : g + h │ 0..63 + +Errors: [] + +Tree: + - ConditionalExpression (Rule): # 0..63 "foo ? a == b ? a + b * c : a + b * c + d : !bar ? ..." + - Expression (Rule): # 0..3 "foo" + - Identifier (Token): "foo" # 0..3 + - QuestionMark (Token): "?" # 4..5 + - Expression (Rule): # 5..40 " a == b ? a + b * c : a + b * c + d" + - ConditionalExpression (Rule): # 5..40 " a == b ? a + b * c : a + b * c + d" + - Expression (Rule): # 5..12 " a == b" + - EqualityExpression (Rule): # 5..12 " a == b" + - Expression (Rule): # 5..7 " a" + - Identifier (Token): "a" # 6..7 + - EqualEqual (Token): "==" # 8..10 + - Expression (Rule): # 10..12 " b" + - Identifier (Token): "b" # 11..12 + - QuestionMark (Token): "?" # 13..14 + - Expression (Rule): # 14..24 " a + b * c" + - AdditiveExpression (Rule): # 14..24 " a + b * c" + - Expression (Rule): # 14..16 " a" + - Identifier (Token): "a" # 15..16 + - Plus (Token): "+" # 17..18 + - Expression (Rule): # 18..24 " b * c" + - MultiplicativeExpression (Rule): # 18..24 " b * c" + - Expression (Rule): # 18..20 " b" + - Identifier (Token): "b" # 19..20 + - Asterisk (Token): "*" # 21..22 + - Expression (Rule): # 22..24 " c" + - Identifier (Token): "c" # 23..24 + - Colon (Token): ":" # 25..26 + - Expression (Rule): # 26..40 " a + b * c + d" + - AdditiveExpression (Rule): # 26..40 " a + b * c + d" + - Expression (Rule): # 26..36 " a + b * c" + - AdditiveExpression (Rule): # 26..36 " a + b * c" + - Expression (Rule): # 26..28 " a" + - Identifier (Token): "a" # 27..28 + - Plus (Token): "+" # 29..30 + - Expression (Rule): # 30..36 " b * c" + - MultiplicativeExpression (Rule): # 30..36 " b * c" + - Expression (Rule): # 30..32 " b" + - Identifier (Token): "b" # 31..32 + - Asterisk (Token): "*" # 33..34 + - Expression (Rule): # 34..36 " c" + - Identifier (Token): "c" # 35..36 + - Plus (Token): "+" # 37..38 + - Expression (Rule): # 38..40 " d" + - Identifier (Token): "d" # 39..40 + - Colon (Token): ":" # 41..42 + - Expression (Rule): # 42..63 " !bar ? e + f : g + h" + - ConditionalExpression (Rule): # 42..63 " !bar ? e + f : g + h" + - Expression (Rule): # 42..47 " !bar" + - PrefixExpression (Rule): # 42..47 " !bar" + - Bang (Token): "!" # 43..44 + - Expression (Rule): # 44..47 "bar" + - Identifier (Token): "bar" # 44..47 + - QuestionMark (Token): "?" # 48..49 + - Expression (Rule): # 49..55 " e + f" + - AdditiveExpression (Rule): # 49..55 " e + f" + - Expression (Rule): # 49..51 " e" + - Identifier (Token): "e" # 50..51 + - Plus (Token): "+" # 52..53 + - Expression (Rule): # 53..55 " f" + - Identifier (Token): "f" # 54..55 + - Colon (Token): ":" # 56..57 + - Expression (Rule): # 57..63 " g + h" + - AdditiveExpression (Rule): # 57..63 " g + h" + - Expression (Rule): # 57..59 " g" + - Identifier (Token): "g" # 58..59 + - Plus (Token): "+" # 60..61 + - Expression (Rule): # 61..63 " h" + - Identifier (Token): "h" # 62..63 diff --git a/crates/solidity/testing/snapshots/cst_output/Expression/conditional_expression_recursive/input.sol b/crates/solidity/testing/snapshots/cst_output/ConditionalExpression/recursive/input.sol similarity index 100% rename from crates/solidity/testing/snapshots/cst_output/Expression/conditional_expression_recursive/input.sol rename to crates/solidity/testing/snapshots/cst_output/ConditionalExpression/recursive/input.sol diff --git a/crates/solidity/testing/snapshots/cst_output/ContractDefinition/function_multiple_delimiters/generated/0.4.11-failure.yml b/crates/solidity/testing/snapshots/cst_output/ContractDefinition/function_multiple_delimiters/generated/0.4.11-failure.yml index 97082d571d..eb7915e42d 100644 --- a/crates/solidity/testing/snapshots/cst_output/ContractDefinition/function_multiple_delimiters/generated/0.4.11-failure.yml +++ b/crates/solidity/testing/snapshots/cst_output/ContractDefinition/function_multiple_delimiters/generated/0.4.11-failure.yml @@ -69,7 +69,7 @@ Tree: - OpenParen (Token): "(" # 133..134 - PositionalArguments (Rule): # 134..198 'address(this).balance >= amount, "Address: insuffi...' - Expression (Rule): # 134..165 "address(this).balance >= amount" - - BinaryExpression (Rule): # 134..165 "address(this).balance >= amount" + - ComparisonExpression (Rule): # 134..165 "address(this).balance >= amount" - Expression (Rule): # 134..155 "address(this).balance" - MemberAccessExpression (Rule): # 134..155 "address(this).balance" - Expression (Rule): # 134..147 "address(this)" diff --git a/crates/solidity/testing/snapshots/cst_output/ContractDefinition/function_multiple_delimiters/generated/0.6.2-success.yml b/crates/solidity/testing/snapshots/cst_output/ContractDefinition/function_multiple_delimiters/generated/0.6.2-success.yml index 1bba7d9ec3..e5d9dbf4ca 100644 --- a/crates/solidity/testing/snapshots/cst_output/ContractDefinition/function_multiple_delimiters/generated/0.6.2-success.yml +++ b/crates/solidity/testing/snapshots/cst_output/ContractDefinition/function_multiple_delimiters/generated/0.6.2-success.yml @@ -61,7 +61,7 @@ Tree: - OpenParen (Token): "(" # 133..134 - PositionalArguments (Rule): # 134..198 'address(this).balance >= amount, "Address: insuffi...' - Expression (Rule): # 134..165 "address(this).balance >= amount" - - BinaryExpression (Rule): # 134..165 "address(this).balance >= amount" + - ComparisonExpression (Rule): # 134..165 "address(this).balance >= amount" - Expression (Rule): # 134..155 "address(this).balance" - MemberAccessExpression (Rule): # 134..155 "address(this).balance" - Expression (Rule): # 134..147 "address(this)" diff --git a/crates/solidity/testing/snapshots/cst_output/ContractDefinition/function_multiple_delimiters/generated/0.8.0-success.yml b/crates/solidity/testing/snapshots/cst_output/ContractDefinition/function_multiple_delimiters/generated/0.8.0-success.yml index f51fff9e96..aaf9eff1e8 100644 --- a/crates/solidity/testing/snapshots/cst_output/ContractDefinition/function_multiple_delimiters/generated/0.8.0-success.yml +++ b/crates/solidity/testing/snapshots/cst_output/ContractDefinition/function_multiple_delimiters/generated/0.8.0-success.yml @@ -61,7 +61,7 @@ Tree: - OpenParen (Token): "(" # 133..134 - PositionalArguments (Rule): # 134..198 'address(this).balance >= amount, "Address: insuffi...' - Expression (Rule): # 134..165 "address(this).balance >= amount" - - BinaryExpression (Rule): # 134..165 "address(this).balance >= amount" + - ComparisonExpression (Rule): # 134..165 "address(this).balance >= amount" - Expression (Rule): # 134..155 "address(this).balance" - MemberAccessExpression (Rule): # 134..155 "address(this).balance" - Expression (Rule): # 134..147 "address(this)" diff --git a/crates/solidity/testing/snapshots/cst_output/ContractMembers/local_expression/generated/0.4.11-success.yml b/crates/solidity/testing/snapshots/cst_output/ContractMembers/local_expression/generated/0.4.11-success.yml index f3dd2450ae..f53ce61cc1 100644 --- a/crates/solidity/testing/snapshots/cst_output/ContractMembers/local_expression/generated/0.4.11-success.yml +++ b/crates/solidity/testing/snapshots/cst_output/ContractMembers/local_expression/generated/0.4.11-success.yml @@ -31,13 +31,13 @@ Tree: - VariableDeclarationValue (Rule): # 26..38 " = 1 + 2 * 3" - Equal (Token): "=" # 27..28 - Expression (Rule): # 28..38 " 1 + 2 * 3" - - BinaryExpression (Rule): # 28..38 " 1 + 2 * 3" + - AdditiveExpression (Rule): # 28..38 " 1 + 2 * 3" - Expression (Rule): # 28..30 " 1" - DecimalNumberExpression (Rule): # 28..30 " 1" - DecimalLiteral (Token): "1" # 29..30 - Plus (Token): "+" # 31..32 - Expression (Rule): # 32..38 " 2 * 3" - - BinaryExpression (Rule): # 32..38 " 2 * 3" + - MultiplicativeExpression (Rule): # 32..38 " 2 * 3" - Expression (Rule): # 32..34 " 2" - DecimalNumberExpression (Rule): # 32..34 " 2" - DecimalLiteral (Token): "2" # 33..34 diff --git a/crates/solidity/testing/snapshots/cst_output/ContractMembers/mismatched_delimiter/generated/0.4.11-failure.yml b/crates/solidity/testing/snapshots/cst_output/ContractMembers/mismatched_delimiter/generated/0.4.11-failure.yml index cd3cf512d1..c8e6501e7e 100644 --- a/crates/solidity/testing/snapshots/cst_output/ContractMembers/mismatched_delimiter/generated/0.4.11-failure.yml +++ b/crates/solidity/testing/snapshots/cst_output/ContractMembers/mismatched_delimiter/generated/0.4.11-failure.yml @@ -62,7 +62,7 @@ Tree: - TupleValues (Rule): # 58..63 "1 + 2" - TupleValue (Rule): # 58..63 "1 + 2" - Expression (Rule): # 58..63 "1 + 2" - - BinaryExpression (Rule): # 58..63 "1 + 2" + - AdditiveExpression (Rule): # 58..63 "1 + 2" - Expression (Rule): # 58..59 "1" - DecimalNumberExpression (Rule): # 58..59 "1" - DecimalLiteral (Token): "1" # 58..59 diff --git a/crates/solidity/testing/snapshots/cst_output/ContractMembers/mismatched_delimiter/generated/0.4.21-failure.yml b/crates/solidity/testing/snapshots/cst_output/ContractMembers/mismatched_delimiter/generated/0.4.21-failure.yml index afd17fa0ed..383bf63366 100644 --- a/crates/solidity/testing/snapshots/cst_output/ContractMembers/mismatched_delimiter/generated/0.4.21-failure.yml +++ b/crates/solidity/testing/snapshots/cst_output/ContractMembers/mismatched_delimiter/generated/0.4.21-failure.yml @@ -62,7 +62,7 @@ Tree: - TupleValues (Rule): # 58..63 "1 + 2" - TupleValue (Rule): # 58..63 "1 + 2" - Expression (Rule): # 58..63 "1 + 2" - - BinaryExpression (Rule): # 58..63 "1 + 2" + - AdditiveExpression (Rule): # 58..63 "1 + 2" - Expression (Rule): # 58..59 "1" - DecimalNumberExpression (Rule): # 58..59 "1" - DecimalLiteral (Token): "1" # 58..59 diff --git a/crates/solidity/testing/snapshots/cst_output/ContractMembers/mismatched_delimiter/generated/0.5.0-failure.yml b/crates/solidity/testing/snapshots/cst_output/ContractMembers/mismatched_delimiter/generated/0.5.0-failure.yml index bd1f4c2e2d..c99b4ac7db 100644 --- a/crates/solidity/testing/snapshots/cst_output/ContractMembers/mismatched_delimiter/generated/0.5.0-failure.yml +++ b/crates/solidity/testing/snapshots/cst_output/ContractMembers/mismatched_delimiter/generated/0.5.0-failure.yml @@ -62,7 +62,7 @@ Tree: - TupleValues (Rule): # 58..63 "1 + 2" - TupleValue (Rule): # 58..63 "1 + 2" - Expression (Rule): # 58..63 "1 + 2" - - BinaryExpression (Rule): # 58..63 "1 + 2" + - AdditiveExpression (Rule): # 58..63 "1 + 2" - Expression (Rule): # 58..59 "1" - DecimalNumberExpression (Rule): # 58..59 "1" - DecimalLiteral (Token): "1" # 58..59 diff --git a/crates/solidity/testing/snapshots/cst_output/ContractMembers/mismatched_delimiter/generated/0.5.3-failure.yml b/crates/solidity/testing/snapshots/cst_output/ContractMembers/mismatched_delimiter/generated/0.5.3-failure.yml index c492dce64f..689d1fcc3f 100644 --- a/crates/solidity/testing/snapshots/cst_output/ContractMembers/mismatched_delimiter/generated/0.5.3-failure.yml +++ b/crates/solidity/testing/snapshots/cst_output/ContractMembers/mismatched_delimiter/generated/0.5.3-failure.yml @@ -62,7 +62,7 @@ Tree: - TupleValues (Rule): # 58..63 "1 + 2" - TupleValue (Rule): # 58..63 "1 + 2" - Expression (Rule): # 58..63 "1 + 2" - - BinaryExpression (Rule): # 58..63 "1 + 2" + - AdditiveExpression (Rule): # 58..63 "1 + 2" - Expression (Rule): # 58..59 "1" - DecimalNumberExpression (Rule): # 58..59 "1" - DecimalLiteral (Token): "1" # 58..59 diff --git a/crates/solidity/testing/snapshots/cst_output/ContractMembers/mismatched_delimiter/generated/0.6.0-failure.yml b/crates/solidity/testing/snapshots/cst_output/ContractMembers/mismatched_delimiter/generated/0.6.0-failure.yml index 143d3fcf3b..7619f3e5aa 100644 --- a/crates/solidity/testing/snapshots/cst_output/ContractMembers/mismatched_delimiter/generated/0.6.0-failure.yml +++ b/crates/solidity/testing/snapshots/cst_output/ContractMembers/mismatched_delimiter/generated/0.6.0-failure.yml @@ -62,7 +62,7 @@ Tree: - TupleValues (Rule): # 58..63 "1 + 2" - TupleValue (Rule): # 58..63 "1 + 2" - Expression (Rule): # 58..63 "1 + 2" - - BinaryExpression (Rule): # 58..63 "1 + 2" + - AdditiveExpression (Rule): # 58..63 "1 + 2" - Expression (Rule): # 58..59 "1" - DecimalNumberExpression (Rule): # 58..59 "1" - DecimalLiteral (Token): "1" # 58..59 diff --git a/crates/solidity/testing/snapshots/cst_output/ContractMembers/mismatched_delimiter/generated/0.7.0-failure.yml b/crates/solidity/testing/snapshots/cst_output/ContractMembers/mismatched_delimiter/generated/0.7.0-failure.yml index 07aa14ec80..2e6a45acd9 100644 --- a/crates/solidity/testing/snapshots/cst_output/ContractMembers/mismatched_delimiter/generated/0.7.0-failure.yml +++ b/crates/solidity/testing/snapshots/cst_output/ContractMembers/mismatched_delimiter/generated/0.7.0-failure.yml @@ -62,7 +62,7 @@ Tree: - TupleValues (Rule): # 58..63 "1 + 2" - TupleValue (Rule): # 58..63 "1 + 2" - Expression (Rule): # 58..63 "1 + 2" - - BinaryExpression (Rule): # 58..63 "1 + 2" + - AdditiveExpression (Rule): # 58..63 "1 + 2" - Expression (Rule): # 58..59 "1" - DecimalNumberExpression (Rule): # 58..59 "1" - DecimalLiteral (Token): "1" # 58..59 diff --git a/crates/solidity/testing/snapshots/cst_output/ContractMembers/mismatched_delimiter/generated/0.8.0-failure.yml b/crates/solidity/testing/snapshots/cst_output/ContractMembers/mismatched_delimiter/generated/0.8.0-failure.yml index 56729fe767..45fe6dc70c 100644 --- a/crates/solidity/testing/snapshots/cst_output/ContractMembers/mismatched_delimiter/generated/0.8.0-failure.yml +++ b/crates/solidity/testing/snapshots/cst_output/ContractMembers/mismatched_delimiter/generated/0.8.0-failure.yml @@ -62,7 +62,7 @@ Tree: - TupleValues (Rule): # 58..63 "1 + 2" - TupleValue (Rule): # 58..63 "1 + 2" - Expression (Rule): # 58..63 "1 + 2" - - BinaryExpression (Rule): # 58..63 "1 + 2" + - AdditiveExpression (Rule): # 58..63 "1 + 2" - Expression (Rule): # 58..59 "1" - DecimalNumberExpression (Rule): # 58..59 "1" - DecimalLiteral (Token): "1" # 58..59 diff --git a/crates/solidity/testing/snapshots/cst_output/ContractMembers/mismatched_delimiter/generated/0.8.4-failure.yml b/crates/solidity/testing/snapshots/cst_output/ContractMembers/mismatched_delimiter/generated/0.8.4-failure.yml index 922c4458f3..f459533ed9 100644 --- a/crates/solidity/testing/snapshots/cst_output/ContractMembers/mismatched_delimiter/generated/0.8.4-failure.yml +++ b/crates/solidity/testing/snapshots/cst_output/ContractMembers/mismatched_delimiter/generated/0.8.4-failure.yml @@ -62,7 +62,7 @@ Tree: - TupleValues (Rule): # 58..63 "1 + 2" - TupleValue (Rule): # 58..63 "1 + 2" - Expression (Rule): # 58..63 "1 + 2" - - BinaryExpression (Rule): # 58..63 "1 + 2" + - AdditiveExpression (Rule): # 58..63 "1 + 2" - Expression (Rule): # 58..59 "1" - DecimalNumberExpression (Rule): # 58..59 "1" - DecimalLiteral (Token): "1" # 58..59 diff --git a/crates/solidity/testing/snapshots/cst_output/ExponentiationExpression/associativity/generated/0.4.11-success.yml b/crates/solidity/testing/snapshots/cst_output/ExponentiationExpression/associativity/generated/0.4.11-success.yml new file mode 100644 index 0000000000..885d2a9fbf --- /dev/null +++ b/crates/solidity/testing/snapshots/cst_output/ExponentiationExpression/associativity/generated/0.4.11-success.yml @@ -0,0 +1,19 @@ +# This file is generated automatically by infrastructure scripts. Please don't edit by hand. + +Source: > + 1 │ x ** y ** z │ 0..11 + +Errors: [] + +Tree: + - ExponentiationExpression (Rule): # 0..12 "x ** y ** z\n" + - Expression (Rule): # 0..6 "x ** y" + - ExponentiationExpression (Rule): # 0..6 "x ** y" + - Expression (Rule): # 0..1 "x" + - Identifier (Token): "x" # 0..1 + - AsteriskAsterisk (Token): "**" # 2..4 + - Expression (Rule): # 4..6 " y" + - Identifier (Token): "y" # 5..6 + - AsteriskAsterisk (Token): "**" # 7..9 + - Expression (Rule): # 9..12 " z\n" + - Identifier (Token): "z" # 10..11 diff --git a/crates/solidity/testing/snapshots/cst_output/ExponentiationExpression/associativity/generated/0.6.0-success.yml b/crates/solidity/testing/snapshots/cst_output/ExponentiationExpression/associativity/generated/0.6.0-success.yml new file mode 100644 index 0000000000..5bacd2885b --- /dev/null +++ b/crates/solidity/testing/snapshots/cst_output/ExponentiationExpression/associativity/generated/0.6.0-success.yml @@ -0,0 +1,19 @@ +# This file is generated automatically by infrastructure scripts. Please don't edit by hand. + +Source: > + 1 │ x ** y ** z │ 0..11 + +Errors: [] + +Tree: + - ExponentiationExpression (Rule): # 0..12 "x ** y ** z\n" + - Expression (Rule): # 0..1 "x" + - Identifier (Token): "x" # 0..1 + - AsteriskAsterisk (Token): "**" # 2..4 + - Expression (Rule): # 4..12 " y ** z\n" + - ExponentiationExpression (Rule): # 4..12 " y ** z\n" + - Expression (Rule): # 4..6 " y" + - Identifier (Token): "y" # 5..6 + - AsteriskAsterisk (Token): "**" # 7..9 + - Expression (Rule): # 9..12 " z\n" + - Identifier (Token): "z" # 10..11 diff --git a/crates/solidity/testing/snapshots/cst_output/Expression/exponentiation_operator_associativity/input.sol b/crates/solidity/testing/snapshots/cst_output/ExponentiationExpression/associativity/input.sol similarity index 100% rename from crates/solidity/testing/snapshots/cst_output/Expression/exponentiation_operator_associativity/input.sol rename to crates/solidity/testing/snapshots/cst_output/ExponentiationExpression/associativity/input.sol diff --git a/crates/solidity/testing/snapshots/cst_output/Expression/add_mul/generated/0.4.11-success.yml b/crates/solidity/testing/snapshots/cst_output/Expression/add_mul/generated/0.4.11-success.yml index aee0045a2f..922a084e86 100644 --- a/crates/solidity/testing/snapshots/cst_output/Expression/add_mul/generated/0.4.11-success.yml +++ b/crates/solidity/testing/snapshots/cst_output/Expression/add_mul/generated/0.4.11-success.yml @@ -7,9 +7,9 @@ Errors: [] Tree: - Expression (Rule): # 0..13 "a * b + c * d" - - BinaryExpression (Rule): # 0..13 "a * b + c * d" + - AdditiveExpression (Rule): # 0..13 "a * b + c * d" - Expression (Rule): # 0..5 "a * b" - - BinaryExpression (Rule): # 0..5 "a * b" + - MultiplicativeExpression (Rule): # 0..5 "a * b" - Expression (Rule): # 0..1 "a" - Identifier (Token): "a" # 0..1 - Asterisk (Token): "*" # 2..3 @@ -17,7 +17,7 @@ Tree: - Identifier (Token): "b" # 4..5 - Plus (Token): "+" # 6..7 - Expression (Rule): # 7..13 " c * d" - - BinaryExpression (Rule): # 7..13 " c * d" + - MultiplicativeExpression (Rule): # 7..13 " c * d" - Expression (Rule): # 7..9 " c" - Identifier (Token): "c" # 8..9 - Asterisk (Token): "*" # 10..11 diff --git a/crates/solidity/testing/snapshots/cst_output/Expression/conditional_expression_identifier_base/generated/0.4.11-success.yml b/crates/solidity/testing/snapshots/cst_output/Expression/conditional_expression_identifier_base/generated/0.4.11-success.yml deleted file mode 100644 index 0c7a33c1d2..0000000000 --- a/crates/solidity/testing/snapshots/cst_output/Expression/conditional_expression_identifier_base/generated/0.4.11-success.yml +++ /dev/null @@ -1,18 +0,0 @@ -# This file is generated automatically by infrastructure scripts. Please don't edit by hand. - -Source: > - 1 │ foo ? true : false │ 0..18 - -Errors: [] - -Tree: - - Expression (Rule): # 0..18 "foo ? true : false" - - ConditionalExpression (Rule): # 0..18 "foo ? true : false" - - Expression (Rule): # 0..3 "foo" - - Identifier (Token): "foo" # 0..3 - - QuestionMark (Token): "?" # 4..5 - - Expression (Rule): # 5..10 " true" - - TrueKeyword (Token): "true" # 6..10 - - Colon (Token): ":" # 11..12 - - Expression (Rule): # 12..18 " false" - - FalseKeyword (Token): "false" # 13..18 diff --git a/crates/solidity/testing/snapshots/cst_output/Expression/conditional_expression_nested_base/generated/0.4.11-success.yml b/crates/solidity/testing/snapshots/cst_output/Expression/conditional_expression_nested_base/generated/0.4.11-success.yml deleted file mode 100644 index 3b021353bc..0000000000 --- a/crates/solidity/testing/snapshots/cst_output/Expression/conditional_expression_nested_base/generated/0.4.11-success.yml +++ /dev/null @@ -1,29 +0,0 @@ -# This file is generated automatically by infrastructure scripts. Please don't edit by hand. - -Source: > - 1 │ (foo == bar) ? true : false │ 0..27 - -Errors: [] - -Tree: - - Expression (Rule): # 0..27 "(foo == bar) ? true : false" - - ConditionalExpression (Rule): # 0..27 "(foo == bar) ? true : false" - - Expression (Rule): # 0..12 "(foo == bar)" - - TupleExpression (Rule): # 0..12 "(foo == bar)" - - OpenParen (Token): "(" # 0..1 - - TupleValues (Rule): # 1..11 "foo == bar" - - TupleValue (Rule): # 1..11 "foo == bar" - - Expression (Rule): # 1..11 "foo == bar" - - BinaryExpression (Rule): # 1..11 "foo == bar" - - Expression (Rule): # 1..4 "foo" - - Identifier (Token): "foo" # 1..4 - - EqualEqual (Token): "==" # 5..7 - - Expression (Rule): # 7..11 " bar" - - Identifier (Token): "bar" # 8..11 - - CloseParen (Token): ")" # 11..12 - - QuestionMark (Token): "?" # 13..14 - - Expression (Rule): # 14..19 " true" - - TrueKeyword (Token): "true" # 15..19 - - Colon (Token): ":" # 20..21 - - Expression (Rule): # 21..27 " false" - - FalseKeyword (Token): "false" # 22..27 diff --git a/crates/solidity/testing/snapshots/cst_output/Expression/conditional_expression_nested_conditions/generated/0.4.11-success.yml b/crates/solidity/testing/snapshots/cst_output/Expression/conditional_expression_nested_conditions/generated/0.4.11-success.yml deleted file mode 100644 index 7420172850..0000000000 --- a/crates/solidity/testing/snapshots/cst_output/Expression/conditional_expression_nested_conditions/generated/0.4.11-success.yml +++ /dev/null @@ -1,40 +0,0 @@ -# This file is generated automatically by infrastructure scripts. Please don't edit by hand. - -Source: > - 1 │ foo ? (a + b) : (c + d) │ 0..23 - -Errors: [] - -Tree: - - Expression (Rule): # 0..23 "foo ? (a + b) : (c + d)" - - ConditionalExpression (Rule): # 0..23 "foo ? (a + b) : (c + d)" - - Expression (Rule): # 0..3 "foo" - - Identifier (Token): "foo" # 0..3 - - QuestionMark (Token): "?" # 4..5 - - Expression (Rule): # 5..13 " (a + b)" - - TupleExpression (Rule): # 5..13 " (a + b)" - - OpenParen (Token): "(" # 6..7 - - TupleValues (Rule): # 7..12 "a + b" - - TupleValue (Rule): # 7..12 "a + b" - - Expression (Rule): # 7..12 "a + b" - - BinaryExpression (Rule): # 7..12 "a + b" - - Expression (Rule): # 7..8 "a" - - Identifier (Token): "a" # 7..8 - - Plus (Token): "+" # 9..10 - - Expression (Rule): # 10..12 " b" - - Identifier (Token): "b" # 11..12 - - CloseParen (Token): ")" # 12..13 - - Colon (Token): ":" # 14..15 - - Expression (Rule): # 15..23 " (c + d)" - - TupleExpression (Rule): # 15..23 " (c + d)" - - OpenParen (Token): "(" # 16..17 - - TupleValues (Rule): # 17..22 "c + d" - - TupleValue (Rule): # 17..22 "c + d" - - Expression (Rule): # 17..22 "c + d" - - BinaryExpression (Rule): # 17..22 "c + d" - - Expression (Rule): # 17..18 "c" - - Identifier (Token): "c" # 17..18 - - Plus (Token): "+" # 19..20 - - Expression (Rule): # 20..22 " d" - - Identifier (Token): "d" # 21..22 - - CloseParen (Token): ")" # 22..23 diff --git a/crates/solidity/testing/snapshots/cst_output/Expression/conditional_expression_recursive/generated/0.4.11-success.yml b/crates/solidity/testing/snapshots/cst_output/Expression/conditional_expression_recursive/generated/0.4.11-success.yml deleted file mode 100644 index aec8fe9d28..0000000000 --- a/crates/solidity/testing/snapshots/cst_output/Expression/conditional_expression_recursive/generated/0.4.11-success.yml +++ /dev/null @@ -1,77 +0,0 @@ -# This file is generated automatically by infrastructure scripts. Please don't edit by hand. - -Source: > - 1 │ foo ? a == b ? a + b * c : a + b * c + d : !bar ? e + f : g + h │ 0..63 - -Errors: [] - -Tree: - - Expression (Rule): # 0..63 "foo ? a == b ? a + b * c : a + b * c + d : !bar ? ..." - - ConditionalExpression (Rule): # 0..63 "foo ? a == b ? a + b * c : a + b * c + d : !bar ? ..." - - Expression (Rule): # 0..3 "foo" - - Identifier (Token): "foo" # 0..3 - - QuestionMark (Token): "?" # 4..5 - - Expression (Rule): # 5..40 " a == b ? a + b * c : a + b * c + d" - - ConditionalExpression (Rule): # 5..40 " a == b ? a + b * c : a + b * c + d" - - Expression (Rule): # 5..12 " a == b" - - BinaryExpression (Rule): # 5..12 " a == b" - - Expression (Rule): # 5..7 " a" - - Identifier (Token): "a" # 6..7 - - EqualEqual (Token): "==" # 8..10 - - Expression (Rule): # 10..12 " b" - - Identifier (Token): "b" # 11..12 - - QuestionMark (Token): "?" # 13..14 - - Expression (Rule): # 14..24 " a + b * c" - - BinaryExpression (Rule): # 14..24 " a + b * c" - - Expression (Rule): # 14..16 " a" - - Identifier (Token): "a" # 15..16 - - Plus (Token): "+" # 17..18 - - Expression (Rule): # 18..24 " b * c" - - BinaryExpression (Rule): # 18..24 " b * c" - - Expression (Rule): # 18..20 " b" - - Identifier (Token): "b" # 19..20 - - Asterisk (Token): "*" # 21..22 - - Expression (Rule): # 22..24 " c" - - Identifier (Token): "c" # 23..24 - - Colon (Token): ":" # 25..26 - - Expression (Rule): # 26..40 " a + b * c + d" - - BinaryExpression (Rule): # 26..40 " a + b * c + d" - - Expression (Rule): # 26..36 " a + b * c" - - BinaryExpression (Rule): # 26..36 " a + b * c" - - Expression (Rule): # 26..28 " a" - - Identifier (Token): "a" # 27..28 - - Plus (Token): "+" # 29..30 - - Expression (Rule): # 30..36 " b * c" - - BinaryExpression (Rule): # 30..36 " b * c" - - Expression (Rule): # 30..32 " b" - - Identifier (Token): "b" # 31..32 - - Asterisk (Token): "*" # 33..34 - - Expression (Rule): # 34..36 " c" - - Identifier (Token): "c" # 35..36 - - Plus (Token): "+" # 37..38 - - Expression (Rule): # 38..40 " d" - - Identifier (Token): "d" # 39..40 - - Colon (Token): ":" # 41..42 - - Expression (Rule): # 42..63 " !bar ? e + f : g + h" - - ConditionalExpression (Rule): # 42..63 " !bar ? e + f : g + h" - - Expression (Rule): # 42..47 " !bar" - - UnaryPrefixExpression (Rule): # 42..47 " !bar" - - Bang (Token): "!" # 43..44 - - Expression (Rule): # 44..47 "bar" - - Identifier (Token): "bar" # 44..47 - - QuestionMark (Token): "?" # 48..49 - - Expression (Rule): # 49..55 " e + f" - - BinaryExpression (Rule): # 49..55 " e + f" - - Expression (Rule): # 49..51 " e" - - Identifier (Token): "e" # 50..51 - - Plus (Token): "+" # 52..53 - - Expression (Rule): # 53..55 " f" - - Identifier (Token): "f" # 54..55 - - Colon (Token): ":" # 56..57 - - Expression (Rule): # 57..63 " g + h" - - BinaryExpression (Rule): # 57..63 " g + h" - - Expression (Rule): # 57..59 " g" - - Identifier (Token): "g" # 58..59 - - Plus (Token): "+" # 60..61 - - Expression (Rule): # 61..63 " h" - - Identifier (Token): "h" # 62..63 diff --git a/crates/solidity/testing/snapshots/cst_output/Expression/exponentiation_operator_associativity/generated/0.4.11-success.yml b/crates/solidity/testing/snapshots/cst_output/Expression/exponentiation_operator_associativity/generated/0.4.11-success.yml deleted file mode 100644 index cbb412d261..0000000000 --- a/crates/solidity/testing/snapshots/cst_output/Expression/exponentiation_operator_associativity/generated/0.4.11-success.yml +++ /dev/null @@ -1,20 +0,0 @@ -# This file is generated automatically by infrastructure scripts. Please don't edit by hand. - -Source: > - 1 │ x ** y ** z │ 0..11 - -Errors: [] - -Tree: - - Expression (Rule): # 0..12 "x ** y ** z\n" - - BinaryExpression (Rule): # 0..12 "x ** y ** z\n" - - Expression (Rule): # 0..6 "x ** y" - - BinaryExpression (Rule): # 0..6 "x ** y" - - Expression (Rule): # 0..1 "x" - - Identifier (Token): "x" # 0..1 - - AsteriskAsterisk (Token): "**" # 2..4 - - Expression (Rule): # 4..6 " y" - - Identifier (Token): "y" # 5..6 - - AsteriskAsterisk (Token): "**" # 7..9 - - Expression (Rule): # 9..12 " z\n" - - Identifier (Token): "z" # 10..11 diff --git a/crates/solidity/testing/snapshots/cst_output/Expression/exponentiation_operator_associativity/generated/0.6.0-success.yml b/crates/solidity/testing/snapshots/cst_output/Expression/exponentiation_operator_associativity/generated/0.6.0-success.yml deleted file mode 100644 index 7013645345..0000000000 --- a/crates/solidity/testing/snapshots/cst_output/Expression/exponentiation_operator_associativity/generated/0.6.0-success.yml +++ /dev/null @@ -1,20 +0,0 @@ -# This file is generated automatically by infrastructure scripts. Please don't edit by hand. - -Source: > - 1 │ x ** y ** z │ 0..11 - -Errors: [] - -Tree: - - Expression (Rule): # 0..12 "x ** y ** z\n" - - BinaryExpression (Rule): # 0..12 "x ** y ** z\n" - - Expression (Rule): # 0..1 "x" - - Identifier (Token): "x" # 0..1 - - AsteriskAsterisk (Token): "**" # 2..4 - - Expression (Rule): # 4..12 " y ** z\n" - - BinaryExpression (Rule): # 4..12 " y ** z\n" - - Expression (Rule): # 4..6 " y" - - Identifier (Token): "y" # 5..6 - - AsteriskAsterisk (Token): "**" # 7..9 - - Expression (Rule): # 9..12 " z\n" - - Identifier (Token): "z" # 10..11 diff --git a/crates/solidity/testing/snapshots/cst_output/Expression/incomplete_operand/generated/0.4.11-failure.yml b/crates/solidity/testing/snapshots/cst_output/Expression/incomplete_operand/generated/0.4.11-failure.yml index 6ba8946815..587426dcdd 100644 --- a/crates/solidity/testing/snapshots/cst_output/Expression/incomplete_operand/generated/0.4.11-failure.yml +++ b/crates/solidity/testing/snapshots/cst_output/Expression/incomplete_operand/generated/0.4.11-failure.yml @@ -17,7 +17,7 @@ Tree: - Expression (Rule): # 0..8 "2 * new\n" - DecimalNumberExpression (Rule): # 0..1 "2" - DecimalLiteral (Token): "2" # 0..1 - - BinaryExpression (Rule): # 1..3 " *" + - MultiplicativeExpression (Rule): # 1..3 " *" - Asterisk (Token): "*" # 2..3 - NewExpression (Rule): # 3..8 " new\n" - NewKeyword (Token): "new" # 4..7 diff --git a/crates/solidity/testing/snapshots/cst_output/Expression/incomplete_operand/generated/0.8.0-failure.yml b/crates/solidity/testing/snapshots/cst_output/Expression/incomplete_operand/generated/0.8.0-failure.yml index cfab07a5ed..b2d55fbc61 100644 --- a/crates/solidity/testing/snapshots/cst_output/Expression/incomplete_operand/generated/0.8.0-failure.yml +++ b/crates/solidity/testing/snapshots/cst_output/Expression/incomplete_operand/generated/0.8.0-failure.yml @@ -17,7 +17,7 @@ Tree: - Expression (Rule): # 0..8 "2 * new\n" - DecimalNumberExpression (Rule): # 0..1 "2" - DecimalLiteral (Token): "2" # 0..1 - - BinaryExpression (Rule): # 1..3 " *" + - MultiplicativeExpression (Rule): # 1..3 " *" - Asterisk (Token): "*" # 2..3 - NewExpression (Rule): # 3..8 " new\n" - NewKeyword (Token): "new" # 4..7 diff --git a/crates/solidity/testing/snapshots/cst_output/Expression/overlapping_operators/generated/0.4.11-success.yml b/crates/solidity/testing/snapshots/cst_output/Expression/overlapping_operators/generated/0.4.11-success.yml index 0c0a5b4824..f93c60cb07 100644 --- a/crates/solidity/testing/snapshots/cst_output/Expression/overlapping_operators/generated/0.4.11-success.yml +++ b/crates/solidity/testing/snapshots/cst_output/Expression/overlapping_operators/generated/0.4.11-success.yml @@ -7,9 +7,9 @@ Errors: [] Tree: - Expression (Rule): # 0..10 "a & b && c" - - BinaryExpression (Rule): # 0..10 "a & b && c" + - AndExpression (Rule): # 0..10 "a & b && c" - Expression (Rule): # 0..5 "a & b" - - BinaryExpression (Rule): # 0..5 "a & b" + - BitwiseAndExpression (Rule): # 0..5 "a & b" - Expression (Rule): # 0..1 "a" - Identifier (Token): "a" # 0..1 - Ampersand (Token): "&" # 2..3 diff --git a/crates/solidity/testing/snapshots/cst_output/Expression/postfix_decrement/generated/0.4.11-success.yml b/crates/solidity/testing/snapshots/cst_output/Expression/postfix_decrement/generated/0.4.11-success.yml index f4b6083343..5509dded67 100644 --- a/crates/solidity/testing/snapshots/cst_output/Expression/postfix_decrement/generated/0.4.11-success.yml +++ b/crates/solidity/testing/snapshots/cst_output/Expression/postfix_decrement/generated/0.4.11-success.yml @@ -7,7 +7,7 @@ Errors: [] Tree: - Expression (Rule): # 0..5 "foo--" - - UnaryPostfixExpression (Rule): # 0..5 "foo--" + - PostfixExpression (Rule): # 0..5 "foo--" - Expression (Rule): # 0..3 "foo" - Identifier (Token): "foo" # 0..3 - MinusMinus (Token): "--" # 3..5 diff --git a/crates/solidity/testing/snapshots/cst_output/Expression/prefix_decrement/generated/0.4.11-success.yml b/crates/solidity/testing/snapshots/cst_output/Expression/prefix_decrement/generated/0.4.11-success.yml index d1f1d2e7c0..31cc07c850 100644 --- a/crates/solidity/testing/snapshots/cst_output/Expression/prefix_decrement/generated/0.4.11-success.yml +++ b/crates/solidity/testing/snapshots/cst_output/Expression/prefix_decrement/generated/0.4.11-success.yml @@ -7,7 +7,7 @@ Errors: [] Tree: - Expression (Rule): # 0..5 "--foo" - - UnaryPrefixExpression (Rule): # 0..5 "--foo" + - PrefixExpression (Rule): # 0..5 "--foo" - MinusMinus (Token): "--" # 0..2 - Expression (Rule): # 2..5 "foo" - Identifier (Token): "foo" # 2..5 diff --git a/crates/solidity/testing/snapshots/cst_output/Expression/prefix_minus/generated/0.4.11-success.yml b/crates/solidity/testing/snapshots/cst_output/Expression/prefix_minus/generated/0.4.11-success.yml index 37c36f3ce0..0e1234045d 100644 --- a/crates/solidity/testing/snapshots/cst_output/Expression/prefix_minus/generated/0.4.11-success.yml +++ b/crates/solidity/testing/snapshots/cst_output/Expression/prefix_minus/generated/0.4.11-success.yml @@ -7,7 +7,7 @@ Errors: [] Tree: - Expression (Rule): # 0..4 "-foo" - - UnaryPrefixExpression (Rule): # 0..4 "-foo" + - PrefixExpression (Rule): # 0..4 "-foo" - Minus (Token): "-" # 0..1 - Expression (Rule): # 1..4 "foo" - Identifier (Token): "foo" # 1..4 diff --git a/crates/solidity/testing/snapshots/cst_output/Expression/prefix_plus/generated/0.4.11-success.yml b/crates/solidity/testing/snapshots/cst_output/Expression/prefix_plus/generated/0.4.11-success.yml index 1687596b40..2e4d204281 100644 --- a/crates/solidity/testing/snapshots/cst_output/Expression/prefix_plus/generated/0.4.11-success.yml +++ b/crates/solidity/testing/snapshots/cst_output/Expression/prefix_plus/generated/0.4.11-success.yml @@ -7,7 +7,7 @@ Errors: [] Tree: - Expression (Rule): # 0..4 "+foo" - - UnaryPrefixExpression (Rule): # 0..4 "+foo" + - PrefixExpression (Rule): # 0..4 "+foo" - Plus (Token): "+" # 0..1 - Expression (Rule): # 1..4 "foo" - Identifier (Token): "foo" # 1..4 diff --git a/crates/solidity/testing/snapshots/cst_output/ReturnStatement/invalid_terminator/generated/0.4.11-failure.yml b/crates/solidity/testing/snapshots/cst_output/ReturnStatement/invalid_terminator/generated/0.4.11-failure.yml index f43ed89169..7cd5253828 100644 --- a/crates/solidity/testing/snapshots/cst_output/ReturnStatement/invalid_terminator/generated/0.4.11-failure.yml +++ b/crates/solidity/testing/snapshots/cst_output/ReturnStatement/invalid_terminator/generated/0.4.11-failure.yml @@ -20,12 +20,12 @@ Tree: - ReturnStatement (Rule): # 0..38 "return a + 2 * some invalid tokens\n\n;\n" - ReturnKeyword (Token): "return" # 0..6 - Expression (Rule): # 6..19 " a + 2 * some" - - BinaryExpression (Rule): # 6..19 " a + 2 * some" + - AdditiveExpression (Rule): # 6..19 " a + 2 * some" - Expression (Rule): # 6..8 " a" - Identifier (Token): "a" # 7..8 - Plus (Token): "+" # 9..10 - Expression (Rule): # 10..19 " 2 * some" - - BinaryExpression (Rule): # 10..19 " 2 * some" + - MultiplicativeExpression (Rule): # 10..19 " 2 * some" - Expression (Rule): # 10..12 " 2" - DecimalNumberExpression (Rule): # 10..12 " 2" - DecimalLiteral (Token): "2" # 11..12 diff --git a/crates/solidity/testing/snapshots/cst_output/SourceUnit/SafeMath/generated/0.8.0-success.yml b/crates/solidity/testing/snapshots/cst_output/SourceUnit/SafeMath/generated/0.8.0-success.yml index c49ace0c34..a96a945288 100644 --- a/crates/solidity/testing/snapshots/cst_output/SourceUnit/SafeMath/generated/0.8.0-success.yml +++ b/crates/solidity/testing/snapshots/cst_output/SourceUnit/SafeMath/generated/0.8.0-success.yml @@ -82,7 +82,7 @@ Tree: - VariableDeclarationValue (Rule): # 130..138 " = a + b" - Equal (Token): "=" # 131..132 - Expression (Rule): # 132..138 " a + b" - - BinaryExpression (Rule): # 132..138 " a + b" + - AdditiveExpression (Rule): # 132..138 " a + b" - Expression (Rule): # 132..134 " a" - Identifier (Token): "a" # 133..134 - Plus (Token): "+" # 135..136 @@ -94,7 +94,7 @@ Tree: - IfKeyword (Token): "if" # 146..148 - OpenParen (Token): "(" # 149..150 - Expression (Rule): # 150..155 "c < a" - - BinaryExpression (Rule): # 150..155 "c < a" + - ComparisonExpression (Rule): # 150..155 "c < a" - Expression (Rule): # 150..151 "c" - Identifier (Token): "c" # 150..151 - LessThan (Token): "<" # 152..153 diff --git a/crates/solidity/testing/snapshots/cst_output/SourceUnit/using_directive/generated/0.4.11-failure.yml b/crates/solidity/testing/snapshots/cst_output/SourceUnit/using_directive/generated/0.4.11-failure.yml index d4a72b3797..94fb5672b2 100644 --- a/crates/solidity/testing/snapshots/cst_output/SourceUnit/using_directive/generated/0.4.11-failure.yml +++ b/crates/solidity/testing/snapshots/cst_output/SourceUnit/using_directive/generated/0.4.11-failure.yml @@ -50,7 +50,7 @@ Tree: - SolidityKeyword (Token): "solidity" # 39..47 - VersionPragmaExpressions (Rule): # 47..54 " ^0.8.0" - VersionPragmaExpression (Rule): # 47..54 " ^0.8.0" - - VersionPragmaUnaryExpression (Rule): # 47..54 " ^0.8.0" + - VersionPragmaPrefixExpression (Rule): # 47..54 " ^0.8.0" - Caret (Token): "^" # 48..49 - VersionPragmaExpression (Rule): # 49..54 "0.8.0" - VersionPragmaSpecifier (Rule): # 49..54 "0.8.0" diff --git a/crates/solidity/testing/snapshots/cst_output/SourceUnit/using_directive/generated/0.8.13-success.yml b/crates/solidity/testing/snapshots/cst_output/SourceUnit/using_directive/generated/0.8.13-success.yml index 0ef1dc5c7c..52650ac05b 100644 --- a/crates/solidity/testing/snapshots/cst_output/SourceUnit/using_directive/generated/0.8.13-success.yml +++ b/crates/solidity/testing/snapshots/cst_output/SourceUnit/using_directive/generated/0.8.13-success.yml @@ -40,7 +40,7 @@ Tree: - SolidityKeyword (Token): "solidity" # 39..47 - VersionPragmaExpressions (Rule): # 47..54 " ^0.8.0" - VersionPragmaExpression (Rule): # 47..54 " ^0.8.0" - - VersionPragmaUnaryExpression (Rule): # 47..54 " ^0.8.0" + - VersionPragmaPrefixExpression (Rule): # 47..54 " ^0.8.0" - Caret (Token): "^" # 48..49 - VersionPragmaExpression (Rule): # 49..54 "0.8.0" - VersionPragmaSpecifier (Rule): # 49..54 "0.8.0" diff --git a/crates/solidity/testing/snapshots/cst_output/Statements/compound_tokens/generated/0.4.11-success.yml b/crates/solidity/testing/snapshots/cst_output/Statements/compound_tokens/generated/0.4.11-success.yml index 018534db86..b6242d4ca7 100644 --- a/crates/solidity/testing/snapshots/cst_output/Statements/compound_tokens/generated/0.4.11-success.yml +++ b/crates/solidity/testing/snapshots/cst_output/Statements/compound_tokens/generated/0.4.11-success.yml @@ -22,7 +22,7 @@ Tree: - Statement (Rule): # 0..8 "a && b;\n" - ExpressionStatement (Rule): # 0..8 "a && b;\n" - Expression (Rule): # 0..6 "a && b" - - BinaryExpression (Rule): # 0..6 "a && b" + - AndExpression (Rule): # 0..6 "a && b" - Expression (Rule): # 0..1 "a" - Identifier (Token): "a" # 0..1 - AmpersandAmpersand (Token): "&&" # 2..4 @@ -32,7 +32,7 @@ Tree: - Statement (Rule): # 8..16 "a &= b;\n" - ExpressionStatement (Rule): # 8..16 "a &= b;\n" - Expression (Rule): # 8..14 "a &= b" - - BinaryExpression (Rule): # 8..14 "a &= b" + - AssignmentExpression (Rule): # 8..14 "a &= b" - Expression (Rule): # 8..9 "a" - Identifier (Token): "a" # 8..9 - AmpersandEqual (Token): "&=" # 10..12 @@ -42,7 +42,7 @@ Tree: - Statement (Rule): # 16..24 "a || b;\n" - ExpressionStatement (Rule): # 16..24 "a || b;\n" - Expression (Rule): # 16..22 "a || b" - - BinaryExpression (Rule): # 16..22 "a || b" + - OrExpression (Rule): # 16..22 "a || b" - Expression (Rule): # 16..17 "a" - Identifier (Token): "a" # 16..17 - BarBar (Token): "||" # 18..20 @@ -52,7 +52,7 @@ Tree: - Statement (Rule): # 24..32 "a |= b;\n" - ExpressionStatement (Rule): # 24..32 "a |= b;\n" - Expression (Rule): # 24..30 "a |= b" - - BinaryExpression (Rule): # 24..30 "a |= b" + - AssignmentExpression (Rule): # 24..30 "a |= b" - Expression (Rule): # 24..25 "a" - Identifier (Token): "a" # 24..25 - BarEqual (Token): "|=" # 26..28 @@ -62,7 +62,7 @@ Tree: - Statement (Rule): # 32..39 "a / b;\n" - ExpressionStatement (Rule): # 32..39 "a / b;\n" - Expression (Rule): # 32..37 "a / b" - - BinaryExpression (Rule): # 32..37 "a / b" + - MultiplicativeExpression (Rule): # 32..37 "a / b" - Expression (Rule): # 32..33 "a" - Identifier (Token): "a" # 32..33 - Slash (Token): "/" # 34..35 @@ -72,7 +72,7 @@ Tree: - Statement (Rule): # 39..47 "a /= b;\n" - ExpressionStatement (Rule): # 39..47 "a /= b;\n" - Expression (Rule): # 39..45 "a /= b" - - BinaryExpression (Rule): # 39..45 "a /= b" + - AssignmentExpression (Rule): # 39..45 "a /= b" - Expression (Rule): # 39..40 "a" - Identifier (Token): "a" # 39..40 - SlashEqual (Token): "/=" # 41..43 @@ -82,7 +82,7 @@ Tree: - Statement (Rule): # 47..54 "a > b;\n" - ExpressionStatement (Rule): # 47..54 "a > b;\n" - Expression (Rule): # 47..52 "a > b" - - BinaryExpression (Rule): # 47..52 "a > b" + - ComparisonExpression (Rule): # 47..52 "a > b" - Expression (Rule): # 47..48 "a" - Identifier (Token): "a" # 47..48 - GreaterThan (Token): ">" # 49..50 @@ -92,7 +92,7 @@ Tree: - Statement (Rule): # 54..62 "a >= b;\n" - ExpressionStatement (Rule): # 54..62 "a >= b;\n" - Expression (Rule): # 54..60 "a >= b" - - BinaryExpression (Rule): # 54..60 "a >= b" + - ComparisonExpression (Rule): # 54..60 "a >= b" - Expression (Rule): # 54..55 "a" - Identifier (Token): "a" # 54..55 - GreaterThanEqual (Token): ">=" # 56..58 @@ -102,7 +102,7 @@ Tree: - Statement (Rule): # 62..70 "a >> b;\n" - ExpressionStatement (Rule): # 62..70 "a >> b;\n" - Expression (Rule): # 62..68 "a >> b" - - BinaryExpression (Rule): # 62..68 "a >> b" + - ShiftExpression (Rule): # 62..68 "a >> b" - Expression (Rule): # 62..63 "a" - Identifier (Token): "a" # 62..63 - GreaterThanGreaterThan (Token): ">>" # 64..66 @@ -112,7 +112,7 @@ Tree: - Statement (Rule): # 70..79 "a >>= b;\n" - ExpressionStatement (Rule): # 70..79 "a >>= b;\n" - Expression (Rule): # 70..77 "a >>= b" - - BinaryExpression (Rule): # 70..77 "a >>= b" + - AssignmentExpression (Rule): # 70..77 "a >>= b" - Expression (Rule): # 70..71 "a" - Identifier (Token): "a" # 70..71 - GreaterThanGreaterThanEqual (Token): ">>=" # 72..75 @@ -122,7 +122,7 @@ Tree: - Statement (Rule): # 79..89 "a >>>= b;\n" - ExpressionStatement (Rule): # 79..89 "a >>>= b;\n" - Expression (Rule): # 79..87 "a >>>= b" - - BinaryExpression (Rule): # 79..87 "a >>>= b" + - AssignmentExpression (Rule): # 79..87 "a >>>= b" - Expression (Rule): # 79..80 "a" - Identifier (Token): "a" # 79..80 - GreaterThanGreaterThanGreaterThanEqual (Token): ">>>=" # 81..85 @@ -132,7 +132,7 @@ Tree: - Statement (Rule): # 89..97 "a << b;\n" - ExpressionStatement (Rule): # 89..97 "a << b;\n" - Expression (Rule): # 89..95 "a << b" - - BinaryExpression (Rule): # 89..95 "a << b" + - ShiftExpression (Rule): # 89..95 "a << b" - Expression (Rule): # 89..90 "a" - Identifier (Token): "a" # 89..90 - LessThanLessThan (Token): "<<" # 91..93 @@ -142,7 +142,7 @@ Tree: - Statement (Rule): # 97..106 "a <<= b;\n" - ExpressionStatement (Rule): # 97..106 "a <<= b;\n" - Expression (Rule): # 97..104 "a <<= b" - - BinaryExpression (Rule): # 97..104 "a <<= b" + - AssignmentExpression (Rule): # 97..104 "a <<= b" - Expression (Rule): # 97..98 "a" - Identifier (Token): "a" # 97..98 - LessThanLessThanEqual (Token): "<<=" # 99..102 diff --git a/crates/solidity/testing/snapshots/cst_output/Statements/invalid_termination/generated/0.4.11-failure.yml b/crates/solidity/testing/snapshots/cst_output/Statements/invalid_termination/generated/0.4.11-failure.yml index 04dc3166d6..d832940c95 100644 --- a/crates/solidity/testing/snapshots/cst_output/Statements/invalid_termination/generated/0.4.11-failure.yml +++ b/crates/solidity/testing/snapshots/cst_output/Statements/invalid_termination/generated/0.4.11-failure.yml @@ -37,7 +37,7 @@ Tree: - Statement (Rule): # 18..25 " 1 * 2;" - ExpressionStatement (Rule): # 18..25 " 1 * 2;" - Expression (Rule): # 18..24 " 1 * 2" - - BinaryExpression (Rule): # 18..24 " 1 * 2" + - MultiplicativeExpression (Rule): # 18..24 " 1 * 2" - Expression (Rule): # 18..20 " 1" - DecimalNumberExpression (Rule): # 18..20 " 1" - DecimalLiteral (Token): "1" # 19..20 @@ -49,7 +49,7 @@ Tree: - Statement (Rule): # 25..40 " 3 * b invalid;" - ExpressionStatement (Rule): # 25..40 " 3 * b invalid;" - Expression (Rule): # 25..31 " 3 * b" - - BinaryExpression (Rule): # 25..31 " 3 * b" + - MultiplicativeExpression (Rule): # 25..31 " 3 * b" - Expression (Rule): # 25..27 " 3" - DecimalNumberExpression (Rule): # 25..27 " 3" - DecimalLiteral (Token): "3" # 26..27 diff --git a/crates/solidity/testing/snapshots/cst_output/VersionPragma/alternatives/generated/0.4.11-success.yml b/crates/solidity/testing/snapshots/cst_output/VersionPragma/alternatives/generated/0.4.11-success.yml index 85def026b9..8a9404d094 100644 --- a/crates/solidity/testing/snapshots/cst_output/VersionPragma/alternatives/generated/0.4.11-success.yml +++ b/crates/solidity/testing/snapshots/cst_output/VersionPragma/alternatives/generated/0.4.11-success.yml @@ -10,9 +10,9 @@ Tree: - SolidityKeyword (Token): "solidity" # 0..8 - VersionPragmaExpressions (Rule): # 8..33 " 0.5.0 || 0.6.0 || ^0.7.0" - VersionPragmaExpression (Rule): # 8..33 " 0.5.0 || 0.6.0 || ^0.7.0" - - VersionPragmaBinaryExpression (Rule): # 8..33 " 0.5.0 || 0.6.0 || ^0.7.0" + - VersionPragmaOrExpression (Rule): # 8..33 " 0.5.0 || 0.6.0 || ^0.7.0" - VersionPragmaExpression (Rule): # 8..23 " 0.5.0 || 0.6.0" - - VersionPragmaBinaryExpression (Rule): # 8..23 " 0.5.0 || 0.6.0" + - VersionPragmaOrExpression (Rule): # 8..23 " 0.5.0 || 0.6.0" - VersionPragmaExpression (Rule): # 8..14 " 0.5.0" - VersionPragmaSpecifier (Rule): # 8..14 " 0.5.0" - VersionPragmaValue (Token): "0" # 9..10 @@ -30,7 +30,7 @@ Tree: - VersionPragmaValue (Token): "0" # 22..23 - BarBar (Token): "||" # 24..26 - VersionPragmaExpression (Rule): # 26..33 " ^0.7.0" - - VersionPragmaUnaryExpression (Rule): # 26..33 " ^0.7.0" + - VersionPragmaPrefixExpression (Rule): # 26..33 " ^0.7.0" - Caret (Token): "^" # 27..28 - VersionPragmaExpression (Rule): # 28..33 "0.7.0" - VersionPragmaSpecifier (Rule): # 28..33 "0.7.0" diff --git a/crates/solidity/testing/snapshots/cst_output/VersionPragma/equal_operator/generated/0.4.11-success.yml b/crates/solidity/testing/snapshots/cst_output/VersionPragma/equal_operator/generated/0.4.11-success.yml index 32b8a78c30..1c20d236e5 100644 --- a/crates/solidity/testing/snapshots/cst_output/VersionPragma/equal_operator/generated/0.4.11-success.yml +++ b/crates/solidity/testing/snapshots/cst_output/VersionPragma/equal_operator/generated/0.4.11-success.yml @@ -10,7 +10,7 @@ Tree: - SolidityKeyword (Token): "solidity" # 0..8 - VersionPragmaExpressions (Rule): # 8..15 " =0.8.0" - VersionPragmaExpression (Rule): # 8..15 " =0.8.0" - - VersionPragmaUnaryExpression (Rule): # 8..15 " =0.8.0" + - VersionPragmaPrefixExpression (Rule): # 8..15 " =0.8.0" - Equal (Token): "=" # 9..10 - VersionPragmaExpression (Rule): # 10..15 "0.8.0" - VersionPragmaSpecifier (Rule): # 10..15 "0.8.0" diff --git a/crates/solidity/testing/snapshots/cst_output/VersionPragma/less_than_operator/generated/0.4.11-success.yml b/crates/solidity/testing/snapshots/cst_output/VersionPragma/less_than_operator/generated/0.4.11-success.yml index 5029c2e26d..277be9828f 100644 --- a/crates/solidity/testing/snapshots/cst_output/VersionPragma/less_than_operator/generated/0.4.11-success.yml +++ b/crates/solidity/testing/snapshots/cst_output/VersionPragma/less_than_operator/generated/0.4.11-success.yml @@ -10,7 +10,7 @@ Tree: - SolidityKeyword (Token): "solidity" # 0..8 - VersionPragmaExpressions (Rule): # 8..15 " <1.0.0" - VersionPragmaExpression (Rule): # 8..15 " <1.0.0" - - VersionPragmaUnaryExpression (Rule): # 8..15 " <1.0.0" + - VersionPragmaPrefixExpression (Rule): # 8..15 " <1.0.0" - LessThan (Token): "<" # 9..10 - VersionPragmaExpression (Rule): # 10..15 "1.0.0" - VersionPragmaSpecifier (Rule): # 10..15 "1.0.0" diff --git a/crates/solidity/testing/snapshots/cst_output/VersionPragma/nested_expressions/generated/0.4.11-success.yml b/crates/solidity/testing/snapshots/cst_output/VersionPragma/nested_expressions/generated/0.4.11-success.yml index f2ac65f9d2..62c639dc9c 100644 --- a/crates/solidity/testing/snapshots/cst_output/VersionPragma/nested_expressions/generated/0.4.11-success.yml +++ b/crates/solidity/testing/snapshots/cst_output/VersionPragma/nested_expressions/generated/0.4.11-success.yml @@ -10,9 +10,9 @@ Tree: - SolidityKeyword (Token): "solidity" # 0..8 - VersionPragmaExpressions (Rule): # 8..30 " ^1.0.0 || 2.0.0-3.0.0" - VersionPragmaExpression (Rule): # 8..30 " ^1.0.0 || 2.0.0-3.0.0" - - VersionPragmaBinaryExpression (Rule): # 8..30 " ^1.0.0 || 2.0.0-3.0.0" + - VersionPragmaOrExpression (Rule): # 8..30 " ^1.0.0 || 2.0.0-3.0.0" - VersionPragmaExpression (Rule): # 8..15 " ^1.0.0" - - VersionPragmaUnaryExpression (Rule): # 8..15 " ^1.0.0" + - VersionPragmaPrefixExpression (Rule): # 8..15 " ^1.0.0" - Caret (Token): "^" # 9..10 - VersionPragmaExpression (Rule): # 10..15 "1.0.0" - VersionPragmaSpecifier (Rule): # 10..15 "1.0.0" @@ -23,7 +23,7 @@ Tree: - VersionPragmaValue (Token): "0" # 14..15 - BarBar (Token): "||" # 16..18 - VersionPragmaExpression (Rule): # 18..30 " 2.0.0-3.0.0" - - VersionPragmaBinaryExpression (Rule): # 18..30 " 2.0.0-3.0.0" + - VersionPragmaRangeExpression (Rule): # 18..30 " 2.0.0-3.0.0" - VersionPragmaExpression (Rule): # 18..24 " 2.0.0" - VersionPragmaSpecifier (Rule): # 18..24 " 2.0.0" - VersionPragmaValue (Token): "2" # 19..20 diff --git a/crates/solidity/testing/snapshots/cst_output/VersionPragma/ranges/generated/0.4.11-success.yml b/crates/solidity/testing/snapshots/cst_output/VersionPragma/ranges/generated/0.4.11-success.yml index 2d3f769d55..d78f22fd12 100644 --- a/crates/solidity/testing/snapshots/cst_output/VersionPragma/ranges/generated/0.4.11-success.yml +++ b/crates/solidity/testing/snapshots/cst_output/VersionPragma/ranges/generated/0.4.11-success.yml @@ -10,7 +10,7 @@ Tree: - SolidityKeyword (Token): "solidity" # 0..8 - VersionPragmaExpressions (Rule): # 8..22 " 0.6.0 - 0.7.0" - VersionPragmaExpression (Rule): # 8..22 " 0.6.0 - 0.7.0" - - VersionPragmaBinaryExpression (Rule): # 8..22 " 0.6.0 - 0.7.0" + - VersionPragmaRangeExpression (Rule): # 8..22 " 0.6.0 - 0.7.0" - VersionPragmaExpression (Rule): # 8..14 " 0.6.0" - VersionPragmaSpecifier (Rule): # 8..14 " 0.6.0" - VersionPragmaValue (Token): "0" # 9..10 diff --git a/crates/solidity/testing/utils/src/node_extensions/tests.rs b/crates/solidity/testing/utils/src/node_extensions/tests.rs index ce99a6e227..c4dc6072f2 100644 --- a/crates/solidity/testing/utils/src/node_extensions/tests.rs +++ b/crates/solidity/testing/utils/src/node_extensions/tests.rs @@ -1,6 +1,6 @@ use anyhow::Result; use semver::Version; -use slang_solidity::{kinds::ProductionKind, language::Language}; +use slang_solidity::{kinds::RuleKind, language::Language}; use crate::node_extensions::NodeExtensions; @@ -14,7 +14,7 @@ fn extract_non_trivia() -> Result<()> { )"; let language = Language::new(Version::parse("0.8.0")?)?; - let output = language.parse(ProductionKind::Expression, source); + let output = language.parse(RuleKind::Expression, source); assert_eq!(output.errors().len(), 0); diff --git a/crates/solidity/testing/utils/src/version_pragmas/mod.rs b/crates/solidity/testing/utils/src/version_pragmas/mod.rs index ea9b722b2f..f37e619c99 100644 --- a/crates/solidity/testing/utils/src/version_pragmas/mod.rs +++ b/crates/solidity/testing/utils/src/version_pragmas/mod.rs @@ -5,11 +5,7 @@ use std::str::FromStr; use anyhow::{bail, ensure, Context, Result}; use semver::{Comparator, Op, Version}; -use slang_solidity::{ - cst::Node, - kinds::{ProductionKind, RuleKind, TokenKind}, - language::Language, -}; +use slang_solidity::{cst::Node, kinds::RuleKind, language::Language}; use crate::node_extensions::NodeExtensions; @@ -18,7 +14,7 @@ pub fn extract_version_pragmas( latest_version: &Version, ) -> Result> { let language = &Language::new(latest_version.to_owned())?; - let output = language.parse(ProductionKind::SourceUnit, source); + let output = language.parse(RuleKind::SourceUnit, source); let mut pragmas = vec![]; let mut cursor = output.create_tree_cursor(); @@ -68,41 +64,34 @@ fn extract_pragma(expression_node: &Node) -> Result { .collect(); match inner_expression.kind { - RuleKind::VersionPragmaBinaryExpression => match &inner_children[..] { - [left, operator, right] => { - let Node::Token(operator) = operator else { - bail!("Expected rule: {operator:?}"); - }; - - match operator.kind { - TokenKind::BarBar => { - let left = extract_pragma(left)?; - let right = extract_pragma(right)?; - - Ok(VersionPragma::or(left, right)) - } - TokenKind::Minus => { - let mut left = extract_pragma(left)?.comparator()?; - let mut right = extract_pragma(right)?.comparator()?; - - // Simulate solc bug: - // https://github.com/ethereum/solidity/issues/13920 - left.op = Op::GreaterEq; - right.op = Op::LessEq; - - Ok(VersionPragma::and( - VersionPragma::single(left), - VersionPragma::single(right), - )) - } - - _ => bail!("Unexpected operator: {operator:?}"), - } - } - - _ => bail!("Expected 3 children: {inner_expression:?}"), - }, - RuleKind::VersionPragmaUnaryExpression => { + RuleKind::VersionPragmaOrExpression => { + let [left, Node::Token(_op), right] = &inner_children[..] else { + bail!("Expected 3 children: {inner_expression:?}"); + }; + let left = extract_pragma(left)?; + let right = extract_pragma(right)?; + + Ok(VersionPragma::or(left, right)) + } + RuleKind::VersionPragmaRangeExpression => { + let [left, Node::Token(_op), right] = &inner_children[..] else { + bail!("Expected 3 children: {inner_expression:?}"); + }; + + let mut left = extract_pragma(left)?.comparator()?; + let mut right = extract_pragma(right)?.comparator()?; + + // Simulate solc bug: + // https://github.com/ethereum/solidity/issues/13920 + left.op = Op::GreaterEq; + right.op = Op::LessEq; + + Ok(VersionPragma::and( + VersionPragma::single(left), + VersionPragma::single(right), + )) + } + RuleKind::VersionPragmaPrefixExpression => { let value = inner_expression.extract_non_trivia(); let comparator = Comparator::from_str(&value)?; diff --git a/documentation/public/user-guide/npm-package/index.md b/documentation/public/user-guide/npm-package/index.md index f67f631887..0c80271ae9 100644 --- a/documentation/public/user-guide/npm-package/index.md +++ b/documentation/public/user-guide/npm-package/index.md @@ -16,9 +16,9 @@ The API is initialized with a language version to create a `Language` object. Specifying the correct version is important, as it will affect the grammar used to parse inputs. You can then use it to parse different inputs belonging to that version. -Each `parse()` operation accepts the input source code, and a `ProductionKind` variant. -This allows callers to parse entire source files (`ProductionKind.SourceUnit`), individual contracts (`ProductionKind.ContractDefinition`), -methods (`ProductionKind.FunctionDefinition`), or any other syntax nodes. +Each `parse()` operation accepts the input source code, and a `RuleKind` variant. +This allows callers to parse entire source files (`RuleKind.SourceUnit`), individual contracts (`RuleKind.ContractDefinition`), +methods (`RuleKind.FunctionDefinition`), or any other syntax nodes. The resulting `ParseOutput` object will contain syntax errors (if any), and the parse tree corresponding to the input source code. You can then iterate over the resulting children, and assert that they match the expected syntax nodes: