diff --git a/Cargo.lock b/Cargo.lock index f425b98bb8..5e0e93d806 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -2078,6 +2078,7 @@ dependencies = [ "codegen_language_definition", "codegen_language_macros", "codegen_schema", + "indexmap 1.9.3", "infra_utils", "semver", ] diff --git a/crates/codegen/grammar/src/dsl.rs b/crates/codegen/grammar/src/dsl.rs deleted file mode 100644 index 2bf9b28286..0000000000 --- a/crates/codegen/grammar/src/dsl.rs +++ /dev/null @@ -1,537 +0,0 @@ -#[macro_export] -macro_rules! slang_grammar { - - ( $( $($idents:ident)+ = $value:tt ; )* ) => { - $( - slang_grammar_top_level_clause! { $($idents)+ $value } - )* - - pub trait GrammarConstructorDslV1 { - fn from_dsl_v1() -> std::rc::Rc<$crate::Grammar>; - } - - impl GrammarConstructorDslV1 for $crate::Grammar { - fn from_dsl_v1() -> std::rc::Rc<$crate::Grammar> { - let name = slang_grammar_top_level_config! { - name - $( $($idents)+ = $value ; )* - }.into(); - let versions = slang_grammar_top_level_config! { - versions - $( $($idents)+ = $value ; )* - }.into(); - let leading_trivia_parser: TriviaParserDefinitionRef = slang_grammar_top_level_config! { - leading_trivia_parser - $( $($idents)+ = $value ; )* - }; - let trailing_trivia_parser: TriviaParserDefinitionRef = slang_grammar_top_level_config! { - trailing_trivia_parser - $( $($idents)+ = $value ; )* - }; - let mut grammar = Self { - name, - versions, - leading_trivia_parser, - trailing_trivia_parser, - elements: std::collections::HashMap::new() - }; - $( - slang_grammar_register_definitions! { grammar $($idents)+ $value } - )* - std::rc::Rc::new(grammar) - } - } - }; - -} - -#[macro_export] -macro_rules! slang_grammar_top_level_clause { - - (config $value:tt) => {}; - - (scanner $name:ident $value:tt) => { - slang_grammar_definition!{ - None - ScannerDefinition - ScannerDefinitionRef - ScannerDefinitionNode - slang_scanner - None - $name - $value - } - }; - - (lexical context $name:ident { $( $($idents:ident)+ = $value:tt ; )* } ) => { - $( - slang_grammar_lexical_context! { - $name - $($idents)+ $value - } - )* - }; -} - -#[macro_export] -macro_rules! slang_grammar_top_level_config { - - // Muncher: Match "name = ;" - ( [ @top_level name ] name = $name:literal ; $($rest:tt)* ) => { - // Only one per top-level config, no need to munch more - $name - }; - // Muncher: Match "versions = [ ,* ] ;" - ( [ @top_level versions ] versions = [ $($version:literal),* ] ; $($rest:tt)* ) => { - // Only one per top-level config, no need to munch more - [ $(semver::Version::parse($version).unwrap()),* ] - }; - // Muncher: Match "leading trivia parser = ;" - ( [ @top_level leading_trivia_parser ] leading trivia parser = $name:ident ; $($rest:tt)* ) => { - // Only one per top-level config, no need to munch more - $name::instance() - }; - // Muncher: Match "trailing trivia parser = ;" - ( [ @top_level trailing_trivia_parser ] trailing trivia parser = $name:ident ; $($rest:tt)* ) => { - // Only one per top-level config, no need to munch more - $name::instance() - }; - // Muncher: Next - ( [ @top_level $name:ident ] $($idents:ident)+ = $value:tt ; $($rest:tt)* ) => { - slang_grammar_top_level_config! { [ @top_level $name ] $($rest)* } - }; - // Muncher: End - ( [ @top_level $name:ident ] ) => { () }; - - // Muncher: Match "config = { ... } ;" - ( $name:ident config = { $($config:tt)* } ; $($rest:tt)* ) => { - // Only one config per top-level, no need to munch more - slang_grammar_top_level_config! { [ @top_level $name ] $($config)* } - }; - // Muncher: Next - ( $name:ident $($idents:ident)+ = $value:tt ; $($rest:tt)* ) => { - slang_grammar_top_level_config! { $name $($rest)* } - }; - // Muncher: End - ( $names:ident ) => {}; -} - -#[macro_export] -macro_rules! slang_grammar_lexical_context { - ($context:ident config $value:tt) => { - /* Not Yet Implemented */ - }; - ($context:ident trivia parser $name:ident $value:tt) => { - slang_grammar_definition! { - $context - TriviaParserDefinition - TriviaParserDefinitionRef - ParserDefinitionNode - slang_parser - None - $name - $value - } - }; - ($context:ident inline parser $name:ident $value:tt) => { - slang_grammar_definition! { - $context - ParserDefinition - ParserDefinitionRef - ParserDefinitionNode - slang_parser - (true) - $name - $value - } - }; - ($context:ident parser $name:ident $value:tt) => { - slang_grammar_definition! { - $context - ParserDefinition - ParserDefinitionRef - ParserDefinitionNode - slang_parser - (false) - $name - $value - } - }; - ($context:ident precedence parser $name:ident $value:tt) => { - slang_grammar_definition! { - $context - PrecedenceParserDefinition - PrecedenceParserDefinitionRef - PrecedenceParserDefinitionNode - slang_precedence_parser - None - $name - $value - } - }; -} - -#[macro_export] -macro_rules! slang_grammar_definition { - ($context:ident $trait:ident $trait_ref:ident $node_type:ident $dsl_macro:ident $is_inline:tt $name:ident $value:tt) => { - #[derive(Debug, Default)] - struct $name { - node: ::std::cell::OnceCell<$crate::$node_type>, - } - - impl $name { - const NAME: &str = stringify!($name); - fn instance() -> $crate::$trait_ref { - use ::std::rc::Rc; - - thread_local! { - static INSTANCE: Rc<$name> = Rc::default(); - } - - INSTANCE.with(Rc::clone) - } - } - - impl $crate::$trait for $name { - fn name(&self) -> &'static str { - Self::NAME - } - fn node(&self) -> &$crate::$node_type { - &self.node.get_or_init(|| $dsl_macro!($value)) - } - slang_grammar_definition! { @context_method $context } - slang_grammar_definition! { @is_inline_method $is_inline } - } - }; - - (@context_method None ) => {}; - (@context_method $context:ident ) => { - fn context(&self) -> &'static str { - stringify!($context) - } - }; - - (@is_inline_method None ) => {}; - (@is_inline_method ($is_inline:literal) ) => { - fn is_inline(&self) -> bool { - $is_inline - } - }; -} - -#[macro_export] -macro_rules! slang_grammar_register_definitions { - - ($grammar:ident lexical context $name:ident { $( $($idents:ident)+ = $value:tt ; )* } ) => { - $( - slang_grammar_register_definitions! { $grammar $($idents)+ $value } - )* - }; - ($grammar:ident config $value:tt) => {}; - ($grammar:ident $(inline)? $(trivia)? $(precedence)? parser $name:ident $value:tt) => { - $grammar.register($name::instance()); - }; - ($grammar:ident scanner $name:ident $value:tt) => { - $grammar.register($name::instance()); - }; - -} - -#[macro_export] -macro_rules! slang_parser { - - ( $x:ident ) => { - $x::instance().into() - }; - - (( $x:tt ? )) => { - $crate::ParserDefinitionNode::Optional( - Box::new(slang_parser!($x)) - ) - }; - (( $x:tt * )) => { - $crate::ParserDefinitionNode::ZeroOrMore( - Box::new(slang_parser!($x)), - ) - }; - (( $x:tt + )) => { - $crate::ParserDefinitionNode::OneOrMore( - Box::new(slang_parser!($x)), - ) - }; - - (( $b:tt delimited by $o:tt and $c:tt )) => { - $crate::ParserDefinitionNode::DelimitedBy( - Box::new(slang_parser!($o)), - Box::new(slang_parser!($b)), - Box::new(slang_parser!($c)), - ) - }; - (( $b:tt terminated by $t:tt )) => { - $crate::ParserDefinitionNode::TerminatedBy( - Box::new(slang_parser!($b)), - Box::new(slang_parser!($t)), - ) - }; - (( $b:tt separated by $s:tt )) => { - $crate::ParserDefinitionNode::SeparatedBy( - Box::new(slang_parser!($b)), - Box::new(slang_parser!($s)), - ) - }; - - (( $first:tt | $($rest:tt)|+ )) => { - $crate::ParserDefinitionNode::Choice( - vec![slang_parser!($first), $(slang_parser!($rest)),+], - ) - }; - - (( $x:tt )) => { - slang_parser!($x) - }; - - (( $($rest:tt)+ )) => { - $crate::ParserDefinitionNode::Sequence( - vec![$(slang_parser!($rest)),+], - ) - }; - - ({ $($rest:tt)+ }) => { - slang_dsl_versioned!([ ParserDefinitionNode slang_parser [] ] $($rest)+) - }; - -} - -#[macro_export] -macro_rules! slang_precedence_parser { - - (( [ $($operators:tt)+ ] with primary expression $primary:tt )) => { - $crate::PrecedenceParserDefinitionNode { - primary_expression: Box::new(slang_parser!($primary)), - operators: slang_precedence_parser_operators!([ [] [] ] $($operators)+), - } - }; - -} - -#[macro_export] -macro_rules! slang_precedence_parser_operators { - - ([ [ $($operator:expr),* ] $versions:tt ] right $operator_parser:ident as $name:ident $(, $($rest:tt)*)?) => { - slang_precedence_parser_operators!( - [ - [ - $($operator,)* - ( - vec! $versions, - $crate::PrecedenceOperatorModel::BinaryRightAssociative, - stringify!($name), - $operator_parser::instance() - ) - ] - [] - ] - $($($rest)*)? - ) - }; - ([ [ $($operator:expr),* ] $versions:tt ] left $operator_parser:ident as $name:ident $(, $($rest:tt)*)?) => { - slang_precedence_parser_operators!( - [ - [ - $($operator,)* - ( - vec! $versions, - $crate::PrecedenceOperatorModel::BinaryLeftAssociative, - stringify!($name), - $operator_parser::instance() - ) - ] - [] - ] - $($($rest)*)? - ) - }; - ([ [ $($operator:expr),* ] $versions:tt ] prefix $operator_parser:ident as $name:ident $(, $($rest:tt)*)?) => { - slang_precedence_parser_operators!( - [ - [ - $($operator,)* - ( - vec! $versions, - $crate::PrecedenceOperatorModel::Prefix, - stringify!($name), - $operator_parser::instance() - ) - ] - [] - ] - $($($rest)*)? - ) - }; - ([ [ $($operator:expr),* ] $versions:tt ] postfix $operator_parser:ident as $name:ident $(, $($rest:tt)*)?) => { - slang_precedence_parser_operators!( - [ - [ - $($operator,)* - ( - vec! $versions, - $crate::PrecedenceOperatorModel::Postfix, - stringify!($name), - $operator_parser::instance() - ) - ] - [] - ] - $($($rest)*)? - ) - }; - // These do just enough to handle solidity 0.4.11 .. 0.8.20 - // TODO: fully general with `... and` syntax as in `slang_parser!` - ([ $operators:tt [ $($version:tt),* ] ] { introduced in $from:literal $mode:ident $operator:ident as $name:ident } $(, $($rest:tt)*)?) => { - slang_precedence_parser_operators!( - [ - $operators - [ - $($version,)* - { - $crate::VersionQualityRange { - from: semver::Version::parse($from).unwrap(), - quality: $crate::VersionQuality::Introduced - } - } - ] - ] - $mode $operator as $name $(, $($rest)*)?) - }; - ([ $operators:tt [ $($version:tt),* ]] { removed in $from:literal $mode:ident $operator:ident as $name:ident } $(, $($rest:tt)*)?) => { - slang_precedence_parser_operators!( - [ - $operators - [ - $($version,)* - { - $crate::VersionQualityRange { - from: semver::Version::parse($from).unwrap(), - quality: $crate::VersionQuality::Removed - } - } - ] - ] - $mode $operator as $name - $(, $($rest)*)?) - }; - - ([ $operators:tt [] ]) => { vec! $operators }; - -} - -#[macro_export] -macro_rules! slang_scanner { - - ( $x:literal ) => { - $crate::ScannerDefinitionNode::Literal( - $x.to_string(), - ) - }; - ( $x:ident ) => { - ($x::instance()).into() - }; - - (( ! $x:literal )) => { - $crate::ScannerDefinitionNode::NoneOf( - $x.to_string(), - ) - }; - (( $x:tt ? )) => { - $crate::ScannerDefinitionNode::Optional( - Box::new(slang_scanner!($x)), - ) - }; - (( $x:tt * )) => { - $crate::ScannerDefinitionNode::ZeroOrMore( - Box::new(slang_scanner!($x)), - ) - }; - (( $x:tt + )) => { - $crate::ScannerDefinitionNode::OneOrMore( - Box::new(slang_scanner!($x)), - ) - }; - - (( $x:literal .. $y:literal )) => { - $crate::ScannerDefinitionNode::CharRange( - $x, $y, - ) - }; - - (( $b:tt not followed by $nla:tt )) => { - $crate::ScannerDefinitionNode::NotFollowedBy( - Box::new(slang_scanner!($b)), - Box::new(slang_scanner!($nla)), - ) - }; - - - (( $first:tt | $($rest:tt)|+ )) => { - $crate::ScannerDefinitionNode::Choice( - vec![slang_scanner!($first), $(slang_scanner!($rest)),+], - ) - }; - - (( $x:tt )) => { - slang_scanner!($x) - }; - - (( $($rest:tt)+ )) => { - $crate::ScannerDefinitionNode::Sequence( - vec![$(slang_scanner!($rest)),+], - ) - }; - - ({ $($rest:tt)+ }) => { - slang_dsl_versioned!([ ScannerDefinitionNode slang_scanner [] ] $($rest)+) - }; - -} - -#[macro_export] -macro_rules! slang_dsl_versioned { - - // The qualities are explicit to avoid ambiguity and hence give better error messages - ($args:tt introduced $($rest:tt)+) => { - slang_dsl_versioned!($args Introduced $($rest)+) - }; - ($args:tt removed $($rest:tt)+) => { - slang_dsl_versioned!($args Removed $($rest)+) - }; - - ($args:tt and $($rest:tt)+) => { - slang_dsl_versioned!($args $($rest)+) - }; - - ([ $node_type:ident $dsl_macro:ident [ $($accum:tt),* ] ] $quality:ident in $from:literal $($rest:tt)+) => { - slang_dsl_versioned!( - [ - $node_type - $dsl_macro - [ - $($accum,)* - { - $crate::VersionQualityRange { - from: semver::Version::parse($from).unwrap(), - quality: $crate::VersionQuality::$quality, - } - } - ] - ] - $($rest)+ - ) - }; - ([ $node_type:ident $dsl_macro:ident $accum:tt ] $($rest:tt)+) => { - $crate::$node_type::Versioned( - Box::new($dsl_macro!($($rest)+)), - vec! $accum, - ) - }; - -} diff --git a/crates/codegen/grammar/src/lib.rs b/crates/codegen/grammar/src/lib.rs index 16cbdc0f7c..206e764a99 100644 --- a/crates/codegen/grammar/src/lib.rs +++ b/crates/codegen/grammar/src/lib.rs @@ -1,5 +1,3 @@ -pub mod dsl; - mod grammar; mod parser_definition; mod precedence_parser_definition; diff --git a/crates/codegen/language/definition/src/compiler/analysis/reachability.rs b/crates/codegen/language/definition/src/compiler/analysis/reachability.rs index cbf68bfa02..600333c0b0 100644 --- a/crates/codegen/language/definition/src/compiler/analysis/reachability.rs +++ b/crates/codegen/language/definition/src/compiler/analysis/reachability.rs @@ -60,13 +60,14 @@ fn collect_trivia<'l>(parser: &'l TriviaParser, acc: &mut Vec<&'l Identifier>) { collect_trivia(parser, acc); } } - TriviaParser::ZeroOrMore { parser } | TriviaParser::Optional { parser } => { + TriviaParser::OneOrMore { parser } + | TriviaParser::ZeroOrMore { parser } + | TriviaParser::Optional { parser } => { collect_trivia(parser, acc); } TriviaParser::Trivia { trivia } => { acc.push(trivia); } - TriviaParser::EndOfInput => {} }; } diff --git a/crates/codegen/language/definition/src/compiler/analysis/references.rs b/crates/codegen/language/definition/src/compiler/analysis/references.rs index d305c91a19..fd0ac85f8c 100644 --- a/crates/codegen/language/definition/src/compiler/analysis/references.rs +++ b/crates/codegen/language/definition/src/compiler/analysis/references.rs @@ -171,7 +171,11 @@ fn check_precedence(analysis: &mut Analysis, item: &PrecedenceItem, enablement: let enablement = update_enablement(analysis, enablement, enabled); for precedence_expression in precedence_expressions { - let PrecedenceExpression { name: _, operators } = &**precedence_expression; + let PrecedenceExpression { + name: _, + rule_name: _, + operators, + } = &**precedence_expression; for operator in operators { let PrecedenceOperator { @@ -262,13 +266,14 @@ fn check_trivia_parser(analysis: &mut Analysis, parser: &TriviaParser, enablemen check_trivia_parser(analysis, parser, enablement); } } - TriviaParser::ZeroOrMore { parser } | TriviaParser::Optional { parser } => { + TriviaParser::OneOrMore { parser } + | TriviaParser::ZeroOrMore { parser } + | TriviaParser::Optional { parser } => { check_trivia_parser(analysis, parser, enablement); } TriviaParser::Trivia { trivia } => { check_reference(analysis, None, trivia, enablement, ReferenceFilter::Trivia); } - TriviaParser::EndOfInput => {} }; } diff --git a/crates/codegen/language/definition/src/model/types.rs b/crates/codegen/language/definition/src/model/types.rs index b27952a684..0c24367c8b 100644 --- a/crates/codegen/language/definition/src/model/types.rs +++ b/crates/codegen/language/definition/src/model/types.rs @@ -6,8 +6,9 @@ pub use self::wrapper::*; /// More information: https://github.com/rust-lang/rust/issues/54726 #[codegen_language_internal_macros::derive_internals] mod wrapper { - use crate::model::Identifier; use indexmap::{IndexMap, IndexSet}; + + use crate::model::Identifier; use semver::Version; use serde::Serialize; use std::{path::PathBuf, rc::Rc}; @@ -61,7 +62,23 @@ mod wrapper { Fragment { item: FragmentItem }, } - #[derive(Debug, Eq, PartialEq, Serialize)] + impl Item { + pub fn name(&self) -> &Identifier { + match self { + Item::Struct { item } => &item.name, + Item::Enum { item } => &item.name, + Item::Repeated { item } => &item.name, + Item::Separated { item } => &item.name, + Item::Precedence { item } => &item.name, + Item::Trivia { item } => &item.name, + Item::Keyword { item } => &item.name, + Item::Token { item } => &item.name, + Item::Fragment { item } => &item.name, + } + } + } + + #[derive(Clone, Debug, Eq, PartialEq, Serialize)] pub struct StructItem { pub name: Identifier, @@ -71,7 +88,7 @@ mod wrapper { pub fields: IndexMap, } - #[derive(Debug, Eq, PartialEq, Serialize)] + #[derive(Clone, Debug, Eq, PartialEq, Serialize)] pub struct EnumItem { pub name: Identifier, @@ -80,7 +97,7 @@ mod wrapper { pub variants: Vec, } - #[derive(Debug, Eq, PartialEq, Serialize)] + #[derive(Clone, Debug, Eq, PartialEq, Serialize)] pub struct EnumVariant { pub name: Identifier, @@ -89,7 +106,7 @@ mod wrapper { pub reference: Identifier, } - #[derive(Debug, Eq, PartialEq, Serialize)] + #[derive(Clone, Debug, Eq, PartialEq, Serialize)] pub struct RepeatedItem { pub name: Identifier, pub repeated: Identifier, @@ -99,7 +116,7 @@ mod wrapper { pub allow_empty: Option, } - #[derive(Debug, Eq, PartialEq, Serialize)] + #[derive(Clone, Debug, Eq, PartialEq, Serialize)] pub struct SeparatedItem { pub name: Identifier, pub separated: Identifier, @@ -110,7 +127,7 @@ mod wrapper { pub allow_empty: Option, } - #[derive(Debug, Eq, PartialEq, Serialize)] + #[derive(Clone, Debug, Eq, PartialEq, Serialize)] pub struct PrecedenceItem { pub name: Identifier, @@ -120,14 +137,16 @@ mod wrapper { pub primary_expressions: Vec, } - #[derive(Debug, Eq, PartialEq, Serialize)] + #[derive(Clone, Debug, Eq, PartialEq, Serialize)] 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, } - #[derive(Debug, Eq, PartialEq, Serialize)] + #[derive(Clone, Debug, Eq, PartialEq, Serialize)] pub struct PrecedenceOperator { pub model: OperatorModel, @@ -137,7 +156,7 @@ mod wrapper { pub fields: IndexMap, } - #[derive(Debug, Eq, PartialEq, Serialize)] + #[derive(Clone, Copy, Debug, Eq, PartialEq, Serialize)] pub enum OperatorModel { Prefix, Postfix, @@ -145,26 +164,26 @@ mod wrapper { BinaryRightAssociative, } - #[derive(Debug, Eq, PartialEq, Serialize)] + #[derive(Clone, Debug, Eq, PartialEq, Serialize)] pub struct PrimaryExpression { pub expression: Identifier, pub enabled: Option, } - #[derive(Debug, Eq, PartialEq, Serialize)] + #[derive(Clone, Debug, Eq, PartialEq, Serialize)] pub struct FieldsErrorRecovery { pub terminator: Option, pub delimiters: Option, } - #[derive(Debug, Eq, PartialEq, Serialize)] + #[derive(Clone, Debug, Eq, PartialEq, Serialize)] pub struct FieldDelimiters { pub open: Identifier, pub close: Identifier, } - #[derive(Debug, Eq, PartialEq, Serialize)] + #[derive(Clone, Debug, Eq, PartialEq, Serialize)] pub enum Field { Required { kind: FieldKind, @@ -176,22 +195,22 @@ mod wrapper { }, } - #[derive(Debug, Eq, PartialEq, Serialize)] + #[derive(Clone, Debug, Eq, PartialEq, Serialize)] pub enum FieldKind { NonTerminal { item: Identifier }, Terminal { items: IndexSet }, } - #[derive(Debug, Eq, PartialEq, Serialize)] + #[derive(Clone, Debug, Eq, PartialEq, Serialize)] pub enum TriviaParser { Sequence { parsers: Vec }, Choice { parsers: Vec }, - ZeroOrMore { parser: Box }, Optional { parser: Box }, + OneOrMore { parser: Box }, + ZeroOrMore { parser: Box }, Trivia { trivia: Identifier }, - EndOfInput, } #[derive(Debug, Eq, PartialEq, Serialize)] @@ -201,7 +220,7 @@ mod wrapper { pub scanner: Scanner, } - #[derive(Debug, Eq, PartialEq, Serialize)] + #[derive(Clone, Debug, Eq, PartialEq, Serialize)] pub struct KeywordItem { pub name: Identifier, pub identifier: Identifier, @@ -209,7 +228,7 @@ mod wrapper { pub definitions: Vec, } - #[derive(Debug, Eq, PartialEq, Serialize)] + #[derive(Clone, Debug, Eq, PartialEq, Serialize)] pub struct KeywordDefinition { pub enabled: Option, pub reserved: Option, @@ -217,7 +236,7 @@ mod wrapper { pub value: KeywordValue, } - #[derive(Debug, Eq, PartialEq, Serialize)] + #[derive(Clone, Debug, Eq, PartialEq, Serialize)] pub enum KeywordValue { Sequence { values: Vec }, Optional { value: Box }, @@ -225,21 +244,21 @@ mod wrapper { Atom { atom: String }, } - #[derive(Debug, Eq, PartialEq, Serialize)] + #[derive(Clone, Debug, Eq, PartialEq, Serialize)] pub struct TokenItem { pub name: Identifier, pub definitions: Vec, } - #[derive(Debug, Eq, PartialEq, Serialize)] + #[derive(Clone, Debug, Eq, PartialEq, Serialize)] pub struct TokenDefinition { pub enabled: Option, pub scanner: Scanner, } - #[derive(Debug, Eq, PartialEq, Serialize)] + #[derive(Clone, Debug, Eq, PartialEq, Serialize)] pub struct FragmentItem { pub name: Identifier, @@ -248,7 +267,7 @@ mod wrapper { pub scanner: Scanner, } - #[derive(Debug, Eq, PartialEq, Serialize)] + #[derive(Clone, Debug, Eq, PartialEq, Serialize)] pub enum Scanner { Sequence { scanners: Vec, @@ -284,7 +303,7 @@ mod wrapper { }, } - #[derive(Debug, Eq, PartialEq, Serialize)] + #[derive(Clone, Debug, Eq, PartialEq, Serialize)] pub enum VersionSpecifier { Never, From { from: Version }, 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 f016675938..df4baaacc2 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, operators = []), - PrecedenceExpression(name = Expression2, operators = []), - PrecedenceExpression(name = Expression1, operators = []) + PrecedenceExpression(name = Expression1, rule_name = X, operators = []), + PrecedenceExpression(name = Expression2, rule_name = X, operators = []), + PrecedenceExpression(name = Expression1, rule_name = X, operators = []) ], primary_expressions = [PrimaryExpression(expression = 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 6d6b1ea841..b9f2da2b43 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, operators = []) +19 | PrecedenceExpression(name = Expression1, rule_name = X, operators = []) | ^^^^^^^^^^^ diff --git a/crates/solidity/inputs/language/Cargo.toml b/crates/solidity/inputs/language/Cargo.toml index 86fdc76c1f..c9d308e486 100644 --- a/crates/solidity/inputs/language/Cargo.toml +++ b/crates/solidity/inputs/language/Cargo.toml @@ -20,4 +20,5 @@ codegen_grammar = { workspace = true } codegen_language_definition = { workspace = true } codegen_language_macros = { workspace = true } codegen_schema = { workspace = true } +indexmap = { workspace = true } semver = { workspace = true } diff --git a/crates/solidity/inputs/language/src/definition.rs b/crates/solidity/inputs/language/src/definition.rs index 464f0e0c18..6a1625bf77 100644 --- a/crates/solidity/inputs/language/src/definition.rs +++ b/crates/solidity/inputs/language/src/definition.rs @@ -3,19 +3,18 @@ pub use solidity::SolidityDefinition; codegen_language_macros::compile!(Language( name = Solidity, root_item = SourceUnit, - leading_trivia = ZeroOrMore(Choice([ + // TODO(#638): For now this is on par with the DSL v1 definition to minimize the fallout. + // We should replace this with the new definition from #629. + leading_trivia = OneOrMore(Choice([ Trivia(Whitespace), Trivia(EndOfLine), - Trivia(SingleLineComment), - Trivia(MultilineComment) + Trivia(MultilineComment), + Trivia(SingleLineComment) ])), trailing_trivia = Sequence([ - ZeroOrMore(Choice([ - Trivia(Whitespace), - Trivia(SingleLineComment), - Trivia(MultilineComment) - ])), - Choice([Trivia(EndOfLine), EndOfInput]) + Optional(Trivia(Whitespace)), + Optional(Trivia(SingleLineComment)), + Trivia(EndOfLine) ]), versions = [ "0.4.11", "0.4.12", "0.4.13", "0.4.14", "0.4.15", "0.4.16", "0.4.17", "0.4.18", "0.4.19", @@ -150,6 +149,7 @@ codegen_language_macros::compile!(Language( precedence_expressions = [ PrecedenceExpression( name = VersionPragmaOrExpression, + rule_name = VersionPragmaBinaryExpression, operators = [PrecedenceOperator( model = BinaryLeftAssociative, fields = (operator = Required(Terminal([BarBar]))) @@ -157,6 +157,7 @@ codegen_language_macros::compile!(Language( ), PrecedenceExpression( name = VersionPragmaRangeExpression, + rule_name = VersionPragmaBinaryExpression, operators = [PrecedenceOperator( model = BinaryLeftAssociative, fields = (operator = Required(Terminal([Minus]))) @@ -164,6 +165,7 @@ codegen_language_macros::compile!(Language( ), PrecedenceExpression( name = VersionPragmaPrefixExpression, + rule_name = VersionPragmaUnaryExpression, operators = [PrecedenceOperator( model = Prefix, fields = (operator = Required(Terminal([ @@ -2668,6 +2670,7 @@ codegen_language_macros::compile!(Language( name = TypeName, precedence_expressions = [PrecedenceExpression( name = ArrayTypeName, + rule_name = ArrayTypeName, operators = [PrecedenceOperator( model = Postfix, error_recovery = FieldsErrorRecovery( @@ -2883,6 +2886,32 @@ codegen_language_macros::compile!(Language( expression = Required(NonTerminal(Expression)), semicolon = Required(Terminal([Semicolon])) ) + ), + Struct( + name = AssemblyStatement, + fields = ( + assembly_keyword = Required(Terminal([AssemblyKeyword])), + label = Optional(kind = Terminal([AsciiStringLiteral])), + flags = Optional(kind = NonTerminal(AssemblyFlagsDeclaration)), + body = Required(NonTerminal(YulBlock)) + ) + ), + Struct( + name = AssemblyFlagsDeclaration, + error_recovery = FieldsErrorRecovery( + delimiters = + FieldDelimiters(open = open_paren, close = close_paren) + ), + fields = ( + open_paren = Required(Terminal([OpenParen])), + flags = Required(NonTerminal(AssemblyFlags)), + close_paren = Required(Terminal([CloseParen])) + ) + ), + Separated( + name = AssemblyFlags, + separated = AsciiStringLiteral, + separator = Comma ) ] ), @@ -3191,6 +3220,7 @@ codegen_language_macros::compile!(Language( precedence_expressions = [ PrecedenceExpression( name = AssignmentExpression, + rule_name = BinaryExpression, operators = [PrecedenceOperator( model = BinaryLeftAssociative, fields = (operator = Required(Terminal([ @@ -3211,6 +3241,7 @@ codegen_language_macros::compile!(Language( ), PrecedenceExpression( name = ConditionalExpression, + rule_name = ConditionalExpression, operators = [PrecedenceOperator( model = Postfix, fields = ( @@ -3223,6 +3254,7 @@ codegen_language_macros::compile!(Language( ), PrecedenceExpression( name = OrExpression, + rule_name = BinaryExpression, operators = [PrecedenceOperator( model = BinaryLeftAssociative, fields = (operator = Required(Terminal([BarBar]))) @@ -3230,6 +3262,7 @@ codegen_language_macros::compile!(Language( ), PrecedenceExpression( name = AndExpression, + rule_name = BinaryExpression, operators = [PrecedenceOperator( model = BinaryLeftAssociative, fields = @@ -3238,6 +3271,7 @@ codegen_language_macros::compile!(Language( ), PrecedenceExpression( name = EqualityExpression, + rule_name = BinaryExpression, operators = [PrecedenceOperator( model = BinaryLeftAssociative, fields = (operator = @@ -3246,6 +3280,7 @@ codegen_language_macros::compile!(Language( ), PrecedenceExpression( name = ComparisonExpression, + rule_name = BinaryExpression, operators = [PrecedenceOperator( model = BinaryLeftAssociative, fields = (operator = Required(Terminal([ @@ -3258,6 +3293,7 @@ codegen_language_macros::compile!(Language( ), PrecedenceExpression( name = BitwiseOrExpression, + rule_name = BinaryExpression, operators = [PrecedenceOperator( model = BinaryLeftAssociative, fields = (operator = Required(Terminal([Bar]))) @@ -3265,6 +3301,7 @@ codegen_language_macros::compile!(Language( ), PrecedenceExpression( name = BitwiseXorExpression, + rule_name = BinaryExpression, operators = [PrecedenceOperator( model = BinaryLeftAssociative, fields = (operator = Required(Terminal([Caret]))) @@ -3272,6 +3309,7 @@ codegen_language_macros::compile!(Language( ), PrecedenceExpression( name = BitwiseAndExpression, + rule_name = BinaryExpression, operators = [PrecedenceOperator( model = BinaryLeftAssociative, fields = (operator = Required(Terminal([Ampersand]))) @@ -3279,6 +3317,7 @@ codegen_language_macros::compile!(Language( ), PrecedenceExpression( name = ShiftExpression, + rule_name = BinaryExpression, operators = [PrecedenceOperator( model = BinaryLeftAssociative, fields = (operator = Required(Terminal([ @@ -3290,6 +3329,7 @@ codegen_language_macros::compile!(Language( ), PrecedenceExpression( name = AdditiveExpression, + rule_name = BinaryExpression, operators = [PrecedenceOperator( model = BinaryLeftAssociative, fields = (operator = Required(Terminal([Plus, Minus]))) @@ -3297,6 +3337,7 @@ codegen_language_macros::compile!(Language( ), PrecedenceExpression( name = MultiplicativeExpression, + rule_name = BinaryExpression, operators = [PrecedenceOperator( model = BinaryLeftAssociative, fields = (operator = @@ -3305,6 +3346,7 @@ codegen_language_macros::compile!(Language( ), PrecedenceExpression( name = ExponentiationExpression, + rule_name = BinaryExpression, operators = [ // Before '0.6.0', it was left-associative: PrecedenceOperator( @@ -3324,6 +3366,7 @@ codegen_language_macros::compile!(Language( ), PrecedenceExpression( name = PostfixExpression, + rule_name = UnaryPostfixExpression, operators = [PrecedenceOperator( model = Postfix, fields = @@ -3332,6 +3375,7 @@ codegen_language_macros::compile!(Language( ), PrecedenceExpression( name = PrefixExpression, + rule_name = UnaryPrefixExpression, operators = [ // Before '0.5.0', 'Plus' was supported: PrecedenceOperator( @@ -3353,6 +3397,7 @@ codegen_language_macros::compile!(Language( ), PrecedenceExpression( name = FunctionCallExpression, + rule_name = FunctionCallExpression, operators = [PrecedenceOperator( model = Postfix, fields = ( @@ -3366,6 +3411,7 @@ codegen_language_macros::compile!(Language( ), PrecedenceExpression( name = MemberAccessExpression, + rule_name = MemberAccessExpression, operators = [PrecedenceOperator( model = Postfix, fields = ( @@ -3377,6 +3423,7 @@ codegen_language_macros::compile!(Language( ), PrecedenceExpression( name = IndexAccessExpression, + rule_name = IndexAccessExpression, operators = [PrecedenceOperator( model = Postfix, error_recovery = FieldsErrorRecovery( @@ -3966,32 +4013,6 @@ codegen_language_macros::compile!(Language( title = "Yul Statements", lexical_context = Yul, items = [ - Struct( - name = AssemblyStatement, - fields = ( - assembly_keyword = Required(Terminal([AssemblyKeyword])), - label = Optional(kind = Terminal([AsciiStringLiteral])), - flags = Optional(kind = NonTerminal(AssemblyFlagsDeclaration)), - body = Required(NonTerminal(YulBlock)) - ) - ), - Struct( - name = AssemblyFlagsDeclaration, - error_recovery = FieldsErrorRecovery( - delimiters = - FieldDelimiters(open = open_paren, close = close_paren) - ), - fields = ( - open_paren = Required(Terminal([OpenParen])), - flags = Required(NonTerminal(AssemblyFlags)), - close_paren = Required(Terminal([CloseParen])) - ) - ), - Separated( - name = AssemblyFlags, - separated = AsciiStringLiteral, - separator = Comma - ), Struct( name = YulBlock, error_recovery = FieldsErrorRecovery( @@ -4162,6 +4183,7 @@ 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/dsl.rs b/crates/solidity/inputs/language/src/dsl.rs deleted file mode 100644 index 7a7637e2ee..0000000000 --- a/crates/solidity/inputs/language/src/dsl.rs +++ /dev/null @@ -1,996 +0,0 @@ -use codegen_grammar::*; - -slang_grammar! { - - config = { - - name = "Solidity" ; - - versions = [ - "0.4.11" , "0.4.12" , "0.4.13" , "0.4.14" , "0.4.15" , "0.4.16" , "0.4.17" , "0.4.18" , "0.4.19" , "0.4.20" , - "0.4.21" , "0.4.22" , "0.4.23" , "0.4.24" , "0.4.25" , "0.4.26" , - - "0.5.0" , "0.5.1" , "0.5.2" , "0.5.3" , "0.5.4" , "0.5.5" , "0.5.6" , "0.5.7" , "0.5.8" , "0.5.9" , "0.5.10" , - "0.5.11" , "0.5.12" , "0.5.13" , "0.5.14" , "0.5.15" , "0.5.16" , "0.5.17" , - - "0.6.0" , "0.6.1" , "0.6.2" , "0.6.3" , "0.6.4" , "0.6.5" , "0.6.6" , "0.6.7" , "0.6.8" , "0.6.9" , "0.6.10" , - "0.6.11" , "0.6.12" , - - "0.7.0" , "0.7.1" , "0.7.2" , "0.7.3" , "0.7.4" , "0.7.5" , "0.7.6" , - - "0.8.0" , "0.8.1" , "0.8.2" , "0.8.3" , "0.8.4" , "0.8.5" , "0.8.6" , "0.8.7" , "0.8.8" , "0.8.9" , "0.8.10" , - "0.8.11" , "0.8.12" , "0.8.13" , "0.8.14" , "0.8.15" , "0.8.16" , "0.8.17" , "0.8.18" , "0.8.19" , "0.8.20" , - "0.8.21" , "0.8.22" - ] ; - - leading trivia parser = LeadingTrivia ; - trailing trivia parser = TrailingTrivia ; - - } ; - - /******************************************** - * Parsers - ********************************************/ - - lexical context Default = { - - inline parser SolidityKeywordsOverAllVersions = ( - AbicoderKeyword - | AbstractKeyword - | AddressKeyword - | AfterKeyword - | AnonymousKeyword - | AsKeyword - | AssemblyKeyword - | BoolKeyword - | BreakKeyword - | ByteKeyword - | CaseKeyword - | CatchKeyword - | ConstantKeyword - | ContinueKeyword - | ContractKeyword - | DaysKeyword - | DefaultKeyword - | DeleteKeyword - | DoKeyword - | ElseKeyword - | EnumKeyword - | EtherKeyword - | EventKeyword - | ExperimentalKeyword - | ExternalKeyword - | FallbackKeyword - | FalseKeyword - | FinalKeyword - | FinneyKeyword - | ForKeyword - | FromKeyword - | FunctionKeyword - | HexKeyword - | HoursKeyword - | IfKeyword - | ImportKeyword - | IndexedKeyword - | InKeyword - | InlineKeyword - | InterfaceKeyword - | InternalKeyword - | IsKeyword - | LetKeyword - | LibraryKeyword - | MappingKeyword - | MatchKeyword - | MemoryKeyword - | MinutesKeyword - | ModifierKeyword - | NewKeyword - | NullKeyword - | OfKeyword - | OverrideKeyword - | PayableKeyword - | PragmaKeyword - | PrivateKeyword - | PublicKeyword - | PureKeyword - | ReceiveKeyword - | RelocatableKeyword - | ReturnKeyword - | ReturnsKeyword - | SecondsKeyword - | SolidityKeyword - | StaticKeyword - | StorageKeyword - | StringKeyword - | StructKeyword - | SwitchKeyword - | SzaboKeyword - | ThrowKeyword - | TrueKeyword - | TypeofKeyword - | UsingKeyword - | VarKeyword - | ViewKeyword - | WeeksKeyword - | WeiKeyword - | WhileKeyword - | YearsKeyword - - // Introduced in 0.4.21 - | EmitKeyword - - // Introduced in 0.4.22 - | ConstructorKeyword - - // introduced in 0.5.0 - | AliasKeyword - | ApplyKeyword - | AutoKeyword - | CalldataKeyword - | CopyofKeyword - | DefineKeyword - | ImplementsKeyword - | MacroKeyword - | MutableKeyword - | PartialKeyword - | PromiseKeyword - | ReferenceKeyword - | SealedKeyword - | SizeofKeyword - | SupportsKeyword - | TypedefKeyword - - // Introduced in 0.5.3 - | TypeKeyword - - // Introduced in 0.6.0 - | LeaveKeyword - | TryKeyword - | VirtualKeyword - - // Introduced in 0.6.5 - | ImmutableKeyword - - // Introduced in 0.6.11 - | GweiKeyword - - // Introduced in 0.8.0 - | UncheckedKeyword - - // Introduced in 0.8.4 - | ErrorKeyword - | RevertKeyword - - // Introduced in 0.8.13 - | GlobalKeyword - ) ; - - parser ABICoderPragma = (AbicoderKeyword Identifier) ; - - inline parser AddSubOperator = (Plus | Minus) ; - - parser AddressType = ((AddressKeyword (PayableKeyword ?)) | PayableKeyword) ; - - inline parser AndOperator = AmpersandAmpersand ; - - parser ArgumentsDeclaration = (((PositionalArguments | NamedArgumentsDeclaration) ?) delimited by OpenParen and CloseParen) ; - - parser ArrayExpression = (ArrayValues delimited by OpenBracket and CloseBracket) ; - - inline parser ArrayTypeNameOperator = ((Expression ?) delimited by OpenBracket and CloseBracket) ; - - parser ArrayValues = (Expression separated by Comma) ; - - parser AsciiStringLiterals = (AsciiStringLiteral +) ; - - parser AssemblyFlags = (AsciiStringLiteral separated by Comma) ; - - parser AssemblyStatement = (AssemblyKeyword (AsciiStringLiteral ?) (AssemblyFlagsDeclaration ?) YulBlock) ; - - parser AssemblyFlagsDeclaration = (AssemblyFlags delimited by OpenParen and CloseParen) ; - - inline parser AssignmentOperator = ( - Equal | BarEqual | PlusEqual | MinusEqual | CaretEqual | SlashEqual | PercentEqual | AsteriskEqual | AmpersandEqual | - LessThanLessThanEqual | GreaterThanGreaterThanEqual | GreaterThanGreaterThanGreaterThanEqual - ) ; - - inline parser BitwiseAndOperator = Ampersand ; - - inline parser BitwiseOrOperator = Bar ; - - inline parser BitwiseXOrOperator = Caret ; - - parser Block = ((Statements ?) delimited by OpenBrace and CloseBrace) ; - - inline parser BooleanExpression = (TrueKeyword | FalseKeyword) ; - - parser BreakStatement = (BreakKeyword terminated by Semicolon) ; - - parser CatchClause = { introduced in "0.6.0" (CatchKeyword (CatchClauseError ?) Block) } ; - - parser CatchClauseError = { introduced in "0.6.0" ((Identifier ?) ParametersDeclaration) } ; - - parser CatchClauses = { introduced in "0.6.0" (CatchClause +) } ; - - inline parser ConditionalOperator = (QuestionMark Expression Colon Expression) ; - - parser ConstantDefinition = { introduced in "0.7.4" ((TypeName ConstantKeyword Identifier Equal Expression) terminated by Semicolon) } ; - - inline parser ConstructorAttribute = { introduced in "0.4.22" (ModifierInvocation | InternalKeyword | PayableKeyword | PublicKeyword) } ; - - parser ConstructorAttributes = { introduced in "0.4.22" (ConstructorAttribute +) } ; - - parser ConstructorDefinition = { introduced in "0.4.22" (ConstructorKeyword ParametersDeclaration (ConstructorAttributes ?) Block) } ; - - parser ContinueStatement = (ContinueKeyword terminated by Semicolon) ; - - parser ContractDefinition = ( - { introduced in "0.6.0" (AbstractKeyword ?) } ContractKeyword Identifier (InheritanceSpecifier ?) ((ContractMembers ?) delimited by OpenBrace and CloseBrace) - ) ; - - inline parser ContractMember = ( - UsingDirective | FunctionDefinition | ModifierDefinition | StructDefinition | EnumDefinition | EventDefinition | StateVariableDefinition | - { introduced in "0.4.22" ConstructorDefinition } | - { introduced in "0.6.0" (FallbackFunctionDefinition | ReceiveFunctionDefinition) } | - { removed in "0.6.0" UnnamedFunctionDefinition } | - { introduced in "0.8.4" ErrorDefinition } | - { introduced in "0.8.8" UserDefinedValueTypeDefinition } - ) ; - - parser ContractMembers = (ContractMember +) ; - - inline parser ControlStatement = ( - IfStatement | ForStatement | WhileStatement | DoWhileStatement | ContinueStatement | BreakStatement | DeleteStatement | ReturnStatement | - { introduced in "0.4.21" EmitStatement } | - { removed in "0.5.0" ThrowStatement } | - { introduced in "0.6.0" TryStatement } | - { introduced in "0.8.4" RevertStatement } - ) ; - - inline parser DataLocation = ( - MemoryKeyword | StorageKeyword | - { introduced in "0.5.0" CalldataKeyword} - ) ; - - parser ImportDeconstruction = ((ImportDeconstructionSymbols delimited by OpenBrace and CloseBrace) FromKeyword AsciiStringLiteral) ; - - parser ImportDeconstructionSymbol = (Identifier ((AsKeyword Identifier) ?)) ; - - parser ImportDeconstructionSymbols = (ImportDeconstructionSymbol separated by Comma) ; - - parser DeleteStatement = ((DeleteKeyword Expression) terminated by Semicolon) ; - - parser DoWhileStatement = ((DoKeyword Statement WhileKeyword (Expression delimited by OpenParen and CloseParen)) terminated by Semicolon) ; - - inline parser ElementaryType = ( - BoolKeyword | StringKeyword | AddressType | BytesKeyword | IntKeyword | UintKeyword | FixedKeyword | UfixedKeyword | - { removed in "0.8.0" ByteKeyword} - ) ; - - parser EmitStatement = { introduced in "0.4.21" ((EmitKeyword IdentifierPath ArgumentsDeclaration) terminated by Semicolon) } ; - - parser EnumDefinition = (EnumKeyword Identifier ((EnumMembers ?) delimited by OpenBrace and CloseBrace)) ; - - inline parser EqualityComparisonOperator = (EqualEqual | BangEqual) ; - - parser ErrorDefinition = { introduced in "0.8.4" ((ErrorKeyword Identifier ErrorParametersDeclaration) terminated by Semicolon) } ; - - parser ErrorParametersDeclaration = { introduced in "0.8.4" ((ErrorParameters ?) delimited by OpenParen and CloseParen) } ; - - parser ErrorParameter = { introduced in "0.8.4" (TypeName (Identifier ?)) } ; - - parser ErrorParameters = { introduced in "0.8.4" (ErrorParameter separated by Comma) } ; - - parser EventDefinition = ((EventKeyword Identifier EventParametersDeclaration (AnonymousKeyword ?)) terminated by Semicolon) ; - - parser EventParametersDeclaration = ((EventParameters ?) delimited by OpenParen and CloseParen); - - parser EventParameter = (TypeName (IndexedKeyword ?) (Identifier ?)) ; - - parser EventParameters = (EventParameter separated by Comma) ; - - parser ExperimentalPragma = (ExperimentalKeyword (AsciiStringLiteral | Identifier)) ; - - inline parser ExponentiationOperator = AsteriskAsterisk ; - - precedence parser Expression = ( - [ - left AssignmentOperator as BinaryExpression, - postfix ConditionalOperator as ConditionalExpression, - left OrOperator as BinaryExpression, - left AndOperator as BinaryExpression, - left EqualityComparisonOperator as BinaryExpression, - left OrderComparisonOperator as BinaryExpression, - left BitwiseOrOperator as BinaryExpression, - left BitwiseXOrOperator as BinaryExpression, - left BitwiseAndOperator as BinaryExpression, - left ShiftOperator as BinaryExpression, - left AddSubOperator as BinaryExpression, - left MulDivModOperator as BinaryExpression, - { removed in "0.6.0" left ExponentiationOperator as BinaryExpression }, - { introduced in "0.6.0" right ExponentiationOperator as BinaryExpression }, - postfix UnaryPostfixOperator as UnaryPostfixExpression, - prefix UnaryPrefixOperator as UnaryPrefixExpression, - postfix FunctionCallOperator as FunctionCallExpression, - postfix MemberAccessOperator as MemberAccessExpression, - postfix IndexAccessOperator as IndexAccessExpression - ] - with primary expression PrimaryExpression - ) ; - - parser ExpressionStatement = (Expression terminated by Semicolon) ; - - inline parser FallbackFunctionAttribute = { introduced in "0.6.0" (ModifierInvocation | OverrideSpecifier | ExternalKeyword | PayableKeyword | PureKeyword | ViewKeyword | VirtualKeyword) } ; - - parser FallbackFunctionAttributes = { introduced in "0.6.0" (FallbackFunctionAttribute +) } ; - - parser FallbackFunctionDefinition = { introduced in "0.6.0" (FallbackKeyword ParametersDeclaration (FallbackFunctionAttributes ?) (ReturnsDeclaration ?) (Semicolon | Block)) } ; - - parser ForStatement = (ForKeyword (((SimpleStatement | Semicolon) (ExpressionStatement | Semicolon) (Expression ?)) delimited by OpenParen and CloseParen) Statement) ; - - inline parser FunctionAttribute = ( - ModifierInvocation | OverrideSpecifier | ExternalKeyword | InternalKeyword | PayableKeyword | PrivateKeyword | PublicKeyword | PureKeyword | ViewKeyword | - { removed in "0.5.0" ConstantKeyword } | - { introduced in "0.6.0" VirtualKeyword } - ) ; - - parser FunctionAttributes = (FunctionAttribute +) ; - - inline parser FunctionCallOperator = ( - { introduced in "0.6.2" (FunctionCallOptions ?) } - ArgumentsDeclaration - ) ; - - parser FunctionCallOptions = ( - { introduced in "0.6.2" and removed in "0.8.0" (NamedArgumentsDeclaration +) } | - { introduced in "0.8.0" NamedArgumentsDeclaration } - ) ; - - parser FunctionDefinition = (FunctionKeyword (Identifier | FallbackKeyword | ReceiveKeyword) ParametersDeclaration (FunctionAttributes ?) (ReturnsDeclaration ?) (Semicolon | Block)) ; - - parser FunctionType = (FunctionKeyword ParametersDeclaration (FunctionTypeAttributes ?) (ReturnsDeclaration ?)) ; - - inline parser FunctionTypeAttribute = (InternalKeyword | ExternalKeyword | PrivateKeyword | PublicKeyword | PureKeyword | ViewKeyword | PayableKeyword) ; - - parser FunctionTypeAttributes = (FunctionTypeAttribute +) ; - - parser HexStringLiterals = (HexStringLiteral +) ; - - parser IdentifierPath = (Identifier separated by Period) ; - - parser OverridePaths = (IdentifierPath separated by Comma) ; - - parser EnumMembers = (Identifier separated by Comma) ; - - parser IfStatement = (IfKeyword (Expression delimited by OpenParen and CloseParen) Statement ((ElseKeyword Statement) ?)) ; - - parser ImportDirective = ((ImportKeyword (PathImport | NamedImport | ImportDeconstruction)) terminated by Semicolon) ; - - inline parser IndexAccessOperator = (((Expression ?) ((Colon (Expression ?)) ?)) delimited by OpenBracket and CloseBracket) ; - - parser InheritanceSpecifier = (IsKeyword InheritanceTypes) ; - - parser InheritanceType = (IdentifierPath (ArgumentsDeclaration ?)) ; - - parser InheritanceTypes = (InheritanceType separated by Comma) ; - - parser InterfaceDefinition = (InterfaceKeyword Identifier (InheritanceSpecifier ?) ((InterfaceMembers ?) delimited by OpenBrace and CloseBrace)) ; - - parser InterfaceMembers = (ContractMember +) ; - - parser LibraryDefinition = (LibraryKeyword Identifier ((LibraryMembers ?) delimited by OpenBrace and CloseBrace)) ; - - parser LibraryMembers = (ContractMember +) ; - - parser MappingKeyType = ( - (ElementaryType | IdentifierPath) - { introduced in "0.8.18" (Identifier ?) } - ) ; - - parser MappingType = (MappingKeyword ((MappingKeyType EqualGreaterThan MappingValueType) delimited by OpenParen and CloseParen)) ; - - parser MappingValueType = ( - TypeName - { introduced in "0.8.18" (Identifier ?) } - ) ; - - inline parser MemberAccessOperator = (Period (Identifier | AddressKeyword)) ; - - inline parser ModifierAttribute = ( - OverrideSpecifier | - { introduced in "0.6.0" VirtualKeyword } - ) ; - - parser ModifierAttributes = (ModifierAttribute +) ; - - parser ModifierDefinition = (ModifierKeyword Identifier (ParametersDeclaration ?) (ModifierAttributes ?) (Semicolon | Block)) ; - - parser ModifierInvocation = (IdentifierPath (ArgumentsDeclaration ?)) ; - - inline parser MulDivModOperator = (Asterisk | Slash | Percent) ; - - parser NamedArgument = (Identifier Colon Expression) ; - - parser NamedArgumentsDeclaration = ((NamedArguments ?) delimited by OpenBrace and CloseBrace) ; - - parser NamedArguments = (NamedArgument separated by Comma) ; - - parser NamedImport = (Asterisk AsKeyword Identifier FromKeyword AsciiStringLiteral) ; - - parser NewExpression = (NewKeyword TypeName) ; - - inline parser NumberUnit = ( - DaysKeyword | EtherKeyword | HoursKeyword | MinutesKeyword | SecondsKeyword | WeeksKeyword | WeiKeyword | - { removed in "0.5.0" YearsKeyword } | - { introduced in "0.6.11" GweiKeyword } | - { removed in "0.7.0" (FinneyKeyword | SzaboKeyword) } - ) ; - - inline parser NumericExpression = ( DecimalNumberExpression | HexNumberExpression ) ; - - parser DecimalNumberExpression = (DecimalLiteral (NumberUnit ?)) ; - parser HexNumberExpression = (HexLiteral { removed in "0.5.0" (NumberUnit ?) }) ; - - inline parser OrOperator = BarBar ; - - inline parser OrderComparisonOperator = (LessThan | GreaterThan | LessThanEqual | GreaterThanEqual) ; - - parser OverrideSpecifier = (OverrideKeyword (((OverridePaths ?) delimited by OpenParen and CloseParen) ?)) ; - - parser Parameter = (TypeName (DataLocation ?) (Identifier ?)) ; - - parser ParametersDeclaration = ((Parameters ?) delimited by OpenParen and CloseParen) ; - - parser Parameters = (Parameter separated by Comma) ; - - parser PathImport = (AsciiStringLiteral ((AsKeyword Identifier) ?)) ; - - parser PositionalArguments = (Expression separated by Comma) ; - - parser PragmaDirective = ((PragmaKeyword (ABICoderPragma | ExperimentalPragma | VersionPragma)) terminated by Semicolon) ; - - inline parser PrimaryExpression = ( - NewExpression | TupleExpression | ArrayExpression | BooleanExpression | NumericExpression | StringExpression | ElementaryType | Identifier | - { introduced in "0.5.3" TypeExpression } - ) ; - - inline parser ReceiveFunctionAttribute = { introduced in "0.6.0" (ModifierInvocation | OverrideSpecifier | ExternalKeyword | PayableKeyword | VirtualKeyword) } ; - - parser ReceiveFunctionAttributes = { introduced in "0.6.0" (ReceiveFunctionAttribute +) } ; - - parser ReceiveFunctionDefinition = { introduced in "0.6.0" (ReceiveKeyword ParametersDeclaration (ReceiveFunctionAttributes ?) (Semicolon | Block)) } ; - - parser ReturnStatement = ((ReturnKeyword (Expression ?)) terminated by Semicolon) ; - - parser ReturnsDeclaration = (ReturnsKeyword ParametersDeclaration) ; - - parser RevertStatement = ((RevertKeyword (IdentifierPath ?) ArgumentsDeclaration) terminated by Semicolon) ; - - inline parser ShiftOperator = (LessThanLessThan | GreaterThanGreaterThan | GreaterThanGreaterThanGreaterThan) ; - - inline parser SimpleStatement = (ExpressionStatement | VariableDeclarationStatement | TupleDeconstructionStatement) ; - - parser SourceUnit = ((SourceUnitMembers ?) (EndOfFileTrivia ?)) ; - - inline parser SourceUnitMember = ( - PragmaDirective | ImportDirective | ContractDefinition | InterfaceDefinition | LibraryDefinition | - { introduced in "0.6.0" (StructDefinition | EnumDefinition) } | - { introduced in "0.7.1" FunctionDefinition } | - { introduced in "0.7.4" ConstantDefinition } | - { introduced in "0.8.4" ErrorDefinition } | - { introduced in "0.8.8" UserDefinedValueTypeDefinition } | - { introduced in "0.8.13" UsingDirective } | - { introduced in "0.8.22" EventDefinition } - ) ; - - parser SourceUnitMembers = (SourceUnitMember +) ; - - inline parser StateVariableAttribute = ( - OverrideSpecifier | ConstantKeyword | InternalKeyword | PrivateKeyword | PublicKeyword| { introduced in "0.6.5" ImmutableKeyword } - ) ; - - parser StateVariableAttributes = (StateVariableAttribute +) ; - - parser StateVariableDefinition = ((TypeName (StateVariableAttributes ?) Identifier ((Equal Expression) ?)) terminated by Semicolon) ; - - inline parser Statement = ( - SimpleStatement | ControlStatement | AssemblyStatement | Block | { introduced in "0.8.0" UncheckedBlock } - ) ; - - parser Statements = (Statement +) ; - - inline parser StringExpression = ( - HexStringLiterals | AsciiStringLiterals | { introduced in "0.7.0" UnicodeStringLiterals } - ) ; - - parser StructDefinition = (StructKeyword Identifier ((StructMembers ?) delimited by OpenBrace and CloseBrace)) ; - - parser StructMember = ((TypeName Identifier) terminated by Semicolon) ; - - parser StructMembers = (StructMember +) ; - - parser ThrowStatement = { removed in "0.5.0" (ThrowKeyword terminated by Semicolon) } ; - - parser TryStatement = { introduced in "0.6.0" (TryKeyword Expression (ReturnsDeclaration ?) Block CatchClauses) } ; - - parser TupleDeconstructionStatement = (((TupleDeconstructionElements delimited by OpenParen and CloseParen) Equal Expression) terminated by Semicolon) ; - - parser TupleExpression = (TupleValues delimited by OpenParen and CloseParen) ; - - parser TupleDeconstructionElement = ((TypedTupleMember | UntypedTupleMember) ?) ; - - parser TupleDeconstructionElements = (TupleDeconstructionElement separated by Comma) ; - - parser TupleValues = ((Expression ?) separated by Comma) ; - - parser TypeExpression = { introduced in "0.5.3" (TypeKeyword (TypeName delimited by OpenParen and CloseParen)) } ; - - parser TypedTupleMember = (TypeName (DataLocation ?) Identifier) ; - - precedence parser TypeName = ( - [ - postfix ArrayTypeNameOperator as ArrayTypeName - ] - with primary expression (FunctionType | MappingType | ElementaryType | IdentifierPath) - ) ; - - inline parser UnaryPostfixOperator = (PlusPlus | MinusMinus) ; - - inline parser UnaryPrefixOperator = ( - PlusPlus | MinusMinus | Tilde | Bang | Minus | { removed in "0.5.0" Plus } - ) ; - - parser UncheckedBlock = { introduced in "0.8.0" (UncheckedKeyword Block) } ; - - parser UnicodeStringLiterals = { introduced in "0.7.0" (UnicodeStringLiteral +) } ; - - inline parser UnnamedFunctionAttribute = { removed in "0.6.0" (ModifierInvocation | OverrideSpecifier | ExternalKeyword | PayableKeyword | PureKeyword | ViewKeyword) } ; - - parser UnnamedFunctionAttributes = { removed in "0.6.0" (UnnamedFunctionAttribute +) } ; - - parser UnnamedFunctionDefinition = { removed in "0.6.0" (FunctionKeyword ParametersDeclaration (UnnamedFunctionAttributes ?) (Semicolon | Block)) } ; - - parser UntypedTupleMember = ((DataLocation ?) Identifier) ; - - parser UserDefinedValueTypeDefinition = { introduced in "0.8.8" ((TypeKeyword Identifier IsKeyword ElementaryType) terminated by Semicolon) } ; - - parser UsingDirective = ((UsingKeyword (IdentifierPath | { introduced in "0.8.13" UsingDeconstruction }) ForKeyword (Asterisk | TypeName) ({ introduced in "0.8.13" GlobalKeyword } ?)) terminated by Semicolon) ; - - parser UsingDeconstruction = { introduced in "0.8.13" (UsingDeconstructionSymbols delimited by OpenBrace and CloseBrace) }; - - inline parser UsingDirectiveOperator = { - introduced in "0.8.19" (Ampersand | Asterisk | BangEqual | Bar | Caret | EqualEqual | GreaterThan | GreaterThanEqual | LessThan | LessThanEqual | Minus | Percent | Plus | Slash | Tilde) - } ; - - parser UsingDeconstructionSymbol = { - introduced in "0.8.13" (IdentifierPath { introduced in "0.8.19" ((AsKeyword UsingDirectiveOperator) ?) } ) - } ; - - parser UsingDeconstructionSymbols = { - introduced in "0.8.13" (UsingDeconstructionSymbol separated by Comma) - } ; - - parser VariableDeclaration = (VariableDeclarationType (DataLocation ?) Identifier) ; - - inline parser VariableDeclarationType = ({ removed in "0.5.0" VarKeyword } | TypeName) ; - - parser VariableDeclarationStatement = ((VariableDeclaration ((Equal Expression) ?)) terminated by Semicolon) ; - - parser WhileStatement = (WhileKeyword (Expression delimited by OpenParen and CloseParen) Statement) ; - - trivia parser EndOfFileTrivia = ((Whitespace | EndOfLine | MultilineComment | SingleLineComment) +) ; - - trivia parser LeadingTrivia = ((Whitespace | EndOfLine | MultilineComment | SingleLineComment) +) ; - - trivia parser TrailingTrivia = ((Whitespace ?) (SingleLineComment ?) EndOfLine) ; - - } ; - - lexical context VersionPragma = { - - parser VersionPragma = (SolidityKeyword VersionPragmaExpressions) ; - - precedence parser VersionPragmaExpression = ( - [ - left VersionPragmaOrOperator as VersionPragmaBinaryExpression, - left VersionPragmaRangeOperator as VersionPragmaBinaryExpression, - prefix VersionPragmaUnaryOperator as VersionPragmaUnaryExpression - ] - with primary expression VersionPragmaSpecifier - ) ; - - parser VersionPragmaExpressions = (VersionPragmaExpression +) ; - - inline parser VersionPragmaOrOperator = BarBar ; - - inline parser VersionPragmaRangeOperator = Minus ; - - parser VersionPragmaSpecifier = (VersionPragmaValue separated by Period) ; - - inline parser VersionPragmaUnaryOperator = (Caret | Tilde | Equal | LessThan | GreaterThan | LessThanEqual | GreaterThanEqual) ; - - } ; - - lexical context YulBlock = { - - inline parser YulKeywordsOverAllVersions = ( - BreakKeyword - | CaseKeyword - | ContinueKeyword - | DefaultKeyword - | FalseKeyword - | ForKeyword - | FunctionKeyword - | HexKeyword - | IfKeyword - | LetKeyword - | SwitchKeyword - | TrueKeyword - - // Introduced in 0.6.0 - | LeaveKeyword - ) ; - - parser YulAssignmentStatement = (YulIdentifierPaths ColonEqual YulExpression) ; - - parser YulBlock = ((YulStatements ?) delimited by OpenBrace and CloseBrace) ; - - parser YulBreakStatement = BreakKeyword ; - - parser YulContinueStatement = ContinueKeyword ; - - parser YulDeclarationStatement = (LetKeyword YulIdentifierPaths ((ColonEqual YulExpression) ?)) ; - - precedence parser YulExpression = ( - [ - postfix YulFunctionCallOperator as YulFunctionCallExpression - ] - with primary expression (YulLiteral | YulIdentifierPath) - ) ; - - parser YulArguments = (YulExpression separated by Comma) ; - - parser YulForStatement = (ForKeyword YulBlock YulExpression YulBlock YulBlock) ; - - inline parser YulFunctionCallOperator = ((YulArguments ?) delimited by OpenParen and CloseParen) ; - - parser YulFunctionDefinition = (FunctionKeyword YulIdentifier YulParametersDeclaration (YulReturnsDeclaration ?) YulBlock) ; - - parser YulIdentifierPath = (YulIdentifier separated by Period) ; - - parser YulIdentifierPaths = (YulIdentifierPath separated by Comma) ; - - parser YulIdentifiers = (YulIdentifier separated by Comma) ; - - parser YulIfStatement = (IfKeyword YulExpression YulBlock) ; - - parser YulLeaveStatement = { introduced in "0.6.0" LeaveKeyword } ; - - inline parser YulLiteral = (TrueKeyword | FalseKeyword | YulHexLiteral | YulDecimalLiteral | HexStringLiteral | AsciiStringLiteral) ; - - parser YulParametersDeclaration = ((YulIdentifiers ?) delimited by OpenParen and CloseParen) ; - - parser YulReturnsDeclaration = (MinusGreaterThan YulIdentifiers) ; - - inline parser YulStatement = ( - YulBlock | YulFunctionDefinition | YulDeclarationStatement | YulAssignmentStatement | YulIfStatement | - YulForStatement | YulSwitchStatement | { introduced in "0.6.0" YulLeaveStatement } | - YulBreakStatement | YulContinueStatement | YulExpression - ) ; - - parser YulStatements = (YulStatement +) ; - - parser YulSwitchCase = ((DefaultKeyword | (CaseKeyword YulLiteral)) YulBlock) ; - - parser YulSwitchCases = (YulSwitchCase +) ; - - parser YulSwitchStatement = (SwitchKeyword YulExpression YulSwitchCases) ; - - } ; - - /******************************************** - * Scanners - ********************************************/ - - // Trivia - - scanner EndOfLine = (('\r' ?) '\n') ; - scanner Whitespace = (('\t' | ' ') +) ; - scanner SingleLineComment = ("//" ((! "\n\r") *)) ; - scanner MultilineComment = ('/' '*' (((! '*') | ('*' not followed by '/')) *) '*' '/') ; - - // Delimiters - - scanner OpenBrace = '{' ; - scanner CloseBrace = '}' ; - - scanner OpenBracket = '[' ; - scanner CloseBracket = ']' ; - - scanner OpenParen = '(' ; - scanner CloseParen = ')' ; - - // Punctuation - - scanner Colon = ':' ; - scanner Comma = ',' ; - scanner MinusGreaterThan = "->" ; - scanner Period = '.' ; - scanner QuestionMark = '?' ; - scanner Semicolon = ';' ; - - // Operators - - scanner Ampersand = '&' ; - scanner AmpersandAmpersand = "&&" ; - scanner Asterisk = '*' ; - scanner AsteriskAsterisk = "**" ; - scanner Bang = '!' ; - scanner Bar = '|' ; - scanner BarBar = "||" ; - scanner Caret = '^' ; - scanner GreaterThan = '>' ; - scanner GreaterThanEqual = ">=" ; - scanner GreaterThanGreaterThan = ">>" ; - scanner GreaterThanGreaterThanGreaterThan = ">>>" ; - scanner EqualEqual = "==" ; - scanner EqualGreaterThan = "=>" ; - scanner LessThan = '<' ; - scanner LessThanEqual = "<=" ; - scanner LessThanLessThan = "<<" ; - scanner Minus = '-' ; - scanner MinusMinus = "--" ; - scanner Percent = '%' ; - scanner Plus = '+' ; - scanner PlusPlus = "++" ; - scanner Slash = '/' ; - scanner Tilde = '~' ; - - // Assignment Operators - - scanner AmpersandEqual = "&=" ; - scanner AsteriskEqual = "*=" ; - scanner BangEqual = "!=" ; - scanner BarEqual = "|=" ; - scanner CaretEqual = "^=" ; - scanner ColonEqual = ":=" ; - scanner GreaterThanGreaterThanEqual = ">>=" ; - scanner GreaterThanGreaterThanGreaterThanEqual = ">>>=" ; - scanner Equal = '=' ; - scanner LessThanLessThanEqual = "<<=" ; - scanner MinusEqual = "-=" ; - scanner PercentEqual = "%=" ; - scanner PlusEqual = "+=" ; - scanner SlashEqual = "/=" ; - - // Identifiers - - scanner Identifier = RawIdentifier ; - scanner YulIdentifier = ( RawIdentifier ) ; - - scanner IdentifierPart = (IdentifierStart | ('0' .. '9')) ; - scanner IdentifierStart = ('$' | ('A' .. 'Z') | '_' | ('a' .. 'z')) ; - scanner RawIdentifier = (IdentifierStart (IdentifierPart *)) ; - - // Constructed Identifiers (Typenames) - - scanner BytesKeyword = ("bytes" FixedBytesTypeSize) ; - scanner FixedKeyword = ("fixed" (FixedTypeSize ?)) ; - scanner IntKeyword = ("int" (IntegerTypeSize ?)) ; - scanner UfixedKeyword = ("ufixed" (FixedTypeSize ?)) ; - scanner UintKeyword = ("uint" (IntegerTypeSize ?)) ; - - scanner FixedBytesTypeSize = ( - "1" | "2" | "3" | "4" | "5" | "6" | "7" | "8" | - "9" | "10" | "11" | "12" | "13" | "14" | "15" | "16" | - "17" | "18" | "19" | "20" | "21" | "22" | "23" | "24" | - "25" | "26" | "27" | "28" | "29" | "30" | "31" | "32" - ) ; - scanner FixedTypeSize = ((('0' .. '9') +) 'x' (('0' .. '9') +)) ; - scanner IntegerTypeSize = ( - "8" | "16" | "24" | "32" | "40" | "48" | "56" | "64" | - "72" | "80" | "88" | "96" | "104" | "112" | "120" | "128" | - "136" | "144" | "152" | "160" | "168" | "176" | "184" | "192" | - "200" | "208" | "216" | "224" | "232" | "240" | "248" | "256" - ) ; - - // Literal Building Blocks - - scanner DecimalDigit = ('0' .. '9') ; - scanner HexCharacter = (DecimalDigit | ('A' .. 'F') | ('a' .. 'f')) ; - scanner AsciiCharacterWithoutDoubleQuoteOrBackslash = ((' ' .. '!') | ('#' .. '[') | (']' .. '~')) ; - scanner AsciiCharacterWithoutSingleQuoteOrBackslash = ((' ' .. '&') | ('(' .. '[') | (']' .. '~')) ; - - scanner EscapeSequence = ('\\' (AsciiEscape | HexByteEscape | UnicodeEscape)) ; - scanner AsciiEscape = ('\n' | '\r' | '"' | '\'' | '\\' | 'n' | 'r' | 't') ; - scanner HexByteEscape = ('x' HexCharacter HexCharacter) ; - scanner UnicodeEscape = ('u' HexCharacter HexCharacter HexCharacter HexCharacter) ; - - // Ascii String Literals - - scanner AsciiStringLiteral = (SingleQuotedAsciiStringLiteral | DoubleQuotedAsciiStringLiteral) ; - scanner DoubleQuotedAsciiStringLiteral = ("\"" ((EscapeSequence | AsciiCharacterWithoutDoubleQuoteOrBackslash) *) "\"") ; - scanner SingleQuotedAsciiStringLiteral = ("\'" ((EscapeSequence | AsciiCharacterWithoutSingleQuoteOrBackslash) *) "\'") ; - - // Hex String Literals - - scanner HexStringLiteral = (SingleQuotedHexStringLiteral | DoubleQuotedHexStringLiteral) ; - scanner DoubleQuotedHexStringLiteral = ("hex\"" (HexStringContents ?) "\"") ; - scanner SingleQuotedHexStringLiteral = ("hex\'" (HexStringContents ?) "\'") ; - scanner HexStringContents = (HexCharacter HexCharacter ((('_' ?) HexCharacter HexCharacter) *)) ; - - // Unicode String Literals - - scanner UnicodeStringLiteral = { - introduced in "0.7.0" (SingleQuotedUnicodeStringLiteral | DoubleQuotedUnicodeStringLiteral) - } ; - scanner DoubleQuotedUnicodeStringLiteral = { introduced in "0.7.0" ("unicode\"" ((EscapeSequence | (! "\n\r\"\\")) *) "\"") } ; - scanner SingleQuotedUnicodeStringLiteral = { introduced in "0.7.0" ("unicode\'" ((EscapeSequence | (! "\n\r\'\\")) *) "\'") } ; - - // Numeric Literals - - scanner DecimalLiteral = ( - ( - ( - (DecimalDigits not followed by '.') | - { removed in "0.5.0" ((DecimalDigits '.') not followed by DecimalDigits) } | - ('.' DecimalDigits) | - (DecimalDigits '.' DecimalDigits) - ) - (DecimalExponent ?) - ) not followed by IdentifierStart - ) ; - scanner DecimalExponent = (('E' | 'e') ('-' ?) DecimalDigits) ; - scanner DecimalDigits = ((DecimalDigit +) (('_' (DecimalDigit +)) *)) ; - scanner HexLiteral = ( - (("0x" | { removed in "0.5.0" "0X" }) (HexCharacter +) (('_' (HexCharacter +)) *)) - not followed by IdentifierStart - ) ; - - scanner YulDecimalLiteral = ( - ("0" | (('1' .. '9') (DecimalDigit *))) - not followed by IdentifierStart - ) ; - scanner YulHexLiteral = ( - ("0x" (HexCharacter +)) - not followed by IdentifierStart - ) ; - - // Pragma Literals - - scanner VersionPragmaValue = (('*' | ('0' .. '9') | 'X' | 'x') +) ; - - // Keywords - - scanner AbicoderKeyword = "abicoder" ; - scanner AbstractKeyword = "abstract" ; - scanner AddressKeyword = "address" ; - scanner AfterKeyword = "after" ; - scanner AnonymousKeyword = "anonymous" ; - scanner AsKeyword = "as" ; - scanner AssemblyKeyword = "assembly" ; - scanner BoolKeyword = "bool" ; - scanner BreakKeyword = "break" ; - scanner ByteKeyword = "byte" ; - scanner CaseKeyword = "case" ; - scanner CatchKeyword = "catch" ; - scanner ConstantKeyword = "constant" ; - scanner ContinueKeyword = "continue" ; - scanner ContractKeyword = "contract" ; - scanner DaysKeyword = "days" ; - scanner DefaultKeyword = "default" ; - scanner DeleteKeyword = "delete" ; - scanner DoKeyword = "do" ; - scanner ElseKeyword = "else" ; - scanner EnumKeyword = "enum" ; - scanner EtherKeyword = "ether" ; - scanner EventKeyword = "event" ; - scanner ExperimentalKeyword = "experimental" ; - scanner ExternalKeyword = "external" ; - scanner FalseKeyword = "false" ; - scanner FinalKeyword = "final" ; - scanner ForKeyword = "for" ; - scanner FromKeyword = "from" ; - scanner FunctionKeyword = "function" ; - scanner HexKeyword = "hex" ; - scanner HoursKeyword = "hours" ; - scanner IfKeyword = "if" ; - scanner ImportKeyword = "import" ; - scanner IndexedKeyword = "indexed" ; - scanner InKeyword = "in" ; - scanner InlineKeyword = "inline" ; - scanner InterfaceKeyword = "interface" ; - scanner InternalKeyword = "internal" ; - scanner IsKeyword = "is" ; - scanner LetKeyword = "let" ; - scanner LibraryKeyword = "library" ; - scanner MappingKeyword = "mapping" ; - scanner MatchKeyword = "match" ; - scanner MemoryKeyword = "memory" ; - scanner MinutesKeyword = "minutes" ; - scanner ModifierKeyword = "modifier" ; - scanner NewKeyword = "new" ; - scanner NullKeyword = "null" ; - scanner OfKeyword = "of" ; - scanner PayableKeyword = "payable" ; - scanner PragmaKeyword = "pragma" ; - scanner PrivateKeyword = "private" ; - scanner PublicKeyword = "public" ; - scanner PureKeyword = "pure" ; - scanner RelocatableKeyword = "relocatable" ; - scanner ReturnKeyword = "return" ; - scanner ReturnsKeyword = "returns" ; - scanner SecondsKeyword = "seconds" ; - scanner SolidityKeyword = "solidity" ; - scanner StaticKeyword = "static" ; - scanner StorageKeyword = "storage" ; - scanner StringKeyword = "string" ; - scanner StructKeyword = "struct" ; - scanner SwitchKeyword = "switch" ; - scanner ThrowKeyword = "throw" ; - scanner TrueKeyword = "true" ; - scanner TypeKeyword = "type"; - scanner TypeofKeyword = "typeof" ; - scanner UsingKeyword = "using" ; - scanner VarKeyword = "var" ; - scanner ViewKeyword = "view" ; - scanner WeeksKeyword = "weeks" ; - scanner WeiKeyword = "wei" ; - scanner WhileKeyword = "while" ; - scanner YearsKeyword = "years" ; - - // Always reserved but used since 0.6.0 - scanner TryKeyword = "try" ; - - // introduced in 0.4.21 - // WRONG, it is both a keyword AND identifier for some versions. - scanner EmitKeyword = { introduced in "0.4.21" "emit" } ; - - // Introduced in 0.4.22 - scanner ConstructorKeyword = { introduced in "0.4.22" "constructor" } ; - - // introduced in 0.5.0 - scanner AliasKeyword = { introduced in "0.5.0" "alias" } ; - scanner ApplyKeyword = { introduced in "0.5.0" "apply" } ; - scanner AutoKeyword = { introduced in "0.5.0" "auto" } ; - scanner CalldataKeyword = { introduced in "0.5.0" "calldata" } ; - scanner CopyofKeyword = { introduced in "0.5.0" "copyof" } ; - scanner DefineKeyword = { introduced in "0.5.0" "define" } ; - scanner ImplementsKeyword = { introduced in "0.5.0" "implements" } ; - scanner MacroKeyword = { introduced in "0.5.0" "macro" } ; - scanner MutableKeyword = { introduced in "0.5.0" "mutable" } ; - scanner PartialKeyword = { introduced in "0.5.0" "partial" } ; - scanner PromiseKeyword = { introduced in "0.5.0" "promise" } ; - scanner ReferenceKeyword = { introduced in "0.5.0" "reference" } ; - scanner SealedKeyword = { introduced in "0.5.0" "sealed" } ; - scanner SizeofKeyword = { introduced in "0.5.0" "sizeof" } ; - scanner SupportsKeyword = { introduced in "0.5.0" "supports" } ; - scanner TypedefKeyword = { introduced in "0.5.0" "typedef" } ; - - // Reserved since 0.5.0 and used since 0.8.0 - scanner UncheckedKeyword = { introduced in "0.5.0" "unchecked" } ; - // Reserved since 0.5.0 and used since 0.6.5 - scanner ImmutableKeyword = { introduced in "0.5.0" "immutable" } ; - // Reserved since 0.5.0 and used since 0.6.0 - scanner OverrideKeyword = { introduced in "0.5.0" "override" } ; - - // Introduced in 0.6.0 - scanner FallbackKeyword = { introduced in "0.6.0" "fallback" } ; - scanner ReceiveKeyword = { introduced in "0.6.0" "receive" } ; - scanner LeaveKeyword = { introduced in "0.6.0" "leave" } ; // warning: used in yul - scanner VirtualKeyword = { introduced in "0.6.0" "virtual" } ; - - // Introduced in 0.6.11 - scanner GweiKeyword = { introduced in "0.6.11" "gwei" } ; - - // Removed in 0.7.0 - scanner FinneyKeyword = { removed in "0.7.0" "finney" } ; - scanner SzaboKeyword = { removed in "0.7.0" "szabo" } ; - - // Introduced in 0.8.4 - scanner ErrorKeyword = { introduced in "0.8.4" "error" } ; - scanner RevertKeyword = { introduced in "0.8.4" "revert" } ; - - // Introduced in 0.8.13 - scanner GlobalKeyword = { introduced in "0.8.13" "global" } ; -} diff --git a/crates/solidity/inputs/language/src/grammar.rs b/crates/solidity/inputs/language/src/grammar.rs new file mode 100644 index 0000000000..764ac6209e --- /dev/null +++ b/crates/solidity/inputs/language/src/grammar.rs @@ -0,0 +1,883 @@ +//! Defines [`GrammarConstructorDslV2`], which allows turning the DSL v2 model into [`Grammar`] +//! (used for generating the parser and the CST). + +use std::cell::OnceCell; +use std::collections::{BTreeSet, HashMap}; +use std::rc::Rc; + +use codegen_grammar::Grammar; +use codegen_grammar::GrammarElement; +use codegen_grammar::ParserDefinition; +use codegen_grammar::ParserDefinitionNode; +use codegen_grammar::PrecedenceOperatorModel; +use codegen_grammar::PrecedenceParserDefinition; +use codegen_grammar::PrecedenceParserDefinitionNode; +use codegen_grammar::ScannerDefinition; +use codegen_grammar::ScannerDefinitionNode; +use codegen_grammar::TriviaParserDefinition; +use codegen_grammar::VersionQuality; +use codegen_grammar::VersionQualityRange; +use codegen_language_definition::model; +use codegen_language_definition::model::FieldsErrorRecovery; +use codegen_language_definition::model::Identifier; +use codegen_language_definition::model::Item; +use indexmap::IndexMap; + +use crate::definition::SolidityDefinition; + +/// Materializes the DSL v2 model ([`SolidityDefinition`]) into [`Grammar`]. +pub trait GrammarConstructorDslV2 { + fn from_dsl_v2() -> Rc; +} + +impl GrammarConstructorDslV2 for Grammar { + fn from_dsl_v2() -> Rc { + let lang = SolidityDefinition::create(); + + let mut items = HashMap::new(); + + for section in lang.sections { + for topic in section.topics { + let ctx = topic.lexical_context; + + for item in topic.items { + items.insert(item.name().clone(), (ctx.clone(), Rc::clone(&item))); + } + } + } + + // TODO(#638): To minimize regression in the parser migration, we keep the existing DSL v1 model + // of SourceUnit being followed by `EndOfFileTrivia`. + items.insert( + Identifier::from("SourceUnit"), + ( + None, + Rc::new(model::Item::Struct { + item: model::StructItem { + name: Identifier::from("SourceUnit"), + enabled: None, + error_recovery: None, + fields: IndexMap::from_iter([ + ( + Identifier::from("members"), + model::Field::Optional { + kind: model::FieldKind::NonTerminal { + item: Identifier::from("SourceUnitMembers"), + }, + enabled: None, + }, + ), + ( + Identifier::from("eof_trivia"), + model::Field::Optional { + kind: model::FieldKind::NonTerminal { + item: Identifier::from("EndOfFileTrivia"), + }, + enabled: None, + }, + ), + ]), + }, + }), + ), + ); + + let mut resolved = HashMap::new(); + let mut ctx = ResolveCtx { + items: &items, + resolved: &mut resolved, + }; + + let leading_trivia = Rc::new(NamedTriviaParser { + name: "LeadingTrivia", + def: resolve_trivia(lang.leading_trivia.clone(), &mut ctx), + }) as Rc; + + let trailing_trivia = Rc::new(NamedTriviaParser { + name: "TrailingTrivia", + def: resolve_trivia(lang.trailing_trivia, &mut ctx), + }) as Rc; + + let eof_trivia = Rc::new(NamedTriviaParser { + name: "EndOfFileTrivia", + def: resolve_trivia(lang.leading_trivia, &mut ctx), + }) as Rc; + + ctx.resolved.insert( + Identifier::from("EndOfFileTrivia"), + eof_trivia.clone().into(), + ); + + for (_lex_ctx, item) in items.values() { + resolve_grammar_element(item.name(), &mut ctx); + } + + // TODO(#638): To make sure the unused (not referred to) keywords are included in the scanner literal trie, + // we replicate the DSL v1 behaviour of introducing a synthetic parser that is only meant to group + // keywords by their lexical context. + let mut keywords_per_ctxt = HashMap::new(); + for (ident, (lex_ctx, item)) in &items { + let lex_ctx = lex_ctx.clone().unwrap_or(Identifier::from("Default")); + if let Item::Keyword { .. } = item.as_ref() { + keywords_per_ctxt + .entry(lex_ctx) + .or_insert_with(Vec::new) + .push(ident); + } + } + for (lex_ctx, mut keywords) in keywords_per_ctxt { + keywords.sort_unstable_by_key(|kw| kw.as_str()); + + let parser_name = Identifier::from(format!("{lex_ctx}AllKeywords")); + let all_keywords = model::EnumItem { + name: parser_name.clone(), + enabled: None, + variants: keywords + .iter() + .map(|&ident| model::EnumVariant { + name: Identifier::from("unused"), + enabled: None, + reference: ident.clone(), + }) + .collect(), + }; + + let def = resolve_choice(all_keywords, &mut ctx); + ctx.resolved.insert( + parser_name.clone(), + GrammarElement::ParserDefinition(Rc::new(NamedParserThunk { + name: parser_name.to_string().leak(), + context: lex_ctx.to_string().leak(), + is_inline: true, + def: OnceCell::from(def), + })), + ); + } + + let resolved_items = ctx + .resolved + .iter() + .map(|(name, elem)| (name.to_string().leak() as &_, elem.clone())); + + Rc::new(Grammar { + name: lang.name.to_string(), + versions: BTreeSet::from_iter(lang.versions), + leading_trivia_parser: leading_trivia.clone(), + trailing_trivia_parser: trailing_trivia.clone(), + elements: HashMap::from_iter( + resolved_items.chain( + [leading_trivia, trailing_trivia, eof_trivia] + .into_iter() + .map(|elem| (elem.name(), elem.into())), + ), + ), + }) + } +} + +#[derive(Debug)] +struct NamedScanner { + name: &'static str, + def: ScannerDefinitionNode, +} + +impl ScannerDefinition for NamedScanner { + fn name(&self) -> &'static str { + self.name + } + fn node(&self) -> &ScannerDefinitionNode { + &self.def + } +} + +#[derive(Debug)] +struct NamedTriviaParser { + name: &'static str, + def: ParserDefinitionNode, +} + +impl TriviaParserDefinition for NamedTriviaParser { + fn name(&self) -> &'static str { + self.name + } + + fn context(&self) -> &'static str { + // NOTE: + "Default" + } + + fn node(&self) -> &ParserDefinitionNode { + &self.def + } +} + +#[derive(Debug)] +struct NamedParserThunk { + name: &'static str, + context: &'static str, + is_inline: bool, + def: OnceCell, +} + +impl ParserDefinition for NamedParserThunk { + fn name(&self) -> &'static str { + self.name + } + + fn context(&self) -> &'static str { + self.context + } + + fn is_inline(&self) -> bool { + self.is_inline + } + + fn node(&self) -> &ParserDefinitionNode { + self.def.get().expect("Thunk to be resolved") + } +} + +#[derive(Debug)] +struct NamedPrecedenceParserThunk { + name: &'static str, + context: &'static str, + def: OnceCell, +} +impl PrecedenceParserDefinition for NamedPrecedenceParserThunk { + fn name(&self) -> &'static str { + self.name + } + + fn context(&self) -> &'static str { + self.context + } + + fn node(&self) -> &PrecedenceParserDefinitionNode { + self.def.get().expect("Thunk to be resolved") + } +} + +fn enabled_to_range(spec: model::VersionSpecifier) -> Vec { + match spec { + model::VersionSpecifier::Never => vec![VersionQualityRange { + from: semver::Version::new(0, 0, 0), + quality: VersionQuality::Removed, + }], + model::VersionSpecifier::From { from } => vec![VersionQualityRange { + from, + quality: VersionQuality::Introduced, + }], + model::VersionSpecifier::Till { till } => vec![VersionQualityRange { + from: till, + quality: VersionQuality::Removed, + }], + model::VersionSpecifier::Range { from, till } => vec![ + VersionQualityRange { + from, + quality: VersionQuality::Introduced, + }, + VersionQualityRange { + from: till, + quality: VersionQuality::Removed, + }, + ], + } +} + +struct ResolveCtx<'a> { + items: &'a HashMap, Rc)>, + resolved: &'a mut HashMap, +} + +fn resolve_grammar_element(ident: &Identifier, ctx: &mut ResolveCtx) -> GrammarElement { + if ident.as_str() == "EndOfFileTrivia" { + return ctx.resolved.get(ident).unwrap().clone(); + } + + let (lex_ctx, elem) = ctx.items.get(ident).expect("Missing item"); + + // FIXME: Don't leak + let lex_ctx = lex_ctx + .as_ref() + .map(|l| l.to_string().leak() as &_) + .unwrap_or("Default"); + + enum ParserThunk { + Regular(Rc), + Precedence(Rc), + } + impl ParserThunk { + fn as_regular_def(&self) -> &OnceCell { + match self { + ParserThunk::Regular(thunk) => &thunk.def, + _ => panic!("Expected a regular parser thunk"), + } + } + + fn as_precedence_def(&self) -> &OnceCell { + match self { + ParserThunk::Precedence(thunk) => &thunk.def, + _ => panic!("Expected a precedence parser thunk"), + } + } + } + // The non-terminals are mutually recursive (so will be the resolution of their definitions), + // so make sure to insert a thunk for non-terminals to resolve to break the cycle. + let inserted_thunk = match (elem.as_ref(), ctx.resolved.contains_key(ident)) { + ( + Item::Struct { .. } + | Item::Enum { .. } + | Item::Repeated { .. } + | Item::Separated { .. }, + false, + ) => { + let thunk = Rc::new(NamedParserThunk { + name: ident.to_string().leak(), + context: lex_ctx, + // Enums have a single reference per variant, so they should be inlined. + is_inline: matches!(elem.as_ref(), Item::Enum { .. }), + def: OnceCell::new(), + }); + ctx.resolved.insert( + ident.clone(), + (thunk.clone() as Rc).into(), + ); + Some(ParserThunk::Regular(thunk)) + } + (Item::Precedence { .. }, false) => { + let thunk = Rc::new(NamedPrecedenceParserThunk { + name: ident.to_string().leak(), + context: lex_ctx, + def: OnceCell::new(), + }); + ctx.resolved.insert( + ident.clone(), + (thunk.clone() as Rc).into(), + ); + Some(ParserThunk::Precedence(thunk)) + } + _ => None, + }; + + match (inserted_thunk, ctx.resolved.get(ident)) { + // Already resolved + (None, Some(resolved)) => resolved.clone(), + (Some(..), None) => unreachable!("We just inserted a thunk!"), + // First time resolving a non-terminal named `ident` (since we just inserted a thunk) + // Any recursive resolution for this non-terminal will already use the thunk. + // Once we're finished, we initialize the cell with the resolved definition. + (Some(thunk), _) => { + match elem.as_ref() { + Item::Struct { item } => { + let item = item.clone(); + thunk + .as_regular_def() + .set(resolve_sequence_like( + item.enabled, + item.fields, + item.error_recovery, + ctx, + )) + .unwrap(); + } + Item::Enum { item } => { + thunk + .as_regular_def() + .set(resolve_choice(item.clone(), ctx)) + .unwrap(); + } + Item::Repeated { item } => { + thunk + .as_regular_def() + .set(resolve_repeated(item.clone(), ctx)) + .unwrap(); + } + Item::Separated { item } => { + thunk + .as_regular_def() + .set(resolve_separated(item.clone(), ctx)) + .unwrap(); + } + Item::Precedence { item } => { + thunk + .as_precedence_def() + .set(resolve_precedence(item.clone(), lex_ctx, ctx)) + .unwrap(); + } + _ => unreachable!("Only non-terminals can be resolved here"), + }; + + ctx.resolved.get(ident).cloned().unwrap() + } + // First time resolving a terminal named `ident` + (None, None) => { + let named_scanner = match elem.as_ref() { + Item::Trivia { item } => NamedScanner { + name: ident.to_string().leak(), + def: resolve_scanner(item.scanner.clone(), ctx), + }, + Item::Fragment { item } => NamedScanner { + name: ident.to_string().leak(), + def: resolve_fragment(item.clone(), ctx), + }, + Item::Token { item } => NamedScanner { + name: ident.to_string().leak(), + def: resolve_token(item.clone(), ctx), + }, + Item::Keyword { item } => NamedScanner { + name: ident.to_string().leak(), + def: resolve_keyword(item.clone()), + }, + _ => unreachable!("Only terminals can be resolved here"), + }; + + let resolved = GrammarElement::ScannerDefinition(Rc::new(named_scanner)); + ctx.resolved.insert(ident.clone(), resolved.clone()); + + resolved + } + } +} + +fn resolve_scanner(scanner: model::Scanner, ctx: &mut ResolveCtx) -> ScannerDefinitionNode { + match scanner { + model::Scanner::Optional { scanner } => { + ScannerDefinitionNode::Optional(Box::new(resolve_scanner(*scanner, ctx))) + } + model::Scanner::ZeroOrMore { scanner } => { + ScannerDefinitionNode::ZeroOrMore(Box::new(resolve_scanner(*scanner, ctx))) + } + model::Scanner::OneOrMore { scanner } => { + ScannerDefinitionNode::OneOrMore(Box::new(resolve_scanner(*scanner, ctx))) + } + model::Scanner::Sequence { scanners } => ScannerDefinitionNode::Sequence( + scanners + .into_iter() + .map(|scanner| resolve_scanner(scanner, ctx)) + .collect(), + ), + model::Scanner::Choice { scanners } => ScannerDefinitionNode::Choice( + scanners + .into_iter() + .map(|scanner| resolve_scanner(scanner, ctx)) + .collect(), + ), + model::Scanner::Not { chars } => ScannerDefinitionNode::NoneOf(chars.into_iter().collect()), + model::Scanner::TrailingContext { + scanner, + not_followed_by, + } => ScannerDefinitionNode::NotFollowedBy( + Box::new(resolve_scanner(*scanner, ctx)), + Box::new(resolve_scanner(*not_followed_by, ctx)), + ), + model::Scanner::Range { + inclusive_start, + inclusive_end, + } => ScannerDefinitionNode::CharRange(inclusive_start, inclusive_end), + model::Scanner::Atom { atom } => ScannerDefinitionNode::Literal(atom), + model::Scanner::Fragment { reference } => match resolve_grammar_element(&reference, ctx) { + GrammarElement::ScannerDefinition(parser) => { + ScannerDefinitionNode::ScannerDefinition(parser) + } + _ => panic!("Expected {reference} to be a ScannerDefinition"), + }, + } +} + +fn resolve_fragment(fragment: model::FragmentItem, ctx: &mut ResolveCtx) -> ScannerDefinitionNode { + resolve_scanner(fragment.scanner, ctx).versioned(fragment.enabled) +} + +fn resolve_token(token: model::TokenItem, ctx: &mut ResolveCtx) -> ScannerDefinitionNode { + let resolved_defs: Vec<_> = token + .definitions + .into_iter() + .map(|def| resolve_scanner(def.scanner, ctx).versioned(def.enabled)) + .collect(); + + match resolved_defs.len() { + 0 => panic!("Token {} has no definitions", token.name), + 1 => resolved_defs.into_iter().next().unwrap(), + _ => ScannerDefinitionNode::Choice(resolved_defs), + } +} + +fn resolve_keyword(keyword: model::KeywordItem) -> ScannerDefinitionNode { + // TODO(#568): Handle reserved keywords using the given "Identifier" parser + let _ = keyword.identifier; + + let defs: Vec<_> = keyword + .definitions + .into_iter() + .map(|def| { + let value = resolve_keyword_value(def.value); + // If missing, the default is "Always" + match (def.enabled, def.reserved) { + // Contextual keywords (never reserved) + // TODO(#568): Properly support contextual keywords. + // Currently, to minimize the diff and ease the transition to the DSL v2, we treat them as normal keywords. + // Moreover, since the DSL v1 only treats "enablement" as being reserved, we try to preserve that for now. + (enabled, Some(model::VersionSpecifier::Never)) => value.versioned(enabled), + // TODO(#568): If a contextual keyword was enabled at some point and then reserved, for now we treat it + // as a reserved keyword starting from when it was being used, to preserve the DSL v1 behaviour. + ( + Some(model::VersionSpecifier::From { from: enabled }), + Some(model::VersionSpecifier::From { from: reserved }), + ) if enabled < reserved => ScannerDefinitionNode::Versioned( + Box::new(value), + enabled_to_range(model::VersionSpecifier::From { from: enabled }), + ), + (_, Some(reserved)) => { + ScannerDefinitionNode::Versioned(Box::new(value), enabled_to_range(reserved)) + } + // The keyword is always reserved + (_, None) => value, + } + }) + .collect(); + + match defs.len() { + 0 => panic!("Keyword {} has no definitions", keyword.name), + 1 => defs.into_iter().next().unwrap(), + _ => ScannerDefinitionNode::Choice(defs), + } +} + +fn resolve_keyword_value(value: model::KeywordValue) -> ScannerDefinitionNode { + match value { + model::KeywordValue::Sequence { values } => { + ScannerDefinitionNode::Sequence(values.into_iter().map(resolve_keyword_value).collect()) + } + model::KeywordValue::Choice { values } => { + ScannerDefinitionNode::Choice(values.into_iter().map(resolve_keyword_value).collect()) + } + model::KeywordValue::Optional { value } => { + ScannerDefinitionNode::Optional(Box::new(resolve_keyword_value(*value))) + } + model::KeywordValue::Atom { atom } => ScannerDefinitionNode::Literal(atom), + } +} + +fn resolve_trivia(parser: model::TriviaParser, ctx: &mut ResolveCtx) -> ParserDefinitionNode { + match parser { + model::TriviaParser::Optional { parser } => { + ParserDefinitionNode::Optional(Box::new(resolve_trivia(*parser, ctx))) + } + model::TriviaParser::OneOrMore { parser } => { + ParserDefinitionNode::OneOrMore(Box::new(resolve_trivia(*parser, ctx))) + } + model::TriviaParser::ZeroOrMore { parser } => { + ParserDefinitionNode::ZeroOrMore(Box::new(resolve_trivia(*parser, ctx))) + } + model::TriviaParser::Sequence { parsers } => ParserDefinitionNode::Sequence( + parsers + .into_iter() + .map(|scanner| resolve_trivia(scanner, ctx)) + .collect(), + ), + model::TriviaParser::Choice { parsers } => ParserDefinitionNode::Choice( + parsers + .into_iter() + .map(|scanner| resolve_trivia(scanner, ctx)) + .collect(), + ), + model::TriviaParser::Trivia { trivia } => match resolve_grammar_element(&trivia, ctx) { + GrammarElement::ScannerDefinition(parser) => { + ParserDefinitionNode::ScannerDefinition(parser) + } + _ => panic!("Expected {trivia} to be a ScannerDefinition"), + }, + } +} + +fn resolve_field(field: model::Field, ctx: &mut ResolveCtx) -> ParserDefinitionNode { + match field { + model::Field::Required { kind } => resolve_field_kind(kind, ctx), + model::Field::Optional { kind, enabled } => ParserDefinitionNode::Optional(Box::new( + resolve_field_kind(kind, ctx).versioned(enabled), + )), + } +} + +fn resolve_field_kind(kind: model::FieldKind, ctx: &mut ResolveCtx) -> ParserDefinitionNode { + match kind { + model::FieldKind::NonTerminal { item } => { + resolve_grammar_element(&item, ctx).into_parser_def_node() + } + model::FieldKind::Terminal { items } => { + let refs: Vec<_> = items + .iter() + .map(|ident| resolve_grammar_element(ident, ctx).into_parser_def_node()) + .collect(); + + match refs.len() { + 0 => panic!("Field has no definitions"), + 1 => refs.into_iter().next().unwrap(), + _ => ParserDefinitionNode::Choice(refs), + } + } + } +} + +fn resolve_sequence_like( + enabled: Option, + fields: IndexMap, + error_recovery: Option, + ctx: &mut ResolveCtx, +) -> ParserDefinitionNode { + let (terminator, delimiters) = match error_recovery { + Some(FieldsErrorRecovery { + terminator: None, + delimiters: None, + }) => panic!("Empty error_recovery"), + None => (None, None), + Some(FieldsErrorRecovery { + terminator, + delimiters, + }) => (terminator, delimiters), + }; + + let mut fields: Vec<_> = fields + .into_iter() + .map(|(name, field)| (name, resolve_field(field, ctx))) + .collect(); + + // Transform inline [.., open, body, close, ..] sequence into single DelimitedBy(open, body, close) node + if let Some(delimiters) = delimiters { + let open_idx = fields.iter().position(|(nam, _)| nam == &delimiters.open); + let close_idx = fields.iter().position(|(nam, _)| nam == &delimiters.close); + let (open_idx, close_idx) = (open_idx.unwrap(), close_idx.unwrap()); + + let delimited_body: Vec<_> = fields + .drain((open_idx + 1)..close_idx) + .map(|(_, field)| field) + .collect(); + + let delimited_body = match delimited_body.len() { + 1 => delimited_body.into_iter().next().unwrap(), + 0 => ParserDefinitionNode::Sequence(vec![]), + _ => ParserDefinitionNode::Sequence(delimited_body), + }; + // Replace the remaining delimiters with the new delimited body + let delimited = { + let mut delims = fields + .drain(open_idx..=open_idx + 1) + .map(|(_, field)| field); + dbg!(delims.size_hint()); + let open = delims.next().unwrap(); + let close = delims.next().unwrap(); + + ParserDefinitionNode::DelimitedBy( + Box::new(open), + Box::new(delimited_body), + Box::new(close), + ) + }; + fields.insert( + open_idx, + ( + delimiters.open, // dummy, identifiers are stripped here anyway + delimited, + ), + ); + } + + let terminator = match terminator { + Some(terminator) => { + let (name, def) = fields.pop().unwrap(); + assert_eq!(name, terminator); + + Some(def) + } + None => None, + }; + + let body = ParserDefinitionNode::Sequence(fields.into_iter().map(|(_, def)| def).collect()); + + if let Some(terminator) = terminator { + ParserDefinitionNode::TerminatedBy(Box::new(body), Box::new(terminator)) + } else { + body + } + .versioned(enabled) +} + +fn resolve_choice(item: model::EnumItem, ctx: &mut ResolveCtx) -> ParserDefinitionNode { + let variants = item + .variants + .into_iter() + .map(|variant| { + resolve_grammar_element(&variant.reference, ctx) + .into_parser_def_node() + .versioned(variant.enabled) + }) + .collect(); + + ParserDefinitionNode::Choice(variants).versioned(item.enabled) +} + +fn resolve_repeated(item: model::RepeatedItem, ctx: &mut ResolveCtx) -> ParserDefinitionNode { + let body = Box::new(resolve_grammar_element(&item.repeated, ctx).into_parser_def_node()); + + let repeated = if item.allow_empty.unwrap_or(false) { + ParserDefinitionNode::ZeroOrMore + } else { + ParserDefinitionNode::OneOrMore + }; + + repeated(body).versioned(item.enabled) +} + +fn resolve_separated(item: model::SeparatedItem, ctx: &mut ResolveCtx) -> ParserDefinitionNode { + let body = resolve_grammar_element(&item.separated, ctx).into_parser_def_node(); + let separator = resolve_grammar_element(&item.separator, ctx).into_parser_def_node(); + + let separated_by = ParserDefinitionNode::SeparatedBy(Box::new(body), Box::new(separator)) + .versioned(item.enabled); + + if item.allow_empty.unwrap_or(false) { + ParserDefinitionNode::Optional(Box::new(separated_by)) + } else { + separated_by + } +} + +fn resolve_precedence( + item: model::PrecedenceItem, + lex_ctx: &'static str, + ctx: &mut ResolveCtx, +) -> PrecedenceParserDefinitionNode { + let primaries: Vec<_> = item + .primary_expressions + .into_iter() + .map(|prim| { + resolve_grammar_element(&prim.expression, ctx) + .into_parser_def_node() + .versioned(prim.enabled) + }) + .collect(); + let primary_expression = Box::new(match primaries.len() { + 0 => panic!("Precedence operator has no primary expressions"), + 1 => primaries.into_iter().next().unwrap(), + _ => ParserDefinitionNode::Choice(primaries), + }); + + fn model_to_enum(model: model::OperatorModel) -> PrecedenceOperatorModel { + match model { + model::OperatorModel::BinaryLeftAssociative => { + PrecedenceOperatorModel::BinaryLeftAssociative + } + model::OperatorModel::BinaryRightAssociative => { + PrecedenceOperatorModel::BinaryRightAssociative + } + model::OperatorModel::Prefix => PrecedenceOperatorModel::Prefix, + model::OperatorModel::Postfix => PrecedenceOperatorModel::Postfix, + } + } + + let mut operators = vec![]; + for expr in item.precedence_expressions { + let name = expr.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(), + 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. + 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, + )); + } + + let defs: Vec<_> = expr + .operators + .into_iter() + .map(|op| resolve_sequence_like(op.enabled, op.fields, op.error_recovery, ctx)) + .collect(); + + let def = match defs.len() { + 0 => panic!("Precedence operator {} has no definitions", name), + 1 => defs.into_iter().next().unwrap(), + _ => ParserDefinitionNode::Choice(defs), + }; + + thunk.def.set(def).unwrap(); + assert!( + !ctx.resolved.contains_key(&name), + "Encountered a duplicate Precedence Operator named {name} when resolving" + ); + ctx.resolved + .insert(name.clone(), GrammarElement::ParserDefinition(thunk)); + } + + PrecedenceParserDefinitionNode { + primary_expression, + operators, + } +} + +trait IntoParserDefNode { + fn into_parser_def_node(self) -> ParserDefinitionNode; +} + +impl IntoParserDefNode for GrammarElement { + fn into_parser_def_node(self) -> ParserDefinitionNode { + match self { + GrammarElement::ParserDefinition(parser) => { + ParserDefinitionNode::ParserDefinition(parser) + } + GrammarElement::ScannerDefinition(parser) => { + ParserDefinitionNode::ScannerDefinition(parser) + } + GrammarElement::TriviaParserDefinition(parser) => { + ParserDefinitionNode::TriviaParserDefinition(parser) + } + GrammarElement::PrecedenceParserDefinition(parser) => { + ParserDefinitionNode::PrecedenceParserDefinition(parser) + } + } + } +} + +/// Helper trait to wrap a definition node with a version specifier. +trait VersionWrapped { + fn versioned(self, enabled: Option) -> Self; +} + +impl VersionWrapped for ParserDefinitionNode { + fn versioned(self, enabled: Option) -> Self { + if let Some(enabled) = enabled { + Self::Versioned(Box::new(self), enabled_to_range(enabled)) + } else { + self + } + } +} + +impl VersionWrapped for ScannerDefinitionNode { + fn versioned(self, enabled: Option) -> Self { + if let Some(enabled) = enabled { + Self::Versioned(Box::new(self), enabled_to_range(enabled)) + } else { + self + } + } +} diff --git a/crates/solidity/inputs/language/src/lib.rs b/crates/solidity/inputs/language/src/lib.rs index a3326b6b19..aeb30c25ab 100644 --- a/crates/solidity/inputs/language/src/lib.rs +++ b/crates/solidity/inputs/language/src/lib.rs @@ -7,10 +7,10 @@ //! Call the [`SolidityLanguageExtensions::load_solidity`] method to load the precompiled language definition. mod definition; -mod dsl; +mod grammar; -pub use definition::*; -pub use dsl::GrammarConstructorDslV1; +pub use definition::SolidityDefinition; +pub use grammar::GrammarConstructorDslV2; use anyhow::Result; use codegen_schema::types::{LanguageDefinition, LanguageDefinitionRef}; diff --git a/crates/solidity/outputs/cargo/build/src/main.rs b/crates/solidity/outputs/cargo/build/src/main.rs index 48f1999d2b..d80be72b76 100644 --- a/crates/solidity/outputs/cargo/build/src/main.rs +++ b/crates/solidity/outputs/cargo/build/src/main.rs @@ -4,7 +4,7 @@ use cargo_emit::rerun_if_changed; use codegen_grammar::Grammar; use codegen_parser_generator::code_generator::CodeGenerator; use infra_utils::{cargo::CargoWorkspace, paths::PathExtensions}; -use solidity_language::GrammarConstructorDslV1; +use solidity_language::GrammarConstructorDslV2; // Instead of the soure crate calling codegen APIs directly in the build script, it invokes this binary, which in turn // calls the codegen APIs (and hence why it's emitting `cargo:` directives). @@ -17,7 +17,8 @@ use solidity_language::GrammarConstructorDslV1; fn main() -> Result<()> { // Generate files in the source crate: { - let grammar = Grammar::from_dsl_v1(); + let grammar = Grammar::from_dsl_v2(); + let crate_dir = CargoWorkspace::locate_source_crate("slang_solidity")?; CodeGenerator::write_source(&crate_dir.join("src/generated"), &grammar)?; diff --git a/crates/solidity/outputs/cargo/crate/src/generated/kinds.rs b/crates/solidity/outputs/cargo/crate/src/generated/kinds.rs index b36c8748b4..4980fe275f 100644 --- a/crates/solidity/outputs/cargo/crate/src/generated/kinds.rs +++ b/crates/solidity/outputs/cargo/crate/src/generated/kinds.rs @@ -19,7 +19,6 @@ use {napi::bindgen_prelude::*, napi_derive::napi}; pub enum ProductionKind { ABICoderPragma, AddressType, - ArgumentsDeclaration, ArrayExpression, ArrayValues, AsciiStringLiterals, @@ -40,6 +39,7 @@ pub enum ProductionKind { DecimalNumberExpression, DeleteStatement, DoWhileStatement, + ElseBranch, EmitStatement, EndOfFileTrivia, EnumDefinition, @@ -59,7 +59,6 @@ pub enum ProductionKind { FallbackFunctionDefinition, ForStatement, FunctionAttributes, - FunctionCallOptions, FunctionDefinition, FunctionType, FunctionTypeAttributes, @@ -67,10 +66,12 @@ pub enum ProductionKind { HexStringLiterals, IdentifierPath, IfStatement, + ImportAlias, ImportDeconstruction, ImportDeconstructionSymbol, ImportDeconstructionSymbols, ImportDirective, + IndexAccessEnd, InheritanceSpecifier, InheritanceType, InheritanceTypes, @@ -79,24 +80,28 @@ pub enum ProductionKind { LeadingTrivia, LibraryDefinition, LibraryMembers, - MappingKeyType, + MappingKey, MappingType, - MappingValueType, + MappingValue, ModifierAttributes, ModifierDefinition, ModifierInvocation, NamedArgument, + NamedArgumentGroup, + NamedArgumentGroups, NamedArguments, NamedArgumentsDeclaration, NamedImport, NewExpression, OverridePaths, + OverridePathsDeclaration, OverrideSpecifier, Parameter, Parameters, ParametersDeclaration, PathImport, PositionalArguments, + PositionalArgumentsDeclaration, PragmaDirective, ReceiveFunctionAttributes, ReceiveFunctionDefinition, @@ -107,6 +112,7 @@ pub enum ProductionKind { SourceUnitMembers, StateVariableAttributes, StateVariableDefinition, + StateVariableDefinitionValue, Statements, StructDefinition, StructMember, @@ -118,6 +124,7 @@ pub enum ProductionKind { TupleDeconstructionElements, TupleDeconstructionStatement, TupleExpression, + TupleValue, TupleValues, TypeExpression, TypeName, @@ -128,12 +135,13 @@ pub enum ProductionKind { UnnamedFunctionDefinition, UntypedTupleMember, UserDefinedValueTypeDefinition, + UsingAlias, UsingDeconstruction, UsingDeconstructionSymbol, UsingDeconstructionSymbols, UsingDirective, - VariableDeclaration, VariableDeclarationStatement, + VariableDeclarationValue, VersionPragma, VersionPragmaExpression, VersionPragmaExpressions, @@ -144,21 +152,24 @@ pub enum ProductionKind { YulBlock, YulBreakStatement, YulContinueStatement, - YulDeclarationStatement, + YulDefaultCase, YulExpression, YulForStatement, YulFunctionDefinition, YulIdentifierPath, YulIdentifierPaths, - YulIdentifiers, YulIfStatement, YulLeaveStatement, + YulParameters, YulParametersDeclaration, + YulReturnVariables, YulReturnsDeclaration, YulStatements, - YulSwitchCase, YulSwitchCases, YulSwitchStatement, + YulValueCase, + YulVariableDeclarationStatement, + YulVariableDeclarationValue, } #[derive( @@ -177,7 +188,6 @@ pub enum ProductionKind { pub enum RuleKind { ABICoderPragma, AddressType, - ArgumentsDeclaration, ArrayExpression, ArrayTypeName, ArrayValues, @@ -201,6 +211,7 @@ pub enum RuleKind { DecimalNumberExpression, DeleteStatement, DoWhileStatement, + ElseBranch, EmitStatement, EndOfFileTrivia, EnumDefinition, @@ -221,7 +232,6 @@ pub enum RuleKind { ForStatement, FunctionAttributes, FunctionCallExpression, - FunctionCallOptions, FunctionDefinition, FunctionType, FunctionTypeAttributes, @@ -229,10 +239,12 @@ pub enum RuleKind { HexStringLiterals, IdentifierPath, IfStatement, + ImportAlias, ImportDeconstruction, ImportDeconstructionSymbol, ImportDeconstructionSymbols, ImportDirective, + IndexAccessEnd, IndexAccessExpression, InheritanceSpecifier, InheritanceType, @@ -242,25 +254,29 @@ pub enum RuleKind { LeadingTrivia, LibraryDefinition, LibraryMembers, - MappingKeyType, + MappingKey, MappingType, - MappingValueType, + MappingValue, MemberAccessExpression, ModifierAttributes, ModifierDefinition, ModifierInvocation, NamedArgument, + NamedArgumentGroup, + NamedArgumentGroups, NamedArguments, NamedArgumentsDeclaration, NamedImport, NewExpression, OverridePaths, + OverridePathsDeclaration, OverrideSpecifier, Parameter, Parameters, ParametersDeclaration, PathImport, PositionalArguments, + PositionalArgumentsDeclaration, PragmaDirective, ReceiveFunctionAttributes, ReceiveFunctionDefinition, @@ -271,6 +287,7 @@ pub enum RuleKind { SourceUnitMembers, StateVariableAttributes, StateVariableDefinition, + StateVariableDefinitionValue, Statements, StructDefinition, StructMember, @@ -282,6 +299,7 @@ pub enum RuleKind { TupleDeconstructionElements, TupleDeconstructionStatement, TupleExpression, + TupleValue, TupleValues, TypeExpression, TypeName, @@ -294,12 +312,13 @@ pub enum RuleKind { UnnamedFunctionDefinition, UntypedTupleMember, UserDefinedValueTypeDefinition, + UsingAlias, UsingDeconstruction, UsingDeconstructionSymbol, UsingDeconstructionSymbols, UsingDirective, - VariableDeclaration, VariableDeclarationStatement, + VariableDeclarationValue, VersionPragma, VersionPragmaBinaryExpression, VersionPragmaExpression, @@ -312,22 +331,25 @@ pub enum RuleKind { YulBlock, YulBreakStatement, YulContinueStatement, - YulDeclarationStatement, + YulDefaultCase, YulExpression, YulForStatement, YulFunctionCallExpression, YulFunctionDefinition, YulIdentifierPath, YulIdentifierPaths, - YulIdentifiers, YulIfStatement, YulLeaveStatement, + YulParameters, YulParametersDeclaration, + YulReturnVariables, YulReturnsDeclaration, YulStatements, - YulSwitchCase, YulSwitchCases, YulSwitchStatement, + YulValueCase, + YulVariableDeclarationStatement, + YulVariableDeclarationValue, } impl RuleKind { @@ -383,7 +405,7 @@ pub enum TokenKind { BreakKeyword, ByteKeyword, BytesKeyword, - CalldataKeyword, + CallDataKeyword, Caret, CaretEqual, CaseKeyword, @@ -398,7 +420,7 @@ pub enum TokenKind { ConstructorKeyword, ContinueKeyword, ContractKeyword, - CopyofKeyword, + CopyOfKeyword, DaysKeyword, DecimalLiteral, DefaultKeyword, @@ -449,7 +471,6 @@ pub enum TokenKind { InterfaceKeyword, InternalKeyword, IsKeyword, - LeaveKeyword, LessThan, LessThanEqual, LessThanLessThan, @@ -499,7 +520,7 @@ pub enum TokenKind { SecondsKeyword, Semicolon, SingleLineComment, - SizeofKeyword, + SizeOfKeyword, Slash, SlashEqual, SolidityKeyword, @@ -514,9 +535,9 @@ pub enum TokenKind { Tilde, TrueKeyword, TryKeyword, + TypeDefKeyword, TypeKeyword, - TypedefKeyword, - TypeofKeyword, + TypeOfKeyword, UfixedKeyword, UintKeyword, UncheckedKeyword, @@ -531,9 +552,116 @@ pub enum TokenKind { WhileKeyword, Whitespace, YearsKeyword, + YulAbstractKeyword, + YulAddressKeyword, + YulAfterKeyword, + YulAliasKeyword, + YulAnonymousKeyword, + YulApplyKeyword, + YulAsKeyword, + YulAssemblyKeyword, + YulAutoKeyword, + YulBoolKeyword, + YulBreakKeyword, + YulByteKeyword, + YulBytesKeyword, + YulCallDataKeyword, + YulCaseKeyword, + YulCatchKeyword, + YulConstantKeyword, + YulConstructorKeyword, + YulContinueKeyword, + YulContractKeyword, + YulCopyOfKeyword, + YulDaysKeyword, YulDecimalLiteral, + YulDefaultKeyword, + YulDefineKeyword, + YulDeleteKeyword, + YulDoKeyword, + YulElseKeyword, + YulEmitKeyword, + YulEnumKeyword, + YulEtherKeyword, + YulEventKeyword, + YulExternalKeyword, + YulFallbackKeyword, + YulFalseKeyword, + YulFinalKeyword, + YulFinneyKeyword, + YulFixedKeyword, + YulForKeyword, + YulFunctionKeyword, + YulGweiKeyword, + YulHexKeyword, YulHexLiteral, + YulHoursKeyword, YulIdentifier, + YulIfKeyword, + YulImmutableKeyword, + YulImplementsKeyword, + YulImportKeyword, + YulInKeyword, + YulIndexedKeyword, + YulInlineKeyword, + YulIntKeyword, + YulInterfaceKeyword, + YulInternalKeyword, + YulIsKeyword, + YulLeaveKeyword, + YulLetKeyword, + YulLibraryKeyword, + YulMacroKeyword, + YulMappingKeyword, + YulMatchKeyword, + YulMemoryKeyword, + YulMinutesKeyword, + YulModifierKeyword, + YulMutableKeyword, + YulNewKeyword, + YulNullKeyword, + YulOfKeyword, + YulOverrideKeyword, + YulPartialKeyword, + YulPayableKeyword, + YulPragmaKeyword, + YulPrivateKeyword, + YulPromiseKeyword, + YulPublicKeyword, + YulPureKeyword, + YulReceiveKeyword, + YulReferenceKeyword, + YulRelocatableKeyword, + YulReturnKeyword, + YulReturnsKeyword, + YulRevertKeyword, + YulSealedKeyword, + YulSecondsKeyword, + YulSizeOfKeyword, + YulStaticKeyword, + YulStorageKeyword, + YulStringKeyword, + YulStructKeyword, + YulSupportsKeyword, + YulSwitchKeyword, + YulSzaboKeyword, + YulThrowKeyword, + YulTrueKeyword, + YulTryKeyword, + YulTypeDefKeyword, + YulTypeKeyword, + YulTypeOfKeyword, + YulUfixedKeyword, + YulUintKeyword, + YulUncheckedKeyword, + YulUsingKeyword, + YulVarKeyword, + YulViewKeyword, + YulVirtualKeyword, + YulWeeksKeyword, + YulWeiKeyword, + YulWhileKeyword, + YulYearsKeyword, } #[derive(strum_macros::FromRepr)] @@ -542,8 +670,8 @@ pub enum TokenKind { #[cfg_attr(not(feature = "slang_napi_interfaces"), derive(Clone, Copy))] pub enum LexicalContext { Default, - VersionPragma, - YulBlock, + Pragma, + Yul, } /// Marker trait for type-level [`LexicalContext`] variants. @@ -561,16 +689,16 @@ pub mod LexicalContextType { LexicalContext::Default } } - pub struct VersionPragma {} - impl IsLexicalContext for VersionPragma { + pub struct Pragma {} + impl IsLexicalContext for Pragma { fn value() -> LexicalContext { - LexicalContext::VersionPragma + LexicalContext::Pragma } } - pub struct YulBlock {} - impl IsLexicalContext for YulBlock { + pub struct Yul {} + impl IsLexicalContext for Yul { fn value() -> LexicalContext { - LexicalContext::YulBlock + LexicalContext::Yul } } } diff --git a/crates/solidity/outputs/cargo/crate/src/generated/language.rs b/crates/solidity/outputs/cargo/crate/src/generated/language.rs index a0ad62c13a..c889122236 100644 --- a/crates/solidity/outputs/cargo/crate/src/generated/language.rs +++ b/crates/solidity/outputs/cargo/crate/src/generated/language.rs @@ -21,13 +21,16 @@ use super::napi::napi_parse_output::ParseOutput as NAPIParseOutput; #[cfg_attr(feature = "slang_napi_interfaces", napi(namespace = "language"))] pub struct Language { pub(crate) version: Version, + pub(crate) version_is_at_least_0_4_14: bool, pub(crate) version_is_at_least_0_4_21: bool, pub(crate) version_is_at_least_0_4_22: bool, pub(crate) version_is_at_least_0_5_0: bool, pub(crate) version_is_at_least_0_5_3: bool, + pub(crate) version_is_at_least_0_5_10: bool, pub(crate) version_is_at_least_0_6_0: bool, pub(crate) version_is_at_least_0_6_2: bool, pub(crate) version_is_at_least_0_6_5: bool, + pub(crate) version_is_at_least_0_6_8: bool, pub(crate) version_is_at_least_0_6_11: bool, pub(crate) version_is_at_least_0_7_0: bool, pub(crate) version_is_at_least_0_7_1: bool, @@ -142,13 +145,16 @@ impl Language { pub fn new(version: Version) -> std::result::Result { if Self::SUPPORTED_VERSIONS.binary_search(&version).is_ok() { Ok(Self { + version_is_at_least_0_4_14: Version::new(0, 4, 14) <= version, version_is_at_least_0_4_21: Version::new(0, 4, 21) <= version, version_is_at_least_0_4_22: Version::new(0, 4, 22) <= version, version_is_at_least_0_5_0: Version::new(0, 5, 0) <= version, version_is_at_least_0_5_3: Version::new(0, 5, 3) <= version, + version_is_at_least_0_5_10: Version::new(0, 5, 10) <= version, version_is_at_least_0_6_0: Version::new(0, 6, 0) <= version, version_is_at_least_0_6_2: Version::new(0, 6, 2) <= version, version_is_at_least_0_6_5: Version::new(0, 6, 5) <= version, + version_is_at_least_0_6_8: Version::new(0, 6, 8) <= version, version_is_at_least_0_6_11: Version::new(0, 6, 11) <= version, version_is_at_least_0_7_0: Version::new(0, 7, 0) <= version, version_is_at_least_0_7_1: Version::new(0, 7, 1) <= version, @@ -178,11 +184,11 @@ impl Language { #[allow(unused_assignments, unused_parens)] fn abi_coder_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::AbicoderKeyword, ))?; - seq.elem(self.parse_token_with_trivia::( + seq.elem(self.parse_token_with_trivia::( input, TokenKind::Identifier, ))?; @@ -193,62 +199,20 @@ impl Language { #[allow(unused_assignments, unused_parens)] fn address_type(&self, input: &mut ParserContext) -> ParserResult { - ChoiceHelper::run(input, |mut choice, input| { - let result = SequenceHelper::run(|mut seq| { - seq.elem(self.parse_token_with_trivia::( - input, - TokenKind::AddressKeyword, - ))?; - seq.elem(OptionalHelper::transform( - self.parse_token_with_trivia::( - input, - TokenKind::PayableKeyword, - ), - ))?; - seq.finish() - }); - choice.consider(input, result)?; - let result = self.parse_token_with_trivia::( - input, - TokenKind::PayableKeyword, - ); - choice.consider(input, result)?; - choice.finish(input) - }) - .with_kind(RuleKind::AddressType) - } - - #[allow(unused_assignments, unused_parens)] - fn arguments_declaration(&self, input: &mut ParserContext) -> ParserResult { SequenceHelper::run(|mut seq| { - let mut delim_guard = input.open_delim(TokenKind::CloseParen); - let input = delim_guard.ctx(); seq.elem(self.parse_token_with_trivia::( input, - TokenKind::OpenParen, + TokenKind::AddressKeyword, ))?; - seq.elem( - OptionalHelper::transform(ChoiceHelper::run(input, |mut choice, input| { - let result = self.positional_arguments(input); - choice.consider(input, result)?; - let result = self.named_arguments_declaration(input); - choice.consider(input, result)?; - choice.finish(input) - })) - .recover_until_with_nested_delims::<_, LexicalContextType::Default>( + seq.elem(OptionalHelper::transform( + self.parse_token_with_trivia::( input, - self, - TokenKind::CloseParen, - RecoverFromNoMatch::Yes, + TokenKind::PayableKeyword, ), - )?; - seq.elem(self.parse_token_with_trivia::( - input, - TokenKind::CloseParen, ))?; seq.finish() }) - .with_kind(RuleKind::ArgumentsDeclaration) + .with_kind(RuleKind::AddressType) } #[allow(unused_assignments, unused_parens)] @@ -639,34 +603,32 @@ impl Language { choice.consider(input, result)?; let result = self.function_definition(input); choice.consider(input, result)?; - let result = self.modifier_definition(input); - choice.consider(input, result)?; - let result = self.struct_definition(input); - choice.consider(input, result)?; - let result = self.enum_definition(input); - choice.consider(input, result)?; - let result = self.event_definition(input); - choice.consider(input, result)?; - let result = self.state_variable_definition(input); - choice.consider(input, result)?; if self.version_is_at_least_0_4_22 { let result = self.constructor_definition(input); choice.consider(input, result)?; } if self.version_is_at_least_0_6_0 { - let result = ChoiceHelper::run(input, |mut choice, input| { - let result = self.fallback_function_definition(input); - choice.consider(input, result)?; - let result = self.receive_function_definition(input); - choice.consider(input, result)?; - choice.finish(input) - }); + let result = self.receive_function_definition(input); + choice.consider(input, result)?; + } + if self.version_is_at_least_0_6_0 { + let result = self.fallback_function_definition(input); choice.consider(input, result)?; } if !self.version_is_at_least_0_6_0 { let result = self.unnamed_function_definition(input); choice.consider(input, result)?; } + let result = self.modifier_definition(input); + choice.consider(input, result)?; + let result = self.struct_definition(input); + choice.consider(input, result)?; + let result = self.enum_definition(input); + choice.consider(input, result)?; + let result = self.event_definition(input); + choice.consider(input, result)?; + let result = self.state_variable_definition(input); + choice.consider(input, result)?; if self.version_is_at_least_0_8_4 { let result = self.error_definition(input); choice.consider(input, result)?; @@ -693,9 +655,30 @@ impl Language { |mut choice, input| { let result = self.parse_token_with_trivia::( input, - TokenKind::DaysKeyword, + TokenKind::WeiKeyword, ); choice.consider(input, result)?; + if self.version_is_at_least_0_6_11 { + let result = self.parse_token_with_trivia::( + input, + TokenKind::GweiKeyword, + ); + choice.consider(input, result)?; + } + if !self.version_is_at_least_0_7_0 { + let result = self.parse_token_with_trivia::( + input, + TokenKind::SzaboKeyword, + ); + choice.consider(input, result)?; + } + if !self.version_is_at_least_0_7_0 { + let result = self.parse_token_with_trivia::( + input, + TokenKind::FinneyKeyword, + ); + choice.consider(input, result)?; + } let result = self.parse_token_with_trivia::( input, TokenKind::EtherKeyword, @@ -703,7 +686,7 @@ impl Language { choice.consider(input, result)?; let result = self.parse_token_with_trivia::( input, - TokenKind::HoursKeyword, + TokenKind::SecondsKeyword, ); choice.consider(input, result)?; let result = self.parse_token_with_trivia::( @@ -713,17 +696,17 @@ impl Language { choice.consider(input, result)?; let result = self.parse_token_with_trivia::( input, - TokenKind::SecondsKeyword, + TokenKind::HoursKeyword, ); choice.consider(input, result)?; let result = self.parse_token_with_trivia::( input, - TokenKind::WeeksKeyword, + TokenKind::DaysKeyword, ); choice.consider(input, result)?; let result = self.parse_token_with_trivia::( input, - TokenKind::WeiKeyword, + TokenKind::WeeksKeyword, ); choice.consider(input, result)?; if !self.version_is_at_least_0_5_0 { @@ -733,31 +716,6 @@ impl Language { ); choice.consider(input, result)?; } - if self.version_is_at_least_0_6_11 { - let result = self.parse_token_with_trivia::( - input, - TokenKind::GweiKeyword, - ); - choice.consider(input, result)?; - } - if !self.version_is_at_least_0_7_0 { - let result = ChoiceHelper::run(input, |mut choice, input| { - let result = self - .parse_token_with_trivia::( - input, - TokenKind::FinneyKeyword, - ); - choice.consider(input, result)?; - let result = self - .parse_token_with_trivia::( - input, - TokenKind::SzaboKeyword, - ); - choice.consider(input, result)?; - choice.finish(input) - }); - choice.consider(input, result)?; - } choice.finish(input) }, )))?; @@ -804,52 +762,44 @@ impl Language { TokenKind::DoKeyword, ))?; seq.elem(ChoiceHelper::run(input, |mut choice, input| { - let result = ChoiceHelper::run(input, |mut choice, input| { - let result = self.expression_statement(input); - choice.consider(input, result)?; - let result = self.variable_declaration_statement(input); - choice.consider(input, result)?; - let result = self.tuple_deconstruction_statement(input); - choice.consider(input, result)?; - choice.finish(input) - }); + let result = self.expression_statement(input); choice.consider(input, result)?; - let result = ChoiceHelper::run(input, |mut choice, input| { - let result = self.if_statement(input); - choice.consider(input, result)?; - let result = self.for_statement(input); - choice.consider(input, result)?; - let result = self.while_statement(input); - choice.consider(input, result)?; - let result = self.do_while_statement(input); - choice.consider(input, result)?; - let result = self.continue_statement(input); + let result = self.variable_declaration_statement(input); + choice.consider(input, result)?; + let result = self.tuple_deconstruction_statement(input); + choice.consider(input, result)?; + let result = self.if_statement(input); + choice.consider(input, result)?; + let result = self.for_statement(input); + choice.consider(input, result)?; + let result = self.while_statement(input); + choice.consider(input, result)?; + let result = self.do_while_statement(input); + choice.consider(input, result)?; + let result = self.continue_statement(input); + choice.consider(input, result)?; + let result = self.break_statement(input); + choice.consider(input, result)?; + let result = self.delete_statement(input); + choice.consider(input, result)?; + let result = self.return_statement(input); + choice.consider(input, result)?; + if !self.version_is_at_least_0_5_0 { + let result = self.throw_statement(input); choice.consider(input, result)?; - let result = self.break_statement(input); + } + if self.version_is_at_least_0_4_21 { + let result = self.emit_statement(input); choice.consider(input, result)?; - let result = self.delete_statement(input); + } + if self.version_is_at_least_0_6_0 { + let result = self.try_statement(input); choice.consider(input, result)?; - let result = self.return_statement(input); + } + if self.version_is_at_least_0_8_4 { + let result = self.revert_statement(input); choice.consider(input, result)?; - if self.version_is_at_least_0_4_21 { - let result = self.emit_statement(input); - choice.consider(input, result)?; - } - if !self.version_is_at_least_0_5_0 { - let result = self.throw_statement(input); - choice.consider(input, result)?; - } - if self.version_is_at_least_0_6_0 { - let result = self.try_statement(input); - choice.consider(input, result)?; - } - if self.version_is_at_least_0_8_4 { - let result = self.revert_statement(input); - choice.consider(input, result)?; - } - choice.finish(input) - }); - choice.consider(input, result)?; + } let result = self.assembly_statement(input); choice.consider(input, result)?; let result = self.block(input); @@ -904,6 +854,67 @@ impl Language { .with_kind(RuleKind::DoWhileStatement) } + #[allow(unused_assignments, unused_parens)] + fn else_branch(&self, input: &mut ParserContext) -> ParserResult { + SequenceHelper::run(|mut seq| { + seq.elem(self.parse_token_with_trivia::( + input, + TokenKind::ElseKeyword, + ))?; + seq.elem(ChoiceHelper::run(input, |mut choice, input| { + let result = self.expression_statement(input); + choice.consider(input, result)?; + let result = self.variable_declaration_statement(input); + choice.consider(input, result)?; + let result = self.tuple_deconstruction_statement(input); + choice.consider(input, result)?; + let result = self.if_statement(input); + choice.consider(input, result)?; + let result = self.for_statement(input); + choice.consider(input, result)?; + let result = self.while_statement(input); + choice.consider(input, result)?; + let result = self.do_while_statement(input); + choice.consider(input, result)?; + let result = self.continue_statement(input); + choice.consider(input, result)?; + let result = self.break_statement(input); + choice.consider(input, result)?; + let result = self.delete_statement(input); + choice.consider(input, result)?; + let result = self.return_statement(input); + choice.consider(input, result)?; + if !self.version_is_at_least_0_5_0 { + let result = self.throw_statement(input); + choice.consider(input, result)?; + } + if self.version_is_at_least_0_4_21 { + let result = self.emit_statement(input); + choice.consider(input, result)?; + } + if self.version_is_at_least_0_6_0 { + let result = self.try_statement(input); + choice.consider(input, result)?; + } + if self.version_is_at_least_0_8_4 { + let result = self.revert_statement(input); + choice.consider(input, result)?; + } + let result = self.assembly_statement(input); + choice.consider(input, result)?; + let result = self.block(input); + choice.consider(input, result)?; + if self.version_is_at_least_0_8_0 { + let result = self.unchecked_block(input); + choice.consider(input, result)?; + } + choice.finish(input) + }))?; + seq.finish() + }) + .with_kind(RuleKind::ElseBranch) + } + #[allow(unused_assignments, unused_parens)] fn emit_statement(&self, input: &mut ParserContext) -> ParserResult { if self.version_is_at_least_0_4_21 { @@ -915,7 +926,13 @@ impl Language { TokenKind::EmitKeyword, ))?; seq.elem(self.identifier_path(input))?; - seq.elem(self.arguments_declaration(input))?; + seq.elem(ChoiceHelper::run(input, |mut choice, input| { + let result = self.positional_arguments_declaration(input); + choice.consider(input, result)?; + let result = self.named_arguments_declaration(input); + choice.consider(input, result)?; + choice.finish(input) + }))?; seq.finish() }) .recover_until_with_nested_delims::<_, LexicalContextType::Default>( @@ -1216,19 +1233,19 @@ impl Language { #[allow(unused_assignments, unused_parens)] fn experimental_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::ExperimentalKeyword, ))?; seq.elem(ChoiceHelper::run(input, |mut choice, input| { - let result = self.parse_token_with_trivia::( + let result = self.parse_token_with_trivia::( input, - TokenKind::AsciiStringLiteral, + TokenKind::Identifier, ); choice.consider(input, result)?; - let result = self.parse_token_with_trivia::( + let result = self.parse_token_with_trivia::( input, - TokenKind::Identifier, + TokenKind::AsciiStringLiteral, ); choice.consider(input, result)?; choice.finish(input) @@ -1240,7 +1257,7 @@ impl Language { #[allow(unused_assignments, unused_parens)] fn expression(&self, input: &mut ParserContext) -> ParserResult { - let parse_assignment_operator = |input: &mut ParserContext| { + let parse_assignment_expression = |input: &mut ParserContext| { PrecedenceHelper::to_binary_operator( RuleKind::BinaryExpression, 1u8, @@ -1310,7 +1327,7 @@ impl Language { }), ) }; - let parse_conditional_operator = |input: &mut ParserContext| { + let parse_conditional_expression = |input: &mut ParserContext| { PrecedenceHelper::to_postfix_operator( RuleKind::ConditionalExpression, 3u8, @@ -1329,7 +1346,7 @@ impl Language { }), ) }; - let parse_or_operator = |input: &mut ParserContext| { + let parse_or_expression = |input: &mut ParserContext| { PrecedenceHelper::to_binary_operator( RuleKind::BinaryExpression, 5u8, @@ -1340,7 +1357,7 @@ impl Language { ), ) }; - let parse_and_operator = |input: &mut ParserContext| { + let parse_and_expression = |input: &mut ParserContext| { PrecedenceHelper::to_binary_operator( RuleKind::BinaryExpression, 7u8, @@ -1351,7 +1368,7 @@ impl Language { ), ) }; - let parse_equality_comparison_operator = |input: &mut ParserContext| { + let parse_equality_expression = |input: &mut ParserContext| { PrecedenceHelper::to_binary_operator( RuleKind::BinaryExpression, 9u8, @@ -1371,7 +1388,7 @@ impl Language { }), ) }; - let parse_order_comparison_operator = |input: &mut ParserContext| { + let parse_comparison_expression = |input: &mut ParserContext| { PrecedenceHelper::to_binary_operator( RuleKind::BinaryExpression, 11u8, @@ -1401,7 +1418,7 @@ impl Language { }), ) }; - let parse_bitwise_or_operator = |input: &mut ParserContext| { + let parse_bitwise_or_expression = |input: &mut ParserContext| { PrecedenceHelper::to_binary_operator( RuleKind::BinaryExpression, 13u8, @@ -1409,7 +1426,7 @@ impl Language { self.parse_token_with_trivia::(input, TokenKind::Bar), ) }; - let parse_bitwise_x_or_operator = |input: &mut ParserContext| { + let parse_bitwise_xor_expression = |input: &mut ParserContext| { PrecedenceHelper::to_binary_operator( RuleKind::BinaryExpression, 15u8, @@ -1420,7 +1437,7 @@ impl Language { ), ) }; - let parse_bitwise_and_operator = |input: &mut ParserContext| { + let parse_bitwise_and_expression = |input: &mut ParserContext| { PrecedenceHelper::to_binary_operator( RuleKind::BinaryExpression, 17u8, @@ -1431,7 +1448,7 @@ impl Language { ), ) }; - let parse_shift_operator = |input: &mut ParserContext| { + let parse_shift_expression = |input: &mut ParserContext| { PrecedenceHelper::to_binary_operator( RuleKind::BinaryExpression, 19u8, @@ -1456,7 +1473,7 @@ impl Language { }), ) }; - let parse_add_sub_operator = |input: &mut ParserContext| { + let parse_additive_expression = |input: &mut ParserContext| { PrecedenceHelper::to_binary_operator( RuleKind::BinaryExpression, 21u8, @@ -1476,7 +1493,7 @@ impl Language { }), ) }; - let parse_mul_div_mod_operator = |input: &mut ParserContext| { + let parse_multiplicative_expression = |input: &mut ParserContext| { PrecedenceHelper::to_binary_operator( RuleKind::BinaryExpression, 23u8, @@ -1501,29 +1518,55 @@ impl Language { }), ) }; - let parse_exponentiation_operator_removed_from_0_6_0 = |input: &mut ParserContext| { + let parse_exponentiation_expression_removed_from_0_6_0 = |input: &mut ParserContext| { PrecedenceHelper::to_binary_operator( RuleKind::BinaryExpression, 25u8, 25u8 + 1, - self.parse_token_with_trivia::( - input, - TokenKind::AsteriskAsterisk, - ), + 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) + }), ) }; - let parse_exponentiation_operator_introduced_from_0_6_0 = |input: &mut ParserContext| { + let parse_exponentiation_expression_introduced_from_0_6_0 = |input: &mut ParserContext| { PrecedenceHelper::to_binary_operator( RuleKind::BinaryExpression, 27u8 + 1, 27u8, - self.parse_token_with_trivia::( - input, - TokenKind::AsteriskAsterisk, - ), - ) + 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) + }), + ) }; - let parse_unary_postfix_operator = |input: &mut ParserContext| { + let parse_postfix_expression = |input: &mut ParserContext| { PrecedenceHelper::to_postfix_operator( RuleKind::UnaryPostfixExpression, 29u8, @@ -1542,64 +1585,221 @@ impl Language { }), ) }; - let parse_unary_prefix_operator = |input: &mut ParserContext| { + let parse_prefix_expression_removed_from_0_5_0 = |input: &mut ParserContext| { PrecedenceHelper::to_prefix_operator( RuleKind::UnaryPrefixExpression, 31u8, 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, - ); + let result = 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)?; + let result = self + .parse_token_with_trivia::( + input, + TokenKind::Plus, + ); + choice.consider(input, result)?; + choice.finish(input) + }); + choice.consider(input, result)?; + } + if self.version_is_at_least_0_5_0 { + let result = 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)?; + choice.finish(input) + }); + choice.consider(input, result)?; + } + choice.finish(input) + }), + ) + }; + let parse_prefix_expression_introduced_from_0_5_0 = |input: &mut ParserContext| { + PrecedenceHelper::to_prefix_operator( + RuleKind::UnaryPrefixExpression, + 33u8, + ChoiceHelper::run(input, |mut choice, input| { + if !self.version_is_at_least_0_5_0 { + let result = 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)?; + let result = self + .parse_token_with_trivia::( + input, + TokenKind::Plus, + ); + choice.consider(input, result)?; + choice.finish(input) + }); + choice.consider(input, result)?; + } + if self.version_is_at_least_0_5_0 { + let result = 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)?; + choice.finish(input) + }); choice.consider(input, result)?; } choice.finish(input) }), ) }; - let parse_function_call_operator = |input: &mut ParserContext| { + let parse_function_call_expression = |input: &mut ParserContext| { PrecedenceHelper::to_postfix_operator( RuleKind::FunctionCallExpression, - 33u8, + 35u8, SequenceHelper::run(|mut seq| { if self.version_is_at_least_0_6_2 { - seq.elem(OptionalHelper::transform(self.function_call_options(input)))?; + seq.elem(OptionalHelper::transform( + if self.version_is_at_least_0_6_2 { + ChoiceHelper::run(input, |mut choice, input| { + if self.version_is_at_least_0_6_2 + && !self.version_is_at_least_0_8_0 + { + let result = self.named_argument_groups(input); + choice.consider(input, result)?; + } + if self.version_is_at_least_0_8_0 { + let result = self.named_argument_group(input); + choice.consider(input, result)?; + } + choice.finish(input) + }) + } else { + ParserResult::disabled() + }, + ))?; } - seq.elem(self.arguments_declaration(input))?; + seq.elem(ChoiceHelper::run(input, |mut choice, input| { + let result = self.positional_arguments_declaration(input); + choice.consider(input, result)?; + let result = self.named_arguments_declaration(input); + choice.consider(input, result)?; + choice.finish(input) + }))?; seq.finish() }), ) }; - let parse_member_access_operator = |input: &mut ParserContext| { + let parse_member_access_expression = |input: &mut ParserContext| { PrecedenceHelper::to_postfix_operator( RuleKind::MemberAccessExpression, - 35u8, + 37u8, SequenceHelper::run(|mut seq| { seq.elem(self.parse_token_with_trivia::( input, @@ -1622,10 +1822,10 @@ impl Language { }), ) }; - let parse_index_access_operator = |input: &mut ParserContext| { + let parse_index_access_expression = |input: &mut ParserContext| { PrecedenceHelper::to_postfix_operator( RuleKind::IndexAccessExpression, - 37u8, + 39u8, SequenceHelper::run(|mut seq| { let mut delim_guard = input.open_delim(TokenKind::CloseBracket); let input = delim_guard.ctx(); @@ -1636,16 +1836,7 @@ impl Language { seq.elem( SequenceHelper::run(|mut seq| { seq.elem(OptionalHelper::transform(self.expression(input)))?; - seq.elem(OptionalHelper::transform(SequenceHelper::run(|mut seq| { - seq.elem( - self.parse_token_with_trivia::( - input, - TokenKind::Colon, - ), - )?; - seq.elem(OptionalHelper::transform(self.expression(input)))?; - seq.finish() - })))?; + seq.elem(OptionalHelper::transform(self.index_access_end(input)))?; seq.finish() }) .recover_until_with_nested_delims::<_, LexicalContextType::Default>( @@ -1665,8 +1856,14 @@ impl Language { }; let prefix_operator_parser = |input: &mut ParserContext| { ChoiceHelper::run(input, |mut choice, input| { - let result = parse_unary_prefix_operator(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)?; + } + if self.version_is_at_least_0_5_0 { + let result = parse_prefix_expression_introduced_from_0_5_0(input); + choice.consider(input, result)?; + } choice.finish(input) }) }; @@ -1676,29 +1873,15 @@ impl Language { choice.consider(input, result)?; let result = self.tuple_expression(input); choice.consider(input, result)?; + if self.version_is_at_least_0_5_3 { + let result = self.type_expression(input); + choice.consider(input, result)?; + } let result = self.array_expression(input); choice.consider(input, result)?; - let result = ChoiceHelper::run(input, |mut choice, input| { - let result = self.parse_token_with_trivia::( - input, - TokenKind::TrueKeyword, - ); - choice.consider(input, result)?; - let result = self.parse_token_with_trivia::( - input, - TokenKind::FalseKeyword, - ); - choice.consider(input, result)?; - choice.finish(input) - }); + let result = self.hex_number_expression(input); choice.consider(input, result)?; - let result = ChoiceHelper::run(input, |mut choice, input| { - let result = self.decimal_number_expression(input); - choice.consider(input, result)?; - let result = self.hex_number_expression(input); - choice.consider(input, result)?; - choice.finish(input) - }); + let result = self.decimal_number_expression(input); choice.consider(input, result)?; let result = ChoiceHelper::run(input, |mut choice, input| { let result = self.hex_string_literals(input); @@ -1718,6 +1901,13 @@ impl Language { TokenKind::BoolKeyword, ); choice.consider(input, result)?; + if !self.version_is_at_least_0_8_0 { + let result = self.parse_token_with_trivia::( + input, + TokenKind::ByteKeyword, + ); + choice.consider(input, result)?; + } let result = self.parse_token_with_trivia::( input, TokenKind::StringKeyword, @@ -1725,6 +1915,11 @@ impl Language { choice.consider(input, result)?; let result = self.address_type(input); choice.consider(input, result)?; + let result = self.parse_token_with_trivia::( + input, + TokenKind::PayableKeyword, + ); + choice.consider(input, result)?; let result = self.parse_token_with_trivia::( input, TokenKind::BytesKeyword, @@ -1750,39 +1945,38 @@ impl Language { TokenKind::UfixedKeyword, ); choice.consider(input, result)?; - if !self.version_is_at_least_0_8_0 { - let result = self.parse_token_with_trivia::( - input, - TokenKind::ByteKeyword, - ); - choice.consider(input, result)?; - } choice.finish(input) }); choice.consider(input, result)?; + let result = self.parse_token_with_trivia::( + input, + TokenKind::TrueKeyword, + ); + choice.consider(input, result)?; + let result = self.parse_token_with_trivia::( + input, + TokenKind::FalseKeyword, + ); + choice.consider(input, result)?; let result = self.parse_token_with_trivia::( input, TokenKind::Identifier, ); choice.consider(input, result)?; - if self.version_is_at_least_0_5_3 { - let result = self.type_expression(input); - choice.consider(input, result)?; - } choice.finish(input) }) }; let postfix_operator_parser = |input: &mut ParserContext| { ChoiceHelper::run(input, |mut choice, input| { - let result = parse_conditional_operator(input); + let result = parse_conditional_expression(input); choice.consider(input, result)?; - let result = parse_unary_postfix_operator(input); + let result = parse_postfix_expression(input); choice.consider(input, result)?; - let result = parse_function_call_operator(input); + let result = parse_function_call_expression(input); choice.consider(input, result)?; - let result = parse_member_access_operator(input); + let result = parse_member_access_expression(input); choice.consider(input, result)?; - let result = parse_index_access_operator(input); + let result = parse_index_access_expression(input); choice.consider(input, result)?; choice.finish(input) }) @@ -1801,34 +1995,34 @@ impl Language { }; let binary_operator_parser = |input: &mut ParserContext| { ChoiceHelper::run(input, |mut choice, input| { - let result = parse_assignment_operator(input); + let result = parse_assignment_expression(input); choice.consider(input, result)?; - let result = parse_or_operator(input); + let result = parse_or_expression(input); choice.consider(input, result)?; - let result = parse_and_operator(input); + let result = parse_and_expression(input); choice.consider(input, result)?; - let result = parse_equality_comparison_operator(input); + let result = parse_equality_expression(input); choice.consider(input, result)?; - let result = parse_order_comparison_operator(input); + let result = parse_comparison_expression(input); choice.consider(input, result)?; - let result = parse_bitwise_or_operator(input); + let result = parse_bitwise_or_expression(input); choice.consider(input, result)?; - let result = parse_bitwise_x_or_operator(input); + let result = parse_bitwise_xor_expression(input); choice.consider(input, result)?; - let result = parse_bitwise_and_operator(input); + let result = parse_bitwise_and_expression(input); choice.consider(input, result)?; - let result = parse_shift_operator(input); + let result = parse_shift_expression(input); choice.consider(input, result)?; - let result = parse_add_sub_operator(input); + let result = parse_additive_expression(input); choice.consider(input, result)?; - let result = parse_mul_div_mod_operator(input); + let result = parse_multiplicative_expression(input); choice.consider(input, result)?; if !self.version_is_at_least_0_6_0 { - let result = parse_exponentiation_operator_removed_from_0_6_0(input); + 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_operator_introduced_from_0_6_0(input); + let result = parse_exponentiation_expression_introduced_from_0_6_0(input); choice.consider(input, result)?; } choice.finish(input) @@ -1936,13 +2130,13 @@ impl Language { ))?; seq.elem(OptionalHelper::transform(self.returns_declaration(input)))?; seq.elem(ChoiceHelper::run(input, |mut choice, input| { - let result = self.parse_token_with_trivia::( + let result = self.block(input); + choice.consider(input, result)?; + let result = self.parse_token_with_trivia::( input, TokenKind::Semicolon, ); choice.consider(input, result)?; - let result = self.block(input); - choice.consider(input, result)?; choice.finish(input) }))?; seq.finish() @@ -1970,15 +2164,11 @@ impl Language { seq.elem( SequenceHelper::run(|mut seq| { seq.elem(ChoiceHelper::run(input, |mut choice, input| { - let result = ChoiceHelper::run(input, |mut choice, input| { - let result = self.expression_statement(input); - choice.consider(input, result)?; - let result = self.variable_declaration_statement(input); - choice.consider(input, result)?; - let result = self.tuple_deconstruction_statement(input); - choice.consider(input, result)?; - choice.finish(input) - }); + let result = self.expression_statement(input); + choice.consider(input, result)?; + let result = self.variable_declaration_statement(input); + choice.consider(input, result)?; + let result = self.tuple_deconstruction_statement(input); choice.consider(input, result)?; let result = self .parse_token_with_trivia::( @@ -2016,52 +2206,44 @@ impl Language { seq.finish() }))?; seq.elem(ChoiceHelper::run(input, |mut choice, input| { - let result = ChoiceHelper::run(input, |mut choice, input| { - let result = self.expression_statement(input); - choice.consider(input, result)?; - let result = self.variable_declaration_statement(input); - choice.consider(input, result)?; - let result = self.tuple_deconstruction_statement(input); - choice.consider(input, result)?; - choice.finish(input) - }); + let result = self.expression_statement(input); choice.consider(input, result)?; - let result = ChoiceHelper::run(input, |mut choice, input| { - let result = self.if_statement(input); - choice.consider(input, result)?; - let result = self.for_statement(input); - choice.consider(input, result)?; - let result = self.while_statement(input); - choice.consider(input, result)?; - let result = self.do_while_statement(input); - choice.consider(input, result)?; - let result = self.continue_statement(input); + let result = self.variable_declaration_statement(input); + choice.consider(input, result)?; + let result = self.tuple_deconstruction_statement(input); + choice.consider(input, result)?; + let result = self.if_statement(input); + choice.consider(input, result)?; + let result = self.for_statement(input); + choice.consider(input, result)?; + let result = self.while_statement(input); + choice.consider(input, result)?; + let result = self.do_while_statement(input); + choice.consider(input, result)?; + let result = self.continue_statement(input); + choice.consider(input, result)?; + let result = self.break_statement(input); + choice.consider(input, result)?; + let result = self.delete_statement(input); + choice.consider(input, result)?; + let result = self.return_statement(input); + choice.consider(input, result)?; + if !self.version_is_at_least_0_5_0 { + let result = self.throw_statement(input); choice.consider(input, result)?; - let result = self.break_statement(input); + } + if self.version_is_at_least_0_4_21 { + let result = self.emit_statement(input); choice.consider(input, result)?; - let result = self.delete_statement(input); + } + if self.version_is_at_least_0_6_0 { + let result = self.try_statement(input); choice.consider(input, result)?; - let result = self.return_statement(input); + } + if self.version_is_at_least_0_8_4 { + let result = self.revert_statement(input); choice.consider(input, result)?; - if self.version_is_at_least_0_4_21 { - let result = self.emit_statement(input); - choice.consider(input, result)?; - } - if !self.version_is_at_least_0_5_0 { - let result = self.throw_statement(input); - choice.consider(input, result)?; - } - if self.version_is_at_least_0_6_0 { - let result = self.try_statement(input); - choice.consider(input, result)?; - } - if self.version_is_at_least_0_8_4 { - let result = self.revert_statement(input); - choice.consider(input, result)?; - } - choice.finish(input) - }); - choice.consider(input, result)?; + } let result = self.assembly_statement(input); choice.consider(input, result)?; let result = self.block(input); @@ -2085,6 +2267,13 @@ impl Language { choice.consider(input, result)?; let result = self.override_specifier(input); choice.consider(input, result)?; + if !self.version_is_at_least_0_5_0 { + let result = self.parse_token_with_trivia::( + input, + TokenKind::ConstantKeyword, + ); + choice.consider(input, result)?; + } let result = self.parse_token_with_trivia::( input, TokenKind::ExternalKeyword, @@ -2120,13 +2309,6 @@ impl Language { TokenKind::ViewKeyword, ); choice.consider(input, result)?; - if !self.version_is_at_least_0_5_0 { - let result = self.parse_token_with_trivia::( - input, - TokenKind::ConstantKeyword, - ); - choice.consider(input, result)?; - } if self.version_is_at_least_0_6_0 { let result = self.parse_token_with_trivia::( input, @@ -2140,23 +2322,6 @@ impl Language { .with_kind(RuleKind::FunctionAttributes) } - #[allow(unused_assignments, unused_parens)] - fn function_call_options(&self, input: &mut ParserContext) -> ParserResult { - ChoiceHelper::run(input, |mut choice, input| { - if self.version_is_at_least_0_6_2 && !self.version_is_at_least_0_8_0 { - let result = - OneOrMoreHelper::run(input, |input| self.named_arguments_declaration(input)); - choice.consider(input, result)?; - } - if self.version_is_at_least_0_8_0 { - let result = self.named_arguments_declaration(input); - choice.consider(input, result)?; - } - choice.finish(input) - }) - .with_kind(RuleKind::FunctionCallOptions) - } - #[allow(unused_assignments, unused_parens)] fn function_definition(&self, input: &mut ParserContext) -> ParserResult { SequenceHelper::run(|mut seq| { @@ -2186,13 +2351,13 @@ impl Language { seq.elem(OptionalHelper::transform(self.function_attributes(input)))?; seq.elem(OptionalHelper::transform(self.returns_declaration(input)))?; seq.elem(ChoiceHelper::run(input, |mut choice, input| { + let result = self.block(input); + choice.consider(input, result)?; let result = self.parse_token_with_trivia::( input, TokenKind::Semicolon, ); choice.consider(input, result)?; - let result = self.block(input); - choice.consider(input, result)?; choice.finish(input) }))?; seq.finish() @@ -2275,9 +2440,33 @@ impl Language { |mut choice, input| { let result = self.parse_token_with_trivia::( input, - TokenKind::DaysKeyword, + TokenKind::WeiKeyword, ); choice.consider(input, result)?; + if self.version_is_at_least_0_6_11 { + let result = self + .parse_token_with_trivia::( + input, + TokenKind::GweiKeyword, + ); + choice.consider(input, result)?; + } + if !self.version_is_at_least_0_7_0 { + let result = self + .parse_token_with_trivia::( + input, + TokenKind::SzaboKeyword, + ); + choice.consider(input, result)?; + } + if !self.version_is_at_least_0_7_0 { + let result = self + .parse_token_with_trivia::( + input, + TokenKind::FinneyKeyword, + ); + choice.consider(input, result)?; + } let result = self.parse_token_with_trivia::( input, TokenKind::EtherKeyword, @@ -2285,7 +2474,7 @@ impl Language { choice.consider(input, result)?; let result = self.parse_token_with_trivia::( input, - TokenKind::HoursKeyword, + TokenKind::SecondsKeyword, ); choice.consider(input, result)?; let result = self.parse_token_with_trivia::( @@ -2295,17 +2484,17 @@ impl Language { choice.consider(input, result)?; let result = self.parse_token_with_trivia::( input, - TokenKind::SecondsKeyword, + TokenKind::HoursKeyword, ); choice.consider(input, result)?; let result = self.parse_token_with_trivia::( input, - TokenKind::WeeksKeyword, + TokenKind::DaysKeyword, ); choice.consider(input, result)?; let result = self.parse_token_with_trivia::( input, - TokenKind::WeiKeyword, + TokenKind::WeeksKeyword, ); choice.consider(input, result)?; if !self.version_is_at_least_0_5_0 { @@ -2316,32 +2505,6 @@ impl Language { ); choice.consider(input, result)?; } - if self.version_is_at_least_0_6_11 { - let result = self - .parse_token_with_trivia::( - input, - TokenKind::GweiKeyword, - ); - choice.consider(input, result)?; - } - if !self.version_is_at_least_0_7_0 { - let result = ChoiceHelper::run(input, |mut choice, input| { - let result = self - .parse_token_with_trivia::( - input, - TokenKind::FinneyKeyword, - ); - choice.consider(input, result)?; - let result = self - .parse_token_with_trivia::( - input, - TokenKind::SzaboKeyword, - ); - choice.consider(input, result)?; - choice.finish(input) - }); - choice.consider(input, result)?; - } choice.finish(input) }, )))?; @@ -2408,52 +2571,44 @@ impl Language { seq.finish() }))?; seq.elem(ChoiceHelper::run(input, |mut choice, input| { - let result = ChoiceHelper::run(input, |mut choice, input| { - let result = self.expression_statement(input); - choice.consider(input, result)?; - let result = self.variable_declaration_statement(input); - choice.consider(input, result)?; - let result = self.tuple_deconstruction_statement(input); - choice.consider(input, result)?; - choice.finish(input) - }); + let result = self.expression_statement(input); choice.consider(input, result)?; - let result = ChoiceHelper::run(input, |mut choice, input| { - let result = self.if_statement(input); - choice.consider(input, result)?; - let result = self.for_statement(input); - choice.consider(input, result)?; - let result = self.while_statement(input); - choice.consider(input, result)?; - let result = self.do_while_statement(input); - choice.consider(input, result)?; - let result = self.continue_statement(input); + let result = self.variable_declaration_statement(input); + choice.consider(input, result)?; + let result = self.tuple_deconstruction_statement(input); + choice.consider(input, result)?; + let result = self.if_statement(input); + choice.consider(input, result)?; + let result = self.for_statement(input); + choice.consider(input, result)?; + let result = self.while_statement(input); + choice.consider(input, result)?; + let result = self.do_while_statement(input); + choice.consider(input, result)?; + let result = self.continue_statement(input); + choice.consider(input, result)?; + let result = self.break_statement(input); + choice.consider(input, result)?; + let result = self.delete_statement(input); + choice.consider(input, result)?; + let result = self.return_statement(input); + choice.consider(input, result)?; + if !self.version_is_at_least_0_5_0 { + let result = self.throw_statement(input); choice.consider(input, result)?; - let result = self.break_statement(input); + } + if self.version_is_at_least_0_4_21 { + let result = self.emit_statement(input); choice.consider(input, result)?; - let result = self.delete_statement(input); + } + if self.version_is_at_least_0_6_0 { + let result = self.try_statement(input); choice.consider(input, result)?; - let result = self.return_statement(input); + } + if self.version_is_at_least_0_8_4 { + let result = self.revert_statement(input); choice.consider(input, result)?; - if self.version_is_at_least_0_4_21 { - let result = self.emit_statement(input); - choice.consider(input, result)?; - } - if !self.version_is_at_least_0_5_0 { - let result = self.throw_statement(input); - choice.consider(input, result)?; - } - if self.version_is_at_least_0_6_0 { - let result = self.try_statement(input); - choice.consider(input, result)?; - } - if self.version_is_at_least_0_8_4 { - let result = self.revert_statement(input); - choice.consider(input, result)?; - } - choice.finish(input) - }); - choice.consider(input, result)?; + } let result = self.assembly_statement(input); choice.consider(input, result)?; let result = self.block(input); @@ -2464,75 +2619,28 @@ impl Language { } choice.finish(input) }))?; - seq.elem(OptionalHelper::transform(SequenceHelper::run(|mut seq| { - seq.elem(self.parse_token_with_trivia::( - input, - TokenKind::ElseKeyword, - ))?; - seq.elem(ChoiceHelper::run(input, |mut choice, input| { - let result = ChoiceHelper::run(input, |mut choice, input| { - let result = self.expression_statement(input); - choice.consider(input, result)?; - let result = self.variable_declaration_statement(input); - choice.consider(input, result)?; - let result = self.tuple_deconstruction_statement(input); - choice.consider(input, result)?; - choice.finish(input) - }); - choice.consider(input, result)?; - let result = ChoiceHelper::run(input, |mut choice, input| { - let result = self.if_statement(input); - choice.consider(input, result)?; - let result = self.for_statement(input); - choice.consider(input, result)?; - let result = self.while_statement(input); - choice.consider(input, result)?; - let result = self.do_while_statement(input); - choice.consider(input, result)?; - let result = self.continue_statement(input); - choice.consider(input, result)?; - let result = self.break_statement(input); - choice.consider(input, result)?; - let result = self.delete_statement(input); - choice.consider(input, result)?; - let result = self.return_statement(input); - choice.consider(input, result)?; - if self.version_is_at_least_0_4_21 { - let result = self.emit_statement(input); - choice.consider(input, result)?; - } - if !self.version_is_at_least_0_5_0 { - let result = self.throw_statement(input); - choice.consider(input, result)?; - } - if self.version_is_at_least_0_6_0 { - let result = self.try_statement(input); - choice.consider(input, result)?; - } - if self.version_is_at_least_0_8_4 { - let result = self.revert_statement(input); - choice.consider(input, result)?; - } - choice.finish(input) - }); - choice.consider(input, result)?; - let result = self.assembly_statement(input); - choice.consider(input, result)?; - let result = self.block(input); - choice.consider(input, result)?; - if self.version_is_at_least_0_8_0 { - let result = self.unchecked_block(input); - choice.consider(input, result)?; - } - choice.finish(input) - }))?; - seq.finish() - })))?; + seq.elem(OptionalHelper::transform(self.else_branch(input)))?; seq.finish() }) .with_kind(RuleKind::IfStatement) } + #[allow(unused_assignments, unused_parens)] + fn import_alias(&self, input: &mut ParserContext) -> ParserResult { + SequenceHelper::run(|mut seq| { + seq.elem(self.parse_token_with_trivia::( + input, + TokenKind::AsKeyword, + ))?; + seq.elem(self.parse_token_with_trivia::( + input, + TokenKind::Identifier, + ))?; + seq.finish() + }) + .with_kind(RuleKind::ImportAlias) + } + #[allow(unused_assignments, unused_parens)] fn import_deconstruction(&self, input: &mut ParserContext) -> ParserResult { SequenceHelper::run(|mut seq| { @@ -2578,17 +2686,7 @@ impl Language { input, TokenKind::Identifier, ))?; - seq.elem(OptionalHelper::transform(SequenceHelper::run(|mut seq| { - seq.elem(self.parse_token_with_trivia::( - input, - TokenKind::AsKeyword, - ))?; - seq.elem(self.parse_token_with_trivia::( - input, - TokenKind::Identifier, - ))?; - seq.finish() - })))?; + seq.elem(OptionalHelper::transform(self.import_alias(input)))?; seq.finish() }) .with_kind(RuleKind::ImportDeconstructionSymbol) @@ -2642,7 +2740,22 @@ impl Language { } #[allow(unused_assignments, unused_parens)] - fn inheritance_specifier(&self, input: &mut ParserContext) -> ParserResult { + fn index_access_end(&self, input: &mut ParserContext) -> ParserResult { + SequenceHelper::run(|mut seq| { + seq.elem( + self.parse_token_with_trivia::( + input, + TokenKind::Colon, + ), + )?; + seq.elem(OptionalHelper::transform(self.expression(input)))?; + seq.finish() + }) + .with_kind(RuleKind::IndexAccessEnd) + } + + #[allow(unused_assignments, unused_parens)] + fn inheritance_specifier(&self, input: &mut ParserContext) -> ParserResult { SequenceHelper::run(|mut seq| { seq.elem(self.parse_token_with_trivia::( input, @@ -2658,7 +2771,16 @@ impl Language { fn inheritance_type(&self, input: &mut ParserContext) -> ParserResult { SequenceHelper::run(|mut seq| { seq.elem(self.identifier_path(input))?; - seq.elem(OptionalHelper::transform(self.arguments_declaration(input)))?; + seq.elem(OptionalHelper::transform(ChoiceHelper::run( + input, + |mut choice, input| { + let result = self.positional_arguments_declaration(input); + choice.consider(input, result)?; + let result = self.named_arguments_declaration(input); + choice.consider(input, result)?; + choice.finish(input) + }, + )))?; seq.finish() }) .with_kind(RuleKind::InheritanceType) @@ -2722,34 +2844,32 @@ impl Language { choice.consider(input, result)?; let result = self.function_definition(input); choice.consider(input, result)?; - let result = self.modifier_definition(input); - choice.consider(input, result)?; - let result = self.struct_definition(input); - choice.consider(input, result)?; - let result = self.enum_definition(input); - choice.consider(input, result)?; - let result = self.event_definition(input); - choice.consider(input, result)?; - let result = self.state_variable_definition(input); - choice.consider(input, result)?; if self.version_is_at_least_0_4_22 { let result = self.constructor_definition(input); choice.consider(input, result)?; } if self.version_is_at_least_0_6_0 { - let result = ChoiceHelper::run(input, |mut choice, input| { - let result = self.fallback_function_definition(input); - choice.consider(input, result)?; - let result = self.receive_function_definition(input); - choice.consider(input, result)?; - choice.finish(input) - }); + let result = self.receive_function_definition(input); + choice.consider(input, result)?; + } + if self.version_is_at_least_0_6_0 { + let result = self.fallback_function_definition(input); choice.consider(input, result)?; } if !self.version_is_at_least_0_6_0 { let result = self.unnamed_function_definition(input); choice.consider(input, result)?; } + let result = self.modifier_definition(input); + choice.consider(input, result)?; + let result = self.struct_definition(input); + choice.consider(input, result)?; + let result = self.enum_definition(input); + choice.consider(input, result)?; + let result = self.event_definition(input); + choice.consider(input, result)?; + let result = self.state_variable_definition(input); + choice.consider(input, result)?; if self.version_is_at_least_0_8_4 { let result = self.error_definition(input); choice.consider(input, result)?; @@ -2834,34 +2954,32 @@ impl Language { choice.consider(input, result)?; let result = self.function_definition(input); choice.consider(input, result)?; - let result = self.modifier_definition(input); - choice.consider(input, result)?; - let result = self.struct_definition(input); - choice.consider(input, result)?; - let result = self.enum_definition(input); - choice.consider(input, result)?; - let result = self.event_definition(input); - choice.consider(input, result)?; - let result = self.state_variable_definition(input); - choice.consider(input, result)?; if self.version_is_at_least_0_4_22 { let result = self.constructor_definition(input); choice.consider(input, result)?; } if self.version_is_at_least_0_6_0 { - let result = ChoiceHelper::run(input, |mut choice, input| { - let result = self.fallback_function_definition(input); - choice.consider(input, result)?; - let result = self.receive_function_definition(input); - choice.consider(input, result)?; - choice.finish(input) - }); + let result = self.receive_function_definition(input); + choice.consider(input, result)?; + } + if self.version_is_at_least_0_6_0 { + let result = self.fallback_function_definition(input); choice.consider(input, result)?; } if !self.version_is_at_least_0_6_0 { let result = self.unnamed_function_definition(input); choice.consider(input, result)?; } + let result = self.modifier_definition(input); + choice.consider(input, result)?; + let result = self.struct_definition(input); + choice.consider(input, result)?; + let result = self.enum_definition(input); + choice.consider(input, result)?; + let result = self.event_definition(input); + choice.consider(input, result)?; + let result = self.state_variable_definition(input); + choice.consider(input, result)?; if self.version_is_at_least_0_8_4 { let result = self.error_definition(input); choice.consider(input, result)?; @@ -2877,7 +2995,7 @@ impl Language { } #[allow(unused_assignments, unused_parens)] - fn mapping_key_type(&self, input: &mut ParserContext) -> ParserResult { + fn mapping_key(&self, input: &mut ParserContext) -> ParserResult { SequenceHelper::run(|mut seq| { seq.elem(ChoiceHelper::run(input, |mut choice, input| { let result = ChoiceHelper::run(input, |mut choice, input| { @@ -2886,6 +3004,13 @@ impl Language { TokenKind::BoolKeyword, ); choice.consider(input, result)?; + if !self.version_is_at_least_0_8_0 { + let result = self.parse_token_with_trivia::( + input, + TokenKind::ByteKeyword, + ); + choice.consider(input, result)?; + } let result = self.parse_token_with_trivia::( input, TokenKind::StringKeyword, @@ -2893,6 +3018,11 @@ impl Language { choice.consider(input, result)?; let result = self.address_type(input); choice.consider(input, result)?; + let result = self.parse_token_with_trivia::( + input, + TokenKind::PayableKeyword, + ); + choice.consider(input, result)?; let result = self.parse_token_with_trivia::( input, TokenKind::BytesKeyword, @@ -2918,13 +3048,6 @@ impl Language { TokenKind::UfixedKeyword, ); choice.consider(input, result)?; - if !self.version_is_at_least_0_8_0 { - let result = self.parse_token_with_trivia::( - input, - TokenKind::ByteKeyword, - ); - choice.consider(input, result)?; - } choice.finish(input) }); choice.consider(input, result)?; @@ -2942,7 +3065,7 @@ impl Language { } seq.finish() }) - .with_kind(RuleKind::MappingKeyType) + .with_kind(RuleKind::MappingKey) } #[allow(unused_assignments, unused_parens)] @@ -2961,12 +3084,12 @@ impl Language { ))?; seq.elem( SequenceHelper::run(|mut seq| { - seq.elem(self.mapping_key_type(input))?; + seq.elem(self.mapping_key(input))?; seq.elem(self.parse_token_with_trivia::( input, TokenKind::EqualGreaterThan, ))?; - seq.elem(self.mapping_value_type(input))?; + seq.elem(self.mapping_value(input))?; seq.finish() }) .recover_until_with_nested_delims::<_, LexicalContextType::Default>( @@ -2988,7 +3111,7 @@ impl Language { } #[allow(unused_assignments, unused_parens)] - fn mapping_value_type(&self, input: &mut ParserContext) -> ParserResult { + fn mapping_value(&self, input: &mut ParserContext) -> ParserResult { SequenceHelper::run(|mut seq| { seq.elem(self.type_name(input))?; if self.version_is_at_least_0_8_18 { @@ -3001,7 +3124,7 @@ impl Language { } seq.finish() }) - .with_kind(RuleKind::MappingValueType) + .with_kind(RuleKind::MappingValue) } #[allow(unused_assignments, unused_parens)] @@ -3039,13 +3162,13 @@ impl Language { ))?; seq.elem(OptionalHelper::transform(self.modifier_attributes(input)))?; seq.elem(ChoiceHelper::run(input, |mut choice, input| { + let result = self.block(input); + choice.consider(input, result)?; let result = self.parse_token_with_trivia::( input, TokenKind::Semicolon, ); choice.consider(input, result)?; - let result = self.block(input); - choice.consider(input, result)?; choice.finish(input) }))?; seq.finish() @@ -3057,7 +3180,16 @@ impl Language { fn modifier_invocation(&self, input: &mut ParserContext) -> ParserResult { SequenceHelper::run(|mut seq| { seq.elem(self.identifier_path(input))?; - seq.elem(OptionalHelper::transform(self.arguments_declaration(input)))?; + seq.elem(OptionalHelper::transform(ChoiceHelper::run( + input, + |mut choice, input| { + let result = self.positional_arguments_declaration(input); + choice.consider(input, result)?; + let result = self.named_arguments_declaration(input); + choice.consider(input, result)?; + choice.finish(input) + }, + )))?; seq.finish() }) .with_kind(RuleKind::ModifierInvocation) @@ -3083,18 +3215,7 @@ impl Language { } #[allow(unused_assignments, unused_parens)] - fn named_arguments(&self, input: &mut ParserContext) -> ParserResult { - SeparatedHelper::run::<_, LexicalContextType::Default>( - input, - self, - |input| self.named_argument(input), - TokenKind::Comma, - ) - .with_kind(RuleKind::NamedArguments) - } - - #[allow(unused_assignments, unused_parens)] - fn named_arguments_declaration(&self, input: &mut ParserContext) -> ParserResult { + fn named_argument_group(&self, input: &mut ParserContext) -> ParserResult { SequenceHelper::run(|mut seq| { let mut delim_guard = input.open_delim(TokenKind::CloseBrace); let input = delim_guard.ctx(); @@ -3117,24 +3238,65 @@ impl Language { ))?; seq.finish() }) - .with_kind(RuleKind::NamedArgumentsDeclaration) + .with_kind(RuleKind::NamedArgumentGroup) } #[allow(unused_assignments, unused_parens)] - fn named_import(&self, input: &mut ParserContext) -> ParserResult { + fn named_argument_groups(&self, input: &mut ParserContext) -> ParserResult { + if self.version_is_at_least_0_6_2 && !self.version_is_at_least_0_8_0 { + OneOrMoreHelper::run(input, |input| self.named_argument_group(input)) + } else { + ParserResult::disabled() + } + .with_kind(RuleKind::NamedArgumentGroups) + } + + #[allow(unused_assignments, unused_parens)] + fn named_arguments(&self, input: &mut ParserContext) -> ParserResult { + SeparatedHelper::run::<_, LexicalContextType::Default>( + input, + self, + |input| self.named_argument(input), + TokenKind::Comma, + ) + .with_kind(RuleKind::NamedArguments) + } + + #[allow(unused_assignments, unused_parens)] + fn named_arguments_declaration(&self, input: &mut ParserContext) -> ParserResult { SequenceHelper::run(|mut seq| { + let mut delim_guard = input.open_delim(TokenKind::CloseParen); + let input = delim_guard.ctx(); seq.elem(self.parse_token_with_trivia::( input, - TokenKind::Asterisk, + TokenKind::OpenParen, ))?; + seq.elem( + OptionalHelper::transform(self.named_argument_group(input)) + .recover_until_with_nested_delims::<_, LexicalContextType::Default>( + input, + self, + TokenKind::CloseParen, + RecoverFromNoMatch::Yes, + ), + )?; seq.elem(self.parse_token_with_trivia::( input, - TokenKind::AsKeyword, + TokenKind::CloseParen, ))?; + seq.finish() + }) + .with_kind(RuleKind::NamedArgumentsDeclaration) + } + + #[allow(unused_assignments, unused_parens)] + fn named_import(&self, input: &mut ParserContext) -> ParserResult { + SequenceHelper::run(|mut seq| { seq.elem(self.parse_token_with_trivia::( input, - TokenKind::Identifier, + TokenKind::Asterisk, ))?; + seq.elem(self.import_alias(input))?; seq.elem(self.parse_token_with_trivia::( input, TokenKind::FromKeyword, @@ -3173,34 +3335,42 @@ impl Language { } #[allow(unused_assignments, unused_parens)] - fn override_specifier(&self, input: &mut ParserContext) -> ParserResult { + fn override_paths_declaration(&self, input: &mut ParserContext) -> ParserResult { SequenceHelper::run(|mut seq| { + let mut delim_guard = input.open_delim(TokenKind::CloseParen); + let input = delim_guard.ctx(); seq.elem(self.parse_token_with_trivia::( input, - TokenKind::OverrideKeyword, + TokenKind::OpenParen, ))?; - seq.elem(OptionalHelper::transform(SequenceHelper::run(|mut seq| { - let mut delim_guard = input.open_delim(TokenKind::CloseParen); - let input = delim_guard.ctx(); - seq.elem(self.parse_token_with_trivia::( - input, - TokenKind::OpenParen, - ))?; - seq.elem( - OptionalHelper::transform(self.override_paths(input)) - .recover_until_with_nested_delims::<_, LexicalContextType::Default>( + seq.elem( + self.override_paths(input) + .recover_until_with_nested_delims::<_, LexicalContextType::Default>( input, self, TokenKind::CloseParen, RecoverFromNoMatch::Yes, ), - )?; - seq.elem(self.parse_token_with_trivia::( - input, - TokenKind::CloseParen, - ))?; - seq.finish() - })))?; + )?; + seq.elem(self.parse_token_with_trivia::( + input, + TokenKind::CloseParen, + ))?; + seq.finish() + }) + .with_kind(RuleKind::OverridePathsDeclaration) + } + + #[allow(unused_assignments, unused_parens)] + fn override_specifier(&self, input: &mut ParserContext) -> ParserResult { + SequenceHelper::run(|mut seq| { + seq.elem(self.parse_token_with_trivia::( + input, + TokenKind::OverrideKeyword, + ))?; + seq.elem(OptionalHelper::transform( + self.override_paths_declaration(input), + ))?; seq.finish() }) .with_kind(RuleKind::OverrideSpecifier) @@ -3226,7 +3396,7 @@ impl Language { if self.version_is_at_least_0_5_0 { let result = self.parse_token_with_trivia::( input, - TokenKind::CalldataKeyword, + TokenKind::CallDataKeyword, ); choice.consider(input, result)?; } @@ -3289,17 +3459,7 @@ impl Language { input, TokenKind::AsciiStringLiteral, ))?; - seq.elem(OptionalHelper::transform(SequenceHelper::run(|mut seq| { - seq.elem(self.parse_token_with_trivia::( - input, - TokenKind::AsKeyword, - ))?; - seq.elem(self.parse_token_with_trivia::( - input, - TokenKind::Identifier, - ))?; - seq.finish() - })))?; + seq.elem(OptionalHelper::transform(self.import_alias(input)))?; seq.finish() }) .with_kind(RuleKind::PathImport) @@ -3316,12 +3476,39 @@ impl Language { .with_kind(RuleKind::PositionalArguments) } + #[allow(unused_assignments, unused_parens)] + fn positional_arguments_declaration(&self, input: &mut ParserContext) -> ParserResult { + SequenceHelper::run(|mut seq| { + let mut delim_guard = input.open_delim(TokenKind::CloseParen); + let input = delim_guard.ctx(); + seq.elem(self.parse_token_with_trivia::( + input, + TokenKind::OpenParen, + ))?; + seq.elem( + OptionalHelper::transform(self.positional_arguments(input)) + .recover_until_with_nested_delims::<_, LexicalContextType::Default>( + input, + self, + TokenKind::CloseParen, + RecoverFromNoMatch::Yes, + ), + )?; + seq.elem(self.parse_token_with_trivia::( + input, + TokenKind::CloseParen, + ))?; + seq.finish() + }) + .with_kind(RuleKind::PositionalArgumentsDeclaration) + } + #[allow(unused_assignments, unused_parens)] fn pragma_directive(&self, input: &mut ParserContext) -> ParserResult { SequenceHelper::run(|mut seq| { seq.elem( SequenceHelper::run(|mut seq| { - seq.elem(self.parse_token_with_trivia::( + seq.elem(self.parse_token_with_trivia::( input, TokenKind::PragmaKeyword, ))?; @@ -3336,14 +3523,14 @@ impl Language { }))?; seq.finish() }) - .recover_until_with_nested_delims::<_, LexicalContextType::Default>( + .recover_until_with_nested_delims::<_, LexicalContextType::Pragma>( input, self, TokenKind::Semicolon, RecoverFromNoMatch::No, ), )?; - seq.elem(self.parse_token_with_trivia::( + seq.elem(self.parse_token_with_trivia::( input, TokenKind::Semicolon, ))?; @@ -3402,13 +3589,13 @@ impl Language { self.receive_function_attributes(input), ))?; seq.elem(ChoiceHelper::run(input, |mut choice, input| { + let result = self.block(input); + choice.consider(input, result)?; let result = self.parse_token_with_trivia::( input, TokenKind::Semicolon, ); choice.consider(input, result)?; - let result = self.block(input); - choice.consider(input, result)?; choice.finish(input) }))?; seq.finish() @@ -3462,30 +3649,40 @@ impl Language { #[allow(unused_assignments, unused_parens)] fn revert_statement(&self, input: &mut ParserContext) -> ParserResult { - SequenceHelper::run(|mut seq| { - seq.elem( - SequenceHelper::run(|mut seq| { - seq.elem(self.parse_token_with_trivia::( - input, - TokenKind::RevertKeyword, - ))?; - seq.elem(OptionalHelper::transform(self.identifier_path(input)))?; - seq.elem(self.arguments_declaration(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() - }) + if self.version_is_at_least_0_8_4 { + SequenceHelper::run(|mut seq| { + seq.elem( + SequenceHelper::run(|mut seq| { + seq.elem(self.parse_token_with_trivia::( + input, + TokenKind::RevertKeyword, + ))?; + seq.elem(OptionalHelper::transform(self.identifier_path(input)))?; + seq.elem(ChoiceHelper::run(input, |mut choice, input| { + let result = self.positional_arguments_declaration(input); + choice.consider(input, result)?; + let result = self.named_arguments_declaration(input); + choice.consider(input, result)?; + choice.finish(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() + }) + } else { + ParserResult::disabled() + } .with_kind(RuleKind::RevertStatement) } @@ -3514,13 +3711,11 @@ impl Language { let result = self.library_definition(input); choice.consider(input, result)?; if self.version_is_at_least_0_6_0 { - let result = ChoiceHelper::run(input, |mut choice, input| { - let result = self.struct_definition(input); - choice.consider(input, result)?; - let result = self.enum_definition(input); - choice.consider(input, result)?; - choice.finish(input) - }); + let result = self.struct_definition(input); + choice.consider(input, result)?; + } + if self.version_is_at_least_0_6_0 { + let result = self.enum_definition(input); choice.consider(input, result)?; } if self.version_is_at_least_0_7_1 { @@ -3605,14 +3800,9 @@ impl Language { input, TokenKind::Identifier, ))?; - seq.elem(OptionalHelper::transform(SequenceHelper::run(|mut seq| { - seq.elem(self.parse_token_with_trivia::( - input, - TokenKind::Equal, - ))?; - seq.elem(self.expression(input))?; - seq.finish() - })))?; + seq.elem(OptionalHelper::transform( + self.state_variable_definition_value(input), + ))?; seq.finish() }) .recover_until_with_nested_delims::<_, LexicalContextType::Default>( @@ -3631,56 +3821,63 @@ impl Language { .with_kind(RuleKind::StateVariableDefinition) } + #[allow(unused_assignments, unused_parens)] + fn state_variable_definition_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::StateVariableDefinitionValue) + } + #[allow(unused_assignments, unused_parens)] fn statements(&self, input: &mut ParserContext) -> ParserResult { OneOrMoreHelper::run(input, |input| { ChoiceHelper::run(input, |mut choice, input| { - let result = ChoiceHelper::run(input, |mut choice, input| { - let result = self.expression_statement(input); - choice.consider(input, result)?; - let result = self.variable_declaration_statement(input); - choice.consider(input, result)?; - let result = self.tuple_deconstruction_statement(input); - choice.consider(input, result)?; - choice.finish(input) - }); + let result = self.expression_statement(input); choice.consider(input, result)?; - let result = ChoiceHelper::run(input, |mut choice, input| { - let result = self.if_statement(input); - choice.consider(input, result)?; - let result = self.for_statement(input); - choice.consider(input, result)?; - let result = self.while_statement(input); - choice.consider(input, result)?; - let result = self.do_while_statement(input); - choice.consider(input, result)?; - let result = self.continue_statement(input); + let result = self.variable_declaration_statement(input); + choice.consider(input, result)?; + let result = self.tuple_deconstruction_statement(input); + choice.consider(input, result)?; + let result = self.if_statement(input); + choice.consider(input, result)?; + let result = self.for_statement(input); + choice.consider(input, result)?; + let result = self.while_statement(input); + choice.consider(input, result)?; + let result = self.do_while_statement(input); + choice.consider(input, result)?; + let result = self.continue_statement(input); + choice.consider(input, result)?; + let result = self.break_statement(input); + choice.consider(input, result)?; + let result = self.delete_statement(input); + choice.consider(input, result)?; + let result = self.return_statement(input); + choice.consider(input, result)?; + if !self.version_is_at_least_0_5_0 { + let result = self.throw_statement(input); choice.consider(input, result)?; - let result = self.break_statement(input); + } + if self.version_is_at_least_0_4_21 { + let result = self.emit_statement(input); choice.consider(input, result)?; - let result = self.delete_statement(input); + } + if self.version_is_at_least_0_6_0 { + let result = self.try_statement(input); choice.consider(input, result)?; - let result = self.return_statement(input); + } + if self.version_is_at_least_0_8_4 { + let result = self.revert_statement(input); choice.consider(input, result)?; - if self.version_is_at_least_0_4_21 { - let result = self.emit_statement(input); - choice.consider(input, result)?; - } - if !self.version_is_at_least_0_5_0 { - let result = self.throw_statement(input); - choice.consider(input, result)?; - } - if self.version_is_at_least_0_6_0 { - let result = self.try_statement(input); - choice.consider(input, result)?; - } - if self.version_is_at_least_0_8_4 { - let result = self.revert_statement(input); - choice.consider(input, result)?; - } - choice.finish(input) - }); - choice.consider(input, result)?; + } let result = self.assembly_statement(input); choice.consider(input, result)?; let result = self.block(input); @@ -3933,12 +4130,17 @@ impl Language { .with_kind(RuleKind::TupleExpression) } + #[allow(unused_assignments, unused_parens)] + fn tuple_value(&self, input: &mut ParserContext) -> ParserResult { + OptionalHelper::transform(self.expression(input)).with_kind(RuleKind::TupleValue) + } + #[allow(unused_assignments, unused_parens)] fn tuple_values(&self, input: &mut ParserContext) -> ParserResult { SeparatedHelper::run::<_, LexicalContextType::Default>( input, self, - |input| OptionalHelper::transform(self.expression(input)), + |input| self.tuple_value(input), TokenKind::Comma, ) .with_kind(RuleKind::TupleValues) @@ -3984,7 +4186,7 @@ impl Language { #[allow(unused_assignments, unused_parens)] fn type_name(&self, input: &mut ParserContext) -> ParserResult { - let parse_array_type_name_operator = |input: &mut ParserContext| { + let parse_array_type_name = |input: &mut ParserContext| { PrecedenceHelper::to_postfix_operator( RuleKind::ArrayTypeName, 1u8, @@ -4024,6 +4226,13 @@ impl Language { TokenKind::BoolKeyword, ); choice.consider(input, result)?; + if !self.version_is_at_least_0_8_0 { + let result = self.parse_token_with_trivia::( + input, + TokenKind::ByteKeyword, + ); + choice.consider(input, result)?; + } let result = self.parse_token_with_trivia::( input, TokenKind::StringKeyword, @@ -4031,6 +4240,11 @@ impl Language { choice.consider(input, result)?; let result = self.address_type(input); choice.consider(input, result)?; + let result = self.parse_token_with_trivia::( + input, + TokenKind::PayableKeyword, + ); + choice.consider(input, result)?; let result = self.parse_token_with_trivia::( input, TokenKind::BytesKeyword, @@ -4056,13 +4270,6 @@ impl Language { TokenKind::UfixedKeyword, ); choice.consider(input, result)?; - if !self.version_is_at_least_0_8_0 { - let result = self.parse_token_with_trivia::( - input, - TokenKind::ByteKeyword, - ); - choice.consider(input, result)?; - } choice.finish(input) }); choice.consider(input, result)?; @@ -4073,7 +4280,7 @@ impl Language { }; let postfix_operator_parser = |input: &mut ParserContext| { ChoiceHelper::run(input, |mut choice, input| { - let result = parse_array_type_name_operator(input); + let result = parse_array_type_name(input); choice.consider(input, result)?; choice.finish(input) }) @@ -4114,7 +4321,7 @@ impl Language { if self.version_is_at_least_0_5_0 { let result = self.parse_token_with_trivia::( input, - TokenKind::CalldataKeyword, + TokenKind::CallDataKeyword, ); choice.consider(input, result)?; } @@ -4217,13 +4424,13 @@ impl Language { self.unnamed_function_attributes(input), ))?; seq.elem(ChoiceHelper::run(input, |mut choice, input| { + let result = self.block(input); + choice.consider(input, result)?; let result = self.parse_token_with_trivia::( input, TokenKind::Semicolon, ); choice.consider(input, result)?; - let result = self.block(input); - choice.consider(input, result)?; choice.finish(input) }))?; seq.finish() @@ -4253,7 +4460,7 @@ impl Language { if self.version_is_at_least_0_5_0 { let result = self.parse_token_with_trivia::( input, - TokenKind::CalldataKeyword, + TokenKind::CallDataKeyword, ); choice.consider(input, result)?; } @@ -4294,6 +4501,14 @@ impl Language { TokenKind::BoolKeyword, ); choice.consider(input, result)?; + if !self.version_is_at_least_0_8_0 { + let result = self + .parse_token_with_trivia::( + input, + TokenKind::ByteKeyword, + ); + choice.consider(input, result)?; + } let result = self .parse_token_with_trivia::( input, @@ -4302,6 +4517,12 @@ impl Language { choice.consider(input, result)?; let result = self.address_type(input); choice.consider(input, result)?; + let result = self + .parse_token_with_trivia::( + input, + TokenKind::PayableKeyword, + ); + choice.consider(input, result)?; let result = self .parse_token_with_trivia::( input, @@ -4332,14 +4553,6 @@ impl Language { TokenKind::UfixedKeyword, ); choice.consider(input, result)?; - if !self.version_is_at_least_0_8_0 { - let result = self - .parse_token_with_trivia::( - input, - TokenKind::ByteKeyword, - ); - choice.consider(input, result)?; - } choice.finish(input) }))?; seq.finish() @@ -4363,6 +4576,100 @@ impl Language { .with_kind(RuleKind::UserDefinedValueTypeDefinition) } + #[allow(unused_assignments, unused_parens)] + fn using_alias(&self, input: &mut ParserContext) -> ParserResult { + if self.version_is_at_least_0_8_19 { + SequenceHelper::run(|mut seq| { + seq.elem(self.parse_token_with_trivia::( + input, + TokenKind::AsKeyword, + ))?; + seq.elem(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) + }))?; + seq.finish() + }) + } else { + ParserResult::disabled() + } + .with_kind(RuleKind::UsingAlias) + } + #[allow(unused_assignments, unused_parens)] fn using_deconstruction(&self, input: &mut ParserContext) -> ParserResult { if self.version_is_at_least_0_8_13 { @@ -4400,110 +4707,7 @@ impl Language { SequenceHelper::run(|mut seq| { seq.elem(self.identifier_path(input))?; if self.version_is_at_least_0_8_19 { - seq.elem(OptionalHelper::transform(SequenceHelper::run(|mut seq| { - seq.elem(self.parse_token_with_trivia::( - input, - TokenKind::AsKeyword, - ))?; - seq.elem(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() - })?; - seq.finish() - })))?; + seq.elem(OptionalHelper::transform(self.using_alias(input)))?; } seq.finish() }) @@ -4551,13 +4755,13 @@ impl Language { TokenKind::ForKeyword, ))?; seq.elem(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)?; - let result = self.type_name(input); - choice.consider(input, result)?; choice.finish(input) }))?; if self.version_is_at_least_0_8_13 { @@ -4586,67 +4790,57 @@ impl Language { .with_kind(RuleKind::UsingDirective) } - #[allow(unused_assignments, unused_parens)] - fn variable_declaration(&self, input: &mut ParserContext) -> ParserResult { - SequenceHelper::run(|mut seq| { - seq.elem(ChoiceHelper::run(input, |mut choice, input| { - if !self.version_is_at_least_0_5_0 { - let result = self.parse_token_with_trivia::( - input, - TokenKind::VarKeyword, - ); - choice.consider(input, result)?; - } - let result = self.type_name(input); - choice.consider(input, result)?; - choice.finish(input) - }))?; - seq.elem(OptionalHelper::transform(ChoiceHelper::run( - input, - |mut choice, input| { - let result = self.parse_token_with_trivia::( - input, - TokenKind::MemoryKeyword, - ); - choice.consider(input, result)?; - let result = self.parse_token_with_trivia::( - input, - TokenKind::StorageKeyword, - ); - choice.consider(input, result)?; - if self.version_is_at_least_0_5_0 { - let result = self.parse_token_with_trivia::( - input, - TokenKind::CalldataKeyword, - ); - choice.consider(input, result)?; - } - choice.finish(input) - }, - )))?; - seq.elem(self.parse_token_with_trivia::( - input, - TokenKind::Identifier, - ))?; - seq.finish() - }) - .with_kind(RuleKind::VariableDeclaration) - } - #[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(input))?; - seq.elem(OptionalHelper::transform(SequenceHelper::run(|mut seq| { - seq.elem(self.parse_token_with_trivia::( - input, - TokenKind::Equal, - ))?; - seq.elem(self.expression(input))?; - seq.finish() - })))?; + seq.elem(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) + }))?; + seq.elem(OptionalHelper::transform(ChoiceHelper::run( + input, + |mut choice, input| { + let result = self + .parse_token_with_trivia::( + input, + TokenKind::MemoryKeyword, + ); + choice.consider(input, result)?; + let result = self + .parse_token_with_trivia::( + input, + TokenKind::StorageKeyword, + ); + choice.consider(input, result)?; + if self.version_is_at_least_0_5_0 { + let result = self + .parse_token_with_trivia::( + input, + TokenKind::CallDataKeyword, + ); + choice.consider(input, result)?; + } + choice.finish(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>( @@ -4666,14 +4860,27 @@ impl Language { } #[allow(unused_assignments, unused_parens)] - fn version_pragma(&self, input: &mut ParserContext) -> ParserResult { + fn variable_declaration_value(&self, input: &mut ParserContext) -> ParserResult { SequenceHelper::run(|mut seq| { seq.elem( - self.parse_token_with_trivia::( + self.parse_token_with_trivia::( input, - TokenKind::SolidityKeyword, + 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() }) @@ -4682,64 +4889,61 @@ impl Language { #[allow(unused_assignments, unused_parens)] fn version_pragma_expression(&self, input: &mut ParserContext) -> ParserResult { - let parse_version_pragma_or_operator = |input: &mut ParserContext| { + let parse_version_pragma_or_expression = |input: &mut ParserContext| { PrecedenceHelper::to_binary_operator( RuleKind::VersionPragmaBinaryExpression, 1u8, 1u8 + 1, - self.parse_token_with_trivia::( + self.parse_token_with_trivia::( input, TokenKind::BarBar, ), ) }; - let parse_version_pragma_range_operator = |input: &mut ParserContext| { + 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, - ), + self.parse_token_with_trivia::(input, TokenKind::Minus), ) }; - let parse_version_pragma_unary_operator = |input: &mut ParserContext| { + 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::( + let result = self.parse_token_with_trivia::( input, TokenKind::Caret, ); choice.consider(input, result)?; - let result = self.parse_token_with_trivia::( + let result = self.parse_token_with_trivia::( input, TokenKind::Tilde, ); choice.consider(input, result)?; - let result = self.parse_token_with_trivia::( + let result = self.parse_token_with_trivia::( input, TokenKind::Equal, ); choice.consider(input, result)?; - let result = self.parse_token_with_trivia::( + let result = self.parse_token_with_trivia::( input, TokenKind::LessThan, ); choice.consider(input, result)?; - let result = self.parse_token_with_trivia::( + let result = self.parse_token_with_trivia::( input, TokenKind::GreaterThan, ); choice.consider(input, result)?; - let result = self.parse_token_with_trivia::( + let result = self.parse_token_with_trivia::( input, TokenKind::LessThanEqual, ); choice.consider(input, result)?; - let result = self.parse_token_with_trivia::( + let result = self.parse_token_with_trivia::( input, TokenKind::GreaterThanEqual, ); @@ -4750,7 +4954,7 @@ impl Language { }; let prefix_operator_parser = |input: &mut ParserContext| { ChoiceHelper::run(input, |mut choice, input| { - let result = parse_version_pragma_unary_operator(input); + let result = parse_version_pragma_prefix_expression(input); choice.consider(input, result)?; choice.finish(input) }) @@ -4768,9 +4972,9 @@ impl Language { }; let binary_operator_parser = |input: &mut ParserContext| { ChoiceHelper::run(input, |mut choice, input| { - let result = parse_version_pragma_or_operator(input); + let result = parse_version_pragma_or_expression(input); choice.consider(input, result)?; - let result = parse_version_pragma_range_operator(input); + let result = parse_version_pragma_range_expression(input); choice.consider(input, result)?; choice.finish(input) }) @@ -4803,11 +5007,11 @@ impl Language { #[allow(unused_assignments, unused_parens)] fn version_pragma_specifier(&self, input: &mut ParserContext) -> ParserResult { - SeparatedHelper::run::<_, LexicalContextType::VersionPragma>( + SeparatedHelper::run::<_, LexicalContextType::Pragma>( input, self, |input| { - self.parse_token_with_trivia::( + self.parse_token_with_trivia::( input, TokenKind::VersionPragmaValue, ) @@ -4847,52 +5051,44 @@ impl Language { seq.finish() }))?; seq.elem(ChoiceHelper::run(input, |mut choice, input| { - let result = ChoiceHelper::run(input, |mut choice, input| { - let result = self.expression_statement(input); - choice.consider(input, result)?; - let result = self.variable_declaration_statement(input); - choice.consider(input, result)?; - let result = self.tuple_deconstruction_statement(input); - choice.consider(input, result)?; - choice.finish(input) - }); + let result = self.expression_statement(input); choice.consider(input, result)?; - let result = ChoiceHelper::run(input, |mut choice, input| { - let result = self.if_statement(input); - choice.consider(input, result)?; - let result = self.for_statement(input); - choice.consider(input, result)?; - let result = self.while_statement(input); - choice.consider(input, result)?; - let result = self.do_while_statement(input); - choice.consider(input, result)?; - let result = self.continue_statement(input); + let result = self.variable_declaration_statement(input); + choice.consider(input, result)?; + let result = self.tuple_deconstruction_statement(input); + choice.consider(input, result)?; + let result = self.if_statement(input); + choice.consider(input, result)?; + let result = self.for_statement(input); + choice.consider(input, result)?; + let result = self.while_statement(input); + choice.consider(input, result)?; + let result = self.do_while_statement(input); + choice.consider(input, result)?; + let result = self.continue_statement(input); + choice.consider(input, result)?; + let result = self.break_statement(input); + choice.consider(input, result)?; + let result = self.delete_statement(input); + choice.consider(input, result)?; + let result = self.return_statement(input); + choice.consider(input, result)?; + if !self.version_is_at_least_0_5_0 { + let result = self.throw_statement(input); choice.consider(input, result)?; - let result = self.break_statement(input); + } + if self.version_is_at_least_0_4_21 { + let result = self.emit_statement(input); choice.consider(input, result)?; - let result = self.delete_statement(input); + } + if self.version_is_at_least_0_6_0 { + let result = self.try_statement(input); choice.consider(input, result)?; - let result = self.return_statement(input); + } + if self.version_is_at_least_0_8_4 { + let result = self.revert_statement(input); choice.consider(input, result)?; - if self.version_is_at_least_0_4_21 { - let result = self.emit_statement(input); - choice.consider(input, result)?; - } - if !self.version_is_at_least_0_5_0 { - let result = self.throw_statement(input); - choice.consider(input, result)?; - } - if self.version_is_at_least_0_6_0 { - let result = self.try_statement(input); - choice.consider(input, result)?; - } - if self.version_is_at_least_0_8_4 { - let result = self.revert_statement(input); - choice.consider(input, result)?; - } - choice.finish(input) - }); - choice.consider(input, result)?; + } let result = self.assembly_statement(input); choice.consider(input, result)?; let result = self.block(input); @@ -4910,7 +5106,7 @@ impl Language { #[allow(unused_assignments, unused_parens)] fn yul_arguments(&self, input: &mut ParserContext) -> ParserResult { - SeparatedHelper::run::<_, LexicalContextType::YulBlock>( + SeparatedHelper::run::<_, LexicalContextType::Yul>( input, self, |input| self.yul_expression(input), @@ -4924,7 +5120,7 @@ impl Language { SequenceHelper::run(|mut seq| { seq.elem(self.yul_identifier_paths(input))?; seq.elem( - self.parse_token_with_trivia::( + self.parse_token_with_trivia::( input, TokenKind::ColonEqual, ), @@ -4941,14 +5137,14 @@ impl Language { let mut delim_guard = input.open_delim(TokenKind::CloseBrace); let input = delim_guard.ctx(); seq.elem( - self.parse_token_with_trivia::( + self.parse_token_with_trivia::( input, TokenKind::OpenBrace, ), )?; seq.elem( OptionalHelper::transform(self.yul_statements(input)) - .recover_until_with_nested_delims::<_, LexicalContextType::YulBlock>( + .recover_until_with_nested_delims::<_, LexicalContextType::Yul>( input, self, TokenKind::CloseBrace, @@ -4956,7 +5152,7 @@ impl Language { ), )?; seq.elem( - self.parse_token_with_trivia::( + self.parse_token_with_trivia::( input, TokenKind::CloseBrace, ), @@ -4968,74 +5164,58 @@ impl Language { #[allow(unused_assignments, unused_parens)] fn yul_break_statement(&self, input: &mut ParserContext) -> ParserResult { - self.parse_token_with_trivia::(input, TokenKind::BreakKeyword) + self.parse_token_with_trivia::(input, TokenKind::YulBreakKeyword) .with_kind(RuleKind::YulBreakStatement) } #[allow(unused_assignments, unused_parens)] fn yul_continue_statement(&self, input: &mut ParserContext) -> ParserResult { - self.parse_token_with_trivia::( + self.parse_token_with_trivia::( input, - TokenKind::ContinueKeyword, + TokenKind::YulContinueKeyword, ) .with_kind(RuleKind::YulContinueStatement) } #[allow(unused_assignments, unused_parens)] - fn yul_declaration_statement(&self, input: &mut ParserContext) -> ParserResult { + fn yul_default_case(&self, input: &mut ParserContext) -> ParserResult { SequenceHelper::run(|mut seq| { - seq.elem( - self.parse_token_with_trivia::( - input, - TokenKind::LetKeyword, - ), - )?; - seq.elem(self.yul_identifier_paths(input))?; - seq.elem(OptionalHelper::transform(SequenceHelper::run(|mut seq| { - seq.elem( - self.parse_token_with_trivia::( - input, - TokenKind::ColonEqual, - ), - )?; - seq.elem(self.yul_expression(input))?; - seq.finish() - })))?; + seq.elem(self.parse_token_with_trivia::( + input, + TokenKind::YulDefaultKeyword, + ))?; + seq.elem(self.yul_block(input))?; seq.finish() }) - .with_kind(RuleKind::YulDeclarationStatement) + .with_kind(RuleKind::YulDefaultCase) } #[allow(unused_assignments, unused_parens)] fn yul_expression(&self, input: &mut ParserContext) -> ParserResult { - let parse_yul_function_call_operator = |input: &mut ParserContext| { + let parse_yul_function_call_expression = |input: &mut ParserContext| { PrecedenceHelper::to_postfix_operator( RuleKind::YulFunctionCallExpression, 1u8, SequenceHelper::run(|mut seq| { let mut delim_guard = input.open_delim(TokenKind::CloseParen); let input = delim_guard.ctx(); - seq.elem( - self.parse_token_with_trivia::( - input, - TokenKind::OpenParen, - ), - )?; + seq.elem(self.parse_token_with_trivia::( + input, + TokenKind::OpenParen, + ))?; seq.elem( OptionalHelper::transform(self.yul_arguments(input)) - .recover_until_with_nested_delims::<_, LexicalContextType::YulBlock>( - input, - self, - TokenKind::CloseParen, - RecoverFromNoMatch::Yes, - ), - )?; - seq.elem( - self.parse_token_with_trivia::( - input, - TokenKind::CloseParen, - ), + .recover_until_with_nested_delims::<_, LexicalContextType::Yul>( + input, + self, + TokenKind::CloseParen, + RecoverFromNoMatch::Yes, + ), )?; + seq.elem(self.parse_token_with_trivia::( + input, + TokenKind::CloseParen, + ))?; seq.finish() }), ) @@ -5043,32 +5223,32 @@ impl Language { let primary_expression_parser = |input: &mut ParserContext| { ChoiceHelper::run(input, |mut choice, input| { let result = ChoiceHelper::run(input, |mut choice, input| { - let result = self.parse_token_with_trivia::( + let result = self.parse_token_with_trivia::( input, - TokenKind::TrueKeyword, + TokenKind::YulTrueKeyword, ); choice.consider(input, result)?; - let result = self.parse_token_with_trivia::( + let result = self.parse_token_with_trivia::( input, - TokenKind::FalseKeyword, + TokenKind::YulFalseKeyword, ); choice.consider(input, result)?; - let result = self.parse_token_with_trivia::( + let result = self.parse_token_with_trivia::( input, - TokenKind::YulHexLiteral, + TokenKind::YulDecimalLiteral, ); choice.consider(input, result)?; - let result = self.parse_token_with_trivia::( + let result = self.parse_token_with_trivia::( input, - TokenKind::YulDecimalLiteral, + TokenKind::YulHexLiteral, ); choice.consider(input, result)?; - let result = self.parse_token_with_trivia::( + let result = self.parse_token_with_trivia::( input, TokenKind::HexStringLiteral, ); choice.consider(input, result)?; - let result = self.parse_token_with_trivia::( + let result = self.parse_token_with_trivia::( input, TokenKind::AsciiStringLiteral, ); @@ -5083,7 +5263,7 @@ impl Language { }; let postfix_operator_parser = |input: &mut ParserContext| { ChoiceHelper::run(input, |mut choice, input| { - let result = parse_yul_function_call_operator(input); + let result = parse_yul_function_call_expression(input); choice.consider(input, result)?; choice.finish(input) }) @@ -5107,13 +5287,11 @@ impl Language { #[allow(unused_assignments, unused_parens)] fn yul_for_statement(&self, input: &mut ParserContext) -> ParserResult { SequenceHelper::run(|mut seq| { - seq.elem( - self.parse_token_with_trivia::( - input, - TokenKind::ForKeyword, - ), - )?; - seq.elem(self.yul_block(input))?; + seq.elem(self.parse_token_with_trivia::( + input, + TokenKind::YulForKeyword, + ))?; + seq.elem(self.yul_block(input))?; seq.elem(self.yul_expression(input))?; seq.elem(self.yul_block(input))?; seq.elem(self.yul_block(input))?; @@ -5125,18 +5303,14 @@ impl Language { #[allow(unused_assignments, unused_parens)] fn yul_function_definition(&self, input: &mut ParserContext) -> ParserResult { SequenceHelper::run(|mut seq| { - seq.elem( - self.parse_token_with_trivia::( - input, - TokenKind::FunctionKeyword, - ), - )?; - seq.elem( - self.parse_token_with_trivia::( - input, - TokenKind::YulIdentifier, - ), - )?; + seq.elem(self.parse_token_with_trivia::( + input, + TokenKind::YulFunctionKeyword, + ))?; + seq.elem(self.parse_token_with_trivia::( + input, + TokenKind::YulIdentifier, + ))?; seq.elem(self.yul_parameters_declaration(input))?; seq.elem(OptionalHelper::transform( self.yul_returns_declaration(input), @@ -5149,11 +5323,11 @@ impl Language { #[allow(unused_assignments, unused_parens)] fn yul_identifier_path(&self, input: &mut ParserContext) -> ParserResult { - SeparatedHelper::run::<_, LexicalContextType::YulBlock>( + SeparatedHelper::run::<_, LexicalContextType::Yul>( input, self, |input| { - self.parse_token_with_trivia::( + self.parse_token_with_trivia::( input, TokenKind::YulIdentifier, ) @@ -5165,7 +5339,7 @@ impl Language { #[allow(unused_assignments, unused_parens)] fn yul_identifier_paths(&self, input: &mut ParserContext) -> ParserResult { - SeparatedHelper::run::<_, LexicalContextType::YulBlock>( + SeparatedHelper::run::<_, LexicalContextType::Yul>( input, self, |input| self.yul_identifier_path(input), @@ -5174,31 +5348,13 @@ impl Language { .with_kind(RuleKind::YulIdentifierPaths) } - #[allow(unused_assignments, unused_parens)] - fn yul_identifiers(&self, input: &mut ParserContext) -> ParserResult { - SeparatedHelper::run::<_, LexicalContextType::YulBlock>( - input, - self, - |input| { - self.parse_token_with_trivia::( - input, - TokenKind::YulIdentifier, - ) - }, - TokenKind::Comma, - ) - .with_kind(RuleKind::YulIdentifiers) - } - #[allow(unused_assignments, unused_parens)] fn yul_if_statement(&self, input: &mut ParserContext) -> ParserResult { SequenceHelper::run(|mut seq| { - seq.elem( - self.parse_token_with_trivia::( - input, - TokenKind::IfKeyword, - ), - )?; + seq.elem(self.parse_token_with_trivia::( + input, + TokenKind::YulIfKeyword, + ))?; seq.elem(self.yul_expression(input))?; seq.elem(self.yul_block(input))?; seq.finish() @@ -5209,9 +5365,9 @@ impl Language { #[allow(unused_assignments, unused_parens)] fn yul_leave_statement(&self, input: &mut ParserContext) -> ParserResult { if self.version_is_at_least_0_6_0 { - self.parse_token_with_trivia::( + self.parse_token_with_trivia::( input, - TokenKind::LeaveKeyword, + TokenKind::YulLeaveKeyword, ) } else { ParserResult::disabled() @@ -5219,20 +5375,36 @@ impl Language { .with_kind(RuleKind::YulLeaveStatement) } + #[allow(unused_assignments, unused_parens)] + fn yul_parameters(&self, input: &mut ParserContext) -> ParserResult { + SeparatedHelper::run::<_, LexicalContextType::Yul>( + input, + self, + |input| { + self.parse_token_with_trivia::( + input, + TokenKind::YulIdentifier, + ) + }, + TokenKind::Comma, + ) + .with_kind(RuleKind::YulParameters) + } + #[allow(unused_assignments, unused_parens)] fn yul_parameters_declaration(&self, input: &mut ParserContext) -> ParserResult { SequenceHelper::run(|mut seq| { let mut delim_guard = input.open_delim(TokenKind::CloseParen); let input = delim_guard.ctx(); seq.elem( - self.parse_token_with_trivia::( + self.parse_token_with_trivia::( input, TokenKind::OpenParen, ), )?; seq.elem( - OptionalHelper::transform(self.yul_identifiers(input)) - .recover_until_with_nested_delims::<_, LexicalContextType::YulBlock>( + OptionalHelper::transform(self.yul_parameters(input)) + .recover_until_with_nested_delims::<_, LexicalContextType::Yul>( input, self, TokenKind::CloseParen, @@ -5240,7 +5412,7 @@ impl Language { ), )?; seq.elem( - self.parse_token_with_trivia::( + self.parse_token_with_trivia::( input, TokenKind::CloseParen, ), @@ -5250,16 +5422,30 @@ impl Language { .with_kind(RuleKind::YulParametersDeclaration) } + #[allow(unused_assignments, unused_parens)] + fn yul_return_variables(&self, input: &mut ParserContext) -> ParserResult { + SeparatedHelper::run::<_, LexicalContextType::Yul>( + input, + self, + |input| { + self.parse_token_with_trivia::( + input, + TokenKind::YulIdentifier, + ) + }, + TokenKind::Comma, + ) + .with_kind(RuleKind::YulReturnVariables) + } + #[allow(unused_assignments, unused_parens)] fn yul_returns_declaration(&self, input: &mut ParserContext) -> ParserResult { SequenceHelper::run(|mut seq| { - seq.elem( - self.parse_token_with_trivia::( - input, - TokenKind::MinusGreaterThan, - ), - )?; - seq.elem(self.yul_identifiers(input))?; + seq.elem(self.parse_token_with_trivia::( + input, + TokenKind::MinusGreaterThan, + ))?; + seq.elem(self.yul_return_variables(input))?; seq.finish() }) .with_kind(RuleKind::YulReturnsDeclaration) @@ -5273,7 +5459,7 @@ impl Language { choice.consider(input, result)?; let result = self.yul_function_definition(input); choice.consider(input, result)?; - let result = self.yul_declaration_statement(input); + let result = self.yul_variable_declaration_statement(input); choice.consider(input, result)?; let result = self.yul_assignment_statement(input); choice.consider(input, result)?; @@ -5300,85 +5486,108 @@ impl Language { } #[allow(unused_assignments, unused_parens)] - fn yul_switch_case(&self, input: &mut ParserContext) -> ParserResult { + fn yul_switch_cases(&self, input: &mut ParserContext) -> ParserResult { + OneOrMoreHelper::run(input, |input| { + ChoiceHelper::run(input, |mut choice, input| { + let result = self.yul_default_case(input); + choice.consider(input, result)?; + let result = self.yul_value_case(input); + choice.consider(input, result)?; + choice.finish(input) + }) + }) + .with_kind(RuleKind::YulSwitchCases) + } + + #[allow(unused_assignments, unused_parens)] + fn yul_switch_statement(&self, input: &mut ParserContext) -> ParserResult { + SequenceHelper::run(|mut seq| { + seq.elem(self.parse_token_with_trivia::( + input, + TokenKind::YulSwitchKeyword, + ))?; + seq.elem(self.yul_expression(input))?; + seq.elem(self.yul_switch_cases(input))?; + seq.finish() + }) + .with_kind(RuleKind::YulSwitchStatement) + } + + #[allow(unused_assignments, unused_parens)] + fn yul_value_case(&self, input: &mut ParserContext) -> ParserResult { SequenceHelper::run(|mut seq| { + seq.elem(self.parse_token_with_trivia::( + input, + TokenKind::YulCaseKeyword, + ))?; seq.elem(ChoiceHelper::run(input, |mut choice, input| { - let result = self.parse_token_with_trivia::( + let result = self.parse_token_with_trivia::( input, - TokenKind::DefaultKeyword, + TokenKind::YulTrueKeyword, ); choice.consider(input, result)?; - let result = SequenceHelper::run(|mut seq| { - seq.elem( - self.parse_token_with_trivia::( - input, - TokenKind::CaseKeyword, - ), - )?; - seq.elem(ChoiceHelper::run(input, |mut choice, input| { - let result = self.parse_token_with_trivia::( - input, - TokenKind::TrueKeyword, - ); - choice.consider(input, result)?; - let result = self.parse_token_with_trivia::( - input, - TokenKind::FalseKeyword, - ); - choice.consider(input, result)?; - let result = self.parse_token_with_trivia::( - input, - TokenKind::YulHexLiteral, - ); - choice.consider(input, result)?; - let result = self.parse_token_with_trivia::( - input, - TokenKind::YulDecimalLiteral, - ); - choice.consider(input, result)?; - let result = self.parse_token_with_trivia::( - input, - TokenKind::HexStringLiteral, - ); - choice.consider(input, result)?; - let result = self.parse_token_with_trivia::( - input, - TokenKind::AsciiStringLiteral, - ); - choice.consider(input, result)?; - choice.finish(input) - }))?; - seq.finish() - }); + let result = self.parse_token_with_trivia::( + input, + TokenKind::YulFalseKeyword, + ); + choice.consider(input, result)?; + let result = self.parse_token_with_trivia::( + input, + TokenKind::YulDecimalLiteral, + ); + choice.consider(input, result)?; + let result = self.parse_token_with_trivia::( + input, + TokenKind::YulHexLiteral, + ); + choice.consider(input, result)?; + let result = self.parse_token_with_trivia::( + input, + TokenKind::HexStringLiteral, + ); + choice.consider(input, result)?; + let result = self.parse_token_with_trivia::( + input, + TokenKind::AsciiStringLiteral, + ); choice.consider(input, result)?; choice.finish(input) }))?; seq.elem(self.yul_block(input))?; seq.finish() }) - .with_kind(RuleKind::YulSwitchCase) + .with_kind(RuleKind::YulValueCase) } #[allow(unused_assignments, unused_parens)] - fn yul_switch_cases(&self, input: &mut ParserContext) -> ParserResult { - OneOrMoreHelper::run(input, |input| self.yul_switch_case(input)) - .with_kind(RuleKind::YulSwitchCases) + fn yul_variable_declaration_statement(&self, input: &mut ParserContext) -> ParserResult { + SequenceHelper::run(|mut seq| { + seq.elem(self.parse_token_with_trivia::( + input, + TokenKind::YulLetKeyword, + ))?; + seq.elem(self.yul_identifier_paths(input))?; + seq.elem(OptionalHelper::transform( + self.yul_variable_declaration_value(input), + ))?; + seq.finish() + }) + .with_kind(RuleKind::YulVariableDeclarationStatement) } #[allow(unused_assignments, unused_parens)] - fn yul_switch_statement(&self, input: &mut ParserContext) -> ParserResult { + fn yul_variable_declaration_value(&self, input: &mut ParserContext) -> ParserResult { SequenceHelper::run(|mut seq| { seq.elem( - self.parse_token_with_trivia::( + self.parse_token_with_trivia::( input, - TokenKind::SwitchKeyword, + TokenKind::ColonEqual, ), )?; seq.elem(self.yul_expression(input))?; - seq.elem(self.yul_switch_cases(input))?; seq.finish() }) - .with_kind(RuleKind::YulSwitchStatement) + .with_kind(RuleKind::YulVariableDeclarationValue) } /******************************************** @@ -5386,22 +5595,11 @@ impl Language { ********************************************/ #[allow(unused_assignments, unused_parens)] - fn ascii_character_without_double_quote_or_backslash(&self, input: &mut ParserContext) -> bool { - scan_choice!( - input, - scan_char_range!(input, ' '..='!'), - scan_char_range!(input, '#'..='['), - scan_char_range!(input, ']'..='~') - ) - } - - #[allow(unused_assignments, unused_parens)] - fn ascii_character_without_single_quote_or_backslash(&self, input: &mut ParserContext) -> bool { - scan_choice!( + fn ampersand(&self, input: &mut ParserContext) -> bool { + scan_not_followed_by!( input, - scan_char_range!(input, ' '..='&'), - scan_char_range!(input, '('..='['), - scan_char_range!(input, ']'..='~') + scan_chars!(input, '&'), + scan_choice!(input, scan_chars!(input, '='), scan_chars!(input, '&')) ) } @@ -5429,28 +5627,90 @@ impl Language { ) } + #[allow(unused_assignments, unused_parens)] + fn asterisk(&self, input: &mut ParserContext) -> bool { + scan_not_followed_by!( + input, + scan_chars!(input, '*'), + scan_choice!(input, scan_chars!(input, '='), scan_chars!(input, '*')) + ) + } + + #[allow(unused_assignments, unused_parens)] + fn bang(&self, input: &mut ParserContext) -> bool { + scan_not_followed_by!(input, scan_chars!(input, '!'), scan_chars!(input, '=')) + } + + #[allow(unused_assignments, unused_parens)] + fn bar(&self, input: &mut ParserContext) -> bool { + scan_not_followed_by!( + input, + scan_chars!(input, '|'), + scan_choice!(input, scan_chars!(input, '|'), scan_chars!(input, '=')) + ) + } + #[allow(unused_assignments, unused_parens)] fn bytes_keyword(&self, input: &mut ParserContext) -> bool { scan_sequence!( scan_chars!(input, 'b', 'y', 't', 'e', 's'), - self.fixed_bytes_type_size(input) + scan_choice!( + input, + scan_chars!(input, '9'), + scan_chars!(input, '8'), + scan_chars!(input, '7'), + scan_chars!(input, '6'), + scan_chars!(input, '5'), + scan_chars!(input, '4'), + scan_chars!(input, '3', '2'), + scan_chars!(input, '3', '1'), + scan_chars!(input, '3', '0'), + scan_chars!(input, '3'), + scan_chars!(input, '2', '9'), + scan_chars!(input, '2', '8'), + scan_chars!(input, '2', '7'), + scan_chars!(input, '2', '6'), + scan_chars!(input, '2', '5'), + scan_chars!(input, '2', '4'), + scan_chars!(input, '2', '3'), + scan_chars!(input, '2', '2'), + scan_chars!(input, '2', '1'), + scan_chars!(input, '2', '0'), + scan_chars!(input, '2'), + scan_chars!(input, '1', '9'), + scan_chars!(input, '1', '8'), + scan_chars!(input, '1', '7'), + scan_chars!(input, '1', '6'), + scan_chars!(input, '1', '5'), + scan_chars!(input, '1', '4'), + scan_chars!(input, '1', '3'), + scan_chars!(input, '1', '2'), + scan_chars!(input, '1', '1'), + scan_chars!(input, '1', '0'), + scan_chars!(input, '1') + ) ) } #[allow(unused_assignments, unused_parens)] - fn decimal_digit(&self, input: &mut ParserContext) -> bool { - scan_char_range!(input, '0'..='9') + fn caret(&self, input: &mut ParserContext) -> bool { + scan_not_followed_by!(input, scan_chars!(input, '^'), scan_chars!(input, '=')) + } + + #[allow(unused_assignments, unused_parens)] + fn colon(&self, input: &mut ParserContext) -> bool { + scan_not_followed_by!(input, scan_chars!(input, ':'), scan_chars!(input, '=')) } #[allow(unused_assignments, unused_parens)] fn decimal_digits(&self, input: &mut ParserContext) -> bool { scan_sequence!( - scan_one_or_more!(input, self.decimal_digit(input)), + scan_one_or_more!(input, scan_char_range!(input, '0'..='9')), scan_zero_or_more!( input, scan_sequence!( scan_chars!(input, '_'), - scan_one_or_more!(input, self.decimal_digit(input)) + scan_one_or_more!(input, scan_char_range!(input, '0'..='9')) ) ) ) @@ -5467,35 +5727,55 @@ impl Language { #[allow(unused_assignments, unused_parens)] fn decimal_literal(&self, input: &mut ParserContext) -> bool { - scan_not_followed_by!( + scan_choice!( input, - scan_sequence!( - scan_choice!( - input, + scan_not_followed_by!( + input, + scan_sequence!( scan_not_followed_by!( input, self.decimal_digits(input), scan_chars!(input, '.') ), - if !self.version_is_at_least_0_5_0 { + scan_optional!(input, self.decimal_exponent(input)) + ), + self.identifier_start(input) + ), + if !self.version_is_at_least_0_5_0 { + scan_not_followed_by!( + input, + scan_sequence!( scan_not_followed_by!( input, scan_sequence!(self.decimal_digits(input), scan_chars!(input, '.')), self.decimal_digits(input) - ) - } else { - false - }, - scan_sequence!(scan_chars!(input, '.'), self.decimal_digits(input)), - scan_sequence!( - self.decimal_digits(input), - scan_chars!(input, '.'), - self.decimal_digits(input) - ) + ), + scan_optional!(input, self.decimal_exponent(input)) + ), + self.identifier_start(input) + ) + } else { + false + }, + scan_not_followed_by!( + input, + scan_sequence!( + scan_chars!(input, '.'), + self.decimal_digits(input), + scan_optional!(input, self.decimal_exponent(input)) ), - scan_optional!(input, self.decimal_exponent(input)) + self.identifier_start(input) ), - self.identifier_start(input) + scan_not_followed_by!( + input, + scan_sequence!( + self.decimal_digits(input), + scan_chars!(input, '.'), + self.decimal_digits(input), + scan_optional!(input, self.decimal_exponent(input)) + ), + self.identifier_start(input) + ) ) } @@ -5508,7 +5788,9 @@ impl Language { scan_choice!( input, self.escape_sequence(input), - self.ascii_character_without_double_quote_or_backslash(input) + scan_char_range!(input, ' '..='!'), + scan_char_range!(input, '#'..='['), + scan_char_range!(input, ']'..='~') ) ), scan_chars!(input, '"') @@ -5534,7 +5816,7 @@ impl Language { scan_choice!( input, self.escape_sequence(input), - scan_none_of!(input, '\n', '\r', '"', '\\') + scan_none_of!(input, '"', '\\', '\r', '\n') ) ), scan_chars!(input, '"') @@ -5552,6 +5834,15 @@ impl Language { ) } + #[allow(unused_assignments, unused_parens)] + fn equal(&self, input: &mut ParserContext) -> bool { + scan_not_followed_by!( + input, + scan_chars!(input, '='), + scan_choice!(input, scan_chars!(input, '>'), scan_chars!(input, '=')) + ) + } + #[allow(unused_assignments, unused_parens)] fn escape_sequence(&self, input: &mut ParserContext) -> bool { scan_sequence!( @@ -5566,66 +5857,320 @@ impl Language { } #[allow(unused_assignments, unused_parens)] - fn fixed_bytes_type_size(&self, input: &mut ParserContext) -> bool { + fn fixed_keyword(&self, input: &mut ParserContext) -> bool { scan_choice!( input, - scan_chars!(input, '9'), - scan_chars!(input, '8'), - scan_chars!(input, '7'), - scan_chars!(input, '6'), - scan_chars!(input, '5'), - scan_chars!(input, '4'), - scan_chars!(input, '3', '2'), - scan_chars!(input, '3', '1'), - scan_chars!(input, '3', '0'), - scan_chars!(input, '3'), - scan_chars!(input, '2', '9'), - scan_chars!(input, '2', '8'), - scan_chars!(input, '2', '7'), - scan_chars!(input, '2', '6'), - scan_chars!(input, '2', '5'), - scan_chars!(input, '2', '4'), - scan_chars!(input, '2', '3'), - scan_chars!(input, '2', '2'), - scan_chars!(input, '2', '1'), - scan_chars!(input, '2', '0'), - scan_chars!(input, '2'), - scan_chars!(input, '1', '9'), - scan_chars!(input, '1', '8'), - scan_chars!(input, '1', '7'), - scan_chars!(input, '1', '6'), - scan_chars!(input, '1', '5'), - scan_chars!(input, '1', '4'), - scan_chars!(input, '1', '3'), - scan_chars!(input, '1', '2'), - scan_chars!(input, '1', '1'), - scan_chars!(input, '1', '0'), - scan_chars!(input, '1') + scan_chars!(input, 'f', 'i', 'x', 'e', 'd'), + scan_sequence!( + scan_chars!(input, 'f', 'i', 'x', 'e', 'd'), + scan_choice!( + input, + scan_chars!(input, '9', '6'), + scan_chars!(input, '8', '8'), + scan_chars!(input, '8', '0'), + scan_chars!(input, '8'), + scan_chars!(input, '7', '2'), + scan_chars!(input, '6', '4'), + scan_chars!(input, '5', '6'), + scan_chars!(input, '4', '8'), + scan_chars!(input, '4', '0'), + scan_chars!(input, '3', '2'), + scan_chars!(input, '2', '4'), + scan_chars!(input, '1', '7', '6'), + scan_chars!(input, '1', '6', '8'), + scan_chars!(input, '1', '6', '0'), + scan_chars!(input, '1', '6'), + scan_chars!(input, '1', '5', '2'), + scan_chars!(input, '1', '4', '4'), + scan_chars!(input, '1', '3', '6'), + scan_chars!(input, '1', '2', '8'), + scan_chars!(input, '1', '2', '0'), + scan_chars!(input, '1', '1', '2'), + scan_chars!(input, '1', '0', '4') + ), + scan_chars!(input, 'x'), + scan_choice!( + input, + scan_chars!(input, '8', '0'), + scan_chars!(input, '8'), + scan_chars!(input, '7', '2'), + scan_chars!(input, '6', '4'), + scan_chars!(input, '5', '6'), + scan_chars!(input, '4', '8'), + scan_chars!(input, '4', '0'), + scan_chars!(input, '3', '2'), + scan_chars!(input, '2', '4'), + scan_chars!(input, '1', '6') + ) + ), + scan_sequence!( + scan_chars!(input, 'f', 'i', 'x', 'e', 'd'), + scan_choice!( + input, + scan_chars!(input, '2', '4', '8', 'x', '8'), + scan_chars!(input, '2', '4', '0', 'x', '8'), + scan_chars!(input, '2', '4', '0', 'x', '1', '6'), + scan_chars!(input, '2', '3', '2', 'x', '8'), + scan_chars!(input, '2', '3', '2', 'x', '2', '4'), + scan_chars!(input, '2', '3', '2', 'x', '1', '6'), + scan_chars!(input, '2', '2', '4', 'x', '8'), + scan_chars!(input, '2', '2', '4', 'x', '3', '2'), + scan_chars!(input, '2', '2', '4', 'x', '2', '4'), + scan_chars!(input, '2', '2', '4', 'x', '1', '6'), + scan_chars!(input, '2', '1', '6', 'x', '8'), + scan_chars!(input, '2', '1', '6', 'x', '4', '0'), + scan_chars!(input, '2', '1', '6', 'x', '3', '2'), + scan_chars!(input, '2', '1', '6', 'x', '2', '4'), + scan_chars!(input, '2', '1', '6', 'x', '1', '6'), + scan_chars!(input, '2', '0', '8', 'x', '8'), + scan_chars!(input, '2', '0', '8', 'x', '4', '8'), + scan_chars!(input, '2', '0', '8', 'x', '4', '0'), + scan_chars!(input, '2', '0', '8', 'x', '3', '2'), + scan_chars!(input, '2', '0', '8', 'x', '2', '4'), + scan_chars!(input, '2', '0', '8', 'x', '1', '6'), + scan_chars!(input, '2', '0', '0', 'x', '8'), + scan_chars!(input, '2', '0', '0', 'x', '5', '6'), + scan_chars!(input, '2', '0', '0', 'x', '4', '8'), + scan_chars!(input, '2', '0', '0', 'x', '4', '0'), + scan_chars!(input, '2', '0', '0', 'x', '3', '2'), + scan_chars!(input, '2', '0', '0', 'x', '2', '4'), + scan_chars!(input, '2', '0', '0', 'x', '1', '6'), + scan_chars!(input, '1', '9', '2', 'x', '8'), + scan_chars!(input, '1', '9', '2', 'x', '6', '4'), + scan_chars!(input, '1', '9', '2', 'x', '5', '6'), + scan_chars!(input, '1', '9', '2', 'x', '4', '8'), + scan_chars!(input, '1', '9', '2', 'x', '4', '0'), + scan_chars!(input, '1', '9', '2', 'x', '3', '2'), + scan_chars!(input, '1', '9', '2', 'x', '2', '4'), + scan_chars!(input, '1', '9', '2', 'x', '1', '6'), + scan_chars!(input, '1', '8', '4', 'x', '8'), + scan_chars!(input, '1', '8', '4', 'x', '7', '2'), + scan_chars!(input, '1', '8', '4', 'x', '6', '4'), + scan_chars!(input, '1', '8', '4', 'x', '5', '6'), + scan_chars!(input, '1', '8', '4', 'x', '4', '8'), + scan_chars!(input, '1', '8', '4', 'x', '4', '0'), + scan_chars!(input, '1', '8', '4', 'x', '3', '2'), + scan_chars!(input, '1', '8', '4', 'x', '2', '4'), + scan_chars!(input, '1', '8', '4', 'x', '1', '6') + ) + ), + if self.version_is_at_least_0_4_14 { + scan_sequence!( + scan_chars!(input, 'f', 'i', 'x', 'e', 'd'), + scan_choice!( + input, + scan_chars!(input, '2', '5', '6', 'x', '8', '0'), + scan_chars!(input, '2', '5', '6', 'x', '8'), + scan_chars!(input, '2', '5', '6', 'x', '7', '2'), + scan_chars!(input, '2', '5', '6', 'x', '6', '4'), + scan_chars!(input, '2', '5', '6', 'x', '5', '6'), + scan_chars!(input, '2', '5', '6', 'x', '4', '8'), + scan_chars!(input, '2', '5', '6', 'x', '4', '0'), + scan_chars!(input, '2', '5', '6', 'x', '3', '2'), + scan_chars!(input, '2', '5', '6', 'x', '2', '4'), + scan_chars!(input, '2', '5', '6', 'x', '1', '6'), + scan_chars!(input, '2', '4', '8', 'x', '8', '0'), + scan_chars!(input, '2', '4', '8', 'x', '7', '2'), + scan_chars!(input, '2', '4', '8', 'x', '6', '4'), + scan_chars!(input, '2', '4', '8', 'x', '5', '6'), + scan_chars!(input, '2', '4', '8', 'x', '4', '8'), + scan_chars!(input, '2', '4', '8', 'x', '4', '0'), + scan_chars!(input, '2', '4', '8', 'x', '3', '2'), + scan_chars!(input, '2', '4', '8', 'x', '2', '4'), + scan_chars!(input, '2', '4', '8', 'x', '1', '6'), + scan_chars!(input, '2', '4', '0', 'x', '8', '0'), + scan_chars!(input, '2', '4', '0', 'x', '7', '2'), + scan_chars!(input, '2', '4', '0', 'x', '6', '4'), + scan_chars!(input, '2', '4', '0', 'x', '5', '6'), + scan_chars!(input, '2', '4', '0', 'x', '4', '8'), + scan_chars!(input, '2', '4', '0', 'x', '4', '0'), + scan_chars!(input, '2', '4', '0', 'x', '3', '2'), + scan_chars!(input, '2', '4', '0', 'x', '2', '4'), + scan_chars!(input, '2', '3', '2', 'x', '8', '0'), + scan_chars!(input, '2', '3', '2', 'x', '7', '2'), + scan_chars!(input, '2', '3', '2', 'x', '6', '4'), + scan_chars!(input, '2', '3', '2', 'x', '5', '6'), + scan_chars!(input, '2', '3', '2', 'x', '4', '8'), + scan_chars!(input, '2', '3', '2', 'x', '4', '0'), + scan_chars!(input, '2', '3', '2', 'x', '3', '2'), + scan_chars!(input, '2', '2', '4', 'x', '8', '0'), + scan_chars!(input, '2', '2', '4', 'x', '7', '2'), + scan_chars!(input, '2', '2', '4', 'x', '6', '4'), + scan_chars!(input, '2', '2', '4', 'x', '5', '6'), + scan_chars!(input, '2', '2', '4', 'x', '4', '8'), + scan_chars!(input, '2', '2', '4', 'x', '4', '0'), + scan_chars!(input, '2', '1', '6', 'x', '8', '0'), + scan_chars!(input, '2', '1', '6', 'x', '7', '2'), + scan_chars!(input, '2', '1', '6', 'x', '6', '4'), + scan_chars!(input, '2', '1', '6', 'x', '5', '6'), + scan_chars!(input, '2', '1', '6', 'x', '4', '8'), + scan_chars!(input, '2', '0', '8', 'x', '8', '0'), + scan_chars!(input, '2', '0', '8', 'x', '7', '2'), + scan_chars!(input, '2', '0', '8', 'x', '6', '4'), + scan_chars!(input, '2', '0', '8', 'x', '5', '6'), + scan_chars!(input, '2', '0', '0', 'x', '8', '0'), + scan_chars!(input, '2', '0', '0', 'x', '7', '2'), + scan_chars!(input, '2', '0', '0', 'x', '6', '4'), + scan_chars!(input, '1', '9', '2', 'x', '8', '0'), + scan_chars!(input, '1', '9', '2', 'x', '7', '2'), + scan_chars!(input, '1', '8', '4', 'x', '8', '0') + ) + ) + } else { + false + }, + if self.version_is_at_least_0_4_14 { + scan_sequence!( + scan_chars!(input, 'f', 'i', 'x', 'e', 'd'), + scan_choice!( + input, + scan_chars!(input, '9', '6'), + scan_chars!(input, '8', '8'), + scan_chars!(input, '8', '0'), + scan_chars!(input, '8'), + scan_chars!(input, '7', '2'), + scan_chars!(input, '6', '4'), + scan_chars!(input, '5', '6'), + scan_chars!(input, '4', '8'), + scan_chars!(input, '4', '0'), + scan_chars!(input, '3', '2'), + scan_chars!(input, '2', '5', '6'), + scan_chars!(input, '2', '4', '8'), + scan_chars!(input, '2', '4', '0'), + scan_chars!(input, '2', '4'), + scan_chars!(input, '2', '3', '2'), + scan_chars!(input, '2', '2', '4'), + scan_chars!(input, '2', '1', '6'), + scan_chars!(input, '2', '0', '8'), + scan_chars!(input, '2', '0', '0'), + scan_chars!(input, '1', '9', '2'), + scan_chars!(input, '1', '8', '4'), + scan_chars!(input, '1', '7', '6'), + scan_chars!(input, '1', '6', '8'), + scan_chars!(input, '1', '6', '0'), + scan_chars!(input, '1', '6'), + scan_chars!(input, '1', '5', '2'), + scan_chars!(input, '1', '4', '4'), + scan_chars!(input, '1', '3', '6'), + scan_chars!(input, '1', '2', '8'), + scan_chars!(input, '1', '2', '0'), + scan_chars!(input, '1', '1', '2'), + scan_chars!(input, '1', '0', '4') + ), + scan_chars!(input, 'x'), + scan_choice!( + input, + scan_chars!(input, '9'), + scan_chars!(input, '7', '9'), + scan_chars!(input, '7', '8'), + scan_chars!(input, '7', '7'), + scan_chars!(input, '7', '6'), + scan_chars!(input, '7', '5'), + scan_chars!(input, '7', '4'), + scan_chars!(input, '7', '3'), + scan_chars!(input, '7', '1'), + scan_chars!(input, '7', '0'), + scan_chars!(input, '7'), + scan_chars!(input, '6', '9'), + scan_chars!(input, '6', '8'), + scan_chars!(input, '6', '7'), + scan_chars!(input, '6', '6'), + scan_chars!(input, '6', '5'), + scan_chars!(input, '6', '3'), + scan_chars!(input, '6', '2'), + scan_chars!(input, '6', '1'), + scan_chars!(input, '6', '0'), + scan_chars!(input, '6'), + scan_chars!(input, '5', '9'), + scan_chars!(input, '5', '8'), + scan_chars!(input, '5', '7'), + scan_chars!(input, '5', '5'), + scan_chars!(input, '5', '4'), + scan_chars!(input, '5', '3'), + scan_chars!(input, '5', '2'), + scan_chars!(input, '5', '1'), + scan_chars!(input, '5', '0'), + scan_chars!(input, '5'), + scan_chars!(input, '4', '9'), + scan_chars!(input, '4', '7'), + scan_chars!(input, '4', '6'), + scan_chars!(input, '4', '5'), + scan_chars!(input, '4', '4'), + scan_chars!(input, '4', '3'), + scan_chars!(input, '4', '2'), + scan_chars!(input, '4', '1'), + scan_chars!(input, '4'), + scan_chars!(input, '3', '9'), + scan_chars!(input, '3', '8'), + scan_chars!(input, '3', '7'), + scan_chars!(input, '3', '6'), + scan_chars!(input, '3', '5'), + scan_chars!(input, '3', '4'), + scan_chars!(input, '3', '3'), + scan_chars!(input, '3', '1'), + scan_chars!(input, '3', '0'), + scan_chars!(input, '3'), + scan_chars!(input, '2', '9'), + scan_chars!(input, '2', '8'), + scan_chars!(input, '2', '7'), + scan_chars!(input, '2', '6'), + scan_chars!(input, '2', '5'), + scan_chars!(input, '2', '3'), + scan_chars!(input, '2', '2'), + scan_chars!(input, '2', '1'), + scan_chars!(input, '2', '0'), + scan_chars!(input, '2'), + scan_chars!(input, '1', '9'), + scan_chars!(input, '1', '8'), + scan_chars!(input, '1', '7'), + scan_chars!(input, '1', '5'), + scan_chars!(input, '1', '4'), + scan_chars!(input, '1', '3'), + scan_chars!(input, '1', '2'), + scan_chars!(input, '1', '1'), + scan_chars!(input, '1', '0'), + scan_chars!(input, '1'), + scan_chars!(input, '0') + ) + ) + } else { + false + } ) } #[allow(unused_assignments, unused_parens)] - fn fixed_keyword(&self, input: &mut ParserContext) -> bool { - scan_sequence!( - scan_chars!(input, 'f', 'i', 'x', 'e', 'd'), - scan_optional!(input, self.fixed_type_size(input)) + fn greater_than(&self, input: &mut ParserContext) -> bool { + scan_not_followed_by!( + input, + scan_chars!(input, '>'), + scan_choice!(input, scan_chars!(input, '>'), scan_chars!(input, '=')) ) } #[allow(unused_assignments, unused_parens)] - fn fixed_type_size(&self, input: &mut ParserContext) -> bool { - scan_sequence!( - scan_one_or_more!(input, scan_char_range!(input, '0'..='9')), - scan_chars!(input, 'x'), - scan_one_or_more!(input, scan_char_range!(input, '0'..='9')) + fn greater_than_greater_than(&self, input: &mut ParserContext) -> bool { + scan_not_followed_by!( + input, + scan_chars!(input, '>', '>'), + scan_choice!(input, scan_chars!(input, '>'), scan_chars!(input, '=')) ) } #[allow(unused_assignments, unused_parens)] - fn hex_byte_escape(&self, input: &mut ParserContext) -> bool { - scan_sequence!( - scan_chars!(input, 'x'), - self.hex_character(input), + fn greater_than_greater_than_greater_than(&self, input: &mut ParserContext) -> bool { + scan_not_followed_by!( + input, + scan_chars!(input, '>', '>', '>'), + scan_chars!(input, '=') + ) + } + + #[allow(unused_assignments, unused_parens)] + fn hex_byte_escape(&self, input: &mut ParserContext) -> bool { + scan_sequence!( + scan_chars!(input, 'x'), + self.hex_character(input), self.hex_character(input) ) } @@ -5634,36 +6179,50 @@ impl Language { fn hex_character(&self, input: &mut ParserContext) -> bool { scan_choice!( input, - self.decimal_digit(input), - scan_char_range!(input, 'A'..='F'), - scan_char_range!(input, 'a'..='f') + scan_char_range!(input, '0'..='9'), + scan_char_range!(input, 'a'..='f'), + scan_char_range!(input, 'A'..='F') ) } #[allow(unused_assignments, unused_parens)] fn hex_literal(&self, input: &mut ParserContext) -> bool { - scan_not_followed_by!( + scan_choice!( input, - scan_sequence!( - scan_choice!( - input, + scan_not_followed_by!( + input, + scan_sequence!( scan_chars!(input, '0', 'x'), - if !self.version_is_at_least_0_5_0 { - scan_chars!(input, '0', 'X') - } else { - false - } + scan_one_or_more!(input, self.hex_character(input)), + scan_zero_or_more!( + input, + scan_sequence!( + scan_chars!(input, '_'), + scan_one_or_more!(input, self.hex_character(input)) + ) + ) ), - scan_one_or_more!(input, self.hex_character(input)), - scan_zero_or_more!( + self.identifier_start(input) + ), + if !self.version_is_at_least_0_5_0 { + scan_not_followed_by!( input, scan_sequence!( - scan_chars!(input, '_'), - scan_one_or_more!(input, self.hex_character(input)) - ) + scan_chars!(input, '0', 'X'), + scan_one_or_more!(input, self.hex_character(input)), + scan_zero_or_more!( + input, + scan_sequence!( + scan_chars!(input, '_'), + scan_one_or_more!(input, self.hex_character(input)) + ) + ) + ), + self.identifier_start(input) ) - ), - self.identifier_start(input) + } else { + false + } ) } @@ -5712,8 +6271,8 @@ impl Language { input, scan_chars!(input, '_'), scan_chars!(input, '$'), - scan_char_range!(input, 'A'..='Z'), - scan_char_range!(input, 'a'..='z') + scan_char_range!(input, 'a'..='z'), + scan_char_range!(input, 'A'..='Z') ) } @@ -5721,46 +6280,72 @@ impl Language { fn int_keyword(&self, input: &mut ParserContext) -> bool { scan_sequence!( scan_chars!(input, 'i', 'n', 't'), - scan_optional!(input, self.integer_type_size(input)) + scan_optional!( + input, + scan_choice!( + input, + scan_chars!(input, '9', '6'), + scan_chars!(input, '8', '8'), + scan_chars!(input, '8', '0'), + scan_chars!(input, '8'), + scan_chars!(input, '7', '2'), + scan_chars!(input, '6', '4'), + scan_chars!(input, '5', '6'), + scan_chars!(input, '4', '8'), + scan_chars!(input, '4', '0'), + scan_chars!(input, '3', '2'), + scan_chars!(input, '2', '5', '6'), + scan_chars!(input, '2', '4', '8'), + scan_chars!(input, '2', '4', '0'), + scan_chars!(input, '2', '4'), + scan_chars!(input, '2', '3', '2'), + scan_chars!(input, '2', '2', '4'), + scan_chars!(input, '2', '1', '6'), + scan_chars!(input, '2', '0', '8'), + scan_chars!(input, '2', '0', '0'), + scan_chars!(input, '1', '9', '2'), + scan_chars!(input, '1', '8', '4'), + scan_chars!(input, '1', '7', '6'), + scan_chars!(input, '1', '6', '8'), + scan_chars!(input, '1', '6', '0'), + scan_chars!(input, '1', '6'), + scan_chars!(input, '1', '5', '2'), + scan_chars!(input, '1', '4', '4'), + scan_chars!(input, '1', '3', '6'), + scan_chars!(input, '1', '2', '8'), + scan_chars!(input, '1', '2', '0'), + scan_chars!(input, '1', '1', '2'), + scan_chars!(input, '1', '0', '4') + ) + ) ) } #[allow(unused_assignments, unused_parens)] - fn integer_type_size(&self, input: &mut ParserContext) -> bool { - scan_choice!( + fn less_than(&self, input: &mut ParserContext) -> bool { + scan_not_followed_by!( + input, + scan_chars!(input, '<'), + scan_choice!(input, scan_chars!(input, '='), scan_chars!(input, '<')) + ) + } + + #[allow(unused_assignments, unused_parens)] + fn less_than_less_than(&self, input: &mut ParserContext) -> bool { + scan_not_followed_by!(input, scan_chars!(input, '<', '<'), scan_chars!(input, '=')) + } + + #[allow(unused_assignments, unused_parens)] + fn minus(&self, input: &mut ParserContext) -> bool { + scan_not_followed_by!( input, - scan_chars!(input, '9', '6'), - scan_chars!(input, '8', '8'), - scan_chars!(input, '8', '0'), - scan_chars!(input, '8'), - scan_chars!(input, '7', '2'), - scan_chars!(input, '6', '4'), - scan_chars!(input, '5', '6'), - scan_chars!(input, '4', '8'), - scan_chars!(input, '4', '0'), - scan_chars!(input, '3', '2'), - scan_chars!(input, '2', '5', '6'), - scan_chars!(input, '2', '4', '8'), - scan_chars!(input, '2', '4', '0'), - scan_chars!(input, '2', '4'), - scan_chars!(input, '2', '3', '2'), - scan_chars!(input, '2', '2', '4'), - scan_chars!(input, '2', '1', '6'), - scan_chars!(input, '2', '0', '8'), - scan_chars!(input, '2', '0', '0'), - scan_chars!(input, '1', '9', '2'), - scan_chars!(input, '1', '8', '4'), - scan_chars!(input, '1', '7', '6'), - scan_chars!(input, '1', '6', '8'), - scan_chars!(input, '1', '6', '0'), - scan_chars!(input, '1', '6'), - scan_chars!(input, '1', '5', '2'), - scan_chars!(input, '1', '4', '4'), - scan_chars!(input, '1', '3', '6'), - scan_chars!(input, '1', '2', '8'), - scan_chars!(input, '1', '2', '0'), - scan_chars!(input, '1', '1', '2'), - scan_chars!(input, '1', '0', '4') + scan_chars!(input, '-'), + scan_choice!( + input, + scan_chars!(input, '>'), + scan_chars!(input, '='), + scan_chars!(input, '-') + ) ) } @@ -5782,6 +6367,20 @@ impl Language { ) } + #[allow(unused_assignments, unused_parens)] + fn percent(&self, input: &mut ParserContext) -> bool { + scan_not_followed_by!(input, scan_chars!(input, '%'), scan_chars!(input, '=')) + } + + #[allow(unused_assignments, unused_parens)] + fn plus(&self, input: &mut ParserContext) -> bool { + scan_not_followed_by!( + input, + scan_chars!(input, '+'), + scan_choice!(input, scan_chars!(input, '='), scan_chars!(input, '+')) + ) + } + #[allow(unused_assignments, unused_parens)] fn raw_identifier(&self, input: &mut ParserContext) -> bool { scan_sequence!( @@ -5794,7 +6393,7 @@ impl Language { fn single_line_comment(&self, input: &mut ParserContext) -> bool { scan_sequence!( scan_chars!(input, '/', '/'), - scan_zero_or_more!(input, scan_none_of!(input, '\n', '\r')) + scan_zero_or_more!(input, scan_none_of!(input, '\r', '\n')) ) } @@ -5807,7 +6406,9 @@ impl Language { scan_choice!( input, self.escape_sequence(input), - self.ascii_character_without_single_quote_or_backslash(input) + scan_char_range!(input, ' '..='&'), + scan_char_range!(input, '('..='['), + scan_char_range!(input, ']'..='~') ) ), scan_chars!(input, '\'') @@ -5833,7 +6434,7 @@ impl Language { scan_choice!( input, self.escape_sequence(input), - scan_none_of!(input, '\n', '\r', '\'', '\\') + scan_none_of!(input, '\'', '\\', '\r', '\n') ) ), scan_chars!(input, '\'') @@ -5843,11 +6444,291 @@ impl Language { } } + #[allow(unused_assignments, unused_parens)] + fn slash(&self, input: &mut ParserContext) -> bool { + scan_not_followed_by!(input, scan_chars!(input, '/'), scan_chars!(input, '=')) + } + #[allow(unused_assignments, unused_parens)] fn ufixed_keyword(&self, input: &mut ParserContext) -> bool { - scan_sequence!( + scan_choice!( + input, scan_chars!(input, 'u', 'f', 'i', 'x', 'e', 'd'), - scan_optional!(input, self.fixed_type_size(input)) + scan_sequence!( + scan_chars!(input, 'u', 'f', 'i', 'x', 'e', 'd'), + scan_choice!( + input, + scan_chars!(input, '9', '6'), + scan_chars!(input, '8', '8'), + scan_chars!(input, '8', '0'), + scan_chars!(input, '8'), + scan_chars!(input, '7', '2'), + scan_chars!(input, '6', '4'), + scan_chars!(input, '5', '6'), + scan_chars!(input, '4', '8'), + scan_chars!(input, '4', '0'), + scan_chars!(input, '3', '2'), + scan_chars!(input, '2', '4'), + scan_chars!(input, '1', '7', '6'), + scan_chars!(input, '1', '6', '8'), + scan_chars!(input, '1', '6', '0'), + scan_chars!(input, '1', '6'), + scan_chars!(input, '1', '5', '2'), + scan_chars!(input, '1', '4', '4'), + scan_chars!(input, '1', '3', '6'), + scan_chars!(input, '1', '2', '8'), + scan_chars!(input, '1', '2', '0'), + scan_chars!(input, '1', '1', '2'), + scan_chars!(input, '1', '0', '4') + ), + scan_chars!(input, 'x'), + scan_choice!( + input, + scan_chars!(input, '8', '0'), + scan_chars!(input, '8'), + scan_chars!(input, '7', '2'), + scan_chars!(input, '6', '4'), + scan_chars!(input, '5', '6'), + scan_chars!(input, '4', '8'), + scan_chars!(input, '4', '0'), + scan_chars!(input, '3', '2'), + scan_chars!(input, '2', '4'), + scan_chars!(input, '1', '6') + ) + ), + scan_sequence!( + scan_chars!(input, 'u', 'f', 'i', 'x', 'e', 'd'), + scan_choice!( + input, + scan_chars!(input, '2', '4', '8', 'x', '8'), + scan_chars!(input, '2', '4', '0', 'x', '8'), + scan_chars!(input, '2', '4', '0', 'x', '1', '6'), + scan_chars!(input, '2', '3', '2', 'x', '8'), + scan_chars!(input, '2', '3', '2', 'x', '2', '4'), + scan_chars!(input, '2', '3', '2', 'x', '1', '6'), + scan_chars!(input, '2', '2', '4', 'x', '8'), + scan_chars!(input, '2', '2', '4', 'x', '3', '2'), + scan_chars!(input, '2', '2', '4', 'x', '2', '4'), + scan_chars!(input, '2', '2', '4', 'x', '1', '6'), + scan_chars!(input, '2', '1', '6', 'x', '8'), + scan_chars!(input, '2', '1', '6', 'x', '4', '0'), + scan_chars!(input, '2', '1', '6', 'x', '3', '2'), + scan_chars!(input, '2', '1', '6', 'x', '2', '4'), + scan_chars!(input, '2', '1', '6', 'x', '1', '6'), + scan_chars!(input, '2', '0', '8', 'x', '8'), + scan_chars!(input, '2', '0', '8', 'x', '4', '8'), + scan_chars!(input, '2', '0', '8', 'x', '4', '0'), + scan_chars!(input, '2', '0', '8', 'x', '3', '2'), + scan_chars!(input, '2', '0', '8', 'x', '2', '4'), + scan_chars!(input, '2', '0', '8', 'x', '1', '6'), + scan_chars!(input, '2', '0', '0', 'x', '8'), + scan_chars!(input, '2', '0', '0', 'x', '5', '6'), + scan_chars!(input, '2', '0', '0', 'x', '4', '8'), + scan_chars!(input, '2', '0', '0', 'x', '4', '0'), + scan_chars!(input, '2', '0', '0', 'x', '3', '2'), + scan_chars!(input, '2', '0', '0', 'x', '2', '4'), + scan_chars!(input, '2', '0', '0', 'x', '1', '6'), + scan_chars!(input, '1', '9', '2', 'x', '8'), + scan_chars!(input, '1', '9', '2', 'x', '6', '4'), + scan_chars!(input, '1', '9', '2', 'x', '5', '6'), + scan_chars!(input, '1', '9', '2', 'x', '4', '8'), + scan_chars!(input, '1', '9', '2', 'x', '4', '0'), + scan_chars!(input, '1', '9', '2', 'x', '3', '2'), + scan_chars!(input, '1', '9', '2', 'x', '2', '4'), + scan_chars!(input, '1', '9', '2', 'x', '1', '6'), + scan_chars!(input, '1', '8', '4', 'x', '8'), + scan_chars!(input, '1', '8', '4', 'x', '7', '2'), + scan_chars!(input, '1', '8', '4', 'x', '6', '4'), + scan_chars!(input, '1', '8', '4', 'x', '5', '6'), + scan_chars!(input, '1', '8', '4', 'x', '4', '8'), + scan_chars!(input, '1', '8', '4', 'x', '4', '0'), + scan_chars!(input, '1', '8', '4', 'x', '3', '2'), + scan_chars!(input, '1', '8', '4', 'x', '2', '4'), + scan_chars!(input, '1', '8', '4', 'x', '1', '6') + ) + ), + if self.version_is_at_least_0_4_14 { + scan_sequence!( + scan_chars!(input, 'u', 'f', 'i', 'x', 'e', 'd'), + scan_choice!( + input, + scan_chars!(input, '2', '5', '6', 'x', '8', '0'), + scan_chars!(input, '2', '5', '6', 'x', '8'), + scan_chars!(input, '2', '5', '6', 'x', '7', '2'), + scan_chars!(input, '2', '5', '6', 'x', '6', '4'), + scan_chars!(input, '2', '5', '6', 'x', '5', '6'), + scan_chars!(input, '2', '5', '6', 'x', '4', '8'), + scan_chars!(input, '2', '5', '6', 'x', '4', '0'), + scan_chars!(input, '2', '5', '6', 'x', '3', '2'), + scan_chars!(input, '2', '5', '6', 'x', '2', '4'), + scan_chars!(input, '2', '5', '6', 'x', '1', '6'), + scan_chars!(input, '2', '4', '8', 'x', '8', '0'), + scan_chars!(input, '2', '4', '8', 'x', '7', '2'), + scan_chars!(input, '2', '4', '8', 'x', '6', '4'), + scan_chars!(input, '2', '4', '8', 'x', '5', '6'), + scan_chars!(input, '2', '4', '8', 'x', '4', '8'), + scan_chars!(input, '2', '4', '8', 'x', '4', '0'), + scan_chars!(input, '2', '4', '8', 'x', '3', '2'), + scan_chars!(input, '2', '4', '8', 'x', '2', '4'), + scan_chars!(input, '2', '4', '8', 'x', '1', '6'), + scan_chars!(input, '2', '4', '0', 'x', '8', '0'), + scan_chars!(input, '2', '4', '0', 'x', '7', '2'), + scan_chars!(input, '2', '4', '0', 'x', '6', '4'), + scan_chars!(input, '2', '4', '0', 'x', '5', '6'), + scan_chars!(input, '2', '4', '0', 'x', '4', '8'), + scan_chars!(input, '2', '4', '0', 'x', '4', '0'), + scan_chars!(input, '2', '4', '0', 'x', '3', '2'), + scan_chars!(input, '2', '4', '0', 'x', '2', '4'), + scan_chars!(input, '2', '3', '2', 'x', '8', '0'), + scan_chars!(input, '2', '3', '2', 'x', '7', '2'), + scan_chars!(input, '2', '3', '2', 'x', '6', '4'), + scan_chars!(input, '2', '3', '2', 'x', '5', '6'), + scan_chars!(input, '2', '3', '2', 'x', '4', '8'), + scan_chars!(input, '2', '3', '2', 'x', '4', '0'), + scan_chars!(input, '2', '3', '2', 'x', '3', '2'), + scan_chars!(input, '2', '2', '4', 'x', '8', '0'), + scan_chars!(input, '2', '2', '4', 'x', '7', '2'), + scan_chars!(input, '2', '2', '4', 'x', '6', '4'), + scan_chars!(input, '2', '2', '4', 'x', '5', '6'), + scan_chars!(input, '2', '2', '4', 'x', '4', '8'), + scan_chars!(input, '2', '2', '4', 'x', '4', '0'), + scan_chars!(input, '2', '1', '6', 'x', '8', '0'), + scan_chars!(input, '2', '1', '6', 'x', '7', '2'), + scan_chars!(input, '2', '1', '6', 'x', '6', '4'), + scan_chars!(input, '2', '1', '6', 'x', '5', '6'), + scan_chars!(input, '2', '1', '6', 'x', '4', '8'), + scan_chars!(input, '2', '0', '8', 'x', '8', '0'), + scan_chars!(input, '2', '0', '8', 'x', '7', '2'), + scan_chars!(input, '2', '0', '8', 'x', '6', '4'), + scan_chars!(input, '2', '0', '8', 'x', '5', '6'), + scan_chars!(input, '2', '0', '0', 'x', '8', '0'), + scan_chars!(input, '2', '0', '0', 'x', '7', '2'), + scan_chars!(input, '2', '0', '0', 'x', '6', '4'), + scan_chars!(input, '1', '9', '2', 'x', '8', '0'), + scan_chars!(input, '1', '9', '2', 'x', '7', '2'), + scan_chars!(input, '1', '8', '4', 'x', '8', '0') + ) + ) + } else { + false + }, + if self.version_is_at_least_0_4_14 { + scan_sequence!( + scan_chars!(input, 'u', 'f', 'i', 'x', 'e', 'd'), + scan_choice!( + input, + scan_chars!(input, '9', '6'), + scan_chars!(input, '8', '8'), + scan_chars!(input, '8', '0'), + scan_chars!(input, '8'), + scan_chars!(input, '7', '2'), + scan_chars!(input, '6', '4'), + scan_chars!(input, '5', '6'), + scan_chars!(input, '4', '8'), + scan_chars!(input, '4', '0'), + scan_chars!(input, '3', '2'), + scan_chars!(input, '2', '5', '6'), + scan_chars!(input, '2', '4', '8'), + scan_chars!(input, '2', '4', '0'), + scan_chars!(input, '2', '4'), + scan_chars!(input, '2', '3', '2'), + scan_chars!(input, '2', '2', '4'), + scan_chars!(input, '2', '1', '6'), + scan_chars!(input, '2', '0', '8'), + scan_chars!(input, '2', '0', '0'), + scan_chars!(input, '1', '9', '2'), + scan_chars!(input, '1', '8', '4'), + scan_chars!(input, '1', '7', '6'), + scan_chars!(input, '1', '6', '8'), + scan_chars!(input, '1', '6', '0'), + scan_chars!(input, '1', '6'), + scan_chars!(input, '1', '5', '2'), + scan_chars!(input, '1', '4', '4'), + scan_chars!(input, '1', '3', '6'), + scan_chars!(input, '1', '2', '8'), + scan_chars!(input, '1', '2', '0'), + scan_chars!(input, '1', '1', '2'), + scan_chars!(input, '1', '0', '4') + ), + scan_chars!(input, 'x'), + scan_choice!( + input, + scan_chars!(input, '9'), + scan_chars!(input, '7', '9'), + scan_chars!(input, '7', '8'), + scan_chars!(input, '7', '7'), + scan_chars!(input, '7', '6'), + scan_chars!(input, '7', '5'), + scan_chars!(input, '7', '4'), + scan_chars!(input, '7', '3'), + scan_chars!(input, '7', '1'), + scan_chars!(input, '7', '0'), + scan_chars!(input, '7'), + scan_chars!(input, '6', '9'), + scan_chars!(input, '6', '8'), + scan_chars!(input, '6', '7'), + scan_chars!(input, '6', '6'), + scan_chars!(input, '6', '5'), + scan_chars!(input, '6', '3'), + scan_chars!(input, '6', '2'), + scan_chars!(input, '6', '1'), + scan_chars!(input, '6', '0'), + scan_chars!(input, '6'), + scan_chars!(input, '5', '9'), + scan_chars!(input, '5', '8'), + scan_chars!(input, '5', '7'), + scan_chars!(input, '5', '5'), + scan_chars!(input, '5', '4'), + scan_chars!(input, '5', '3'), + scan_chars!(input, '5', '2'), + scan_chars!(input, '5', '1'), + scan_chars!(input, '5', '0'), + scan_chars!(input, '5'), + scan_chars!(input, '4', '9'), + scan_chars!(input, '4', '7'), + scan_chars!(input, '4', '6'), + scan_chars!(input, '4', '5'), + scan_chars!(input, '4', '4'), + scan_chars!(input, '4', '3'), + scan_chars!(input, '4', '2'), + scan_chars!(input, '4', '1'), + scan_chars!(input, '4'), + scan_chars!(input, '3', '9'), + scan_chars!(input, '3', '8'), + scan_chars!(input, '3', '7'), + scan_chars!(input, '3', '6'), + scan_chars!(input, '3', '5'), + scan_chars!(input, '3', '4'), + scan_chars!(input, '3', '3'), + scan_chars!(input, '3', '1'), + scan_chars!(input, '3', '0'), + scan_chars!(input, '3'), + scan_chars!(input, '2', '9'), + scan_chars!(input, '2', '8'), + scan_chars!(input, '2', '7'), + scan_chars!(input, '2', '6'), + scan_chars!(input, '2', '5'), + scan_chars!(input, '2', '3'), + scan_chars!(input, '2', '2'), + scan_chars!(input, '2', '1'), + scan_chars!(input, '2', '0'), + scan_chars!(input, '2'), + scan_chars!(input, '1', '9'), + scan_chars!(input, '1', '8'), + scan_chars!(input, '1', '7'), + scan_chars!(input, '1', '5'), + scan_chars!(input, '1', '4'), + scan_chars!(input, '1', '3'), + scan_chars!(input, '1', '2'), + scan_chars!(input, '1', '1'), + scan_chars!(input, '1', '0'), + scan_chars!(input, '1'), + scan_chars!(input, '0') + ) + ) + } else { + false + } ) } @@ -5855,7 +6736,44 @@ impl Language { fn uint_keyword(&self, input: &mut ParserContext) -> bool { scan_sequence!( scan_chars!(input, 'u', 'i', 'n', 't'), - scan_optional!(input, self.integer_type_size(input)) + scan_optional!( + input, + scan_choice!( + input, + scan_chars!(input, '9', '6'), + scan_chars!(input, '8', '8'), + scan_chars!(input, '8', '0'), + scan_chars!(input, '8'), + scan_chars!(input, '7', '2'), + scan_chars!(input, '6', '4'), + scan_chars!(input, '5', '6'), + scan_chars!(input, '4', '8'), + scan_chars!(input, '4', '0'), + scan_chars!(input, '3', '2'), + scan_chars!(input, '2', '5', '6'), + scan_chars!(input, '2', '4', '8'), + scan_chars!(input, '2', '4', '0'), + scan_chars!(input, '2', '4'), + scan_chars!(input, '2', '3', '2'), + scan_chars!(input, '2', '2', '4'), + scan_chars!(input, '2', '1', '6'), + scan_chars!(input, '2', '0', '8'), + scan_chars!(input, '2', '0', '0'), + scan_chars!(input, '1', '9', '2'), + scan_chars!(input, '1', '8', '4'), + scan_chars!(input, '1', '7', '6'), + scan_chars!(input, '1', '6', '8'), + scan_chars!(input, '1', '6', '0'), + scan_chars!(input, '1', '6'), + scan_chars!(input, '1', '5', '2'), + scan_chars!(input, '1', '4', '4'), + scan_chars!(input, '1', '3', '6'), + scan_chars!(input, '1', '2', '8'), + scan_chars!(input, '1', '2', '0'), + scan_chars!(input, '1', '1', '2'), + scan_chars!(input, '1', '0', '4') + ) + ) ) } @@ -5872,15 +6790,19 @@ impl Language { #[allow(unused_assignments, unused_parens)] fn unicode_string_literal(&self, input: &mut ParserContext) -> bool { - if self.version_is_at_least_0_7_0 { - scan_choice!( - input, - self.single_quoted_unicode_string_literal(input), + scan_choice!( + input, + if self.version_is_at_least_0_7_0 { + self.single_quoted_unicode_string_literal(input) + } else { + false + }, + if self.version_is_at_least_0_7_0 { self.double_quoted_unicode_string_literal(input) - ) - } else { - false - } + } else { + false + } + ) } #[allow(unused_assignments, unused_parens)] @@ -5905,6 +6827,52 @@ impl Language { ) } + #[allow(unused_assignments, unused_parens)] + fn yul_bytes_keyword(&self, input: &mut ParserContext) -> bool { + if !self.version_is_at_least_0_7_1 { + scan_sequence!( + scan_chars!(input, 'b', 'y', 't', 'e', 's'), + scan_choice!( + input, + scan_chars!(input, '9'), + scan_chars!(input, '8'), + scan_chars!(input, '7'), + scan_chars!(input, '6'), + scan_chars!(input, '5'), + scan_chars!(input, '4'), + scan_chars!(input, '3', '2'), + scan_chars!(input, '3', '1'), + scan_chars!(input, '3', '0'), + scan_chars!(input, '3'), + scan_chars!(input, '2', '9'), + scan_chars!(input, '2', '8'), + scan_chars!(input, '2', '7'), + scan_chars!(input, '2', '6'), + scan_chars!(input, '2', '5'), + scan_chars!(input, '2', '4'), + scan_chars!(input, '2', '3'), + scan_chars!(input, '2', '2'), + scan_chars!(input, '2', '1'), + scan_chars!(input, '2', '0'), + scan_chars!(input, '2'), + scan_chars!(input, '1', '9'), + scan_chars!(input, '1', '8'), + scan_chars!(input, '1', '7'), + scan_chars!(input, '1', '6'), + scan_chars!(input, '1', '5'), + scan_chars!(input, '1', '4'), + scan_chars!(input, '1', '3'), + scan_chars!(input, '1', '2'), + scan_chars!(input, '1', '1'), + scan_chars!(input, '1', '0'), + scan_chars!(input, '1') + ) + ) + } else { + false + } + } + #[allow(unused_assignments, unused_parens)] fn yul_decimal_literal(&self, input: &mut ParserContext) -> bool { scan_not_followed_by!( @@ -5914,13 +6882,308 @@ impl Language { scan_chars!(input, '0'), scan_sequence!( scan_char_range!(input, '1'..='9'), - scan_zero_or_more!(input, self.decimal_digit(input)) + scan_zero_or_more!(input, scan_char_range!(input, '0'..='9')) ) ), self.identifier_start(input) ) } + #[allow(unused_assignments, unused_parens)] + fn yul_fixed_keyword(&self, input: &mut ParserContext) -> bool { + scan_choice!( + input, + if !self.version_is_at_least_0_7_1 { + scan_chars!(input, 'f', 'i', 'x', 'e', 'd') + } else { + false + }, + if !self.version_is_at_least_0_7_1 { + scan_sequence!( + scan_chars!(input, 'f', 'i', 'x', 'e', 'd'), + scan_choice!( + input, + scan_chars!(input, '9', '6'), + scan_chars!(input, '8', '8'), + scan_chars!(input, '8', '0'), + scan_chars!(input, '8'), + scan_chars!(input, '7', '2'), + scan_chars!(input, '6', '4'), + scan_chars!(input, '5', '6'), + scan_chars!(input, '4', '8'), + scan_chars!(input, '4', '0'), + scan_chars!(input, '3', '2'), + scan_chars!(input, '2', '4'), + scan_chars!(input, '1', '7', '6'), + scan_chars!(input, '1', '6', '8'), + scan_chars!(input, '1', '6', '0'), + scan_chars!(input, '1', '6'), + scan_chars!(input, '1', '5', '2'), + scan_chars!(input, '1', '4', '4'), + scan_chars!(input, '1', '3', '6'), + scan_chars!(input, '1', '2', '8'), + scan_chars!(input, '1', '2', '0'), + scan_chars!(input, '1', '1', '2'), + scan_chars!(input, '1', '0', '4') + ), + scan_chars!(input, 'x'), + scan_choice!( + input, + scan_chars!(input, '8', '0'), + scan_chars!(input, '8'), + scan_chars!(input, '7', '2'), + scan_chars!(input, '6', '4'), + scan_chars!(input, '5', '6'), + scan_chars!(input, '4', '8'), + scan_chars!(input, '4', '0'), + scan_chars!(input, '3', '2'), + scan_chars!(input, '2', '4'), + scan_chars!(input, '1', '6') + ) + ) + } else { + false + }, + if !self.version_is_at_least_0_7_1 { + scan_sequence!( + scan_chars!(input, 'f', 'i', 'x', 'e', 'd'), + scan_choice!( + input, + scan_chars!(input, '2', '4', '8', 'x', '8'), + scan_chars!(input, '2', '4', '0', 'x', '8'), + scan_chars!(input, '2', '4', '0', 'x', '1', '6'), + scan_chars!(input, '2', '3', '2', 'x', '8'), + scan_chars!(input, '2', '3', '2', 'x', '2', '4'), + scan_chars!(input, '2', '3', '2', 'x', '1', '6'), + scan_chars!(input, '2', '2', '4', 'x', '8'), + scan_chars!(input, '2', '2', '4', 'x', '3', '2'), + scan_chars!(input, '2', '2', '4', 'x', '2', '4'), + scan_chars!(input, '2', '2', '4', 'x', '1', '6'), + scan_chars!(input, '2', '1', '6', 'x', '8'), + scan_chars!(input, '2', '1', '6', 'x', '4', '0'), + scan_chars!(input, '2', '1', '6', 'x', '3', '2'), + scan_chars!(input, '2', '1', '6', 'x', '2', '4'), + scan_chars!(input, '2', '1', '6', 'x', '1', '6'), + scan_chars!(input, '2', '0', '8', 'x', '8'), + scan_chars!(input, '2', '0', '8', 'x', '4', '8'), + scan_chars!(input, '2', '0', '8', 'x', '4', '0'), + scan_chars!(input, '2', '0', '8', 'x', '3', '2'), + scan_chars!(input, '2', '0', '8', 'x', '2', '4'), + scan_chars!(input, '2', '0', '8', 'x', '1', '6'), + scan_chars!(input, '2', '0', '0', 'x', '8'), + scan_chars!(input, '2', '0', '0', 'x', '5', '6'), + scan_chars!(input, '2', '0', '0', 'x', '4', '8'), + scan_chars!(input, '2', '0', '0', 'x', '4', '0'), + scan_chars!(input, '2', '0', '0', 'x', '3', '2'), + scan_chars!(input, '2', '0', '0', 'x', '2', '4'), + scan_chars!(input, '2', '0', '0', 'x', '1', '6'), + scan_chars!(input, '1', '9', '2', 'x', '8'), + scan_chars!(input, '1', '9', '2', 'x', '6', '4'), + scan_chars!(input, '1', '9', '2', 'x', '5', '6'), + scan_chars!(input, '1', '9', '2', 'x', '4', '8'), + scan_chars!(input, '1', '9', '2', 'x', '4', '0'), + scan_chars!(input, '1', '9', '2', 'x', '3', '2'), + scan_chars!(input, '1', '9', '2', 'x', '2', '4'), + scan_chars!(input, '1', '9', '2', 'x', '1', '6'), + scan_chars!(input, '1', '8', '4', 'x', '8'), + scan_chars!(input, '1', '8', '4', 'x', '7', '2'), + scan_chars!(input, '1', '8', '4', 'x', '6', '4'), + scan_chars!(input, '1', '8', '4', 'x', '5', '6'), + scan_chars!(input, '1', '8', '4', 'x', '4', '8'), + scan_chars!(input, '1', '8', '4', 'x', '4', '0'), + scan_chars!(input, '1', '8', '4', 'x', '3', '2'), + scan_chars!(input, '1', '8', '4', 'x', '2', '4'), + scan_chars!(input, '1', '8', '4', 'x', '1', '6') + ) + ) + } else { + false + }, + if self.version_is_at_least_0_4_14 && !self.version_is_at_least_0_7_1 { + scan_sequence!( + scan_chars!(input, 'f', 'i', 'x', 'e', 'd'), + scan_choice!( + input, + scan_chars!(input, '2', '5', '6', 'x', '8', '0'), + scan_chars!(input, '2', '5', '6', 'x', '8'), + scan_chars!(input, '2', '5', '6', 'x', '7', '2'), + scan_chars!(input, '2', '5', '6', 'x', '6', '4'), + scan_chars!(input, '2', '5', '6', 'x', '5', '6'), + scan_chars!(input, '2', '5', '6', 'x', '4', '8'), + scan_chars!(input, '2', '5', '6', 'x', '4', '0'), + scan_chars!(input, '2', '5', '6', 'x', '3', '2'), + scan_chars!(input, '2', '5', '6', 'x', '2', '4'), + scan_chars!(input, '2', '5', '6', 'x', '1', '6'), + scan_chars!(input, '2', '4', '8', 'x', '8', '0'), + scan_chars!(input, '2', '4', '8', 'x', '7', '2'), + scan_chars!(input, '2', '4', '8', 'x', '6', '4'), + scan_chars!(input, '2', '4', '8', 'x', '5', '6'), + scan_chars!(input, '2', '4', '8', 'x', '4', '8'), + scan_chars!(input, '2', '4', '8', 'x', '4', '0'), + scan_chars!(input, '2', '4', '8', 'x', '3', '2'), + scan_chars!(input, '2', '4', '8', 'x', '2', '4'), + scan_chars!(input, '2', '4', '8', 'x', '1', '6'), + scan_chars!(input, '2', '4', '0', 'x', '8', '0'), + scan_chars!(input, '2', '4', '0', 'x', '7', '2'), + scan_chars!(input, '2', '4', '0', 'x', '6', '4'), + scan_chars!(input, '2', '4', '0', 'x', '5', '6'), + scan_chars!(input, '2', '4', '0', 'x', '4', '8'), + scan_chars!(input, '2', '4', '0', 'x', '4', '0'), + scan_chars!(input, '2', '4', '0', 'x', '3', '2'), + scan_chars!(input, '2', '4', '0', 'x', '2', '4'), + scan_chars!(input, '2', '3', '2', 'x', '8', '0'), + scan_chars!(input, '2', '3', '2', 'x', '7', '2'), + scan_chars!(input, '2', '3', '2', 'x', '6', '4'), + scan_chars!(input, '2', '3', '2', 'x', '5', '6'), + scan_chars!(input, '2', '3', '2', 'x', '4', '8'), + scan_chars!(input, '2', '3', '2', 'x', '4', '0'), + scan_chars!(input, '2', '3', '2', 'x', '3', '2'), + scan_chars!(input, '2', '2', '4', 'x', '8', '0'), + scan_chars!(input, '2', '2', '4', 'x', '7', '2'), + scan_chars!(input, '2', '2', '4', 'x', '6', '4'), + scan_chars!(input, '2', '2', '4', 'x', '5', '6'), + scan_chars!(input, '2', '2', '4', 'x', '4', '8'), + scan_chars!(input, '2', '2', '4', 'x', '4', '0'), + scan_chars!(input, '2', '1', '6', 'x', '8', '0'), + scan_chars!(input, '2', '1', '6', 'x', '7', '2'), + scan_chars!(input, '2', '1', '6', 'x', '6', '4'), + scan_chars!(input, '2', '1', '6', 'x', '5', '6'), + scan_chars!(input, '2', '1', '6', 'x', '4', '8'), + scan_chars!(input, '2', '0', '8', 'x', '8', '0'), + scan_chars!(input, '2', '0', '8', 'x', '7', '2'), + scan_chars!(input, '2', '0', '8', 'x', '6', '4'), + scan_chars!(input, '2', '0', '8', 'x', '5', '6'), + scan_chars!(input, '2', '0', '0', 'x', '8', '0'), + scan_chars!(input, '2', '0', '0', 'x', '7', '2'), + scan_chars!(input, '2', '0', '0', 'x', '6', '4'), + scan_chars!(input, '1', '9', '2', 'x', '8', '0'), + scan_chars!(input, '1', '9', '2', 'x', '7', '2'), + scan_chars!(input, '1', '8', '4', 'x', '8', '0') + ) + ) + } else { + false + }, + if self.version_is_at_least_0_4_14 && !self.version_is_at_least_0_7_1 { + scan_sequence!( + scan_chars!(input, 'f', 'i', 'x', 'e', 'd'), + scan_choice!( + input, + scan_chars!(input, '9', '6'), + scan_chars!(input, '8', '8'), + scan_chars!(input, '8', '0'), + scan_chars!(input, '8'), + scan_chars!(input, '7', '2'), + scan_chars!(input, '6', '4'), + scan_chars!(input, '5', '6'), + scan_chars!(input, '4', '8'), + scan_chars!(input, '4', '0'), + scan_chars!(input, '3', '2'), + scan_chars!(input, '2', '5', '6'), + scan_chars!(input, '2', '4', '8'), + scan_chars!(input, '2', '4', '0'), + scan_chars!(input, '2', '4'), + scan_chars!(input, '2', '3', '2'), + scan_chars!(input, '2', '2', '4'), + scan_chars!(input, '2', '1', '6'), + scan_chars!(input, '2', '0', '8'), + scan_chars!(input, '2', '0', '0'), + scan_chars!(input, '1', '9', '2'), + scan_chars!(input, '1', '8', '4'), + scan_chars!(input, '1', '7', '6'), + scan_chars!(input, '1', '6', '8'), + scan_chars!(input, '1', '6', '0'), + scan_chars!(input, '1', '6'), + scan_chars!(input, '1', '5', '2'), + scan_chars!(input, '1', '4', '4'), + scan_chars!(input, '1', '3', '6'), + scan_chars!(input, '1', '2', '8'), + scan_chars!(input, '1', '2', '0'), + scan_chars!(input, '1', '1', '2'), + scan_chars!(input, '1', '0', '4') + ), + scan_chars!(input, 'x'), + scan_choice!( + input, + scan_chars!(input, '9'), + scan_chars!(input, '7', '9'), + scan_chars!(input, '7', '8'), + scan_chars!(input, '7', '7'), + scan_chars!(input, '7', '6'), + scan_chars!(input, '7', '5'), + scan_chars!(input, '7', '4'), + scan_chars!(input, '7', '3'), + scan_chars!(input, '7', '1'), + scan_chars!(input, '7', '0'), + scan_chars!(input, '7'), + scan_chars!(input, '6', '9'), + scan_chars!(input, '6', '8'), + scan_chars!(input, '6', '7'), + scan_chars!(input, '6', '6'), + scan_chars!(input, '6', '5'), + scan_chars!(input, '6', '3'), + scan_chars!(input, '6', '2'), + scan_chars!(input, '6', '1'), + scan_chars!(input, '6', '0'), + scan_chars!(input, '6'), + scan_chars!(input, '5', '9'), + scan_chars!(input, '5', '8'), + scan_chars!(input, '5', '7'), + scan_chars!(input, '5', '5'), + scan_chars!(input, '5', '4'), + scan_chars!(input, '5', '3'), + scan_chars!(input, '5', '2'), + scan_chars!(input, '5', '1'), + scan_chars!(input, '5', '0'), + scan_chars!(input, '5'), + scan_chars!(input, '4', '9'), + scan_chars!(input, '4', '7'), + scan_chars!(input, '4', '6'), + scan_chars!(input, '4', '5'), + scan_chars!(input, '4', '4'), + scan_chars!(input, '4', '3'), + scan_chars!(input, '4', '2'), + scan_chars!(input, '4', '1'), + scan_chars!(input, '4'), + scan_chars!(input, '3', '9'), + scan_chars!(input, '3', '8'), + scan_chars!(input, '3', '7'), + scan_chars!(input, '3', '6'), + scan_chars!(input, '3', '5'), + scan_chars!(input, '3', '4'), + scan_chars!(input, '3', '3'), + scan_chars!(input, '3', '1'), + scan_chars!(input, '3', '0'), + scan_chars!(input, '3'), + scan_chars!(input, '2', '9'), + scan_chars!(input, '2', '8'), + scan_chars!(input, '2', '7'), + scan_chars!(input, '2', '6'), + scan_chars!(input, '2', '5'), + scan_chars!(input, '2', '3'), + scan_chars!(input, '2', '2'), + scan_chars!(input, '2', '1'), + scan_chars!(input, '2', '0'), + scan_chars!(input, '2'), + scan_chars!(input, '1', '9'), + scan_chars!(input, '1', '8'), + scan_chars!(input, '1', '7'), + scan_chars!(input, '1', '5'), + scan_chars!(input, '1', '4'), + scan_chars!(input, '1', '3'), + scan_chars!(input, '1', '2'), + scan_chars!(input, '1', '1'), + scan_chars!(input, '1', '0'), + scan_chars!(input, '1'), + scan_chars!(input, '0') + ) + ) + } else { + false + } + ) + } + #[allow(unused_assignments, unused_parens)] fn yul_hex_literal(&self, input: &mut ParserContext) -> bool { scan_not_followed_by!( @@ -5938,18 +7201,409 @@ impl Language { self.raw_identifier(input) } + #[allow(unused_assignments, unused_parens)] + fn yul_int_keyword(&self, input: &mut ParserContext) -> bool { + if !self.version_is_at_least_0_7_1 { + scan_sequence!( + scan_chars!(input, 'i', 'n', 't'), + scan_optional!( + input, + scan_choice!( + input, + scan_chars!(input, '9', '6'), + scan_chars!(input, '8', '8'), + scan_chars!(input, '8', '0'), + scan_chars!(input, '8'), + scan_chars!(input, '7', '2'), + scan_chars!(input, '6', '4'), + scan_chars!(input, '5', '6'), + scan_chars!(input, '4', '8'), + scan_chars!(input, '4', '0'), + scan_chars!(input, '3', '2'), + scan_chars!(input, '2', '5', '6'), + scan_chars!(input, '2', '4', '8'), + scan_chars!(input, '2', '4', '0'), + scan_chars!(input, '2', '4'), + scan_chars!(input, '2', '3', '2'), + scan_chars!(input, '2', '2', '4'), + scan_chars!(input, '2', '1', '6'), + scan_chars!(input, '2', '0', '8'), + scan_chars!(input, '2', '0', '0'), + scan_chars!(input, '1', '9', '2'), + scan_chars!(input, '1', '8', '4'), + scan_chars!(input, '1', '7', '6'), + scan_chars!(input, '1', '6', '8'), + scan_chars!(input, '1', '6', '0'), + scan_chars!(input, '1', '6'), + scan_chars!(input, '1', '5', '2'), + scan_chars!(input, '1', '4', '4'), + scan_chars!(input, '1', '3', '6'), + scan_chars!(input, '1', '2', '8'), + scan_chars!(input, '1', '2', '0'), + scan_chars!(input, '1', '1', '2'), + scan_chars!(input, '1', '0', '4') + ) + ) + ) + } else { + false + } + } + + #[allow(unused_assignments, unused_parens)] + fn yul_ufixed_keyword(&self, input: &mut ParserContext) -> bool { + scan_choice!( + input, + if !self.version_is_at_least_0_7_1 { + scan_chars!(input, 'u', 'f', 'i', 'x', 'e', 'd') + } else { + false + }, + if !self.version_is_at_least_0_7_1 { + scan_sequence!( + scan_chars!(input, 'u', 'f', 'i', 'x', 'e', 'd'), + scan_choice!( + input, + scan_chars!(input, '9', '6'), + scan_chars!(input, '8', '8'), + scan_chars!(input, '8', '0'), + scan_chars!(input, '8'), + scan_chars!(input, '7', '2'), + scan_chars!(input, '6', '4'), + scan_chars!(input, '5', '6'), + scan_chars!(input, '4', '8'), + scan_chars!(input, '4', '0'), + scan_chars!(input, '3', '2'), + scan_chars!(input, '2', '4'), + scan_chars!(input, '1', '7', '6'), + scan_chars!(input, '1', '6', '8'), + scan_chars!(input, '1', '6', '0'), + scan_chars!(input, '1', '6'), + scan_chars!(input, '1', '5', '2'), + scan_chars!(input, '1', '4', '4'), + scan_chars!(input, '1', '3', '6'), + scan_chars!(input, '1', '2', '8'), + scan_chars!(input, '1', '2', '0'), + scan_chars!(input, '1', '1', '2'), + scan_chars!(input, '1', '0', '4') + ), + scan_chars!(input, 'x'), + scan_choice!( + input, + scan_chars!(input, '8', '0'), + scan_chars!(input, '8'), + scan_chars!(input, '7', '2'), + scan_chars!(input, '6', '4'), + scan_chars!(input, '5', '6'), + scan_chars!(input, '4', '8'), + scan_chars!(input, '4', '0'), + scan_chars!(input, '3', '2'), + scan_chars!(input, '2', '4'), + scan_chars!(input, '1', '6') + ) + ) + } else { + false + }, + if !self.version_is_at_least_0_7_1 { + scan_sequence!( + scan_chars!(input, 'u', 'f', 'i', 'x', 'e', 'd'), + scan_choice!( + input, + scan_chars!(input, '2', '4', '8', 'x', '8'), + scan_chars!(input, '2', '4', '0', 'x', '8'), + scan_chars!(input, '2', '4', '0', 'x', '1', '6'), + scan_chars!(input, '2', '3', '2', 'x', '8'), + scan_chars!(input, '2', '3', '2', 'x', '2', '4'), + scan_chars!(input, '2', '3', '2', 'x', '1', '6'), + scan_chars!(input, '2', '2', '4', 'x', '8'), + scan_chars!(input, '2', '2', '4', 'x', '3', '2'), + scan_chars!(input, '2', '2', '4', 'x', '2', '4'), + scan_chars!(input, '2', '2', '4', 'x', '1', '6'), + scan_chars!(input, '2', '1', '6', 'x', '8'), + scan_chars!(input, '2', '1', '6', 'x', '4', '0'), + scan_chars!(input, '2', '1', '6', 'x', '3', '2'), + scan_chars!(input, '2', '1', '6', 'x', '2', '4'), + scan_chars!(input, '2', '1', '6', 'x', '1', '6'), + scan_chars!(input, '2', '0', '8', 'x', '8'), + scan_chars!(input, '2', '0', '8', 'x', '4', '8'), + scan_chars!(input, '2', '0', '8', 'x', '4', '0'), + scan_chars!(input, '2', '0', '8', 'x', '3', '2'), + scan_chars!(input, '2', '0', '8', 'x', '2', '4'), + scan_chars!(input, '2', '0', '8', 'x', '1', '6'), + scan_chars!(input, '2', '0', '0', 'x', '8'), + scan_chars!(input, '2', '0', '0', 'x', '5', '6'), + scan_chars!(input, '2', '0', '0', 'x', '4', '8'), + scan_chars!(input, '2', '0', '0', 'x', '4', '0'), + scan_chars!(input, '2', '0', '0', 'x', '3', '2'), + scan_chars!(input, '2', '0', '0', 'x', '2', '4'), + scan_chars!(input, '2', '0', '0', 'x', '1', '6'), + scan_chars!(input, '1', '9', '2', 'x', '8'), + scan_chars!(input, '1', '9', '2', 'x', '6', '4'), + scan_chars!(input, '1', '9', '2', 'x', '5', '6'), + scan_chars!(input, '1', '9', '2', 'x', '4', '8'), + scan_chars!(input, '1', '9', '2', 'x', '4', '0'), + scan_chars!(input, '1', '9', '2', 'x', '3', '2'), + scan_chars!(input, '1', '9', '2', 'x', '2', '4'), + scan_chars!(input, '1', '9', '2', 'x', '1', '6'), + scan_chars!(input, '1', '8', '4', 'x', '8'), + scan_chars!(input, '1', '8', '4', 'x', '7', '2'), + scan_chars!(input, '1', '8', '4', 'x', '6', '4'), + scan_chars!(input, '1', '8', '4', 'x', '5', '6'), + scan_chars!(input, '1', '8', '4', 'x', '4', '8'), + scan_chars!(input, '1', '8', '4', 'x', '4', '0'), + scan_chars!(input, '1', '8', '4', 'x', '3', '2'), + scan_chars!(input, '1', '8', '4', 'x', '2', '4'), + scan_chars!(input, '1', '8', '4', 'x', '1', '6') + ) + ) + } else { + false + }, + if self.version_is_at_least_0_4_14 && !self.version_is_at_least_0_7_1 { + scan_sequence!( + scan_chars!(input, 'u', 'f', 'i', 'x', 'e', 'd'), + scan_choice!( + input, + scan_chars!(input, '2', '5', '6', 'x', '8', '0'), + scan_chars!(input, '2', '5', '6', 'x', '8'), + scan_chars!(input, '2', '5', '6', 'x', '7', '2'), + scan_chars!(input, '2', '5', '6', 'x', '6', '4'), + scan_chars!(input, '2', '5', '6', 'x', '5', '6'), + scan_chars!(input, '2', '5', '6', 'x', '4', '8'), + scan_chars!(input, '2', '5', '6', 'x', '4', '0'), + scan_chars!(input, '2', '5', '6', 'x', '3', '2'), + scan_chars!(input, '2', '5', '6', 'x', '2', '4'), + scan_chars!(input, '2', '5', '6', 'x', '1', '6'), + scan_chars!(input, '2', '4', '8', 'x', '8', '0'), + scan_chars!(input, '2', '4', '8', 'x', '7', '2'), + scan_chars!(input, '2', '4', '8', 'x', '6', '4'), + scan_chars!(input, '2', '4', '8', 'x', '5', '6'), + scan_chars!(input, '2', '4', '8', 'x', '4', '8'), + scan_chars!(input, '2', '4', '8', 'x', '4', '0'), + scan_chars!(input, '2', '4', '8', 'x', '3', '2'), + scan_chars!(input, '2', '4', '8', 'x', '2', '4'), + scan_chars!(input, '2', '4', '8', 'x', '1', '6'), + scan_chars!(input, '2', '4', '0', 'x', '8', '0'), + scan_chars!(input, '2', '4', '0', 'x', '7', '2'), + scan_chars!(input, '2', '4', '0', 'x', '6', '4'), + scan_chars!(input, '2', '4', '0', 'x', '5', '6'), + scan_chars!(input, '2', '4', '0', 'x', '4', '8'), + scan_chars!(input, '2', '4', '0', 'x', '4', '0'), + scan_chars!(input, '2', '4', '0', 'x', '3', '2'), + scan_chars!(input, '2', '4', '0', 'x', '2', '4'), + scan_chars!(input, '2', '3', '2', 'x', '8', '0'), + scan_chars!(input, '2', '3', '2', 'x', '7', '2'), + scan_chars!(input, '2', '3', '2', 'x', '6', '4'), + scan_chars!(input, '2', '3', '2', 'x', '5', '6'), + scan_chars!(input, '2', '3', '2', 'x', '4', '8'), + scan_chars!(input, '2', '3', '2', 'x', '4', '0'), + scan_chars!(input, '2', '3', '2', 'x', '3', '2'), + scan_chars!(input, '2', '2', '4', 'x', '8', '0'), + scan_chars!(input, '2', '2', '4', 'x', '7', '2'), + scan_chars!(input, '2', '2', '4', 'x', '6', '4'), + scan_chars!(input, '2', '2', '4', 'x', '5', '6'), + scan_chars!(input, '2', '2', '4', 'x', '4', '8'), + scan_chars!(input, '2', '2', '4', 'x', '4', '0'), + scan_chars!(input, '2', '1', '6', 'x', '8', '0'), + scan_chars!(input, '2', '1', '6', 'x', '7', '2'), + scan_chars!(input, '2', '1', '6', 'x', '6', '4'), + scan_chars!(input, '2', '1', '6', 'x', '5', '6'), + scan_chars!(input, '2', '1', '6', 'x', '4', '8'), + scan_chars!(input, '2', '0', '8', 'x', '8', '0'), + scan_chars!(input, '2', '0', '8', 'x', '7', '2'), + scan_chars!(input, '2', '0', '8', 'x', '6', '4'), + scan_chars!(input, '2', '0', '8', 'x', '5', '6'), + scan_chars!(input, '2', '0', '0', 'x', '8', '0'), + scan_chars!(input, '2', '0', '0', 'x', '7', '2'), + scan_chars!(input, '2', '0', '0', 'x', '6', '4'), + scan_chars!(input, '1', '9', '2', 'x', '8', '0'), + scan_chars!(input, '1', '9', '2', 'x', '7', '2'), + scan_chars!(input, '1', '8', '4', 'x', '8', '0') + ) + ) + } else { + false + }, + if self.version_is_at_least_0_4_14 && !self.version_is_at_least_0_7_1 { + scan_sequence!( + scan_chars!(input, 'u', 'f', 'i', 'x', 'e', 'd'), + scan_choice!( + input, + scan_chars!(input, '9', '6'), + scan_chars!(input, '8', '8'), + scan_chars!(input, '8', '0'), + scan_chars!(input, '8'), + scan_chars!(input, '7', '2'), + scan_chars!(input, '6', '4'), + scan_chars!(input, '5', '6'), + scan_chars!(input, '4', '8'), + scan_chars!(input, '4', '0'), + scan_chars!(input, '3', '2'), + scan_chars!(input, '2', '5', '6'), + scan_chars!(input, '2', '4', '8'), + scan_chars!(input, '2', '4', '0'), + scan_chars!(input, '2', '4'), + scan_chars!(input, '2', '3', '2'), + scan_chars!(input, '2', '2', '4'), + scan_chars!(input, '2', '1', '6'), + scan_chars!(input, '2', '0', '8'), + scan_chars!(input, '2', '0', '0'), + scan_chars!(input, '1', '9', '2'), + scan_chars!(input, '1', '8', '4'), + scan_chars!(input, '1', '7', '6'), + scan_chars!(input, '1', '6', '8'), + scan_chars!(input, '1', '6', '0'), + scan_chars!(input, '1', '6'), + scan_chars!(input, '1', '5', '2'), + scan_chars!(input, '1', '4', '4'), + scan_chars!(input, '1', '3', '6'), + scan_chars!(input, '1', '2', '8'), + scan_chars!(input, '1', '2', '0'), + scan_chars!(input, '1', '1', '2'), + scan_chars!(input, '1', '0', '4') + ), + scan_chars!(input, 'x'), + scan_choice!( + input, + scan_chars!(input, '9'), + scan_chars!(input, '7', '9'), + scan_chars!(input, '7', '8'), + scan_chars!(input, '7', '7'), + scan_chars!(input, '7', '6'), + scan_chars!(input, '7', '5'), + scan_chars!(input, '7', '4'), + scan_chars!(input, '7', '3'), + scan_chars!(input, '7', '1'), + scan_chars!(input, '7', '0'), + scan_chars!(input, '7'), + scan_chars!(input, '6', '9'), + scan_chars!(input, '6', '8'), + scan_chars!(input, '6', '7'), + scan_chars!(input, '6', '6'), + scan_chars!(input, '6', '5'), + scan_chars!(input, '6', '3'), + scan_chars!(input, '6', '2'), + scan_chars!(input, '6', '1'), + scan_chars!(input, '6', '0'), + scan_chars!(input, '6'), + scan_chars!(input, '5', '9'), + scan_chars!(input, '5', '8'), + scan_chars!(input, '5', '7'), + scan_chars!(input, '5', '5'), + scan_chars!(input, '5', '4'), + scan_chars!(input, '5', '3'), + scan_chars!(input, '5', '2'), + scan_chars!(input, '5', '1'), + scan_chars!(input, '5', '0'), + scan_chars!(input, '5'), + scan_chars!(input, '4', '9'), + scan_chars!(input, '4', '7'), + scan_chars!(input, '4', '6'), + scan_chars!(input, '4', '5'), + scan_chars!(input, '4', '4'), + scan_chars!(input, '4', '3'), + scan_chars!(input, '4', '2'), + scan_chars!(input, '4', '1'), + scan_chars!(input, '4'), + scan_chars!(input, '3', '9'), + scan_chars!(input, '3', '8'), + scan_chars!(input, '3', '7'), + scan_chars!(input, '3', '6'), + scan_chars!(input, '3', '5'), + scan_chars!(input, '3', '4'), + scan_chars!(input, '3', '3'), + scan_chars!(input, '3', '1'), + scan_chars!(input, '3', '0'), + scan_chars!(input, '3'), + scan_chars!(input, '2', '9'), + scan_chars!(input, '2', '8'), + scan_chars!(input, '2', '7'), + scan_chars!(input, '2', '6'), + scan_chars!(input, '2', '5'), + scan_chars!(input, '2', '3'), + scan_chars!(input, '2', '2'), + scan_chars!(input, '2', '1'), + scan_chars!(input, '2', '0'), + scan_chars!(input, '2'), + scan_chars!(input, '1', '9'), + scan_chars!(input, '1', '8'), + scan_chars!(input, '1', '7'), + scan_chars!(input, '1', '5'), + scan_chars!(input, '1', '4'), + scan_chars!(input, '1', '3'), + scan_chars!(input, '1', '2'), + scan_chars!(input, '1', '1'), + scan_chars!(input, '1', '0'), + scan_chars!(input, '1'), + scan_chars!(input, '0') + ) + ) + } else { + false + } + ) + } + + #[allow(unused_assignments, unused_parens)] + fn yul_uint_keyword(&self, input: &mut ParserContext) -> bool { + if !self.version_is_at_least_0_7_1 { + scan_sequence!( + scan_chars!(input, 'u', 'i', 'n', 't'), + scan_optional!( + input, + scan_choice!( + input, + scan_chars!(input, '9', '6'), + scan_chars!(input, '8', '8'), + scan_chars!(input, '8', '0'), + scan_chars!(input, '8'), + scan_chars!(input, '7', '2'), + scan_chars!(input, '6', '4'), + scan_chars!(input, '5', '6'), + scan_chars!(input, '4', '8'), + scan_chars!(input, '4', '0'), + scan_chars!(input, '3', '2'), + scan_chars!(input, '2', '5', '6'), + scan_chars!(input, '2', '4', '8'), + scan_chars!(input, '2', '4', '0'), + scan_chars!(input, '2', '4'), + scan_chars!(input, '2', '3', '2'), + scan_chars!(input, '2', '2', '4'), + scan_chars!(input, '2', '1', '6'), + scan_chars!(input, '2', '0', '8'), + scan_chars!(input, '2', '0', '0'), + scan_chars!(input, '1', '9', '2'), + scan_chars!(input, '1', '8', '4'), + scan_chars!(input, '1', '7', '6'), + scan_chars!(input, '1', '6', '8'), + scan_chars!(input, '1', '6', '0'), + scan_chars!(input, '1', '6'), + scan_chars!(input, '1', '5', '2'), + scan_chars!(input, '1', '4', '4'), + scan_chars!(input, '1', '3', '6'), + scan_chars!(input, '1', '2', '8'), + scan_chars!(input, '1', '2', '0'), + scan_chars!(input, '1', '1', '2'), + scan_chars!(input, '1', '0', '4') + ) + ) + ) + } else { + false + } + } + pub fn scan(&self, lexical_context: LexicalContext, input: &str) -> Option { let mut input = ParserContext::new(input); match lexical_context { LexicalContext::Default => { Lexer::next_token::(self, &mut input) } - LexicalContext::VersionPragma => { - Lexer::next_token::(self, &mut input) - } - LexicalContext::YulBlock => { - Lexer::next_token::(self, &mut input) + LexicalContext::Pragma => { + Lexer::next_token::(self, &mut input) } + LexicalContext::Yul => Lexer::next_token::(self, &mut input), } } @@ -5957,7 +7611,6 @@ impl Language { 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), @@ -5986,6 +7639,7 @@ impl Language { } ProductionKind::DeleteStatement => Self::delete_statement.parse(self, input), ProductionKind::DoWhileStatement => Self::do_while_statement.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), @@ -6013,7 +7667,6 @@ impl Language { } ProductionKind::ForStatement => Self::for_statement.parse(self, input), ProductionKind::FunctionAttributes => Self::function_attributes.parse(self, input), - ProductionKind::FunctionCallOptions => Self::function_call_options.parse(self, input), ProductionKind::FunctionDefinition => Self::function_definition.parse(self, input), ProductionKind::FunctionType => Self::function_type.parse(self, input), ProductionKind::FunctionTypeAttributes => { @@ -6023,6 +7676,7 @@ impl Language { 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::ImportDeconstruction => Self::import_deconstruction.parse(self, input), ProductionKind::ImportDeconstructionSymbol => { Self::import_deconstruction_symbol.parse(self, input) @@ -6031,6 +7685,7 @@ impl Language { 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), @@ -6039,13 +7694,15 @@ impl Language { 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::MappingKeyType => Self::mapping_key_type.parse(self, input), + ProductionKind::MappingKey => Self::mapping_key.parse(self, input), ProductionKind::MappingType => Self::mapping_type.parse(self, input), - ProductionKind::MappingValueType => Self::mapping_value_type.parse(self, input), + ProductionKind::MappingValue => Self::mapping_value.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 => { Self::named_arguments_declaration.parse(self, input) @@ -6053,6 +7710,9 @@ impl Language { ProductionKind::NamedImport => Self::named_import.parse(self, input), ProductionKind::NewExpression => Self::new_expression.parse(self, input), ProductionKind::OverridePaths => Self::override_paths.parse(self, input), + ProductionKind::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), @@ -6061,6 +7721,9 @@ impl Language { } ProductionKind::PathImport => Self::path_import.parse(self, input), ProductionKind::PositionalArguments => Self::positional_arguments.parse(self, input), + ProductionKind::PositionalArgumentsDeclaration => { + Self::positional_arguments_declaration.parse(self, input) + } ProductionKind::PragmaDirective => Self::pragma_directive.parse(self, input), ProductionKind::ReceiveFunctionAttributes => { Self::receive_function_attributes.parse(self, input) @@ -6079,6 +7742,9 @@ impl Language { ProductionKind::StateVariableDefinition => { Self::state_variable_definition.parse(self, input) } + ProductionKind::StateVariableDefinitionValue => { + Self::state_variable_definition_value.parse(self, input) + } ProductionKind::Statements => Self::statements.parse(self, input), ProductionKind::StructDefinition => Self::struct_definition.parse(self, input), ProductionKind::StructMember => Self::struct_member.parse(self, input), @@ -6096,6 +7762,7 @@ impl Language { Self::tuple_deconstruction_statement.parse(self, input) } ProductionKind::TupleExpression => Self::tuple_expression.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), @@ -6114,6 +7781,7 @@ impl Language { ProductionKind::UserDefinedValueTypeDefinition => { Self::user_defined_value_type_definition.parse(self, input) } + ProductionKind::UsingAlias => Self::using_alias.parse(self, input), ProductionKind::UsingDeconstruction => Self::using_deconstruction.parse(self, input), ProductionKind::UsingDeconstructionSymbol => { Self::using_deconstruction_symbol.parse(self, input) @@ -6122,10 +7790,12 @@ impl Language { Self::using_deconstruction_symbols.parse(self, input) } ProductionKind::UsingDirective => Self::using_directive.parse(self, input), - ProductionKind::VariableDeclaration => Self::variable_declaration.parse(self, input), ProductionKind::VariableDeclarationStatement => { Self::variable_declaration_statement.parse(self, input) } + ProductionKind::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) @@ -6144,9 +7814,7 @@ impl Language { 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::YulDeclarationStatement => { - Self::yul_declaration_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 => { @@ -6154,19 +7822,26 @@ impl Language { } ProductionKind::YulIdentifierPath => Self::yul_identifier_path.parse(self, input), ProductionKind::YulIdentifierPaths => Self::yul_identifier_paths.parse(self, input), - ProductionKind::YulIdentifiers => Self::yul_identifiers.parse(self, input), ProductionKind::YulIfStatement => Self::yul_if_statement.parse(self, input), ProductionKind::YulLeaveStatement => Self::yul_leave_statement.parse(self, input), + ProductionKind::YulParameters => Self::yul_parameters.parse(self, input), ProductionKind::YulParametersDeclaration => { Self::yul_parameters_declaration.parse(self, input) } + ProductionKind::YulReturnVariables => Self::yul_return_variables.parse(self, input), ProductionKind::YulReturnsDeclaration => { Self::yul_returns_declaration.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 => { + Self::yul_variable_declaration_statement.parse(self, input) + } + ProductionKind::YulVariableDeclarationValue => { + Self::yul_variable_declaration_value.parse(self, input) + } } } } @@ -6187,8 +7862,8 @@ impl Lexer for Language { (TokenKind::OpenBracket, TokenKind::CloseBracket), (TokenKind::OpenParen, TokenKind::CloseParen), ], - LexicalContext::VersionPragma => &[], - LexicalContext::YulBlock => &[ + LexicalContext::Pragma => &[], + LexicalContext::Yul => &[ (TokenKind::OpenBrace, TokenKind::CloseBrace), (TokenKind::OpenParen, TokenKind::CloseParen), ], @@ -6216,17 +7891,8 @@ impl Lexer for Language { if let Some(kind) = match input.next() { Some('a') => match input.next() { - Some('b') => match input.next() { - Some('i') => scan_chars!(input, 'c', 'o', 'd', 'e', 'r') - .then_some(TokenKind::AbicoderKeyword), - Some('s') => scan_chars!(input, 't', 'r', 'a', 'c', 't') - .then_some(TokenKind::AbstractKeyword), - Some(_) => { - input.undo(); - None - } - None => None, - }, + Some('b') => scan_chars!(input, 's', 't', 'r', 'a', 'c', 't') + .then_some(TokenKind::AbstractKeyword), Some('d') => scan_chars!(input, 'd', 'r', 'e', 's', 's') .then_some(TokenKind::AddressKeyword), Some('f') => { @@ -6287,7 +7953,7 @@ impl Lexer for Language { Some('l') => { if self.version_is_at_least_0_5_0 { scan_chars!(input, 'l', 'd', 'a', 't', 'a') - .then_some(TokenKind::CalldataKeyword) + .then_some(TokenKind::CallDataKeyword) } else { None } @@ -6347,7 +8013,7 @@ impl Lexer for Language { Some('p') => { if self.version_is_at_least_0_5_0 { scan_chars!(input, 'y', 'o', 'f') - .then_some(TokenKind::CopyofKeyword) + .then_some(TokenKind::CopyOfKeyword) } else { None } @@ -6422,19 +8088,8 @@ impl Lexer for Language { Some('v') => { scan_chars!(input, 'e', 'n', 't').then_some(TokenKind::EventKeyword) } - Some('x') => match input.next() { - Some('p') => { - scan_chars!(input, 'e', 'r', 'i', 'm', 'e', 'n', 't', 'a', 'l') - .then_some(TokenKind::ExperimentalKeyword) - } - Some('t') => scan_chars!(input, 'e', 'r', 'n', 'a', 'l') - .then_some(TokenKind::ExternalKeyword), - Some(_) => { - input.undo(); - None - } - None => None, - }, + Some('x') => scan_chars!(input, 't', 'e', 'r', 'n', 'a', 'l') + .then_some(TokenKind::ExternalKeyword), Some(_) => { input.undo(); None @@ -6604,21 +8259,7 @@ impl Lexer for Language { None => None, }, Some('l') => match input.next() { - Some('e') => match input.next() { - Some('a') => { - if self.version_is_at_least_0_6_0 { - scan_chars!(input, 'v', 'e').then_some(TokenKind::LeaveKeyword) - } else { - None - } - } - Some('t') => Some(TokenKind::LetKeyword), - Some(_) => { - input.undo(); - None - } - None => None, - }, + Some('e') => scan_chars!(input, 't').then_some(TokenKind::LetKeyword), Some('i') => scan_chars!(input, 'b', 'r', 'a', 'r', 'y') .then_some(TokenKind::LibraryKeyword), Some(_) => { @@ -6821,13 +8462,11 @@ impl Lexer for Language { Some('i') => { if self.version_is_at_least_0_5_0 { scan_chars!(input, 'z', 'e', 'o', 'f') - .then_some(TokenKind::SizeofKeyword) + .then_some(TokenKind::SizeOfKeyword) } else { None } } - Some('o') => scan_chars!(input, 'l', 'i', 'd', 'i', 't', 'y') - .then_some(TokenKind::SolidityKeyword), Some('t') => { match input.next() { Some('a') => scan_chars!(input, 't', 'i', 'c') @@ -6894,13 +8533,13 @@ impl Lexer for Language { Some('d') => { if self.version_is_at_least_0_5_0 { scan_chars!(input, 'e', 'f') - .then_some(TokenKind::TypedefKeyword) + .then_some(TokenKind::TypeDefKeyword) } else { None } } Some('o') => { - scan_chars!(input, 'f').then_some(TokenKind::TypeofKeyword) + scan_chars!(input, 'f').then_some(TokenKind::TypeOfKeyword) } Some(_) => { input.undo(); @@ -6999,30 +8638,16 @@ impl Lexer for Language { input.set_position(save); if let Some(kind) = match input.next() { - Some('!') => match input.next() { - Some('=') => Some(TokenKind::BangEqual), - Some(_) => { - input.undo(); - Some(TokenKind::Bang) - } - None => Some(TokenKind::Bang), - }, - Some('%') => match input.next() { - Some('=') => Some(TokenKind::PercentEqual), - Some(_) => { - input.undo(); - Some(TokenKind::Percent) - } - None => Some(TokenKind::Percent), - }, + Some('!') => scan_chars!(input, '=').then_some(TokenKind::BangEqual), + Some('%') => scan_chars!(input, '=').then_some(TokenKind::PercentEqual), Some('&') => match input.next() { Some('&') => Some(TokenKind::AmpersandAmpersand), Some('=') => Some(TokenKind::AmpersandEqual), Some(_) => { input.undo(); - Some(TokenKind::Ampersand) + None } - None => Some(TokenKind::Ampersand), + None => None, }, Some('(') => Some(TokenKind::OpenParen), Some(')') => Some(TokenKind::CloseParen), @@ -7031,18 +8656,18 @@ impl Lexer for Language { Some('=') => Some(TokenKind::AsteriskEqual), Some(_) => { input.undo(); - Some(TokenKind::Asterisk) + None } - None => Some(TokenKind::Asterisk), + None => None, }, Some('+') => match input.next() { Some('+') => Some(TokenKind::PlusPlus), Some('=') => Some(TokenKind::PlusEqual), Some(_) => { input.undo(); - Some(TokenKind::Plus) + None } - None => Some(TokenKind::Plus), + None => None, }, Some(',') => Some(TokenKind::Comma), Some('-') => match input.next() { @@ -7050,92 +8675,64 @@ impl Lexer for Language { Some('=') => Some(TokenKind::MinusEqual), Some(_) => { input.undo(); - Some(TokenKind::Minus) + None } - None => Some(TokenKind::Minus), + None => None, }, Some('.') => Some(TokenKind::Period), - Some('/') => match input.next() { - Some('=') => Some(TokenKind::SlashEqual), - Some(_) => { - input.undo(); - Some(TokenKind::Slash) - } - None => Some(TokenKind::Slash), - }, - Some(':') => Some(TokenKind::Colon), + Some('/') => scan_chars!(input, '=').then_some(TokenKind::SlashEqual), Some(';') => Some(TokenKind::Semicolon), Some('<') => match input.next() { - Some('<') => match input.next() { - Some('=') => Some(TokenKind::LessThanLessThanEqual), - Some(_) => { - input.undo(); - Some(TokenKind::LessThanLessThan) - } - None => Some(TokenKind::LessThanLessThan), - }, + Some('<') => { + scan_chars!(input, '=').then_some(TokenKind::LessThanLessThanEqual) + } Some('=') => Some(TokenKind::LessThanEqual), Some(_) => { input.undo(); - Some(TokenKind::LessThan) + None } - None => Some(TokenKind::LessThan), + None => None, }, Some('=') => match input.next() { Some('=') => Some(TokenKind::EqualEqual), Some('>') => Some(TokenKind::EqualGreaterThan), Some(_) => { input.undo(); - Some(TokenKind::Equal) + None } - None => Some(TokenKind::Equal), + None => None, }, Some('>') => match input.next() { Some('=') => Some(TokenKind::GreaterThanEqual), Some('>') => match input.next() { Some('=') => Some(TokenKind::GreaterThanGreaterThanEqual), - Some('>') => match input.next() { - Some('=') => { - Some(TokenKind::GreaterThanGreaterThanGreaterThanEqual) - } - Some(_) => { - input.undo(); - Some(TokenKind::GreaterThanGreaterThanGreaterThan) - } - None => Some(TokenKind::GreaterThanGreaterThanGreaterThan), - }, + Some('>') => scan_chars!(input, '=') + .then_some(TokenKind::GreaterThanGreaterThanGreaterThanEqual), Some(_) => { input.undo(); - Some(TokenKind::GreaterThanGreaterThan) + None } - None => Some(TokenKind::GreaterThanGreaterThan), + None => None, }, Some(_) => { input.undo(); - Some(TokenKind::GreaterThan) + None } - None => Some(TokenKind::GreaterThan), + None => None, }, Some('?') => Some(TokenKind::QuestionMark), Some('[') => Some(TokenKind::OpenBracket), Some(']') => Some(TokenKind::CloseBracket), - Some('^') => match input.next() { - Some('=') => Some(TokenKind::CaretEqual), - Some(_) => { - input.undo(); - Some(TokenKind::Caret) - } - None => Some(TokenKind::Caret), - }, + Some('^') => scan_chars!(input, '=').then_some(TokenKind::CaretEqual), Some('{') => Some(TokenKind::OpenBrace), Some('|') => match input.next() { Some('=') => Some(TokenKind::BarEqual), Some('|') => Some(TokenKind::BarBar), Some(_) => { input.undo(); - Some(TokenKind::Bar) + None } - None => Some(TokenKind::Bar), + None => None, }, Some('}') => Some(TokenKind::CloseBrace), Some('~') => Some(TokenKind::Tilde), @@ -7151,16 +8748,32 @@ impl Lexer for Language { input.set_position(save); longest_match! { + { Ampersand = ampersand } { AsciiStringLiteral = ascii_string_literal } + { Asterisk = asterisk } + { Bang = bang } + { Bar = bar } { BytesKeyword = bytes_keyword } + { Caret = caret } + { Colon = colon } { DecimalLiteral = decimal_literal } { EndOfLine = end_of_line } + { Equal = equal } { FixedKeyword = fixed_keyword } + { GreaterThan = greater_than } + { GreaterThanGreaterThan = greater_than_greater_than } + { GreaterThanGreaterThanGreaterThan = greater_than_greater_than_greater_than } { HexLiteral = hex_literal } { HexStringLiteral = hex_string_literal } { IntKeyword = int_keyword } + { LessThan = less_than } + { LessThanLessThan = less_than_less_than } + { Minus = minus } { MultilineComment = multiline_comment } + { Percent = percent } + { Plus = plus } { SingleLineComment = single_line_comment } + { Slash = slash } { UfixedKeyword = ufixed_keyword } { UintKeyword = uint_keyword } { UnicodeStringLiteral = unicode_string_literal } @@ -7168,7 +8781,7 @@ impl Lexer for Language { { Identifier = identifier } } } - LexicalContext::VersionPragma => { + LexicalContext::Pragma => { macro_rules! longest_match { ($( { $kind:ident = $function:ident } )*) => { $( @@ -7181,9 +8794,23 @@ impl Lexer for Language { }; } - if let Some(kind) = scan_chars!(input, 's', 'o', 'l', 'i', 'd', 'i', 't', 'y') - .then_some(TokenKind::SolidityKeyword) - { + if let Some(kind) = match input.next() { + Some('a') => scan_chars!(input, 'b', 'i', 'c', 'o', 'd', 'e', 'r') + .then_some(TokenKind::AbicoderKeyword), + Some('e') => { + scan_chars!(input, 'x', 'p', 'e', 'r', 'i', 'm', 'e', 'n', 't', 'a', 'l') + .then_some(TokenKind::ExperimentalKeyword) + } + Some('p') => scan_chars!(input, 'r', 'a', 'g', 'm', 'a') + .then_some(TokenKind::PragmaKeyword), + Some('s') => scan_chars!(input, 'o', 'l', 'i', 'd', 'i', 't', 'y') + .then_some(TokenKind::SolidityKeyword), + Some(_) => { + input.undo(); + None + } + None => None, + } { // Make sure that this is not the start of an identifier if !self.identifier_part(input) { furthest_position = input.position(); @@ -7193,26 +8820,10 @@ impl Lexer for Language { input.set_position(save); if let Some(kind) = match input.next() { - Some('-') => Some(TokenKind::Minus), Some('.') => Some(TokenKind::Period), - Some('<') => match input.next() { - Some('=') => Some(TokenKind::LessThanEqual), - Some(_) => { - input.undo(); - Some(TokenKind::LessThan) - } - None => Some(TokenKind::LessThan), - }, - Some('=') => Some(TokenKind::Equal), - Some('>') => match input.next() { - Some('=') => Some(TokenKind::GreaterThanEqual), - Some(_) => { - input.undo(); - Some(TokenKind::GreaterThan) - } - None => Some(TokenKind::GreaterThan), - }, - Some('^') => Some(TokenKind::Caret), + Some(';') => Some(TokenKind::Semicolon), + Some('<') => scan_chars!(input, '=').then_some(TokenKind::LessThanEqual), + Some('>') => scan_chars!(input, '=').then_some(TokenKind::GreaterThanEqual), Some('|') => scan_chars!(input, '|').then_some(TokenKind::BarBar), Some('~') => Some(TokenKind::Tilde), Some(_) => { @@ -7227,10 +8838,17 @@ impl Lexer for Language { input.set_position(save); longest_match! { + { AsciiStringLiteral = ascii_string_literal } + { Caret = caret } + { Equal = equal } + { GreaterThan = greater_than } + { LessThan = less_than } + { Minus = minus } { VersionPragmaValue = version_pragma_value } + { Identifier = identifier } } } - LexicalContext::YulBlock => { + LexicalContext::Yul => { macro_rules! longest_match { ($( { $kind:ident = $function:ident } )*) => { $( @@ -7244,62 +8862,1097 @@ impl Lexer for Language { } if let Some(kind) = match input.next() { - Some('b') => { - scan_chars!(input, 'r', 'e', 'a', 'k').then_some(TokenKind::BreakKeyword) - } - Some('c') => match input.next() { - Some('a') => scan_chars!(input, 's', 'e').then_some(TokenKind::CaseKeyword), - Some('o') => scan_chars!(input, 'n', 't', 'i', 'n', 'u', 'e') - .then_some(TokenKind::ContinueKeyword), + Some('a') => match input.next() { + Some('b') => { + if !self.version_is_at_least_0_7_1 { + scan_chars!(input, 's', 't', 'r', 'a', 'c', 't') + .then_some(TokenKind::YulAbstractKeyword) + } else { + None + } + } + Some('d') => scan_chars!(input, 'd', 'r', 'e', 's', 's') + .then_some(TokenKind::YulAddressKeyword), + Some('f') => { + if !self.version_is_at_least_0_7_1 { + scan_chars!(input, 't', 'e', 'r') + .then_some(TokenKind::YulAfterKeyword) + } else { + None + } + } + Some('l') => { + if self.version_is_at_least_0_5_0 && !self.version_is_at_least_0_7_1 { + scan_chars!(input, 'i', 'a', 's') + .then_some(TokenKind::YulAliasKeyword) + } else { + None + } + } + Some('n') => { + if !self.version_is_at_least_0_7_1 { + scan_chars!(input, 'o', 'n', 'y', 'm', 'o', 'u', 's') + .then_some(TokenKind::YulAnonymousKeyword) + } else { + None + } + } + Some('p') => { + if self.version_is_at_least_0_5_0 && !self.version_is_at_least_0_7_1 { + scan_chars!(input, 'p', 'l', 'y') + .then_some(TokenKind::YulApplyKeyword) + } else { + None + } + } + Some('s') => match input.next() { + Some('s') => { + if !self.version_is_at_least_0_7_1 { + scan_chars!(input, 'e', 'm', 'b', 'l', 'y') + .then_some(TokenKind::YulAssemblyKeyword) + } else { + None + } + } + Some(_) => { + input.undo(); + if !self.version_is_at_least_0_7_1 { + Some(TokenKind::YulAsKeyword) + } else { + None + } + } + None => { + if !self.version_is_at_least_0_7_1 { + Some(TokenKind::YulAsKeyword) + } else { + None + } + } + }, + Some('u') => { + if self.version_is_at_least_0_5_0 && !self.version_is_at_least_0_7_1 { + scan_chars!(input, 't', 'o').then_some(TokenKind::YulAutoKeyword) + } else { + None + } + } Some(_) => { input.undo(); None } None => None, }, - Some('d') => scan_chars!(input, 'e', 'f', 'a', 'u', 'l', 't') - .then_some(TokenKind::DefaultKeyword), - Some('f') => match input.next() { - Some('a') => { - scan_chars!(input, 'l', 's', 'e').then_some(TokenKind::FalseKeyword) + Some('b') => match input.next() { + Some('o') => { + if !self.version_is_at_least_0_5_10 { + scan_chars!(input, 'o', 'l').then_some(TokenKind::YulBoolKeyword) + } else { + None + } + } + Some('r') => { + scan_chars!(input, 'e', 'a', 'k').then_some(TokenKind::YulBreakKeyword) + } + Some('y') => { + scan_chars!(input, 't', 'e').then_some(TokenKind::YulByteKeyword) } - Some('o') => scan_chars!(input, 'r').then_some(TokenKind::ForKeyword), - Some('u') => scan_chars!(input, 'n', 'c', 't', 'i', 'o', 'n') - .then_some(TokenKind::FunctionKeyword), Some(_) => { input.undo(); None } None => None, }, - Some('h') => scan_chars!(input, 'e', 'x').then_some(TokenKind::HexKeyword), - Some('i') => scan_chars!(input, 'f').then_some(TokenKind::IfKeyword), - Some('l') => { - if scan_chars!(input, 'e') { - match input.next() { - Some('a') => { - if self.version_is_at_least_0_6_0 { - scan_chars!(input, 'v', 'e') - .then_some(TokenKind::LeaveKeyword) + Some('c') => match input.next() { + Some('a') => match input.next() { + Some('l') => { + if self.version_is_at_least_0_5_0 && !self.version_is_at_least_0_7_1 + { + scan_chars!(input, 'l', 'd', 'a', 't', 'a') + .then_some(TokenKind::YulCallDataKeyword) + } else { + None + } + } + Some('s') => { + scan_chars!(input, 'e').then_some(TokenKind::YulCaseKeyword) + } + Some('t') => { + if !self.version_is_at_least_0_7_1 { + scan_chars!(input, 'c', 'h') + .then_some(TokenKind::YulCatchKeyword) + } else { + None + } + } + Some(_) => { + input.undo(); + None + } + None => None, + }, + Some('o') => match input.next() { + Some('n') => match input.next() { + Some('s') => { + if scan_chars!(input, 't') { + match input.next() { + Some('a') => { + if !self.version_is_at_least_0_7_1 { + scan_chars!(input, 'n', 't') + .then_some(TokenKind::YulConstantKeyword) + } else { + None + } + } + Some('r') => { + if self.version_is_at_least_0_5_0 + && !self.version_is_at_least_0_7_1 + { + scan_chars!(input, 'u', 'c', 't', 'o', 'r') + .then_some(TokenKind::YulConstructorKeyword) + } else { + None + } + } + Some(_) => { + input.undo(); + None + } + None => None, + } + } else { + None + } + } + Some('t') => match input.next() { + Some('i') => scan_chars!(input, 'n', 'u', 'e') + .then_some(TokenKind::YulContinueKeyword), + Some('r') => { + if !self.version_is_at_least_0_7_1 { + scan_chars!(input, 'a', 'c', 't') + .then_some(TokenKind::YulContractKeyword) + } else { + None + } + } + Some(_) => { + input.undo(); + None + } + None => None, + }, + Some(_) => { + input.undo(); + None + } + None => None, + }, + Some('p') => { + if self.version_is_at_least_0_5_0 && !self.version_is_at_least_0_7_1 + { + scan_chars!(input, 'y', 'o', 'f') + .then_some(TokenKind::YulCopyOfKeyword) + } else { + None + } + } + Some(_) => { + input.undo(); + None + } + None => None, + }, + Some(_) => { + input.undo(); + None + } + None => None, + }, + Some('d') => match input.next() { + Some('a') => { + if !self.version_is_at_least_0_7_1 { + scan_chars!(input, 'y', 's').then_some(TokenKind::YulDaysKeyword) + } else { + None + } + } + Some('e') => match input.next() { + Some('f') => match input.next() { + Some('a') => scan_chars!(input, 'u', 'l', 't') + .then_some(TokenKind::YulDefaultKeyword), + Some('i') => { + if self.version_is_at_least_0_5_0 + && !self.version_is_at_least_0_7_1 + { + scan_chars!(input, 'n', 'e') + .then_some(TokenKind::YulDefineKeyword) } else { None } } - Some('t') => Some(TokenKind::LetKeyword), Some(_) => { input.undo(); None } None => None, + }, + Some('l') => { + if !self.version_is_at_least_0_7_1 { + scan_chars!(input, 'e', 't', 'e') + .then_some(TokenKind::YulDeleteKeyword) + } else { + None + } } - } else { + Some(_) => { + input.undo(); + None + } + None => None, + }, + Some('o') => { + if !self.version_is_at_least_0_7_1 { + Some(TokenKind::YulDoKeyword) + } else { + None + } + } + Some(_) => { + input.undo(); + None + } + None => None, + }, + Some('e') => match input.next() { + Some('l') => { + if !self.version_is_at_least_0_7_1 { + scan_chars!(input, 's', 'e').then_some(TokenKind::YulElseKeyword) + } else { + None + } + } + Some('m') => { + if self.version_is_at_least_0_5_0 && !self.version_is_at_least_0_7_1 { + scan_chars!(input, 'i', 't').then_some(TokenKind::YulEmitKeyword) + } else { + None + } + } + Some('n') => { + if !self.version_is_at_least_0_7_1 { + scan_chars!(input, 'u', 'm').then_some(TokenKind::YulEnumKeyword) + } else { + None + } + } + Some('t') => { + if !self.version_is_at_least_0_7_1 { + scan_chars!(input, 'h', 'e', 'r') + .then_some(TokenKind::YulEtherKeyword) + } else { + None + } + } + Some('v') => { + if !self.version_is_at_least_0_7_1 { + scan_chars!(input, 'e', 'n', 't') + .then_some(TokenKind::YulEventKeyword) + } else { + None + } + } + Some('x') => { + if !self.version_is_at_least_0_7_1 { + scan_chars!(input, 't', 'e', 'r', 'n', 'a', 'l') + .then_some(TokenKind::YulExternalKeyword) + } else { + None + } + } + Some(_) => { + input.undo(); + None + } + None => None, + }, + Some('f') => match input.next() { + Some('a') => { + if scan_chars!(input, 'l') { + match input.next() { + Some('l') => { + if self.version_is_at_least_0_6_0 + && !self.version_is_at_least_0_7_1 + { + scan_chars!(input, 'b', 'a', 'c', 'k') + .then_some(TokenKind::YulFallbackKeyword) + } else { + None + } + } + Some('s') => scan_chars!(input, 'e') + .then_some(TokenKind::YulFalseKeyword), + Some(_) => { + input.undo(); + None + } + None => None, + } + } else { + None + } + } + Some('i') => { + if scan_chars!(input, 'n') { + match input.next() { + Some('a') => { + if !self.version_is_at_least_0_7_1 { + scan_chars!(input, 'l') + .then_some(TokenKind::YulFinalKeyword) + } else { + None + } + } + Some('n') => { + if !self.version_is_at_least_0_7_0 { + scan_chars!(input, 'e', 'y') + .then_some(TokenKind::YulFinneyKeyword) + } else { + None + } + } + Some(_) => { + input.undo(); + None + } + None => None, + } + } else { + None + } + } + Some('o') => scan_chars!(input, 'r').then_some(TokenKind::YulForKeyword), + Some('u') => scan_chars!(input, 'n', 'c', 't', 'i', 'o', 'n') + .then_some(TokenKind::YulFunctionKeyword), + Some(_) => { + input.undo(); + None + } + None => None, + }, + Some('g') => { + if self.version_is_at_least_0_7_0 && !self.version_is_at_least_0_7_1 { + scan_chars!(input, 'w', 'e', 'i').then_some(TokenKind::YulGweiKeyword) + } else { + None + } + } + Some('h') => match input.next() { + Some('e') => scan_chars!(input, 'x').then_some(TokenKind::YulHexKeyword), + Some('o') => { + if !self.version_is_at_least_0_7_1 { + scan_chars!(input, 'u', 'r', 's') + .then_some(TokenKind::YulHoursKeyword) + } else { + None + } + } + Some(_) => { + input.undo(); + None + } + None => None, + }, + Some('i') => match input.next() { + Some('f') => Some(TokenKind::YulIfKeyword), + Some('m') => match input.next() { + Some('m') => { + if self.version_is_at_least_0_5_0 && !self.version_is_at_least_0_7_1 + { + scan_chars!(input, 'u', 't', 'a', 'b', 'l', 'e') + .then_some(TokenKind::YulImmutableKeyword) + } else { + None + } + } + Some('p') => match input.next() { + Some('l') => { + if self.version_is_at_least_0_5_0 + && !self.version_is_at_least_0_7_1 + { + scan_chars!(input, 'e', 'm', 'e', 'n', 't', 's') + .then_some(TokenKind::YulImplementsKeyword) + } else { + None + } + } + Some('o') => { + if !self.version_is_at_least_0_7_1 { + scan_chars!(input, 'r', 't') + .then_some(TokenKind::YulImportKeyword) + } else { + None + } + } + Some(_) => { + input.undo(); + None + } + None => None, + }, + Some(_) => { + input.undo(); + None + } + None => None, + }, + Some('n') => match input.next() { + Some('d') => { + if !self.version_is_at_least_0_7_1 { + scan_chars!(input, 'e', 'x', 'e', 'd') + .then_some(TokenKind::YulIndexedKeyword) + } else { + None + } + } + Some('l') => { + if !self.version_is_at_least_0_7_1 { + scan_chars!(input, 'i', 'n', 'e') + .then_some(TokenKind::YulInlineKeyword) + } else { + None + } + } + Some('t') => { + if scan_chars!(input, 'e', 'r') { + match input.next() { + Some('f') => { + if !self.version_is_at_least_0_7_1 { + scan_chars!(input, 'a', 'c', 'e') + .then_some(TokenKind::YulInterfaceKeyword) + } else { + None + } + } + Some('n') => { + if !self.version_is_at_least_0_7_1 { + scan_chars!(input, 'a', 'l') + .then_some(TokenKind::YulInternalKeyword) + } else { + None + } + } + Some(_) => { + input.undo(); + None + } + None => None, + } + } else { + None + } + } + Some(_) => { + input.undo(); + if !self.version_is_at_least_0_6_8 { + Some(TokenKind::YulInKeyword) + } else { + None + } + } + None => { + if !self.version_is_at_least_0_6_8 { + Some(TokenKind::YulInKeyword) + } else { + None + } + } + }, + Some('s') => { + if !self.version_is_at_least_0_7_1 { + Some(TokenKind::YulIsKeyword) + } else { + None + } + } + Some(_) => { + input.undo(); + None + } + None => None, + }, + Some('l') => match input.next() { + Some('e') => match input.next() { + Some('a') => { + if self.version_is_at_least_0_6_0 { + scan_chars!(input, 'v', 'e') + .then_some(TokenKind::YulLeaveKeyword) + } else { + None + } + } + Some('t') => Some(TokenKind::YulLetKeyword), + Some(_) => { + input.undo(); + None + } + None => None, + }, + Some('i') => { + if !self.version_is_at_least_0_7_1 { + scan_chars!(input, 'b', 'r', 'a', 'r', 'y') + .then_some(TokenKind::YulLibraryKeyword) + } else { + None + } + } + Some(_) => { + input.undo(); + None + } + None => None, + }, + Some('m') => match input.next() { + Some('a') => match input.next() { + Some('c') => { + if self.version_is_at_least_0_5_0 && !self.version_is_at_least_0_7_1 + { + scan_chars!(input, 'r', 'o') + .then_some(TokenKind::YulMacroKeyword) + } else { + None + } + } + Some('p') => { + if !self.version_is_at_least_0_7_1 { + scan_chars!(input, 'p', 'i', 'n', 'g') + .then_some(TokenKind::YulMappingKeyword) + } else { + None + } + } + Some('t') => { + if !self.version_is_at_least_0_7_1 { + scan_chars!(input, 'c', 'h') + .then_some(TokenKind::YulMatchKeyword) + } else { + None + } + } + Some(_) => { + input.undo(); + None + } + None => None, + }, + Some('e') => { + if !self.version_is_at_least_0_7_1 { + scan_chars!(input, 'm', 'o', 'r', 'y') + .then_some(TokenKind::YulMemoryKeyword) + } else { + None + } + } + Some('i') => { + if !self.version_is_at_least_0_7_1 { + scan_chars!(input, 'n', 'u', 't', 'e', 's') + .then_some(TokenKind::YulMinutesKeyword) + } else { + None + } + } + Some('o') => { + if !self.version_is_at_least_0_7_1 { + scan_chars!(input, 'd', 'i', 'f', 'i', 'e', 'r') + .then_some(TokenKind::YulModifierKeyword) + } else { + None + } + } + Some('u') => { + if self.version_is_at_least_0_5_0 && !self.version_is_at_least_0_7_1 { + scan_chars!(input, 't', 'a', 'b', 'l', 'e') + .then_some(TokenKind::YulMutableKeyword) + } else { + None + } + } + Some(_) => { + input.undo(); + None + } + None => None, + }, + Some('n') => match input.next() { + Some('e') => { + if !self.version_is_at_least_0_7_1 { + scan_chars!(input, 'w').then_some(TokenKind::YulNewKeyword) + } else { + None + } + } + Some('u') => { + if !self.version_is_at_least_0_7_1 { + scan_chars!(input, 'l', 'l').then_some(TokenKind::YulNullKeyword) + } else { + None + } + } + Some(_) => { + input.undo(); + None + } + None => None, + }, + Some('o') => match input.next() { + Some('f') => { + if !self.version_is_at_least_0_7_1 { + Some(TokenKind::YulOfKeyword) + } else { + None + } + } + Some('v') => { + if self.version_is_at_least_0_5_0 && !self.version_is_at_least_0_7_1 { + scan_chars!(input, 'e', 'r', 'r', 'i', 'd', 'e') + .then_some(TokenKind::YulOverrideKeyword) + } else { + None + } + } + Some(_) => { + input.undo(); + None + } + None => None, + }, + Some('p') => match input.next() { + Some('a') => match input.next() { + Some('r') => { + if self.version_is_at_least_0_5_0 && !self.version_is_at_least_0_7_1 + { + scan_chars!(input, 't', 'i', 'a', 'l') + .then_some(TokenKind::YulPartialKeyword) + } else { + None + } + } + Some('y') => { + if !self.version_is_at_least_0_7_1 { + scan_chars!(input, 'a', 'b', 'l', 'e') + .then_some(TokenKind::YulPayableKeyword) + } else { + None + } + } + Some(_) => { + input.undo(); + None + } + None => None, + }, + Some('r') => match input.next() { + Some('a') => { + if !self.version_is_at_least_0_7_1 { + scan_chars!(input, 'g', 'm', 'a') + .then_some(TokenKind::YulPragmaKeyword) + } else { + None + } + } + Some('i') => { + if !self.version_is_at_least_0_7_1 { + scan_chars!(input, 'v', 'a', 't', 'e') + .then_some(TokenKind::YulPrivateKeyword) + } else { + None + } + } + Some('o') => { + if self.version_is_at_least_0_5_0 && !self.version_is_at_least_0_7_1 + { + scan_chars!(input, 'm', 'i', 's', 'e') + .then_some(TokenKind::YulPromiseKeyword) + } else { + None + } + } + Some(_) => { + input.undo(); + None + } + None => None, + }, + Some('u') => match input.next() { + Some('b') => { + if !self.version_is_at_least_0_7_1 { + scan_chars!(input, 'l', 'i', 'c') + .then_some(TokenKind::YulPublicKeyword) + } else { + None + } + } + Some('r') => { + if !self.version_is_at_least_0_7_1 { + scan_chars!(input, 'e').then_some(TokenKind::YulPureKeyword) + } else { + None + } + } + Some(_) => { + input.undo(); + None + } + None => None, + }, + Some(_) => { + input.undo(); + None + } + None => None, + }, + Some('r') => { + if scan_chars!(input, 'e') { + match input.next() { + Some('c') => { + if self.version_is_at_least_0_6_0 + && !self.version_is_at_least_0_7_1 + { + scan_chars!(input, 'e', 'i', 'v', 'e') + .then_some(TokenKind::YulReceiveKeyword) + } else { + None + } + } + Some('f') => { + if self.version_is_at_least_0_5_0 + && !self.version_is_at_least_0_7_1 + { + scan_chars!(input, 'e', 'r', 'e', 'n', 'c', 'e') + .then_some(TokenKind::YulReferenceKeyword) + } else { + None + } + } + Some('l') => { + if !self.version_is_at_least_0_7_1 { + scan_chars!(input, 'o', 'c', 'a', 't', 'a', 'b', 'l', 'e') + .then_some(TokenKind::YulRelocatableKeyword) + } else { + None + } + } + Some('t') => { + if scan_chars!(input, 'u', 'r', 'n') { + match input.next() { + Some('s') => { + if !self.version_is_at_least_0_7_1 { + Some(TokenKind::YulReturnsKeyword) + } else { + None + } + } + Some(_) => { + input.undo(); + Some(TokenKind::YulReturnKeyword) + } + None => Some(TokenKind::YulReturnKeyword), + } + } else { + None + } + } + Some('v') => scan_chars!(input, 'e', 'r', 't') + .then_some(TokenKind::YulRevertKeyword), + Some(_) => { + input.undo(); + None + } + None => None, + } + } else { + None + } + } + Some('s') => match input.next() { + Some('e') => match input.next() { + Some('a') => { + if self.version_is_at_least_0_5_0 && !self.version_is_at_least_0_7_1 + { + scan_chars!(input, 'l', 'e', 'd') + .then_some(TokenKind::YulSealedKeyword) + } else { + None + } + } + Some('c') => { + if !self.version_is_at_least_0_7_1 { + scan_chars!(input, 'o', 'n', 'd', 's') + .then_some(TokenKind::YulSecondsKeyword) + } else { + None + } + } + Some(_) => { + input.undo(); + None + } + None => None, + }, + Some('i') => { + if self.version_is_at_least_0_5_0 && !self.version_is_at_least_0_7_1 { + scan_chars!(input, 'z', 'e', 'o', 'f') + .then_some(TokenKind::YulSizeOfKeyword) + } else { + None + } + } + Some('t') => match input.next() { + Some('a') => { + if !self.version_is_at_least_0_7_1 { + scan_chars!(input, 't', 'i', 'c') + .then_some(TokenKind::YulStaticKeyword) + } else { + None + } + } + Some('o') => { + if !self.version_is_at_least_0_7_1 { + scan_chars!(input, 'r', 'a', 'g', 'e') + .then_some(TokenKind::YulStorageKeyword) + } else { + None + } + } + Some('r') => match input.next() { + Some('i') => { + if !self.version_is_at_least_0_7_1 { + scan_chars!(input, 'n', 'g') + .then_some(TokenKind::YulStringKeyword) + } else { + None + } + } + Some('u') => { + if !self.version_is_at_least_0_7_1 { + scan_chars!(input, 'c', 't') + .then_some(TokenKind::YulStructKeyword) + } else { + None + } + } + Some(_) => { + input.undo(); + None + } + None => None, + }, + Some(_) => { + input.undo(); + None + } + None => None, + }, + Some('u') => { + if self.version_is_at_least_0_5_0 && !self.version_is_at_least_0_7_1 { + scan_chars!(input, 'p', 'p', 'o', 'r', 't', 's') + .then_some(TokenKind::YulSupportsKeyword) + } else { + None + } + } + Some('w') => scan_chars!(input, 'i', 't', 'c', 'h') + .then_some(TokenKind::YulSwitchKeyword), + Some('z') => { + if !self.version_is_at_least_0_7_0 { + scan_chars!(input, 'a', 'b', 'o') + .then_some(TokenKind::YulSzaboKeyword) + } else { + None + } + } + Some(_) => { + input.undo(); + None + } + None => None, + }, + Some('t') => match input.next() { + Some('h') => { + if !self.version_is_at_least_0_7_1 { + scan_chars!(input, 'r', 'o', 'w') + .then_some(TokenKind::YulThrowKeyword) + } else { + None + } + } + Some('r') => match input.next() { + Some('u') => { + scan_chars!(input, 'e').then_some(TokenKind::YulTrueKeyword) + } + Some('y') => { + if !self.version_is_at_least_0_7_1 { + Some(TokenKind::YulTryKeyword) + } else { + None + } + } + Some(_) => { + input.undo(); + None + } + None => None, + }, + Some('y') => { + if scan_chars!(input, 'p', 'e') { + match input.next() { + Some('d') => { + if self.version_is_at_least_0_5_0 + && !self.version_is_at_least_0_7_1 + { + scan_chars!(input, 'e', 'f') + .then_some(TokenKind::YulTypeDefKeyword) + } else { + None + } + } + Some('o') => { + if !self.version_is_at_least_0_7_1 { + scan_chars!(input, 'f') + .then_some(TokenKind::YulTypeOfKeyword) + } else { + None + } + } + Some(_) => { + input.undo(); + if !self.version_is_at_least_0_7_1 { + Some(TokenKind::YulTypeKeyword) + } else { + None + } + } + None => { + if !self.version_is_at_least_0_7_1 { + Some(TokenKind::YulTypeKeyword) + } else { + None + } + } + } + } else { + None + } + } + Some(_) => { + input.undo(); + None + } + None => None, + }, + Some('u') => match input.next() { + Some('n') => { + if self.version_is_at_least_0_5_0 && !self.version_is_at_least_0_7_1 { + scan_chars!(input, 'c', 'h', 'e', 'c', 'k', 'e', 'd') + .then_some(TokenKind::YulUncheckedKeyword) + } else { + None + } + } + Some('s') => { + if !self.version_is_at_least_0_7_1 { + scan_chars!(input, 'i', 'n', 'g') + .then_some(TokenKind::YulUsingKeyword) + } else { + None + } + } + Some(_) => { + input.undo(); + None + } + None => None, + }, + Some('v') => match input.next() { + Some('a') => { + if !self.version_is_at_least_0_6_5 { + scan_chars!(input, 'r').then_some(TokenKind::YulVarKeyword) + } else { + None + } + } + Some('i') => match input.next() { + Some('e') => { + if !self.version_is_at_least_0_7_1 { + scan_chars!(input, 'w').then_some(TokenKind::YulViewKeyword) + } else { + None + } + } + Some('r') => { + if self.version_is_at_least_0_6_0 && !self.version_is_at_least_0_7_1 + { + scan_chars!(input, 't', 'u', 'a', 'l') + .then_some(TokenKind::YulVirtualKeyword) + } else { + None + } + } + Some(_) => { + input.undo(); + None + } + None => None, + }, + Some(_) => { + input.undo(); + None + } + None => None, + }, + Some('w') => match input.next() { + Some('e') => match input.next() { + Some('e') => { + if !self.version_is_at_least_0_7_1 { + scan_chars!(input, 'k', 's') + .then_some(TokenKind::YulWeeksKeyword) + } else { + None + } + } + Some('i') => { + if !self.version_is_at_least_0_7_1 { + Some(TokenKind::YulWeiKeyword) + } else { + None + } + } + Some(_) => { + input.undo(); + None + } + None => None, + }, + Some('h') => { + if !self.version_is_at_least_0_7_1 { + scan_chars!(input, 'i', 'l', 'e') + .then_some(TokenKind::YulWhileKeyword) + } else { + None + } + } + Some(_) => { + input.undo(); + None + } + None => None, + }, + Some('y') => { + if !self.version_is_at_least_0_7_1 { + scan_chars!(input, 'e', 'a', 'r', 's') + .then_some(TokenKind::YulYearsKeyword) + } else { None } - } - Some('s') => scan_chars!(input, 'w', 'i', 't', 'c', 'h') - .then_some(TokenKind::SwitchKeyword), - Some('t') => { - scan_chars!(input, 'r', 'u', 'e').then_some(TokenKind::TrueKeyword) } Some(_) => { input.undo(); @@ -7338,9 +9991,14 @@ impl Lexer for Language { longest_match! { { AsciiStringLiteral = ascii_string_literal } { HexStringLiteral = hex_string_literal } + { YulBytesKeyword = yul_bytes_keyword } { YulDecimalLiteral = yul_decimal_literal } + { YulFixedKeyword = yul_fixed_keyword } { YulHexLiteral = yul_hex_literal } { YulIdentifier = yul_identifier } + { YulIntKeyword = yul_int_keyword } + { YulUfixedKeyword = yul_ufixed_keyword } + { YulUintKeyword = yul_uint_keyword } } } } diff --git a/crates/solidity/outputs/npm/build/src/main.rs b/crates/solidity/outputs/npm/build/src/main.rs index ab93f61f60..9b44f5cc5a 100644 --- a/crates/solidity/outputs/npm/build/src/main.rs +++ b/crates/solidity/outputs/npm/build/src/main.rs @@ -4,7 +4,7 @@ use cargo_emit::rerun_if_changed; use codegen_grammar::Grammar; use codegen_parser_generator::code_generator::CodeGenerator; use infra_utils::{cargo::CargoWorkspace, paths::PathExtensions}; -use solidity_language::GrammarConstructorDslV1; +use solidity_language::GrammarConstructorDslV2; // Instead of the soure crate calling codegen APIs directly in the build script, it invokes this binary, which in turn // calls the codegen APIs (and hence why it's emitting `cargo:` directives). @@ -17,7 +17,8 @@ use solidity_language::GrammarConstructorDslV1; fn main() -> Result<()> { // Generate files in the source crate: { - let grammar = Grammar::from_dsl_v1(); + let grammar = Grammar::from_dsl_v2(); + let crate_dir = CargoWorkspace::locate_source_crate("solidity_npm_crate")?; CodeGenerator::write_source(&crate_dir.join("src/generated"), &grammar)?; diff --git a/crates/solidity/outputs/npm/crate/src/generated/kinds.rs b/crates/solidity/outputs/npm/crate/src/generated/kinds.rs index b36c8748b4..4980fe275f 100644 --- a/crates/solidity/outputs/npm/crate/src/generated/kinds.rs +++ b/crates/solidity/outputs/npm/crate/src/generated/kinds.rs @@ -19,7 +19,6 @@ use {napi::bindgen_prelude::*, napi_derive::napi}; pub enum ProductionKind { ABICoderPragma, AddressType, - ArgumentsDeclaration, ArrayExpression, ArrayValues, AsciiStringLiterals, @@ -40,6 +39,7 @@ pub enum ProductionKind { DecimalNumberExpression, DeleteStatement, DoWhileStatement, + ElseBranch, EmitStatement, EndOfFileTrivia, EnumDefinition, @@ -59,7 +59,6 @@ pub enum ProductionKind { FallbackFunctionDefinition, ForStatement, FunctionAttributes, - FunctionCallOptions, FunctionDefinition, FunctionType, FunctionTypeAttributes, @@ -67,10 +66,12 @@ pub enum ProductionKind { HexStringLiterals, IdentifierPath, IfStatement, + ImportAlias, ImportDeconstruction, ImportDeconstructionSymbol, ImportDeconstructionSymbols, ImportDirective, + IndexAccessEnd, InheritanceSpecifier, InheritanceType, InheritanceTypes, @@ -79,24 +80,28 @@ pub enum ProductionKind { LeadingTrivia, LibraryDefinition, LibraryMembers, - MappingKeyType, + MappingKey, MappingType, - MappingValueType, + MappingValue, ModifierAttributes, ModifierDefinition, ModifierInvocation, NamedArgument, + NamedArgumentGroup, + NamedArgumentGroups, NamedArguments, NamedArgumentsDeclaration, NamedImport, NewExpression, OverridePaths, + OverridePathsDeclaration, OverrideSpecifier, Parameter, Parameters, ParametersDeclaration, PathImport, PositionalArguments, + PositionalArgumentsDeclaration, PragmaDirective, ReceiveFunctionAttributes, ReceiveFunctionDefinition, @@ -107,6 +112,7 @@ pub enum ProductionKind { SourceUnitMembers, StateVariableAttributes, StateVariableDefinition, + StateVariableDefinitionValue, Statements, StructDefinition, StructMember, @@ -118,6 +124,7 @@ pub enum ProductionKind { TupleDeconstructionElements, TupleDeconstructionStatement, TupleExpression, + TupleValue, TupleValues, TypeExpression, TypeName, @@ -128,12 +135,13 @@ pub enum ProductionKind { UnnamedFunctionDefinition, UntypedTupleMember, UserDefinedValueTypeDefinition, + UsingAlias, UsingDeconstruction, UsingDeconstructionSymbol, UsingDeconstructionSymbols, UsingDirective, - VariableDeclaration, VariableDeclarationStatement, + VariableDeclarationValue, VersionPragma, VersionPragmaExpression, VersionPragmaExpressions, @@ -144,21 +152,24 @@ pub enum ProductionKind { YulBlock, YulBreakStatement, YulContinueStatement, - YulDeclarationStatement, + YulDefaultCase, YulExpression, YulForStatement, YulFunctionDefinition, YulIdentifierPath, YulIdentifierPaths, - YulIdentifiers, YulIfStatement, YulLeaveStatement, + YulParameters, YulParametersDeclaration, + YulReturnVariables, YulReturnsDeclaration, YulStatements, - YulSwitchCase, YulSwitchCases, YulSwitchStatement, + YulValueCase, + YulVariableDeclarationStatement, + YulVariableDeclarationValue, } #[derive( @@ -177,7 +188,6 @@ pub enum ProductionKind { pub enum RuleKind { ABICoderPragma, AddressType, - ArgumentsDeclaration, ArrayExpression, ArrayTypeName, ArrayValues, @@ -201,6 +211,7 @@ pub enum RuleKind { DecimalNumberExpression, DeleteStatement, DoWhileStatement, + ElseBranch, EmitStatement, EndOfFileTrivia, EnumDefinition, @@ -221,7 +232,6 @@ pub enum RuleKind { ForStatement, FunctionAttributes, FunctionCallExpression, - FunctionCallOptions, FunctionDefinition, FunctionType, FunctionTypeAttributes, @@ -229,10 +239,12 @@ pub enum RuleKind { HexStringLiterals, IdentifierPath, IfStatement, + ImportAlias, ImportDeconstruction, ImportDeconstructionSymbol, ImportDeconstructionSymbols, ImportDirective, + IndexAccessEnd, IndexAccessExpression, InheritanceSpecifier, InheritanceType, @@ -242,25 +254,29 @@ pub enum RuleKind { LeadingTrivia, LibraryDefinition, LibraryMembers, - MappingKeyType, + MappingKey, MappingType, - MappingValueType, + MappingValue, MemberAccessExpression, ModifierAttributes, ModifierDefinition, ModifierInvocation, NamedArgument, + NamedArgumentGroup, + NamedArgumentGroups, NamedArguments, NamedArgumentsDeclaration, NamedImport, NewExpression, OverridePaths, + OverridePathsDeclaration, OverrideSpecifier, Parameter, Parameters, ParametersDeclaration, PathImport, PositionalArguments, + PositionalArgumentsDeclaration, PragmaDirective, ReceiveFunctionAttributes, ReceiveFunctionDefinition, @@ -271,6 +287,7 @@ pub enum RuleKind { SourceUnitMembers, StateVariableAttributes, StateVariableDefinition, + StateVariableDefinitionValue, Statements, StructDefinition, StructMember, @@ -282,6 +299,7 @@ pub enum RuleKind { TupleDeconstructionElements, TupleDeconstructionStatement, TupleExpression, + TupleValue, TupleValues, TypeExpression, TypeName, @@ -294,12 +312,13 @@ pub enum RuleKind { UnnamedFunctionDefinition, UntypedTupleMember, UserDefinedValueTypeDefinition, + UsingAlias, UsingDeconstruction, UsingDeconstructionSymbol, UsingDeconstructionSymbols, UsingDirective, - VariableDeclaration, VariableDeclarationStatement, + VariableDeclarationValue, VersionPragma, VersionPragmaBinaryExpression, VersionPragmaExpression, @@ -312,22 +331,25 @@ pub enum RuleKind { YulBlock, YulBreakStatement, YulContinueStatement, - YulDeclarationStatement, + YulDefaultCase, YulExpression, YulForStatement, YulFunctionCallExpression, YulFunctionDefinition, YulIdentifierPath, YulIdentifierPaths, - YulIdentifiers, YulIfStatement, YulLeaveStatement, + YulParameters, YulParametersDeclaration, + YulReturnVariables, YulReturnsDeclaration, YulStatements, - YulSwitchCase, YulSwitchCases, YulSwitchStatement, + YulValueCase, + YulVariableDeclarationStatement, + YulVariableDeclarationValue, } impl RuleKind { @@ -383,7 +405,7 @@ pub enum TokenKind { BreakKeyword, ByteKeyword, BytesKeyword, - CalldataKeyword, + CallDataKeyword, Caret, CaretEqual, CaseKeyword, @@ -398,7 +420,7 @@ pub enum TokenKind { ConstructorKeyword, ContinueKeyword, ContractKeyword, - CopyofKeyword, + CopyOfKeyword, DaysKeyword, DecimalLiteral, DefaultKeyword, @@ -449,7 +471,6 @@ pub enum TokenKind { InterfaceKeyword, InternalKeyword, IsKeyword, - LeaveKeyword, LessThan, LessThanEqual, LessThanLessThan, @@ -499,7 +520,7 @@ pub enum TokenKind { SecondsKeyword, Semicolon, SingleLineComment, - SizeofKeyword, + SizeOfKeyword, Slash, SlashEqual, SolidityKeyword, @@ -514,9 +535,9 @@ pub enum TokenKind { Tilde, TrueKeyword, TryKeyword, + TypeDefKeyword, TypeKeyword, - TypedefKeyword, - TypeofKeyword, + TypeOfKeyword, UfixedKeyword, UintKeyword, UncheckedKeyword, @@ -531,9 +552,116 @@ pub enum TokenKind { WhileKeyword, Whitespace, YearsKeyword, + YulAbstractKeyword, + YulAddressKeyword, + YulAfterKeyword, + YulAliasKeyword, + YulAnonymousKeyword, + YulApplyKeyword, + YulAsKeyword, + YulAssemblyKeyword, + YulAutoKeyword, + YulBoolKeyword, + YulBreakKeyword, + YulByteKeyword, + YulBytesKeyword, + YulCallDataKeyword, + YulCaseKeyword, + YulCatchKeyword, + YulConstantKeyword, + YulConstructorKeyword, + YulContinueKeyword, + YulContractKeyword, + YulCopyOfKeyword, + YulDaysKeyword, YulDecimalLiteral, + YulDefaultKeyword, + YulDefineKeyword, + YulDeleteKeyword, + YulDoKeyword, + YulElseKeyword, + YulEmitKeyword, + YulEnumKeyword, + YulEtherKeyword, + YulEventKeyword, + YulExternalKeyword, + YulFallbackKeyword, + YulFalseKeyword, + YulFinalKeyword, + YulFinneyKeyword, + YulFixedKeyword, + YulForKeyword, + YulFunctionKeyword, + YulGweiKeyword, + YulHexKeyword, YulHexLiteral, + YulHoursKeyword, YulIdentifier, + YulIfKeyword, + YulImmutableKeyword, + YulImplementsKeyword, + YulImportKeyword, + YulInKeyword, + YulIndexedKeyword, + YulInlineKeyword, + YulIntKeyword, + YulInterfaceKeyword, + YulInternalKeyword, + YulIsKeyword, + YulLeaveKeyword, + YulLetKeyword, + YulLibraryKeyword, + YulMacroKeyword, + YulMappingKeyword, + YulMatchKeyword, + YulMemoryKeyword, + YulMinutesKeyword, + YulModifierKeyword, + YulMutableKeyword, + YulNewKeyword, + YulNullKeyword, + YulOfKeyword, + YulOverrideKeyword, + YulPartialKeyword, + YulPayableKeyword, + YulPragmaKeyword, + YulPrivateKeyword, + YulPromiseKeyword, + YulPublicKeyword, + YulPureKeyword, + YulReceiveKeyword, + YulReferenceKeyword, + YulRelocatableKeyword, + YulReturnKeyword, + YulReturnsKeyword, + YulRevertKeyword, + YulSealedKeyword, + YulSecondsKeyword, + YulSizeOfKeyword, + YulStaticKeyword, + YulStorageKeyword, + YulStringKeyword, + YulStructKeyword, + YulSupportsKeyword, + YulSwitchKeyword, + YulSzaboKeyword, + YulThrowKeyword, + YulTrueKeyword, + YulTryKeyword, + YulTypeDefKeyword, + YulTypeKeyword, + YulTypeOfKeyword, + YulUfixedKeyword, + YulUintKeyword, + YulUncheckedKeyword, + YulUsingKeyword, + YulVarKeyword, + YulViewKeyword, + YulVirtualKeyword, + YulWeeksKeyword, + YulWeiKeyword, + YulWhileKeyword, + YulYearsKeyword, } #[derive(strum_macros::FromRepr)] @@ -542,8 +670,8 @@ pub enum TokenKind { #[cfg_attr(not(feature = "slang_napi_interfaces"), derive(Clone, Copy))] pub enum LexicalContext { Default, - VersionPragma, - YulBlock, + Pragma, + Yul, } /// Marker trait for type-level [`LexicalContext`] variants. @@ -561,16 +689,16 @@ pub mod LexicalContextType { LexicalContext::Default } } - pub struct VersionPragma {} - impl IsLexicalContext for VersionPragma { + pub struct Pragma {} + impl IsLexicalContext for Pragma { fn value() -> LexicalContext { - LexicalContext::VersionPragma + LexicalContext::Pragma } } - pub struct YulBlock {} - impl IsLexicalContext for YulBlock { + pub struct Yul {} + impl IsLexicalContext for Yul { fn value() -> LexicalContext { - LexicalContext::YulBlock + LexicalContext::Yul } } } diff --git a/crates/solidity/outputs/npm/crate/src/generated/language.rs b/crates/solidity/outputs/npm/crate/src/generated/language.rs index a0ad62c13a..c889122236 100644 --- a/crates/solidity/outputs/npm/crate/src/generated/language.rs +++ b/crates/solidity/outputs/npm/crate/src/generated/language.rs @@ -21,13 +21,16 @@ use super::napi::napi_parse_output::ParseOutput as NAPIParseOutput; #[cfg_attr(feature = "slang_napi_interfaces", napi(namespace = "language"))] pub struct Language { pub(crate) version: Version, + pub(crate) version_is_at_least_0_4_14: bool, pub(crate) version_is_at_least_0_4_21: bool, pub(crate) version_is_at_least_0_4_22: bool, pub(crate) version_is_at_least_0_5_0: bool, pub(crate) version_is_at_least_0_5_3: bool, + pub(crate) version_is_at_least_0_5_10: bool, pub(crate) version_is_at_least_0_6_0: bool, pub(crate) version_is_at_least_0_6_2: bool, pub(crate) version_is_at_least_0_6_5: bool, + pub(crate) version_is_at_least_0_6_8: bool, pub(crate) version_is_at_least_0_6_11: bool, pub(crate) version_is_at_least_0_7_0: bool, pub(crate) version_is_at_least_0_7_1: bool, @@ -142,13 +145,16 @@ impl Language { pub fn new(version: Version) -> std::result::Result { if Self::SUPPORTED_VERSIONS.binary_search(&version).is_ok() { Ok(Self { + version_is_at_least_0_4_14: Version::new(0, 4, 14) <= version, version_is_at_least_0_4_21: Version::new(0, 4, 21) <= version, version_is_at_least_0_4_22: Version::new(0, 4, 22) <= version, version_is_at_least_0_5_0: Version::new(0, 5, 0) <= version, version_is_at_least_0_5_3: Version::new(0, 5, 3) <= version, + version_is_at_least_0_5_10: Version::new(0, 5, 10) <= version, version_is_at_least_0_6_0: Version::new(0, 6, 0) <= version, version_is_at_least_0_6_2: Version::new(0, 6, 2) <= version, version_is_at_least_0_6_5: Version::new(0, 6, 5) <= version, + version_is_at_least_0_6_8: Version::new(0, 6, 8) <= version, version_is_at_least_0_6_11: Version::new(0, 6, 11) <= version, version_is_at_least_0_7_0: Version::new(0, 7, 0) <= version, version_is_at_least_0_7_1: Version::new(0, 7, 1) <= version, @@ -178,11 +184,11 @@ impl Language { #[allow(unused_assignments, unused_parens)] fn abi_coder_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::AbicoderKeyword, ))?; - seq.elem(self.parse_token_with_trivia::( + seq.elem(self.parse_token_with_trivia::( input, TokenKind::Identifier, ))?; @@ -193,62 +199,20 @@ impl Language { #[allow(unused_assignments, unused_parens)] fn address_type(&self, input: &mut ParserContext) -> ParserResult { - ChoiceHelper::run(input, |mut choice, input| { - let result = SequenceHelper::run(|mut seq| { - seq.elem(self.parse_token_with_trivia::( - input, - TokenKind::AddressKeyword, - ))?; - seq.elem(OptionalHelper::transform( - self.parse_token_with_trivia::( - input, - TokenKind::PayableKeyword, - ), - ))?; - seq.finish() - }); - choice.consider(input, result)?; - let result = self.parse_token_with_trivia::( - input, - TokenKind::PayableKeyword, - ); - choice.consider(input, result)?; - choice.finish(input) - }) - .with_kind(RuleKind::AddressType) - } - - #[allow(unused_assignments, unused_parens)] - fn arguments_declaration(&self, input: &mut ParserContext) -> ParserResult { SequenceHelper::run(|mut seq| { - let mut delim_guard = input.open_delim(TokenKind::CloseParen); - let input = delim_guard.ctx(); seq.elem(self.parse_token_with_trivia::( input, - TokenKind::OpenParen, + TokenKind::AddressKeyword, ))?; - seq.elem( - OptionalHelper::transform(ChoiceHelper::run(input, |mut choice, input| { - let result = self.positional_arguments(input); - choice.consider(input, result)?; - let result = self.named_arguments_declaration(input); - choice.consider(input, result)?; - choice.finish(input) - })) - .recover_until_with_nested_delims::<_, LexicalContextType::Default>( + seq.elem(OptionalHelper::transform( + self.parse_token_with_trivia::( input, - self, - TokenKind::CloseParen, - RecoverFromNoMatch::Yes, + TokenKind::PayableKeyword, ), - )?; - seq.elem(self.parse_token_with_trivia::( - input, - TokenKind::CloseParen, ))?; seq.finish() }) - .with_kind(RuleKind::ArgumentsDeclaration) + .with_kind(RuleKind::AddressType) } #[allow(unused_assignments, unused_parens)] @@ -639,34 +603,32 @@ impl Language { choice.consider(input, result)?; let result = self.function_definition(input); choice.consider(input, result)?; - let result = self.modifier_definition(input); - choice.consider(input, result)?; - let result = self.struct_definition(input); - choice.consider(input, result)?; - let result = self.enum_definition(input); - choice.consider(input, result)?; - let result = self.event_definition(input); - choice.consider(input, result)?; - let result = self.state_variable_definition(input); - choice.consider(input, result)?; if self.version_is_at_least_0_4_22 { let result = self.constructor_definition(input); choice.consider(input, result)?; } if self.version_is_at_least_0_6_0 { - let result = ChoiceHelper::run(input, |mut choice, input| { - let result = self.fallback_function_definition(input); - choice.consider(input, result)?; - let result = self.receive_function_definition(input); - choice.consider(input, result)?; - choice.finish(input) - }); + let result = self.receive_function_definition(input); + choice.consider(input, result)?; + } + if self.version_is_at_least_0_6_0 { + let result = self.fallback_function_definition(input); choice.consider(input, result)?; } if !self.version_is_at_least_0_6_0 { let result = self.unnamed_function_definition(input); choice.consider(input, result)?; } + let result = self.modifier_definition(input); + choice.consider(input, result)?; + let result = self.struct_definition(input); + choice.consider(input, result)?; + let result = self.enum_definition(input); + choice.consider(input, result)?; + let result = self.event_definition(input); + choice.consider(input, result)?; + let result = self.state_variable_definition(input); + choice.consider(input, result)?; if self.version_is_at_least_0_8_4 { let result = self.error_definition(input); choice.consider(input, result)?; @@ -693,9 +655,30 @@ impl Language { |mut choice, input| { let result = self.parse_token_with_trivia::( input, - TokenKind::DaysKeyword, + TokenKind::WeiKeyword, ); choice.consider(input, result)?; + if self.version_is_at_least_0_6_11 { + let result = self.parse_token_with_trivia::( + input, + TokenKind::GweiKeyword, + ); + choice.consider(input, result)?; + } + if !self.version_is_at_least_0_7_0 { + let result = self.parse_token_with_trivia::( + input, + TokenKind::SzaboKeyword, + ); + choice.consider(input, result)?; + } + if !self.version_is_at_least_0_7_0 { + let result = self.parse_token_with_trivia::( + input, + TokenKind::FinneyKeyword, + ); + choice.consider(input, result)?; + } let result = self.parse_token_with_trivia::( input, TokenKind::EtherKeyword, @@ -703,7 +686,7 @@ impl Language { choice.consider(input, result)?; let result = self.parse_token_with_trivia::( input, - TokenKind::HoursKeyword, + TokenKind::SecondsKeyword, ); choice.consider(input, result)?; let result = self.parse_token_with_trivia::( @@ -713,17 +696,17 @@ impl Language { choice.consider(input, result)?; let result = self.parse_token_with_trivia::( input, - TokenKind::SecondsKeyword, + TokenKind::HoursKeyword, ); choice.consider(input, result)?; let result = self.parse_token_with_trivia::( input, - TokenKind::WeeksKeyword, + TokenKind::DaysKeyword, ); choice.consider(input, result)?; let result = self.parse_token_with_trivia::( input, - TokenKind::WeiKeyword, + TokenKind::WeeksKeyword, ); choice.consider(input, result)?; if !self.version_is_at_least_0_5_0 { @@ -733,31 +716,6 @@ impl Language { ); choice.consider(input, result)?; } - if self.version_is_at_least_0_6_11 { - let result = self.parse_token_with_trivia::( - input, - TokenKind::GweiKeyword, - ); - choice.consider(input, result)?; - } - if !self.version_is_at_least_0_7_0 { - let result = ChoiceHelper::run(input, |mut choice, input| { - let result = self - .parse_token_with_trivia::( - input, - TokenKind::FinneyKeyword, - ); - choice.consider(input, result)?; - let result = self - .parse_token_with_trivia::( - input, - TokenKind::SzaboKeyword, - ); - choice.consider(input, result)?; - choice.finish(input) - }); - choice.consider(input, result)?; - } choice.finish(input) }, )))?; @@ -804,52 +762,44 @@ impl Language { TokenKind::DoKeyword, ))?; seq.elem(ChoiceHelper::run(input, |mut choice, input| { - let result = ChoiceHelper::run(input, |mut choice, input| { - let result = self.expression_statement(input); - choice.consider(input, result)?; - let result = self.variable_declaration_statement(input); - choice.consider(input, result)?; - let result = self.tuple_deconstruction_statement(input); - choice.consider(input, result)?; - choice.finish(input) - }); + let result = self.expression_statement(input); choice.consider(input, result)?; - let result = ChoiceHelper::run(input, |mut choice, input| { - let result = self.if_statement(input); - choice.consider(input, result)?; - let result = self.for_statement(input); - choice.consider(input, result)?; - let result = self.while_statement(input); - choice.consider(input, result)?; - let result = self.do_while_statement(input); - choice.consider(input, result)?; - let result = self.continue_statement(input); + let result = self.variable_declaration_statement(input); + choice.consider(input, result)?; + let result = self.tuple_deconstruction_statement(input); + choice.consider(input, result)?; + let result = self.if_statement(input); + choice.consider(input, result)?; + let result = self.for_statement(input); + choice.consider(input, result)?; + let result = self.while_statement(input); + choice.consider(input, result)?; + let result = self.do_while_statement(input); + choice.consider(input, result)?; + let result = self.continue_statement(input); + choice.consider(input, result)?; + let result = self.break_statement(input); + choice.consider(input, result)?; + let result = self.delete_statement(input); + choice.consider(input, result)?; + let result = self.return_statement(input); + choice.consider(input, result)?; + if !self.version_is_at_least_0_5_0 { + let result = self.throw_statement(input); choice.consider(input, result)?; - let result = self.break_statement(input); + } + if self.version_is_at_least_0_4_21 { + let result = self.emit_statement(input); choice.consider(input, result)?; - let result = self.delete_statement(input); + } + if self.version_is_at_least_0_6_0 { + let result = self.try_statement(input); choice.consider(input, result)?; - let result = self.return_statement(input); + } + if self.version_is_at_least_0_8_4 { + let result = self.revert_statement(input); choice.consider(input, result)?; - if self.version_is_at_least_0_4_21 { - let result = self.emit_statement(input); - choice.consider(input, result)?; - } - if !self.version_is_at_least_0_5_0 { - let result = self.throw_statement(input); - choice.consider(input, result)?; - } - if self.version_is_at_least_0_6_0 { - let result = self.try_statement(input); - choice.consider(input, result)?; - } - if self.version_is_at_least_0_8_4 { - let result = self.revert_statement(input); - choice.consider(input, result)?; - } - choice.finish(input) - }); - choice.consider(input, result)?; + } let result = self.assembly_statement(input); choice.consider(input, result)?; let result = self.block(input); @@ -904,6 +854,67 @@ impl Language { .with_kind(RuleKind::DoWhileStatement) } + #[allow(unused_assignments, unused_parens)] + fn else_branch(&self, input: &mut ParserContext) -> ParserResult { + SequenceHelper::run(|mut seq| { + seq.elem(self.parse_token_with_trivia::( + input, + TokenKind::ElseKeyword, + ))?; + seq.elem(ChoiceHelper::run(input, |mut choice, input| { + let result = self.expression_statement(input); + choice.consider(input, result)?; + let result = self.variable_declaration_statement(input); + choice.consider(input, result)?; + let result = self.tuple_deconstruction_statement(input); + choice.consider(input, result)?; + let result = self.if_statement(input); + choice.consider(input, result)?; + let result = self.for_statement(input); + choice.consider(input, result)?; + let result = self.while_statement(input); + choice.consider(input, result)?; + let result = self.do_while_statement(input); + choice.consider(input, result)?; + let result = self.continue_statement(input); + choice.consider(input, result)?; + let result = self.break_statement(input); + choice.consider(input, result)?; + let result = self.delete_statement(input); + choice.consider(input, result)?; + let result = self.return_statement(input); + choice.consider(input, result)?; + if !self.version_is_at_least_0_5_0 { + let result = self.throw_statement(input); + choice.consider(input, result)?; + } + if self.version_is_at_least_0_4_21 { + let result = self.emit_statement(input); + choice.consider(input, result)?; + } + if self.version_is_at_least_0_6_0 { + let result = self.try_statement(input); + choice.consider(input, result)?; + } + if self.version_is_at_least_0_8_4 { + let result = self.revert_statement(input); + choice.consider(input, result)?; + } + let result = self.assembly_statement(input); + choice.consider(input, result)?; + let result = self.block(input); + choice.consider(input, result)?; + if self.version_is_at_least_0_8_0 { + let result = self.unchecked_block(input); + choice.consider(input, result)?; + } + choice.finish(input) + }))?; + seq.finish() + }) + .with_kind(RuleKind::ElseBranch) + } + #[allow(unused_assignments, unused_parens)] fn emit_statement(&self, input: &mut ParserContext) -> ParserResult { if self.version_is_at_least_0_4_21 { @@ -915,7 +926,13 @@ impl Language { TokenKind::EmitKeyword, ))?; seq.elem(self.identifier_path(input))?; - seq.elem(self.arguments_declaration(input))?; + seq.elem(ChoiceHelper::run(input, |mut choice, input| { + let result = self.positional_arguments_declaration(input); + choice.consider(input, result)?; + let result = self.named_arguments_declaration(input); + choice.consider(input, result)?; + choice.finish(input) + }))?; seq.finish() }) .recover_until_with_nested_delims::<_, LexicalContextType::Default>( @@ -1216,19 +1233,19 @@ impl Language { #[allow(unused_assignments, unused_parens)] fn experimental_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::ExperimentalKeyword, ))?; seq.elem(ChoiceHelper::run(input, |mut choice, input| { - let result = self.parse_token_with_trivia::( + let result = self.parse_token_with_trivia::( input, - TokenKind::AsciiStringLiteral, + TokenKind::Identifier, ); choice.consider(input, result)?; - let result = self.parse_token_with_trivia::( + let result = self.parse_token_with_trivia::( input, - TokenKind::Identifier, + TokenKind::AsciiStringLiteral, ); choice.consider(input, result)?; choice.finish(input) @@ -1240,7 +1257,7 @@ impl Language { #[allow(unused_assignments, unused_parens)] fn expression(&self, input: &mut ParserContext) -> ParserResult { - let parse_assignment_operator = |input: &mut ParserContext| { + let parse_assignment_expression = |input: &mut ParserContext| { PrecedenceHelper::to_binary_operator( RuleKind::BinaryExpression, 1u8, @@ -1310,7 +1327,7 @@ impl Language { }), ) }; - let parse_conditional_operator = |input: &mut ParserContext| { + let parse_conditional_expression = |input: &mut ParserContext| { PrecedenceHelper::to_postfix_operator( RuleKind::ConditionalExpression, 3u8, @@ -1329,7 +1346,7 @@ impl Language { }), ) }; - let parse_or_operator = |input: &mut ParserContext| { + let parse_or_expression = |input: &mut ParserContext| { PrecedenceHelper::to_binary_operator( RuleKind::BinaryExpression, 5u8, @@ -1340,7 +1357,7 @@ impl Language { ), ) }; - let parse_and_operator = |input: &mut ParserContext| { + let parse_and_expression = |input: &mut ParserContext| { PrecedenceHelper::to_binary_operator( RuleKind::BinaryExpression, 7u8, @@ -1351,7 +1368,7 @@ impl Language { ), ) }; - let parse_equality_comparison_operator = |input: &mut ParserContext| { + let parse_equality_expression = |input: &mut ParserContext| { PrecedenceHelper::to_binary_operator( RuleKind::BinaryExpression, 9u8, @@ -1371,7 +1388,7 @@ impl Language { }), ) }; - let parse_order_comparison_operator = |input: &mut ParserContext| { + let parse_comparison_expression = |input: &mut ParserContext| { PrecedenceHelper::to_binary_operator( RuleKind::BinaryExpression, 11u8, @@ -1401,7 +1418,7 @@ impl Language { }), ) }; - let parse_bitwise_or_operator = |input: &mut ParserContext| { + let parse_bitwise_or_expression = |input: &mut ParserContext| { PrecedenceHelper::to_binary_operator( RuleKind::BinaryExpression, 13u8, @@ -1409,7 +1426,7 @@ impl Language { self.parse_token_with_trivia::(input, TokenKind::Bar), ) }; - let parse_bitwise_x_or_operator = |input: &mut ParserContext| { + let parse_bitwise_xor_expression = |input: &mut ParserContext| { PrecedenceHelper::to_binary_operator( RuleKind::BinaryExpression, 15u8, @@ -1420,7 +1437,7 @@ impl Language { ), ) }; - let parse_bitwise_and_operator = |input: &mut ParserContext| { + let parse_bitwise_and_expression = |input: &mut ParserContext| { PrecedenceHelper::to_binary_operator( RuleKind::BinaryExpression, 17u8, @@ -1431,7 +1448,7 @@ impl Language { ), ) }; - let parse_shift_operator = |input: &mut ParserContext| { + let parse_shift_expression = |input: &mut ParserContext| { PrecedenceHelper::to_binary_operator( RuleKind::BinaryExpression, 19u8, @@ -1456,7 +1473,7 @@ impl Language { }), ) }; - let parse_add_sub_operator = |input: &mut ParserContext| { + let parse_additive_expression = |input: &mut ParserContext| { PrecedenceHelper::to_binary_operator( RuleKind::BinaryExpression, 21u8, @@ -1476,7 +1493,7 @@ impl Language { }), ) }; - let parse_mul_div_mod_operator = |input: &mut ParserContext| { + let parse_multiplicative_expression = |input: &mut ParserContext| { PrecedenceHelper::to_binary_operator( RuleKind::BinaryExpression, 23u8, @@ -1501,29 +1518,55 @@ impl Language { }), ) }; - let parse_exponentiation_operator_removed_from_0_6_0 = |input: &mut ParserContext| { + let parse_exponentiation_expression_removed_from_0_6_0 = |input: &mut ParserContext| { PrecedenceHelper::to_binary_operator( RuleKind::BinaryExpression, 25u8, 25u8 + 1, - self.parse_token_with_trivia::( - input, - TokenKind::AsteriskAsterisk, - ), + 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) + }), ) }; - let parse_exponentiation_operator_introduced_from_0_6_0 = |input: &mut ParserContext| { + let parse_exponentiation_expression_introduced_from_0_6_0 = |input: &mut ParserContext| { PrecedenceHelper::to_binary_operator( RuleKind::BinaryExpression, 27u8 + 1, 27u8, - self.parse_token_with_trivia::( - input, - TokenKind::AsteriskAsterisk, - ), - ) + 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) + }), + ) }; - let parse_unary_postfix_operator = |input: &mut ParserContext| { + let parse_postfix_expression = |input: &mut ParserContext| { PrecedenceHelper::to_postfix_operator( RuleKind::UnaryPostfixExpression, 29u8, @@ -1542,64 +1585,221 @@ impl Language { }), ) }; - let parse_unary_prefix_operator = |input: &mut ParserContext| { + let parse_prefix_expression_removed_from_0_5_0 = |input: &mut ParserContext| { PrecedenceHelper::to_prefix_operator( RuleKind::UnaryPrefixExpression, 31u8, 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, - ); + let result = 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)?; + let result = self + .parse_token_with_trivia::( + input, + TokenKind::Plus, + ); + choice.consider(input, result)?; + choice.finish(input) + }); + choice.consider(input, result)?; + } + if self.version_is_at_least_0_5_0 { + let result = 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)?; + choice.finish(input) + }); + choice.consider(input, result)?; + } + choice.finish(input) + }), + ) + }; + let parse_prefix_expression_introduced_from_0_5_0 = |input: &mut ParserContext| { + PrecedenceHelper::to_prefix_operator( + RuleKind::UnaryPrefixExpression, + 33u8, + ChoiceHelper::run(input, |mut choice, input| { + if !self.version_is_at_least_0_5_0 { + let result = 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)?; + let result = self + .parse_token_with_trivia::( + input, + TokenKind::Plus, + ); + choice.consider(input, result)?; + choice.finish(input) + }); + choice.consider(input, result)?; + } + if self.version_is_at_least_0_5_0 { + let result = 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)?; + choice.finish(input) + }); choice.consider(input, result)?; } choice.finish(input) }), ) }; - let parse_function_call_operator = |input: &mut ParserContext| { + let parse_function_call_expression = |input: &mut ParserContext| { PrecedenceHelper::to_postfix_operator( RuleKind::FunctionCallExpression, - 33u8, + 35u8, SequenceHelper::run(|mut seq| { if self.version_is_at_least_0_6_2 { - seq.elem(OptionalHelper::transform(self.function_call_options(input)))?; + seq.elem(OptionalHelper::transform( + if self.version_is_at_least_0_6_2 { + ChoiceHelper::run(input, |mut choice, input| { + if self.version_is_at_least_0_6_2 + && !self.version_is_at_least_0_8_0 + { + let result = self.named_argument_groups(input); + choice.consider(input, result)?; + } + if self.version_is_at_least_0_8_0 { + let result = self.named_argument_group(input); + choice.consider(input, result)?; + } + choice.finish(input) + }) + } else { + ParserResult::disabled() + }, + ))?; } - seq.elem(self.arguments_declaration(input))?; + seq.elem(ChoiceHelper::run(input, |mut choice, input| { + let result = self.positional_arguments_declaration(input); + choice.consider(input, result)?; + let result = self.named_arguments_declaration(input); + choice.consider(input, result)?; + choice.finish(input) + }))?; seq.finish() }), ) }; - let parse_member_access_operator = |input: &mut ParserContext| { + let parse_member_access_expression = |input: &mut ParserContext| { PrecedenceHelper::to_postfix_operator( RuleKind::MemberAccessExpression, - 35u8, + 37u8, SequenceHelper::run(|mut seq| { seq.elem(self.parse_token_with_trivia::( input, @@ -1622,10 +1822,10 @@ impl Language { }), ) }; - let parse_index_access_operator = |input: &mut ParserContext| { + let parse_index_access_expression = |input: &mut ParserContext| { PrecedenceHelper::to_postfix_operator( RuleKind::IndexAccessExpression, - 37u8, + 39u8, SequenceHelper::run(|mut seq| { let mut delim_guard = input.open_delim(TokenKind::CloseBracket); let input = delim_guard.ctx(); @@ -1636,16 +1836,7 @@ impl Language { seq.elem( SequenceHelper::run(|mut seq| { seq.elem(OptionalHelper::transform(self.expression(input)))?; - seq.elem(OptionalHelper::transform(SequenceHelper::run(|mut seq| { - seq.elem( - self.parse_token_with_trivia::( - input, - TokenKind::Colon, - ), - )?; - seq.elem(OptionalHelper::transform(self.expression(input)))?; - seq.finish() - })))?; + seq.elem(OptionalHelper::transform(self.index_access_end(input)))?; seq.finish() }) .recover_until_with_nested_delims::<_, LexicalContextType::Default>( @@ -1665,8 +1856,14 @@ impl Language { }; let prefix_operator_parser = |input: &mut ParserContext| { ChoiceHelper::run(input, |mut choice, input| { - let result = parse_unary_prefix_operator(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)?; + } + if self.version_is_at_least_0_5_0 { + let result = parse_prefix_expression_introduced_from_0_5_0(input); + choice.consider(input, result)?; + } choice.finish(input) }) }; @@ -1676,29 +1873,15 @@ impl Language { choice.consider(input, result)?; let result = self.tuple_expression(input); choice.consider(input, result)?; + if self.version_is_at_least_0_5_3 { + let result = self.type_expression(input); + choice.consider(input, result)?; + } let result = self.array_expression(input); choice.consider(input, result)?; - let result = ChoiceHelper::run(input, |mut choice, input| { - let result = self.parse_token_with_trivia::( - input, - TokenKind::TrueKeyword, - ); - choice.consider(input, result)?; - let result = self.parse_token_with_trivia::( - input, - TokenKind::FalseKeyword, - ); - choice.consider(input, result)?; - choice.finish(input) - }); + let result = self.hex_number_expression(input); choice.consider(input, result)?; - let result = ChoiceHelper::run(input, |mut choice, input| { - let result = self.decimal_number_expression(input); - choice.consider(input, result)?; - let result = self.hex_number_expression(input); - choice.consider(input, result)?; - choice.finish(input) - }); + let result = self.decimal_number_expression(input); choice.consider(input, result)?; let result = ChoiceHelper::run(input, |mut choice, input| { let result = self.hex_string_literals(input); @@ -1718,6 +1901,13 @@ impl Language { TokenKind::BoolKeyword, ); choice.consider(input, result)?; + if !self.version_is_at_least_0_8_0 { + let result = self.parse_token_with_trivia::( + input, + TokenKind::ByteKeyword, + ); + choice.consider(input, result)?; + } let result = self.parse_token_with_trivia::( input, TokenKind::StringKeyword, @@ -1725,6 +1915,11 @@ impl Language { choice.consider(input, result)?; let result = self.address_type(input); choice.consider(input, result)?; + let result = self.parse_token_with_trivia::( + input, + TokenKind::PayableKeyword, + ); + choice.consider(input, result)?; let result = self.parse_token_with_trivia::( input, TokenKind::BytesKeyword, @@ -1750,39 +1945,38 @@ impl Language { TokenKind::UfixedKeyword, ); choice.consider(input, result)?; - if !self.version_is_at_least_0_8_0 { - let result = self.parse_token_with_trivia::( - input, - TokenKind::ByteKeyword, - ); - choice.consider(input, result)?; - } choice.finish(input) }); choice.consider(input, result)?; + let result = self.parse_token_with_trivia::( + input, + TokenKind::TrueKeyword, + ); + choice.consider(input, result)?; + let result = self.parse_token_with_trivia::( + input, + TokenKind::FalseKeyword, + ); + choice.consider(input, result)?; let result = self.parse_token_with_trivia::( input, TokenKind::Identifier, ); choice.consider(input, result)?; - if self.version_is_at_least_0_5_3 { - let result = self.type_expression(input); - choice.consider(input, result)?; - } choice.finish(input) }) }; let postfix_operator_parser = |input: &mut ParserContext| { ChoiceHelper::run(input, |mut choice, input| { - let result = parse_conditional_operator(input); + let result = parse_conditional_expression(input); choice.consider(input, result)?; - let result = parse_unary_postfix_operator(input); + let result = parse_postfix_expression(input); choice.consider(input, result)?; - let result = parse_function_call_operator(input); + let result = parse_function_call_expression(input); choice.consider(input, result)?; - let result = parse_member_access_operator(input); + let result = parse_member_access_expression(input); choice.consider(input, result)?; - let result = parse_index_access_operator(input); + let result = parse_index_access_expression(input); choice.consider(input, result)?; choice.finish(input) }) @@ -1801,34 +1995,34 @@ impl Language { }; let binary_operator_parser = |input: &mut ParserContext| { ChoiceHelper::run(input, |mut choice, input| { - let result = parse_assignment_operator(input); + let result = parse_assignment_expression(input); choice.consider(input, result)?; - let result = parse_or_operator(input); + let result = parse_or_expression(input); choice.consider(input, result)?; - let result = parse_and_operator(input); + let result = parse_and_expression(input); choice.consider(input, result)?; - let result = parse_equality_comparison_operator(input); + let result = parse_equality_expression(input); choice.consider(input, result)?; - let result = parse_order_comparison_operator(input); + let result = parse_comparison_expression(input); choice.consider(input, result)?; - let result = parse_bitwise_or_operator(input); + let result = parse_bitwise_or_expression(input); choice.consider(input, result)?; - let result = parse_bitwise_x_or_operator(input); + let result = parse_bitwise_xor_expression(input); choice.consider(input, result)?; - let result = parse_bitwise_and_operator(input); + let result = parse_bitwise_and_expression(input); choice.consider(input, result)?; - let result = parse_shift_operator(input); + let result = parse_shift_expression(input); choice.consider(input, result)?; - let result = parse_add_sub_operator(input); + let result = parse_additive_expression(input); choice.consider(input, result)?; - let result = parse_mul_div_mod_operator(input); + let result = parse_multiplicative_expression(input); choice.consider(input, result)?; if !self.version_is_at_least_0_6_0 { - let result = parse_exponentiation_operator_removed_from_0_6_0(input); + 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_operator_introduced_from_0_6_0(input); + let result = parse_exponentiation_expression_introduced_from_0_6_0(input); choice.consider(input, result)?; } choice.finish(input) @@ -1936,13 +2130,13 @@ impl Language { ))?; seq.elem(OptionalHelper::transform(self.returns_declaration(input)))?; seq.elem(ChoiceHelper::run(input, |mut choice, input| { - let result = self.parse_token_with_trivia::( + let result = self.block(input); + choice.consider(input, result)?; + let result = self.parse_token_with_trivia::( input, TokenKind::Semicolon, ); choice.consider(input, result)?; - let result = self.block(input); - choice.consider(input, result)?; choice.finish(input) }))?; seq.finish() @@ -1970,15 +2164,11 @@ impl Language { seq.elem( SequenceHelper::run(|mut seq| { seq.elem(ChoiceHelper::run(input, |mut choice, input| { - let result = ChoiceHelper::run(input, |mut choice, input| { - let result = self.expression_statement(input); - choice.consider(input, result)?; - let result = self.variable_declaration_statement(input); - choice.consider(input, result)?; - let result = self.tuple_deconstruction_statement(input); - choice.consider(input, result)?; - choice.finish(input) - }); + let result = self.expression_statement(input); + choice.consider(input, result)?; + let result = self.variable_declaration_statement(input); + choice.consider(input, result)?; + let result = self.tuple_deconstruction_statement(input); choice.consider(input, result)?; let result = self .parse_token_with_trivia::( @@ -2016,52 +2206,44 @@ impl Language { seq.finish() }))?; seq.elem(ChoiceHelper::run(input, |mut choice, input| { - let result = ChoiceHelper::run(input, |mut choice, input| { - let result = self.expression_statement(input); - choice.consider(input, result)?; - let result = self.variable_declaration_statement(input); - choice.consider(input, result)?; - let result = self.tuple_deconstruction_statement(input); - choice.consider(input, result)?; - choice.finish(input) - }); + let result = self.expression_statement(input); choice.consider(input, result)?; - let result = ChoiceHelper::run(input, |mut choice, input| { - let result = self.if_statement(input); - choice.consider(input, result)?; - let result = self.for_statement(input); - choice.consider(input, result)?; - let result = self.while_statement(input); - choice.consider(input, result)?; - let result = self.do_while_statement(input); - choice.consider(input, result)?; - let result = self.continue_statement(input); + let result = self.variable_declaration_statement(input); + choice.consider(input, result)?; + let result = self.tuple_deconstruction_statement(input); + choice.consider(input, result)?; + let result = self.if_statement(input); + choice.consider(input, result)?; + let result = self.for_statement(input); + choice.consider(input, result)?; + let result = self.while_statement(input); + choice.consider(input, result)?; + let result = self.do_while_statement(input); + choice.consider(input, result)?; + let result = self.continue_statement(input); + choice.consider(input, result)?; + let result = self.break_statement(input); + choice.consider(input, result)?; + let result = self.delete_statement(input); + choice.consider(input, result)?; + let result = self.return_statement(input); + choice.consider(input, result)?; + if !self.version_is_at_least_0_5_0 { + let result = self.throw_statement(input); choice.consider(input, result)?; - let result = self.break_statement(input); + } + if self.version_is_at_least_0_4_21 { + let result = self.emit_statement(input); choice.consider(input, result)?; - let result = self.delete_statement(input); + } + if self.version_is_at_least_0_6_0 { + let result = self.try_statement(input); choice.consider(input, result)?; - let result = self.return_statement(input); + } + if self.version_is_at_least_0_8_4 { + let result = self.revert_statement(input); choice.consider(input, result)?; - if self.version_is_at_least_0_4_21 { - let result = self.emit_statement(input); - choice.consider(input, result)?; - } - if !self.version_is_at_least_0_5_0 { - let result = self.throw_statement(input); - choice.consider(input, result)?; - } - if self.version_is_at_least_0_6_0 { - let result = self.try_statement(input); - choice.consider(input, result)?; - } - if self.version_is_at_least_0_8_4 { - let result = self.revert_statement(input); - choice.consider(input, result)?; - } - choice.finish(input) - }); - choice.consider(input, result)?; + } let result = self.assembly_statement(input); choice.consider(input, result)?; let result = self.block(input); @@ -2085,6 +2267,13 @@ impl Language { choice.consider(input, result)?; let result = self.override_specifier(input); choice.consider(input, result)?; + if !self.version_is_at_least_0_5_0 { + let result = self.parse_token_with_trivia::( + input, + TokenKind::ConstantKeyword, + ); + choice.consider(input, result)?; + } let result = self.parse_token_with_trivia::( input, TokenKind::ExternalKeyword, @@ -2120,13 +2309,6 @@ impl Language { TokenKind::ViewKeyword, ); choice.consider(input, result)?; - if !self.version_is_at_least_0_5_0 { - let result = self.parse_token_with_trivia::( - input, - TokenKind::ConstantKeyword, - ); - choice.consider(input, result)?; - } if self.version_is_at_least_0_6_0 { let result = self.parse_token_with_trivia::( input, @@ -2140,23 +2322,6 @@ impl Language { .with_kind(RuleKind::FunctionAttributes) } - #[allow(unused_assignments, unused_parens)] - fn function_call_options(&self, input: &mut ParserContext) -> ParserResult { - ChoiceHelper::run(input, |mut choice, input| { - if self.version_is_at_least_0_6_2 && !self.version_is_at_least_0_8_0 { - let result = - OneOrMoreHelper::run(input, |input| self.named_arguments_declaration(input)); - choice.consider(input, result)?; - } - if self.version_is_at_least_0_8_0 { - let result = self.named_arguments_declaration(input); - choice.consider(input, result)?; - } - choice.finish(input) - }) - .with_kind(RuleKind::FunctionCallOptions) - } - #[allow(unused_assignments, unused_parens)] fn function_definition(&self, input: &mut ParserContext) -> ParserResult { SequenceHelper::run(|mut seq| { @@ -2186,13 +2351,13 @@ impl Language { seq.elem(OptionalHelper::transform(self.function_attributes(input)))?; seq.elem(OptionalHelper::transform(self.returns_declaration(input)))?; seq.elem(ChoiceHelper::run(input, |mut choice, input| { + let result = self.block(input); + choice.consider(input, result)?; let result = self.parse_token_with_trivia::( input, TokenKind::Semicolon, ); choice.consider(input, result)?; - let result = self.block(input); - choice.consider(input, result)?; choice.finish(input) }))?; seq.finish() @@ -2275,9 +2440,33 @@ impl Language { |mut choice, input| { let result = self.parse_token_with_trivia::( input, - TokenKind::DaysKeyword, + TokenKind::WeiKeyword, ); choice.consider(input, result)?; + if self.version_is_at_least_0_6_11 { + let result = self + .parse_token_with_trivia::( + input, + TokenKind::GweiKeyword, + ); + choice.consider(input, result)?; + } + if !self.version_is_at_least_0_7_0 { + let result = self + .parse_token_with_trivia::( + input, + TokenKind::SzaboKeyword, + ); + choice.consider(input, result)?; + } + if !self.version_is_at_least_0_7_0 { + let result = self + .parse_token_with_trivia::( + input, + TokenKind::FinneyKeyword, + ); + choice.consider(input, result)?; + } let result = self.parse_token_with_trivia::( input, TokenKind::EtherKeyword, @@ -2285,7 +2474,7 @@ impl Language { choice.consider(input, result)?; let result = self.parse_token_with_trivia::( input, - TokenKind::HoursKeyword, + TokenKind::SecondsKeyword, ); choice.consider(input, result)?; let result = self.parse_token_with_trivia::( @@ -2295,17 +2484,17 @@ impl Language { choice.consider(input, result)?; let result = self.parse_token_with_trivia::( input, - TokenKind::SecondsKeyword, + TokenKind::HoursKeyword, ); choice.consider(input, result)?; let result = self.parse_token_with_trivia::( input, - TokenKind::WeeksKeyword, + TokenKind::DaysKeyword, ); choice.consider(input, result)?; let result = self.parse_token_with_trivia::( input, - TokenKind::WeiKeyword, + TokenKind::WeeksKeyword, ); choice.consider(input, result)?; if !self.version_is_at_least_0_5_0 { @@ -2316,32 +2505,6 @@ impl Language { ); choice.consider(input, result)?; } - if self.version_is_at_least_0_6_11 { - let result = self - .parse_token_with_trivia::( - input, - TokenKind::GweiKeyword, - ); - choice.consider(input, result)?; - } - if !self.version_is_at_least_0_7_0 { - let result = ChoiceHelper::run(input, |mut choice, input| { - let result = self - .parse_token_with_trivia::( - input, - TokenKind::FinneyKeyword, - ); - choice.consider(input, result)?; - let result = self - .parse_token_with_trivia::( - input, - TokenKind::SzaboKeyword, - ); - choice.consider(input, result)?; - choice.finish(input) - }); - choice.consider(input, result)?; - } choice.finish(input) }, )))?; @@ -2408,52 +2571,44 @@ impl Language { seq.finish() }))?; seq.elem(ChoiceHelper::run(input, |mut choice, input| { - let result = ChoiceHelper::run(input, |mut choice, input| { - let result = self.expression_statement(input); - choice.consider(input, result)?; - let result = self.variable_declaration_statement(input); - choice.consider(input, result)?; - let result = self.tuple_deconstruction_statement(input); - choice.consider(input, result)?; - choice.finish(input) - }); + let result = self.expression_statement(input); choice.consider(input, result)?; - let result = ChoiceHelper::run(input, |mut choice, input| { - let result = self.if_statement(input); - choice.consider(input, result)?; - let result = self.for_statement(input); - choice.consider(input, result)?; - let result = self.while_statement(input); - choice.consider(input, result)?; - let result = self.do_while_statement(input); - choice.consider(input, result)?; - let result = self.continue_statement(input); + let result = self.variable_declaration_statement(input); + choice.consider(input, result)?; + let result = self.tuple_deconstruction_statement(input); + choice.consider(input, result)?; + let result = self.if_statement(input); + choice.consider(input, result)?; + let result = self.for_statement(input); + choice.consider(input, result)?; + let result = self.while_statement(input); + choice.consider(input, result)?; + let result = self.do_while_statement(input); + choice.consider(input, result)?; + let result = self.continue_statement(input); + choice.consider(input, result)?; + let result = self.break_statement(input); + choice.consider(input, result)?; + let result = self.delete_statement(input); + choice.consider(input, result)?; + let result = self.return_statement(input); + choice.consider(input, result)?; + if !self.version_is_at_least_0_5_0 { + let result = self.throw_statement(input); choice.consider(input, result)?; - let result = self.break_statement(input); + } + if self.version_is_at_least_0_4_21 { + let result = self.emit_statement(input); choice.consider(input, result)?; - let result = self.delete_statement(input); + } + if self.version_is_at_least_0_6_0 { + let result = self.try_statement(input); choice.consider(input, result)?; - let result = self.return_statement(input); + } + if self.version_is_at_least_0_8_4 { + let result = self.revert_statement(input); choice.consider(input, result)?; - if self.version_is_at_least_0_4_21 { - let result = self.emit_statement(input); - choice.consider(input, result)?; - } - if !self.version_is_at_least_0_5_0 { - let result = self.throw_statement(input); - choice.consider(input, result)?; - } - if self.version_is_at_least_0_6_0 { - let result = self.try_statement(input); - choice.consider(input, result)?; - } - if self.version_is_at_least_0_8_4 { - let result = self.revert_statement(input); - choice.consider(input, result)?; - } - choice.finish(input) - }); - choice.consider(input, result)?; + } let result = self.assembly_statement(input); choice.consider(input, result)?; let result = self.block(input); @@ -2464,75 +2619,28 @@ impl Language { } choice.finish(input) }))?; - seq.elem(OptionalHelper::transform(SequenceHelper::run(|mut seq| { - seq.elem(self.parse_token_with_trivia::( - input, - TokenKind::ElseKeyword, - ))?; - seq.elem(ChoiceHelper::run(input, |mut choice, input| { - let result = ChoiceHelper::run(input, |mut choice, input| { - let result = self.expression_statement(input); - choice.consider(input, result)?; - let result = self.variable_declaration_statement(input); - choice.consider(input, result)?; - let result = self.tuple_deconstruction_statement(input); - choice.consider(input, result)?; - choice.finish(input) - }); - choice.consider(input, result)?; - let result = ChoiceHelper::run(input, |mut choice, input| { - let result = self.if_statement(input); - choice.consider(input, result)?; - let result = self.for_statement(input); - choice.consider(input, result)?; - let result = self.while_statement(input); - choice.consider(input, result)?; - let result = self.do_while_statement(input); - choice.consider(input, result)?; - let result = self.continue_statement(input); - choice.consider(input, result)?; - let result = self.break_statement(input); - choice.consider(input, result)?; - let result = self.delete_statement(input); - choice.consider(input, result)?; - let result = self.return_statement(input); - choice.consider(input, result)?; - if self.version_is_at_least_0_4_21 { - let result = self.emit_statement(input); - choice.consider(input, result)?; - } - if !self.version_is_at_least_0_5_0 { - let result = self.throw_statement(input); - choice.consider(input, result)?; - } - if self.version_is_at_least_0_6_0 { - let result = self.try_statement(input); - choice.consider(input, result)?; - } - if self.version_is_at_least_0_8_4 { - let result = self.revert_statement(input); - choice.consider(input, result)?; - } - choice.finish(input) - }); - choice.consider(input, result)?; - let result = self.assembly_statement(input); - choice.consider(input, result)?; - let result = self.block(input); - choice.consider(input, result)?; - if self.version_is_at_least_0_8_0 { - let result = self.unchecked_block(input); - choice.consider(input, result)?; - } - choice.finish(input) - }))?; - seq.finish() - })))?; + seq.elem(OptionalHelper::transform(self.else_branch(input)))?; seq.finish() }) .with_kind(RuleKind::IfStatement) } + #[allow(unused_assignments, unused_parens)] + fn import_alias(&self, input: &mut ParserContext) -> ParserResult { + SequenceHelper::run(|mut seq| { + seq.elem(self.parse_token_with_trivia::( + input, + TokenKind::AsKeyword, + ))?; + seq.elem(self.parse_token_with_trivia::( + input, + TokenKind::Identifier, + ))?; + seq.finish() + }) + .with_kind(RuleKind::ImportAlias) + } + #[allow(unused_assignments, unused_parens)] fn import_deconstruction(&self, input: &mut ParserContext) -> ParserResult { SequenceHelper::run(|mut seq| { @@ -2578,17 +2686,7 @@ impl Language { input, TokenKind::Identifier, ))?; - seq.elem(OptionalHelper::transform(SequenceHelper::run(|mut seq| { - seq.elem(self.parse_token_with_trivia::( - input, - TokenKind::AsKeyword, - ))?; - seq.elem(self.parse_token_with_trivia::( - input, - TokenKind::Identifier, - ))?; - seq.finish() - })))?; + seq.elem(OptionalHelper::transform(self.import_alias(input)))?; seq.finish() }) .with_kind(RuleKind::ImportDeconstructionSymbol) @@ -2642,7 +2740,22 @@ impl Language { } #[allow(unused_assignments, unused_parens)] - fn inheritance_specifier(&self, input: &mut ParserContext) -> ParserResult { + fn index_access_end(&self, input: &mut ParserContext) -> ParserResult { + SequenceHelper::run(|mut seq| { + seq.elem( + self.parse_token_with_trivia::( + input, + TokenKind::Colon, + ), + )?; + seq.elem(OptionalHelper::transform(self.expression(input)))?; + seq.finish() + }) + .with_kind(RuleKind::IndexAccessEnd) + } + + #[allow(unused_assignments, unused_parens)] + fn inheritance_specifier(&self, input: &mut ParserContext) -> ParserResult { SequenceHelper::run(|mut seq| { seq.elem(self.parse_token_with_trivia::( input, @@ -2658,7 +2771,16 @@ impl Language { fn inheritance_type(&self, input: &mut ParserContext) -> ParserResult { SequenceHelper::run(|mut seq| { seq.elem(self.identifier_path(input))?; - seq.elem(OptionalHelper::transform(self.arguments_declaration(input)))?; + seq.elem(OptionalHelper::transform(ChoiceHelper::run( + input, + |mut choice, input| { + let result = self.positional_arguments_declaration(input); + choice.consider(input, result)?; + let result = self.named_arguments_declaration(input); + choice.consider(input, result)?; + choice.finish(input) + }, + )))?; seq.finish() }) .with_kind(RuleKind::InheritanceType) @@ -2722,34 +2844,32 @@ impl Language { choice.consider(input, result)?; let result = self.function_definition(input); choice.consider(input, result)?; - let result = self.modifier_definition(input); - choice.consider(input, result)?; - let result = self.struct_definition(input); - choice.consider(input, result)?; - let result = self.enum_definition(input); - choice.consider(input, result)?; - let result = self.event_definition(input); - choice.consider(input, result)?; - let result = self.state_variable_definition(input); - choice.consider(input, result)?; if self.version_is_at_least_0_4_22 { let result = self.constructor_definition(input); choice.consider(input, result)?; } if self.version_is_at_least_0_6_0 { - let result = ChoiceHelper::run(input, |mut choice, input| { - let result = self.fallback_function_definition(input); - choice.consider(input, result)?; - let result = self.receive_function_definition(input); - choice.consider(input, result)?; - choice.finish(input) - }); + let result = self.receive_function_definition(input); + choice.consider(input, result)?; + } + if self.version_is_at_least_0_6_0 { + let result = self.fallback_function_definition(input); choice.consider(input, result)?; } if !self.version_is_at_least_0_6_0 { let result = self.unnamed_function_definition(input); choice.consider(input, result)?; } + let result = self.modifier_definition(input); + choice.consider(input, result)?; + let result = self.struct_definition(input); + choice.consider(input, result)?; + let result = self.enum_definition(input); + choice.consider(input, result)?; + let result = self.event_definition(input); + choice.consider(input, result)?; + let result = self.state_variable_definition(input); + choice.consider(input, result)?; if self.version_is_at_least_0_8_4 { let result = self.error_definition(input); choice.consider(input, result)?; @@ -2834,34 +2954,32 @@ impl Language { choice.consider(input, result)?; let result = self.function_definition(input); choice.consider(input, result)?; - let result = self.modifier_definition(input); - choice.consider(input, result)?; - let result = self.struct_definition(input); - choice.consider(input, result)?; - let result = self.enum_definition(input); - choice.consider(input, result)?; - let result = self.event_definition(input); - choice.consider(input, result)?; - let result = self.state_variable_definition(input); - choice.consider(input, result)?; if self.version_is_at_least_0_4_22 { let result = self.constructor_definition(input); choice.consider(input, result)?; } if self.version_is_at_least_0_6_0 { - let result = ChoiceHelper::run(input, |mut choice, input| { - let result = self.fallback_function_definition(input); - choice.consider(input, result)?; - let result = self.receive_function_definition(input); - choice.consider(input, result)?; - choice.finish(input) - }); + let result = self.receive_function_definition(input); + choice.consider(input, result)?; + } + if self.version_is_at_least_0_6_0 { + let result = self.fallback_function_definition(input); choice.consider(input, result)?; } if !self.version_is_at_least_0_6_0 { let result = self.unnamed_function_definition(input); choice.consider(input, result)?; } + let result = self.modifier_definition(input); + choice.consider(input, result)?; + let result = self.struct_definition(input); + choice.consider(input, result)?; + let result = self.enum_definition(input); + choice.consider(input, result)?; + let result = self.event_definition(input); + choice.consider(input, result)?; + let result = self.state_variable_definition(input); + choice.consider(input, result)?; if self.version_is_at_least_0_8_4 { let result = self.error_definition(input); choice.consider(input, result)?; @@ -2877,7 +2995,7 @@ impl Language { } #[allow(unused_assignments, unused_parens)] - fn mapping_key_type(&self, input: &mut ParserContext) -> ParserResult { + fn mapping_key(&self, input: &mut ParserContext) -> ParserResult { SequenceHelper::run(|mut seq| { seq.elem(ChoiceHelper::run(input, |mut choice, input| { let result = ChoiceHelper::run(input, |mut choice, input| { @@ -2886,6 +3004,13 @@ impl Language { TokenKind::BoolKeyword, ); choice.consider(input, result)?; + if !self.version_is_at_least_0_8_0 { + let result = self.parse_token_with_trivia::( + input, + TokenKind::ByteKeyword, + ); + choice.consider(input, result)?; + } let result = self.parse_token_with_trivia::( input, TokenKind::StringKeyword, @@ -2893,6 +3018,11 @@ impl Language { choice.consider(input, result)?; let result = self.address_type(input); choice.consider(input, result)?; + let result = self.parse_token_with_trivia::( + input, + TokenKind::PayableKeyword, + ); + choice.consider(input, result)?; let result = self.parse_token_with_trivia::( input, TokenKind::BytesKeyword, @@ -2918,13 +3048,6 @@ impl Language { TokenKind::UfixedKeyword, ); choice.consider(input, result)?; - if !self.version_is_at_least_0_8_0 { - let result = self.parse_token_with_trivia::( - input, - TokenKind::ByteKeyword, - ); - choice.consider(input, result)?; - } choice.finish(input) }); choice.consider(input, result)?; @@ -2942,7 +3065,7 @@ impl Language { } seq.finish() }) - .with_kind(RuleKind::MappingKeyType) + .with_kind(RuleKind::MappingKey) } #[allow(unused_assignments, unused_parens)] @@ -2961,12 +3084,12 @@ impl Language { ))?; seq.elem( SequenceHelper::run(|mut seq| { - seq.elem(self.mapping_key_type(input))?; + seq.elem(self.mapping_key(input))?; seq.elem(self.parse_token_with_trivia::( input, TokenKind::EqualGreaterThan, ))?; - seq.elem(self.mapping_value_type(input))?; + seq.elem(self.mapping_value(input))?; seq.finish() }) .recover_until_with_nested_delims::<_, LexicalContextType::Default>( @@ -2988,7 +3111,7 @@ impl Language { } #[allow(unused_assignments, unused_parens)] - fn mapping_value_type(&self, input: &mut ParserContext) -> ParserResult { + fn mapping_value(&self, input: &mut ParserContext) -> ParserResult { SequenceHelper::run(|mut seq| { seq.elem(self.type_name(input))?; if self.version_is_at_least_0_8_18 { @@ -3001,7 +3124,7 @@ impl Language { } seq.finish() }) - .with_kind(RuleKind::MappingValueType) + .with_kind(RuleKind::MappingValue) } #[allow(unused_assignments, unused_parens)] @@ -3039,13 +3162,13 @@ impl Language { ))?; seq.elem(OptionalHelper::transform(self.modifier_attributes(input)))?; seq.elem(ChoiceHelper::run(input, |mut choice, input| { + let result = self.block(input); + choice.consider(input, result)?; let result = self.parse_token_with_trivia::( input, TokenKind::Semicolon, ); choice.consider(input, result)?; - let result = self.block(input); - choice.consider(input, result)?; choice.finish(input) }))?; seq.finish() @@ -3057,7 +3180,16 @@ impl Language { fn modifier_invocation(&self, input: &mut ParserContext) -> ParserResult { SequenceHelper::run(|mut seq| { seq.elem(self.identifier_path(input))?; - seq.elem(OptionalHelper::transform(self.arguments_declaration(input)))?; + seq.elem(OptionalHelper::transform(ChoiceHelper::run( + input, + |mut choice, input| { + let result = self.positional_arguments_declaration(input); + choice.consider(input, result)?; + let result = self.named_arguments_declaration(input); + choice.consider(input, result)?; + choice.finish(input) + }, + )))?; seq.finish() }) .with_kind(RuleKind::ModifierInvocation) @@ -3083,18 +3215,7 @@ impl Language { } #[allow(unused_assignments, unused_parens)] - fn named_arguments(&self, input: &mut ParserContext) -> ParserResult { - SeparatedHelper::run::<_, LexicalContextType::Default>( - input, - self, - |input| self.named_argument(input), - TokenKind::Comma, - ) - .with_kind(RuleKind::NamedArguments) - } - - #[allow(unused_assignments, unused_parens)] - fn named_arguments_declaration(&self, input: &mut ParserContext) -> ParserResult { + fn named_argument_group(&self, input: &mut ParserContext) -> ParserResult { SequenceHelper::run(|mut seq| { let mut delim_guard = input.open_delim(TokenKind::CloseBrace); let input = delim_guard.ctx(); @@ -3117,24 +3238,65 @@ impl Language { ))?; seq.finish() }) - .with_kind(RuleKind::NamedArgumentsDeclaration) + .with_kind(RuleKind::NamedArgumentGroup) } #[allow(unused_assignments, unused_parens)] - fn named_import(&self, input: &mut ParserContext) -> ParserResult { + fn named_argument_groups(&self, input: &mut ParserContext) -> ParserResult { + if self.version_is_at_least_0_6_2 && !self.version_is_at_least_0_8_0 { + OneOrMoreHelper::run(input, |input| self.named_argument_group(input)) + } else { + ParserResult::disabled() + } + .with_kind(RuleKind::NamedArgumentGroups) + } + + #[allow(unused_assignments, unused_parens)] + fn named_arguments(&self, input: &mut ParserContext) -> ParserResult { + SeparatedHelper::run::<_, LexicalContextType::Default>( + input, + self, + |input| self.named_argument(input), + TokenKind::Comma, + ) + .with_kind(RuleKind::NamedArguments) + } + + #[allow(unused_assignments, unused_parens)] + fn named_arguments_declaration(&self, input: &mut ParserContext) -> ParserResult { SequenceHelper::run(|mut seq| { + let mut delim_guard = input.open_delim(TokenKind::CloseParen); + let input = delim_guard.ctx(); seq.elem(self.parse_token_with_trivia::( input, - TokenKind::Asterisk, + TokenKind::OpenParen, ))?; + seq.elem( + OptionalHelper::transform(self.named_argument_group(input)) + .recover_until_with_nested_delims::<_, LexicalContextType::Default>( + input, + self, + TokenKind::CloseParen, + RecoverFromNoMatch::Yes, + ), + )?; seq.elem(self.parse_token_with_trivia::( input, - TokenKind::AsKeyword, + TokenKind::CloseParen, ))?; + seq.finish() + }) + .with_kind(RuleKind::NamedArgumentsDeclaration) + } + + #[allow(unused_assignments, unused_parens)] + fn named_import(&self, input: &mut ParserContext) -> ParserResult { + SequenceHelper::run(|mut seq| { seq.elem(self.parse_token_with_trivia::( input, - TokenKind::Identifier, + TokenKind::Asterisk, ))?; + seq.elem(self.import_alias(input))?; seq.elem(self.parse_token_with_trivia::( input, TokenKind::FromKeyword, @@ -3173,34 +3335,42 @@ impl Language { } #[allow(unused_assignments, unused_parens)] - fn override_specifier(&self, input: &mut ParserContext) -> ParserResult { + fn override_paths_declaration(&self, input: &mut ParserContext) -> ParserResult { SequenceHelper::run(|mut seq| { + let mut delim_guard = input.open_delim(TokenKind::CloseParen); + let input = delim_guard.ctx(); seq.elem(self.parse_token_with_trivia::( input, - TokenKind::OverrideKeyword, + TokenKind::OpenParen, ))?; - seq.elem(OptionalHelper::transform(SequenceHelper::run(|mut seq| { - let mut delim_guard = input.open_delim(TokenKind::CloseParen); - let input = delim_guard.ctx(); - seq.elem(self.parse_token_with_trivia::( - input, - TokenKind::OpenParen, - ))?; - seq.elem( - OptionalHelper::transform(self.override_paths(input)) - .recover_until_with_nested_delims::<_, LexicalContextType::Default>( + seq.elem( + self.override_paths(input) + .recover_until_with_nested_delims::<_, LexicalContextType::Default>( input, self, TokenKind::CloseParen, RecoverFromNoMatch::Yes, ), - )?; - seq.elem(self.parse_token_with_trivia::( - input, - TokenKind::CloseParen, - ))?; - seq.finish() - })))?; + )?; + seq.elem(self.parse_token_with_trivia::( + input, + TokenKind::CloseParen, + ))?; + seq.finish() + }) + .with_kind(RuleKind::OverridePathsDeclaration) + } + + #[allow(unused_assignments, unused_parens)] + fn override_specifier(&self, input: &mut ParserContext) -> ParserResult { + SequenceHelper::run(|mut seq| { + seq.elem(self.parse_token_with_trivia::( + input, + TokenKind::OverrideKeyword, + ))?; + seq.elem(OptionalHelper::transform( + self.override_paths_declaration(input), + ))?; seq.finish() }) .with_kind(RuleKind::OverrideSpecifier) @@ -3226,7 +3396,7 @@ impl Language { if self.version_is_at_least_0_5_0 { let result = self.parse_token_with_trivia::( input, - TokenKind::CalldataKeyword, + TokenKind::CallDataKeyword, ); choice.consider(input, result)?; } @@ -3289,17 +3459,7 @@ impl Language { input, TokenKind::AsciiStringLiteral, ))?; - seq.elem(OptionalHelper::transform(SequenceHelper::run(|mut seq| { - seq.elem(self.parse_token_with_trivia::( - input, - TokenKind::AsKeyword, - ))?; - seq.elem(self.parse_token_with_trivia::( - input, - TokenKind::Identifier, - ))?; - seq.finish() - })))?; + seq.elem(OptionalHelper::transform(self.import_alias(input)))?; seq.finish() }) .with_kind(RuleKind::PathImport) @@ -3316,12 +3476,39 @@ impl Language { .with_kind(RuleKind::PositionalArguments) } + #[allow(unused_assignments, unused_parens)] + fn positional_arguments_declaration(&self, input: &mut ParserContext) -> ParserResult { + SequenceHelper::run(|mut seq| { + let mut delim_guard = input.open_delim(TokenKind::CloseParen); + let input = delim_guard.ctx(); + seq.elem(self.parse_token_with_trivia::( + input, + TokenKind::OpenParen, + ))?; + seq.elem( + OptionalHelper::transform(self.positional_arguments(input)) + .recover_until_with_nested_delims::<_, LexicalContextType::Default>( + input, + self, + TokenKind::CloseParen, + RecoverFromNoMatch::Yes, + ), + )?; + seq.elem(self.parse_token_with_trivia::( + input, + TokenKind::CloseParen, + ))?; + seq.finish() + }) + .with_kind(RuleKind::PositionalArgumentsDeclaration) + } + #[allow(unused_assignments, unused_parens)] fn pragma_directive(&self, input: &mut ParserContext) -> ParserResult { SequenceHelper::run(|mut seq| { seq.elem( SequenceHelper::run(|mut seq| { - seq.elem(self.parse_token_with_trivia::( + seq.elem(self.parse_token_with_trivia::( input, TokenKind::PragmaKeyword, ))?; @@ -3336,14 +3523,14 @@ impl Language { }))?; seq.finish() }) - .recover_until_with_nested_delims::<_, LexicalContextType::Default>( + .recover_until_with_nested_delims::<_, LexicalContextType::Pragma>( input, self, TokenKind::Semicolon, RecoverFromNoMatch::No, ), )?; - seq.elem(self.parse_token_with_trivia::( + seq.elem(self.parse_token_with_trivia::( input, TokenKind::Semicolon, ))?; @@ -3402,13 +3589,13 @@ impl Language { self.receive_function_attributes(input), ))?; seq.elem(ChoiceHelper::run(input, |mut choice, input| { + let result = self.block(input); + choice.consider(input, result)?; let result = self.parse_token_with_trivia::( input, TokenKind::Semicolon, ); choice.consider(input, result)?; - let result = self.block(input); - choice.consider(input, result)?; choice.finish(input) }))?; seq.finish() @@ -3462,30 +3649,40 @@ impl Language { #[allow(unused_assignments, unused_parens)] fn revert_statement(&self, input: &mut ParserContext) -> ParserResult { - SequenceHelper::run(|mut seq| { - seq.elem( - SequenceHelper::run(|mut seq| { - seq.elem(self.parse_token_with_trivia::( - input, - TokenKind::RevertKeyword, - ))?; - seq.elem(OptionalHelper::transform(self.identifier_path(input)))?; - seq.elem(self.arguments_declaration(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() - }) + if self.version_is_at_least_0_8_4 { + SequenceHelper::run(|mut seq| { + seq.elem( + SequenceHelper::run(|mut seq| { + seq.elem(self.parse_token_with_trivia::( + input, + TokenKind::RevertKeyword, + ))?; + seq.elem(OptionalHelper::transform(self.identifier_path(input)))?; + seq.elem(ChoiceHelper::run(input, |mut choice, input| { + let result = self.positional_arguments_declaration(input); + choice.consider(input, result)?; + let result = self.named_arguments_declaration(input); + choice.consider(input, result)?; + choice.finish(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() + }) + } else { + ParserResult::disabled() + } .with_kind(RuleKind::RevertStatement) } @@ -3514,13 +3711,11 @@ impl Language { let result = self.library_definition(input); choice.consider(input, result)?; if self.version_is_at_least_0_6_0 { - let result = ChoiceHelper::run(input, |mut choice, input| { - let result = self.struct_definition(input); - choice.consider(input, result)?; - let result = self.enum_definition(input); - choice.consider(input, result)?; - choice.finish(input) - }); + let result = self.struct_definition(input); + choice.consider(input, result)?; + } + if self.version_is_at_least_0_6_0 { + let result = self.enum_definition(input); choice.consider(input, result)?; } if self.version_is_at_least_0_7_1 { @@ -3605,14 +3800,9 @@ impl Language { input, TokenKind::Identifier, ))?; - seq.elem(OptionalHelper::transform(SequenceHelper::run(|mut seq| { - seq.elem(self.parse_token_with_trivia::( - input, - TokenKind::Equal, - ))?; - seq.elem(self.expression(input))?; - seq.finish() - })))?; + seq.elem(OptionalHelper::transform( + self.state_variable_definition_value(input), + ))?; seq.finish() }) .recover_until_with_nested_delims::<_, LexicalContextType::Default>( @@ -3631,56 +3821,63 @@ impl Language { .with_kind(RuleKind::StateVariableDefinition) } + #[allow(unused_assignments, unused_parens)] + fn state_variable_definition_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::StateVariableDefinitionValue) + } + #[allow(unused_assignments, unused_parens)] fn statements(&self, input: &mut ParserContext) -> ParserResult { OneOrMoreHelper::run(input, |input| { ChoiceHelper::run(input, |mut choice, input| { - let result = ChoiceHelper::run(input, |mut choice, input| { - let result = self.expression_statement(input); - choice.consider(input, result)?; - let result = self.variable_declaration_statement(input); - choice.consider(input, result)?; - let result = self.tuple_deconstruction_statement(input); - choice.consider(input, result)?; - choice.finish(input) - }); + let result = self.expression_statement(input); choice.consider(input, result)?; - let result = ChoiceHelper::run(input, |mut choice, input| { - let result = self.if_statement(input); - choice.consider(input, result)?; - let result = self.for_statement(input); - choice.consider(input, result)?; - let result = self.while_statement(input); - choice.consider(input, result)?; - let result = self.do_while_statement(input); - choice.consider(input, result)?; - let result = self.continue_statement(input); + let result = self.variable_declaration_statement(input); + choice.consider(input, result)?; + let result = self.tuple_deconstruction_statement(input); + choice.consider(input, result)?; + let result = self.if_statement(input); + choice.consider(input, result)?; + let result = self.for_statement(input); + choice.consider(input, result)?; + let result = self.while_statement(input); + choice.consider(input, result)?; + let result = self.do_while_statement(input); + choice.consider(input, result)?; + let result = self.continue_statement(input); + choice.consider(input, result)?; + let result = self.break_statement(input); + choice.consider(input, result)?; + let result = self.delete_statement(input); + choice.consider(input, result)?; + let result = self.return_statement(input); + choice.consider(input, result)?; + if !self.version_is_at_least_0_5_0 { + let result = self.throw_statement(input); choice.consider(input, result)?; - let result = self.break_statement(input); + } + if self.version_is_at_least_0_4_21 { + let result = self.emit_statement(input); choice.consider(input, result)?; - let result = self.delete_statement(input); + } + if self.version_is_at_least_0_6_0 { + let result = self.try_statement(input); choice.consider(input, result)?; - let result = self.return_statement(input); + } + if self.version_is_at_least_0_8_4 { + let result = self.revert_statement(input); choice.consider(input, result)?; - if self.version_is_at_least_0_4_21 { - let result = self.emit_statement(input); - choice.consider(input, result)?; - } - if !self.version_is_at_least_0_5_0 { - let result = self.throw_statement(input); - choice.consider(input, result)?; - } - if self.version_is_at_least_0_6_0 { - let result = self.try_statement(input); - choice.consider(input, result)?; - } - if self.version_is_at_least_0_8_4 { - let result = self.revert_statement(input); - choice.consider(input, result)?; - } - choice.finish(input) - }); - choice.consider(input, result)?; + } let result = self.assembly_statement(input); choice.consider(input, result)?; let result = self.block(input); @@ -3933,12 +4130,17 @@ impl Language { .with_kind(RuleKind::TupleExpression) } + #[allow(unused_assignments, unused_parens)] + fn tuple_value(&self, input: &mut ParserContext) -> ParserResult { + OptionalHelper::transform(self.expression(input)).with_kind(RuleKind::TupleValue) + } + #[allow(unused_assignments, unused_parens)] fn tuple_values(&self, input: &mut ParserContext) -> ParserResult { SeparatedHelper::run::<_, LexicalContextType::Default>( input, self, - |input| OptionalHelper::transform(self.expression(input)), + |input| self.tuple_value(input), TokenKind::Comma, ) .with_kind(RuleKind::TupleValues) @@ -3984,7 +4186,7 @@ impl Language { #[allow(unused_assignments, unused_parens)] fn type_name(&self, input: &mut ParserContext) -> ParserResult { - let parse_array_type_name_operator = |input: &mut ParserContext| { + let parse_array_type_name = |input: &mut ParserContext| { PrecedenceHelper::to_postfix_operator( RuleKind::ArrayTypeName, 1u8, @@ -4024,6 +4226,13 @@ impl Language { TokenKind::BoolKeyword, ); choice.consider(input, result)?; + if !self.version_is_at_least_0_8_0 { + let result = self.parse_token_with_trivia::( + input, + TokenKind::ByteKeyword, + ); + choice.consider(input, result)?; + } let result = self.parse_token_with_trivia::( input, TokenKind::StringKeyword, @@ -4031,6 +4240,11 @@ impl Language { choice.consider(input, result)?; let result = self.address_type(input); choice.consider(input, result)?; + let result = self.parse_token_with_trivia::( + input, + TokenKind::PayableKeyword, + ); + choice.consider(input, result)?; let result = self.parse_token_with_trivia::( input, TokenKind::BytesKeyword, @@ -4056,13 +4270,6 @@ impl Language { TokenKind::UfixedKeyword, ); choice.consider(input, result)?; - if !self.version_is_at_least_0_8_0 { - let result = self.parse_token_with_trivia::( - input, - TokenKind::ByteKeyword, - ); - choice.consider(input, result)?; - } choice.finish(input) }); choice.consider(input, result)?; @@ -4073,7 +4280,7 @@ impl Language { }; let postfix_operator_parser = |input: &mut ParserContext| { ChoiceHelper::run(input, |mut choice, input| { - let result = parse_array_type_name_operator(input); + let result = parse_array_type_name(input); choice.consider(input, result)?; choice.finish(input) }) @@ -4114,7 +4321,7 @@ impl Language { if self.version_is_at_least_0_5_0 { let result = self.parse_token_with_trivia::( input, - TokenKind::CalldataKeyword, + TokenKind::CallDataKeyword, ); choice.consider(input, result)?; } @@ -4217,13 +4424,13 @@ impl Language { self.unnamed_function_attributes(input), ))?; seq.elem(ChoiceHelper::run(input, |mut choice, input| { + let result = self.block(input); + choice.consider(input, result)?; let result = self.parse_token_with_trivia::( input, TokenKind::Semicolon, ); choice.consider(input, result)?; - let result = self.block(input); - choice.consider(input, result)?; choice.finish(input) }))?; seq.finish() @@ -4253,7 +4460,7 @@ impl Language { if self.version_is_at_least_0_5_0 { let result = self.parse_token_with_trivia::( input, - TokenKind::CalldataKeyword, + TokenKind::CallDataKeyword, ); choice.consider(input, result)?; } @@ -4294,6 +4501,14 @@ impl Language { TokenKind::BoolKeyword, ); choice.consider(input, result)?; + if !self.version_is_at_least_0_8_0 { + let result = self + .parse_token_with_trivia::( + input, + TokenKind::ByteKeyword, + ); + choice.consider(input, result)?; + } let result = self .parse_token_with_trivia::( input, @@ -4302,6 +4517,12 @@ impl Language { choice.consider(input, result)?; let result = self.address_type(input); choice.consider(input, result)?; + let result = self + .parse_token_with_trivia::( + input, + TokenKind::PayableKeyword, + ); + choice.consider(input, result)?; let result = self .parse_token_with_trivia::( input, @@ -4332,14 +4553,6 @@ impl Language { TokenKind::UfixedKeyword, ); choice.consider(input, result)?; - if !self.version_is_at_least_0_8_0 { - let result = self - .parse_token_with_trivia::( - input, - TokenKind::ByteKeyword, - ); - choice.consider(input, result)?; - } choice.finish(input) }))?; seq.finish() @@ -4363,6 +4576,100 @@ impl Language { .with_kind(RuleKind::UserDefinedValueTypeDefinition) } + #[allow(unused_assignments, unused_parens)] + fn using_alias(&self, input: &mut ParserContext) -> ParserResult { + if self.version_is_at_least_0_8_19 { + SequenceHelper::run(|mut seq| { + seq.elem(self.parse_token_with_trivia::( + input, + TokenKind::AsKeyword, + ))?; + seq.elem(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) + }))?; + seq.finish() + }) + } else { + ParserResult::disabled() + } + .with_kind(RuleKind::UsingAlias) + } + #[allow(unused_assignments, unused_parens)] fn using_deconstruction(&self, input: &mut ParserContext) -> ParserResult { if self.version_is_at_least_0_8_13 { @@ -4400,110 +4707,7 @@ impl Language { SequenceHelper::run(|mut seq| { seq.elem(self.identifier_path(input))?; if self.version_is_at_least_0_8_19 { - seq.elem(OptionalHelper::transform(SequenceHelper::run(|mut seq| { - seq.elem(self.parse_token_with_trivia::( - input, - TokenKind::AsKeyword, - ))?; - seq.elem(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() - })?; - seq.finish() - })))?; + seq.elem(OptionalHelper::transform(self.using_alias(input)))?; } seq.finish() }) @@ -4551,13 +4755,13 @@ impl Language { TokenKind::ForKeyword, ))?; seq.elem(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)?; - let result = self.type_name(input); - choice.consider(input, result)?; choice.finish(input) }))?; if self.version_is_at_least_0_8_13 { @@ -4586,67 +4790,57 @@ impl Language { .with_kind(RuleKind::UsingDirective) } - #[allow(unused_assignments, unused_parens)] - fn variable_declaration(&self, input: &mut ParserContext) -> ParserResult { - SequenceHelper::run(|mut seq| { - seq.elem(ChoiceHelper::run(input, |mut choice, input| { - if !self.version_is_at_least_0_5_0 { - let result = self.parse_token_with_trivia::( - input, - TokenKind::VarKeyword, - ); - choice.consider(input, result)?; - } - let result = self.type_name(input); - choice.consider(input, result)?; - choice.finish(input) - }))?; - seq.elem(OptionalHelper::transform(ChoiceHelper::run( - input, - |mut choice, input| { - let result = self.parse_token_with_trivia::( - input, - TokenKind::MemoryKeyword, - ); - choice.consider(input, result)?; - let result = self.parse_token_with_trivia::( - input, - TokenKind::StorageKeyword, - ); - choice.consider(input, result)?; - if self.version_is_at_least_0_5_0 { - let result = self.parse_token_with_trivia::( - input, - TokenKind::CalldataKeyword, - ); - choice.consider(input, result)?; - } - choice.finish(input) - }, - )))?; - seq.elem(self.parse_token_with_trivia::( - input, - TokenKind::Identifier, - ))?; - seq.finish() - }) - .with_kind(RuleKind::VariableDeclaration) - } - #[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(input))?; - seq.elem(OptionalHelper::transform(SequenceHelper::run(|mut seq| { - seq.elem(self.parse_token_with_trivia::( - input, - TokenKind::Equal, - ))?; - seq.elem(self.expression(input))?; - seq.finish() - })))?; + seq.elem(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) + }))?; + seq.elem(OptionalHelper::transform(ChoiceHelper::run( + input, + |mut choice, input| { + let result = self + .parse_token_with_trivia::( + input, + TokenKind::MemoryKeyword, + ); + choice.consider(input, result)?; + let result = self + .parse_token_with_trivia::( + input, + TokenKind::StorageKeyword, + ); + choice.consider(input, result)?; + if self.version_is_at_least_0_5_0 { + let result = self + .parse_token_with_trivia::( + input, + TokenKind::CallDataKeyword, + ); + choice.consider(input, result)?; + } + choice.finish(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>( @@ -4666,14 +4860,27 @@ impl Language { } #[allow(unused_assignments, unused_parens)] - fn version_pragma(&self, input: &mut ParserContext) -> ParserResult { + fn variable_declaration_value(&self, input: &mut ParserContext) -> ParserResult { SequenceHelper::run(|mut seq| { seq.elem( - self.parse_token_with_trivia::( + self.parse_token_with_trivia::( input, - TokenKind::SolidityKeyword, + 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() }) @@ -4682,64 +4889,61 @@ impl Language { #[allow(unused_assignments, unused_parens)] fn version_pragma_expression(&self, input: &mut ParserContext) -> ParserResult { - let parse_version_pragma_or_operator = |input: &mut ParserContext| { + let parse_version_pragma_or_expression = |input: &mut ParserContext| { PrecedenceHelper::to_binary_operator( RuleKind::VersionPragmaBinaryExpression, 1u8, 1u8 + 1, - self.parse_token_with_trivia::( + self.parse_token_with_trivia::( input, TokenKind::BarBar, ), ) }; - let parse_version_pragma_range_operator = |input: &mut ParserContext| { + 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, - ), + self.parse_token_with_trivia::(input, TokenKind::Minus), ) }; - let parse_version_pragma_unary_operator = |input: &mut ParserContext| { + 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::( + let result = self.parse_token_with_trivia::( input, TokenKind::Caret, ); choice.consider(input, result)?; - let result = self.parse_token_with_trivia::( + let result = self.parse_token_with_trivia::( input, TokenKind::Tilde, ); choice.consider(input, result)?; - let result = self.parse_token_with_trivia::( + let result = self.parse_token_with_trivia::( input, TokenKind::Equal, ); choice.consider(input, result)?; - let result = self.parse_token_with_trivia::( + let result = self.parse_token_with_trivia::( input, TokenKind::LessThan, ); choice.consider(input, result)?; - let result = self.parse_token_with_trivia::( + let result = self.parse_token_with_trivia::( input, TokenKind::GreaterThan, ); choice.consider(input, result)?; - let result = self.parse_token_with_trivia::( + let result = self.parse_token_with_trivia::( input, TokenKind::LessThanEqual, ); choice.consider(input, result)?; - let result = self.parse_token_with_trivia::( + let result = self.parse_token_with_trivia::( input, TokenKind::GreaterThanEqual, ); @@ -4750,7 +4954,7 @@ impl Language { }; let prefix_operator_parser = |input: &mut ParserContext| { ChoiceHelper::run(input, |mut choice, input| { - let result = parse_version_pragma_unary_operator(input); + let result = parse_version_pragma_prefix_expression(input); choice.consider(input, result)?; choice.finish(input) }) @@ -4768,9 +4972,9 @@ impl Language { }; let binary_operator_parser = |input: &mut ParserContext| { ChoiceHelper::run(input, |mut choice, input| { - let result = parse_version_pragma_or_operator(input); + let result = parse_version_pragma_or_expression(input); choice.consider(input, result)?; - let result = parse_version_pragma_range_operator(input); + let result = parse_version_pragma_range_expression(input); choice.consider(input, result)?; choice.finish(input) }) @@ -4803,11 +5007,11 @@ impl Language { #[allow(unused_assignments, unused_parens)] fn version_pragma_specifier(&self, input: &mut ParserContext) -> ParserResult { - SeparatedHelper::run::<_, LexicalContextType::VersionPragma>( + SeparatedHelper::run::<_, LexicalContextType::Pragma>( input, self, |input| { - self.parse_token_with_trivia::( + self.parse_token_with_trivia::( input, TokenKind::VersionPragmaValue, ) @@ -4847,52 +5051,44 @@ impl Language { seq.finish() }))?; seq.elem(ChoiceHelper::run(input, |mut choice, input| { - let result = ChoiceHelper::run(input, |mut choice, input| { - let result = self.expression_statement(input); - choice.consider(input, result)?; - let result = self.variable_declaration_statement(input); - choice.consider(input, result)?; - let result = self.tuple_deconstruction_statement(input); - choice.consider(input, result)?; - choice.finish(input) - }); + let result = self.expression_statement(input); choice.consider(input, result)?; - let result = ChoiceHelper::run(input, |mut choice, input| { - let result = self.if_statement(input); - choice.consider(input, result)?; - let result = self.for_statement(input); - choice.consider(input, result)?; - let result = self.while_statement(input); - choice.consider(input, result)?; - let result = self.do_while_statement(input); - choice.consider(input, result)?; - let result = self.continue_statement(input); + let result = self.variable_declaration_statement(input); + choice.consider(input, result)?; + let result = self.tuple_deconstruction_statement(input); + choice.consider(input, result)?; + let result = self.if_statement(input); + choice.consider(input, result)?; + let result = self.for_statement(input); + choice.consider(input, result)?; + let result = self.while_statement(input); + choice.consider(input, result)?; + let result = self.do_while_statement(input); + choice.consider(input, result)?; + let result = self.continue_statement(input); + choice.consider(input, result)?; + let result = self.break_statement(input); + choice.consider(input, result)?; + let result = self.delete_statement(input); + choice.consider(input, result)?; + let result = self.return_statement(input); + choice.consider(input, result)?; + if !self.version_is_at_least_0_5_0 { + let result = self.throw_statement(input); choice.consider(input, result)?; - let result = self.break_statement(input); + } + if self.version_is_at_least_0_4_21 { + let result = self.emit_statement(input); choice.consider(input, result)?; - let result = self.delete_statement(input); + } + if self.version_is_at_least_0_6_0 { + let result = self.try_statement(input); choice.consider(input, result)?; - let result = self.return_statement(input); + } + if self.version_is_at_least_0_8_4 { + let result = self.revert_statement(input); choice.consider(input, result)?; - if self.version_is_at_least_0_4_21 { - let result = self.emit_statement(input); - choice.consider(input, result)?; - } - if !self.version_is_at_least_0_5_0 { - let result = self.throw_statement(input); - choice.consider(input, result)?; - } - if self.version_is_at_least_0_6_0 { - let result = self.try_statement(input); - choice.consider(input, result)?; - } - if self.version_is_at_least_0_8_4 { - let result = self.revert_statement(input); - choice.consider(input, result)?; - } - choice.finish(input) - }); - choice.consider(input, result)?; + } let result = self.assembly_statement(input); choice.consider(input, result)?; let result = self.block(input); @@ -4910,7 +5106,7 @@ impl Language { #[allow(unused_assignments, unused_parens)] fn yul_arguments(&self, input: &mut ParserContext) -> ParserResult { - SeparatedHelper::run::<_, LexicalContextType::YulBlock>( + SeparatedHelper::run::<_, LexicalContextType::Yul>( input, self, |input| self.yul_expression(input), @@ -4924,7 +5120,7 @@ impl Language { SequenceHelper::run(|mut seq| { seq.elem(self.yul_identifier_paths(input))?; seq.elem( - self.parse_token_with_trivia::( + self.parse_token_with_trivia::( input, TokenKind::ColonEqual, ), @@ -4941,14 +5137,14 @@ impl Language { let mut delim_guard = input.open_delim(TokenKind::CloseBrace); let input = delim_guard.ctx(); seq.elem( - self.parse_token_with_trivia::( + self.parse_token_with_trivia::( input, TokenKind::OpenBrace, ), )?; seq.elem( OptionalHelper::transform(self.yul_statements(input)) - .recover_until_with_nested_delims::<_, LexicalContextType::YulBlock>( + .recover_until_with_nested_delims::<_, LexicalContextType::Yul>( input, self, TokenKind::CloseBrace, @@ -4956,7 +5152,7 @@ impl Language { ), )?; seq.elem( - self.parse_token_with_trivia::( + self.parse_token_with_trivia::( input, TokenKind::CloseBrace, ), @@ -4968,74 +5164,58 @@ impl Language { #[allow(unused_assignments, unused_parens)] fn yul_break_statement(&self, input: &mut ParserContext) -> ParserResult { - self.parse_token_with_trivia::(input, TokenKind::BreakKeyword) + self.parse_token_with_trivia::(input, TokenKind::YulBreakKeyword) .with_kind(RuleKind::YulBreakStatement) } #[allow(unused_assignments, unused_parens)] fn yul_continue_statement(&self, input: &mut ParserContext) -> ParserResult { - self.parse_token_with_trivia::( + self.parse_token_with_trivia::( input, - TokenKind::ContinueKeyword, + TokenKind::YulContinueKeyword, ) .with_kind(RuleKind::YulContinueStatement) } #[allow(unused_assignments, unused_parens)] - fn yul_declaration_statement(&self, input: &mut ParserContext) -> ParserResult { + fn yul_default_case(&self, input: &mut ParserContext) -> ParserResult { SequenceHelper::run(|mut seq| { - seq.elem( - self.parse_token_with_trivia::( - input, - TokenKind::LetKeyword, - ), - )?; - seq.elem(self.yul_identifier_paths(input))?; - seq.elem(OptionalHelper::transform(SequenceHelper::run(|mut seq| { - seq.elem( - self.parse_token_with_trivia::( - input, - TokenKind::ColonEqual, - ), - )?; - seq.elem(self.yul_expression(input))?; - seq.finish() - })))?; + seq.elem(self.parse_token_with_trivia::( + input, + TokenKind::YulDefaultKeyword, + ))?; + seq.elem(self.yul_block(input))?; seq.finish() }) - .with_kind(RuleKind::YulDeclarationStatement) + .with_kind(RuleKind::YulDefaultCase) } #[allow(unused_assignments, unused_parens)] fn yul_expression(&self, input: &mut ParserContext) -> ParserResult { - let parse_yul_function_call_operator = |input: &mut ParserContext| { + let parse_yul_function_call_expression = |input: &mut ParserContext| { PrecedenceHelper::to_postfix_operator( RuleKind::YulFunctionCallExpression, 1u8, SequenceHelper::run(|mut seq| { let mut delim_guard = input.open_delim(TokenKind::CloseParen); let input = delim_guard.ctx(); - seq.elem( - self.parse_token_with_trivia::( - input, - TokenKind::OpenParen, - ), - )?; + seq.elem(self.parse_token_with_trivia::( + input, + TokenKind::OpenParen, + ))?; seq.elem( OptionalHelper::transform(self.yul_arguments(input)) - .recover_until_with_nested_delims::<_, LexicalContextType::YulBlock>( - input, - self, - TokenKind::CloseParen, - RecoverFromNoMatch::Yes, - ), - )?; - seq.elem( - self.parse_token_with_trivia::( - input, - TokenKind::CloseParen, - ), + .recover_until_with_nested_delims::<_, LexicalContextType::Yul>( + input, + self, + TokenKind::CloseParen, + RecoverFromNoMatch::Yes, + ), )?; + seq.elem(self.parse_token_with_trivia::( + input, + TokenKind::CloseParen, + ))?; seq.finish() }), ) @@ -5043,32 +5223,32 @@ impl Language { let primary_expression_parser = |input: &mut ParserContext| { ChoiceHelper::run(input, |mut choice, input| { let result = ChoiceHelper::run(input, |mut choice, input| { - let result = self.parse_token_with_trivia::( + let result = self.parse_token_with_trivia::( input, - TokenKind::TrueKeyword, + TokenKind::YulTrueKeyword, ); choice.consider(input, result)?; - let result = self.parse_token_with_trivia::( + let result = self.parse_token_with_trivia::( input, - TokenKind::FalseKeyword, + TokenKind::YulFalseKeyword, ); choice.consider(input, result)?; - let result = self.parse_token_with_trivia::( + let result = self.parse_token_with_trivia::( input, - TokenKind::YulHexLiteral, + TokenKind::YulDecimalLiteral, ); choice.consider(input, result)?; - let result = self.parse_token_with_trivia::( + let result = self.parse_token_with_trivia::( input, - TokenKind::YulDecimalLiteral, + TokenKind::YulHexLiteral, ); choice.consider(input, result)?; - let result = self.parse_token_with_trivia::( + let result = self.parse_token_with_trivia::( input, TokenKind::HexStringLiteral, ); choice.consider(input, result)?; - let result = self.parse_token_with_trivia::( + let result = self.parse_token_with_trivia::( input, TokenKind::AsciiStringLiteral, ); @@ -5083,7 +5263,7 @@ impl Language { }; let postfix_operator_parser = |input: &mut ParserContext| { ChoiceHelper::run(input, |mut choice, input| { - let result = parse_yul_function_call_operator(input); + let result = parse_yul_function_call_expression(input); choice.consider(input, result)?; choice.finish(input) }) @@ -5107,13 +5287,11 @@ impl Language { #[allow(unused_assignments, unused_parens)] fn yul_for_statement(&self, input: &mut ParserContext) -> ParserResult { SequenceHelper::run(|mut seq| { - seq.elem( - self.parse_token_with_trivia::( - input, - TokenKind::ForKeyword, - ), - )?; - seq.elem(self.yul_block(input))?; + seq.elem(self.parse_token_with_trivia::( + input, + TokenKind::YulForKeyword, + ))?; + seq.elem(self.yul_block(input))?; seq.elem(self.yul_expression(input))?; seq.elem(self.yul_block(input))?; seq.elem(self.yul_block(input))?; @@ -5125,18 +5303,14 @@ impl Language { #[allow(unused_assignments, unused_parens)] fn yul_function_definition(&self, input: &mut ParserContext) -> ParserResult { SequenceHelper::run(|mut seq| { - seq.elem( - self.parse_token_with_trivia::( - input, - TokenKind::FunctionKeyword, - ), - )?; - seq.elem( - self.parse_token_with_trivia::( - input, - TokenKind::YulIdentifier, - ), - )?; + seq.elem(self.parse_token_with_trivia::( + input, + TokenKind::YulFunctionKeyword, + ))?; + seq.elem(self.parse_token_with_trivia::( + input, + TokenKind::YulIdentifier, + ))?; seq.elem(self.yul_parameters_declaration(input))?; seq.elem(OptionalHelper::transform( self.yul_returns_declaration(input), @@ -5149,11 +5323,11 @@ impl Language { #[allow(unused_assignments, unused_parens)] fn yul_identifier_path(&self, input: &mut ParserContext) -> ParserResult { - SeparatedHelper::run::<_, LexicalContextType::YulBlock>( + SeparatedHelper::run::<_, LexicalContextType::Yul>( input, self, |input| { - self.parse_token_with_trivia::( + self.parse_token_with_trivia::( input, TokenKind::YulIdentifier, ) @@ -5165,7 +5339,7 @@ impl Language { #[allow(unused_assignments, unused_parens)] fn yul_identifier_paths(&self, input: &mut ParserContext) -> ParserResult { - SeparatedHelper::run::<_, LexicalContextType::YulBlock>( + SeparatedHelper::run::<_, LexicalContextType::Yul>( input, self, |input| self.yul_identifier_path(input), @@ -5174,31 +5348,13 @@ impl Language { .with_kind(RuleKind::YulIdentifierPaths) } - #[allow(unused_assignments, unused_parens)] - fn yul_identifiers(&self, input: &mut ParserContext) -> ParserResult { - SeparatedHelper::run::<_, LexicalContextType::YulBlock>( - input, - self, - |input| { - self.parse_token_with_trivia::( - input, - TokenKind::YulIdentifier, - ) - }, - TokenKind::Comma, - ) - .with_kind(RuleKind::YulIdentifiers) - } - #[allow(unused_assignments, unused_parens)] fn yul_if_statement(&self, input: &mut ParserContext) -> ParserResult { SequenceHelper::run(|mut seq| { - seq.elem( - self.parse_token_with_trivia::( - input, - TokenKind::IfKeyword, - ), - )?; + seq.elem(self.parse_token_with_trivia::( + input, + TokenKind::YulIfKeyword, + ))?; seq.elem(self.yul_expression(input))?; seq.elem(self.yul_block(input))?; seq.finish() @@ -5209,9 +5365,9 @@ impl Language { #[allow(unused_assignments, unused_parens)] fn yul_leave_statement(&self, input: &mut ParserContext) -> ParserResult { if self.version_is_at_least_0_6_0 { - self.parse_token_with_trivia::( + self.parse_token_with_trivia::( input, - TokenKind::LeaveKeyword, + TokenKind::YulLeaveKeyword, ) } else { ParserResult::disabled() @@ -5219,20 +5375,36 @@ impl Language { .with_kind(RuleKind::YulLeaveStatement) } + #[allow(unused_assignments, unused_parens)] + fn yul_parameters(&self, input: &mut ParserContext) -> ParserResult { + SeparatedHelper::run::<_, LexicalContextType::Yul>( + input, + self, + |input| { + self.parse_token_with_trivia::( + input, + TokenKind::YulIdentifier, + ) + }, + TokenKind::Comma, + ) + .with_kind(RuleKind::YulParameters) + } + #[allow(unused_assignments, unused_parens)] fn yul_parameters_declaration(&self, input: &mut ParserContext) -> ParserResult { SequenceHelper::run(|mut seq| { let mut delim_guard = input.open_delim(TokenKind::CloseParen); let input = delim_guard.ctx(); seq.elem( - self.parse_token_with_trivia::( + self.parse_token_with_trivia::( input, TokenKind::OpenParen, ), )?; seq.elem( - OptionalHelper::transform(self.yul_identifiers(input)) - .recover_until_with_nested_delims::<_, LexicalContextType::YulBlock>( + OptionalHelper::transform(self.yul_parameters(input)) + .recover_until_with_nested_delims::<_, LexicalContextType::Yul>( input, self, TokenKind::CloseParen, @@ -5240,7 +5412,7 @@ impl Language { ), )?; seq.elem( - self.parse_token_with_trivia::( + self.parse_token_with_trivia::( input, TokenKind::CloseParen, ), @@ -5250,16 +5422,30 @@ impl Language { .with_kind(RuleKind::YulParametersDeclaration) } + #[allow(unused_assignments, unused_parens)] + fn yul_return_variables(&self, input: &mut ParserContext) -> ParserResult { + SeparatedHelper::run::<_, LexicalContextType::Yul>( + input, + self, + |input| { + self.parse_token_with_trivia::( + input, + TokenKind::YulIdentifier, + ) + }, + TokenKind::Comma, + ) + .with_kind(RuleKind::YulReturnVariables) + } + #[allow(unused_assignments, unused_parens)] fn yul_returns_declaration(&self, input: &mut ParserContext) -> ParserResult { SequenceHelper::run(|mut seq| { - seq.elem( - self.parse_token_with_trivia::( - input, - TokenKind::MinusGreaterThan, - ), - )?; - seq.elem(self.yul_identifiers(input))?; + seq.elem(self.parse_token_with_trivia::( + input, + TokenKind::MinusGreaterThan, + ))?; + seq.elem(self.yul_return_variables(input))?; seq.finish() }) .with_kind(RuleKind::YulReturnsDeclaration) @@ -5273,7 +5459,7 @@ impl Language { choice.consider(input, result)?; let result = self.yul_function_definition(input); choice.consider(input, result)?; - let result = self.yul_declaration_statement(input); + let result = self.yul_variable_declaration_statement(input); choice.consider(input, result)?; let result = self.yul_assignment_statement(input); choice.consider(input, result)?; @@ -5300,85 +5486,108 @@ impl Language { } #[allow(unused_assignments, unused_parens)] - fn yul_switch_case(&self, input: &mut ParserContext) -> ParserResult { + fn yul_switch_cases(&self, input: &mut ParserContext) -> ParserResult { + OneOrMoreHelper::run(input, |input| { + ChoiceHelper::run(input, |mut choice, input| { + let result = self.yul_default_case(input); + choice.consider(input, result)?; + let result = self.yul_value_case(input); + choice.consider(input, result)?; + choice.finish(input) + }) + }) + .with_kind(RuleKind::YulSwitchCases) + } + + #[allow(unused_assignments, unused_parens)] + fn yul_switch_statement(&self, input: &mut ParserContext) -> ParserResult { + SequenceHelper::run(|mut seq| { + seq.elem(self.parse_token_with_trivia::( + input, + TokenKind::YulSwitchKeyword, + ))?; + seq.elem(self.yul_expression(input))?; + seq.elem(self.yul_switch_cases(input))?; + seq.finish() + }) + .with_kind(RuleKind::YulSwitchStatement) + } + + #[allow(unused_assignments, unused_parens)] + fn yul_value_case(&self, input: &mut ParserContext) -> ParserResult { SequenceHelper::run(|mut seq| { + seq.elem(self.parse_token_with_trivia::( + input, + TokenKind::YulCaseKeyword, + ))?; seq.elem(ChoiceHelper::run(input, |mut choice, input| { - let result = self.parse_token_with_trivia::( + let result = self.parse_token_with_trivia::( input, - TokenKind::DefaultKeyword, + TokenKind::YulTrueKeyword, ); choice.consider(input, result)?; - let result = SequenceHelper::run(|mut seq| { - seq.elem( - self.parse_token_with_trivia::( - input, - TokenKind::CaseKeyword, - ), - )?; - seq.elem(ChoiceHelper::run(input, |mut choice, input| { - let result = self.parse_token_with_trivia::( - input, - TokenKind::TrueKeyword, - ); - choice.consider(input, result)?; - let result = self.parse_token_with_trivia::( - input, - TokenKind::FalseKeyword, - ); - choice.consider(input, result)?; - let result = self.parse_token_with_trivia::( - input, - TokenKind::YulHexLiteral, - ); - choice.consider(input, result)?; - let result = self.parse_token_with_trivia::( - input, - TokenKind::YulDecimalLiteral, - ); - choice.consider(input, result)?; - let result = self.parse_token_with_trivia::( - input, - TokenKind::HexStringLiteral, - ); - choice.consider(input, result)?; - let result = self.parse_token_with_trivia::( - input, - TokenKind::AsciiStringLiteral, - ); - choice.consider(input, result)?; - choice.finish(input) - }))?; - seq.finish() - }); + let result = self.parse_token_with_trivia::( + input, + TokenKind::YulFalseKeyword, + ); + choice.consider(input, result)?; + let result = self.parse_token_with_trivia::( + input, + TokenKind::YulDecimalLiteral, + ); + choice.consider(input, result)?; + let result = self.parse_token_with_trivia::( + input, + TokenKind::YulHexLiteral, + ); + choice.consider(input, result)?; + let result = self.parse_token_with_trivia::( + input, + TokenKind::HexStringLiteral, + ); + choice.consider(input, result)?; + let result = self.parse_token_with_trivia::( + input, + TokenKind::AsciiStringLiteral, + ); choice.consider(input, result)?; choice.finish(input) }))?; seq.elem(self.yul_block(input))?; seq.finish() }) - .with_kind(RuleKind::YulSwitchCase) + .with_kind(RuleKind::YulValueCase) } #[allow(unused_assignments, unused_parens)] - fn yul_switch_cases(&self, input: &mut ParserContext) -> ParserResult { - OneOrMoreHelper::run(input, |input| self.yul_switch_case(input)) - .with_kind(RuleKind::YulSwitchCases) + fn yul_variable_declaration_statement(&self, input: &mut ParserContext) -> ParserResult { + SequenceHelper::run(|mut seq| { + seq.elem(self.parse_token_with_trivia::( + input, + TokenKind::YulLetKeyword, + ))?; + seq.elem(self.yul_identifier_paths(input))?; + seq.elem(OptionalHelper::transform( + self.yul_variable_declaration_value(input), + ))?; + seq.finish() + }) + .with_kind(RuleKind::YulVariableDeclarationStatement) } #[allow(unused_assignments, unused_parens)] - fn yul_switch_statement(&self, input: &mut ParserContext) -> ParserResult { + fn yul_variable_declaration_value(&self, input: &mut ParserContext) -> ParserResult { SequenceHelper::run(|mut seq| { seq.elem( - self.parse_token_with_trivia::( + self.parse_token_with_trivia::( input, - TokenKind::SwitchKeyword, + TokenKind::ColonEqual, ), )?; seq.elem(self.yul_expression(input))?; - seq.elem(self.yul_switch_cases(input))?; seq.finish() }) - .with_kind(RuleKind::YulSwitchStatement) + .with_kind(RuleKind::YulVariableDeclarationValue) } /******************************************** @@ -5386,22 +5595,11 @@ impl Language { ********************************************/ #[allow(unused_assignments, unused_parens)] - fn ascii_character_without_double_quote_or_backslash(&self, input: &mut ParserContext) -> bool { - scan_choice!( - input, - scan_char_range!(input, ' '..='!'), - scan_char_range!(input, '#'..='['), - scan_char_range!(input, ']'..='~') - ) - } - - #[allow(unused_assignments, unused_parens)] - fn ascii_character_without_single_quote_or_backslash(&self, input: &mut ParserContext) -> bool { - scan_choice!( + fn ampersand(&self, input: &mut ParserContext) -> bool { + scan_not_followed_by!( input, - scan_char_range!(input, ' '..='&'), - scan_char_range!(input, '('..='['), - scan_char_range!(input, ']'..='~') + scan_chars!(input, '&'), + scan_choice!(input, scan_chars!(input, '='), scan_chars!(input, '&')) ) } @@ -5429,28 +5627,90 @@ impl Language { ) } + #[allow(unused_assignments, unused_parens)] + fn asterisk(&self, input: &mut ParserContext) -> bool { + scan_not_followed_by!( + input, + scan_chars!(input, '*'), + scan_choice!(input, scan_chars!(input, '='), scan_chars!(input, '*')) + ) + } + + #[allow(unused_assignments, unused_parens)] + fn bang(&self, input: &mut ParserContext) -> bool { + scan_not_followed_by!(input, scan_chars!(input, '!'), scan_chars!(input, '=')) + } + + #[allow(unused_assignments, unused_parens)] + fn bar(&self, input: &mut ParserContext) -> bool { + scan_not_followed_by!( + input, + scan_chars!(input, '|'), + scan_choice!(input, scan_chars!(input, '|'), scan_chars!(input, '=')) + ) + } + #[allow(unused_assignments, unused_parens)] fn bytes_keyword(&self, input: &mut ParserContext) -> bool { scan_sequence!( scan_chars!(input, 'b', 'y', 't', 'e', 's'), - self.fixed_bytes_type_size(input) + scan_choice!( + input, + scan_chars!(input, '9'), + scan_chars!(input, '8'), + scan_chars!(input, '7'), + scan_chars!(input, '6'), + scan_chars!(input, '5'), + scan_chars!(input, '4'), + scan_chars!(input, '3', '2'), + scan_chars!(input, '3', '1'), + scan_chars!(input, '3', '0'), + scan_chars!(input, '3'), + scan_chars!(input, '2', '9'), + scan_chars!(input, '2', '8'), + scan_chars!(input, '2', '7'), + scan_chars!(input, '2', '6'), + scan_chars!(input, '2', '5'), + scan_chars!(input, '2', '4'), + scan_chars!(input, '2', '3'), + scan_chars!(input, '2', '2'), + scan_chars!(input, '2', '1'), + scan_chars!(input, '2', '0'), + scan_chars!(input, '2'), + scan_chars!(input, '1', '9'), + scan_chars!(input, '1', '8'), + scan_chars!(input, '1', '7'), + scan_chars!(input, '1', '6'), + scan_chars!(input, '1', '5'), + scan_chars!(input, '1', '4'), + scan_chars!(input, '1', '3'), + scan_chars!(input, '1', '2'), + scan_chars!(input, '1', '1'), + scan_chars!(input, '1', '0'), + scan_chars!(input, '1') + ) ) } #[allow(unused_assignments, unused_parens)] - fn decimal_digit(&self, input: &mut ParserContext) -> bool { - scan_char_range!(input, '0'..='9') + fn caret(&self, input: &mut ParserContext) -> bool { + scan_not_followed_by!(input, scan_chars!(input, '^'), scan_chars!(input, '=')) + } + + #[allow(unused_assignments, unused_parens)] + fn colon(&self, input: &mut ParserContext) -> bool { + scan_not_followed_by!(input, scan_chars!(input, ':'), scan_chars!(input, '=')) } #[allow(unused_assignments, unused_parens)] fn decimal_digits(&self, input: &mut ParserContext) -> bool { scan_sequence!( - scan_one_or_more!(input, self.decimal_digit(input)), + scan_one_or_more!(input, scan_char_range!(input, '0'..='9')), scan_zero_or_more!( input, scan_sequence!( scan_chars!(input, '_'), - scan_one_or_more!(input, self.decimal_digit(input)) + scan_one_or_more!(input, scan_char_range!(input, '0'..='9')) ) ) ) @@ -5467,35 +5727,55 @@ impl Language { #[allow(unused_assignments, unused_parens)] fn decimal_literal(&self, input: &mut ParserContext) -> bool { - scan_not_followed_by!( + scan_choice!( input, - scan_sequence!( - scan_choice!( - input, + scan_not_followed_by!( + input, + scan_sequence!( scan_not_followed_by!( input, self.decimal_digits(input), scan_chars!(input, '.') ), - if !self.version_is_at_least_0_5_0 { + scan_optional!(input, self.decimal_exponent(input)) + ), + self.identifier_start(input) + ), + if !self.version_is_at_least_0_5_0 { + scan_not_followed_by!( + input, + scan_sequence!( scan_not_followed_by!( input, scan_sequence!(self.decimal_digits(input), scan_chars!(input, '.')), self.decimal_digits(input) - ) - } else { - false - }, - scan_sequence!(scan_chars!(input, '.'), self.decimal_digits(input)), - scan_sequence!( - self.decimal_digits(input), - scan_chars!(input, '.'), - self.decimal_digits(input) - ) + ), + scan_optional!(input, self.decimal_exponent(input)) + ), + self.identifier_start(input) + ) + } else { + false + }, + scan_not_followed_by!( + input, + scan_sequence!( + scan_chars!(input, '.'), + self.decimal_digits(input), + scan_optional!(input, self.decimal_exponent(input)) ), - scan_optional!(input, self.decimal_exponent(input)) + self.identifier_start(input) ), - self.identifier_start(input) + scan_not_followed_by!( + input, + scan_sequence!( + self.decimal_digits(input), + scan_chars!(input, '.'), + self.decimal_digits(input), + scan_optional!(input, self.decimal_exponent(input)) + ), + self.identifier_start(input) + ) ) } @@ -5508,7 +5788,9 @@ impl Language { scan_choice!( input, self.escape_sequence(input), - self.ascii_character_without_double_quote_or_backslash(input) + scan_char_range!(input, ' '..='!'), + scan_char_range!(input, '#'..='['), + scan_char_range!(input, ']'..='~') ) ), scan_chars!(input, '"') @@ -5534,7 +5816,7 @@ impl Language { scan_choice!( input, self.escape_sequence(input), - scan_none_of!(input, '\n', '\r', '"', '\\') + scan_none_of!(input, '"', '\\', '\r', '\n') ) ), scan_chars!(input, '"') @@ -5552,6 +5834,15 @@ impl Language { ) } + #[allow(unused_assignments, unused_parens)] + fn equal(&self, input: &mut ParserContext) -> bool { + scan_not_followed_by!( + input, + scan_chars!(input, '='), + scan_choice!(input, scan_chars!(input, '>'), scan_chars!(input, '=')) + ) + } + #[allow(unused_assignments, unused_parens)] fn escape_sequence(&self, input: &mut ParserContext) -> bool { scan_sequence!( @@ -5566,66 +5857,320 @@ impl Language { } #[allow(unused_assignments, unused_parens)] - fn fixed_bytes_type_size(&self, input: &mut ParserContext) -> bool { + fn fixed_keyword(&self, input: &mut ParserContext) -> bool { scan_choice!( input, - scan_chars!(input, '9'), - scan_chars!(input, '8'), - scan_chars!(input, '7'), - scan_chars!(input, '6'), - scan_chars!(input, '5'), - scan_chars!(input, '4'), - scan_chars!(input, '3', '2'), - scan_chars!(input, '3', '1'), - scan_chars!(input, '3', '0'), - scan_chars!(input, '3'), - scan_chars!(input, '2', '9'), - scan_chars!(input, '2', '8'), - scan_chars!(input, '2', '7'), - scan_chars!(input, '2', '6'), - scan_chars!(input, '2', '5'), - scan_chars!(input, '2', '4'), - scan_chars!(input, '2', '3'), - scan_chars!(input, '2', '2'), - scan_chars!(input, '2', '1'), - scan_chars!(input, '2', '0'), - scan_chars!(input, '2'), - scan_chars!(input, '1', '9'), - scan_chars!(input, '1', '8'), - scan_chars!(input, '1', '7'), - scan_chars!(input, '1', '6'), - scan_chars!(input, '1', '5'), - scan_chars!(input, '1', '4'), - scan_chars!(input, '1', '3'), - scan_chars!(input, '1', '2'), - scan_chars!(input, '1', '1'), - scan_chars!(input, '1', '0'), - scan_chars!(input, '1') + scan_chars!(input, 'f', 'i', 'x', 'e', 'd'), + scan_sequence!( + scan_chars!(input, 'f', 'i', 'x', 'e', 'd'), + scan_choice!( + input, + scan_chars!(input, '9', '6'), + scan_chars!(input, '8', '8'), + scan_chars!(input, '8', '0'), + scan_chars!(input, '8'), + scan_chars!(input, '7', '2'), + scan_chars!(input, '6', '4'), + scan_chars!(input, '5', '6'), + scan_chars!(input, '4', '8'), + scan_chars!(input, '4', '0'), + scan_chars!(input, '3', '2'), + scan_chars!(input, '2', '4'), + scan_chars!(input, '1', '7', '6'), + scan_chars!(input, '1', '6', '8'), + scan_chars!(input, '1', '6', '0'), + scan_chars!(input, '1', '6'), + scan_chars!(input, '1', '5', '2'), + scan_chars!(input, '1', '4', '4'), + scan_chars!(input, '1', '3', '6'), + scan_chars!(input, '1', '2', '8'), + scan_chars!(input, '1', '2', '0'), + scan_chars!(input, '1', '1', '2'), + scan_chars!(input, '1', '0', '4') + ), + scan_chars!(input, 'x'), + scan_choice!( + input, + scan_chars!(input, '8', '0'), + scan_chars!(input, '8'), + scan_chars!(input, '7', '2'), + scan_chars!(input, '6', '4'), + scan_chars!(input, '5', '6'), + scan_chars!(input, '4', '8'), + scan_chars!(input, '4', '0'), + scan_chars!(input, '3', '2'), + scan_chars!(input, '2', '4'), + scan_chars!(input, '1', '6') + ) + ), + scan_sequence!( + scan_chars!(input, 'f', 'i', 'x', 'e', 'd'), + scan_choice!( + input, + scan_chars!(input, '2', '4', '8', 'x', '8'), + scan_chars!(input, '2', '4', '0', 'x', '8'), + scan_chars!(input, '2', '4', '0', 'x', '1', '6'), + scan_chars!(input, '2', '3', '2', 'x', '8'), + scan_chars!(input, '2', '3', '2', 'x', '2', '4'), + scan_chars!(input, '2', '3', '2', 'x', '1', '6'), + scan_chars!(input, '2', '2', '4', 'x', '8'), + scan_chars!(input, '2', '2', '4', 'x', '3', '2'), + scan_chars!(input, '2', '2', '4', 'x', '2', '4'), + scan_chars!(input, '2', '2', '4', 'x', '1', '6'), + scan_chars!(input, '2', '1', '6', 'x', '8'), + scan_chars!(input, '2', '1', '6', 'x', '4', '0'), + scan_chars!(input, '2', '1', '6', 'x', '3', '2'), + scan_chars!(input, '2', '1', '6', 'x', '2', '4'), + scan_chars!(input, '2', '1', '6', 'x', '1', '6'), + scan_chars!(input, '2', '0', '8', 'x', '8'), + scan_chars!(input, '2', '0', '8', 'x', '4', '8'), + scan_chars!(input, '2', '0', '8', 'x', '4', '0'), + scan_chars!(input, '2', '0', '8', 'x', '3', '2'), + scan_chars!(input, '2', '0', '8', 'x', '2', '4'), + scan_chars!(input, '2', '0', '8', 'x', '1', '6'), + scan_chars!(input, '2', '0', '0', 'x', '8'), + scan_chars!(input, '2', '0', '0', 'x', '5', '6'), + scan_chars!(input, '2', '0', '0', 'x', '4', '8'), + scan_chars!(input, '2', '0', '0', 'x', '4', '0'), + scan_chars!(input, '2', '0', '0', 'x', '3', '2'), + scan_chars!(input, '2', '0', '0', 'x', '2', '4'), + scan_chars!(input, '2', '0', '0', 'x', '1', '6'), + scan_chars!(input, '1', '9', '2', 'x', '8'), + scan_chars!(input, '1', '9', '2', 'x', '6', '4'), + scan_chars!(input, '1', '9', '2', 'x', '5', '6'), + scan_chars!(input, '1', '9', '2', 'x', '4', '8'), + scan_chars!(input, '1', '9', '2', 'x', '4', '0'), + scan_chars!(input, '1', '9', '2', 'x', '3', '2'), + scan_chars!(input, '1', '9', '2', 'x', '2', '4'), + scan_chars!(input, '1', '9', '2', 'x', '1', '6'), + scan_chars!(input, '1', '8', '4', 'x', '8'), + scan_chars!(input, '1', '8', '4', 'x', '7', '2'), + scan_chars!(input, '1', '8', '4', 'x', '6', '4'), + scan_chars!(input, '1', '8', '4', 'x', '5', '6'), + scan_chars!(input, '1', '8', '4', 'x', '4', '8'), + scan_chars!(input, '1', '8', '4', 'x', '4', '0'), + scan_chars!(input, '1', '8', '4', 'x', '3', '2'), + scan_chars!(input, '1', '8', '4', 'x', '2', '4'), + scan_chars!(input, '1', '8', '4', 'x', '1', '6') + ) + ), + if self.version_is_at_least_0_4_14 { + scan_sequence!( + scan_chars!(input, 'f', 'i', 'x', 'e', 'd'), + scan_choice!( + input, + scan_chars!(input, '2', '5', '6', 'x', '8', '0'), + scan_chars!(input, '2', '5', '6', 'x', '8'), + scan_chars!(input, '2', '5', '6', 'x', '7', '2'), + scan_chars!(input, '2', '5', '6', 'x', '6', '4'), + scan_chars!(input, '2', '5', '6', 'x', '5', '6'), + scan_chars!(input, '2', '5', '6', 'x', '4', '8'), + scan_chars!(input, '2', '5', '6', 'x', '4', '0'), + scan_chars!(input, '2', '5', '6', 'x', '3', '2'), + scan_chars!(input, '2', '5', '6', 'x', '2', '4'), + scan_chars!(input, '2', '5', '6', 'x', '1', '6'), + scan_chars!(input, '2', '4', '8', 'x', '8', '0'), + scan_chars!(input, '2', '4', '8', 'x', '7', '2'), + scan_chars!(input, '2', '4', '8', 'x', '6', '4'), + scan_chars!(input, '2', '4', '8', 'x', '5', '6'), + scan_chars!(input, '2', '4', '8', 'x', '4', '8'), + scan_chars!(input, '2', '4', '8', 'x', '4', '0'), + scan_chars!(input, '2', '4', '8', 'x', '3', '2'), + scan_chars!(input, '2', '4', '8', 'x', '2', '4'), + scan_chars!(input, '2', '4', '8', 'x', '1', '6'), + scan_chars!(input, '2', '4', '0', 'x', '8', '0'), + scan_chars!(input, '2', '4', '0', 'x', '7', '2'), + scan_chars!(input, '2', '4', '0', 'x', '6', '4'), + scan_chars!(input, '2', '4', '0', 'x', '5', '6'), + scan_chars!(input, '2', '4', '0', 'x', '4', '8'), + scan_chars!(input, '2', '4', '0', 'x', '4', '0'), + scan_chars!(input, '2', '4', '0', 'x', '3', '2'), + scan_chars!(input, '2', '4', '0', 'x', '2', '4'), + scan_chars!(input, '2', '3', '2', 'x', '8', '0'), + scan_chars!(input, '2', '3', '2', 'x', '7', '2'), + scan_chars!(input, '2', '3', '2', 'x', '6', '4'), + scan_chars!(input, '2', '3', '2', 'x', '5', '6'), + scan_chars!(input, '2', '3', '2', 'x', '4', '8'), + scan_chars!(input, '2', '3', '2', 'x', '4', '0'), + scan_chars!(input, '2', '3', '2', 'x', '3', '2'), + scan_chars!(input, '2', '2', '4', 'x', '8', '0'), + scan_chars!(input, '2', '2', '4', 'x', '7', '2'), + scan_chars!(input, '2', '2', '4', 'x', '6', '4'), + scan_chars!(input, '2', '2', '4', 'x', '5', '6'), + scan_chars!(input, '2', '2', '4', 'x', '4', '8'), + scan_chars!(input, '2', '2', '4', 'x', '4', '0'), + scan_chars!(input, '2', '1', '6', 'x', '8', '0'), + scan_chars!(input, '2', '1', '6', 'x', '7', '2'), + scan_chars!(input, '2', '1', '6', 'x', '6', '4'), + scan_chars!(input, '2', '1', '6', 'x', '5', '6'), + scan_chars!(input, '2', '1', '6', 'x', '4', '8'), + scan_chars!(input, '2', '0', '8', 'x', '8', '0'), + scan_chars!(input, '2', '0', '8', 'x', '7', '2'), + scan_chars!(input, '2', '0', '8', 'x', '6', '4'), + scan_chars!(input, '2', '0', '8', 'x', '5', '6'), + scan_chars!(input, '2', '0', '0', 'x', '8', '0'), + scan_chars!(input, '2', '0', '0', 'x', '7', '2'), + scan_chars!(input, '2', '0', '0', 'x', '6', '4'), + scan_chars!(input, '1', '9', '2', 'x', '8', '0'), + scan_chars!(input, '1', '9', '2', 'x', '7', '2'), + scan_chars!(input, '1', '8', '4', 'x', '8', '0') + ) + ) + } else { + false + }, + if self.version_is_at_least_0_4_14 { + scan_sequence!( + scan_chars!(input, 'f', 'i', 'x', 'e', 'd'), + scan_choice!( + input, + scan_chars!(input, '9', '6'), + scan_chars!(input, '8', '8'), + scan_chars!(input, '8', '0'), + scan_chars!(input, '8'), + scan_chars!(input, '7', '2'), + scan_chars!(input, '6', '4'), + scan_chars!(input, '5', '6'), + scan_chars!(input, '4', '8'), + scan_chars!(input, '4', '0'), + scan_chars!(input, '3', '2'), + scan_chars!(input, '2', '5', '6'), + scan_chars!(input, '2', '4', '8'), + scan_chars!(input, '2', '4', '0'), + scan_chars!(input, '2', '4'), + scan_chars!(input, '2', '3', '2'), + scan_chars!(input, '2', '2', '4'), + scan_chars!(input, '2', '1', '6'), + scan_chars!(input, '2', '0', '8'), + scan_chars!(input, '2', '0', '0'), + scan_chars!(input, '1', '9', '2'), + scan_chars!(input, '1', '8', '4'), + scan_chars!(input, '1', '7', '6'), + scan_chars!(input, '1', '6', '8'), + scan_chars!(input, '1', '6', '0'), + scan_chars!(input, '1', '6'), + scan_chars!(input, '1', '5', '2'), + scan_chars!(input, '1', '4', '4'), + scan_chars!(input, '1', '3', '6'), + scan_chars!(input, '1', '2', '8'), + scan_chars!(input, '1', '2', '0'), + scan_chars!(input, '1', '1', '2'), + scan_chars!(input, '1', '0', '4') + ), + scan_chars!(input, 'x'), + scan_choice!( + input, + scan_chars!(input, '9'), + scan_chars!(input, '7', '9'), + scan_chars!(input, '7', '8'), + scan_chars!(input, '7', '7'), + scan_chars!(input, '7', '6'), + scan_chars!(input, '7', '5'), + scan_chars!(input, '7', '4'), + scan_chars!(input, '7', '3'), + scan_chars!(input, '7', '1'), + scan_chars!(input, '7', '0'), + scan_chars!(input, '7'), + scan_chars!(input, '6', '9'), + scan_chars!(input, '6', '8'), + scan_chars!(input, '6', '7'), + scan_chars!(input, '6', '6'), + scan_chars!(input, '6', '5'), + scan_chars!(input, '6', '3'), + scan_chars!(input, '6', '2'), + scan_chars!(input, '6', '1'), + scan_chars!(input, '6', '0'), + scan_chars!(input, '6'), + scan_chars!(input, '5', '9'), + scan_chars!(input, '5', '8'), + scan_chars!(input, '5', '7'), + scan_chars!(input, '5', '5'), + scan_chars!(input, '5', '4'), + scan_chars!(input, '5', '3'), + scan_chars!(input, '5', '2'), + scan_chars!(input, '5', '1'), + scan_chars!(input, '5', '0'), + scan_chars!(input, '5'), + scan_chars!(input, '4', '9'), + scan_chars!(input, '4', '7'), + scan_chars!(input, '4', '6'), + scan_chars!(input, '4', '5'), + scan_chars!(input, '4', '4'), + scan_chars!(input, '4', '3'), + scan_chars!(input, '4', '2'), + scan_chars!(input, '4', '1'), + scan_chars!(input, '4'), + scan_chars!(input, '3', '9'), + scan_chars!(input, '3', '8'), + scan_chars!(input, '3', '7'), + scan_chars!(input, '3', '6'), + scan_chars!(input, '3', '5'), + scan_chars!(input, '3', '4'), + scan_chars!(input, '3', '3'), + scan_chars!(input, '3', '1'), + scan_chars!(input, '3', '0'), + scan_chars!(input, '3'), + scan_chars!(input, '2', '9'), + scan_chars!(input, '2', '8'), + scan_chars!(input, '2', '7'), + scan_chars!(input, '2', '6'), + scan_chars!(input, '2', '5'), + scan_chars!(input, '2', '3'), + scan_chars!(input, '2', '2'), + scan_chars!(input, '2', '1'), + scan_chars!(input, '2', '0'), + scan_chars!(input, '2'), + scan_chars!(input, '1', '9'), + scan_chars!(input, '1', '8'), + scan_chars!(input, '1', '7'), + scan_chars!(input, '1', '5'), + scan_chars!(input, '1', '4'), + scan_chars!(input, '1', '3'), + scan_chars!(input, '1', '2'), + scan_chars!(input, '1', '1'), + scan_chars!(input, '1', '0'), + scan_chars!(input, '1'), + scan_chars!(input, '0') + ) + ) + } else { + false + } ) } #[allow(unused_assignments, unused_parens)] - fn fixed_keyword(&self, input: &mut ParserContext) -> bool { - scan_sequence!( - scan_chars!(input, 'f', 'i', 'x', 'e', 'd'), - scan_optional!(input, self.fixed_type_size(input)) + fn greater_than(&self, input: &mut ParserContext) -> bool { + scan_not_followed_by!( + input, + scan_chars!(input, '>'), + scan_choice!(input, scan_chars!(input, '>'), scan_chars!(input, '=')) ) } #[allow(unused_assignments, unused_parens)] - fn fixed_type_size(&self, input: &mut ParserContext) -> bool { - scan_sequence!( - scan_one_or_more!(input, scan_char_range!(input, '0'..='9')), - scan_chars!(input, 'x'), - scan_one_or_more!(input, scan_char_range!(input, '0'..='9')) + fn greater_than_greater_than(&self, input: &mut ParserContext) -> bool { + scan_not_followed_by!( + input, + scan_chars!(input, '>', '>'), + scan_choice!(input, scan_chars!(input, '>'), scan_chars!(input, '=')) ) } #[allow(unused_assignments, unused_parens)] - fn hex_byte_escape(&self, input: &mut ParserContext) -> bool { - scan_sequence!( - scan_chars!(input, 'x'), - self.hex_character(input), + fn greater_than_greater_than_greater_than(&self, input: &mut ParserContext) -> bool { + scan_not_followed_by!( + input, + scan_chars!(input, '>', '>', '>'), + scan_chars!(input, '=') + ) + } + + #[allow(unused_assignments, unused_parens)] + fn hex_byte_escape(&self, input: &mut ParserContext) -> bool { + scan_sequence!( + scan_chars!(input, 'x'), + self.hex_character(input), self.hex_character(input) ) } @@ -5634,36 +6179,50 @@ impl Language { fn hex_character(&self, input: &mut ParserContext) -> bool { scan_choice!( input, - self.decimal_digit(input), - scan_char_range!(input, 'A'..='F'), - scan_char_range!(input, 'a'..='f') + scan_char_range!(input, '0'..='9'), + scan_char_range!(input, 'a'..='f'), + scan_char_range!(input, 'A'..='F') ) } #[allow(unused_assignments, unused_parens)] fn hex_literal(&self, input: &mut ParserContext) -> bool { - scan_not_followed_by!( + scan_choice!( input, - scan_sequence!( - scan_choice!( - input, + scan_not_followed_by!( + input, + scan_sequence!( scan_chars!(input, '0', 'x'), - if !self.version_is_at_least_0_5_0 { - scan_chars!(input, '0', 'X') - } else { - false - } + scan_one_or_more!(input, self.hex_character(input)), + scan_zero_or_more!( + input, + scan_sequence!( + scan_chars!(input, '_'), + scan_one_or_more!(input, self.hex_character(input)) + ) + ) ), - scan_one_or_more!(input, self.hex_character(input)), - scan_zero_or_more!( + self.identifier_start(input) + ), + if !self.version_is_at_least_0_5_0 { + scan_not_followed_by!( input, scan_sequence!( - scan_chars!(input, '_'), - scan_one_or_more!(input, self.hex_character(input)) - ) + scan_chars!(input, '0', 'X'), + scan_one_or_more!(input, self.hex_character(input)), + scan_zero_or_more!( + input, + scan_sequence!( + scan_chars!(input, '_'), + scan_one_or_more!(input, self.hex_character(input)) + ) + ) + ), + self.identifier_start(input) ) - ), - self.identifier_start(input) + } else { + false + } ) } @@ -5712,8 +6271,8 @@ impl Language { input, scan_chars!(input, '_'), scan_chars!(input, '$'), - scan_char_range!(input, 'A'..='Z'), - scan_char_range!(input, 'a'..='z') + scan_char_range!(input, 'a'..='z'), + scan_char_range!(input, 'A'..='Z') ) } @@ -5721,46 +6280,72 @@ impl Language { fn int_keyword(&self, input: &mut ParserContext) -> bool { scan_sequence!( scan_chars!(input, 'i', 'n', 't'), - scan_optional!(input, self.integer_type_size(input)) + scan_optional!( + input, + scan_choice!( + input, + scan_chars!(input, '9', '6'), + scan_chars!(input, '8', '8'), + scan_chars!(input, '8', '0'), + scan_chars!(input, '8'), + scan_chars!(input, '7', '2'), + scan_chars!(input, '6', '4'), + scan_chars!(input, '5', '6'), + scan_chars!(input, '4', '8'), + scan_chars!(input, '4', '0'), + scan_chars!(input, '3', '2'), + scan_chars!(input, '2', '5', '6'), + scan_chars!(input, '2', '4', '8'), + scan_chars!(input, '2', '4', '0'), + scan_chars!(input, '2', '4'), + scan_chars!(input, '2', '3', '2'), + scan_chars!(input, '2', '2', '4'), + scan_chars!(input, '2', '1', '6'), + scan_chars!(input, '2', '0', '8'), + scan_chars!(input, '2', '0', '0'), + scan_chars!(input, '1', '9', '2'), + scan_chars!(input, '1', '8', '4'), + scan_chars!(input, '1', '7', '6'), + scan_chars!(input, '1', '6', '8'), + scan_chars!(input, '1', '6', '0'), + scan_chars!(input, '1', '6'), + scan_chars!(input, '1', '5', '2'), + scan_chars!(input, '1', '4', '4'), + scan_chars!(input, '1', '3', '6'), + scan_chars!(input, '1', '2', '8'), + scan_chars!(input, '1', '2', '0'), + scan_chars!(input, '1', '1', '2'), + scan_chars!(input, '1', '0', '4') + ) + ) ) } #[allow(unused_assignments, unused_parens)] - fn integer_type_size(&self, input: &mut ParserContext) -> bool { - scan_choice!( + fn less_than(&self, input: &mut ParserContext) -> bool { + scan_not_followed_by!( + input, + scan_chars!(input, '<'), + scan_choice!(input, scan_chars!(input, '='), scan_chars!(input, '<')) + ) + } + + #[allow(unused_assignments, unused_parens)] + fn less_than_less_than(&self, input: &mut ParserContext) -> bool { + scan_not_followed_by!(input, scan_chars!(input, '<', '<'), scan_chars!(input, '=')) + } + + #[allow(unused_assignments, unused_parens)] + fn minus(&self, input: &mut ParserContext) -> bool { + scan_not_followed_by!( input, - scan_chars!(input, '9', '6'), - scan_chars!(input, '8', '8'), - scan_chars!(input, '8', '0'), - scan_chars!(input, '8'), - scan_chars!(input, '7', '2'), - scan_chars!(input, '6', '4'), - scan_chars!(input, '5', '6'), - scan_chars!(input, '4', '8'), - scan_chars!(input, '4', '0'), - scan_chars!(input, '3', '2'), - scan_chars!(input, '2', '5', '6'), - scan_chars!(input, '2', '4', '8'), - scan_chars!(input, '2', '4', '0'), - scan_chars!(input, '2', '4'), - scan_chars!(input, '2', '3', '2'), - scan_chars!(input, '2', '2', '4'), - scan_chars!(input, '2', '1', '6'), - scan_chars!(input, '2', '0', '8'), - scan_chars!(input, '2', '0', '0'), - scan_chars!(input, '1', '9', '2'), - scan_chars!(input, '1', '8', '4'), - scan_chars!(input, '1', '7', '6'), - scan_chars!(input, '1', '6', '8'), - scan_chars!(input, '1', '6', '0'), - scan_chars!(input, '1', '6'), - scan_chars!(input, '1', '5', '2'), - scan_chars!(input, '1', '4', '4'), - scan_chars!(input, '1', '3', '6'), - scan_chars!(input, '1', '2', '8'), - scan_chars!(input, '1', '2', '0'), - scan_chars!(input, '1', '1', '2'), - scan_chars!(input, '1', '0', '4') + scan_chars!(input, '-'), + scan_choice!( + input, + scan_chars!(input, '>'), + scan_chars!(input, '='), + scan_chars!(input, '-') + ) ) } @@ -5782,6 +6367,20 @@ impl Language { ) } + #[allow(unused_assignments, unused_parens)] + fn percent(&self, input: &mut ParserContext) -> bool { + scan_not_followed_by!(input, scan_chars!(input, '%'), scan_chars!(input, '=')) + } + + #[allow(unused_assignments, unused_parens)] + fn plus(&self, input: &mut ParserContext) -> bool { + scan_not_followed_by!( + input, + scan_chars!(input, '+'), + scan_choice!(input, scan_chars!(input, '='), scan_chars!(input, '+')) + ) + } + #[allow(unused_assignments, unused_parens)] fn raw_identifier(&self, input: &mut ParserContext) -> bool { scan_sequence!( @@ -5794,7 +6393,7 @@ impl Language { fn single_line_comment(&self, input: &mut ParserContext) -> bool { scan_sequence!( scan_chars!(input, '/', '/'), - scan_zero_or_more!(input, scan_none_of!(input, '\n', '\r')) + scan_zero_or_more!(input, scan_none_of!(input, '\r', '\n')) ) } @@ -5807,7 +6406,9 @@ impl Language { scan_choice!( input, self.escape_sequence(input), - self.ascii_character_without_single_quote_or_backslash(input) + scan_char_range!(input, ' '..='&'), + scan_char_range!(input, '('..='['), + scan_char_range!(input, ']'..='~') ) ), scan_chars!(input, '\'') @@ -5833,7 +6434,7 @@ impl Language { scan_choice!( input, self.escape_sequence(input), - scan_none_of!(input, '\n', '\r', '\'', '\\') + scan_none_of!(input, '\'', '\\', '\r', '\n') ) ), scan_chars!(input, '\'') @@ -5843,11 +6444,291 @@ impl Language { } } + #[allow(unused_assignments, unused_parens)] + fn slash(&self, input: &mut ParserContext) -> bool { + scan_not_followed_by!(input, scan_chars!(input, '/'), scan_chars!(input, '=')) + } + #[allow(unused_assignments, unused_parens)] fn ufixed_keyword(&self, input: &mut ParserContext) -> bool { - scan_sequence!( + scan_choice!( + input, scan_chars!(input, 'u', 'f', 'i', 'x', 'e', 'd'), - scan_optional!(input, self.fixed_type_size(input)) + scan_sequence!( + scan_chars!(input, 'u', 'f', 'i', 'x', 'e', 'd'), + scan_choice!( + input, + scan_chars!(input, '9', '6'), + scan_chars!(input, '8', '8'), + scan_chars!(input, '8', '0'), + scan_chars!(input, '8'), + scan_chars!(input, '7', '2'), + scan_chars!(input, '6', '4'), + scan_chars!(input, '5', '6'), + scan_chars!(input, '4', '8'), + scan_chars!(input, '4', '0'), + scan_chars!(input, '3', '2'), + scan_chars!(input, '2', '4'), + scan_chars!(input, '1', '7', '6'), + scan_chars!(input, '1', '6', '8'), + scan_chars!(input, '1', '6', '0'), + scan_chars!(input, '1', '6'), + scan_chars!(input, '1', '5', '2'), + scan_chars!(input, '1', '4', '4'), + scan_chars!(input, '1', '3', '6'), + scan_chars!(input, '1', '2', '8'), + scan_chars!(input, '1', '2', '0'), + scan_chars!(input, '1', '1', '2'), + scan_chars!(input, '1', '0', '4') + ), + scan_chars!(input, 'x'), + scan_choice!( + input, + scan_chars!(input, '8', '0'), + scan_chars!(input, '8'), + scan_chars!(input, '7', '2'), + scan_chars!(input, '6', '4'), + scan_chars!(input, '5', '6'), + scan_chars!(input, '4', '8'), + scan_chars!(input, '4', '0'), + scan_chars!(input, '3', '2'), + scan_chars!(input, '2', '4'), + scan_chars!(input, '1', '6') + ) + ), + scan_sequence!( + scan_chars!(input, 'u', 'f', 'i', 'x', 'e', 'd'), + scan_choice!( + input, + scan_chars!(input, '2', '4', '8', 'x', '8'), + scan_chars!(input, '2', '4', '0', 'x', '8'), + scan_chars!(input, '2', '4', '0', 'x', '1', '6'), + scan_chars!(input, '2', '3', '2', 'x', '8'), + scan_chars!(input, '2', '3', '2', 'x', '2', '4'), + scan_chars!(input, '2', '3', '2', 'x', '1', '6'), + scan_chars!(input, '2', '2', '4', 'x', '8'), + scan_chars!(input, '2', '2', '4', 'x', '3', '2'), + scan_chars!(input, '2', '2', '4', 'x', '2', '4'), + scan_chars!(input, '2', '2', '4', 'x', '1', '6'), + scan_chars!(input, '2', '1', '6', 'x', '8'), + scan_chars!(input, '2', '1', '6', 'x', '4', '0'), + scan_chars!(input, '2', '1', '6', 'x', '3', '2'), + scan_chars!(input, '2', '1', '6', 'x', '2', '4'), + scan_chars!(input, '2', '1', '6', 'x', '1', '6'), + scan_chars!(input, '2', '0', '8', 'x', '8'), + scan_chars!(input, '2', '0', '8', 'x', '4', '8'), + scan_chars!(input, '2', '0', '8', 'x', '4', '0'), + scan_chars!(input, '2', '0', '8', 'x', '3', '2'), + scan_chars!(input, '2', '0', '8', 'x', '2', '4'), + scan_chars!(input, '2', '0', '8', 'x', '1', '6'), + scan_chars!(input, '2', '0', '0', 'x', '8'), + scan_chars!(input, '2', '0', '0', 'x', '5', '6'), + scan_chars!(input, '2', '0', '0', 'x', '4', '8'), + scan_chars!(input, '2', '0', '0', 'x', '4', '0'), + scan_chars!(input, '2', '0', '0', 'x', '3', '2'), + scan_chars!(input, '2', '0', '0', 'x', '2', '4'), + scan_chars!(input, '2', '0', '0', 'x', '1', '6'), + scan_chars!(input, '1', '9', '2', 'x', '8'), + scan_chars!(input, '1', '9', '2', 'x', '6', '4'), + scan_chars!(input, '1', '9', '2', 'x', '5', '6'), + scan_chars!(input, '1', '9', '2', 'x', '4', '8'), + scan_chars!(input, '1', '9', '2', 'x', '4', '0'), + scan_chars!(input, '1', '9', '2', 'x', '3', '2'), + scan_chars!(input, '1', '9', '2', 'x', '2', '4'), + scan_chars!(input, '1', '9', '2', 'x', '1', '6'), + scan_chars!(input, '1', '8', '4', 'x', '8'), + scan_chars!(input, '1', '8', '4', 'x', '7', '2'), + scan_chars!(input, '1', '8', '4', 'x', '6', '4'), + scan_chars!(input, '1', '8', '4', 'x', '5', '6'), + scan_chars!(input, '1', '8', '4', 'x', '4', '8'), + scan_chars!(input, '1', '8', '4', 'x', '4', '0'), + scan_chars!(input, '1', '8', '4', 'x', '3', '2'), + scan_chars!(input, '1', '8', '4', 'x', '2', '4'), + scan_chars!(input, '1', '8', '4', 'x', '1', '6') + ) + ), + if self.version_is_at_least_0_4_14 { + scan_sequence!( + scan_chars!(input, 'u', 'f', 'i', 'x', 'e', 'd'), + scan_choice!( + input, + scan_chars!(input, '2', '5', '6', 'x', '8', '0'), + scan_chars!(input, '2', '5', '6', 'x', '8'), + scan_chars!(input, '2', '5', '6', 'x', '7', '2'), + scan_chars!(input, '2', '5', '6', 'x', '6', '4'), + scan_chars!(input, '2', '5', '6', 'x', '5', '6'), + scan_chars!(input, '2', '5', '6', 'x', '4', '8'), + scan_chars!(input, '2', '5', '6', 'x', '4', '0'), + scan_chars!(input, '2', '5', '6', 'x', '3', '2'), + scan_chars!(input, '2', '5', '6', 'x', '2', '4'), + scan_chars!(input, '2', '5', '6', 'x', '1', '6'), + scan_chars!(input, '2', '4', '8', 'x', '8', '0'), + scan_chars!(input, '2', '4', '8', 'x', '7', '2'), + scan_chars!(input, '2', '4', '8', 'x', '6', '4'), + scan_chars!(input, '2', '4', '8', 'x', '5', '6'), + scan_chars!(input, '2', '4', '8', 'x', '4', '8'), + scan_chars!(input, '2', '4', '8', 'x', '4', '0'), + scan_chars!(input, '2', '4', '8', 'x', '3', '2'), + scan_chars!(input, '2', '4', '8', 'x', '2', '4'), + scan_chars!(input, '2', '4', '8', 'x', '1', '6'), + scan_chars!(input, '2', '4', '0', 'x', '8', '0'), + scan_chars!(input, '2', '4', '0', 'x', '7', '2'), + scan_chars!(input, '2', '4', '0', 'x', '6', '4'), + scan_chars!(input, '2', '4', '0', 'x', '5', '6'), + scan_chars!(input, '2', '4', '0', 'x', '4', '8'), + scan_chars!(input, '2', '4', '0', 'x', '4', '0'), + scan_chars!(input, '2', '4', '0', 'x', '3', '2'), + scan_chars!(input, '2', '4', '0', 'x', '2', '4'), + scan_chars!(input, '2', '3', '2', 'x', '8', '0'), + scan_chars!(input, '2', '3', '2', 'x', '7', '2'), + scan_chars!(input, '2', '3', '2', 'x', '6', '4'), + scan_chars!(input, '2', '3', '2', 'x', '5', '6'), + scan_chars!(input, '2', '3', '2', 'x', '4', '8'), + scan_chars!(input, '2', '3', '2', 'x', '4', '0'), + scan_chars!(input, '2', '3', '2', 'x', '3', '2'), + scan_chars!(input, '2', '2', '4', 'x', '8', '0'), + scan_chars!(input, '2', '2', '4', 'x', '7', '2'), + scan_chars!(input, '2', '2', '4', 'x', '6', '4'), + scan_chars!(input, '2', '2', '4', 'x', '5', '6'), + scan_chars!(input, '2', '2', '4', 'x', '4', '8'), + scan_chars!(input, '2', '2', '4', 'x', '4', '0'), + scan_chars!(input, '2', '1', '6', 'x', '8', '0'), + scan_chars!(input, '2', '1', '6', 'x', '7', '2'), + scan_chars!(input, '2', '1', '6', 'x', '6', '4'), + scan_chars!(input, '2', '1', '6', 'x', '5', '6'), + scan_chars!(input, '2', '1', '6', 'x', '4', '8'), + scan_chars!(input, '2', '0', '8', 'x', '8', '0'), + scan_chars!(input, '2', '0', '8', 'x', '7', '2'), + scan_chars!(input, '2', '0', '8', 'x', '6', '4'), + scan_chars!(input, '2', '0', '8', 'x', '5', '6'), + scan_chars!(input, '2', '0', '0', 'x', '8', '0'), + scan_chars!(input, '2', '0', '0', 'x', '7', '2'), + scan_chars!(input, '2', '0', '0', 'x', '6', '4'), + scan_chars!(input, '1', '9', '2', 'x', '8', '0'), + scan_chars!(input, '1', '9', '2', 'x', '7', '2'), + scan_chars!(input, '1', '8', '4', 'x', '8', '0') + ) + ) + } else { + false + }, + if self.version_is_at_least_0_4_14 { + scan_sequence!( + scan_chars!(input, 'u', 'f', 'i', 'x', 'e', 'd'), + scan_choice!( + input, + scan_chars!(input, '9', '6'), + scan_chars!(input, '8', '8'), + scan_chars!(input, '8', '0'), + scan_chars!(input, '8'), + scan_chars!(input, '7', '2'), + scan_chars!(input, '6', '4'), + scan_chars!(input, '5', '6'), + scan_chars!(input, '4', '8'), + scan_chars!(input, '4', '0'), + scan_chars!(input, '3', '2'), + scan_chars!(input, '2', '5', '6'), + scan_chars!(input, '2', '4', '8'), + scan_chars!(input, '2', '4', '0'), + scan_chars!(input, '2', '4'), + scan_chars!(input, '2', '3', '2'), + scan_chars!(input, '2', '2', '4'), + scan_chars!(input, '2', '1', '6'), + scan_chars!(input, '2', '0', '8'), + scan_chars!(input, '2', '0', '0'), + scan_chars!(input, '1', '9', '2'), + scan_chars!(input, '1', '8', '4'), + scan_chars!(input, '1', '7', '6'), + scan_chars!(input, '1', '6', '8'), + scan_chars!(input, '1', '6', '0'), + scan_chars!(input, '1', '6'), + scan_chars!(input, '1', '5', '2'), + scan_chars!(input, '1', '4', '4'), + scan_chars!(input, '1', '3', '6'), + scan_chars!(input, '1', '2', '8'), + scan_chars!(input, '1', '2', '0'), + scan_chars!(input, '1', '1', '2'), + scan_chars!(input, '1', '0', '4') + ), + scan_chars!(input, 'x'), + scan_choice!( + input, + scan_chars!(input, '9'), + scan_chars!(input, '7', '9'), + scan_chars!(input, '7', '8'), + scan_chars!(input, '7', '7'), + scan_chars!(input, '7', '6'), + scan_chars!(input, '7', '5'), + scan_chars!(input, '7', '4'), + scan_chars!(input, '7', '3'), + scan_chars!(input, '7', '1'), + scan_chars!(input, '7', '0'), + scan_chars!(input, '7'), + scan_chars!(input, '6', '9'), + scan_chars!(input, '6', '8'), + scan_chars!(input, '6', '7'), + scan_chars!(input, '6', '6'), + scan_chars!(input, '6', '5'), + scan_chars!(input, '6', '3'), + scan_chars!(input, '6', '2'), + scan_chars!(input, '6', '1'), + scan_chars!(input, '6', '0'), + scan_chars!(input, '6'), + scan_chars!(input, '5', '9'), + scan_chars!(input, '5', '8'), + scan_chars!(input, '5', '7'), + scan_chars!(input, '5', '5'), + scan_chars!(input, '5', '4'), + scan_chars!(input, '5', '3'), + scan_chars!(input, '5', '2'), + scan_chars!(input, '5', '1'), + scan_chars!(input, '5', '0'), + scan_chars!(input, '5'), + scan_chars!(input, '4', '9'), + scan_chars!(input, '4', '7'), + scan_chars!(input, '4', '6'), + scan_chars!(input, '4', '5'), + scan_chars!(input, '4', '4'), + scan_chars!(input, '4', '3'), + scan_chars!(input, '4', '2'), + scan_chars!(input, '4', '1'), + scan_chars!(input, '4'), + scan_chars!(input, '3', '9'), + scan_chars!(input, '3', '8'), + scan_chars!(input, '3', '7'), + scan_chars!(input, '3', '6'), + scan_chars!(input, '3', '5'), + scan_chars!(input, '3', '4'), + scan_chars!(input, '3', '3'), + scan_chars!(input, '3', '1'), + scan_chars!(input, '3', '0'), + scan_chars!(input, '3'), + scan_chars!(input, '2', '9'), + scan_chars!(input, '2', '8'), + scan_chars!(input, '2', '7'), + scan_chars!(input, '2', '6'), + scan_chars!(input, '2', '5'), + scan_chars!(input, '2', '3'), + scan_chars!(input, '2', '2'), + scan_chars!(input, '2', '1'), + scan_chars!(input, '2', '0'), + scan_chars!(input, '2'), + scan_chars!(input, '1', '9'), + scan_chars!(input, '1', '8'), + scan_chars!(input, '1', '7'), + scan_chars!(input, '1', '5'), + scan_chars!(input, '1', '4'), + scan_chars!(input, '1', '3'), + scan_chars!(input, '1', '2'), + scan_chars!(input, '1', '1'), + scan_chars!(input, '1', '0'), + scan_chars!(input, '1'), + scan_chars!(input, '0') + ) + ) + } else { + false + } ) } @@ -5855,7 +6736,44 @@ impl Language { fn uint_keyword(&self, input: &mut ParserContext) -> bool { scan_sequence!( scan_chars!(input, 'u', 'i', 'n', 't'), - scan_optional!(input, self.integer_type_size(input)) + scan_optional!( + input, + scan_choice!( + input, + scan_chars!(input, '9', '6'), + scan_chars!(input, '8', '8'), + scan_chars!(input, '8', '0'), + scan_chars!(input, '8'), + scan_chars!(input, '7', '2'), + scan_chars!(input, '6', '4'), + scan_chars!(input, '5', '6'), + scan_chars!(input, '4', '8'), + scan_chars!(input, '4', '0'), + scan_chars!(input, '3', '2'), + scan_chars!(input, '2', '5', '6'), + scan_chars!(input, '2', '4', '8'), + scan_chars!(input, '2', '4', '0'), + scan_chars!(input, '2', '4'), + scan_chars!(input, '2', '3', '2'), + scan_chars!(input, '2', '2', '4'), + scan_chars!(input, '2', '1', '6'), + scan_chars!(input, '2', '0', '8'), + scan_chars!(input, '2', '0', '0'), + scan_chars!(input, '1', '9', '2'), + scan_chars!(input, '1', '8', '4'), + scan_chars!(input, '1', '7', '6'), + scan_chars!(input, '1', '6', '8'), + scan_chars!(input, '1', '6', '0'), + scan_chars!(input, '1', '6'), + scan_chars!(input, '1', '5', '2'), + scan_chars!(input, '1', '4', '4'), + scan_chars!(input, '1', '3', '6'), + scan_chars!(input, '1', '2', '8'), + scan_chars!(input, '1', '2', '0'), + scan_chars!(input, '1', '1', '2'), + scan_chars!(input, '1', '0', '4') + ) + ) ) } @@ -5872,15 +6790,19 @@ impl Language { #[allow(unused_assignments, unused_parens)] fn unicode_string_literal(&self, input: &mut ParserContext) -> bool { - if self.version_is_at_least_0_7_0 { - scan_choice!( - input, - self.single_quoted_unicode_string_literal(input), + scan_choice!( + input, + if self.version_is_at_least_0_7_0 { + self.single_quoted_unicode_string_literal(input) + } else { + false + }, + if self.version_is_at_least_0_7_0 { self.double_quoted_unicode_string_literal(input) - ) - } else { - false - } + } else { + false + } + ) } #[allow(unused_assignments, unused_parens)] @@ -5905,6 +6827,52 @@ impl Language { ) } + #[allow(unused_assignments, unused_parens)] + fn yul_bytes_keyword(&self, input: &mut ParserContext) -> bool { + if !self.version_is_at_least_0_7_1 { + scan_sequence!( + scan_chars!(input, 'b', 'y', 't', 'e', 's'), + scan_choice!( + input, + scan_chars!(input, '9'), + scan_chars!(input, '8'), + scan_chars!(input, '7'), + scan_chars!(input, '6'), + scan_chars!(input, '5'), + scan_chars!(input, '4'), + scan_chars!(input, '3', '2'), + scan_chars!(input, '3', '1'), + scan_chars!(input, '3', '0'), + scan_chars!(input, '3'), + scan_chars!(input, '2', '9'), + scan_chars!(input, '2', '8'), + scan_chars!(input, '2', '7'), + scan_chars!(input, '2', '6'), + scan_chars!(input, '2', '5'), + scan_chars!(input, '2', '4'), + scan_chars!(input, '2', '3'), + scan_chars!(input, '2', '2'), + scan_chars!(input, '2', '1'), + scan_chars!(input, '2', '0'), + scan_chars!(input, '2'), + scan_chars!(input, '1', '9'), + scan_chars!(input, '1', '8'), + scan_chars!(input, '1', '7'), + scan_chars!(input, '1', '6'), + scan_chars!(input, '1', '5'), + scan_chars!(input, '1', '4'), + scan_chars!(input, '1', '3'), + scan_chars!(input, '1', '2'), + scan_chars!(input, '1', '1'), + scan_chars!(input, '1', '0'), + scan_chars!(input, '1') + ) + ) + } else { + false + } + } + #[allow(unused_assignments, unused_parens)] fn yul_decimal_literal(&self, input: &mut ParserContext) -> bool { scan_not_followed_by!( @@ -5914,13 +6882,308 @@ impl Language { scan_chars!(input, '0'), scan_sequence!( scan_char_range!(input, '1'..='9'), - scan_zero_or_more!(input, self.decimal_digit(input)) + scan_zero_or_more!(input, scan_char_range!(input, '0'..='9')) ) ), self.identifier_start(input) ) } + #[allow(unused_assignments, unused_parens)] + fn yul_fixed_keyword(&self, input: &mut ParserContext) -> bool { + scan_choice!( + input, + if !self.version_is_at_least_0_7_1 { + scan_chars!(input, 'f', 'i', 'x', 'e', 'd') + } else { + false + }, + if !self.version_is_at_least_0_7_1 { + scan_sequence!( + scan_chars!(input, 'f', 'i', 'x', 'e', 'd'), + scan_choice!( + input, + scan_chars!(input, '9', '6'), + scan_chars!(input, '8', '8'), + scan_chars!(input, '8', '0'), + scan_chars!(input, '8'), + scan_chars!(input, '7', '2'), + scan_chars!(input, '6', '4'), + scan_chars!(input, '5', '6'), + scan_chars!(input, '4', '8'), + scan_chars!(input, '4', '0'), + scan_chars!(input, '3', '2'), + scan_chars!(input, '2', '4'), + scan_chars!(input, '1', '7', '6'), + scan_chars!(input, '1', '6', '8'), + scan_chars!(input, '1', '6', '0'), + scan_chars!(input, '1', '6'), + scan_chars!(input, '1', '5', '2'), + scan_chars!(input, '1', '4', '4'), + scan_chars!(input, '1', '3', '6'), + scan_chars!(input, '1', '2', '8'), + scan_chars!(input, '1', '2', '0'), + scan_chars!(input, '1', '1', '2'), + scan_chars!(input, '1', '0', '4') + ), + scan_chars!(input, 'x'), + scan_choice!( + input, + scan_chars!(input, '8', '0'), + scan_chars!(input, '8'), + scan_chars!(input, '7', '2'), + scan_chars!(input, '6', '4'), + scan_chars!(input, '5', '6'), + scan_chars!(input, '4', '8'), + scan_chars!(input, '4', '0'), + scan_chars!(input, '3', '2'), + scan_chars!(input, '2', '4'), + scan_chars!(input, '1', '6') + ) + ) + } else { + false + }, + if !self.version_is_at_least_0_7_1 { + scan_sequence!( + scan_chars!(input, 'f', 'i', 'x', 'e', 'd'), + scan_choice!( + input, + scan_chars!(input, '2', '4', '8', 'x', '8'), + scan_chars!(input, '2', '4', '0', 'x', '8'), + scan_chars!(input, '2', '4', '0', 'x', '1', '6'), + scan_chars!(input, '2', '3', '2', 'x', '8'), + scan_chars!(input, '2', '3', '2', 'x', '2', '4'), + scan_chars!(input, '2', '3', '2', 'x', '1', '6'), + scan_chars!(input, '2', '2', '4', 'x', '8'), + scan_chars!(input, '2', '2', '4', 'x', '3', '2'), + scan_chars!(input, '2', '2', '4', 'x', '2', '4'), + scan_chars!(input, '2', '2', '4', 'x', '1', '6'), + scan_chars!(input, '2', '1', '6', 'x', '8'), + scan_chars!(input, '2', '1', '6', 'x', '4', '0'), + scan_chars!(input, '2', '1', '6', 'x', '3', '2'), + scan_chars!(input, '2', '1', '6', 'x', '2', '4'), + scan_chars!(input, '2', '1', '6', 'x', '1', '6'), + scan_chars!(input, '2', '0', '8', 'x', '8'), + scan_chars!(input, '2', '0', '8', 'x', '4', '8'), + scan_chars!(input, '2', '0', '8', 'x', '4', '0'), + scan_chars!(input, '2', '0', '8', 'x', '3', '2'), + scan_chars!(input, '2', '0', '8', 'x', '2', '4'), + scan_chars!(input, '2', '0', '8', 'x', '1', '6'), + scan_chars!(input, '2', '0', '0', 'x', '8'), + scan_chars!(input, '2', '0', '0', 'x', '5', '6'), + scan_chars!(input, '2', '0', '0', 'x', '4', '8'), + scan_chars!(input, '2', '0', '0', 'x', '4', '0'), + scan_chars!(input, '2', '0', '0', 'x', '3', '2'), + scan_chars!(input, '2', '0', '0', 'x', '2', '4'), + scan_chars!(input, '2', '0', '0', 'x', '1', '6'), + scan_chars!(input, '1', '9', '2', 'x', '8'), + scan_chars!(input, '1', '9', '2', 'x', '6', '4'), + scan_chars!(input, '1', '9', '2', 'x', '5', '6'), + scan_chars!(input, '1', '9', '2', 'x', '4', '8'), + scan_chars!(input, '1', '9', '2', 'x', '4', '0'), + scan_chars!(input, '1', '9', '2', 'x', '3', '2'), + scan_chars!(input, '1', '9', '2', 'x', '2', '4'), + scan_chars!(input, '1', '9', '2', 'x', '1', '6'), + scan_chars!(input, '1', '8', '4', 'x', '8'), + scan_chars!(input, '1', '8', '4', 'x', '7', '2'), + scan_chars!(input, '1', '8', '4', 'x', '6', '4'), + scan_chars!(input, '1', '8', '4', 'x', '5', '6'), + scan_chars!(input, '1', '8', '4', 'x', '4', '8'), + scan_chars!(input, '1', '8', '4', 'x', '4', '0'), + scan_chars!(input, '1', '8', '4', 'x', '3', '2'), + scan_chars!(input, '1', '8', '4', 'x', '2', '4'), + scan_chars!(input, '1', '8', '4', 'x', '1', '6') + ) + ) + } else { + false + }, + if self.version_is_at_least_0_4_14 && !self.version_is_at_least_0_7_1 { + scan_sequence!( + scan_chars!(input, 'f', 'i', 'x', 'e', 'd'), + scan_choice!( + input, + scan_chars!(input, '2', '5', '6', 'x', '8', '0'), + scan_chars!(input, '2', '5', '6', 'x', '8'), + scan_chars!(input, '2', '5', '6', 'x', '7', '2'), + scan_chars!(input, '2', '5', '6', 'x', '6', '4'), + scan_chars!(input, '2', '5', '6', 'x', '5', '6'), + scan_chars!(input, '2', '5', '6', 'x', '4', '8'), + scan_chars!(input, '2', '5', '6', 'x', '4', '0'), + scan_chars!(input, '2', '5', '6', 'x', '3', '2'), + scan_chars!(input, '2', '5', '6', 'x', '2', '4'), + scan_chars!(input, '2', '5', '6', 'x', '1', '6'), + scan_chars!(input, '2', '4', '8', 'x', '8', '0'), + scan_chars!(input, '2', '4', '8', 'x', '7', '2'), + scan_chars!(input, '2', '4', '8', 'x', '6', '4'), + scan_chars!(input, '2', '4', '8', 'x', '5', '6'), + scan_chars!(input, '2', '4', '8', 'x', '4', '8'), + scan_chars!(input, '2', '4', '8', 'x', '4', '0'), + scan_chars!(input, '2', '4', '8', 'x', '3', '2'), + scan_chars!(input, '2', '4', '8', 'x', '2', '4'), + scan_chars!(input, '2', '4', '8', 'x', '1', '6'), + scan_chars!(input, '2', '4', '0', 'x', '8', '0'), + scan_chars!(input, '2', '4', '0', 'x', '7', '2'), + scan_chars!(input, '2', '4', '0', 'x', '6', '4'), + scan_chars!(input, '2', '4', '0', 'x', '5', '6'), + scan_chars!(input, '2', '4', '0', 'x', '4', '8'), + scan_chars!(input, '2', '4', '0', 'x', '4', '0'), + scan_chars!(input, '2', '4', '0', 'x', '3', '2'), + scan_chars!(input, '2', '4', '0', 'x', '2', '4'), + scan_chars!(input, '2', '3', '2', 'x', '8', '0'), + scan_chars!(input, '2', '3', '2', 'x', '7', '2'), + scan_chars!(input, '2', '3', '2', 'x', '6', '4'), + scan_chars!(input, '2', '3', '2', 'x', '5', '6'), + scan_chars!(input, '2', '3', '2', 'x', '4', '8'), + scan_chars!(input, '2', '3', '2', 'x', '4', '0'), + scan_chars!(input, '2', '3', '2', 'x', '3', '2'), + scan_chars!(input, '2', '2', '4', 'x', '8', '0'), + scan_chars!(input, '2', '2', '4', 'x', '7', '2'), + scan_chars!(input, '2', '2', '4', 'x', '6', '4'), + scan_chars!(input, '2', '2', '4', 'x', '5', '6'), + scan_chars!(input, '2', '2', '4', 'x', '4', '8'), + scan_chars!(input, '2', '2', '4', 'x', '4', '0'), + scan_chars!(input, '2', '1', '6', 'x', '8', '0'), + scan_chars!(input, '2', '1', '6', 'x', '7', '2'), + scan_chars!(input, '2', '1', '6', 'x', '6', '4'), + scan_chars!(input, '2', '1', '6', 'x', '5', '6'), + scan_chars!(input, '2', '1', '6', 'x', '4', '8'), + scan_chars!(input, '2', '0', '8', 'x', '8', '0'), + scan_chars!(input, '2', '0', '8', 'x', '7', '2'), + scan_chars!(input, '2', '0', '8', 'x', '6', '4'), + scan_chars!(input, '2', '0', '8', 'x', '5', '6'), + scan_chars!(input, '2', '0', '0', 'x', '8', '0'), + scan_chars!(input, '2', '0', '0', 'x', '7', '2'), + scan_chars!(input, '2', '0', '0', 'x', '6', '4'), + scan_chars!(input, '1', '9', '2', 'x', '8', '0'), + scan_chars!(input, '1', '9', '2', 'x', '7', '2'), + scan_chars!(input, '1', '8', '4', 'x', '8', '0') + ) + ) + } else { + false + }, + if self.version_is_at_least_0_4_14 && !self.version_is_at_least_0_7_1 { + scan_sequence!( + scan_chars!(input, 'f', 'i', 'x', 'e', 'd'), + scan_choice!( + input, + scan_chars!(input, '9', '6'), + scan_chars!(input, '8', '8'), + scan_chars!(input, '8', '0'), + scan_chars!(input, '8'), + scan_chars!(input, '7', '2'), + scan_chars!(input, '6', '4'), + scan_chars!(input, '5', '6'), + scan_chars!(input, '4', '8'), + scan_chars!(input, '4', '0'), + scan_chars!(input, '3', '2'), + scan_chars!(input, '2', '5', '6'), + scan_chars!(input, '2', '4', '8'), + scan_chars!(input, '2', '4', '0'), + scan_chars!(input, '2', '4'), + scan_chars!(input, '2', '3', '2'), + scan_chars!(input, '2', '2', '4'), + scan_chars!(input, '2', '1', '6'), + scan_chars!(input, '2', '0', '8'), + scan_chars!(input, '2', '0', '0'), + scan_chars!(input, '1', '9', '2'), + scan_chars!(input, '1', '8', '4'), + scan_chars!(input, '1', '7', '6'), + scan_chars!(input, '1', '6', '8'), + scan_chars!(input, '1', '6', '0'), + scan_chars!(input, '1', '6'), + scan_chars!(input, '1', '5', '2'), + scan_chars!(input, '1', '4', '4'), + scan_chars!(input, '1', '3', '6'), + scan_chars!(input, '1', '2', '8'), + scan_chars!(input, '1', '2', '0'), + scan_chars!(input, '1', '1', '2'), + scan_chars!(input, '1', '0', '4') + ), + scan_chars!(input, 'x'), + scan_choice!( + input, + scan_chars!(input, '9'), + scan_chars!(input, '7', '9'), + scan_chars!(input, '7', '8'), + scan_chars!(input, '7', '7'), + scan_chars!(input, '7', '6'), + scan_chars!(input, '7', '5'), + scan_chars!(input, '7', '4'), + scan_chars!(input, '7', '3'), + scan_chars!(input, '7', '1'), + scan_chars!(input, '7', '0'), + scan_chars!(input, '7'), + scan_chars!(input, '6', '9'), + scan_chars!(input, '6', '8'), + scan_chars!(input, '6', '7'), + scan_chars!(input, '6', '6'), + scan_chars!(input, '6', '5'), + scan_chars!(input, '6', '3'), + scan_chars!(input, '6', '2'), + scan_chars!(input, '6', '1'), + scan_chars!(input, '6', '0'), + scan_chars!(input, '6'), + scan_chars!(input, '5', '9'), + scan_chars!(input, '5', '8'), + scan_chars!(input, '5', '7'), + scan_chars!(input, '5', '5'), + scan_chars!(input, '5', '4'), + scan_chars!(input, '5', '3'), + scan_chars!(input, '5', '2'), + scan_chars!(input, '5', '1'), + scan_chars!(input, '5', '0'), + scan_chars!(input, '5'), + scan_chars!(input, '4', '9'), + scan_chars!(input, '4', '7'), + scan_chars!(input, '4', '6'), + scan_chars!(input, '4', '5'), + scan_chars!(input, '4', '4'), + scan_chars!(input, '4', '3'), + scan_chars!(input, '4', '2'), + scan_chars!(input, '4', '1'), + scan_chars!(input, '4'), + scan_chars!(input, '3', '9'), + scan_chars!(input, '3', '8'), + scan_chars!(input, '3', '7'), + scan_chars!(input, '3', '6'), + scan_chars!(input, '3', '5'), + scan_chars!(input, '3', '4'), + scan_chars!(input, '3', '3'), + scan_chars!(input, '3', '1'), + scan_chars!(input, '3', '0'), + scan_chars!(input, '3'), + scan_chars!(input, '2', '9'), + scan_chars!(input, '2', '8'), + scan_chars!(input, '2', '7'), + scan_chars!(input, '2', '6'), + scan_chars!(input, '2', '5'), + scan_chars!(input, '2', '3'), + scan_chars!(input, '2', '2'), + scan_chars!(input, '2', '1'), + scan_chars!(input, '2', '0'), + scan_chars!(input, '2'), + scan_chars!(input, '1', '9'), + scan_chars!(input, '1', '8'), + scan_chars!(input, '1', '7'), + scan_chars!(input, '1', '5'), + scan_chars!(input, '1', '4'), + scan_chars!(input, '1', '3'), + scan_chars!(input, '1', '2'), + scan_chars!(input, '1', '1'), + scan_chars!(input, '1', '0'), + scan_chars!(input, '1'), + scan_chars!(input, '0') + ) + ) + } else { + false + } + ) + } + #[allow(unused_assignments, unused_parens)] fn yul_hex_literal(&self, input: &mut ParserContext) -> bool { scan_not_followed_by!( @@ -5938,18 +7201,409 @@ impl Language { self.raw_identifier(input) } + #[allow(unused_assignments, unused_parens)] + fn yul_int_keyword(&self, input: &mut ParserContext) -> bool { + if !self.version_is_at_least_0_7_1 { + scan_sequence!( + scan_chars!(input, 'i', 'n', 't'), + scan_optional!( + input, + scan_choice!( + input, + scan_chars!(input, '9', '6'), + scan_chars!(input, '8', '8'), + scan_chars!(input, '8', '0'), + scan_chars!(input, '8'), + scan_chars!(input, '7', '2'), + scan_chars!(input, '6', '4'), + scan_chars!(input, '5', '6'), + scan_chars!(input, '4', '8'), + scan_chars!(input, '4', '0'), + scan_chars!(input, '3', '2'), + scan_chars!(input, '2', '5', '6'), + scan_chars!(input, '2', '4', '8'), + scan_chars!(input, '2', '4', '0'), + scan_chars!(input, '2', '4'), + scan_chars!(input, '2', '3', '2'), + scan_chars!(input, '2', '2', '4'), + scan_chars!(input, '2', '1', '6'), + scan_chars!(input, '2', '0', '8'), + scan_chars!(input, '2', '0', '0'), + scan_chars!(input, '1', '9', '2'), + scan_chars!(input, '1', '8', '4'), + scan_chars!(input, '1', '7', '6'), + scan_chars!(input, '1', '6', '8'), + scan_chars!(input, '1', '6', '0'), + scan_chars!(input, '1', '6'), + scan_chars!(input, '1', '5', '2'), + scan_chars!(input, '1', '4', '4'), + scan_chars!(input, '1', '3', '6'), + scan_chars!(input, '1', '2', '8'), + scan_chars!(input, '1', '2', '0'), + scan_chars!(input, '1', '1', '2'), + scan_chars!(input, '1', '0', '4') + ) + ) + ) + } else { + false + } + } + + #[allow(unused_assignments, unused_parens)] + fn yul_ufixed_keyword(&self, input: &mut ParserContext) -> bool { + scan_choice!( + input, + if !self.version_is_at_least_0_7_1 { + scan_chars!(input, 'u', 'f', 'i', 'x', 'e', 'd') + } else { + false + }, + if !self.version_is_at_least_0_7_1 { + scan_sequence!( + scan_chars!(input, 'u', 'f', 'i', 'x', 'e', 'd'), + scan_choice!( + input, + scan_chars!(input, '9', '6'), + scan_chars!(input, '8', '8'), + scan_chars!(input, '8', '0'), + scan_chars!(input, '8'), + scan_chars!(input, '7', '2'), + scan_chars!(input, '6', '4'), + scan_chars!(input, '5', '6'), + scan_chars!(input, '4', '8'), + scan_chars!(input, '4', '0'), + scan_chars!(input, '3', '2'), + scan_chars!(input, '2', '4'), + scan_chars!(input, '1', '7', '6'), + scan_chars!(input, '1', '6', '8'), + scan_chars!(input, '1', '6', '0'), + scan_chars!(input, '1', '6'), + scan_chars!(input, '1', '5', '2'), + scan_chars!(input, '1', '4', '4'), + scan_chars!(input, '1', '3', '6'), + scan_chars!(input, '1', '2', '8'), + scan_chars!(input, '1', '2', '0'), + scan_chars!(input, '1', '1', '2'), + scan_chars!(input, '1', '0', '4') + ), + scan_chars!(input, 'x'), + scan_choice!( + input, + scan_chars!(input, '8', '0'), + scan_chars!(input, '8'), + scan_chars!(input, '7', '2'), + scan_chars!(input, '6', '4'), + scan_chars!(input, '5', '6'), + scan_chars!(input, '4', '8'), + scan_chars!(input, '4', '0'), + scan_chars!(input, '3', '2'), + scan_chars!(input, '2', '4'), + scan_chars!(input, '1', '6') + ) + ) + } else { + false + }, + if !self.version_is_at_least_0_7_1 { + scan_sequence!( + scan_chars!(input, 'u', 'f', 'i', 'x', 'e', 'd'), + scan_choice!( + input, + scan_chars!(input, '2', '4', '8', 'x', '8'), + scan_chars!(input, '2', '4', '0', 'x', '8'), + scan_chars!(input, '2', '4', '0', 'x', '1', '6'), + scan_chars!(input, '2', '3', '2', 'x', '8'), + scan_chars!(input, '2', '3', '2', 'x', '2', '4'), + scan_chars!(input, '2', '3', '2', 'x', '1', '6'), + scan_chars!(input, '2', '2', '4', 'x', '8'), + scan_chars!(input, '2', '2', '4', 'x', '3', '2'), + scan_chars!(input, '2', '2', '4', 'x', '2', '4'), + scan_chars!(input, '2', '2', '4', 'x', '1', '6'), + scan_chars!(input, '2', '1', '6', 'x', '8'), + scan_chars!(input, '2', '1', '6', 'x', '4', '0'), + scan_chars!(input, '2', '1', '6', 'x', '3', '2'), + scan_chars!(input, '2', '1', '6', 'x', '2', '4'), + scan_chars!(input, '2', '1', '6', 'x', '1', '6'), + scan_chars!(input, '2', '0', '8', 'x', '8'), + scan_chars!(input, '2', '0', '8', 'x', '4', '8'), + scan_chars!(input, '2', '0', '8', 'x', '4', '0'), + scan_chars!(input, '2', '0', '8', 'x', '3', '2'), + scan_chars!(input, '2', '0', '8', 'x', '2', '4'), + scan_chars!(input, '2', '0', '8', 'x', '1', '6'), + scan_chars!(input, '2', '0', '0', 'x', '8'), + scan_chars!(input, '2', '0', '0', 'x', '5', '6'), + scan_chars!(input, '2', '0', '0', 'x', '4', '8'), + scan_chars!(input, '2', '0', '0', 'x', '4', '0'), + scan_chars!(input, '2', '0', '0', 'x', '3', '2'), + scan_chars!(input, '2', '0', '0', 'x', '2', '4'), + scan_chars!(input, '2', '0', '0', 'x', '1', '6'), + scan_chars!(input, '1', '9', '2', 'x', '8'), + scan_chars!(input, '1', '9', '2', 'x', '6', '4'), + scan_chars!(input, '1', '9', '2', 'x', '5', '6'), + scan_chars!(input, '1', '9', '2', 'x', '4', '8'), + scan_chars!(input, '1', '9', '2', 'x', '4', '0'), + scan_chars!(input, '1', '9', '2', 'x', '3', '2'), + scan_chars!(input, '1', '9', '2', 'x', '2', '4'), + scan_chars!(input, '1', '9', '2', 'x', '1', '6'), + scan_chars!(input, '1', '8', '4', 'x', '8'), + scan_chars!(input, '1', '8', '4', 'x', '7', '2'), + scan_chars!(input, '1', '8', '4', 'x', '6', '4'), + scan_chars!(input, '1', '8', '4', 'x', '5', '6'), + scan_chars!(input, '1', '8', '4', 'x', '4', '8'), + scan_chars!(input, '1', '8', '4', 'x', '4', '0'), + scan_chars!(input, '1', '8', '4', 'x', '3', '2'), + scan_chars!(input, '1', '8', '4', 'x', '2', '4'), + scan_chars!(input, '1', '8', '4', 'x', '1', '6') + ) + ) + } else { + false + }, + if self.version_is_at_least_0_4_14 && !self.version_is_at_least_0_7_1 { + scan_sequence!( + scan_chars!(input, 'u', 'f', 'i', 'x', 'e', 'd'), + scan_choice!( + input, + scan_chars!(input, '2', '5', '6', 'x', '8', '0'), + scan_chars!(input, '2', '5', '6', 'x', '8'), + scan_chars!(input, '2', '5', '6', 'x', '7', '2'), + scan_chars!(input, '2', '5', '6', 'x', '6', '4'), + scan_chars!(input, '2', '5', '6', 'x', '5', '6'), + scan_chars!(input, '2', '5', '6', 'x', '4', '8'), + scan_chars!(input, '2', '5', '6', 'x', '4', '0'), + scan_chars!(input, '2', '5', '6', 'x', '3', '2'), + scan_chars!(input, '2', '5', '6', 'x', '2', '4'), + scan_chars!(input, '2', '5', '6', 'x', '1', '6'), + scan_chars!(input, '2', '4', '8', 'x', '8', '0'), + scan_chars!(input, '2', '4', '8', 'x', '7', '2'), + scan_chars!(input, '2', '4', '8', 'x', '6', '4'), + scan_chars!(input, '2', '4', '8', 'x', '5', '6'), + scan_chars!(input, '2', '4', '8', 'x', '4', '8'), + scan_chars!(input, '2', '4', '8', 'x', '4', '0'), + scan_chars!(input, '2', '4', '8', 'x', '3', '2'), + scan_chars!(input, '2', '4', '8', 'x', '2', '4'), + scan_chars!(input, '2', '4', '8', 'x', '1', '6'), + scan_chars!(input, '2', '4', '0', 'x', '8', '0'), + scan_chars!(input, '2', '4', '0', 'x', '7', '2'), + scan_chars!(input, '2', '4', '0', 'x', '6', '4'), + scan_chars!(input, '2', '4', '0', 'x', '5', '6'), + scan_chars!(input, '2', '4', '0', 'x', '4', '8'), + scan_chars!(input, '2', '4', '0', 'x', '4', '0'), + scan_chars!(input, '2', '4', '0', 'x', '3', '2'), + scan_chars!(input, '2', '4', '0', 'x', '2', '4'), + scan_chars!(input, '2', '3', '2', 'x', '8', '0'), + scan_chars!(input, '2', '3', '2', 'x', '7', '2'), + scan_chars!(input, '2', '3', '2', 'x', '6', '4'), + scan_chars!(input, '2', '3', '2', 'x', '5', '6'), + scan_chars!(input, '2', '3', '2', 'x', '4', '8'), + scan_chars!(input, '2', '3', '2', 'x', '4', '0'), + scan_chars!(input, '2', '3', '2', 'x', '3', '2'), + scan_chars!(input, '2', '2', '4', 'x', '8', '0'), + scan_chars!(input, '2', '2', '4', 'x', '7', '2'), + scan_chars!(input, '2', '2', '4', 'x', '6', '4'), + scan_chars!(input, '2', '2', '4', 'x', '5', '6'), + scan_chars!(input, '2', '2', '4', 'x', '4', '8'), + scan_chars!(input, '2', '2', '4', 'x', '4', '0'), + scan_chars!(input, '2', '1', '6', 'x', '8', '0'), + scan_chars!(input, '2', '1', '6', 'x', '7', '2'), + scan_chars!(input, '2', '1', '6', 'x', '6', '4'), + scan_chars!(input, '2', '1', '6', 'x', '5', '6'), + scan_chars!(input, '2', '1', '6', 'x', '4', '8'), + scan_chars!(input, '2', '0', '8', 'x', '8', '0'), + scan_chars!(input, '2', '0', '8', 'x', '7', '2'), + scan_chars!(input, '2', '0', '8', 'x', '6', '4'), + scan_chars!(input, '2', '0', '8', 'x', '5', '6'), + scan_chars!(input, '2', '0', '0', 'x', '8', '0'), + scan_chars!(input, '2', '0', '0', 'x', '7', '2'), + scan_chars!(input, '2', '0', '0', 'x', '6', '4'), + scan_chars!(input, '1', '9', '2', 'x', '8', '0'), + scan_chars!(input, '1', '9', '2', 'x', '7', '2'), + scan_chars!(input, '1', '8', '4', 'x', '8', '0') + ) + ) + } else { + false + }, + if self.version_is_at_least_0_4_14 && !self.version_is_at_least_0_7_1 { + scan_sequence!( + scan_chars!(input, 'u', 'f', 'i', 'x', 'e', 'd'), + scan_choice!( + input, + scan_chars!(input, '9', '6'), + scan_chars!(input, '8', '8'), + scan_chars!(input, '8', '0'), + scan_chars!(input, '8'), + scan_chars!(input, '7', '2'), + scan_chars!(input, '6', '4'), + scan_chars!(input, '5', '6'), + scan_chars!(input, '4', '8'), + scan_chars!(input, '4', '0'), + scan_chars!(input, '3', '2'), + scan_chars!(input, '2', '5', '6'), + scan_chars!(input, '2', '4', '8'), + scan_chars!(input, '2', '4', '0'), + scan_chars!(input, '2', '4'), + scan_chars!(input, '2', '3', '2'), + scan_chars!(input, '2', '2', '4'), + scan_chars!(input, '2', '1', '6'), + scan_chars!(input, '2', '0', '8'), + scan_chars!(input, '2', '0', '0'), + scan_chars!(input, '1', '9', '2'), + scan_chars!(input, '1', '8', '4'), + scan_chars!(input, '1', '7', '6'), + scan_chars!(input, '1', '6', '8'), + scan_chars!(input, '1', '6', '0'), + scan_chars!(input, '1', '6'), + scan_chars!(input, '1', '5', '2'), + scan_chars!(input, '1', '4', '4'), + scan_chars!(input, '1', '3', '6'), + scan_chars!(input, '1', '2', '8'), + scan_chars!(input, '1', '2', '0'), + scan_chars!(input, '1', '1', '2'), + scan_chars!(input, '1', '0', '4') + ), + scan_chars!(input, 'x'), + scan_choice!( + input, + scan_chars!(input, '9'), + scan_chars!(input, '7', '9'), + scan_chars!(input, '7', '8'), + scan_chars!(input, '7', '7'), + scan_chars!(input, '7', '6'), + scan_chars!(input, '7', '5'), + scan_chars!(input, '7', '4'), + scan_chars!(input, '7', '3'), + scan_chars!(input, '7', '1'), + scan_chars!(input, '7', '0'), + scan_chars!(input, '7'), + scan_chars!(input, '6', '9'), + scan_chars!(input, '6', '8'), + scan_chars!(input, '6', '7'), + scan_chars!(input, '6', '6'), + scan_chars!(input, '6', '5'), + scan_chars!(input, '6', '3'), + scan_chars!(input, '6', '2'), + scan_chars!(input, '6', '1'), + scan_chars!(input, '6', '0'), + scan_chars!(input, '6'), + scan_chars!(input, '5', '9'), + scan_chars!(input, '5', '8'), + scan_chars!(input, '5', '7'), + scan_chars!(input, '5', '5'), + scan_chars!(input, '5', '4'), + scan_chars!(input, '5', '3'), + scan_chars!(input, '5', '2'), + scan_chars!(input, '5', '1'), + scan_chars!(input, '5', '0'), + scan_chars!(input, '5'), + scan_chars!(input, '4', '9'), + scan_chars!(input, '4', '7'), + scan_chars!(input, '4', '6'), + scan_chars!(input, '4', '5'), + scan_chars!(input, '4', '4'), + scan_chars!(input, '4', '3'), + scan_chars!(input, '4', '2'), + scan_chars!(input, '4', '1'), + scan_chars!(input, '4'), + scan_chars!(input, '3', '9'), + scan_chars!(input, '3', '8'), + scan_chars!(input, '3', '7'), + scan_chars!(input, '3', '6'), + scan_chars!(input, '3', '5'), + scan_chars!(input, '3', '4'), + scan_chars!(input, '3', '3'), + scan_chars!(input, '3', '1'), + scan_chars!(input, '3', '0'), + scan_chars!(input, '3'), + scan_chars!(input, '2', '9'), + scan_chars!(input, '2', '8'), + scan_chars!(input, '2', '7'), + scan_chars!(input, '2', '6'), + scan_chars!(input, '2', '5'), + scan_chars!(input, '2', '3'), + scan_chars!(input, '2', '2'), + scan_chars!(input, '2', '1'), + scan_chars!(input, '2', '0'), + scan_chars!(input, '2'), + scan_chars!(input, '1', '9'), + scan_chars!(input, '1', '8'), + scan_chars!(input, '1', '7'), + scan_chars!(input, '1', '5'), + scan_chars!(input, '1', '4'), + scan_chars!(input, '1', '3'), + scan_chars!(input, '1', '2'), + scan_chars!(input, '1', '1'), + scan_chars!(input, '1', '0'), + scan_chars!(input, '1'), + scan_chars!(input, '0') + ) + ) + } else { + false + } + ) + } + + #[allow(unused_assignments, unused_parens)] + fn yul_uint_keyword(&self, input: &mut ParserContext) -> bool { + if !self.version_is_at_least_0_7_1 { + scan_sequence!( + scan_chars!(input, 'u', 'i', 'n', 't'), + scan_optional!( + input, + scan_choice!( + input, + scan_chars!(input, '9', '6'), + scan_chars!(input, '8', '8'), + scan_chars!(input, '8', '0'), + scan_chars!(input, '8'), + scan_chars!(input, '7', '2'), + scan_chars!(input, '6', '4'), + scan_chars!(input, '5', '6'), + scan_chars!(input, '4', '8'), + scan_chars!(input, '4', '0'), + scan_chars!(input, '3', '2'), + scan_chars!(input, '2', '5', '6'), + scan_chars!(input, '2', '4', '8'), + scan_chars!(input, '2', '4', '0'), + scan_chars!(input, '2', '4'), + scan_chars!(input, '2', '3', '2'), + scan_chars!(input, '2', '2', '4'), + scan_chars!(input, '2', '1', '6'), + scan_chars!(input, '2', '0', '8'), + scan_chars!(input, '2', '0', '0'), + scan_chars!(input, '1', '9', '2'), + scan_chars!(input, '1', '8', '4'), + scan_chars!(input, '1', '7', '6'), + scan_chars!(input, '1', '6', '8'), + scan_chars!(input, '1', '6', '0'), + scan_chars!(input, '1', '6'), + scan_chars!(input, '1', '5', '2'), + scan_chars!(input, '1', '4', '4'), + scan_chars!(input, '1', '3', '6'), + scan_chars!(input, '1', '2', '8'), + scan_chars!(input, '1', '2', '0'), + scan_chars!(input, '1', '1', '2'), + scan_chars!(input, '1', '0', '4') + ) + ) + ) + } else { + false + } + } + pub fn scan(&self, lexical_context: LexicalContext, input: &str) -> Option { let mut input = ParserContext::new(input); match lexical_context { LexicalContext::Default => { Lexer::next_token::(self, &mut input) } - LexicalContext::VersionPragma => { - Lexer::next_token::(self, &mut input) - } - LexicalContext::YulBlock => { - Lexer::next_token::(self, &mut input) + LexicalContext::Pragma => { + Lexer::next_token::(self, &mut input) } + LexicalContext::Yul => Lexer::next_token::(self, &mut input), } } @@ -5957,7 +7611,6 @@ impl Language { 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), @@ -5986,6 +7639,7 @@ impl Language { } ProductionKind::DeleteStatement => Self::delete_statement.parse(self, input), ProductionKind::DoWhileStatement => Self::do_while_statement.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), @@ -6013,7 +7667,6 @@ impl Language { } ProductionKind::ForStatement => Self::for_statement.parse(self, input), ProductionKind::FunctionAttributes => Self::function_attributes.parse(self, input), - ProductionKind::FunctionCallOptions => Self::function_call_options.parse(self, input), ProductionKind::FunctionDefinition => Self::function_definition.parse(self, input), ProductionKind::FunctionType => Self::function_type.parse(self, input), ProductionKind::FunctionTypeAttributes => { @@ -6023,6 +7676,7 @@ impl Language { 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::ImportDeconstruction => Self::import_deconstruction.parse(self, input), ProductionKind::ImportDeconstructionSymbol => { Self::import_deconstruction_symbol.parse(self, input) @@ -6031,6 +7685,7 @@ impl Language { 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), @@ -6039,13 +7694,15 @@ impl Language { 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::MappingKeyType => Self::mapping_key_type.parse(self, input), + ProductionKind::MappingKey => Self::mapping_key.parse(self, input), ProductionKind::MappingType => Self::mapping_type.parse(self, input), - ProductionKind::MappingValueType => Self::mapping_value_type.parse(self, input), + ProductionKind::MappingValue => Self::mapping_value.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 => { Self::named_arguments_declaration.parse(self, input) @@ -6053,6 +7710,9 @@ impl Language { ProductionKind::NamedImport => Self::named_import.parse(self, input), ProductionKind::NewExpression => Self::new_expression.parse(self, input), ProductionKind::OverridePaths => Self::override_paths.parse(self, input), + ProductionKind::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), @@ -6061,6 +7721,9 @@ impl Language { } ProductionKind::PathImport => Self::path_import.parse(self, input), ProductionKind::PositionalArguments => Self::positional_arguments.parse(self, input), + ProductionKind::PositionalArgumentsDeclaration => { + Self::positional_arguments_declaration.parse(self, input) + } ProductionKind::PragmaDirective => Self::pragma_directive.parse(self, input), ProductionKind::ReceiveFunctionAttributes => { Self::receive_function_attributes.parse(self, input) @@ -6079,6 +7742,9 @@ impl Language { ProductionKind::StateVariableDefinition => { Self::state_variable_definition.parse(self, input) } + ProductionKind::StateVariableDefinitionValue => { + Self::state_variable_definition_value.parse(self, input) + } ProductionKind::Statements => Self::statements.parse(self, input), ProductionKind::StructDefinition => Self::struct_definition.parse(self, input), ProductionKind::StructMember => Self::struct_member.parse(self, input), @@ -6096,6 +7762,7 @@ impl Language { Self::tuple_deconstruction_statement.parse(self, input) } ProductionKind::TupleExpression => Self::tuple_expression.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), @@ -6114,6 +7781,7 @@ impl Language { ProductionKind::UserDefinedValueTypeDefinition => { Self::user_defined_value_type_definition.parse(self, input) } + ProductionKind::UsingAlias => Self::using_alias.parse(self, input), ProductionKind::UsingDeconstruction => Self::using_deconstruction.parse(self, input), ProductionKind::UsingDeconstructionSymbol => { Self::using_deconstruction_symbol.parse(self, input) @@ -6122,10 +7790,12 @@ impl Language { Self::using_deconstruction_symbols.parse(self, input) } ProductionKind::UsingDirective => Self::using_directive.parse(self, input), - ProductionKind::VariableDeclaration => Self::variable_declaration.parse(self, input), ProductionKind::VariableDeclarationStatement => { Self::variable_declaration_statement.parse(self, input) } + ProductionKind::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) @@ -6144,9 +7814,7 @@ impl Language { 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::YulDeclarationStatement => { - Self::yul_declaration_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 => { @@ -6154,19 +7822,26 @@ impl Language { } ProductionKind::YulIdentifierPath => Self::yul_identifier_path.parse(self, input), ProductionKind::YulIdentifierPaths => Self::yul_identifier_paths.parse(self, input), - ProductionKind::YulIdentifiers => Self::yul_identifiers.parse(self, input), ProductionKind::YulIfStatement => Self::yul_if_statement.parse(self, input), ProductionKind::YulLeaveStatement => Self::yul_leave_statement.parse(self, input), + ProductionKind::YulParameters => Self::yul_parameters.parse(self, input), ProductionKind::YulParametersDeclaration => { Self::yul_parameters_declaration.parse(self, input) } + ProductionKind::YulReturnVariables => Self::yul_return_variables.parse(self, input), ProductionKind::YulReturnsDeclaration => { Self::yul_returns_declaration.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 => { + Self::yul_variable_declaration_statement.parse(self, input) + } + ProductionKind::YulVariableDeclarationValue => { + Self::yul_variable_declaration_value.parse(self, input) + } } } } @@ -6187,8 +7862,8 @@ impl Lexer for Language { (TokenKind::OpenBracket, TokenKind::CloseBracket), (TokenKind::OpenParen, TokenKind::CloseParen), ], - LexicalContext::VersionPragma => &[], - LexicalContext::YulBlock => &[ + LexicalContext::Pragma => &[], + LexicalContext::Yul => &[ (TokenKind::OpenBrace, TokenKind::CloseBrace), (TokenKind::OpenParen, TokenKind::CloseParen), ], @@ -6216,17 +7891,8 @@ impl Lexer for Language { if let Some(kind) = match input.next() { Some('a') => match input.next() { - Some('b') => match input.next() { - Some('i') => scan_chars!(input, 'c', 'o', 'd', 'e', 'r') - .then_some(TokenKind::AbicoderKeyword), - Some('s') => scan_chars!(input, 't', 'r', 'a', 'c', 't') - .then_some(TokenKind::AbstractKeyword), - Some(_) => { - input.undo(); - None - } - None => None, - }, + Some('b') => scan_chars!(input, 's', 't', 'r', 'a', 'c', 't') + .then_some(TokenKind::AbstractKeyword), Some('d') => scan_chars!(input, 'd', 'r', 'e', 's', 's') .then_some(TokenKind::AddressKeyword), Some('f') => { @@ -6287,7 +7953,7 @@ impl Lexer for Language { Some('l') => { if self.version_is_at_least_0_5_0 { scan_chars!(input, 'l', 'd', 'a', 't', 'a') - .then_some(TokenKind::CalldataKeyword) + .then_some(TokenKind::CallDataKeyword) } else { None } @@ -6347,7 +8013,7 @@ impl Lexer for Language { Some('p') => { if self.version_is_at_least_0_5_0 { scan_chars!(input, 'y', 'o', 'f') - .then_some(TokenKind::CopyofKeyword) + .then_some(TokenKind::CopyOfKeyword) } else { None } @@ -6422,19 +8088,8 @@ impl Lexer for Language { Some('v') => { scan_chars!(input, 'e', 'n', 't').then_some(TokenKind::EventKeyword) } - Some('x') => match input.next() { - Some('p') => { - scan_chars!(input, 'e', 'r', 'i', 'm', 'e', 'n', 't', 'a', 'l') - .then_some(TokenKind::ExperimentalKeyword) - } - Some('t') => scan_chars!(input, 'e', 'r', 'n', 'a', 'l') - .then_some(TokenKind::ExternalKeyword), - Some(_) => { - input.undo(); - None - } - None => None, - }, + Some('x') => scan_chars!(input, 't', 'e', 'r', 'n', 'a', 'l') + .then_some(TokenKind::ExternalKeyword), Some(_) => { input.undo(); None @@ -6604,21 +8259,7 @@ impl Lexer for Language { None => None, }, Some('l') => match input.next() { - Some('e') => match input.next() { - Some('a') => { - if self.version_is_at_least_0_6_0 { - scan_chars!(input, 'v', 'e').then_some(TokenKind::LeaveKeyword) - } else { - None - } - } - Some('t') => Some(TokenKind::LetKeyword), - Some(_) => { - input.undo(); - None - } - None => None, - }, + Some('e') => scan_chars!(input, 't').then_some(TokenKind::LetKeyword), Some('i') => scan_chars!(input, 'b', 'r', 'a', 'r', 'y') .then_some(TokenKind::LibraryKeyword), Some(_) => { @@ -6821,13 +8462,11 @@ impl Lexer for Language { Some('i') => { if self.version_is_at_least_0_5_0 { scan_chars!(input, 'z', 'e', 'o', 'f') - .then_some(TokenKind::SizeofKeyword) + .then_some(TokenKind::SizeOfKeyword) } else { None } } - Some('o') => scan_chars!(input, 'l', 'i', 'd', 'i', 't', 'y') - .then_some(TokenKind::SolidityKeyword), Some('t') => { match input.next() { Some('a') => scan_chars!(input, 't', 'i', 'c') @@ -6894,13 +8533,13 @@ impl Lexer for Language { Some('d') => { if self.version_is_at_least_0_5_0 { scan_chars!(input, 'e', 'f') - .then_some(TokenKind::TypedefKeyword) + .then_some(TokenKind::TypeDefKeyword) } else { None } } Some('o') => { - scan_chars!(input, 'f').then_some(TokenKind::TypeofKeyword) + scan_chars!(input, 'f').then_some(TokenKind::TypeOfKeyword) } Some(_) => { input.undo(); @@ -6999,30 +8638,16 @@ impl Lexer for Language { input.set_position(save); if let Some(kind) = match input.next() { - Some('!') => match input.next() { - Some('=') => Some(TokenKind::BangEqual), - Some(_) => { - input.undo(); - Some(TokenKind::Bang) - } - None => Some(TokenKind::Bang), - }, - Some('%') => match input.next() { - Some('=') => Some(TokenKind::PercentEqual), - Some(_) => { - input.undo(); - Some(TokenKind::Percent) - } - None => Some(TokenKind::Percent), - }, + Some('!') => scan_chars!(input, '=').then_some(TokenKind::BangEqual), + Some('%') => scan_chars!(input, '=').then_some(TokenKind::PercentEqual), Some('&') => match input.next() { Some('&') => Some(TokenKind::AmpersandAmpersand), Some('=') => Some(TokenKind::AmpersandEqual), Some(_) => { input.undo(); - Some(TokenKind::Ampersand) + None } - None => Some(TokenKind::Ampersand), + None => None, }, Some('(') => Some(TokenKind::OpenParen), Some(')') => Some(TokenKind::CloseParen), @@ -7031,18 +8656,18 @@ impl Lexer for Language { Some('=') => Some(TokenKind::AsteriskEqual), Some(_) => { input.undo(); - Some(TokenKind::Asterisk) + None } - None => Some(TokenKind::Asterisk), + None => None, }, Some('+') => match input.next() { Some('+') => Some(TokenKind::PlusPlus), Some('=') => Some(TokenKind::PlusEqual), Some(_) => { input.undo(); - Some(TokenKind::Plus) + None } - None => Some(TokenKind::Plus), + None => None, }, Some(',') => Some(TokenKind::Comma), Some('-') => match input.next() { @@ -7050,92 +8675,64 @@ impl Lexer for Language { Some('=') => Some(TokenKind::MinusEqual), Some(_) => { input.undo(); - Some(TokenKind::Minus) + None } - None => Some(TokenKind::Minus), + None => None, }, Some('.') => Some(TokenKind::Period), - Some('/') => match input.next() { - Some('=') => Some(TokenKind::SlashEqual), - Some(_) => { - input.undo(); - Some(TokenKind::Slash) - } - None => Some(TokenKind::Slash), - }, - Some(':') => Some(TokenKind::Colon), + Some('/') => scan_chars!(input, '=').then_some(TokenKind::SlashEqual), Some(';') => Some(TokenKind::Semicolon), Some('<') => match input.next() { - Some('<') => match input.next() { - Some('=') => Some(TokenKind::LessThanLessThanEqual), - Some(_) => { - input.undo(); - Some(TokenKind::LessThanLessThan) - } - None => Some(TokenKind::LessThanLessThan), - }, + Some('<') => { + scan_chars!(input, '=').then_some(TokenKind::LessThanLessThanEqual) + } Some('=') => Some(TokenKind::LessThanEqual), Some(_) => { input.undo(); - Some(TokenKind::LessThan) + None } - None => Some(TokenKind::LessThan), + None => None, }, Some('=') => match input.next() { Some('=') => Some(TokenKind::EqualEqual), Some('>') => Some(TokenKind::EqualGreaterThan), Some(_) => { input.undo(); - Some(TokenKind::Equal) + None } - None => Some(TokenKind::Equal), + None => None, }, Some('>') => match input.next() { Some('=') => Some(TokenKind::GreaterThanEqual), Some('>') => match input.next() { Some('=') => Some(TokenKind::GreaterThanGreaterThanEqual), - Some('>') => match input.next() { - Some('=') => { - Some(TokenKind::GreaterThanGreaterThanGreaterThanEqual) - } - Some(_) => { - input.undo(); - Some(TokenKind::GreaterThanGreaterThanGreaterThan) - } - None => Some(TokenKind::GreaterThanGreaterThanGreaterThan), - }, + Some('>') => scan_chars!(input, '=') + .then_some(TokenKind::GreaterThanGreaterThanGreaterThanEqual), Some(_) => { input.undo(); - Some(TokenKind::GreaterThanGreaterThan) + None } - None => Some(TokenKind::GreaterThanGreaterThan), + None => None, }, Some(_) => { input.undo(); - Some(TokenKind::GreaterThan) + None } - None => Some(TokenKind::GreaterThan), + None => None, }, Some('?') => Some(TokenKind::QuestionMark), Some('[') => Some(TokenKind::OpenBracket), Some(']') => Some(TokenKind::CloseBracket), - Some('^') => match input.next() { - Some('=') => Some(TokenKind::CaretEqual), - Some(_) => { - input.undo(); - Some(TokenKind::Caret) - } - None => Some(TokenKind::Caret), - }, + Some('^') => scan_chars!(input, '=').then_some(TokenKind::CaretEqual), Some('{') => Some(TokenKind::OpenBrace), Some('|') => match input.next() { Some('=') => Some(TokenKind::BarEqual), Some('|') => Some(TokenKind::BarBar), Some(_) => { input.undo(); - Some(TokenKind::Bar) + None } - None => Some(TokenKind::Bar), + None => None, }, Some('}') => Some(TokenKind::CloseBrace), Some('~') => Some(TokenKind::Tilde), @@ -7151,16 +8748,32 @@ impl Lexer for Language { input.set_position(save); longest_match! { + { Ampersand = ampersand } { AsciiStringLiteral = ascii_string_literal } + { Asterisk = asterisk } + { Bang = bang } + { Bar = bar } { BytesKeyword = bytes_keyword } + { Caret = caret } + { Colon = colon } { DecimalLiteral = decimal_literal } { EndOfLine = end_of_line } + { Equal = equal } { FixedKeyword = fixed_keyword } + { GreaterThan = greater_than } + { GreaterThanGreaterThan = greater_than_greater_than } + { GreaterThanGreaterThanGreaterThan = greater_than_greater_than_greater_than } { HexLiteral = hex_literal } { HexStringLiteral = hex_string_literal } { IntKeyword = int_keyword } + { LessThan = less_than } + { LessThanLessThan = less_than_less_than } + { Minus = minus } { MultilineComment = multiline_comment } + { Percent = percent } + { Plus = plus } { SingleLineComment = single_line_comment } + { Slash = slash } { UfixedKeyword = ufixed_keyword } { UintKeyword = uint_keyword } { UnicodeStringLiteral = unicode_string_literal } @@ -7168,7 +8781,7 @@ impl Lexer for Language { { Identifier = identifier } } } - LexicalContext::VersionPragma => { + LexicalContext::Pragma => { macro_rules! longest_match { ($( { $kind:ident = $function:ident } )*) => { $( @@ -7181,9 +8794,23 @@ impl Lexer for Language { }; } - if let Some(kind) = scan_chars!(input, 's', 'o', 'l', 'i', 'd', 'i', 't', 'y') - .then_some(TokenKind::SolidityKeyword) - { + if let Some(kind) = match input.next() { + Some('a') => scan_chars!(input, 'b', 'i', 'c', 'o', 'd', 'e', 'r') + .then_some(TokenKind::AbicoderKeyword), + Some('e') => { + scan_chars!(input, 'x', 'p', 'e', 'r', 'i', 'm', 'e', 'n', 't', 'a', 'l') + .then_some(TokenKind::ExperimentalKeyword) + } + Some('p') => scan_chars!(input, 'r', 'a', 'g', 'm', 'a') + .then_some(TokenKind::PragmaKeyword), + Some('s') => scan_chars!(input, 'o', 'l', 'i', 'd', 'i', 't', 'y') + .then_some(TokenKind::SolidityKeyword), + Some(_) => { + input.undo(); + None + } + None => None, + } { // Make sure that this is not the start of an identifier if !self.identifier_part(input) { furthest_position = input.position(); @@ -7193,26 +8820,10 @@ impl Lexer for Language { input.set_position(save); if let Some(kind) = match input.next() { - Some('-') => Some(TokenKind::Minus), Some('.') => Some(TokenKind::Period), - Some('<') => match input.next() { - Some('=') => Some(TokenKind::LessThanEqual), - Some(_) => { - input.undo(); - Some(TokenKind::LessThan) - } - None => Some(TokenKind::LessThan), - }, - Some('=') => Some(TokenKind::Equal), - Some('>') => match input.next() { - Some('=') => Some(TokenKind::GreaterThanEqual), - Some(_) => { - input.undo(); - Some(TokenKind::GreaterThan) - } - None => Some(TokenKind::GreaterThan), - }, - Some('^') => Some(TokenKind::Caret), + Some(';') => Some(TokenKind::Semicolon), + Some('<') => scan_chars!(input, '=').then_some(TokenKind::LessThanEqual), + Some('>') => scan_chars!(input, '=').then_some(TokenKind::GreaterThanEqual), Some('|') => scan_chars!(input, '|').then_some(TokenKind::BarBar), Some('~') => Some(TokenKind::Tilde), Some(_) => { @@ -7227,10 +8838,17 @@ impl Lexer for Language { input.set_position(save); longest_match! { + { AsciiStringLiteral = ascii_string_literal } + { Caret = caret } + { Equal = equal } + { GreaterThan = greater_than } + { LessThan = less_than } + { Minus = minus } { VersionPragmaValue = version_pragma_value } + { Identifier = identifier } } } - LexicalContext::YulBlock => { + LexicalContext::Yul => { macro_rules! longest_match { ($( { $kind:ident = $function:ident } )*) => { $( @@ -7244,62 +8862,1097 @@ impl Lexer for Language { } if let Some(kind) = match input.next() { - Some('b') => { - scan_chars!(input, 'r', 'e', 'a', 'k').then_some(TokenKind::BreakKeyword) - } - Some('c') => match input.next() { - Some('a') => scan_chars!(input, 's', 'e').then_some(TokenKind::CaseKeyword), - Some('o') => scan_chars!(input, 'n', 't', 'i', 'n', 'u', 'e') - .then_some(TokenKind::ContinueKeyword), + Some('a') => match input.next() { + Some('b') => { + if !self.version_is_at_least_0_7_1 { + scan_chars!(input, 's', 't', 'r', 'a', 'c', 't') + .then_some(TokenKind::YulAbstractKeyword) + } else { + None + } + } + Some('d') => scan_chars!(input, 'd', 'r', 'e', 's', 's') + .then_some(TokenKind::YulAddressKeyword), + Some('f') => { + if !self.version_is_at_least_0_7_1 { + scan_chars!(input, 't', 'e', 'r') + .then_some(TokenKind::YulAfterKeyword) + } else { + None + } + } + Some('l') => { + if self.version_is_at_least_0_5_0 && !self.version_is_at_least_0_7_1 { + scan_chars!(input, 'i', 'a', 's') + .then_some(TokenKind::YulAliasKeyword) + } else { + None + } + } + Some('n') => { + if !self.version_is_at_least_0_7_1 { + scan_chars!(input, 'o', 'n', 'y', 'm', 'o', 'u', 's') + .then_some(TokenKind::YulAnonymousKeyword) + } else { + None + } + } + Some('p') => { + if self.version_is_at_least_0_5_0 && !self.version_is_at_least_0_7_1 { + scan_chars!(input, 'p', 'l', 'y') + .then_some(TokenKind::YulApplyKeyword) + } else { + None + } + } + Some('s') => match input.next() { + Some('s') => { + if !self.version_is_at_least_0_7_1 { + scan_chars!(input, 'e', 'm', 'b', 'l', 'y') + .then_some(TokenKind::YulAssemblyKeyword) + } else { + None + } + } + Some(_) => { + input.undo(); + if !self.version_is_at_least_0_7_1 { + Some(TokenKind::YulAsKeyword) + } else { + None + } + } + None => { + if !self.version_is_at_least_0_7_1 { + Some(TokenKind::YulAsKeyword) + } else { + None + } + } + }, + Some('u') => { + if self.version_is_at_least_0_5_0 && !self.version_is_at_least_0_7_1 { + scan_chars!(input, 't', 'o').then_some(TokenKind::YulAutoKeyword) + } else { + None + } + } Some(_) => { input.undo(); None } None => None, }, - Some('d') => scan_chars!(input, 'e', 'f', 'a', 'u', 'l', 't') - .then_some(TokenKind::DefaultKeyword), - Some('f') => match input.next() { - Some('a') => { - scan_chars!(input, 'l', 's', 'e').then_some(TokenKind::FalseKeyword) + Some('b') => match input.next() { + Some('o') => { + if !self.version_is_at_least_0_5_10 { + scan_chars!(input, 'o', 'l').then_some(TokenKind::YulBoolKeyword) + } else { + None + } + } + Some('r') => { + scan_chars!(input, 'e', 'a', 'k').then_some(TokenKind::YulBreakKeyword) + } + Some('y') => { + scan_chars!(input, 't', 'e').then_some(TokenKind::YulByteKeyword) } - Some('o') => scan_chars!(input, 'r').then_some(TokenKind::ForKeyword), - Some('u') => scan_chars!(input, 'n', 'c', 't', 'i', 'o', 'n') - .then_some(TokenKind::FunctionKeyword), Some(_) => { input.undo(); None } None => None, }, - Some('h') => scan_chars!(input, 'e', 'x').then_some(TokenKind::HexKeyword), - Some('i') => scan_chars!(input, 'f').then_some(TokenKind::IfKeyword), - Some('l') => { - if scan_chars!(input, 'e') { - match input.next() { - Some('a') => { - if self.version_is_at_least_0_6_0 { - scan_chars!(input, 'v', 'e') - .then_some(TokenKind::LeaveKeyword) + Some('c') => match input.next() { + Some('a') => match input.next() { + Some('l') => { + if self.version_is_at_least_0_5_0 && !self.version_is_at_least_0_7_1 + { + scan_chars!(input, 'l', 'd', 'a', 't', 'a') + .then_some(TokenKind::YulCallDataKeyword) + } else { + None + } + } + Some('s') => { + scan_chars!(input, 'e').then_some(TokenKind::YulCaseKeyword) + } + Some('t') => { + if !self.version_is_at_least_0_7_1 { + scan_chars!(input, 'c', 'h') + .then_some(TokenKind::YulCatchKeyword) + } else { + None + } + } + Some(_) => { + input.undo(); + None + } + None => None, + }, + Some('o') => match input.next() { + Some('n') => match input.next() { + Some('s') => { + if scan_chars!(input, 't') { + match input.next() { + Some('a') => { + if !self.version_is_at_least_0_7_1 { + scan_chars!(input, 'n', 't') + .then_some(TokenKind::YulConstantKeyword) + } else { + None + } + } + Some('r') => { + if self.version_is_at_least_0_5_0 + && !self.version_is_at_least_0_7_1 + { + scan_chars!(input, 'u', 'c', 't', 'o', 'r') + .then_some(TokenKind::YulConstructorKeyword) + } else { + None + } + } + Some(_) => { + input.undo(); + None + } + None => None, + } + } else { + None + } + } + Some('t') => match input.next() { + Some('i') => scan_chars!(input, 'n', 'u', 'e') + .then_some(TokenKind::YulContinueKeyword), + Some('r') => { + if !self.version_is_at_least_0_7_1 { + scan_chars!(input, 'a', 'c', 't') + .then_some(TokenKind::YulContractKeyword) + } else { + None + } + } + Some(_) => { + input.undo(); + None + } + None => None, + }, + Some(_) => { + input.undo(); + None + } + None => None, + }, + Some('p') => { + if self.version_is_at_least_0_5_0 && !self.version_is_at_least_0_7_1 + { + scan_chars!(input, 'y', 'o', 'f') + .then_some(TokenKind::YulCopyOfKeyword) + } else { + None + } + } + Some(_) => { + input.undo(); + None + } + None => None, + }, + Some(_) => { + input.undo(); + None + } + None => None, + }, + Some('d') => match input.next() { + Some('a') => { + if !self.version_is_at_least_0_7_1 { + scan_chars!(input, 'y', 's').then_some(TokenKind::YulDaysKeyword) + } else { + None + } + } + Some('e') => match input.next() { + Some('f') => match input.next() { + Some('a') => scan_chars!(input, 'u', 'l', 't') + .then_some(TokenKind::YulDefaultKeyword), + Some('i') => { + if self.version_is_at_least_0_5_0 + && !self.version_is_at_least_0_7_1 + { + scan_chars!(input, 'n', 'e') + .then_some(TokenKind::YulDefineKeyword) } else { None } } - Some('t') => Some(TokenKind::LetKeyword), Some(_) => { input.undo(); None } None => None, + }, + Some('l') => { + if !self.version_is_at_least_0_7_1 { + scan_chars!(input, 'e', 't', 'e') + .then_some(TokenKind::YulDeleteKeyword) + } else { + None + } } - } else { + Some(_) => { + input.undo(); + None + } + None => None, + }, + Some('o') => { + if !self.version_is_at_least_0_7_1 { + Some(TokenKind::YulDoKeyword) + } else { + None + } + } + Some(_) => { + input.undo(); + None + } + None => None, + }, + Some('e') => match input.next() { + Some('l') => { + if !self.version_is_at_least_0_7_1 { + scan_chars!(input, 's', 'e').then_some(TokenKind::YulElseKeyword) + } else { + None + } + } + Some('m') => { + if self.version_is_at_least_0_5_0 && !self.version_is_at_least_0_7_1 { + scan_chars!(input, 'i', 't').then_some(TokenKind::YulEmitKeyword) + } else { + None + } + } + Some('n') => { + if !self.version_is_at_least_0_7_1 { + scan_chars!(input, 'u', 'm').then_some(TokenKind::YulEnumKeyword) + } else { + None + } + } + Some('t') => { + if !self.version_is_at_least_0_7_1 { + scan_chars!(input, 'h', 'e', 'r') + .then_some(TokenKind::YulEtherKeyword) + } else { + None + } + } + Some('v') => { + if !self.version_is_at_least_0_7_1 { + scan_chars!(input, 'e', 'n', 't') + .then_some(TokenKind::YulEventKeyword) + } else { + None + } + } + Some('x') => { + if !self.version_is_at_least_0_7_1 { + scan_chars!(input, 't', 'e', 'r', 'n', 'a', 'l') + .then_some(TokenKind::YulExternalKeyword) + } else { + None + } + } + Some(_) => { + input.undo(); + None + } + None => None, + }, + Some('f') => match input.next() { + Some('a') => { + if scan_chars!(input, 'l') { + match input.next() { + Some('l') => { + if self.version_is_at_least_0_6_0 + && !self.version_is_at_least_0_7_1 + { + scan_chars!(input, 'b', 'a', 'c', 'k') + .then_some(TokenKind::YulFallbackKeyword) + } else { + None + } + } + Some('s') => scan_chars!(input, 'e') + .then_some(TokenKind::YulFalseKeyword), + Some(_) => { + input.undo(); + None + } + None => None, + } + } else { + None + } + } + Some('i') => { + if scan_chars!(input, 'n') { + match input.next() { + Some('a') => { + if !self.version_is_at_least_0_7_1 { + scan_chars!(input, 'l') + .then_some(TokenKind::YulFinalKeyword) + } else { + None + } + } + Some('n') => { + if !self.version_is_at_least_0_7_0 { + scan_chars!(input, 'e', 'y') + .then_some(TokenKind::YulFinneyKeyword) + } else { + None + } + } + Some(_) => { + input.undo(); + None + } + None => None, + } + } else { + None + } + } + Some('o') => scan_chars!(input, 'r').then_some(TokenKind::YulForKeyword), + Some('u') => scan_chars!(input, 'n', 'c', 't', 'i', 'o', 'n') + .then_some(TokenKind::YulFunctionKeyword), + Some(_) => { + input.undo(); + None + } + None => None, + }, + Some('g') => { + if self.version_is_at_least_0_7_0 && !self.version_is_at_least_0_7_1 { + scan_chars!(input, 'w', 'e', 'i').then_some(TokenKind::YulGweiKeyword) + } else { + None + } + } + Some('h') => match input.next() { + Some('e') => scan_chars!(input, 'x').then_some(TokenKind::YulHexKeyword), + Some('o') => { + if !self.version_is_at_least_0_7_1 { + scan_chars!(input, 'u', 'r', 's') + .then_some(TokenKind::YulHoursKeyword) + } else { + None + } + } + Some(_) => { + input.undo(); + None + } + None => None, + }, + Some('i') => match input.next() { + Some('f') => Some(TokenKind::YulIfKeyword), + Some('m') => match input.next() { + Some('m') => { + if self.version_is_at_least_0_5_0 && !self.version_is_at_least_0_7_1 + { + scan_chars!(input, 'u', 't', 'a', 'b', 'l', 'e') + .then_some(TokenKind::YulImmutableKeyword) + } else { + None + } + } + Some('p') => match input.next() { + Some('l') => { + if self.version_is_at_least_0_5_0 + && !self.version_is_at_least_0_7_1 + { + scan_chars!(input, 'e', 'm', 'e', 'n', 't', 's') + .then_some(TokenKind::YulImplementsKeyword) + } else { + None + } + } + Some('o') => { + if !self.version_is_at_least_0_7_1 { + scan_chars!(input, 'r', 't') + .then_some(TokenKind::YulImportKeyword) + } else { + None + } + } + Some(_) => { + input.undo(); + None + } + None => None, + }, + Some(_) => { + input.undo(); + None + } + None => None, + }, + Some('n') => match input.next() { + Some('d') => { + if !self.version_is_at_least_0_7_1 { + scan_chars!(input, 'e', 'x', 'e', 'd') + .then_some(TokenKind::YulIndexedKeyword) + } else { + None + } + } + Some('l') => { + if !self.version_is_at_least_0_7_1 { + scan_chars!(input, 'i', 'n', 'e') + .then_some(TokenKind::YulInlineKeyword) + } else { + None + } + } + Some('t') => { + if scan_chars!(input, 'e', 'r') { + match input.next() { + Some('f') => { + if !self.version_is_at_least_0_7_1 { + scan_chars!(input, 'a', 'c', 'e') + .then_some(TokenKind::YulInterfaceKeyword) + } else { + None + } + } + Some('n') => { + if !self.version_is_at_least_0_7_1 { + scan_chars!(input, 'a', 'l') + .then_some(TokenKind::YulInternalKeyword) + } else { + None + } + } + Some(_) => { + input.undo(); + None + } + None => None, + } + } else { + None + } + } + Some(_) => { + input.undo(); + if !self.version_is_at_least_0_6_8 { + Some(TokenKind::YulInKeyword) + } else { + None + } + } + None => { + if !self.version_is_at_least_0_6_8 { + Some(TokenKind::YulInKeyword) + } else { + None + } + } + }, + Some('s') => { + if !self.version_is_at_least_0_7_1 { + Some(TokenKind::YulIsKeyword) + } else { + None + } + } + Some(_) => { + input.undo(); + None + } + None => None, + }, + Some('l') => match input.next() { + Some('e') => match input.next() { + Some('a') => { + if self.version_is_at_least_0_6_0 { + scan_chars!(input, 'v', 'e') + .then_some(TokenKind::YulLeaveKeyword) + } else { + None + } + } + Some('t') => Some(TokenKind::YulLetKeyword), + Some(_) => { + input.undo(); + None + } + None => None, + }, + Some('i') => { + if !self.version_is_at_least_0_7_1 { + scan_chars!(input, 'b', 'r', 'a', 'r', 'y') + .then_some(TokenKind::YulLibraryKeyword) + } else { + None + } + } + Some(_) => { + input.undo(); + None + } + None => None, + }, + Some('m') => match input.next() { + Some('a') => match input.next() { + Some('c') => { + if self.version_is_at_least_0_5_0 && !self.version_is_at_least_0_7_1 + { + scan_chars!(input, 'r', 'o') + .then_some(TokenKind::YulMacroKeyword) + } else { + None + } + } + Some('p') => { + if !self.version_is_at_least_0_7_1 { + scan_chars!(input, 'p', 'i', 'n', 'g') + .then_some(TokenKind::YulMappingKeyword) + } else { + None + } + } + Some('t') => { + if !self.version_is_at_least_0_7_1 { + scan_chars!(input, 'c', 'h') + .then_some(TokenKind::YulMatchKeyword) + } else { + None + } + } + Some(_) => { + input.undo(); + None + } + None => None, + }, + Some('e') => { + if !self.version_is_at_least_0_7_1 { + scan_chars!(input, 'm', 'o', 'r', 'y') + .then_some(TokenKind::YulMemoryKeyword) + } else { + None + } + } + Some('i') => { + if !self.version_is_at_least_0_7_1 { + scan_chars!(input, 'n', 'u', 't', 'e', 's') + .then_some(TokenKind::YulMinutesKeyword) + } else { + None + } + } + Some('o') => { + if !self.version_is_at_least_0_7_1 { + scan_chars!(input, 'd', 'i', 'f', 'i', 'e', 'r') + .then_some(TokenKind::YulModifierKeyword) + } else { + None + } + } + Some('u') => { + if self.version_is_at_least_0_5_0 && !self.version_is_at_least_0_7_1 { + scan_chars!(input, 't', 'a', 'b', 'l', 'e') + .then_some(TokenKind::YulMutableKeyword) + } else { + None + } + } + Some(_) => { + input.undo(); + None + } + None => None, + }, + Some('n') => match input.next() { + Some('e') => { + if !self.version_is_at_least_0_7_1 { + scan_chars!(input, 'w').then_some(TokenKind::YulNewKeyword) + } else { + None + } + } + Some('u') => { + if !self.version_is_at_least_0_7_1 { + scan_chars!(input, 'l', 'l').then_some(TokenKind::YulNullKeyword) + } else { + None + } + } + Some(_) => { + input.undo(); + None + } + None => None, + }, + Some('o') => match input.next() { + Some('f') => { + if !self.version_is_at_least_0_7_1 { + Some(TokenKind::YulOfKeyword) + } else { + None + } + } + Some('v') => { + if self.version_is_at_least_0_5_0 && !self.version_is_at_least_0_7_1 { + scan_chars!(input, 'e', 'r', 'r', 'i', 'd', 'e') + .then_some(TokenKind::YulOverrideKeyword) + } else { + None + } + } + Some(_) => { + input.undo(); + None + } + None => None, + }, + Some('p') => match input.next() { + Some('a') => match input.next() { + Some('r') => { + if self.version_is_at_least_0_5_0 && !self.version_is_at_least_0_7_1 + { + scan_chars!(input, 't', 'i', 'a', 'l') + .then_some(TokenKind::YulPartialKeyword) + } else { + None + } + } + Some('y') => { + if !self.version_is_at_least_0_7_1 { + scan_chars!(input, 'a', 'b', 'l', 'e') + .then_some(TokenKind::YulPayableKeyword) + } else { + None + } + } + Some(_) => { + input.undo(); + None + } + None => None, + }, + Some('r') => match input.next() { + Some('a') => { + if !self.version_is_at_least_0_7_1 { + scan_chars!(input, 'g', 'm', 'a') + .then_some(TokenKind::YulPragmaKeyword) + } else { + None + } + } + Some('i') => { + if !self.version_is_at_least_0_7_1 { + scan_chars!(input, 'v', 'a', 't', 'e') + .then_some(TokenKind::YulPrivateKeyword) + } else { + None + } + } + Some('o') => { + if self.version_is_at_least_0_5_0 && !self.version_is_at_least_0_7_1 + { + scan_chars!(input, 'm', 'i', 's', 'e') + .then_some(TokenKind::YulPromiseKeyword) + } else { + None + } + } + Some(_) => { + input.undo(); + None + } + None => None, + }, + Some('u') => match input.next() { + Some('b') => { + if !self.version_is_at_least_0_7_1 { + scan_chars!(input, 'l', 'i', 'c') + .then_some(TokenKind::YulPublicKeyword) + } else { + None + } + } + Some('r') => { + if !self.version_is_at_least_0_7_1 { + scan_chars!(input, 'e').then_some(TokenKind::YulPureKeyword) + } else { + None + } + } + Some(_) => { + input.undo(); + None + } + None => None, + }, + Some(_) => { + input.undo(); + None + } + None => None, + }, + Some('r') => { + if scan_chars!(input, 'e') { + match input.next() { + Some('c') => { + if self.version_is_at_least_0_6_0 + && !self.version_is_at_least_0_7_1 + { + scan_chars!(input, 'e', 'i', 'v', 'e') + .then_some(TokenKind::YulReceiveKeyword) + } else { + None + } + } + Some('f') => { + if self.version_is_at_least_0_5_0 + && !self.version_is_at_least_0_7_1 + { + scan_chars!(input, 'e', 'r', 'e', 'n', 'c', 'e') + .then_some(TokenKind::YulReferenceKeyword) + } else { + None + } + } + Some('l') => { + if !self.version_is_at_least_0_7_1 { + scan_chars!(input, 'o', 'c', 'a', 't', 'a', 'b', 'l', 'e') + .then_some(TokenKind::YulRelocatableKeyword) + } else { + None + } + } + Some('t') => { + if scan_chars!(input, 'u', 'r', 'n') { + match input.next() { + Some('s') => { + if !self.version_is_at_least_0_7_1 { + Some(TokenKind::YulReturnsKeyword) + } else { + None + } + } + Some(_) => { + input.undo(); + Some(TokenKind::YulReturnKeyword) + } + None => Some(TokenKind::YulReturnKeyword), + } + } else { + None + } + } + Some('v') => scan_chars!(input, 'e', 'r', 't') + .then_some(TokenKind::YulRevertKeyword), + Some(_) => { + input.undo(); + None + } + None => None, + } + } else { + None + } + } + Some('s') => match input.next() { + Some('e') => match input.next() { + Some('a') => { + if self.version_is_at_least_0_5_0 && !self.version_is_at_least_0_7_1 + { + scan_chars!(input, 'l', 'e', 'd') + .then_some(TokenKind::YulSealedKeyword) + } else { + None + } + } + Some('c') => { + if !self.version_is_at_least_0_7_1 { + scan_chars!(input, 'o', 'n', 'd', 's') + .then_some(TokenKind::YulSecondsKeyword) + } else { + None + } + } + Some(_) => { + input.undo(); + None + } + None => None, + }, + Some('i') => { + if self.version_is_at_least_0_5_0 && !self.version_is_at_least_0_7_1 { + scan_chars!(input, 'z', 'e', 'o', 'f') + .then_some(TokenKind::YulSizeOfKeyword) + } else { + None + } + } + Some('t') => match input.next() { + Some('a') => { + if !self.version_is_at_least_0_7_1 { + scan_chars!(input, 't', 'i', 'c') + .then_some(TokenKind::YulStaticKeyword) + } else { + None + } + } + Some('o') => { + if !self.version_is_at_least_0_7_1 { + scan_chars!(input, 'r', 'a', 'g', 'e') + .then_some(TokenKind::YulStorageKeyword) + } else { + None + } + } + Some('r') => match input.next() { + Some('i') => { + if !self.version_is_at_least_0_7_1 { + scan_chars!(input, 'n', 'g') + .then_some(TokenKind::YulStringKeyword) + } else { + None + } + } + Some('u') => { + if !self.version_is_at_least_0_7_1 { + scan_chars!(input, 'c', 't') + .then_some(TokenKind::YulStructKeyword) + } else { + None + } + } + Some(_) => { + input.undo(); + None + } + None => None, + }, + Some(_) => { + input.undo(); + None + } + None => None, + }, + Some('u') => { + if self.version_is_at_least_0_5_0 && !self.version_is_at_least_0_7_1 { + scan_chars!(input, 'p', 'p', 'o', 'r', 't', 's') + .then_some(TokenKind::YulSupportsKeyword) + } else { + None + } + } + Some('w') => scan_chars!(input, 'i', 't', 'c', 'h') + .then_some(TokenKind::YulSwitchKeyword), + Some('z') => { + if !self.version_is_at_least_0_7_0 { + scan_chars!(input, 'a', 'b', 'o') + .then_some(TokenKind::YulSzaboKeyword) + } else { + None + } + } + Some(_) => { + input.undo(); + None + } + None => None, + }, + Some('t') => match input.next() { + Some('h') => { + if !self.version_is_at_least_0_7_1 { + scan_chars!(input, 'r', 'o', 'w') + .then_some(TokenKind::YulThrowKeyword) + } else { + None + } + } + Some('r') => match input.next() { + Some('u') => { + scan_chars!(input, 'e').then_some(TokenKind::YulTrueKeyword) + } + Some('y') => { + if !self.version_is_at_least_0_7_1 { + Some(TokenKind::YulTryKeyword) + } else { + None + } + } + Some(_) => { + input.undo(); + None + } + None => None, + }, + Some('y') => { + if scan_chars!(input, 'p', 'e') { + match input.next() { + Some('d') => { + if self.version_is_at_least_0_5_0 + && !self.version_is_at_least_0_7_1 + { + scan_chars!(input, 'e', 'f') + .then_some(TokenKind::YulTypeDefKeyword) + } else { + None + } + } + Some('o') => { + if !self.version_is_at_least_0_7_1 { + scan_chars!(input, 'f') + .then_some(TokenKind::YulTypeOfKeyword) + } else { + None + } + } + Some(_) => { + input.undo(); + if !self.version_is_at_least_0_7_1 { + Some(TokenKind::YulTypeKeyword) + } else { + None + } + } + None => { + if !self.version_is_at_least_0_7_1 { + Some(TokenKind::YulTypeKeyword) + } else { + None + } + } + } + } else { + None + } + } + Some(_) => { + input.undo(); + None + } + None => None, + }, + Some('u') => match input.next() { + Some('n') => { + if self.version_is_at_least_0_5_0 && !self.version_is_at_least_0_7_1 { + scan_chars!(input, 'c', 'h', 'e', 'c', 'k', 'e', 'd') + .then_some(TokenKind::YulUncheckedKeyword) + } else { + None + } + } + Some('s') => { + if !self.version_is_at_least_0_7_1 { + scan_chars!(input, 'i', 'n', 'g') + .then_some(TokenKind::YulUsingKeyword) + } else { + None + } + } + Some(_) => { + input.undo(); + None + } + None => None, + }, + Some('v') => match input.next() { + Some('a') => { + if !self.version_is_at_least_0_6_5 { + scan_chars!(input, 'r').then_some(TokenKind::YulVarKeyword) + } else { + None + } + } + Some('i') => match input.next() { + Some('e') => { + if !self.version_is_at_least_0_7_1 { + scan_chars!(input, 'w').then_some(TokenKind::YulViewKeyword) + } else { + None + } + } + Some('r') => { + if self.version_is_at_least_0_6_0 && !self.version_is_at_least_0_7_1 + { + scan_chars!(input, 't', 'u', 'a', 'l') + .then_some(TokenKind::YulVirtualKeyword) + } else { + None + } + } + Some(_) => { + input.undo(); + None + } + None => None, + }, + Some(_) => { + input.undo(); + None + } + None => None, + }, + Some('w') => match input.next() { + Some('e') => match input.next() { + Some('e') => { + if !self.version_is_at_least_0_7_1 { + scan_chars!(input, 'k', 's') + .then_some(TokenKind::YulWeeksKeyword) + } else { + None + } + } + Some('i') => { + if !self.version_is_at_least_0_7_1 { + Some(TokenKind::YulWeiKeyword) + } else { + None + } + } + Some(_) => { + input.undo(); + None + } + None => None, + }, + Some('h') => { + if !self.version_is_at_least_0_7_1 { + scan_chars!(input, 'i', 'l', 'e') + .then_some(TokenKind::YulWhileKeyword) + } else { + None + } + } + Some(_) => { + input.undo(); + None + } + None => None, + }, + Some('y') => { + if !self.version_is_at_least_0_7_1 { + scan_chars!(input, 'e', 'a', 'r', 's') + .then_some(TokenKind::YulYearsKeyword) + } else { None } - } - Some('s') => scan_chars!(input, 'w', 'i', 't', 'c', 'h') - .then_some(TokenKind::SwitchKeyword), - Some('t') => { - scan_chars!(input, 'r', 'u', 'e').then_some(TokenKind::TrueKeyword) } Some(_) => { input.undo(); @@ -7338,9 +9991,14 @@ impl Lexer for Language { longest_match! { { AsciiStringLiteral = ascii_string_literal } { HexStringLiteral = hex_string_literal } + { YulBytesKeyword = yul_bytes_keyword } { YulDecimalLiteral = yul_decimal_literal } + { YulFixedKeyword = yul_fixed_keyword } { YulHexLiteral = yul_hex_literal } { YulIdentifier = yul_identifier } + { YulIntKeyword = yul_int_keyword } + { YulUfixedKeyword = yul_ufixed_keyword } + { YulUintKeyword = yul_uint_keyword } } } } 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 097bc4ebab..f2262e1a2c 100644 --- a/crates/solidity/outputs/npm/package/src/generated/index.d.ts +++ b/crates/solidity/outputs/npm/package/src/generated/index.d.ts @@ -14,7 +14,6 @@ export namespace kinds { export enum ProductionKind { ABICoderPragma = "ABICoderPragma", AddressType = "AddressType", - ArgumentsDeclaration = "ArgumentsDeclaration", ArrayExpression = "ArrayExpression", ArrayValues = "ArrayValues", AsciiStringLiterals = "AsciiStringLiterals", @@ -35,6 +34,7 @@ export namespace kinds { DecimalNumberExpression = "DecimalNumberExpression", DeleteStatement = "DeleteStatement", DoWhileStatement = "DoWhileStatement", + ElseBranch = "ElseBranch", EmitStatement = "EmitStatement", EndOfFileTrivia = "EndOfFileTrivia", EnumDefinition = "EnumDefinition", @@ -54,7 +54,6 @@ export namespace kinds { FallbackFunctionDefinition = "FallbackFunctionDefinition", ForStatement = "ForStatement", FunctionAttributes = "FunctionAttributes", - FunctionCallOptions = "FunctionCallOptions", FunctionDefinition = "FunctionDefinition", FunctionType = "FunctionType", FunctionTypeAttributes = "FunctionTypeAttributes", @@ -62,10 +61,12 @@ export namespace kinds { HexStringLiterals = "HexStringLiterals", IdentifierPath = "IdentifierPath", IfStatement = "IfStatement", + ImportAlias = "ImportAlias", ImportDeconstruction = "ImportDeconstruction", ImportDeconstructionSymbol = "ImportDeconstructionSymbol", ImportDeconstructionSymbols = "ImportDeconstructionSymbols", ImportDirective = "ImportDirective", + IndexAccessEnd = "IndexAccessEnd", InheritanceSpecifier = "InheritanceSpecifier", InheritanceType = "InheritanceType", InheritanceTypes = "InheritanceTypes", @@ -74,24 +75,28 @@ export namespace kinds { LeadingTrivia = "LeadingTrivia", LibraryDefinition = "LibraryDefinition", LibraryMembers = "LibraryMembers", - MappingKeyType = "MappingKeyType", + MappingKey = "MappingKey", MappingType = "MappingType", - MappingValueType = "MappingValueType", + MappingValue = "MappingValue", ModifierAttributes = "ModifierAttributes", ModifierDefinition = "ModifierDefinition", ModifierInvocation = "ModifierInvocation", NamedArgument = "NamedArgument", + NamedArgumentGroup = "NamedArgumentGroup", + NamedArgumentGroups = "NamedArgumentGroups", NamedArguments = "NamedArguments", NamedArgumentsDeclaration = "NamedArgumentsDeclaration", NamedImport = "NamedImport", NewExpression = "NewExpression", OverridePaths = "OverridePaths", + OverridePathsDeclaration = "OverridePathsDeclaration", OverrideSpecifier = "OverrideSpecifier", Parameter = "Parameter", Parameters = "Parameters", ParametersDeclaration = "ParametersDeclaration", PathImport = "PathImport", PositionalArguments = "PositionalArguments", + PositionalArgumentsDeclaration = "PositionalArgumentsDeclaration", PragmaDirective = "PragmaDirective", ReceiveFunctionAttributes = "ReceiveFunctionAttributes", ReceiveFunctionDefinition = "ReceiveFunctionDefinition", @@ -102,6 +107,7 @@ export namespace kinds { SourceUnitMembers = "SourceUnitMembers", StateVariableAttributes = "StateVariableAttributes", StateVariableDefinition = "StateVariableDefinition", + StateVariableDefinitionValue = "StateVariableDefinitionValue", Statements = "Statements", StructDefinition = "StructDefinition", StructMember = "StructMember", @@ -113,6 +119,7 @@ export namespace kinds { TupleDeconstructionElements = "TupleDeconstructionElements", TupleDeconstructionStatement = "TupleDeconstructionStatement", TupleExpression = "TupleExpression", + TupleValue = "TupleValue", TupleValues = "TupleValues", TypeExpression = "TypeExpression", TypeName = "TypeName", @@ -123,12 +130,13 @@ export namespace kinds { UnnamedFunctionDefinition = "UnnamedFunctionDefinition", UntypedTupleMember = "UntypedTupleMember", UserDefinedValueTypeDefinition = "UserDefinedValueTypeDefinition", + UsingAlias = "UsingAlias", UsingDeconstruction = "UsingDeconstruction", UsingDeconstructionSymbol = "UsingDeconstructionSymbol", UsingDeconstructionSymbols = "UsingDeconstructionSymbols", UsingDirective = "UsingDirective", - VariableDeclaration = "VariableDeclaration", VariableDeclarationStatement = "VariableDeclarationStatement", + VariableDeclarationValue = "VariableDeclarationValue", VersionPragma = "VersionPragma", VersionPragmaExpression = "VersionPragmaExpression", VersionPragmaExpressions = "VersionPragmaExpressions", @@ -139,26 +147,28 @@ export namespace kinds { YulBlock = "YulBlock", YulBreakStatement = "YulBreakStatement", YulContinueStatement = "YulContinueStatement", - YulDeclarationStatement = "YulDeclarationStatement", + YulDefaultCase = "YulDefaultCase", YulExpression = "YulExpression", YulForStatement = "YulForStatement", YulFunctionDefinition = "YulFunctionDefinition", YulIdentifierPath = "YulIdentifierPath", YulIdentifierPaths = "YulIdentifierPaths", - YulIdentifiers = "YulIdentifiers", YulIfStatement = "YulIfStatement", YulLeaveStatement = "YulLeaveStatement", + YulParameters = "YulParameters", YulParametersDeclaration = "YulParametersDeclaration", + YulReturnVariables = "YulReturnVariables", YulReturnsDeclaration = "YulReturnsDeclaration", YulStatements = "YulStatements", - YulSwitchCase = "YulSwitchCase", YulSwitchCases = "YulSwitchCases", YulSwitchStatement = "YulSwitchStatement", + YulValueCase = "YulValueCase", + YulVariableDeclarationStatement = "YulVariableDeclarationStatement", + YulVariableDeclarationValue = "YulVariableDeclarationValue", } export enum RuleKind { ABICoderPragma = "ABICoderPragma", AddressType = "AddressType", - ArgumentsDeclaration = "ArgumentsDeclaration", ArrayExpression = "ArrayExpression", ArrayTypeName = "ArrayTypeName", ArrayValues = "ArrayValues", @@ -182,6 +192,7 @@ export namespace kinds { DecimalNumberExpression = "DecimalNumberExpression", DeleteStatement = "DeleteStatement", DoWhileStatement = "DoWhileStatement", + ElseBranch = "ElseBranch", EmitStatement = "EmitStatement", EndOfFileTrivia = "EndOfFileTrivia", EnumDefinition = "EnumDefinition", @@ -202,7 +213,6 @@ export namespace kinds { ForStatement = "ForStatement", FunctionAttributes = "FunctionAttributes", FunctionCallExpression = "FunctionCallExpression", - FunctionCallOptions = "FunctionCallOptions", FunctionDefinition = "FunctionDefinition", FunctionType = "FunctionType", FunctionTypeAttributes = "FunctionTypeAttributes", @@ -210,10 +220,12 @@ export namespace kinds { HexStringLiterals = "HexStringLiterals", IdentifierPath = "IdentifierPath", IfStatement = "IfStatement", + ImportAlias = "ImportAlias", ImportDeconstruction = "ImportDeconstruction", ImportDeconstructionSymbol = "ImportDeconstructionSymbol", ImportDeconstructionSymbols = "ImportDeconstructionSymbols", ImportDirective = "ImportDirective", + IndexAccessEnd = "IndexAccessEnd", IndexAccessExpression = "IndexAccessExpression", InheritanceSpecifier = "InheritanceSpecifier", InheritanceType = "InheritanceType", @@ -223,25 +235,29 @@ export namespace kinds { LeadingTrivia = "LeadingTrivia", LibraryDefinition = "LibraryDefinition", LibraryMembers = "LibraryMembers", - MappingKeyType = "MappingKeyType", + MappingKey = "MappingKey", MappingType = "MappingType", - MappingValueType = "MappingValueType", + MappingValue = "MappingValue", MemberAccessExpression = "MemberAccessExpression", ModifierAttributes = "ModifierAttributes", ModifierDefinition = "ModifierDefinition", ModifierInvocation = "ModifierInvocation", NamedArgument = "NamedArgument", + NamedArgumentGroup = "NamedArgumentGroup", + NamedArgumentGroups = "NamedArgumentGroups", NamedArguments = "NamedArguments", NamedArgumentsDeclaration = "NamedArgumentsDeclaration", NamedImport = "NamedImport", NewExpression = "NewExpression", OverridePaths = "OverridePaths", + OverridePathsDeclaration = "OverridePathsDeclaration", OverrideSpecifier = "OverrideSpecifier", Parameter = "Parameter", Parameters = "Parameters", ParametersDeclaration = "ParametersDeclaration", PathImport = "PathImport", PositionalArguments = "PositionalArguments", + PositionalArgumentsDeclaration = "PositionalArgumentsDeclaration", PragmaDirective = "PragmaDirective", ReceiveFunctionAttributes = "ReceiveFunctionAttributes", ReceiveFunctionDefinition = "ReceiveFunctionDefinition", @@ -252,6 +268,7 @@ export namespace kinds { SourceUnitMembers = "SourceUnitMembers", StateVariableAttributes = "StateVariableAttributes", StateVariableDefinition = "StateVariableDefinition", + StateVariableDefinitionValue = "StateVariableDefinitionValue", Statements = "Statements", StructDefinition = "StructDefinition", StructMember = "StructMember", @@ -263,6 +280,7 @@ export namespace kinds { TupleDeconstructionElements = "TupleDeconstructionElements", TupleDeconstructionStatement = "TupleDeconstructionStatement", TupleExpression = "TupleExpression", + TupleValue = "TupleValue", TupleValues = "TupleValues", TypeExpression = "TypeExpression", TypeName = "TypeName", @@ -275,12 +293,13 @@ export namespace kinds { UnnamedFunctionDefinition = "UnnamedFunctionDefinition", UntypedTupleMember = "UntypedTupleMember", UserDefinedValueTypeDefinition = "UserDefinedValueTypeDefinition", + UsingAlias = "UsingAlias", UsingDeconstruction = "UsingDeconstruction", UsingDeconstructionSymbol = "UsingDeconstructionSymbol", UsingDeconstructionSymbols = "UsingDeconstructionSymbols", UsingDirective = "UsingDirective", - VariableDeclaration = "VariableDeclaration", VariableDeclarationStatement = "VariableDeclarationStatement", + VariableDeclarationValue = "VariableDeclarationValue", VersionPragma = "VersionPragma", VersionPragmaBinaryExpression = "VersionPragmaBinaryExpression", VersionPragmaExpression = "VersionPragmaExpression", @@ -293,22 +312,25 @@ export namespace kinds { YulBlock = "YulBlock", YulBreakStatement = "YulBreakStatement", YulContinueStatement = "YulContinueStatement", - YulDeclarationStatement = "YulDeclarationStatement", + YulDefaultCase = "YulDefaultCase", YulExpression = "YulExpression", YulForStatement = "YulForStatement", YulFunctionCallExpression = "YulFunctionCallExpression", YulFunctionDefinition = "YulFunctionDefinition", YulIdentifierPath = "YulIdentifierPath", YulIdentifierPaths = "YulIdentifierPaths", - YulIdentifiers = "YulIdentifiers", YulIfStatement = "YulIfStatement", YulLeaveStatement = "YulLeaveStatement", + YulParameters = "YulParameters", YulParametersDeclaration = "YulParametersDeclaration", + YulReturnVariables = "YulReturnVariables", YulReturnsDeclaration = "YulReturnsDeclaration", YulStatements = "YulStatements", - YulSwitchCase = "YulSwitchCase", YulSwitchCases = "YulSwitchCases", YulSwitchStatement = "YulSwitchStatement", + YulValueCase = "YulValueCase", + YulVariableDeclarationStatement = "YulVariableDeclarationStatement", + YulVariableDeclarationValue = "YulVariableDeclarationValue", } export enum TokenKind { SKIPPED = "SKIPPED", @@ -338,7 +360,7 @@ export namespace kinds { BreakKeyword = "BreakKeyword", ByteKeyword = "ByteKeyword", BytesKeyword = "BytesKeyword", - CalldataKeyword = "CalldataKeyword", + CallDataKeyword = "CallDataKeyword", Caret = "Caret", CaretEqual = "CaretEqual", CaseKeyword = "CaseKeyword", @@ -353,7 +375,7 @@ export namespace kinds { ConstructorKeyword = "ConstructorKeyword", ContinueKeyword = "ContinueKeyword", ContractKeyword = "ContractKeyword", - CopyofKeyword = "CopyofKeyword", + CopyOfKeyword = "CopyOfKeyword", DaysKeyword = "DaysKeyword", DecimalLiteral = "DecimalLiteral", DefaultKeyword = "DefaultKeyword", @@ -404,7 +426,6 @@ export namespace kinds { InterfaceKeyword = "InterfaceKeyword", InternalKeyword = "InternalKeyword", IsKeyword = "IsKeyword", - LeaveKeyword = "LeaveKeyword", LessThan = "LessThan", LessThanEqual = "LessThanEqual", LessThanLessThan = "LessThanLessThan", @@ -454,7 +475,7 @@ export namespace kinds { SecondsKeyword = "SecondsKeyword", Semicolon = "Semicolon", SingleLineComment = "SingleLineComment", - SizeofKeyword = "SizeofKeyword", + SizeOfKeyword = "SizeOfKeyword", Slash = "Slash", SlashEqual = "SlashEqual", SolidityKeyword = "SolidityKeyword", @@ -469,9 +490,9 @@ export namespace kinds { Tilde = "Tilde", TrueKeyword = "TrueKeyword", TryKeyword = "TryKeyword", + TypeDefKeyword = "TypeDefKeyword", TypeKeyword = "TypeKeyword", - TypedefKeyword = "TypedefKeyword", - TypeofKeyword = "TypeofKeyword", + TypeOfKeyword = "TypeOfKeyword", UfixedKeyword = "UfixedKeyword", UintKeyword = "UintKeyword", UncheckedKeyword = "UncheckedKeyword", @@ -486,17 +507,124 @@ export namespace kinds { WhileKeyword = "WhileKeyword", Whitespace = "Whitespace", YearsKeyword = "YearsKeyword", + YulAbstractKeyword = "YulAbstractKeyword", + YulAddressKeyword = "YulAddressKeyword", + YulAfterKeyword = "YulAfterKeyword", + YulAliasKeyword = "YulAliasKeyword", + YulAnonymousKeyword = "YulAnonymousKeyword", + YulApplyKeyword = "YulApplyKeyword", + YulAsKeyword = "YulAsKeyword", + YulAssemblyKeyword = "YulAssemblyKeyword", + YulAutoKeyword = "YulAutoKeyword", + YulBoolKeyword = "YulBoolKeyword", + YulBreakKeyword = "YulBreakKeyword", + YulByteKeyword = "YulByteKeyword", + YulBytesKeyword = "YulBytesKeyword", + YulCallDataKeyword = "YulCallDataKeyword", + YulCaseKeyword = "YulCaseKeyword", + YulCatchKeyword = "YulCatchKeyword", + YulConstantKeyword = "YulConstantKeyword", + YulConstructorKeyword = "YulConstructorKeyword", + YulContinueKeyword = "YulContinueKeyword", + YulContractKeyword = "YulContractKeyword", + YulCopyOfKeyword = "YulCopyOfKeyword", + YulDaysKeyword = "YulDaysKeyword", YulDecimalLiteral = "YulDecimalLiteral", + YulDefaultKeyword = "YulDefaultKeyword", + YulDefineKeyword = "YulDefineKeyword", + YulDeleteKeyword = "YulDeleteKeyword", + YulDoKeyword = "YulDoKeyword", + YulElseKeyword = "YulElseKeyword", + YulEmitKeyword = "YulEmitKeyword", + YulEnumKeyword = "YulEnumKeyword", + YulEtherKeyword = "YulEtherKeyword", + YulEventKeyword = "YulEventKeyword", + YulExternalKeyword = "YulExternalKeyword", + YulFallbackKeyword = "YulFallbackKeyword", + YulFalseKeyword = "YulFalseKeyword", + YulFinalKeyword = "YulFinalKeyword", + YulFinneyKeyword = "YulFinneyKeyword", + YulFixedKeyword = "YulFixedKeyword", + YulForKeyword = "YulForKeyword", + YulFunctionKeyword = "YulFunctionKeyword", + YulGweiKeyword = "YulGweiKeyword", + YulHexKeyword = "YulHexKeyword", YulHexLiteral = "YulHexLiteral", + YulHoursKeyword = "YulHoursKeyword", YulIdentifier = "YulIdentifier", + YulIfKeyword = "YulIfKeyword", + YulImmutableKeyword = "YulImmutableKeyword", + YulImplementsKeyword = "YulImplementsKeyword", + YulImportKeyword = "YulImportKeyword", + YulInKeyword = "YulInKeyword", + YulIndexedKeyword = "YulIndexedKeyword", + YulInlineKeyword = "YulInlineKeyword", + YulIntKeyword = "YulIntKeyword", + YulInterfaceKeyword = "YulInterfaceKeyword", + YulInternalKeyword = "YulInternalKeyword", + YulIsKeyword = "YulIsKeyword", + YulLeaveKeyword = "YulLeaveKeyword", + YulLetKeyword = "YulLetKeyword", + YulLibraryKeyword = "YulLibraryKeyword", + YulMacroKeyword = "YulMacroKeyword", + YulMappingKeyword = "YulMappingKeyword", + YulMatchKeyword = "YulMatchKeyword", + YulMemoryKeyword = "YulMemoryKeyword", + YulMinutesKeyword = "YulMinutesKeyword", + YulModifierKeyword = "YulModifierKeyword", + YulMutableKeyword = "YulMutableKeyword", + YulNewKeyword = "YulNewKeyword", + YulNullKeyword = "YulNullKeyword", + YulOfKeyword = "YulOfKeyword", + YulOverrideKeyword = "YulOverrideKeyword", + YulPartialKeyword = "YulPartialKeyword", + YulPayableKeyword = "YulPayableKeyword", + YulPragmaKeyword = "YulPragmaKeyword", + YulPrivateKeyword = "YulPrivateKeyword", + YulPromiseKeyword = "YulPromiseKeyword", + YulPublicKeyword = "YulPublicKeyword", + YulPureKeyword = "YulPureKeyword", + YulReceiveKeyword = "YulReceiveKeyword", + YulReferenceKeyword = "YulReferenceKeyword", + YulRelocatableKeyword = "YulRelocatableKeyword", + YulReturnKeyword = "YulReturnKeyword", + YulReturnsKeyword = "YulReturnsKeyword", + YulRevertKeyword = "YulRevertKeyword", + YulSealedKeyword = "YulSealedKeyword", + YulSecondsKeyword = "YulSecondsKeyword", + YulSizeOfKeyword = "YulSizeOfKeyword", + YulStaticKeyword = "YulStaticKeyword", + YulStorageKeyword = "YulStorageKeyword", + YulStringKeyword = "YulStringKeyword", + YulStructKeyword = "YulStructKeyword", + YulSupportsKeyword = "YulSupportsKeyword", + YulSwitchKeyword = "YulSwitchKeyword", + YulSzaboKeyword = "YulSzaboKeyword", + YulThrowKeyword = "YulThrowKeyword", + YulTrueKeyword = "YulTrueKeyword", + YulTryKeyword = "YulTryKeyword", + YulTypeDefKeyword = "YulTypeDefKeyword", + YulTypeKeyword = "YulTypeKeyword", + YulTypeOfKeyword = "YulTypeOfKeyword", + YulUfixedKeyword = "YulUfixedKeyword", + YulUintKeyword = "YulUintKeyword", + YulUncheckedKeyword = "YulUncheckedKeyword", + YulUsingKeyword = "YulUsingKeyword", + YulVarKeyword = "YulVarKeyword", + YulViewKeyword = "YulViewKeyword", + YulVirtualKeyword = "YulVirtualKeyword", + YulWeeksKeyword = "YulWeeksKeyword", + YulWeiKeyword = "YulWeiKeyword", + YulWhileKeyword = "YulWhileKeyword", + YulYearsKeyword = "YulYearsKeyword", } } export namespace language { /** The lexical context of the scanner. */ export enum LexicalContext { Default = "Default", - VersionPragma = "VersionPragma", - YulBlock = "YulBlock", + Pragma = "Pragma", + Yul = "Yul", } export class Language { constructor(version: string); 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 b29bea96aa..43ff2859b9 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 @@ -57,7 +57,7 @@ Tree: - FunctionCallExpression (Rule): # 122..199 ' require(address(this).balance >= amount, "Addr...' - Expression (Rule): # 122..133 " require" - Identifier (Token): "require" # 126..133 - - ArgumentsDeclaration (Rule): # 133..199 '(address(this).balance >= amount, "Address: insuff...' + - PositionalArgumentsDeclaration (Rule): # 133..199 '(address(this).balance >= amount, "Address: insuff...' - OpenParen (Token): "(" # 133..134 - PositionalArguments (Rule): # 134..198 'address(this).balance >= amount, "Address: insuffi...' - Expression (Rule): # 134..165 "address(this).balance >= amount" @@ -69,7 +69,7 @@ Tree: - Expression (Rule): # 134..141 "address" - AddressType (Rule): # 134..141 "address" - AddressKeyword (Token): "address" # 134..141 - - ArgumentsDeclaration (Rule): # 141..147 "(this)" + - PositionalArgumentsDeclaration (Rule): # 141..147 "(this)" - OpenParen (Token): "(" # 141..142 - PositionalArguments (Rule): # 142..146 "this" - Expression (Rule): # 142..146 "this" @@ -111,7 +111,7 @@ Tree: - FunctionCallExpression (Rule): # 262..344 ' require(success, "Address: unable to send valu...' - Expression (Rule): # 262..273 " require" - Identifier (Token): "require" # 266..273 - - ArgumentsDeclaration (Rule): # 273..344 '(success, "Address: unable to send value, recipien...' + - PositionalArgumentsDeclaration (Rule): # 273..344 '(success, "Address: unable to send value, recipien...' - OpenParen (Token): "(" # 273..274 - PositionalArguments (Rule): # 274..343 'success, "Address: unable to send value, recipient...' - Expression (Rule): # 274..281 "success" 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 c8994b26cb..02381078c5 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 @@ -49,7 +49,7 @@ Tree: - FunctionCallExpression (Rule): # 122..199 ' require(address(this).balance >= amount, "Addr...' - Expression (Rule): # 122..133 " require" - Identifier (Token): "require" # 126..133 - - ArgumentsDeclaration (Rule): # 133..199 '(address(this).balance >= amount, "Address: insuff...' + - PositionalArgumentsDeclaration (Rule): # 133..199 '(address(this).balance >= amount, "Address: insuff...' - OpenParen (Token): "(" # 133..134 - PositionalArguments (Rule): # 134..198 'address(this).balance >= amount, "Address: insuffi...' - Expression (Rule): # 134..165 "address(this).balance >= amount" @@ -61,7 +61,7 @@ Tree: - Expression (Rule): # 134..141 "address" - AddressType (Rule): # 134..141 "address" - AddressKeyword (Token): "address" # 134..141 - - ArgumentsDeclaration (Rule): # 141..147 "(this)" + - PositionalArgumentsDeclaration (Rule): # 141..147 "(this)" - OpenParen (Token): "(" # 141..142 - PositionalArguments (Rule): # 142..146 "this" - Expression (Rule): # 142..146 "this" @@ -98,8 +98,8 @@ Tree: - Identifier (Token): "recipient" # 225..234 - Period (Token): "." # 234..235 - Identifier (Token): "call" # 235..239 - - FunctionCallOptions (Rule): # 239..256 "{ value: amount }" - - NamedArgumentsDeclaration (Rule): # 239..256 "{ value: amount }" + - NamedArgumentGroups (Rule): # 239..256 "{ value: amount }" + - NamedArgumentGroup (Rule): # 239..256 "{ value: amount }" - OpenBrace (Token): "{" # 239..240 - NamedArguments (Rule): # 240..254 " value: amount" - NamedArgument (Rule): # 240..254 " value: amount" @@ -108,7 +108,7 @@ Tree: - Expression (Rule): # 247..254 " amount" - Identifier (Token): "amount" # 248..254 - CloseBrace (Token): "}" # 255..256 - - ArgumentsDeclaration (Rule): # 256..260 '("")' + - PositionalArgumentsDeclaration (Rule): # 256..260 '("")' - OpenParen (Token): "(" # 256..257 - PositionalArguments (Rule): # 257..259 '""' - Expression (Rule): # 257..259 '""' @@ -121,7 +121,7 @@ Tree: - FunctionCallExpression (Rule): # 262..344 ' require(success, "Address: unable to send valu...' - Expression (Rule): # 262..273 " require" - Identifier (Token): "require" # 266..273 - - ArgumentsDeclaration (Rule): # 273..344 '(success, "Address: unable to send value, recipien...' + - PositionalArgumentsDeclaration (Rule): # 273..344 '(success, "Address: unable to send value, recipien...' - OpenParen (Token): "(" # 273..274 - PositionalArguments (Rule): # 274..343 'success, "Address: unable to send value, recipient...' - Expression (Rule): # 274..281 "success" 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 new file mode 100644 index 0000000000..d7db1f4772 --- /dev/null +++ b/crates/solidity/testing/snapshots/cst_output/ContractDefinition/function_multiple_delimiters/generated/0.8.0-success.yml @@ -0,0 +1,135 @@ +# This file is generated automatically by infrastructure scripts. Please don't edit by hand. + +Source: > + 1 │ // SPDX-License-Identifier: MIT │ 0..31 + 2 │ contract ABC { │ 32..46 + 3 │ function sendValue(address payable recipient, uint256 amount) internal { │ 47..121 + 4 │ require(address(this).balance >= amount, "Address: insufficient balance"); │ 122..200 + 5 │ │ 201..201 + 6 │ (bool success, ) = recipient.call{ value: amount }(""); │ 202..261 + 7 │ require(success, "Address: unable to send value, recipient may have reverted"); │ 262..345 + 8 │ } │ 346..349 + 9 │ } │ 350..351 + +Errors: [] + +Tree: + - ContractDefinition (Rule): # 0..352 "// SPDX-License-Identifier: MIT\ncontract ABC {\n f..." + - LeadingTrivia (Rule): # 0..32 "// SPDX-License-Identifier: MIT\n" + - SingleLineComment (Trivia): "// SPDX-License-Identifier: MIT" # 0..31 + - ContractKeyword (Token): "contract" # 32..40 + - Identifier (Token): "ABC" # 41..44 + - OpenBrace (Token): "{" # 45..46 + - ContractMembers (Rule): # 47..350 " function sendValue(address payable recipient, ui..." + - FunctionDefinition (Rule): # 47..350 " function sendValue(address payable recipient, ui..." + - FunctionKeyword (Token): "function" # 49..57 + - Identifier (Token): "sendValue" # 58..67 + - ParametersDeclaration (Rule): # 67..110 "(address payable recipient, uint256 amount)" + - OpenParen (Token): "(" # 67..68 + - Parameters (Rule): # 68..109 "address payable recipient, uint256 amount" + - Parameter (Rule): # 68..93 "address payable recipient" + - TypeName (Rule): # 68..83 "address payable" + - AddressType (Rule): # 68..83 "address payable" + - AddressKeyword (Token): "address" # 68..75 + - PayableKeyword (Token): "payable" # 76..83 + - Identifier (Token): "recipient" # 84..93 + - Comma (Token): "," # 93..94 + - Parameter (Rule): # 94..109 " uint256 amount" + - TypeName (Rule): # 94..102 " uint256" + - UintKeyword (Token): "uint256" # 95..102 + - Identifier (Token): "amount" # 103..109 + - CloseParen (Token): ")" # 109..110 + - FunctionAttributes (Rule): # 110..119 " internal" + - InternalKeyword (Token): "internal" # 111..119 + - Block (Rule): # 119..350 ' {\n require(address(this).balance >= amount, "A...' + - OpenBrace (Token): "{" # 120..121 + - Statements (Rule): # 122..346 ' require(address(this).balance >= amount, "Addr...' + - ExpressionStatement (Rule): # 122..201 ' require(address(this).balance >= amount, "Addr...' + - Expression (Rule): # 122..199 ' require(address(this).balance >= amount, "Addr...' + - FunctionCallExpression (Rule): # 122..199 ' require(address(this).balance >= amount, "Addr...' + - Expression (Rule): # 122..133 " require" + - Identifier (Token): "require" # 126..133 + - PositionalArgumentsDeclaration (Rule): # 133..199 '(address(this).balance >= amount, "Address: insuff...' + - 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" + - Expression (Rule): # 134..155 "address(this).balance" + - MemberAccessExpression (Rule): # 134..155 "address(this).balance" + - Expression (Rule): # 134..147 "address(this)" + - FunctionCallExpression (Rule): # 134..147 "address(this)" + - Expression (Rule): # 134..141 "address" + - AddressType (Rule): # 134..141 "address" + - AddressKeyword (Token): "address" # 134..141 + - PositionalArgumentsDeclaration (Rule): # 141..147 "(this)" + - OpenParen (Token): "(" # 141..142 + - PositionalArguments (Rule): # 142..146 "this" + - Expression (Rule): # 142..146 "this" + - Identifier (Token): "this" # 142..146 + - CloseParen (Token): ")" # 146..147 + - Period (Token): "." # 147..148 + - Identifier (Token): "balance" # 148..155 + - GreaterThanEqual (Token): ">=" # 156..158 + - Expression (Rule): # 158..165 " amount" + - Identifier (Token): "amount" # 159..165 + - Comma (Token): "," # 165..166 + - Expression (Rule): # 166..198 ' "Address: insufficient balance"' + - AsciiStringLiterals (Rule): # 166..198 ' "Address: insufficient balance"' + - AsciiStringLiteral (Token): '"Address: insufficient balance"' # 167..198 + - CloseParen (Token): ")" # 198..199 + - Semicolon (Token): ";" # 199..200 + - TupleDeconstructionStatement (Rule): # 201..262 "\n (bool success, ) = recipient.call{ value: amo..." + - OpenParen (Token): "(" # 206..207 + - TupleDeconstructionElements (Rule): # 207..220 "bool success," + - TupleDeconstructionElement (Rule): # 207..219 "bool success" + - TypedTupleMember (Rule): # 207..219 "bool success" + - TypeName (Rule): # 207..211 "bool" + - BoolKeyword (Token): "bool" # 207..211 + - Identifier (Token): "success" # 212..219 + - Comma (Token): "," # 219..220 + - TupleDeconstructionElement (Rule): [] # 220..220 + - CloseParen (Token): ")" # 221..222 + - Equal (Token): "=" # 223..224 + - Expression (Rule): # 224..260 ' recipient.call{ value: amount }("")' + - FunctionCallExpression (Rule): # 224..260 ' recipient.call{ value: amount }("")' + - Expression (Rule): # 224..239 " recipient.call" + - MemberAccessExpression (Rule): # 224..239 " recipient.call" + - Expression (Rule): # 224..234 " recipient" + - Identifier (Token): "recipient" # 225..234 + - Period (Token): "." # 234..235 + - Identifier (Token): "call" # 235..239 + - NamedArgumentGroup (Rule): # 239..256 "{ value: amount }" + - OpenBrace (Token): "{" # 239..240 + - NamedArguments (Rule): # 240..254 " value: amount" + - NamedArgument (Rule): # 240..254 " value: amount" + - Identifier (Token): "value" # 241..246 + - Colon (Token): ":" # 246..247 + - Expression (Rule): # 247..254 " amount" + - Identifier (Token): "amount" # 248..254 + - CloseBrace (Token): "}" # 255..256 + - PositionalArgumentsDeclaration (Rule): # 256..260 '("")' + - OpenParen (Token): "(" # 256..257 + - PositionalArguments (Rule): # 257..259 '""' + - Expression (Rule): # 257..259 '""' + - AsciiStringLiterals (Rule): # 257..259 '""' + - AsciiStringLiteral (Token): '""' # 257..259 + - CloseParen (Token): ")" # 259..260 + - Semicolon (Token): ";" # 260..261 + - ExpressionStatement (Rule): # 262..346 ' require(success, "Address: unable to send valu...' + - Expression (Rule): # 262..344 ' require(success, "Address: unable to send valu...' + - FunctionCallExpression (Rule): # 262..344 ' require(success, "Address: unable to send valu...' + - Expression (Rule): # 262..273 " require" + - Identifier (Token): "require" # 266..273 + - PositionalArgumentsDeclaration (Rule): # 273..344 '(success, "Address: unable to send value, recipien...' + - OpenParen (Token): "(" # 273..274 + - PositionalArguments (Rule): # 274..343 'success, "Address: unable to send value, recipient...' + - Expression (Rule): # 274..281 "success" + - Identifier (Token): "success" # 274..281 + - Comma (Token): "," # 281..282 + - Expression (Rule): # 282..343 ' "Address: unable to send value, recipient may hav...' + - AsciiStringLiterals (Rule): # 282..343 ' "Address: unable to send value, recipient may hav...' + - AsciiStringLiteral (Token): '"Address: unable to send value, recipient may have...' # 283..343 + - CloseParen (Token): ")" # 343..344 + - Semicolon (Token): ";" # 344..345 + - CloseBrace (Token): "}" # 348..349 + - CloseBrace (Token): "}" # 350..351 diff --git a/crates/solidity/testing/snapshots/cst_output/ContractDefinition/inheritence_specifier/generated/0.4.11-success.yml b/crates/solidity/testing/snapshots/cst_output/ContractDefinition/inheritence_specifier/generated/0.4.11-success.yml index c14462d9ed..ea11102f51 100644 --- a/crates/solidity/testing/snapshots/cst_output/ContractDefinition/inheritence_specifier/generated/0.4.11-success.yml +++ b/crates/solidity/testing/snapshots/cst_output/ContractDefinition/inheritence_specifier/generated/0.4.11-success.yml @@ -19,7 +19,7 @@ Tree: - InheritanceType (Rule): # 23..33 " Bar(1, 2)" - IdentifierPath (Rule): # 23..27 " Bar" - Identifier (Token): "Bar" # 24..27 - - ArgumentsDeclaration (Rule): # 27..33 "(1, 2)" + - PositionalArgumentsDeclaration (Rule): # 27..33 "(1, 2)" - OpenParen (Token): "(" # 27..28 - PositionalArguments (Rule): # 28..32 "1, 2" - Expression (Rule): # 28..29 "1" diff --git a/crates/solidity/testing/snapshots/cst_output/ContractDefinition/recovery_testbed/generated/0.4.11-failure.yml b/crates/solidity/testing/snapshots/cst_output/ContractDefinition/recovery_testbed/generated/0.4.11-failure.yml index b38ed4d556..9ddbf6f70e 100644 --- a/crates/solidity/testing/snapshots/cst_output/ContractDefinition/recovery_testbed/generated/0.4.11-failure.yml +++ b/crates/solidity/testing/snapshots/cst_output/ContractDefinition/recovery_testbed/generated/0.4.11-failure.yml @@ -73,14 +73,14 @@ Tree: - OpenBrace (Token): "{" # 111..112 - Statements (Rule): # 113..131 "\t\t\tuint256 a = 1;\n" - VariableDeclarationStatement (Rule): # 113..131 "\t\t\tuint256 a = 1;\n" - - VariableDeclaration (Rule): # 113..125 "\t\t\tuint256 a" - - TypeName (Rule): # 113..123 "\t\t\tuint256" - - UintKeyword (Token): "uint256" # 116..123 - - Identifier (Token): "a" # 124..125 - - Equal (Token): "=" # 126..127 - - Expression (Rule): # 127..129 " 1" - - DecimalNumberExpression (Rule): # 127..129 " 1" - - DecimalLiteral (Token): "1" # 128..129 + - TypeName (Rule): # 113..123 "\t\t\tuint256" + - UintKeyword (Token): "uint256" # 116..123 + - Identifier (Token): "a" # 124..125 + - VariableDeclarationValue (Rule): # 125..129 " = 1" + - Equal (Token): "=" # 126..127 + - Expression (Rule): # 127..129 " 1" + - DecimalNumberExpression (Rule): # 127..129 " 1" + - DecimalLiteral (Token): "1" # 128..129 - Semicolon (Token): ";" # 129..130 - CloseBrace (Token): "}" # 133..134 - CloseBrace (Token): "}" # 136..137 @@ -94,14 +94,14 @@ Tree: - OpenBrace (Token): "{" # 155..156 - Statements (Rule): # 157..186 "\t\tuint256 x = 0;\n\t\tunchecked " - VariableDeclarationStatement (Rule): # 157..174 "\t\tuint256 x = 0;\n" - - VariableDeclaration (Rule): # 157..168 "\t\tuint256 x" - - TypeName (Rule): # 157..166 "\t\tuint256" - - UintKeyword (Token): "uint256" # 159..166 - - Identifier (Token): "x" # 167..168 - - Equal (Token): "=" # 169..170 - - Expression (Rule): # 170..172 " 0" - - DecimalNumberExpression (Rule): # 170..172 " 0" - - DecimalLiteral (Token): "0" # 171..172 + - TypeName (Rule): # 157..166 "\t\tuint256" + - UintKeyword (Token): "uint256" # 159..166 + - Identifier (Token): "x" # 167..168 + - VariableDeclarationValue (Rule): # 168..172 " = 0" + - Equal (Token): "=" # 169..170 + - Expression (Rule): # 170..172 " 0" + - DecimalNumberExpression (Rule): # 170..172 " 0" + - DecimalLiteral (Token): "0" # 171..172 - Semicolon (Token): ";" # 172..173 - ExpressionStatement (Rule): # 174..186 "\t\tunchecked " - Expression (Rule): # 174..185 "\t\tunchecked" diff --git a/crates/solidity/testing/snapshots/cst_output/ContractDefinition/recovery_testbed/generated/0.5.0-failure.yml b/crates/solidity/testing/snapshots/cst_output/ContractDefinition/recovery_testbed/generated/0.5.0-failure.yml index 38cd7ddb8e..b5f0c518ac 100644 --- a/crates/solidity/testing/snapshots/cst_output/ContractDefinition/recovery_testbed/generated/0.5.0-failure.yml +++ b/crates/solidity/testing/snapshots/cst_output/ContractDefinition/recovery_testbed/generated/0.5.0-failure.yml @@ -73,14 +73,14 @@ Tree: - OpenBrace (Token): "{" # 111..112 - Statements (Rule): # 113..131 "\t\t\tuint256 a = 1;\n" - VariableDeclarationStatement (Rule): # 113..131 "\t\t\tuint256 a = 1;\n" - - VariableDeclaration (Rule): # 113..125 "\t\t\tuint256 a" - - TypeName (Rule): # 113..123 "\t\t\tuint256" - - UintKeyword (Token): "uint256" # 116..123 - - Identifier (Token): "a" # 124..125 - - Equal (Token): "=" # 126..127 - - Expression (Rule): # 127..129 " 1" - - DecimalNumberExpression (Rule): # 127..129 " 1" - - DecimalLiteral (Token): "1" # 128..129 + - TypeName (Rule): # 113..123 "\t\t\tuint256" + - UintKeyword (Token): "uint256" # 116..123 + - Identifier (Token): "a" # 124..125 + - VariableDeclarationValue (Rule): # 125..129 " = 1" + - Equal (Token): "=" # 126..127 + - Expression (Rule): # 127..129 " 1" + - DecimalNumberExpression (Rule): # 127..129 " 1" + - DecimalLiteral (Token): "1" # 128..129 - Semicolon (Token): ";" # 129..130 - CloseBrace (Token): "}" # 133..134 - CloseBrace (Token): "}" # 136..137 @@ -94,14 +94,14 @@ Tree: - OpenBrace (Token): "{" # 155..156 - Statements (Rule): # 157..174 "\t\tuint256 x = 0;\n" - VariableDeclarationStatement (Rule): # 157..174 "\t\tuint256 x = 0;\n" - - VariableDeclaration (Rule): # 157..168 "\t\tuint256 x" - - TypeName (Rule): # 157..166 "\t\tuint256" - - UintKeyword (Token): "uint256" # 159..166 - - Identifier (Token): "x" # 167..168 - - Equal (Token): "=" # 169..170 - - Expression (Rule): # 170..172 " 0" - - DecimalNumberExpression (Rule): # 170..172 " 0" - - DecimalLiteral (Token): "0" # 171..172 + - TypeName (Rule): # 157..166 "\t\tuint256" + - UintKeyword (Token): "uint256" # 159..166 + - Identifier (Token): "x" # 167..168 + - VariableDeclarationValue (Rule): # 168..172 " = 0" + - Equal (Token): "=" # 169..170 + - Expression (Rule): # 170..172 " 0" + - DecimalNumberExpression (Rule): # 170..172 " 0" + - DecimalLiteral (Token): "0" # 171..172 - Semicolon (Token): ";" # 172..173 - SKIPPED (Token): "unchecked { invalid sequence }\n\t" # 176..208 - CloseBrace (Token): "}" # 208..209 diff --git a/crates/solidity/testing/snapshots/cst_output/ContractDefinition/recovery_testbed/generated/0.5.3-failure.yml b/crates/solidity/testing/snapshots/cst_output/ContractDefinition/recovery_testbed/generated/0.5.3-failure.yml index cb6b81f4a0..09aa26f1c9 100644 --- a/crates/solidity/testing/snapshots/cst_output/ContractDefinition/recovery_testbed/generated/0.5.3-failure.yml +++ b/crates/solidity/testing/snapshots/cst_output/ContractDefinition/recovery_testbed/generated/0.5.3-failure.yml @@ -73,14 +73,14 @@ Tree: - OpenBrace (Token): "{" # 111..112 - Statements (Rule): # 113..131 "\t\t\tuint256 a = 1;\n" - VariableDeclarationStatement (Rule): # 113..131 "\t\t\tuint256 a = 1;\n" - - VariableDeclaration (Rule): # 113..125 "\t\t\tuint256 a" - - TypeName (Rule): # 113..123 "\t\t\tuint256" - - UintKeyword (Token): "uint256" # 116..123 - - Identifier (Token): "a" # 124..125 - - Equal (Token): "=" # 126..127 - - Expression (Rule): # 127..129 " 1" - - DecimalNumberExpression (Rule): # 127..129 " 1" - - DecimalLiteral (Token): "1" # 128..129 + - TypeName (Rule): # 113..123 "\t\t\tuint256" + - UintKeyword (Token): "uint256" # 116..123 + - Identifier (Token): "a" # 124..125 + - VariableDeclarationValue (Rule): # 125..129 " = 1" + - Equal (Token): "=" # 126..127 + - Expression (Rule): # 127..129 " 1" + - DecimalNumberExpression (Rule): # 127..129 " 1" + - DecimalLiteral (Token): "1" # 128..129 - Semicolon (Token): ";" # 129..130 - CloseBrace (Token): "}" # 133..134 - CloseBrace (Token): "}" # 136..137 @@ -94,14 +94,14 @@ Tree: - OpenBrace (Token): "{" # 155..156 - Statements (Rule): # 157..174 "\t\tuint256 x = 0;\n" - VariableDeclarationStatement (Rule): # 157..174 "\t\tuint256 x = 0;\n" - - VariableDeclaration (Rule): # 157..168 "\t\tuint256 x" - - TypeName (Rule): # 157..166 "\t\tuint256" - - UintKeyword (Token): "uint256" # 159..166 - - Identifier (Token): "x" # 167..168 - - Equal (Token): "=" # 169..170 - - Expression (Rule): # 170..172 " 0" - - DecimalNumberExpression (Rule): # 170..172 " 0" - - DecimalLiteral (Token): "0" # 171..172 + - TypeName (Rule): # 157..166 "\t\tuint256" + - UintKeyword (Token): "uint256" # 159..166 + - Identifier (Token): "x" # 167..168 + - VariableDeclarationValue (Rule): # 168..172 " = 0" + - Equal (Token): "=" # 169..170 + - Expression (Rule): # 170..172 " 0" + - DecimalNumberExpression (Rule): # 170..172 " 0" + - DecimalLiteral (Token): "0" # 171..172 - Semicolon (Token): ";" # 172..173 - SKIPPED (Token): "unchecked { invalid sequence }\n\t" # 176..208 - CloseBrace (Token): "}" # 208..209 diff --git a/crates/solidity/testing/snapshots/cst_output/ContractDefinition/recovery_testbed/generated/0.6.0-failure.yml b/crates/solidity/testing/snapshots/cst_output/ContractDefinition/recovery_testbed/generated/0.6.0-failure.yml index 4bc261ec0c..96f0abf624 100644 --- a/crates/solidity/testing/snapshots/cst_output/ContractDefinition/recovery_testbed/generated/0.6.0-failure.yml +++ b/crates/solidity/testing/snapshots/cst_output/ContractDefinition/recovery_testbed/generated/0.6.0-failure.yml @@ -73,14 +73,14 @@ Tree: - OpenBrace (Token): "{" # 111..112 - Statements (Rule): # 113..131 "\t\t\tuint256 a = 1;\n" - VariableDeclarationStatement (Rule): # 113..131 "\t\t\tuint256 a = 1;\n" - - VariableDeclaration (Rule): # 113..125 "\t\t\tuint256 a" - - TypeName (Rule): # 113..123 "\t\t\tuint256" - - UintKeyword (Token): "uint256" # 116..123 - - Identifier (Token): "a" # 124..125 - - Equal (Token): "=" # 126..127 - - Expression (Rule): # 127..129 " 1" - - DecimalNumberExpression (Rule): # 127..129 " 1" - - DecimalLiteral (Token): "1" # 128..129 + - TypeName (Rule): # 113..123 "\t\t\tuint256" + - UintKeyword (Token): "uint256" # 116..123 + - Identifier (Token): "a" # 124..125 + - VariableDeclarationValue (Rule): # 125..129 " = 1" + - Equal (Token): "=" # 126..127 + - Expression (Rule): # 127..129 " 1" + - DecimalNumberExpression (Rule): # 127..129 " 1" + - DecimalLiteral (Token): "1" # 128..129 - Semicolon (Token): ";" # 129..130 - CloseBrace (Token): "}" # 133..134 - CloseBrace (Token): "}" # 136..137 @@ -94,14 +94,14 @@ Tree: - OpenBrace (Token): "{" # 155..156 - Statements (Rule): # 157..174 "\t\tuint256 x = 0;\n" - VariableDeclarationStatement (Rule): # 157..174 "\t\tuint256 x = 0;\n" - - VariableDeclaration (Rule): # 157..168 "\t\tuint256 x" - - TypeName (Rule): # 157..166 "\t\tuint256" - - UintKeyword (Token): "uint256" # 159..166 - - Identifier (Token): "x" # 167..168 - - Equal (Token): "=" # 169..170 - - Expression (Rule): # 170..172 " 0" - - DecimalNumberExpression (Rule): # 170..172 " 0" - - DecimalLiteral (Token): "0" # 171..172 + - TypeName (Rule): # 157..166 "\t\tuint256" + - UintKeyword (Token): "uint256" # 159..166 + - Identifier (Token): "x" # 167..168 + - VariableDeclarationValue (Rule): # 168..172 " = 0" + - Equal (Token): "=" # 169..170 + - Expression (Rule): # 170..172 " 0" + - DecimalNumberExpression (Rule): # 170..172 " 0" + - DecimalLiteral (Token): "0" # 171..172 - Semicolon (Token): ";" # 172..173 - SKIPPED (Token): "unchecked { invalid sequence }\n\t" # 176..208 - CloseBrace (Token): "}" # 208..209 diff --git a/crates/solidity/testing/snapshots/cst_output/ContractDefinition/recovery_testbed/generated/0.7.0-failure.yml b/crates/solidity/testing/snapshots/cst_output/ContractDefinition/recovery_testbed/generated/0.7.0-failure.yml index 5bb230097a..b1bc0f22e6 100644 --- a/crates/solidity/testing/snapshots/cst_output/ContractDefinition/recovery_testbed/generated/0.7.0-failure.yml +++ b/crates/solidity/testing/snapshots/cst_output/ContractDefinition/recovery_testbed/generated/0.7.0-failure.yml @@ -73,14 +73,14 @@ Tree: - OpenBrace (Token): "{" # 111..112 - Statements (Rule): # 113..131 "\t\t\tuint256 a = 1;\n" - VariableDeclarationStatement (Rule): # 113..131 "\t\t\tuint256 a = 1;\n" - - VariableDeclaration (Rule): # 113..125 "\t\t\tuint256 a" - - TypeName (Rule): # 113..123 "\t\t\tuint256" - - UintKeyword (Token): "uint256" # 116..123 - - Identifier (Token): "a" # 124..125 - - Equal (Token): "=" # 126..127 - - Expression (Rule): # 127..129 " 1" - - DecimalNumberExpression (Rule): # 127..129 " 1" - - DecimalLiteral (Token): "1" # 128..129 + - TypeName (Rule): # 113..123 "\t\t\tuint256" + - UintKeyword (Token): "uint256" # 116..123 + - Identifier (Token): "a" # 124..125 + - VariableDeclarationValue (Rule): # 125..129 " = 1" + - Equal (Token): "=" # 126..127 + - Expression (Rule): # 127..129 " 1" + - DecimalNumberExpression (Rule): # 127..129 " 1" + - DecimalLiteral (Token): "1" # 128..129 - Semicolon (Token): ";" # 129..130 - CloseBrace (Token): "}" # 133..134 - CloseBrace (Token): "}" # 136..137 @@ -94,14 +94,14 @@ Tree: - OpenBrace (Token): "{" # 155..156 - Statements (Rule): # 157..174 "\t\tuint256 x = 0;\n" - VariableDeclarationStatement (Rule): # 157..174 "\t\tuint256 x = 0;\n" - - VariableDeclaration (Rule): # 157..168 "\t\tuint256 x" - - TypeName (Rule): # 157..166 "\t\tuint256" - - UintKeyword (Token): "uint256" # 159..166 - - Identifier (Token): "x" # 167..168 - - Equal (Token): "=" # 169..170 - - Expression (Rule): # 170..172 " 0" - - DecimalNumberExpression (Rule): # 170..172 " 0" - - DecimalLiteral (Token): "0" # 171..172 + - TypeName (Rule): # 157..166 "\t\tuint256" + - UintKeyword (Token): "uint256" # 159..166 + - Identifier (Token): "x" # 167..168 + - VariableDeclarationValue (Rule): # 168..172 " = 0" + - Equal (Token): "=" # 169..170 + - Expression (Rule): # 170..172 " 0" + - DecimalNumberExpression (Rule): # 170..172 " 0" + - DecimalLiteral (Token): "0" # 171..172 - Semicolon (Token): ";" # 172..173 - SKIPPED (Token): "unchecked { invalid sequence }\n\t" # 176..208 - CloseBrace (Token): "}" # 208..209 diff --git a/crates/solidity/testing/snapshots/cst_output/ContractDefinition/recovery_testbed/generated/0.8.0-failure.yml b/crates/solidity/testing/snapshots/cst_output/ContractDefinition/recovery_testbed/generated/0.8.0-failure.yml index 00764cf813..81f4618530 100644 --- a/crates/solidity/testing/snapshots/cst_output/ContractDefinition/recovery_testbed/generated/0.8.0-failure.yml +++ b/crates/solidity/testing/snapshots/cst_output/ContractDefinition/recovery_testbed/generated/0.8.0-failure.yml @@ -72,14 +72,14 @@ Tree: - OpenBrace (Token): "{" # 111..112 - Statements (Rule): # 113..131 "\t\t\tuint256 a = 1;\n" - VariableDeclarationStatement (Rule): # 113..131 "\t\t\tuint256 a = 1;\n" - - VariableDeclaration (Rule): # 113..125 "\t\t\tuint256 a" - - TypeName (Rule): # 113..123 "\t\t\tuint256" - - UintKeyword (Token): "uint256" # 116..123 - - Identifier (Token): "a" # 124..125 - - Equal (Token): "=" # 126..127 - - Expression (Rule): # 127..129 " 1" - - DecimalNumberExpression (Rule): # 127..129 " 1" - - DecimalLiteral (Token): "1" # 128..129 + - TypeName (Rule): # 113..123 "\t\t\tuint256" + - UintKeyword (Token): "uint256" # 116..123 + - Identifier (Token): "a" # 124..125 + - VariableDeclarationValue (Rule): # 125..129 " = 1" + - Equal (Token): "=" # 126..127 + - Expression (Rule): # 127..129 " 1" + - DecimalNumberExpression (Rule): # 127..129 " 1" + - DecimalLiteral (Token): "1" # 128..129 - Semicolon (Token): ";" # 129..130 - CloseBrace (Token): "}" # 133..134 - CloseBrace (Token): "}" # 136..137 @@ -93,14 +93,14 @@ Tree: - OpenBrace (Token): "{" # 155..156 - Statements (Rule): # 157..207 "\t\tuint256 x = 0;\n\t\tunchecked { invalid sequence }\n" - VariableDeclarationStatement (Rule): # 157..174 "\t\tuint256 x = 0;\n" - - VariableDeclaration (Rule): # 157..168 "\t\tuint256 x" - - TypeName (Rule): # 157..166 "\t\tuint256" - - UintKeyword (Token): "uint256" # 159..166 - - Identifier (Token): "x" # 167..168 - - Equal (Token): "=" # 169..170 - - Expression (Rule): # 170..172 " 0" - - DecimalNumberExpression (Rule): # 170..172 " 0" - - DecimalLiteral (Token): "0" # 171..172 + - TypeName (Rule): # 157..166 "\t\tuint256" + - UintKeyword (Token): "uint256" # 159..166 + - Identifier (Token): "x" # 167..168 + - VariableDeclarationValue (Rule): # 168..172 " = 0" + - Equal (Token): "=" # 169..170 + - Expression (Rule): # 170..172 " 0" + - DecimalNumberExpression (Rule): # 170..172 " 0" + - DecimalLiteral (Token): "0" # 171..172 - Semicolon (Token): ";" # 172..173 - UncheckedBlock (Rule): # 174..207 "\t\tunchecked { invalid sequence }\n" - UncheckedKeyword (Token): "unchecked" # 176..185 @@ -108,11 +108,10 @@ Tree: - OpenBrace (Token): "{" # 186..187 - Statements (Rule): # 187..205 " invalid sequence " - VariableDeclarationStatement (Rule): # 187..205 " invalid sequence " - - VariableDeclaration (Rule): # 187..204 " invalid sequence" - - TypeName (Rule): # 187..195 " invalid" - - IdentifierPath (Rule): # 187..195 " invalid" - - Identifier (Token): "invalid" # 188..195 - - Identifier (Token): "sequence" # 196..204 + - TypeName (Rule): # 187..195 " invalid" + - IdentifierPath (Rule): # 187..195 " invalid" + - Identifier (Token): "invalid" # 188..195 + - Identifier (Token): "sequence" # 196..204 - SKIPPED (Token): "" # 205..205 - CloseBrace (Token): "}" # 205..206 - CloseBrace (Token): "}" # 208..209 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 a9795edb8f..53671e0c8e 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 @@ -19,25 +19,25 @@ Tree: - OpenBrace (Token): "{" # 16..17 - Statements (Rule): # 18..40 " uint a = 1 + 2 * 3;\n" - VariableDeclarationStatement (Rule): # 18..40 " uint a = 1 + 2 * 3;\n" - - VariableDeclaration (Rule): # 18..26 " uint a" - - TypeName (Rule): # 18..24 " uint" - - UintKeyword (Token): "uint" # 20..24 - - Identifier (Token): "a" # 25..26 - - Equal (Token): "=" # 27..28 - - Expression (Rule): # 28..38 " 1 + 2 * 3" - - BinaryExpression (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" - - Expression (Rule): # 32..34 " 2" - - DecimalNumberExpression (Rule): # 32..34 " 2" - - DecimalLiteral (Token): "2" # 33..34 - - Asterisk (Token): "*" # 35..36 - - Expression (Rule): # 36..38 " 3" - - DecimalNumberExpression (Rule): # 36..38 " 3" - - DecimalLiteral (Token): "3" # 37..38 + - TypeName (Rule): # 18..24 " uint" + - UintKeyword (Token): "uint" # 20..24 + - Identifier (Token): "a" # 25..26 + - 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" + - 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" + - Expression (Rule): # 32..34 " 2" + - DecimalNumberExpression (Rule): # 32..34 " 2" + - DecimalLiteral (Token): "2" # 33..34 + - Asterisk (Token): "*" # 35..36 + - Expression (Rule): # 36..38 " 3" + - DecimalNumberExpression (Rule): # 36..38 " 3" + - DecimalLiteral (Token): "3" # 37..38 - Semicolon (Token): ";" # 38..39 - CloseBrace (Token): "}" # 40..41 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 83e5d8478e..813d1de643 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 @@ -43,24 +43,25 @@ Tree: - OpenBrace (Token): "{" # 33..34 - Statements (Rule): # 35..63 " uint256 arg = (1 + 2" - VariableDeclarationStatement (Rule): # 35..63 " uint256 arg = (1 + 2" - - VariableDeclaration (Rule): # 35..54 " uint256 arg" - - TypeName (Rule): # 35..50 " uint256" - - UintKeyword (Token): "uint256" # 43..50 - - Identifier (Token): "arg" # 51..54 - - Equal (Token): "=" # 55..56 - - Expression (Rule): # 56..63 " (1 + 2" - - TupleExpression (Rule): # 56..63 " (1 + 2" - - OpenParen (Token): "(" # 57..58 - - TupleValues (Rule): # 58..63 "1 + 2" - - Expression (Rule): # 58..63 "1 + 2" - - BinaryExpression (Rule): # 58..63 "1 + 2" - - Expression (Rule): # 58..59 "1" - - DecimalNumberExpression (Rule): # 58..59 "1" - - DecimalLiteral (Token): "1" # 58..59 - - Plus (Token): "+" # 60..61 - - Expression (Rule): # 61..63 " 2" - - DecimalNumberExpression (Rule): # 61..63 " 2" - - DecimalLiteral (Token): "2" # 62..63 + - TypeName (Rule): # 35..50 " uint256" + - UintKeyword (Token): "uint256" # 43..50 + - Identifier (Token): "arg" # 51..54 + - VariableDeclarationValue (Rule): # 54..63 " = (1 + 2" + - Equal (Token): "=" # 55..56 + - Expression (Rule): # 56..63 " (1 + 2" + - TupleExpression (Rule): # 56..63 " (1 + 2" + - OpenParen (Token): "(" # 57..58 + - TupleValues (Rule): # 58..63 "1 + 2" + - TupleValue (Rule): # 58..63 "1 + 2" + - Expression (Rule): # 58..63 "1 + 2" + - BinaryExpression (Rule): # 58..63 "1 + 2" + - Expression (Rule): # 58..59 "1" + - DecimalNumberExpression (Rule): # 58..59 "1" + - DecimalLiteral (Token): "1" # 58..59 + - Plus (Token): "+" # 60..61 + - Expression (Rule): # 61..63 " 2" + - DecimalNumberExpression (Rule): # 61..63 " 2" + - DecimalLiteral (Token): "2" # 62..63 - SKIPPED (Token): ";\n " # 63..69 - CloseBrace (Token): "}" # 69..70 - SKIPPED (Token): ")\n" # 70..72 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 b38458e410..8caf42d81b 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 @@ -43,24 +43,25 @@ Tree: - OpenBrace (Token): "{" # 33..34 - Statements (Rule): # 35..63 " uint256 arg = (1 + 2" - VariableDeclarationStatement (Rule): # 35..63 " uint256 arg = (1 + 2" - - VariableDeclaration (Rule): # 35..54 " uint256 arg" - - TypeName (Rule): # 35..50 " uint256" - - UintKeyword (Token): "uint256" # 43..50 - - Identifier (Token): "arg" # 51..54 - - Equal (Token): "=" # 55..56 - - Expression (Rule): # 56..63 " (1 + 2" - - TupleExpression (Rule): # 56..63 " (1 + 2" - - OpenParen (Token): "(" # 57..58 - - TupleValues (Rule): # 58..63 "1 + 2" - - Expression (Rule): # 58..63 "1 + 2" - - BinaryExpression (Rule): # 58..63 "1 + 2" - - Expression (Rule): # 58..59 "1" - - DecimalNumberExpression (Rule): # 58..59 "1" - - DecimalLiteral (Token): "1" # 58..59 - - Plus (Token): "+" # 60..61 - - Expression (Rule): # 61..63 " 2" - - DecimalNumberExpression (Rule): # 61..63 " 2" - - DecimalLiteral (Token): "2" # 62..63 + - TypeName (Rule): # 35..50 " uint256" + - UintKeyword (Token): "uint256" # 43..50 + - Identifier (Token): "arg" # 51..54 + - VariableDeclarationValue (Rule): # 54..63 " = (1 + 2" + - Equal (Token): "=" # 55..56 + - Expression (Rule): # 56..63 " (1 + 2" + - TupleExpression (Rule): # 56..63 " (1 + 2" + - OpenParen (Token): "(" # 57..58 + - TupleValues (Rule): # 58..63 "1 + 2" + - TupleValue (Rule): # 58..63 "1 + 2" + - Expression (Rule): # 58..63 "1 + 2" + - BinaryExpression (Rule): # 58..63 "1 + 2" + - Expression (Rule): # 58..59 "1" + - DecimalNumberExpression (Rule): # 58..59 "1" + - DecimalLiteral (Token): "1" # 58..59 + - Plus (Token): "+" # 60..61 + - Expression (Rule): # 61..63 " 2" + - DecimalNumberExpression (Rule): # 61..63 " 2" + - DecimalLiteral (Token): "2" # 62..63 - SKIPPED (Token): ";\n " # 63..69 - CloseBrace (Token): "}" # 69..70 - SKIPPED (Token): ")\n" # 70..72 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 ba5cb6f4a0..d2d6f3a43b 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 @@ -43,24 +43,25 @@ Tree: - OpenBrace (Token): "{" # 33..34 - Statements (Rule): # 35..63 " uint256 arg = (1 + 2" - VariableDeclarationStatement (Rule): # 35..63 " uint256 arg = (1 + 2" - - VariableDeclaration (Rule): # 35..54 " uint256 arg" - - TypeName (Rule): # 35..50 " uint256" - - UintKeyword (Token): "uint256" # 43..50 - - Identifier (Token): "arg" # 51..54 - - Equal (Token): "=" # 55..56 - - Expression (Rule): # 56..63 " (1 + 2" - - TupleExpression (Rule): # 56..63 " (1 + 2" - - OpenParen (Token): "(" # 57..58 - - TupleValues (Rule): # 58..63 "1 + 2" - - Expression (Rule): # 58..63 "1 + 2" - - BinaryExpression (Rule): # 58..63 "1 + 2" - - Expression (Rule): # 58..59 "1" - - DecimalNumberExpression (Rule): # 58..59 "1" - - DecimalLiteral (Token): "1" # 58..59 - - Plus (Token): "+" # 60..61 - - Expression (Rule): # 61..63 " 2" - - DecimalNumberExpression (Rule): # 61..63 " 2" - - DecimalLiteral (Token): "2" # 62..63 + - TypeName (Rule): # 35..50 " uint256" + - UintKeyword (Token): "uint256" # 43..50 + - Identifier (Token): "arg" # 51..54 + - VariableDeclarationValue (Rule): # 54..63 " = (1 + 2" + - Equal (Token): "=" # 55..56 + - Expression (Rule): # 56..63 " (1 + 2" + - TupleExpression (Rule): # 56..63 " (1 + 2" + - OpenParen (Token): "(" # 57..58 + - TupleValues (Rule): # 58..63 "1 + 2" + - TupleValue (Rule): # 58..63 "1 + 2" + - Expression (Rule): # 58..63 "1 + 2" + - BinaryExpression (Rule): # 58..63 "1 + 2" + - Expression (Rule): # 58..59 "1" + - DecimalNumberExpression (Rule): # 58..59 "1" + - DecimalLiteral (Token): "1" # 58..59 + - Plus (Token): "+" # 60..61 + - Expression (Rule): # 61..63 " 2" + - DecimalNumberExpression (Rule): # 61..63 " 2" + - DecimalLiteral (Token): "2" # 62..63 - SKIPPED (Token): ";\n " # 63..69 - CloseBrace (Token): "}" # 69..70 - SKIPPED (Token): ")\n" # 70..72 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 a1d4b6b05c..69b8095919 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 @@ -43,24 +43,25 @@ Tree: - OpenBrace (Token): "{" # 33..34 - Statements (Rule): # 35..63 " uint256 arg = (1 + 2" - VariableDeclarationStatement (Rule): # 35..63 " uint256 arg = (1 + 2" - - VariableDeclaration (Rule): # 35..54 " uint256 arg" - - TypeName (Rule): # 35..50 " uint256" - - UintKeyword (Token): "uint256" # 43..50 - - Identifier (Token): "arg" # 51..54 - - Equal (Token): "=" # 55..56 - - Expression (Rule): # 56..63 " (1 + 2" - - TupleExpression (Rule): # 56..63 " (1 + 2" - - OpenParen (Token): "(" # 57..58 - - TupleValues (Rule): # 58..63 "1 + 2" - - Expression (Rule): # 58..63 "1 + 2" - - BinaryExpression (Rule): # 58..63 "1 + 2" - - Expression (Rule): # 58..59 "1" - - DecimalNumberExpression (Rule): # 58..59 "1" - - DecimalLiteral (Token): "1" # 58..59 - - Plus (Token): "+" # 60..61 - - Expression (Rule): # 61..63 " 2" - - DecimalNumberExpression (Rule): # 61..63 " 2" - - DecimalLiteral (Token): "2" # 62..63 + - TypeName (Rule): # 35..50 " uint256" + - UintKeyword (Token): "uint256" # 43..50 + - Identifier (Token): "arg" # 51..54 + - VariableDeclarationValue (Rule): # 54..63 " = (1 + 2" + - Equal (Token): "=" # 55..56 + - Expression (Rule): # 56..63 " (1 + 2" + - TupleExpression (Rule): # 56..63 " (1 + 2" + - OpenParen (Token): "(" # 57..58 + - TupleValues (Rule): # 58..63 "1 + 2" + - TupleValue (Rule): # 58..63 "1 + 2" + - Expression (Rule): # 58..63 "1 + 2" + - BinaryExpression (Rule): # 58..63 "1 + 2" + - Expression (Rule): # 58..59 "1" + - DecimalNumberExpression (Rule): # 58..59 "1" + - DecimalLiteral (Token): "1" # 58..59 + - Plus (Token): "+" # 60..61 + - Expression (Rule): # 61..63 " 2" + - DecimalNumberExpression (Rule): # 61..63 " 2" + - DecimalLiteral (Token): "2" # 62..63 - SKIPPED (Token): ";\n " # 63..69 - CloseBrace (Token): "}" # 69..70 - SKIPPED (Token): ")\n" # 70..72 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 380df160a3..274b5368dc 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 @@ -43,24 +43,25 @@ Tree: - OpenBrace (Token): "{" # 33..34 - Statements (Rule): # 35..63 " uint256 arg = (1 + 2" - VariableDeclarationStatement (Rule): # 35..63 " uint256 arg = (1 + 2" - - VariableDeclaration (Rule): # 35..54 " uint256 arg" - - TypeName (Rule): # 35..50 " uint256" - - UintKeyword (Token): "uint256" # 43..50 - - Identifier (Token): "arg" # 51..54 - - Equal (Token): "=" # 55..56 - - Expression (Rule): # 56..63 " (1 + 2" - - TupleExpression (Rule): # 56..63 " (1 + 2" - - OpenParen (Token): "(" # 57..58 - - TupleValues (Rule): # 58..63 "1 + 2" - - Expression (Rule): # 58..63 "1 + 2" - - BinaryExpression (Rule): # 58..63 "1 + 2" - - Expression (Rule): # 58..59 "1" - - DecimalNumberExpression (Rule): # 58..59 "1" - - DecimalLiteral (Token): "1" # 58..59 - - Plus (Token): "+" # 60..61 - - Expression (Rule): # 61..63 " 2" - - DecimalNumberExpression (Rule): # 61..63 " 2" - - DecimalLiteral (Token): "2" # 62..63 + - TypeName (Rule): # 35..50 " uint256" + - UintKeyword (Token): "uint256" # 43..50 + - Identifier (Token): "arg" # 51..54 + - VariableDeclarationValue (Rule): # 54..63 " = (1 + 2" + - Equal (Token): "=" # 55..56 + - Expression (Rule): # 56..63 " (1 + 2" + - TupleExpression (Rule): # 56..63 " (1 + 2" + - OpenParen (Token): "(" # 57..58 + - TupleValues (Rule): # 58..63 "1 + 2" + - TupleValue (Rule): # 58..63 "1 + 2" + - Expression (Rule): # 58..63 "1 + 2" + - BinaryExpression (Rule): # 58..63 "1 + 2" + - Expression (Rule): # 58..59 "1" + - DecimalNumberExpression (Rule): # 58..59 "1" + - DecimalLiteral (Token): "1" # 58..59 + - Plus (Token): "+" # 60..61 + - Expression (Rule): # 61..63 " 2" + - DecimalNumberExpression (Rule): # 61..63 " 2" + - DecimalLiteral (Token): "2" # 62..63 - SKIPPED (Token): ";\n " # 63..69 - CloseBrace (Token): "}" # 69..70 - SKIPPED (Token): ")\n" # 70..72 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 4dca0a60d3..4c3d6b8f2d 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 @@ -43,24 +43,25 @@ Tree: - OpenBrace (Token): "{" # 33..34 - Statements (Rule): # 35..63 " uint256 arg = (1 + 2" - VariableDeclarationStatement (Rule): # 35..63 " uint256 arg = (1 + 2" - - VariableDeclaration (Rule): # 35..54 " uint256 arg" - - TypeName (Rule): # 35..50 " uint256" - - UintKeyword (Token): "uint256" # 43..50 - - Identifier (Token): "arg" # 51..54 - - Equal (Token): "=" # 55..56 - - Expression (Rule): # 56..63 " (1 + 2" - - TupleExpression (Rule): # 56..63 " (1 + 2" - - OpenParen (Token): "(" # 57..58 - - TupleValues (Rule): # 58..63 "1 + 2" - - Expression (Rule): # 58..63 "1 + 2" - - BinaryExpression (Rule): # 58..63 "1 + 2" - - Expression (Rule): # 58..59 "1" - - DecimalNumberExpression (Rule): # 58..59 "1" - - DecimalLiteral (Token): "1" # 58..59 - - Plus (Token): "+" # 60..61 - - Expression (Rule): # 61..63 " 2" - - DecimalNumberExpression (Rule): # 61..63 " 2" - - DecimalLiteral (Token): "2" # 62..63 + - TypeName (Rule): # 35..50 " uint256" + - UintKeyword (Token): "uint256" # 43..50 + - Identifier (Token): "arg" # 51..54 + - VariableDeclarationValue (Rule): # 54..63 " = (1 + 2" + - Equal (Token): "=" # 55..56 + - Expression (Rule): # 56..63 " (1 + 2" + - TupleExpression (Rule): # 56..63 " (1 + 2" + - OpenParen (Token): "(" # 57..58 + - TupleValues (Rule): # 58..63 "1 + 2" + - TupleValue (Rule): # 58..63 "1 + 2" + - Expression (Rule): # 58..63 "1 + 2" + - BinaryExpression (Rule): # 58..63 "1 + 2" + - Expression (Rule): # 58..59 "1" + - DecimalNumberExpression (Rule): # 58..59 "1" + - DecimalLiteral (Token): "1" # 58..59 + - Plus (Token): "+" # 60..61 + - Expression (Rule): # 61..63 " 2" + - DecimalNumberExpression (Rule): # 61..63 " 2" + - DecimalLiteral (Token): "2" # 62..63 - SKIPPED (Token): ";\n " # 63..69 - CloseBrace (Token): "}" # 69..70 - SKIPPED (Token): ")\n" # 70..72 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 5a4d7a48a1..f370c2181c 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 @@ -43,24 +43,25 @@ Tree: - OpenBrace (Token): "{" # 33..34 - Statements (Rule): # 35..63 " uint256 arg = (1 + 2" - VariableDeclarationStatement (Rule): # 35..63 " uint256 arg = (1 + 2" - - VariableDeclaration (Rule): # 35..54 " uint256 arg" - - TypeName (Rule): # 35..50 " uint256" - - UintKeyword (Token): "uint256" # 43..50 - - Identifier (Token): "arg" # 51..54 - - Equal (Token): "=" # 55..56 - - Expression (Rule): # 56..63 " (1 + 2" - - TupleExpression (Rule): # 56..63 " (1 + 2" - - OpenParen (Token): "(" # 57..58 - - TupleValues (Rule): # 58..63 "1 + 2" - - Expression (Rule): # 58..63 "1 + 2" - - BinaryExpression (Rule): # 58..63 "1 + 2" - - Expression (Rule): # 58..59 "1" - - DecimalNumberExpression (Rule): # 58..59 "1" - - DecimalLiteral (Token): "1" # 58..59 - - Plus (Token): "+" # 60..61 - - Expression (Rule): # 61..63 " 2" - - DecimalNumberExpression (Rule): # 61..63 " 2" - - DecimalLiteral (Token): "2" # 62..63 + - TypeName (Rule): # 35..50 " uint256" + - UintKeyword (Token): "uint256" # 43..50 + - Identifier (Token): "arg" # 51..54 + - VariableDeclarationValue (Rule): # 54..63 " = (1 + 2" + - Equal (Token): "=" # 55..56 + - Expression (Rule): # 56..63 " (1 + 2" + - TupleExpression (Rule): # 56..63 " (1 + 2" + - OpenParen (Token): "(" # 57..58 + - TupleValues (Rule): # 58..63 "1 + 2" + - TupleValue (Rule): # 58..63 "1 + 2" + - Expression (Rule): # 58..63 "1 + 2" + - BinaryExpression (Rule): # 58..63 "1 + 2" + - Expression (Rule): # 58..59 "1" + - DecimalNumberExpression (Rule): # 58..59 "1" + - DecimalLiteral (Token): "1" # 58..59 + - Plus (Token): "+" # 60..61 + - Expression (Rule): # 61..63 " 2" + - DecimalNumberExpression (Rule): # 61..63 " 2" + - DecimalLiteral (Token): "2" # 62..63 - SKIPPED (Token): ";\n " # 63..69 - CloseBrace (Token): "}" # 69..70 - SKIPPED (Token): ")\n" # 70..72 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 dc0f8b1f30..dad44c7d54 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 @@ -43,24 +43,25 @@ Tree: - OpenBrace (Token): "{" # 33..34 - Statements (Rule): # 35..63 " uint256 arg = (1 + 2" - VariableDeclarationStatement (Rule): # 35..63 " uint256 arg = (1 + 2" - - VariableDeclaration (Rule): # 35..54 " uint256 arg" - - TypeName (Rule): # 35..50 " uint256" - - UintKeyword (Token): "uint256" # 43..50 - - Identifier (Token): "arg" # 51..54 - - Equal (Token): "=" # 55..56 - - Expression (Rule): # 56..63 " (1 + 2" - - TupleExpression (Rule): # 56..63 " (1 + 2" - - OpenParen (Token): "(" # 57..58 - - TupleValues (Rule): # 58..63 "1 + 2" - - Expression (Rule): # 58..63 "1 + 2" - - BinaryExpression (Rule): # 58..63 "1 + 2" - - Expression (Rule): # 58..59 "1" - - DecimalNumberExpression (Rule): # 58..59 "1" - - DecimalLiteral (Token): "1" # 58..59 - - Plus (Token): "+" # 60..61 - - Expression (Rule): # 61..63 " 2" - - DecimalNumberExpression (Rule): # 61..63 " 2" - - DecimalLiteral (Token): "2" # 62..63 + - TypeName (Rule): # 35..50 " uint256" + - UintKeyword (Token): "uint256" # 43..50 + - Identifier (Token): "arg" # 51..54 + - VariableDeclarationValue (Rule): # 54..63 " = (1 + 2" + - Equal (Token): "=" # 55..56 + - Expression (Rule): # 56..63 " (1 + 2" + - TupleExpression (Rule): # 56..63 " (1 + 2" + - OpenParen (Token): "(" # 57..58 + - TupleValues (Rule): # 58..63 "1 + 2" + - TupleValue (Rule): # 58..63 "1 + 2" + - Expression (Rule): # 58..63 "1 + 2" + - BinaryExpression (Rule): # 58..63 "1 + 2" + - Expression (Rule): # 58..59 "1" + - DecimalNumberExpression (Rule): # 58..59 "1" + - DecimalLiteral (Token): "1" # 58..59 + - Plus (Token): "+" # 60..61 + - Expression (Rule): # 61..63 " 2" + - DecimalNumberExpression (Rule): # 61..63 " 2" + - DecimalLiteral (Token): "2" # 62..63 - SKIPPED (Token): ";\n " # 63..69 - CloseBrace (Token): "}" # 69..70 - SKIPPED (Token): ")\n" # 70..72 diff --git a/crates/solidity/testing/snapshots/cst_output/ContractMembers/separated_recovery/generated/0.4.11-failure.yml b/crates/solidity/testing/snapshots/cst_output/ContractMembers/separated_recovery/generated/0.4.11-failure.yml index 8fcb21aac0..0dd29f73c9 100644 --- a/crates/solidity/testing/snapshots/cst_output/ContractMembers/separated_recovery/generated/0.4.11-failure.yml +++ b/crates/solidity/testing/snapshots/cst_output/ContractMembers/separated_recovery/generated/0.4.11-failure.yml @@ -108,7 +108,7 @@ Tree: - ModifierInvocation (Rule): # 14..76 " override(some.ident unexpected tokens, ISomeInter..." - IdentifierPath (Rule): # 14..23 " override" - Identifier (Token): "override" # 15..23 - - ArgumentsDeclaration (Rule): # 23..76 "(some.ident unexpected tokens, ISomeInterface, Oth..." + - PositionalArgumentsDeclaration (Rule): # 23..76 "(some.ident unexpected tokens, ISomeInterface, Oth..." - OpenParen (Token): "(" # 23..24 - PositionalArguments (Rule): # 24..34 "some.ident" - Expression (Rule): # 24..34 "some.ident" @@ -186,7 +186,7 @@ Tree: - ModifierInvocation (Rule): # 326..386 " override(some.ident, /* empty */, other.arg.here,..." - IdentifierPath (Rule): # 326..335 " override" - Identifier (Token): "override" # 327..335 - - ArgumentsDeclaration (Rule): # 335..386 "(some.ident, /* empty */, other.arg.here, and.here..." + - PositionalArgumentsDeclaration (Rule): # 335..386 "(some.ident, /* empty */, other.arg.here, and.here..." - OpenParen (Token): "(" # 335..336 - PositionalArguments (Rule): # 336..347 "some.ident," - Expression (Rule): # 336..346 "some.ident" @@ -211,7 +211,7 @@ Tree: - ModifierInvocation (Rule): # 412..487 " override(some.ident, next.do.that, other.while, n..." - IdentifierPath (Rule): # 412..421 " override" - Identifier (Token): "override" # 413..421 - - ArgumentsDeclaration (Rule): # 421..487 "(some.ident, next.do.that, other.while, next.one, ..." + - PositionalArgumentsDeclaration (Rule): # 421..487 "(some.ident, next.do.that, other.while, next.one, ..." - OpenParen (Token): "(" # 421..422 - PositionalArguments (Rule): # 422..470 "some.ident, next.do.that, other.while, next.one," - Expression (Rule): # 422..432 "some.ident" @@ -251,7 +251,7 @@ Tree: - ModifierInvocation (Rule): # 512..558 " override(some., next.arg, next.one, ultimate)" - IdentifierPath (Rule): # 512..521 " override" - Identifier (Token): "override" # 513..521 - - ArgumentsDeclaration (Rule): # 521..558 "(some., next.arg, next.one, ultimate)" + - PositionalArgumentsDeclaration (Rule): # 521..558 "(some., next.arg, next.one, ultimate)" - OpenParen (Token): "(" # 521..522 - PositionalArguments (Rule): # 522..557 "some., next.arg, next.one, ultimate" - Expression (Rule): # 522..527 "some." diff --git a/crates/solidity/testing/snapshots/cst_output/ContractMembers/separated_recovery/generated/0.5.0-failure.yml b/crates/solidity/testing/snapshots/cst_output/ContractMembers/separated_recovery/generated/0.5.0-failure.yml index 1613c29997..0d20c0e724 100644 --- a/crates/solidity/testing/snapshots/cst_output/ContractMembers/separated_recovery/generated/0.5.0-failure.yml +++ b/crates/solidity/testing/snapshots/cst_output/ContractMembers/separated_recovery/generated/0.5.0-failure.yml @@ -107,14 +107,15 @@ Tree: - FunctionAttributes (Rule): # 14..83 " override(some.ident unexpected tokens, ISomeInter..." - OverrideSpecifier (Rule): # 14..76 " override(some.ident unexpected tokens, ISomeInter..." - OverrideKeyword (Token): "override" # 15..23 - - OpenParen (Token): "(" # 23..24 - - OverridePaths (Rule): # 24..34 "some.ident" - - IdentifierPath (Rule): # 24..34 "some.ident" - - Identifier (Token): "some" # 24..28 - - Period (Token): "." # 28..29 - - Identifier (Token): "ident" # 29..34 - - SKIPPED (Token): "unexpected tokens, ISomeInterface, Other" # 35..75 - - CloseParen (Token): ")" # 75..76 + - OverridePathsDeclaration (Rule): # 23..76 "(some.ident unexpected tokens, ISomeInterface, Oth..." + - OpenParen (Token): "(" # 23..24 + - OverridePaths (Rule): # 24..34 "some.ident" + - IdentifierPath (Rule): # 24..34 "some.ident" + - Identifier (Token): "some" # 24..28 + - Period (Token): "." # 28..29 + - Identifier (Token): "ident" # 29..34 + - SKIPPED (Token): "unexpected tokens, ISomeInterface, Other" # 35..75 + - CloseParen (Token): ")" # 75..76 - PublicKeyword (Token): "public" # 77..83 - Block (Rule): # 83..309 " {\n msg.sender.call{do: 1, arg: 1 }();\n msg.send..." - OpenBrace (Token): "{" # 84..85 @@ -181,17 +182,18 @@ Tree: - FunctionAttributes (Rule): # 326..386 " override(some.ident, /* empty */, other.arg.here,..." - OverrideSpecifier (Rule): # 326..386 " override(some.ident, /* empty */, other.arg.here,..." - OverrideKeyword (Token): "override" # 327..335 - - OpenParen (Token): "(" # 335..336 - - OverridePaths (Rule): # 336..347 "some.ident," - - IdentifierPath (Rule): # 336..346 "some.ident" - - Identifier (Token): "some" # 336..340 - - Period (Token): "." # 340..341 - - Identifier (Token): "ident" # 341..346 - - Comma (Token): "," # 346..347 - - LeadingTrivia (Rule): # 347..359 " /* empty */" - - MultilineComment (Trivia): "/* empty */" # 348..359 - - SKIPPED (Token): ", other.arg.here, and.here" # 359..385 - - CloseParen (Token): ")" # 385..386 + - OverridePathsDeclaration (Rule): # 335..386 "(some.ident, /* empty */, other.arg.here, and.here..." + - OpenParen (Token): "(" # 335..336 + - OverridePaths (Rule): # 336..347 "some.ident," + - IdentifierPath (Rule): # 336..346 "some.ident" + - Identifier (Token): "some" # 336..340 + - Period (Token): "." # 340..341 + - Identifier (Token): "ident" # 341..346 + - Comma (Token): "," # 346..347 + - LeadingTrivia (Rule): # 347..359 " /* empty */" + - MultilineComment (Trivia): "/* empty */" # 348..359 + - SKIPPED (Token): ", other.arg.here, and.here" # 359..385 + - CloseParen (Token): ")" # 385..386 - Semicolon (Token): ";" # 386..387 - FunctionDefinition (Rule): # 388..489 "\nfunction nested_lists() override(some.ident, next..." - FunctionKeyword (Token): "function" # 389..397 @@ -202,30 +204,31 @@ Tree: - FunctionAttributes (Rule): # 412..487 " override(some.ident, next.do.that, other.while, n..." - OverrideSpecifier (Rule): # 412..487 " override(some.ident, next.do.that, other.while, n..." - OverrideKeyword (Token): "override" # 413..421 - - OpenParen (Token): "(" # 421..422 - - OverridePaths (Rule): # 422..470 "some.ident, next.do.that, other.while, next.one," - - IdentifierPath (Rule): # 422..432 "some.ident" - - Identifier (Token): "some" # 422..426 - - Period (Token): "." # 426..427 - - Identifier (Token): "ident" # 427..432 - - Comma (Token): "," # 432..433 - - IdentifierPath (Rule): # 433..439 " next." - - Identifier (Token): "next" # 434..438 - - Period (Token): "." # 438..439 - - SKIPPED (Token): "do.that" # 439..446 - - Comma (Token): "," # 446..447 - - IdentifierPath (Rule): # 447..454 " other." - - Identifier (Token): "other" # 448..453 - - Period (Token): "." # 453..454 - - SKIPPED (Token): "while" # 454..459 - - Comma (Token): "," # 459..460 - - IdentifierPath (Rule): # 460..469 " next.one" - - Identifier (Token): "next" # 461..465 - - Period (Token): "." # 465..466 - - Identifier (Token): "one" # 466..469 - - Comma (Token): "," # 469..470 - - SKIPPED (Token): "final, ultimate" # 471..486 - - CloseParen (Token): ")" # 486..487 + - OverridePathsDeclaration (Rule): # 421..487 "(some.ident, next.do.that, other.while, next.one, ..." + - OpenParen (Token): "(" # 421..422 + - OverridePaths (Rule): # 422..470 "some.ident, next.do.that, other.while, next.one," + - IdentifierPath (Rule): # 422..432 "some.ident" + - Identifier (Token): "some" # 422..426 + - Period (Token): "." # 426..427 + - Identifier (Token): "ident" # 427..432 + - Comma (Token): "," # 432..433 + - IdentifierPath (Rule): # 433..439 " next." + - Identifier (Token): "next" # 434..438 + - Period (Token): "." # 438..439 + - SKIPPED (Token): "do.that" # 439..446 + - Comma (Token): "," # 446..447 + - IdentifierPath (Rule): # 447..454 " other." + - Identifier (Token): "other" # 448..453 + - Period (Token): "." # 453..454 + - SKIPPED (Token): "while" # 454..459 + - Comma (Token): "," # 459..460 + - IdentifierPath (Rule): # 460..469 " next.one" + - Identifier (Token): "next" # 461..465 + - Period (Token): "." # 465..466 + - Identifier (Token): "one" # 466..469 + - Comma (Token): "," # 469..470 + - SKIPPED (Token): "final, ultimate" # 471..486 + - CloseParen (Token): ")" # 486..487 - Semicolon (Token): ";" # 487..488 - FunctionDefinition (Rule): # 489..560 "function nested_lists() override(some., next.arg, ..." - FunctionKeyword (Token): "function" # 489..497 @@ -236,24 +239,25 @@ Tree: - FunctionAttributes (Rule): # 512..558 " override(some., next.arg, next.one, ultimate)" - OverrideSpecifier (Rule): # 512..558 " override(some., next.arg, next.one, ultimate)" - OverrideKeyword (Token): "override" # 513..521 - - OpenParen (Token): "(" # 521..522 - - OverridePaths (Rule): # 522..557 "some., next.arg, next.one, ultimate" - - IdentifierPath (Rule): # 522..527 "some." - - Identifier (Token): "some" # 522..526 - - Period (Token): "." # 526..527 - - SKIPPED (Token): "" # 527..527 - - Comma (Token): "," # 527..528 - - IdentifierPath (Rule): # 528..537 " next.arg" - - Identifier (Token): "next" # 529..533 - - Period (Token): "." # 533..534 - - Identifier (Token): "arg" # 534..537 - - Comma (Token): "," # 537..538 - - IdentifierPath (Rule): # 538..547 " next.one" - - Identifier (Token): "next" # 539..543 - - Period (Token): "." # 543..544 - - Identifier (Token): "one" # 544..547 - - Comma (Token): "," # 547..548 - - IdentifierPath (Rule): # 548..557 " ultimate" - - Identifier (Token): "ultimate" # 549..557 - - CloseParen (Token): ")" # 557..558 + - OverridePathsDeclaration (Rule): # 521..558 "(some., next.arg, next.one, ultimate)" + - OpenParen (Token): "(" # 521..522 + - OverridePaths (Rule): # 522..557 "some., next.arg, next.one, ultimate" + - IdentifierPath (Rule): # 522..527 "some." + - Identifier (Token): "some" # 522..526 + - Period (Token): "." # 526..527 + - SKIPPED (Token): "" # 527..527 + - Comma (Token): "," # 527..528 + - IdentifierPath (Rule): # 528..537 " next.arg" + - Identifier (Token): "next" # 529..533 + - Period (Token): "." # 533..534 + - Identifier (Token): "arg" # 534..537 + - Comma (Token): "," # 537..538 + - IdentifierPath (Rule): # 538..547 " next.one" + - Identifier (Token): "next" # 539..543 + - Period (Token): "." # 543..544 + - Identifier (Token): "one" # 544..547 + - Comma (Token): "," # 547..548 + - IdentifierPath (Rule): # 548..557 " ultimate" + - Identifier (Token): "ultimate" # 549..557 + - CloseParen (Token): ")" # 557..558 - Semicolon (Token): ";" # 558..559 diff --git a/crates/solidity/testing/snapshots/cst_output/ContractMembers/separated_recovery/generated/0.6.2-failure.yml b/crates/solidity/testing/snapshots/cst_output/ContractMembers/separated_recovery/generated/0.6.2-failure.yml index 4f59aec02e..e71e12ef12 100644 --- a/crates/solidity/testing/snapshots/cst_output/ContractMembers/separated_recovery/generated/0.6.2-failure.yml +++ b/crates/solidity/testing/snapshots/cst_output/ContractMembers/separated_recovery/generated/0.6.2-failure.yml @@ -123,14 +123,15 @@ Tree: - FunctionAttributes (Rule): # 14..83 " override(some.ident unexpected tokens, ISomeInter..." - OverrideSpecifier (Rule): # 14..76 " override(some.ident unexpected tokens, ISomeInter..." - OverrideKeyword (Token): "override" # 15..23 - - OpenParen (Token): "(" # 23..24 - - OverridePaths (Rule): # 24..34 "some.ident" - - IdentifierPath (Rule): # 24..34 "some.ident" - - Identifier (Token): "some" # 24..28 - - Period (Token): "." # 28..29 - - Identifier (Token): "ident" # 29..34 - - SKIPPED (Token): "unexpected tokens, ISomeInterface, Other" # 35..75 - - CloseParen (Token): ")" # 75..76 + - OverridePathsDeclaration (Rule): # 23..76 "(some.ident unexpected tokens, ISomeInterface, Oth..." + - OpenParen (Token): "(" # 23..24 + - OverridePaths (Rule): # 24..34 "some.ident" + - IdentifierPath (Rule): # 24..34 "some.ident" + - Identifier (Token): "some" # 24..28 + - Period (Token): "." # 28..29 + - Identifier (Token): "ident" # 29..34 + - SKIPPED (Token): "unexpected tokens, ISomeInterface, Other" # 35..75 + - CloseParen (Token): ")" # 75..76 - PublicKeyword (Token): "public" # 77..83 - Block (Rule): # 83..309 " {\n msg.sender.call{do: 1, arg: 1 }();\n msg.send..." - OpenBrace (Token): "{" # 84..85 @@ -148,12 +149,12 @@ Tree: - Identifier (Token): "sender" # 92..98 - Period (Token): "." # 98..99 - Identifier (Token): "call" # 99..103 - - FunctionCallOptions (Rule): # 103..119 "{do: 1, arg: 1 }" - - NamedArgumentsDeclaration (Rule): # 103..119 "{do: 1, arg: 1 }" + - NamedArgumentGroups (Rule): # 103..119 "{do: 1, arg: 1 }" + - NamedArgumentGroup (Rule): # 103..119 "{do: 1, arg: 1 }" - OpenBrace (Token): "{" # 103..104 - SKIPPED (Token): "do: 1, arg: 1 " # 104..118 - CloseBrace (Token): "}" # 118..119 - - ArgumentsDeclaration (Rule): # 119..121 "()" + - PositionalArgumentsDeclaration (Rule): # 119..121 "()" - OpenParen (Token): "(" # 119..120 - CloseParen (Token): ")" # 120..121 - Semicolon (Token): ";" # 121..122 @@ -170,12 +171,12 @@ Tree: - Identifier (Token): "sender" # 129..135 - Period (Token): "." # 135..136 - Identifier (Token): "call" # 136..140 - - FunctionCallOptions (Rule): # 140..163 "{, empty: 1, parse: 2 }" - - NamedArgumentsDeclaration (Rule): # 140..163 "{, empty: 1, parse: 2 }" + - NamedArgumentGroups (Rule): # 140..163 "{, empty: 1, parse: 2 }" + - NamedArgumentGroup (Rule): # 140..163 "{, empty: 1, parse: 2 }" - OpenBrace (Token): "{" # 140..141 - SKIPPED (Token): ", empty: 1, parse: 2 " # 141..162 - CloseBrace (Token): "}" # 162..163 - - ArgumentsDeclaration (Rule): # 163..165 "()" + - PositionalArgumentsDeclaration (Rule): # 163..165 "()" - OpenParen (Token): "(" # 163..164 - CloseParen (Token): ")" # 164..165 - Semicolon (Token): ";" # 165..166 @@ -192,8 +193,8 @@ Tree: - Identifier (Token): "sender" # 173..179 - Period (Token): "." # 179..180 - Identifier (Token): "call" # 180..184 - - FunctionCallOptions (Rule): # 184..226 "{arg: 1, missing_expr: , no_semicolon, , }" - - NamedArgumentsDeclaration (Rule): # 184..226 "{arg: 1, missing_expr: , no_semicolon, , }" + - NamedArgumentGroups (Rule): # 184..226 "{arg: 1, missing_expr: , no_semicolon, , }" + - NamedArgumentGroup (Rule): # 184..226 "{arg: 1, missing_expr: , no_semicolon, , }" - OpenBrace (Token): "{" # 184..185 - NamedArguments (Rule): # 185..222 "arg: 1, missing_expr: , no_semicolon," - NamedArgument (Rule): # 185..191 "arg: 1" @@ -214,7 +215,7 @@ Tree: - Comma (Token): "," # 221..222 - SKIPPED (Token): ", " # 223..225 - CloseBrace (Token): "}" # 225..226 - - ArgumentsDeclaration (Rule): # 226..228 "()" + - PositionalArgumentsDeclaration (Rule): # 226..228 "()" - OpenParen (Token): "(" # 226..227 - CloseParen (Token): ")" # 227..228 - Semicolon (Token): ";" # 228..229 @@ -231,8 +232,8 @@ Tree: - Identifier (Token): "sender" # 236..242 - Period (Token): "." # 242..243 - Identifier (Token): "call" # 243..247 - - FunctionCallOptions (Rule): # 247..302 "{arg: 1 unexpected tokens, not: 2, recovered, yet:..." - - NamedArgumentsDeclaration (Rule): # 247..302 "{arg: 1 unexpected tokens, not: 2, recovered, yet:..." + - NamedArgumentGroups (Rule): # 247..302 "{arg: 1 unexpected tokens, not: 2, recovered, yet:..." + - NamedArgumentGroup (Rule): # 247..302 "{arg: 1 unexpected tokens, not: 2, recovered, yet:..." - OpenBrace (Token): "{" # 247..248 - NamedArguments (Rule): # 248..254 "arg: 1" - NamedArgument (Rule): # 248..254 "arg: 1" @@ -243,7 +244,7 @@ Tree: - DecimalLiteral (Token): "1" # 253..254 - SKIPPED (Token): "unexpected tokens, not: 2, recovered, yet: 3, " # 255..301 - CloseBrace (Token): "}" # 301..302 - - ArgumentsDeclaration (Rule): # 302..304 "()" + - PositionalArgumentsDeclaration (Rule): # 302..304 "()" - OpenParen (Token): "(" # 302..303 - CloseParen (Token): ")" # 303..304 - Semicolon (Token): ";" # 304..305 @@ -257,17 +258,18 @@ Tree: - FunctionAttributes (Rule): # 326..386 " override(some.ident, /* empty */, other.arg.here,..." - OverrideSpecifier (Rule): # 326..386 " override(some.ident, /* empty */, other.arg.here,..." - OverrideKeyword (Token): "override" # 327..335 - - OpenParen (Token): "(" # 335..336 - - OverridePaths (Rule): # 336..347 "some.ident," - - IdentifierPath (Rule): # 336..346 "some.ident" - - Identifier (Token): "some" # 336..340 - - Period (Token): "." # 340..341 - - Identifier (Token): "ident" # 341..346 - - Comma (Token): "," # 346..347 - - LeadingTrivia (Rule): # 347..359 " /* empty */" - - MultilineComment (Trivia): "/* empty */" # 348..359 - - SKIPPED (Token): ", other.arg.here, and.here" # 359..385 - - CloseParen (Token): ")" # 385..386 + - OverridePathsDeclaration (Rule): # 335..386 "(some.ident, /* empty */, other.arg.here, and.here..." + - OpenParen (Token): "(" # 335..336 + - OverridePaths (Rule): # 336..347 "some.ident," + - IdentifierPath (Rule): # 336..346 "some.ident" + - Identifier (Token): "some" # 336..340 + - Period (Token): "." # 340..341 + - Identifier (Token): "ident" # 341..346 + - Comma (Token): "," # 346..347 + - LeadingTrivia (Rule): # 347..359 " /* empty */" + - MultilineComment (Trivia): "/* empty */" # 348..359 + - SKIPPED (Token): ", other.arg.here, and.here" # 359..385 + - CloseParen (Token): ")" # 385..386 - Semicolon (Token): ";" # 386..387 - FunctionDefinition (Rule): # 388..489 "\nfunction nested_lists() override(some.ident, next..." - FunctionKeyword (Token): "function" # 389..397 @@ -278,30 +280,31 @@ Tree: - FunctionAttributes (Rule): # 412..487 " override(some.ident, next.do.that, other.while, n..." - OverrideSpecifier (Rule): # 412..487 " override(some.ident, next.do.that, other.while, n..." - OverrideKeyword (Token): "override" # 413..421 - - OpenParen (Token): "(" # 421..422 - - OverridePaths (Rule): # 422..470 "some.ident, next.do.that, other.while, next.one," - - IdentifierPath (Rule): # 422..432 "some.ident" - - Identifier (Token): "some" # 422..426 - - Period (Token): "." # 426..427 - - Identifier (Token): "ident" # 427..432 - - Comma (Token): "," # 432..433 - - IdentifierPath (Rule): # 433..439 " next." - - Identifier (Token): "next" # 434..438 - - Period (Token): "." # 438..439 - - SKIPPED (Token): "do.that" # 439..446 - - Comma (Token): "," # 446..447 - - IdentifierPath (Rule): # 447..454 " other." - - Identifier (Token): "other" # 448..453 - - Period (Token): "." # 453..454 - - SKIPPED (Token): "while" # 454..459 - - Comma (Token): "," # 459..460 - - IdentifierPath (Rule): # 460..469 " next.one" - - Identifier (Token): "next" # 461..465 - - Period (Token): "." # 465..466 - - Identifier (Token): "one" # 466..469 - - Comma (Token): "," # 469..470 - - SKIPPED (Token): "final, ultimate" # 471..486 - - CloseParen (Token): ")" # 486..487 + - OverridePathsDeclaration (Rule): # 421..487 "(some.ident, next.do.that, other.while, next.one, ..." + - OpenParen (Token): "(" # 421..422 + - OverridePaths (Rule): # 422..470 "some.ident, next.do.that, other.while, next.one," + - IdentifierPath (Rule): # 422..432 "some.ident" + - Identifier (Token): "some" # 422..426 + - Period (Token): "." # 426..427 + - Identifier (Token): "ident" # 427..432 + - Comma (Token): "," # 432..433 + - IdentifierPath (Rule): # 433..439 " next." + - Identifier (Token): "next" # 434..438 + - Period (Token): "." # 438..439 + - SKIPPED (Token): "do.that" # 439..446 + - Comma (Token): "," # 446..447 + - IdentifierPath (Rule): # 447..454 " other." + - Identifier (Token): "other" # 448..453 + - Period (Token): "." # 453..454 + - SKIPPED (Token): "while" # 454..459 + - Comma (Token): "," # 459..460 + - IdentifierPath (Rule): # 460..469 " next.one" + - Identifier (Token): "next" # 461..465 + - Period (Token): "." # 465..466 + - Identifier (Token): "one" # 466..469 + - Comma (Token): "," # 469..470 + - SKIPPED (Token): "final, ultimate" # 471..486 + - CloseParen (Token): ")" # 486..487 - Semicolon (Token): ";" # 487..488 - FunctionDefinition (Rule): # 489..560 "function nested_lists() override(some., next.arg, ..." - FunctionKeyword (Token): "function" # 489..497 @@ -312,24 +315,25 @@ Tree: - FunctionAttributes (Rule): # 512..558 " override(some., next.arg, next.one, ultimate)" - OverrideSpecifier (Rule): # 512..558 " override(some., next.arg, next.one, ultimate)" - OverrideKeyword (Token): "override" # 513..521 - - OpenParen (Token): "(" # 521..522 - - OverridePaths (Rule): # 522..557 "some., next.arg, next.one, ultimate" - - IdentifierPath (Rule): # 522..527 "some." - - Identifier (Token): "some" # 522..526 - - Period (Token): "." # 526..527 - - SKIPPED (Token): "" # 527..527 - - Comma (Token): "," # 527..528 - - IdentifierPath (Rule): # 528..537 " next.arg" - - Identifier (Token): "next" # 529..533 - - Period (Token): "." # 533..534 - - Identifier (Token): "arg" # 534..537 - - Comma (Token): "," # 537..538 - - IdentifierPath (Rule): # 538..547 " next.one" - - Identifier (Token): "next" # 539..543 - - Period (Token): "." # 543..544 - - Identifier (Token): "one" # 544..547 - - Comma (Token): "," # 547..548 - - IdentifierPath (Rule): # 548..557 " ultimate" - - Identifier (Token): "ultimate" # 549..557 - - CloseParen (Token): ")" # 557..558 + - OverridePathsDeclaration (Rule): # 521..558 "(some., next.arg, next.one, ultimate)" + - OpenParen (Token): "(" # 521..522 + - OverridePaths (Rule): # 522..557 "some., next.arg, next.one, ultimate" + - IdentifierPath (Rule): # 522..527 "some." + - Identifier (Token): "some" # 522..526 + - Period (Token): "." # 526..527 + - SKIPPED (Token): "" # 527..527 + - Comma (Token): "," # 527..528 + - IdentifierPath (Rule): # 528..537 " next.arg" + - Identifier (Token): "next" # 529..533 + - Period (Token): "." # 533..534 + - Identifier (Token): "arg" # 534..537 + - Comma (Token): "," # 537..538 + - IdentifierPath (Rule): # 538..547 " next.one" + - Identifier (Token): "next" # 539..543 + - Period (Token): "." # 543..544 + - Identifier (Token): "one" # 544..547 + - Comma (Token): "," # 547..548 + - IdentifierPath (Rule): # 548..557 " ultimate" + - Identifier (Token): "ultimate" # 549..557 + - CloseParen (Token): ")" # 557..558 - Semicolon (Token): ";" # 558..559 diff --git a/crates/solidity/testing/snapshots/cst_output/ContractMembers/separated_recovery/generated/0.7.0-failure.yml b/crates/solidity/testing/snapshots/cst_output/ContractMembers/separated_recovery/generated/0.7.0-failure.yml index 94eb6f85a5..5ea4dcef1c 100644 --- a/crates/solidity/testing/snapshots/cst_output/ContractMembers/separated_recovery/generated/0.7.0-failure.yml +++ b/crates/solidity/testing/snapshots/cst_output/ContractMembers/separated_recovery/generated/0.7.0-failure.yml @@ -123,14 +123,15 @@ Tree: - FunctionAttributes (Rule): # 14..83 " override(some.ident unexpected tokens, ISomeInter..." - OverrideSpecifier (Rule): # 14..76 " override(some.ident unexpected tokens, ISomeInter..." - OverrideKeyword (Token): "override" # 15..23 - - OpenParen (Token): "(" # 23..24 - - OverridePaths (Rule): # 24..34 "some.ident" - - IdentifierPath (Rule): # 24..34 "some.ident" - - Identifier (Token): "some" # 24..28 - - Period (Token): "." # 28..29 - - Identifier (Token): "ident" # 29..34 - - SKIPPED (Token): "unexpected tokens, ISomeInterface, Other" # 35..75 - - CloseParen (Token): ")" # 75..76 + - OverridePathsDeclaration (Rule): # 23..76 "(some.ident unexpected tokens, ISomeInterface, Oth..." + - OpenParen (Token): "(" # 23..24 + - OverridePaths (Rule): # 24..34 "some.ident" + - IdentifierPath (Rule): # 24..34 "some.ident" + - Identifier (Token): "some" # 24..28 + - Period (Token): "." # 28..29 + - Identifier (Token): "ident" # 29..34 + - SKIPPED (Token): "unexpected tokens, ISomeInterface, Other" # 35..75 + - CloseParen (Token): ")" # 75..76 - PublicKeyword (Token): "public" # 77..83 - Block (Rule): # 83..309 " {\n msg.sender.call{do: 1, arg: 1 }();\n msg.send..." - OpenBrace (Token): "{" # 84..85 @@ -148,12 +149,12 @@ Tree: - Identifier (Token): "sender" # 92..98 - Period (Token): "." # 98..99 - Identifier (Token): "call" # 99..103 - - FunctionCallOptions (Rule): # 103..119 "{do: 1, arg: 1 }" - - NamedArgumentsDeclaration (Rule): # 103..119 "{do: 1, arg: 1 }" + - NamedArgumentGroups (Rule): # 103..119 "{do: 1, arg: 1 }" + - NamedArgumentGroup (Rule): # 103..119 "{do: 1, arg: 1 }" - OpenBrace (Token): "{" # 103..104 - SKIPPED (Token): "do: 1, arg: 1 " # 104..118 - CloseBrace (Token): "}" # 118..119 - - ArgumentsDeclaration (Rule): # 119..121 "()" + - PositionalArgumentsDeclaration (Rule): # 119..121 "()" - OpenParen (Token): "(" # 119..120 - CloseParen (Token): ")" # 120..121 - Semicolon (Token): ";" # 121..122 @@ -170,12 +171,12 @@ Tree: - Identifier (Token): "sender" # 129..135 - Period (Token): "." # 135..136 - Identifier (Token): "call" # 136..140 - - FunctionCallOptions (Rule): # 140..163 "{, empty: 1, parse: 2 }" - - NamedArgumentsDeclaration (Rule): # 140..163 "{, empty: 1, parse: 2 }" + - NamedArgumentGroups (Rule): # 140..163 "{, empty: 1, parse: 2 }" + - NamedArgumentGroup (Rule): # 140..163 "{, empty: 1, parse: 2 }" - OpenBrace (Token): "{" # 140..141 - SKIPPED (Token): ", empty: 1, parse: 2 " # 141..162 - CloseBrace (Token): "}" # 162..163 - - ArgumentsDeclaration (Rule): # 163..165 "()" + - PositionalArgumentsDeclaration (Rule): # 163..165 "()" - OpenParen (Token): "(" # 163..164 - CloseParen (Token): ")" # 164..165 - Semicolon (Token): ";" # 165..166 @@ -192,8 +193,8 @@ Tree: - Identifier (Token): "sender" # 173..179 - Period (Token): "." # 179..180 - Identifier (Token): "call" # 180..184 - - FunctionCallOptions (Rule): # 184..226 "{arg: 1, missing_expr: , no_semicolon, , }" - - NamedArgumentsDeclaration (Rule): # 184..226 "{arg: 1, missing_expr: , no_semicolon, , }" + - NamedArgumentGroups (Rule): # 184..226 "{arg: 1, missing_expr: , no_semicolon, , }" + - NamedArgumentGroup (Rule): # 184..226 "{arg: 1, missing_expr: , no_semicolon, , }" - OpenBrace (Token): "{" # 184..185 - NamedArguments (Rule): # 185..222 "arg: 1, missing_expr: , no_semicolon," - NamedArgument (Rule): # 185..191 "arg: 1" @@ -214,7 +215,7 @@ Tree: - Comma (Token): "," # 221..222 - SKIPPED (Token): ", " # 223..225 - CloseBrace (Token): "}" # 225..226 - - ArgumentsDeclaration (Rule): # 226..228 "()" + - PositionalArgumentsDeclaration (Rule): # 226..228 "()" - OpenParen (Token): "(" # 226..227 - CloseParen (Token): ")" # 227..228 - Semicolon (Token): ";" # 228..229 @@ -231,8 +232,8 @@ Tree: - Identifier (Token): "sender" # 236..242 - Period (Token): "." # 242..243 - Identifier (Token): "call" # 243..247 - - FunctionCallOptions (Rule): # 247..302 "{arg: 1 unexpected tokens, not: 2, recovered, yet:..." - - NamedArgumentsDeclaration (Rule): # 247..302 "{arg: 1 unexpected tokens, not: 2, recovered, yet:..." + - NamedArgumentGroups (Rule): # 247..302 "{arg: 1 unexpected tokens, not: 2, recovered, yet:..." + - NamedArgumentGroup (Rule): # 247..302 "{arg: 1 unexpected tokens, not: 2, recovered, yet:..." - OpenBrace (Token): "{" # 247..248 - NamedArguments (Rule): # 248..254 "arg: 1" - NamedArgument (Rule): # 248..254 "arg: 1" @@ -243,7 +244,7 @@ Tree: - DecimalLiteral (Token): "1" # 253..254 - SKIPPED (Token): "unexpected tokens, not: 2, recovered, yet: 3, " # 255..301 - CloseBrace (Token): "}" # 301..302 - - ArgumentsDeclaration (Rule): # 302..304 "()" + - PositionalArgumentsDeclaration (Rule): # 302..304 "()" - OpenParen (Token): "(" # 302..303 - CloseParen (Token): ")" # 303..304 - Semicolon (Token): ";" # 304..305 @@ -257,17 +258,18 @@ Tree: - FunctionAttributes (Rule): # 326..386 " override(some.ident, /* empty */, other.arg.here,..." - OverrideSpecifier (Rule): # 326..386 " override(some.ident, /* empty */, other.arg.here,..." - OverrideKeyword (Token): "override" # 327..335 - - OpenParen (Token): "(" # 335..336 - - OverridePaths (Rule): # 336..347 "some.ident," - - IdentifierPath (Rule): # 336..346 "some.ident" - - Identifier (Token): "some" # 336..340 - - Period (Token): "." # 340..341 - - Identifier (Token): "ident" # 341..346 - - Comma (Token): "," # 346..347 - - LeadingTrivia (Rule): # 347..359 " /* empty */" - - MultilineComment (Trivia): "/* empty */" # 348..359 - - SKIPPED (Token): ", other.arg.here, and.here" # 359..385 - - CloseParen (Token): ")" # 385..386 + - OverridePathsDeclaration (Rule): # 335..386 "(some.ident, /* empty */, other.arg.here, and.here..." + - OpenParen (Token): "(" # 335..336 + - OverridePaths (Rule): # 336..347 "some.ident," + - IdentifierPath (Rule): # 336..346 "some.ident" + - Identifier (Token): "some" # 336..340 + - Period (Token): "." # 340..341 + - Identifier (Token): "ident" # 341..346 + - Comma (Token): "," # 346..347 + - LeadingTrivia (Rule): # 347..359 " /* empty */" + - MultilineComment (Trivia): "/* empty */" # 348..359 + - SKIPPED (Token): ", other.arg.here, and.here" # 359..385 + - CloseParen (Token): ")" # 385..386 - Semicolon (Token): ";" # 386..387 - FunctionDefinition (Rule): # 388..489 "\nfunction nested_lists() override(some.ident, next..." - FunctionKeyword (Token): "function" # 389..397 @@ -278,30 +280,31 @@ Tree: - FunctionAttributes (Rule): # 412..487 " override(some.ident, next.do.that, other.while, n..." - OverrideSpecifier (Rule): # 412..487 " override(some.ident, next.do.that, other.while, n..." - OverrideKeyword (Token): "override" # 413..421 - - OpenParen (Token): "(" # 421..422 - - OverridePaths (Rule): # 422..470 "some.ident, next.do.that, other.while, next.one," - - IdentifierPath (Rule): # 422..432 "some.ident" - - Identifier (Token): "some" # 422..426 - - Period (Token): "." # 426..427 - - Identifier (Token): "ident" # 427..432 - - Comma (Token): "," # 432..433 - - IdentifierPath (Rule): # 433..439 " next." - - Identifier (Token): "next" # 434..438 - - Period (Token): "." # 438..439 - - SKIPPED (Token): "do.that" # 439..446 - - Comma (Token): "," # 446..447 - - IdentifierPath (Rule): # 447..454 " other." - - Identifier (Token): "other" # 448..453 - - Period (Token): "." # 453..454 - - SKIPPED (Token): "while" # 454..459 - - Comma (Token): "," # 459..460 - - IdentifierPath (Rule): # 460..469 " next.one" - - Identifier (Token): "next" # 461..465 - - Period (Token): "." # 465..466 - - Identifier (Token): "one" # 466..469 - - Comma (Token): "," # 469..470 - - SKIPPED (Token): "final, ultimate" # 471..486 - - CloseParen (Token): ")" # 486..487 + - OverridePathsDeclaration (Rule): # 421..487 "(some.ident, next.do.that, other.while, next.one, ..." + - OpenParen (Token): "(" # 421..422 + - OverridePaths (Rule): # 422..470 "some.ident, next.do.that, other.while, next.one," + - IdentifierPath (Rule): # 422..432 "some.ident" + - Identifier (Token): "some" # 422..426 + - Period (Token): "." # 426..427 + - Identifier (Token): "ident" # 427..432 + - Comma (Token): "," # 432..433 + - IdentifierPath (Rule): # 433..439 " next." + - Identifier (Token): "next" # 434..438 + - Period (Token): "." # 438..439 + - SKIPPED (Token): "do.that" # 439..446 + - Comma (Token): "," # 446..447 + - IdentifierPath (Rule): # 447..454 " other." + - Identifier (Token): "other" # 448..453 + - Period (Token): "." # 453..454 + - SKIPPED (Token): "while" # 454..459 + - Comma (Token): "," # 459..460 + - IdentifierPath (Rule): # 460..469 " next.one" + - Identifier (Token): "next" # 461..465 + - Period (Token): "." # 465..466 + - Identifier (Token): "one" # 466..469 + - Comma (Token): "," # 469..470 + - SKIPPED (Token): "final, ultimate" # 471..486 + - CloseParen (Token): ")" # 486..487 - Semicolon (Token): ";" # 487..488 - FunctionDefinition (Rule): # 489..560 "function nested_lists() override(some., next.arg, ..." - FunctionKeyword (Token): "function" # 489..497 @@ -312,24 +315,25 @@ Tree: - FunctionAttributes (Rule): # 512..558 " override(some., next.arg, next.one, ultimate)" - OverrideSpecifier (Rule): # 512..558 " override(some., next.arg, next.one, ultimate)" - OverrideKeyword (Token): "override" # 513..521 - - OpenParen (Token): "(" # 521..522 - - OverridePaths (Rule): # 522..557 "some., next.arg, next.one, ultimate" - - IdentifierPath (Rule): # 522..527 "some." - - Identifier (Token): "some" # 522..526 - - Period (Token): "." # 526..527 - - SKIPPED (Token): "" # 527..527 - - Comma (Token): "," # 527..528 - - IdentifierPath (Rule): # 528..537 " next.arg" - - Identifier (Token): "next" # 529..533 - - Period (Token): "." # 533..534 - - Identifier (Token): "arg" # 534..537 - - Comma (Token): "," # 537..538 - - IdentifierPath (Rule): # 538..547 " next.one" - - Identifier (Token): "next" # 539..543 - - Period (Token): "." # 543..544 - - Identifier (Token): "one" # 544..547 - - Comma (Token): "," # 547..548 - - IdentifierPath (Rule): # 548..557 " ultimate" - - Identifier (Token): "ultimate" # 549..557 - - CloseParen (Token): ")" # 557..558 + - OverridePathsDeclaration (Rule): # 521..558 "(some., next.arg, next.one, ultimate)" + - OpenParen (Token): "(" # 521..522 + - OverridePaths (Rule): # 522..557 "some., next.arg, next.one, ultimate" + - IdentifierPath (Rule): # 522..527 "some." + - Identifier (Token): "some" # 522..526 + - Period (Token): "." # 526..527 + - SKIPPED (Token): "" # 527..527 + - Comma (Token): "," # 527..528 + - IdentifierPath (Rule): # 528..537 " next.arg" + - Identifier (Token): "next" # 529..533 + - Period (Token): "." # 533..534 + - Identifier (Token): "arg" # 534..537 + - Comma (Token): "," # 537..538 + - IdentifierPath (Rule): # 538..547 " next.one" + - Identifier (Token): "next" # 539..543 + - Period (Token): "." # 543..544 + - Identifier (Token): "one" # 544..547 + - Comma (Token): "," # 547..548 + - IdentifierPath (Rule): # 548..557 " ultimate" + - Identifier (Token): "ultimate" # 549..557 + - CloseParen (Token): ")" # 557..558 - Semicolon (Token): ";" # 558..559 diff --git a/crates/solidity/testing/snapshots/cst_output/ContractMembers/separated_recovery/generated/0.8.0-failure.yml b/crates/solidity/testing/snapshots/cst_output/ContractMembers/separated_recovery/generated/0.8.0-failure.yml index 05c0651ace..7627917e88 100644 --- a/crates/solidity/testing/snapshots/cst_output/ContractMembers/separated_recovery/generated/0.8.0-failure.yml +++ b/crates/solidity/testing/snapshots/cst_output/ContractMembers/separated_recovery/generated/0.8.0-failure.yml @@ -123,14 +123,15 @@ Tree: - FunctionAttributes (Rule): # 14..83 " override(some.ident unexpected tokens, ISomeInter..." - OverrideSpecifier (Rule): # 14..76 " override(some.ident unexpected tokens, ISomeInter..." - OverrideKeyword (Token): "override" # 15..23 - - OpenParen (Token): "(" # 23..24 - - OverridePaths (Rule): # 24..34 "some.ident" - - IdentifierPath (Rule): # 24..34 "some.ident" - - Identifier (Token): "some" # 24..28 - - Period (Token): "." # 28..29 - - Identifier (Token): "ident" # 29..34 - - SKIPPED (Token): "unexpected tokens, ISomeInterface, Other" # 35..75 - - CloseParen (Token): ")" # 75..76 + - OverridePathsDeclaration (Rule): # 23..76 "(some.ident unexpected tokens, ISomeInterface, Oth..." + - OpenParen (Token): "(" # 23..24 + - OverridePaths (Rule): # 24..34 "some.ident" + - IdentifierPath (Rule): # 24..34 "some.ident" + - Identifier (Token): "some" # 24..28 + - Period (Token): "." # 28..29 + - Identifier (Token): "ident" # 29..34 + - SKIPPED (Token): "unexpected tokens, ISomeInterface, Other" # 35..75 + - CloseParen (Token): ")" # 75..76 - PublicKeyword (Token): "public" # 77..83 - Block (Rule): # 83..309 " {\n msg.sender.call{do: 1, arg: 1 }();\n msg.send..." - OpenBrace (Token): "{" # 84..85 @@ -148,12 +149,11 @@ Tree: - Identifier (Token): "sender" # 92..98 - Period (Token): "." # 98..99 - Identifier (Token): "call" # 99..103 - - FunctionCallOptions (Rule): # 103..119 "{do: 1, arg: 1 }" - - NamedArgumentsDeclaration (Rule): # 103..119 "{do: 1, arg: 1 }" - - OpenBrace (Token): "{" # 103..104 - - SKIPPED (Token): "do: 1, arg: 1 " # 104..118 - - CloseBrace (Token): "}" # 118..119 - - ArgumentsDeclaration (Rule): # 119..121 "()" + - NamedArgumentGroup (Rule): # 103..119 "{do: 1, arg: 1 }" + - OpenBrace (Token): "{" # 103..104 + - SKIPPED (Token): "do: 1, arg: 1 " # 104..118 + - CloseBrace (Token): "}" # 118..119 + - PositionalArgumentsDeclaration (Rule): # 119..121 "()" - OpenParen (Token): "(" # 119..120 - CloseParen (Token): ")" # 120..121 - Semicolon (Token): ";" # 121..122 @@ -170,12 +170,11 @@ Tree: - Identifier (Token): "sender" # 129..135 - Period (Token): "." # 135..136 - Identifier (Token): "call" # 136..140 - - FunctionCallOptions (Rule): # 140..163 "{, empty: 1, parse: 2 }" - - NamedArgumentsDeclaration (Rule): # 140..163 "{, empty: 1, parse: 2 }" - - OpenBrace (Token): "{" # 140..141 - - SKIPPED (Token): ", empty: 1, parse: 2 " # 141..162 - - CloseBrace (Token): "}" # 162..163 - - ArgumentsDeclaration (Rule): # 163..165 "()" + - NamedArgumentGroup (Rule): # 140..163 "{, empty: 1, parse: 2 }" + - OpenBrace (Token): "{" # 140..141 + - SKIPPED (Token): ", empty: 1, parse: 2 " # 141..162 + - CloseBrace (Token): "}" # 162..163 + - PositionalArgumentsDeclaration (Rule): # 163..165 "()" - OpenParen (Token): "(" # 163..164 - CloseParen (Token): ")" # 164..165 - Semicolon (Token): ";" # 165..166 @@ -192,29 +191,28 @@ Tree: - Identifier (Token): "sender" # 173..179 - Period (Token): "." # 179..180 - Identifier (Token): "call" # 180..184 - - FunctionCallOptions (Rule): # 184..226 "{arg: 1, missing_expr: , no_semicolon, , }" - - NamedArgumentsDeclaration (Rule): # 184..226 "{arg: 1, missing_expr: , no_semicolon, , }" - - OpenBrace (Token): "{" # 184..185 - - NamedArguments (Rule): # 185..222 "arg: 1, missing_expr: , no_semicolon," - - NamedArgument (Rule): # 185..191 "arg: 1" - - Identifier (Token): "arg" # 185..188 - - Colon (Token): ":" # 188..189 - - Expression (Rule): # 189..191 " 1" - - DecimalNumberExpression (Rule): # 189..191 " 1" - - DecimalLiteral (Token): "1" # 190..191 - - Comma (Token): "," # 191..192 - - NamedArgument (Rule): # 192..206 " missing_expr:" - - Identifier (Token): "missing_expr" # 193..205 - - Colon (Token): ":" # 205..206 - - SKIPPED (Token): " " # 206..207 - - Comma (Token): "," # 207..208 - - NamedArgument (Rule): # 208..221 " no_semicolon" - - Identifier (Token): "no_semicolon" # 209..221 - - SKIPPED (Token): "" # 221..221 - - Comma (Token): "," # 221..222 - - SKIPPED (Token): ", " # 223..225 - - CloseBrace (Token): "}" # 225..226 - - ArgumentsDeclaration (Rule): # 226..228 "()" + - NamedArgumentGroup (Rule): # 184..226 "{arg: 1, missing_expr: , no_semicolon, , }" + - OpenBrace (Token): "{" # 184..185 + - NamedArguments (Rule): # 185..222 "arg: 1, missing_expr: , no_semicolon," + - NamedArgument (Rule): # 185..191 "arg: 1" + - Identifier (Token): "arg" # 185..188 + - Colon (Token): ":" # 188..189 + - Expression (Rule): # 189..191 " 1" + - DecimalNumberExpression (Rule): # 189..191 " 1" + - DecimalLiteral (Token): "1" # 190..191 + - Comma (Token): "," # 191..192 + - NamedArgument (Rule): # 192..206 " missing_expr:" + - Identifier (Token): "missing_expr" # 193..205 + - Colon (Token): ":" # 205..206 + - SKIPPED (Token): " " # 206..207 + - Comma (Token): "," # 207..208 + - NamedArgument (Rule): # 208..221 " no_semicolon" + - Identifier (Token): "no_semicolon" # 209..221 + - SKIPPED (Token): "" # 221..221 + - Comma (Token): "," # 221..222 + - SKIPPED (Token): ", " # 223..225 + - CloseBrace (Token): "}" # 225..226 + - PositionalArgumentsDeclaration (Rule): # 226..228 "()" - OpenParen (Token): "(" # 226..227 - CloseParen (Token): ")" # 227..228 - Semicolon (Token): ";" # 228..229 @@ -231,19 +229,18 @@ Tree: - Identifier (Token): "sender" # 236..242 - Period (Token): "." # 242..243 - Identifier (Token): "call" # 243..247 - - FunctionCallOptions (Rule): # 247..302 "{arg: 1 unexpected tokens, not: 2, recovered, yet:..." - - NamedArgumentsDeclaration (Rule): # 247..302 "{arg: 1 unexpected tokens, not: 2, recovered, yet:..." - - OpenBrace (Token): "{" # 247..248 - - NamedArguments (Rule): # 248..254 "arg: 1" - - NamedArgument (Rule): # 248..254 "arg: 1" - - Identifier (Token): "arg" # 248..251 - - Colon (Token): ":" # 251..252 - - Expression (Rule): # 252..254 " 1" - - DecimalNumberExpression (Rule): # 252..254 " 1" - - DecimalLiteral (Token): "1" # 253..254 - - SKIPPED (Token): "unexpected tokens, not: 2, recovered, yet: 3, " # 255..301 - - CloseBrace (Token): "}" # 301..302 - - ArgumentsDeclaration (Rule): # 302..304 "()" + - NamedArgumentGroup (Rule): # 247..302 "{arg: 1 unexpected tokens, not: 2, recovered, yet:..." + - OpenBrace (Token): "{" # 247..248 + - NamedArguments (Rule): # 248..254 "arg: 1" + - NamedArgument (Rule): # 248..254 "arg: 1" + - Identifier (Token): "arg" # 248..251 + - Colon (Token): ":" # 251..252 + - Expression (Rule): # 252..254 " 1" + - DecimalNumberExpression (Rule): # 252..254 " 1" + - DecimalLiteral (Token): "1" # 253..254 + - SKIPPED (Token): "unexpected tokens, not: 2, recovered, yet: 3, " # 255..301 + - CloseBrace (Token): "}" # 301..302 + - PositionalArgumentsDeclaration (Rule): # 302..304 "()" - OpenParen (Token): "(" # 302..303 - CloseParen (Token): ")" # 303..304 - Semicolon (Token): ";" # 304..305 @@ -257,17 +254,18 @@ Tree: - FunctionAttributes (Rule): # 326..386 " override(some.ident, /* empty */, other.arg.here,..." - OverrideSpecifier (Rule): # 326..386 " override(some.ident, /* empty */, other.arg.here,..." - OverrideKeyword (Token): "override" # 327..335 - - OpenParen (Token): "(" # 335..336 - - OverridePaths (Rule): # 336..347 "some.ident," - - IdentifierPath (Rule): # 336..346 "some.ident" - - Identifier (Token): "some" # 336..340 - - Period (Token): "." # 340..341 - - Identifier (Token): "ident" # 341..346 - - Comma (Token): "," # 346..347 - - LeadingTrivia (Rule): # 347..359 " /* empty */" - - MultilineComment (Trivia): "/* empty */" # 348..359 - - SKIPPED (Token): ", other.arg.here, and.here" # 359..385 - - CloseParen (Token): ")" # 385..386 + - OverridePathsDeclaration (Rule): # 335..386 "(some.ident, /* empty */, other.arg.here, and.here..." + - OpenParen (Token): "(" # 335..336 + - OverridePaths (Rule): # 336..347 "some.ident," + - IdentifierPath (Rule): # 336..346 "some.ident" + - Identifier (Token): "some" # 336..340 + - Period (Token): "." # 340..341 + - Identifier (Token): "ident" # 341..346 + - Comma (Token): "," # 346..347 + - LeadingTrivia (Rule): # 347..359 " /* empty */" + - MultilineComment (Trivia): "/* empty */" # 348..359 + - SKIPPED (Token): ", other.arg.here, and.here" # 359..385 + - CloseParen (Token): ")" # 385..386 - Semicolon (Token): ";" # 386..387 - FunctionDefinition (Rule): # 388..489 "\nfunction nested_lists() override(some.ident, next..." - FunctionKeyword (Token): "function" # 389..397 @@ -278,30 +276,31 @@ Tree: - FunctionAttributes (Rule): # 412..487 " override(some.ident, next.do.that, other.while, n..." - OverrideSpecifier (Rule): # 412..487 " override(some.ident, next.do.that, other.while, n..." - OverrideKeyword (Token): "override" # 413..421 - - OpenParen (Token): "(" # 421..422 - - OverridePaths (Rule): # 422..470 "some.ident, next.do.that, other.while, next.one," - - IdentifierPath (Rule): # 422..432 "some.ident" - - Identifier (Token): "some" # 422..426 - - Period (Token): "." # 426..427 - - Identifier (Token): "ident" # 427..432 - - Comma (Token): "," # 432..433 - - IdentifierPath (Rule): # 433..439 " next." - - Identifier (Token): "next" # 434..438 - - Period (Token): "." # 438..439 - - SKIPPED (Token): "do.that" # 439..446 - - Comma (Token): "," # 446..447 - - IdentifierPath (Rule): # 447..454 " other." - - Identifier (Token): "other" # 448..453 - - Period (Token): "." # 453..454 - - SKIPPED (Token): "while" # 454..459 - - Comma (Token): "," # 459..460 - - IdentifierPath (Rule): # 460..469 " next.one" - - Identifier (Token): "next" # 461..465 - - Period (Token): "." # 465..466 - - Identifier (Token): "one" # 466..469 - - Comma (Token): "," # 469..470 - - SKIPPED (Token): "final, ultimate" # 471..486 - - CloseParen (Token): ")" # 486..487 + - OverridePathsDeclaration (Rule): # 421..487 "(some.ident, next.do.that, other.while, next.one, ..." + - OpenParen (Token): "(" # 421..422 + - OverridePaths (Rule): # 422..470 "some.ident, next.do.that, other.while, next.one," + - IdentifierPath (Rule): # 422..432 "some.ident" + - Identifier (Token): "some" # 422..426 + - Period (Token): "." # 426..427 + - Identifier (Token): "ident" # 427..432 + - Comma (Token): "," # 432..433 + - IdentifierPath (Rule): # 433..439 " next." + - Identifier (Token): "next" # 434..438 + - Period (Token): "." # 438..439 + - SKIPPED (Token): "do.that" # 439..446 + - Comma (Token): "," # 446..447 + - IdentifierPath (Rule): # 447..454 " other." + - Identifier (Token): "other" # 448..453 + - Period (Token): "." # 453..454 + - SKIPPED (Token): "while" # 454..459 + - Comma (Token): "," # 459..460 + - IdentifierPath (Rule): # 460..469 " next.one" + - Identifier (Token): "next" # 461..465 + - Period (Token): "." # 465..466 + - Identifier (Token): "one" # 466..469 + - Comma (Token): "," # 469..470 + - SKIPPED (Token): "final, ultimate" # 471..486 + - CloseParen (Token): ")" # 486..487 - Semicolon (Token): ";" # 487..488 - FunctionDefinition (Rule): # 489..560 "function nested_lists() override(some., next.arg, ..." - FunctionKeyword (Token): "function" # 489..497 @@ -312,24 +311,25 @@ Tree: - FunctionAttributes (Rule): # 512..558 " override(some., next.arg, next.one, ultimate)" - OverrideSpecifier (Rule): # 512..558 " override(some., next.arg, next.one, ultimate)" - OverrideKeyword (Token): "override" # 513..521 - - OpenParen (Token): "(" # 521..522 - - OverridePaths (Rule): # 522..557 "some., next.arg, next.one, ultimate" - - IdentifierPath (Rule): # 522..527 "some." - - Identifier (Token): "some" # 522..526 - - Period (Token): "." # 526..527 - - SKIPPED (Token): "" # 527..527 - - Comma (Token): "," # 527..528 - - IdentifierPath (Rule): # 528..537 " next.arg" - - Identifier (Token): "next" # 529..533 - - Period (Token): "." # 533..534 - - Identifier (Token): "arg" # 534..537 - - Comma (Token): "," # 537..538 - - IdentifierPath (Rule): # 538..547 " next.one" - - Identifier (Token): "next" # 539..543 - - Period (Token): "." # 543..544 - - Identifier (Token): "one" # 544..547 - - Comma (Token): "," # 547..548 - - IdentifierPath (Rule): # 548..557 " ultimate" - - Identifier (Token): "ultimate" # 549..557 - - CloseParen (Token): ")" # 557..558 + - OverridePathsDeclaration (Rule): # 521..558 "(some., next.arg, next.one, ultimate)" + - OpenParen (Token): "(" # 521..522 + - OverridePaths (Rule): # 522..557 "some., next.arg, next.one, ultimate" + - IdentifierPath (Rule): # 522..527 "some." + - Identifier (Token): "some" # 522..526 + - Period (Token): "." # 526..527 + - SKIPPED (Token): "" # 527..527 + - Comma (Token): "," # 527..528 + - IdentifierPath (Rule): # 528..537 " next.arg" + - Identifier (Token): "next" # 529..533 + - Period (Token): "." # 533..534 + - Identifier (Token): "arg" # 534..537 + - Comma (Token): "," # 537..538 + - IdentifierPath (Rule): # 538..547 " next.one" + - Identifier (Token): "next" # 539..543 + - Period (Token): "." # 543..544 + - Identifier (Token): "one" # 544..547 + - Comma (Token): "," # 547..548 + - IdentifierPath (Rule): # 548..557 " ultimate" + - Identifier (Token): "ultimate" # 549..557 + - CloseParen (Token): ")" # 557..558 - Semicolon (Token): ";" # 558..559 diff --git a/crates/solidity/testing/snapshots/cst_output/Expression/address_call/generated/0.4.11-success.yml b/crates/solidity/testing/snapshots/cst_output/Expression/address_call/generated/0.4.11-success.yml index 0f7f820deb..35bc7bff61 100644 --- a/crates/solidity/testing/snapshots/cst_output/Expression/address_call/generated/0.4.11-success.yml +++ b/crates/solidity/testing/snapshots/cst_output/Expression/address_call/generated/0.4.11-success.yml @@ -11,7 +11,7 @@ Tree: - Expression (Rule): # 0..7 "address" - AddressType (Rule): # 0..7 "address" - AddressKeyword (Token): "address" # 0..7 - - ArgumentsDeclaration (Rule): # 7..14 "(value)" + - PositionalArgumentsDeclaration (Rule): # 7..14 "(value)" - OpenParen (Token): "(" # 7..8 - PositionalArguments (Rule): # 8..13 "value" - Expression (Rule): # 8..13 "value" diff --git a/crates/solidity/testing/snapshots/cst_output/Expression/address_payable_call/generated/0.4.11-success.yml b/crates/solidity/testing/snapshots/cst_output/Expression/address_payable_call/generated/0.4.11-success.yml index dfbb82c056..5ef1ecf5a3 100644 --- a/crates/solidity/testing/snapshots/cst_output/Expression/address_payable_call/generated/0.4.11-success.yml +++ b/crates/solidity/testing/snapshots/cst_output/Expression/address_payable_call/generated/0.4.11-success.yml @@ -12,7 +12,7 @@ Tree: - AddressType (Rule): # 0..15 "address payable" - AddressKeyword (Token): "address" # 0..7 - PayableKeyword (Token): "payable" # 8..15 - - ArgumentsDeclaration (Rule): # 15..22 "(value)" + - PositionalArgumentsDeclaration (Rule): # 15..22 "(value)" - OpenParen (Token): "(" # 15..16 - PositionalArguments (Rule): # 16..21 "value" - Expression (Rule): # 16..21 "value" 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 index 2d61701cf9..3b021353bc 100644 --- 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 @@ -12,13 +12,14 @@ Tree: - TupleExpression (Rule): # 0..12 "(foo == bar)" - OpenParen (Token): "(" # 0..1 - TupleValues (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 + - 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" 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 index 5318082828..7420172850 100644 --- 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 @@ -15,24 +15,26 @@ Tree: - TupleExpression (Rule): # 5..13 " (a + b)" - OpenParen (Token): "(" # 6..7 - TupleValues (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 + - 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" - - 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 + - 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/function_call/generated/0.4.11-success.yml b/crates/solidity/testing/snapshots/cst_output/Expression/function_call/generated/0.4.11-success.yml index c8e4c7a02a..b443a641a2 100644 --- a/crates/solidity/testing/snapshots/cst_output/Expression/function_call/generated/0.4.11-success.yml +++ b/crates/solidity/testing/snapshots/cst_output/Expression/function_call/generated/0.4.11-success.yml @@ -10,7 +10,7 @@ Tree: - FunctionCallExpression (Rule): # 0..7 "x(1, 2)" - Expression (Rule): # 0..1 "x" - Identifier (Token): "x" # 0..1 - - ArgumentsDeclaration (Rule): # 1..7 "(1, 2)" + - PositionalArgumentsDeclaration (Rule): # 1..7 "(1, 2)" - OpenParen (Token): "(" # 1..2 - PositionalArguments (Rule): # 2..6 "1, 2" - Expression (Rule): # 2..3 "1" diff --git a/crates/solidity/testing/snapshots/cst_output/Expression/function_call_argument_has_type_name_as_prefix/generated/0.4.11-success.yml b/crates/solidity/testing/snapshots/cst_output/Expression/function_call_argument_has_type_name_as_prefix/generated/0.4.11-success.yml index 96b8d7407b..06512d33ed 100644 --- a/crates/solidity/testing/snapshots/cst_output/Expression/function_call_argument_has_type_name_as_prefix/generated/0.4.11-success.yml +++ b/crates/solidity/testing/snapshots/cst_output/Expression/function_call_argument_has_type_name_as_prefix/generated/0.4.11-success.yml @@ -10,7 +10,7 @@ Tree: - FunctionCallExpression (Rule): # 0..13 "x(interested)" - Expression (Rule): # 0..1 "x" - Identifier (Token): "x" # 0..1 - - ArgumentsDeclaration (Rule): # 1..13 "(interested)" + - PositionalArgumentsDeclaration (Rule): # 1..13 "(interested)" - OpenParen (Token): "(" # 1..2 - PositionalArguments (Rule): # 2..12 "interested" - Expression (Rule): # 2..12 "interested" diff --git a/crates/solidity/testing/snapshots/cst_output/Expression/function_call_chain/generated/0.4.11-success.yml b/crates/solidity/testing/snapshots/cst_output/Expression/function_call_chain/generated/0.4.11-success.yml index 2f2e3b2a80..905a53b354 100644 --- a/crates/solidity/testing/snapshots/cst_output/Expression/function_call_chain/generated/0.4.11-success.yml +++ b/crates/solidity/testing/snapshots/cst_output/Expression/function_call_chain/generated/0.4.11-success.yml @@ -12,9 +12,9 @@ Tree: - FunctionCallExpression (Rule): # 0..3 "x()" - Expression (Rule): # 0..1 "x" - Identifier (Token): "x" # 0..1 - - ArgumentsDeclaration (Rule): # 1..3 "()" + - PositionalArgumentsDeclaration (Rule): # 1..3 "()" - OpenParen (Token): "(" # 1..2 - CloseParen (Token): ")" # 2..3 - - ArgumentsDeclaration (Rule): # 3..5 "()" + - PositionalArgumentsDeclaration (Rule): # 3..5 "()" - OpenParen (Token): "(" # 3..4 - CloseParen (Token): ")" # 4..5 diff --git a/crates/solidity/testing/snapshots/cst_output/Expression/function_call_member_access/generated/0.4.11-success.yml b/crates/solidity/testing/snapshots/cst_output/Expression/function_call_member_access/generated/0.4.11-success.yml index 6c8e6134fd..fad51c97bf 100644 --- a/crates/solidity/testing/snapshots/cst_output/Expression/function_call_member_access/generated/0.4.11-success.yml +++ b/crates/solidity/testing/snapshots/cst_output/Expression/function_call_member_access/generated/0.4.11-success.yml @@ -12,7 +12,7 @@ Tree: - FunctionCallExpression (Rule): # 0..3 "x()" - Expression (Rule): # 0..1 "x" - Identifier (Token): "x" # 0..1 - - ArgumentsDeclaration (Rule): # 1..3 "()" + - PositionalArgumentsDeclaration (Rule): # 1..3 "()" - OpenParen (Token): "(" # 1..2 - CloseParen (Token): ")" # 2..3 - Period (Token): "." # 3..4 diff --git a/crates/solidity/testing/snapshots/cst_output/Expression/function_call_options/generated/0.6.2-success.yml b/crates/solidity/testing/snapshots/cst_output/Expression/function_call_options/generated/0.6.2-success.yml index 3dacad7448..b1a3b15b7c 100644 --- a/crates/solidity/testing/snapshots/cst_output/Expression/function_call_options/generated/0.6.2-success.yml +++ b/crates/solidity/testing/snapshots/cst_output/Expression/function_call_options/generated/0.6.2-success.yml @@ -14,8 +14,8 @@ Tree: - Identifier (Token): "a" # 0..1 - Period (Token): "." # 1..2 - Identifier (Token): "b" # 2..3 - - FunctionCallOptions (Rule): # 3..21 "{value: 0, gas: 1}" - - NamedArgumentsDeclaration (Rule): # 3..21 "{value: 0, gas: 1}" + - NamedArgumentGroups (Rule): # 3..21 "{value: 0, gas: 1}" + - NamedArgumentGroup (Rule): # 3..21 "{value: 0, gas: 1}" - OpenBrace (Token): "{" # 3..4 - NamedArguments (Rule): # 4..20 "value: 0, gas: 1" - NamedArgument (Rule): # 4..12 "value: 0" @@ -32,7 +32,7 @@ Tree: - DecimalNumberExpression (Rule): # 18..20 " 1" - DecimalLiteral (Token): "1" # 19..20 - CloseBrace (Token): "}" # 20..21 - - ArgumentsDeclaration (Rule): # 21..25 '("")' + - PositionalArgumentsDeclaration (Rule): # 21..25 '("")' - OpenParen (Token): "(" # 21..22 - PositionalArguments (Rule): # 22..24 '""' - Expression (Rule): # 22..24 '""' diff --git a/crates/solidity/testing/snapshots/cst_output/Expression/function_call_options/generated/0.8.0-success.yml b/crates/solidity/testing/snapshots/cst_output/Expression/function_call_options/generated/0.8.0-success.yml new file mode 100644 index 0000000000..7f0b4ef80d --- /dev/null +++ b/crates/solidity/testing/snapshots/cst_output/Expression/function_call_options/generated/0.8.0-success.yml @@ -0,0 +1,40 @@ +# This file is generated automatically by infrastructure scripts. Please don't edit by hand. + +Source: > + 1 │ a.b{value: 0, gas: 1}("") │ 0..25 + +Errors: [] + +Tree: + - Expression (Rule): # 0..25 'a.b{value: 0, gas: 1}("")' + - FunctionCallExpression (Rule): # 0..25 'a.b{value: 0, gas: 1}("")' + - Expression (Rule): # 0..3 "a.b" + - MemberAccessExpression (Rule): # 0..3 "a.b" + - Expression (Rule): # 0..1 "a" + - Identifier (Token): "a" # 0..1 + - Period (Token): "." # 1..2 + - Identifier (Token): "b" # 2..3 + - NamedArgumentGroup (Rule): # 3..21 "{value: 0, gas: 1}" + - OpenBrace (Token): "{" # 3..4 + - NamedArguments (Rule): # 4..20 "value: 0, gas: 1" + - NamedArgument (Rule): # 4..12 "value: 0" + - Identifier (Token): "value" # 4..9 + - Colon (Token): ":" # 9..10 + - Expression (Rule): # 10..12 " 0" + - DecimalNumberExpression (Rule): # 10..12 " 0" + - DecimalLiteral (Token): "0" # 11..12 + - Comma (Token): "," # 12..13 + - NamedArgument (Rule): # 13..20 " gas: 1" + - Identifier (Token): "gas" # 14..17 + - Colon (Token): ":" # 17..18 + - Expression (Rule): # 18..20 " 1" + - DecimalNumberExpression (Rule): # 18..20 " 1" + - DecimalLiteral (Token): "1" # 19..20 + - CloseBrace (Token): "}" # 20..21 + - PositionalArgumentsDeclaration (Rule): # 21..25 '("")' + - OpenParen (Token): "(" # 21..22 + - PositionalArguments (Rule): # 22..24 '""' + - Expression (Rule): # 22..24 '""' + - AsciiStringLiterals (Rule): # 22..24 '""' + - AsciiStringLiteral (Token): '""' # 22..24 + - CloseParen (Token): ")" # 24..25 diff --git a/crates/solidity/testing/snapshots/cst_output/Expression/function_call_options_split/generated/0.6.2-success.yml b/crates/solidity/testing/snapshots/cst_output/Expression/function_call_options_split/generated/0.6.2-success.yml index 3322a55830..19fdf2f6de 100644 --- a/crates/solidity/testing/snapshots/cst_output/Expression/function_call_options_split/generated/0.6.2-success.yml +++ b/crates/solidity/testing/snapshots/cst_output/Expression/function_call_options_split/generated/0.6.2-success.yml @@ -14,8 +14,8 @@ Tree: - Identifier (Token): "a" # 0..1 - Period (Token): "." # 1..2 - Identifier (Token): "b" # 2..3 - - FunctionCallOptions (Rule): # 3..21 "{value: 0}{gas: 1}" - - NamedArgumentsDeclaration (Rule): # 3..13 "{value: 0}" + - NamedArgumentGroups (Rule): # 3..21 "{value: 0}{gas: 1}" + - NamedArgumentGroup (Rule): # 3..13 "{value: 0}" - OpenBrace (Token): "{" # 3..4 - NamedArguments (Rule): # 4..12 "value: 0" - NamedArgument (Rule): # 4..12 "value: 0" @@ -25,7 +25,7 @@ Tree: - DecimalNumberExpression (Rule): # 10..12 " 0" - DecimalLiteral (Token): "0" # 11..12 - CloseBrace (Token): "}" # 12..13 - - NamedArgumentsDeclaration (Rule): # 13..21 "{gas: 1}" + - NamedArgumentGroup (Rule): # 13..21 "{gas: 1}" - OpenBrace (Token): "{" # 13..14 - NamedArguments (Rule): # 14..20 "gas: 1" - NamedArgument (Rule): # 14..20 "gas: 1" @@ -35,7 +35,7 @@ Tree: - DecimalNumberExpression (Rule): # 18..20 " 1" - DecimalLiteral (Token): "1" # 19..20 - CloseBrace (Token): "}" # 20..21 - - ArgumentsDeclaration (Rule): # 21..25 '("")' + - PositionalArgumentsDeclaration (Rule): # 21..25 '("")' - OpenParen (Token): "(" # 21..22 - PositionalArguments (Rule): # 22..24 '""' - Expression (Rule): # 22..24 '""' diff --git a/crates/solidity/testing/snapshots/cst_output/Expression/identifier_call/generated/0.4.11-success.yml b/crates/solidity/testing/snapshots/cst_output/Expression/identifier_call/generated/0.4.11-success.yml index 1c04e25028..22338ddf4f 100644 --- a/crates/solidity/testing/snapshots/cst_output/Expression/identifier_call/generated/0.4.11-success.yml +++ b/crates/solidity/testing/snapshots/cst_output/Expression/identifier_call/generated/0.4.11-success.yml @@ -10,7 +10,7 @@ Tree: - FunctionCallExpression (Rule): # 0..20 "function_name(value)" - Expression (Rule): # 0..13 "function_name" - Identifier (Token): "function_name" # 0..13 - - ArgumentsDeclaration (Rule): # 13..20 "(value)" + - PositionalArgumentsDeclaration (Rule): # 13..20 "(value)" - OpenParen (Token): "(" # 13..14 - PositionalArguments (Rule): # 14..19 "value" - Expression (Rule): # 14..19 "value" diff --git a/crates/solidity/testing/snapshots/cst_output/Expression/index_slice_end/generated/0.4.11-success.yml b/crates/solidity/testing/snapshots/cst_output/Expression/index_slice_end/generated/0.4.11-success.yml index b83e96cd68..bfa1a01032 100644 --- a/crates/solidity/testing/snapshots/cst_output/Expression/index_slice_end/generated/0.4.11-success.yml +++ b/crates/solidity/testing/snapshots/cst_output/Expression/index_slice_end/generated/0.4.11-success.yml @@ -11,7 +11,8 @@ Tree: - Expression (Rule): # 0..3 "arr" - Identifier (Token): "arr" # 0..3 - OpenBracket (Token): "[" # 3..4 - - Colon (Token): ":" # 4..5 - - Expression (Rule): # 5..8 "end" - - Identifier (Token): "end" # 5..8 + - IndexAccessEnd (Rule): # 4..8 ":end" + - Colon (Token): ":" # 4..5 + - Expression (Rule): # 5..8 "end" + - Identifier (Token): "end" # 5..8 - CloseBracket (Token): "]" # 8..9 diff --git a/crates/solidity/testing/snapshots/cst_output/Expression/index_slice_start/generated/0.4.11-success.yml b/crates/solidity/testing/snapshots/cst_output/Expression/index_slice_start/generated/0.4.11-success.yml index d8e8d07b1f..abc7f34656 100644 --- a/crates/solidity/testing/snapshots/cst_output/Expression/index_slice_start/generated/0.4.11-success.yml +++ b/crates/solidity/testing/snapshots/cst_output/Expression/index_slice_start/generated/0.4.11-success.yml @@ -13,5 +13,6 @@ Tree: - OpenBracket (Token): "[" # 3..4 - Expression (Rule): # 4..9 "start" - Identifier (Token): "start" # 4..9 - - Colon (Token): ":" # 9..10 + - IndexAccessEnd (Rule): # 9..10 ":" + - Colon (Token): ":" # 9..10 - CloseBracket (Token): "]" # 10..11 diff --git a/crates/solidity/testing/snapshots/cst_output/Expression/index_slice_start_end/generated/0.4.11-success.yml b/crates/solidity/testing/snapshots/cst_output/Expression/index_slice_start_end/generated/0.4.11-success.yml index 9c394bfb08..bab2b1cf62 100644 --- a/crates/solidity/testing/snapshots/cst_output/Expression/index_slice_start_end/generated/0.4.11-success.yml +++ b/crates/solidity/testing/snapshots/cst_output/Expression/index_slice_start_end/generated/0.4.11-success.yml @@ -13,7 +13,8 @@ Tree: - OpenBracket (Token): "[" # 3..4 - Expression (Rule): # 4..9 "start" - Identifier (Token): "start" # 4..9 - - Colon (Token): ":" # 9..10 - - Expression (Rule): # 10..13 "end" - - Identifier (Token): "end" # 10..13 + - IndexAccessEnd (Rule): # 9..13 ":end" + - Colon (Token): ":" # 9..10 + - Expression (Rule): # 10..13 "end" + - Identifier (Token): "end" # 10..13 - CloseBracket (Token): "]" # 13..14 diff --git a/crates/solidity/testing/snapshots/cst_output/Expression/index_slice_unbounded/generated/0.4.11-success.yml b/crates/solidity/testing/snapshots/cst_output/Expression/index_slice_unbounded/generated/0.4.11-success.yml index d4a159481d..97158ca73e 100644 --- a/crates/solidity/testing/snapshots/cst_output/Expression/index_slice_unbounded/generated/0.4.11-success.yml +++ b/crates/solidity/testing/snapshots/cst_output/Expression/index_slice_unbounded/generated/0.4.11-success.yml @@ -11,5 +11,6 @@ Tree: - Expression (Rule): # 0..3 "arr" - Identifier (Token): "arr" # 0..3 - OpenBracket (Token): "[" # 3..4 - - Colon (Token): ":" # 4..5 + - IndexAccessEnd (Rule): # 4..5 ":" + - Colon (Token): ":" # 4..5 - CloseBracket (Token): "]" # 5..6 diff --git a/crates/solidity/testing/snapshots/cst_output/Expression/member_access_function_call/generated/0.4.11-success.yml b/crates/solidity/testing/snapshots/cst_output/Expression/member_access_function_call/generated/0.4.11-success.yml index 2e2dfb8e53..4e0de2ed3b 100644 --- a/crates/solidity/testing/snapshots/cst_output/Expression/member_access_function_call/generated/0.4.11-success.yml +++ b/crates/solidity/testing/snapshots/cst_output/Expression/member_access_function_call/generated/0.4.11-success.yml @@ -14,6 +14,6 @@ Tree: - Identifier (Token): "x" # 0..1 - Period (Token): "." # 1..2 - Identifier (Token): "y" # 2..3 - - ArgumentsDeclaration (Rule): # 3..5 "()" + - PositionalArgumentsDeclaration (Rule): # 3..5 "()" - OpenParen (Token): "(" # 3..4 - CloseParen (Token): ")" # 4..5 diff --git a/crates/solidity/testing/snapshots/cst_output/Expression/payable_call/generated/0.4.11-success.yml b/crates/solidity/testing/snapshots/cst_output/Expression/payable_call/generated/0.4.11-success.yml index db8c27986c..adc4be29f4 100644 --- a/crates/solidity/testing/snapshots/cst_output/Expression/payable_call/generated/0.4.11-success.yml +++ b/crates/solidity/testing/snapshots/cst_output/Expression/payable_call/generated/0.4.11-success.yml @@ -9,9 +9,8 @@ Tree: - Expression (Rule): # 0..14 "payable(value)" - FunctionCallExpression (Rule): # 0..14 "payable(value)" - Expression (Rule): # 0..7 "payable" - - AddressType (Rule): # 0..7 "payable" - - PayableKeyword (Token): "payable" # 0..7 - - ArgumentsDeclaration (Rule): # 7..14 "(value)" + - PayableKeyword (Token): "payable" # 0..7 + - PositionalArgumentsDeclaration (Rule): # 7..14 "(value)" - OpenParen (Token): "(" # 7..8 - PositionalArguments (Rule): # 8..13 "value" - Expression (Rule): # 8..13 "value" diff --git a/crates/solidity/testing/snapshots/cst_output/ImportDirective/destructure_import_multiple/generated/0.4.11-success.yml b/crates/solidity/testing/snapshots/cst_output/ImportDirective/destructure_import_multiple/generated/0.4.11-success.yml index 403168a68d..df047bbc0d 100644 --- a/crates/solidity/testing/snapshots/cst_output/ImportDirective/destructure_import_multiple/generated/0.4.11-success.yml +++ b/crates/solidity/testing/snapshots/cst_output/ImportDirective/destructure_import_multiple/generated/0.4.11-success.yml @@ -13,16 +13,18 @@ Tree: - ImportDeconstructionSymbols (Rule): # 8..31 " A1 as A2, B1, C1 as C2" - ImportDeconstructionSymbol (Rule): # 8..17 " A1 as A2" - Identifier (Token): "A1" # 9..11 - - AsKeyword (Token): "as" # 12..14 - - Identifier (Token): "A2" # 15..17 + - ImportAlias (Rule): # 11..17 " as A2" + - AsKeyword (Token): "as" # 12..14 + - Identifier (Token): "A2" # 15..17 - Comma (Token): "," # 17..18 - ImportDeconstructionSymbol (Rule): # 18..21 " B1" - Identifier (Token): "B1" # 19..21 - Comma (Token): "," # 21..22 - ImportDeconstructionSymbol (Rule): # 22..31 " C1 as C2" - Identifier (Token): "C1" # 23..25 - - AsKeyword (Token): "as" # 26..28 - - Identifier (Token): "C2" # 29..31 + - ImportAlias (Rule): # 25..31 " as C2" + - AsKeyword (Token): "as" # 26..28 + - Identifier (Token): "C2" # 29..31 - CloseBrace (Token): "}" # 32..33 - FromKeyword (Token): "from" # 34..38 - AsciiStringLiteral (Token): '"foo"' # 39..44 diff --git a/crates/solidity/testing/snapshots/cst_output/ImportDirective/destructure_import_single/generated/0.4.11-success.yml b/crates/solidity/testing/snapshots/cst_output/ImportDirective/destructure_import_single/generated/0.4.11-success.yml index a0d8d7633c..580d8d55bd 100644 --- a/crates/solidity/testing/snapshots/cst_output/ImportDirective/destructure_import_single/generated/0.4.11-success.yml +++ b/crates/solidity/testing/snapshots/cst_output/ImportDirective/destructure_import_single/generated/0.4.11-success.yml @@ -13,8 +13,9 @@ Tree: - ImportDeconstructionSymbols (Rule): # 8..15 " x as y" - ImportDeconstructionSymbol (Rule): # 8..15 " x as y" - Identifier (Token): "x" # 9..10 - - AsKeyword (Token): "as" # 11..13 - - Identifier (Token): "y" # 14..15 + - ImportAlias (Rule): # 10..15 " as y" + - AsKeyword (Token): "as" # 11..13 + - Identifier (Token): "y" # 14..15 - CloseBrace (Token): "}" # 16..17 - FromKeyword (Token): "from" # 18..22 - AsciiStringLiteral (Token): '"foo"' # 23..28 diff --git a/crates/solidity/testing/snapshots/cst_output/ImportDirective/named_import/generated/0.4.11-success.yml b/crates/solidity/testing/snapshots/cst_output/ImportDirective/named_import/generated/0.4.11-success.yml index 03a76fb81c..b0338d5bbb 100644 --- a/crates/solidity/testing/snapshots/cst_output/ImportDirective/named_import/generated/0.4.11-success.yml +++ b/crates/solidity/testing/snapshots/cst_output/ImportDirective/named_import/generated/0.4.11-success.yml @@ -10,8 +10,9 @@ Tree: - ImportKeyword (Token): "import" # 0..6 - NamedImport (Rule): # 6..26 ' * as foo from "bar"' - Asterisk (Token): "*" # 7..8 - - AsKeyword (Token): "as" # 9..11 - - Identifier (Token): "foo" # 12..15 + - ImportAlias (Rule): # 8..15 " as foo" + - AsKeyword (Token): "as" # 9..11 + - Identifier (Token): "foo" # 12..15 - FromKeyword (Token): "from" # 16..20 - AsciiStringLiteral (Token): '"bar"' # 21..26 - Semicolon (Token): ";" # 26..27 diff --git a/crates/solidity/testing/snapshots/cst_output/ImportDirective/path_import_with_alias/generated/0.4.11-success.yml b/crates/solidity/testing/snapshots/cst_output/ImportDirective/path_import_with_alias/generated/0.4.11-success.yml index a8a320ec38..f61f91b142 100644 --- a/crates/solidity/testing/snapshots/cst_output/ImportDirective/path_import_with_alias/generated/0.4.11-success.yml +++ b/crates/solidity/testing/snapshots/cst_output/ImportDirective/path_import_with_alias/generated/0.4.11-success.yml @@ -10,6 +10,7 @@ Tree: - ImportKeyword (Token): "import" # 0..6 - PathImport (Rule): # 6..19 ' "foo" as bar' - AsciiStringLiteral (Token): '"foo"' # 7..12 - - AsKeyword (Token): "as" # 13..15 - - Identifier (Token): "bar" # 16..19 + - ImportAlias (Rule): # 12..19 " as bar" + - AsKeyword (Token): "as" # 13..15 + - Identifier (Token): "bar" # 16..19 - Semicolon (Token): ";" # 19..20 diff --git a/crates/solidity/testing/snapshots/cst_output/MappingType/named_both/generated/0.4.11-failure.yml b/crates/solidity/testing/snapshots/cst_output/MappingType/named_both/generated/0.4.11-failure.yml index 174ca74981..7cef59751f 100644 --- a/crates/solidity/testing/snapshots/cst_output/MappingType/named_both/generated/0.4.11-failure.yml +++ b/crates/solidity/testing/snapshots/cst_output/MappingType/named_both/generated/0.4.11-failure.yml @@ -17,7 +17,7 @@ Tree: - MappingType (Rule): # 0..34 "mapping(string Foo => bytes32 Bar)" - MappingKeyword (Token): "mapping" # 0..7 - OpenParen (Token): "(" # 7..8 - - MappingKeyType (Rule): # 8..14 "string" + - MappingKey (Rule): # 8..14 "string" - StringKeyword (Token): "string" # 8..14 - SKIPPED (Token): "Foo => bytes32 Bar" # 15..33 - CloseParen (Token): ")" # 33..34 diff --git a/crates/solidity/testing/snapshots/cst_output/MappingType/named_both/generated/0.8.18-success.yml b/crates/solidity/testing/snapshots/cst_output/MappingType/named_both/generated/0.8.18-success.yml index dbc7268529..8bc144cf25 100644 --- a/crates/solidity/testing/snapshots/cst_output/MappingType/named_both/generated/0.8.18-success.yml +++ b/crates/solidity/testing/snapshots/cst_output/MappingType/named_both/generated/0.8.18-success.yml @@ -9,11 +9,11 @@ Tree: - MappingType (Rule): # 0..34 "mapping(string Foo => bytes32 Bar)" - MappingKeyword (Token): "mapping" # 0..7 - OpenParen (Token): "(" # 7..8 - - MappingKeyType (Rule): # 8..18 "string Foo" + - MappingKey (Rule): # 8..18 "string Foo" - StringKeyword (Token): "string" # 8..14 - Identifier (Token): "Foo" # 15..18 - EqualGreaterThan (Token): "=>" # 19..21 - - MappingValueType (Rule): # 21..33 " bytes32 Bar" + - MappingValue (Rule): # 21..33 " bytes32 Bar" - TypeName (Rule): # 21..29 " bytes32" - BytesKeyword (Token): "bytes32" # 22..29 - Identifier (Token): "Bar" # 30..33 diff --git a/crates/solidity/testing/snapshots/cst_output/MappingType/named_key/generated/0.4.11-failure.yml b/crates/solidity/testing/snapshots/cst_output/MappingType/named_key/generated/0.4.11-failure.yml index 2110c69fb5..63eff7ca3e 100644 --- a/crates/solidity/testing/snapshots/cst_output/MappingType/named_key/generated/0.4.11-failure.yml +++ b/crates/solidity/testing/snapshots/cst_output/MappingType/named_key/generated/0.4.11-failure.yml @@ -17,7 +17,7 @@ Tree: - MappingType (Rule): # 0..30 "mapping(string Foo => bytes32)" - MappingKeyword (Token): "mapping" # 0..7 - OpenParen (Token): "(" # 7..8 - - MappingKeyType (Rule): # 8..14 "string" + - MappingKey (Rule): # 8..14 "string" - StringKeyword (Token): "string" # 8..14 - SKIPPED (Token): "Foo => bytes32" # 15..29 - CloseParen (Token): ")" # 29..30 diff --git a/crates/solidity/testing/snapshots/cst_output/MappingType/named_key/generated/0.8.18-success.yml b/crates/solidity/testing/snapshots/cst_output/MappingType/named_key/generated/0.8.18-success.yml index 9efa00211b..50b71185df 100644 --- a/crates/solidity/testing/snapshots/cst_output/MappingType/named_key/generated/0.8.18-success.yml +++ b/crates/solidity/testing/snapshots/cst_output/MappingType/named_key/generated/0.8.18-success.yml @@ -9,11 +9,11 @@ Tree: - MappingType (Rule): # 0..30 "mapping(string Foo => bytes32)" - MappingKeyword (Token): "mapping" # 0..7 - OpenParen (Token): "(" # 7..8 - - MappingKeyType (Rule): # 8..18 "string Foo" + - MappingKey (Rule): # 8..18 "string Foo" - StringKeyword (Token): "string" # 8..14 - Identifier (Token): "Foo" # 15..18 - EqualGreaterThan (Token): "=>" # 19..21 - - MappingValueType (Rule): # 21..29 " bytes32" + - MappingValue (Rule): # 21..29 " bytes32" - TypeName (Rule): # 21..29 " bytes32" - BytesKeyword (Token): "bytes32" # 22..29 - CloseParen (Token): ")" # 29..30 diff --git a/crates/solidity/testing/snapshots/cst_output/MappingType/named_value/generated/0.4.11-failure.yml b/crates/solidity/testing/snapshots/cst_output/MappingType/named_value/generated/0.4.11-failure.yml index 0b4ad9a329..7cd1faca8b 100644 --- a/crates/solidity/testing/snapshots/cst_output/MappingType/named_value/generated/0.4.11-failure.yml +++ b/crates/solidity/testing/snapshots/cst_output/MappingType/named_value/generated/0.4.11-failure.yml @@ -17,10 +17,10 @@ Tree: - MappingType (Rule): # 0..30 "mapping(string => bytes32 Bar)" - MappingKeyword (Token): "mapping" # 0..7 - OpenParen (Token): "(" # 7..8 - - MappingKeyType (Rule): # 8..14 "string" + - MappingKey (Rule): # 8..14 "string" - StringKeyword (Token): "string" # 8..14 - EqualGreaterThan (Token): "=>" # 15..17 - - MappingValueType (Rule): # 17..25 " bytes32" + - MappingValue (Rule): # 17..25 " bytes32" - TypeName (Rule): # 17..25 " bytes32" - BytesKeyword (Token): "bytes32" # 18..25 - SKIPPED (Token): "Bar" # 26..29 diff --git a/crates/solidity/testing/snapshots/cst_output/MappingType/named_value/generated/0.8.18-success.yml b/crates/solidity/testing/snapshots/cst_output/MappingType/named_value/generated/0.8.18-success.yml index b23cc6a8fd..b86e4b017e 100644 --- a/crates/solidity/testing/snapshots/cst_output/MappingType/named_value/generated/0.8.18-success.yml +++ b/crates/solidity/testing/snapshots/cst_output/MappingType/named_value/generated/0.8.18-success.yml @@ -9,10 +9,10 @@ Tree: - MappingType (Rule): # 0..30 "mapping(string => bytes32 Bar)" - MappingKeyword (Token): "mapping" # 0..7 - OpenParen (Token): "(" # 7..8 - - MappingKeyType (Rule): # 8..14 "string" + - MappingKey (Rule): # 8..14 "string" - StringKeyword (Token): "string" # 8..14 - EqualGreaterThan (Token): "=>" # 15..17 - - MappingValueType (Rule): # 17..29 " bytes32 Bar" + - MappingValue (Rule): # 17..29 " bytes32 Bar" - TypeName (Rule): # 17..25 " bytes32" - BytesKeyword (Token): "bytes32" # 18..25 - Identifier (Token): "Bar" # 26..29 diff --git a/crates/solidity/testing/snapshots/cst_output/MappingType/stray_delimiter/generated/0.4.11-failure.yml b/crates/solidity/testing/snapshots/cst_output/MappingType/stray_delimiter/generated/0.4.11-failure.yml index ed93fcd8ab..2c791730d9 100644 --- a/crates/solidity/testing/snapshots/cst_output/MappingType/stray_delimiter/generated/0.4.11-failure.yml +++ b/crates/solidity/testing/snapshots/cst_output/MappingType/stray_delimiter/generated/0.4.11-failure.yml @@ -17,10 +17,10 @@ Tree: - MappingType (Rule): # 0..32 "mapping(string => bytes32] arg)\n" - MappingKeyword (Token): "mapping" # 0..7 - OpenParen (Token): "(" # 7..8 - - MappingKeyType (Rule): # 8..14 "string" + - MappingKey (Rule): # 8..14 "string" - StringKeyword (Token): "string" # 8..14 - EqualGreaterThan (Token): "=>" # 15..17 - - MappingValueType (Rule): # 17..25 " bytes32" + - MappingValue (Rule): # 17..25 " bytes32" - TypeName (Rule): # 17..25 " bytes32" - BytesKeyword (Token): "bytes32" # 18..25 - SKIPPED (Token): "] arg" # 25..30 diff --git a/crates/solidity/testing/snapshots/cst_output/MappingType/stray_delimiter/generated/0.8.18-failure.yml b/crates/solidity/testing/snapshots/cst_output/MappingType/stray_delimiter/generated/0.8.18-failure.yml index cc97708fb1..a7ea185b8b 100644 --- a/crates/solidity/testing/snapshots/cst_output/MappingType/stray_delimiter/generated/0.8.18-failure.yml +++ b/crates/solidity/testing/snapshots/cst_output/MappingType/stray_delimiter/generated/0.8.18-failure.yml @@ -17,10 +17,10 @@ Tree: - MappingType (Rule): # 0..32 "mapping(string => bytes32] arg)\n" - MappingKeyword (Token): "mapping" # 0..7 - OpenParen (Token): "(" # 7..8 - - MappingKeyType (Rule): # 8..14 "string" + - MappingKey (Rule): # 8..14 "string" - StringKeyword (Token): "string" # 8..14 - EqualGreaterThan (Token): "=>" # 15..17 - - MappingValueType (Rule): # 17..25 " bytes32" + - MappingValue (Rule): # 17..25 " bytes32" - TypeName (Rule): # 17..25 " bytes32" - BytesKeyword (Token): "bytes32" # 18..25 - SKIPPED (Token): "] arg" # 25..30 diff --git a/crates/solidity/testing/snapshots/cst_output/MappingType/unnamed/generated/0.4.11-success.yml b/crates/solidity/testing/snapshots/cst_output/MappingType/unnamed/generated/0.4.11-success.yml index 6d106c37c1..d53fbb4225 100644 --- a/crates/solidity/testing/snapshots/cst_output/MappingType/unnamed/generated/0.4.11-success.yml +++ b/crates/solidity/testing/snapshots/cst_output/MappingType/unnamed/generated/0.4.11-success.yml @@ -9,10 +9,10 @@ Tree: - MappingType (Rule): # 0..26 "mapping(string => bytes32)" - MappingKeyword (Token): "mapping" # 0..7 - OpenParen (Token): "(" # 7..8 - - MappingKeyType (Rule): # 8..14 "string" + - MappingKey (Rule): # 8..14 "string" - StringKeyword (Token): "string" # 8..14 - EqualGreaterThan (Token): "=>" # 15..17 - - MappingValueType (Rule): # 17..25 " bytes32" + - MappingValue (Rule): # 17..25 " bytes32" - TypeName (Rule): # 17..25 " bytes32" - BytesKeyword (Token): "bytes32" # 18..25 - CloseParen (Token): ")" # 25..26 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 7a59bb7f73..333c68b909 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 @@ -62,18 +62,18 @@ Tree: - OpenBrace (Token): "{" # 113..114 - Statements (Rule): # 115..200 " uint256 c = a + b;\n if (c < a) return (..." - VariableDeclarationStatement (Rule): # 115..140 " uint256 c = a + b;\n" - - VariableDeclaration (Rule): # 115..130 " uint256 c" - - TypeName (Rule): # 115..128 " uint256" - - UintKeyword (Token): "uint256" # 121..128 - - Identifier (Token): "c" # 129..130 - - Equal (Token): "=" # 131..132 - - Expression (Rule): # 132..138 " a + b" - - BinaryExpression (Rule): # 132..138 " a + b" - - Expression (Rule): # 132..134 " a" - - Identifier (Token): "a" # 133..134 - - Plus (Token): "+" # 135..136 - - Expression (Rule): # 136..138 " b" - - Identifier (Token): "b" # 137..138 + - TypeName (Rule): # 115..128 " uint256" + - UintKeyword (Token): "uint256" # 121..128 + - Identifier (Token): "c" # 129..130 + - VariableDeclarationValue (Rule): # 130..138 " = a + b" + - Equal (Token): "=" # 131..132 + - Expression (Rule): # 132..138 " a + b" + - BinaryExpression (Rule): # 132..138 " a + b" + - Expression (Rule): # 132..134 " a" + - Identifier (Token): "a" # 133..134 + - Plus (Token): "+" # 135..136 + - Expression (Rule): # 136..138 " b" + - Identifier (Token): "b" # 137..138 - Semicolon (Token): ";" # 138..139 - IfStatement (Rule): # 140..176 " if (c < a) return (false, 0);\n" - IfKeyword (Token): "if" # 146..148 @@ -92,12 +92,14 @@ Tree: - TupleExpression (Rule): # 163..174 " (false, 0)" - OpenParen (Token): "(" # 164..165 - TupleValues (Rule): # 165..173 "false, 0" - - Expression (Rule): # 165..170 "false" - - FalseKeyword (Token): "false" # 165..170 + - TupleValue (Rule): # 165..170 "false" + - Expression (Rule): # 165..170 "false" + - FalseKeyword (Token): "false" # 165..170 - Comma (Token): "," # 170..171 - - Expression (Rule): # 171..173 " 0" - - DecimalNumberExpression (Rule): # 171..173 " 0" - - DecimalLiteral (Token): "0" # 172..173 + - TupleValue (Rule): # 171..173 " 0" + - Expression (Rule): # 171..173 " 0" + - DecimalNumberExpression (Rule): # 171..173 " 0" + - DecimalLiteral (Token): "0" # 172..173 - CloseParen (Token): ")" # 173..174 - Semicolon (Token): ";" # 174..175 - ReturnStatement (Rule): # 176..200 " return (true, c);\n" @@ -106,11 +108,13 @@ Tree: - TupleExpression (Rule): # 188..198 " (true, c)" - OpenParen (Token): "(" # 189..190 - TupleValues (Rule): # 190..197 "true, c" - - Expression (Rule): # 190..194 "true" - - TrueKeyword (Token): "true" # 190..194 + - TupleValue (Rule): # 190..194 "true" + - Expression (Rule): # 190..194 "true" + - TrueKeyword (Token): "true" # 190..194 - Comma (Token): "," # 194..195 - - Expression (Rule): # 195..197 " c" - - Identifier (Token): "c" # 196..197 + - TupleValue (Rule): # 195..197 " c" + - Expression (Rule): # 195..197 " c" + - Identifier (Token): "c" # 196..197 - CloseParen (Token): ")" # 197..198 - Semicolon (Token): ";" # 198..199 - CloseBrace (Token): "}" # 204..205 diff --git a/crates/solidity/testing/snapshots/cst_output/TryStatement/try_catch/generated/0.6.0-success.yml b/crates/solidity/testing/snapshots/cst_output/TryStatement/try_catch/generated/0.6.0-success.yml index 9ae60be1a6..f5c1d43d93 100644 --- a/crates/solidity/testing/snapshots/cst_output/TryStatement/try_catch/generated/0.6.0-success.yml +++ b/crates/solidity/testing/snapshots/cst_output/TryStatement/try_catch/generated/0.6.0-success.yml @@ -16,7 +16,7 @@ Tree: - Identifier (Token): "a" # 4..5 - Period (Token): "." # 5..6 - Identifier (Token): "b" # 6..7 - - ArgumentsDeclaration (Rule): # 7..9 "()" + - PositionalArgumentsDeclaration (Rule): # 7..9 "()" - OpenParen (Token): "(" # 7..8 - CloseParen (Token): ")" # 8..9 - Block (Rule): # 9..12 " {}" diff --git a/crates/solidity/testing/snapshots/cst_output/TupleDeconstructionStatement/abi_decode_array_type/generated/0.4.11-success.yml b/crates/solidity/testing/snapshots/cst_output/TupleDeconstructionStatement/abi_decode_array_type/generated/0.4.11-success.yml index 717586bcca..3733963a12 100644 --- a/crates/solidity/testing/snapshots/cst_output/TupleDeconstructionStatement/abi_decode_array_type/generated/0.4.11-success.yml +++ b/crates/solidity/testing/snapshots/cst_output/TupleDeconstructionStatement/abi_decode_array_type/generated/0.4.11-success.yml @@ -35,7 +35,7 @@ Tree: - Identifier (Token): "abi" # 32..35 - Period (Token): "." # 35..36 - Identifier (Token): "decode" # 36..42 - - ArgumentsDeclaration (Rule): # 42..68 "(data, (uint32, uint32[]))" + - PositionalArgumentsDeclaration (Rule): # 42..68 "(data, (uint32, uint32[]))" - OpenParen (Token): "(" # 42..43 - PositionalArguments (Rule): # 43..67 "data, (uint32, uint32[])" - Expression (Rule): # 43..47 "data" @@ -45,15 +45,17 @@ Tree: - TupleExpression (Rule): # 48..67 " (uint32, uint32[])" - OpenParen (Token): "(" # 49..50 - TupleValues (Rule): # 50..66 "uint32, uint32[]" - - Expression (Rule): # 50..56 "uint32" - - UintKeyword (Token): "uint32" # 50..56 + - TupleValue (Rule): # 50..56 "uint32" + - Expression (Rule): # 50..56 "uint32" + - UintKeyword (Token): "uint32" # 50..56 - Comma (Token): "," # 56..57 - - Expression (Rule): # 57..66 " uint32[]" - - IndexAccessExpression (Rule): # 57..66 " uint32[]" - - Expression (Rule): # 57..64 " uint32" - - UintKeyword (Token): "uint32" # 58..64 - - OpenBracket (Token): "[" # 64..65 - - CloseBracket (Token): "]" # 65..66 + - TupleValue (Rule): # 57..66 " uint32[]" + - Expression (Rule): # 57..66 " uint32[]" + - IndexAccessExpression (Rule): # 57..66 " uint32[]" + - Expression (Rule): # 57..64 " uint32" + - UintKeyword (Token): "uint32" # 58..64 + - OpenBracket (Token): "[" # 64..65 + - CloseBracket (Token): "]" # 65..66 - CloseParen (Token): ")" # 66..67 - CloseParen (Token): ")" # 67..68 - Semicolon (Token): ";" # 68..69 diff --git a/crates/solidity/testing/snapshots/cst_output/TupleDeconstructionStatement/abi_decode_singleton_type/generated/0.4.11-success.yml b/crates/solidity/testing/snapshots/cst_output/TupleDeconstructionStatement/abi_decode_singleton_type/generated/0.4.11-success.yml index 08291c675a..6aee2231bf 100644 --- a/crates/solidity/testing/snapshots/cst_output/TupleDeconstructionStatement/abi_decode_singleton_type/generated/0.4.11-success.yml +++ b/crates/solidity/testing/snapshots/cst_output/TupleDeconstructionStatement/abi_decode_singleton_type/generated/0.4.11-success.yml @@ -30,7 +30,7 @@ Tree: - Identifier (Token): "abi" # 23..26 - Period (Token): "." # 26..27 - Identifier (Token): "decode" # 27..33 - - ArgumentsDeclaration (Rule): # 33..57 "(data, (uint32, uint32))" + - PositionalArgumentsDeclaration (Rule): # 33..57 "(data, (uint32, uint32))" - OpenParen (Token): "(" # 33..34 - PositionalArguments (Rule): # 34..56 "data, (uint32, uint32)" - Expression (Rule): # 34..38 "data" @@ -40,11 +40,13 @@ Tree: - TupleExpression (Rule): # 39..56 " (uint32, uint32)" - OpenParen (Token): "(" # 40..41 - TupleValues (Rule): # 41..55 "uint32, uint32" - - Expression (Rule): # 41..47 "uint32" - - UintKeyword (Token): "uint32" # 41..47 + - TupleValue (Rule): # 41..47 "uint32" + - Expression (Rule): # 41..47 "uint32" + - UintKeyword (Token): "uint32" # 41..47 - Comma (Token): "," # 47..48 - - Expression (Rule): # 48..55 " uint32" - - UintKeyword (Token): "uint32" # 49..55 + - TupleValue (Rule): # 48..55 " uint32" + - Expression (Rule): # 48..55 " uint32" + - UintKeyword (Token): "uint32" # 49..55 - CloseParen (Token): ")" # 55..56 - CloseParen (Token): ")" # 56..57 - Semicolon (Token): ";" # 57..58 diff --git a/crates/solidity/testing/snapshots/cst_output/TupleDeconstructionStatement/empty/generated/0.4.11-success.yml b/crates/solidity/testing/snapshots/cst_output/TupleDeconstructionStatement/empty/generated/0.4.11-success.yml index 4835b5b02e..7f45cb955b 100644 --- a/crates/solidity/testing/snapshots/cst_output/TupleDeconstructionStatement/empty/generated/0.4.11-success.yml +++ b/crates/solidity/testing/snapshots/cst_output/TupleDeconstructionStatement/empty/generated/0.4.11-success.yml @@ -18,6 +18,7 @@ Tree: - Expression (Rule): # 52..55 " ()" - TupleExpression (Rule): # 52..55 " ()" - OpenParen (Token): "(" # 53..54 - - TupleValues (Rule): [] # 54..54 + - TupleValues (Rule): # 54..54 + - TupleValue (Rule): [] # 54..54 - CloseParen (Token): ")" # 54..55 - Semicolon (Token): ";" # 55..56 diff --git a/crates/solidity/testing/snapshots/cst_output/TupleDeconstructionStatement/invalid_termination/generated/0.4.11-failure.yml b/crates/solidity/testing/snapshots/cst_output/TupleDeconstructionStatement/invalid_termination/generated/0.4.11-failure.yml index fa9246fa74..31ca1acaca 100644 --- a/crates/solidity/testing/snapshots/cst_output/TupleDeconstructionStatement/invalid_termination/generated/0.4.11-failure.yml +++ b/crates/solidity/testing/snapshots/cst_output/TupleDeconstructionStatement/invalid_termination/generated/0.4.11-failure.yml @@ -33,12 +33,14 @@ Tree: - TupleExpression (Rule): # 8..20 " (123, 135)\n" - OpenParen (Token): "(" # 9..10 - TupleValues (Rule): # 10..18 "123, 135" - - Expression (Rule): # 10..13 "123" - - DecimalNumberExpression (Rule): # 10..13 "123" - - DecimalLiteral (Token): "123" # 10..13 + - TupleValue (Rule): # 10..13 "123" + - Expression (Rule): # 10..13 "123" + - DecimalNumberExpression (Rule): # 10..13 "123" + - DecimalLiteral (Token): "123" # 10..13 - Comma (Token): "," # 13..14 - - Expression (Rule): # 14..18 " 135" - - DecimalNumberExpression (Rule): # 14..18 " 135" - - DecimalLiteral (Token): "135" # 15..18 + - TupleValue (Rule): # 14..18 " 135" + - Expression (Rule): # 14..18 " 135" + - DecimalNumberExpression (Rule): # 14..18 " 135" + - DecimalLiteral (Token): "135" # 15..18 - CloseParen (Token): ")" # 18..19 - SKIPPED (Token): "/**/\n{ throw; \n" # 20..35 diff --git a/crates/solidity/testing/snapshots/cst_output/TupleDeconstructionStatement/invalid_termination/generated/0.6.2-failure.yml b/crates/solidity/testing/snapshots/cst_output/TupleDeconstructionStatement/invalid_termination/generated/0.6.2-failure.yml index f66f8099c9..a84c184fb0 100644 --- a/crates/solidity/testing/snapshots/cst_output/TupleDeconstructionStatement/invalid_termination/generated/0.6.2-failure.yml +++ b/crates/solidity/testing/snapshots/cst_output/TupleDeconstructionStatement/invalid_termination/generated/0.6.2-failure.yml @@ -32,16 +32,18 @@ Tree: - TupleExpression (Rule): # 8..20 " (123, 135)\n" - OpenParen (Token): "(" # 9..10 - TupleValues (Rule): # 10..18 "123, 135" - - Expression (Rule): # 10..13 "123" - - DecimalNumberExpression (Rule): # 10..13 "123" - - DecimalLiteral (Token): "123" # 10..13 + - TupleValue (Rule): # 10..13 "123" + - Expression (Rule): # 10..13 "123" + - DecimalNumberExpression (Rule): # 10..13 "123" + - DecimalLiteral (Token): "123" # 10..13 - Comma (Token): "," # 13..14 - - Expression (Rule): # 14..18 " 135" - - DecimalNumberExpression (Rule): # 14..18 " 135" - - DecimalLiteral (Token): "135" # 15..18 + - TupleValue (Rule): # 14..18 " 135" + - Expression (Rule): # 14..18 " 135" + - DecimalNumberExpression (Rule): # 14..18 " 135" + - DecimalLiteral (Token): "135" # 15..18 - CloseParen (Token): ")" # 18..19 - - FunctionCallOptions (Rule): # 20..26 "/**/\n{" - - NamedArgumentsDeclaration (Rule): # 20..26 "/**/\n{" + - NamedArgumentGroups (Rule): # 20..26 "/**/\n{" + - NamedArgumentGroup (Rule): # 20..26 "/**/\n{" - LeadingTrivia (Rule): # 20..25 "/**/\n" - MultilineComment (Trivia): "/**/" # 20..24 - OpenBrace (Token): "{" # 25..26 diff --git a/crates/solidity/testing/snapshots/cst_output/TupleDeconstructionStatement/invalid_termination/generated/0.8.0-failure.yml b/crates/solidity/testing/snapshots/cst_output/TupleDeconstructionStatement/invalid_termination/generated/0.8.0-failure.yml new file mode 100644 index 0000000000..e53f2a106c --- /dev/null +++ b/crates/solidity/testing/snapshots/cst_output/TupleDeconstructionStatement/invalid_termination/generated/0.8.0-failure.yml @@ -0,0 +1,50 @@ +# This file is generated automatically by infrastructure scripts. Please don't edit by hand. + +Source: > + 1 │ (a, b) = (123, 135) │ 0..19 + 2 │ /**/ │ 20..24 + 3 │ { throw; │ 25..34 + +Errors: # 1 total + - > + Error: Expected CloseBrace or Identifier. + ╭─[crates/solidity/testing/snapshots/cst_output/TupleDeconstructionStatement/invalid_termination/input.sol:3:3] + │ + 3 │ { throw; + │ ──┬── + │ ╰──── Error occurred here. + ───╯ + +Tree: + - TupleDeconstructionStatement (Rule): # 0..35 "(a, b) = (123, 135)\n/**/\n{ throw; \n" + - OpenParen (Token): "(" # 0..1 + - TupleDeconstructionElements (Rule): # 1..5 "a, b" + - TupleDeconstructionElement (Rule): # 1..2 "a" + - UntypedTupleMember (Rule): # 1..2 "a" + - Identifier (Token): "a" # 1..2 + - Comma (Token): "," # 2..3 + - TupleDeconstructionElement (Rule): # 3..5 " b" + - UntypedTupleMember (Rule): # 3..5 " b" + - Identifier (Token): "b" # 4..5 + - CloseParen (Token): ")" # 5..6 + - Equal (Token): "=" # 7..8 + - Expression (Rule): # 8..26 " (123, 135)\n/**/\n{" + - TupleExpression (Rule): # 8..20 " (123, 135)\n" + - OpenParen (Token): "(" # 9..10 + - TupleValues (Rule): # 10..18 "123, 135" + - TupleValue (Rule): # 10..13 "123" + - Expression (Rule): # 10..13 "123" + - DecimalNumberExpression (Rule): # 10..13 "123" + - DecimalLiteral (Token): "123" # 10..13 + - Comma (Token): "," # 13..14 + - TupleValue (Rule): # 14..18 " 135" + - Expression (Rule): # 14..18 " 135" + - DecimalNumberExpression (Rule): # 14..18 " 135" + - DecimalLiteral (Token): "135" # 15..18 + - CloseParen (Token): ")" # 18..19 + - NamedArgumentGroup (Rule): # 20..26 "/**/\n{" + - LeadingTrivia (Rule): # 20..25 "/**/\n" + - MultilineComment (Trivia): "/**/" # 20..24 + - OpenBrace (Token): "{" # 25..26 + - SKIPPED (Token): "throw" # 27..32 + - Semicolon (Token): ";" # 32..33 diff --git a/crates/solidity/testing/snapshots/cst_output/TupleExpression/empty/generated/0.4.11-success.yml b/crates/solidity/testing/snapshots/cst_output/TupleExpression/empty/generated/0.4.11-success.yml index 5fb4f0a893..12e639e6a8 100644 --- a/crates/solidity/testing/snapshots/cst_output/TupleExpression/empty/generated/0.4.11-success.yml +++ b/crates/solidity/testing/snapshots/cst_output/TupleExpression/empty/generated/0.4.11-success.yml @@ -8,5 +8,6 @@ Errors: [] Tree: - TupleExpression (Rule): # 0..3 "( )" - OpenParen (Token): "(" # 0..1 - - TupleValues (Rule): [] # 1..1 + - TupleValues (Rule): # 1..1 + - TupleValue (Rule): [] # 1..1 - CloseParen (Token): ")" # 2..3 diff --git a/crates/solidity/testing/snapshots/cst_output/TupleExpression/full/generated/0.4.11-success.yml b/crates/solidity/testing/snapshots/cst_output/TupleExpression/full/generated/0.4.11-success.yml index 4d0a3397b3..0c378e46f5 100644 --- a/crates/solidity/testing/snapshots/cst_output/TupleExpression/full/generated/0.4.11-success.yml +++ b/crates/solidity/testing/snapshots/cst_output/TupleExpression/full/generated/0.4.11-success.yml @@ -9,15 +9,19 @@ Tree: - TupleExpression (Rule): # 0..30 "(first, second, third, fourth)" - OpenParen (Token): "(" # 0..1 - TupleValues (Rule): # 1..29 "first, second, third, fourth" - - Expression (Rule): # 1..6 "first" - - Identifier (Token): "first" # 1..6 + - TupleValue (Rule): # 1..6 "first" + - Expression (Rule): # 1..6 "first" + - Identifier (Token): "first" # 1..6 - Comma (Token): "," # 6..7 - - Expression (Rule): # 7..14 " second" - - Identifier (Token): "second" # 8..14 + - TupleValue (Rule): # 7..14 " second" + - Expression (Rule): # 7..14 " second" + - Identifier (Token): "second" # 8..14 - Comma (Token): "," # 14..15 - - Expression (Rule): # 15..21 " third" - - Identifier (Token): "third" # 16..21 + - TupleValue (Rule): # 15..21 " third" + - Expression (Rule): # 15..21 " third" + - Identifier (Token): "third" # 16..21 - Comma (Token): "," # 21..22 - - Expression (Rule): # 22..29 " fourth" - - Identifier (Token): "fourth" # 23..29 + - TupleValue (Rule): # 22..29 " fourth" + - Expression (Rule): # 22..29 " fourth" + - Identifier (Token): "fourth" # 23..29 - CloseParen (Token): ")" # 29..30 diff --git a/crates/solidity/testing/snapshots/cst_output/TupleExpression/missing_elements/generated/0.4.11-success.yml b/crates/solidity/testing/snapshots/cst_output/TupleExpression/missing_elements/generated/0.4.11-success.yml index 456a15bfba..4073f1c648 100644 --- a/crates/solidity/testing/snapshots/cst_output/TupleExpression/missing_elements/generated/0.4.11-success.yml +++ b/crates/solidity/testing/snapshots/cst_output/TupleExpression/missing_elements/generated/0.4.11-success.yml @@ -9,11 +9,15 @@ Tree: - TupleExpression (Rule): # 0..20 "(, second, , fourth)" - OpenParen (Token): "(" # 0..1 - TupleValues (Rule): # 1..19 ", second, , fourth" + - TupleValue (Rule): [] # 1..1 - Comma (Token): "," # 1..2 - - Expression (Rule): # 2..9 " second" - - Identifier (Token): "second" # 3..9 + - TupleValue (Rule): # 2..9 " second" + - Expression (Rule): # 2..9 " second" + - Identifier (Token): "second" # 3..9 - Comma (Token): "," # 9..10 + - TupleValue (Rule): [] # 10..10 - Comma (Token): "," # 11..12 - - Expression (Rule): # 12..19 " fourth" - - Identifier (Token): "fourth" # 13..19 + - TupleValue (Rule): # 12..19 " fourth" + - Expression (Rule): # 12..19 " fourth" + - Identifier (Token): "fourth" # 13..19 - CloseParen (Token): ")" # 19..20 diff --git a/crates/solidity/testing/snapshots/cst_output/UsingDeconstructionSymbol/identifier_path_as_operator/generated/0.8.19-success.yml b/crates/solidity/testing/snapshots/cst_output/UsingDeconstructionSymbol/identifier_path_as_operator/generated/0.8.19-success.yml index 873462110c..31f4a4da8f 100644 --- a/crates/solidity/testing/snapshots/cst_output/UsingDeconstructionSymbol/identifier_path_as_operator/generated/0.8.19-success.yml +++ b/crates/solidity/testing/snapshots/cst_output/UsingDeconstructionSymbol/identifier_path_as_operator/generated/0.8.19-success.yml @@ -11,5 +11,6 @@ Tree: - Identifier (Token): "foo" # 0..3 - Period (Token): "." # 3..4 - Identifier (Token): "bar" # 4..7 - - AsKeyword (Token): "as" # 8..10 - - Slash (Token): "/" # 11..12 + - UsingAlias (Rule): # 7..12 " as /" + - AsKeyword (Token): "as" # 8..10 + - Slash (Token): "/" # 11..12 diff --git a/crates/solidity/testing/snapshots/cst_output/UsingDeconstructionSymbol/single_id_as_operator/generated/0.8.19-success.yml b/crates/solidity/testing/snapshots/cst_output/UsingDeconstructionSymbol/single_id_as_operator/generated/0.8.19-success.yml index fdbfbc2890..8af521e6c8 100644 --- a/crates/solidity/testing/snapshots/cst_output/UsingDeconstructionSymbol/single_id_as_operator/generated/0.8.19-success.yml +++ b/crates/solidity/testing/snapshots/cst_output/UsingDeconstructionSymbol/single_id_as_operator/generated/0.8.19-success.yml @@ -9,5 +9,6 @@ Tree: - UsingDeconstructionSymbol (Rule): # 0..8 "foo as /" - IdentifierPath (Rule): # 0..3 "foo" - Identifier (Token): "foo" # 0..3 - - AsKeyword (Token): "as" # 4..6 - - Slash (Token): "/" # 7..8 + - UsingAlias (Rule): # 3..8 " as /" + - AsKeyword (Token): "as" # 4..6 + - Slash (Token): "/" # 7..8 diff --git a/crates/solidity/testing/snapshots/cst_output/UsingDirective/destructure_multiple/generated/0.8.19-success.yml b/crates/solidity/testing/snapshots/cst_output/UsingDirective/destructure_multiple/generated/0.8.19-success.yml index c95720c406..d6cfb58268 100644 --- a/crates/solidity/testing/snapshots/cst_output/UsingDirective/destructure_multiple/generated/0.8.19-success.yml +++ b/crates/solidity/testing/snapshots/cst_output/UsingDirective/destructure_multiple/generated/0.8.19-success.yml @@ -14,8 +14,9 @@ Tree: - UsingDeconstructionSymbol (Rule): # 7..15 "add as +" - IdentifierPath (Rule): # 7..10 "add" - Identifier (Token): "add" # 7..10 - - AsKeyword (Token): "as" # 11..13 - - Plus (Token): "+" # 14..15 + - UsingAlias (Rule): # 10..15 " as +" + - AsKeyword (Token): "as" # 11..13 + - Plus (Token): "+" # 14..15 - Comma (Token): "," # 15..16 - UsingDeconstructionSymbol (Rule): # 16..20 " sub" - IdentifierPath (Rule): # 16..20 " sub" @@ -28,8 +29,9 @@ Tree: - UsingDeconstructionSymbol (Rule): # 26..35 " div as /" - IdentifierPath (Rule): # 26..30 " div" - Identifier (Token): "div" # 27..30 - - AsKeyword (Token): "as" # 31..33 - - Slash (Token): "/" # 34..35 + - UsingAlias (Rule): # 30..35 " as /" + - AsKeyword (Token): "as" # 31..33 + - Slash (Token): "/" # 34..35 - CloseBrace (Token): "}" # 35..36 - ForKeyword (Token): "for" # 37..40 - TypeName (Rule): # 40..44 " Int" diff --git a/crates/solidity/testing/snapshots/cst_output/UsingDirective/user_defined_operator/generated/0.8.19-success.yml b/crates/solidity/testing/snapshots/cst_output/UsingDirective/user_defined_operator/generated/0.8.19-success.yml index 846e36cea6..b8933b0136 100644 --- a/crates/solidity/testing/snapshots/cst_output/UsingDirective/user_defined_operator/generated/0.8.19-success.yml +++ b/crates/solidity/testing/snapshots/cst_output/UsingDirective/user_defined_operator/generated/0.8.19-success.yml @@ -14,8 +14,9 @@ Tree: - UsingDeconstructionSymbol (Rule): # 7..15 "div as /" - IdentifierPath (Rule): # 7..10 "div" - Identifier (Token): "div" # 7..10 - - AsKeyword (Token): "as" # 11..13 - - Slash (Token): "/" # 14..15 + - UsingAlias (Rule): # 10..15 " as /" + - AsKeyword (Token): "as" # 11..13 + - Slash (Token): "/" # 14..15 - CloseBrace (Token): "}" # 15..16 - ForKeyword (Token): "for" # 17..20 - TypeName (Rule): # 20..24 " Int" diff --git a/crates/solidity/testing/snapshots/cst_output/VariableDeclarationStatement/var/generated/0.4.11-success.yml b/crates/solidity/testing/snapshots/cst_output/VariableDeclarationStatement/var/generated/0.4.11-success.yml index 09c154a164..ce501c55f2 100644 --- a/crates/solidity/testing/snapshots/cst_output/VariableDeclarationStatement/var/generated/0.4.11-success.yml +++ b/crates/solidity/testing/snapshots/cst_output/VariableDeclarationStatement/var/generated/0.4.11-success.yml @@ -7,11 +7,11 @@ Errors: [] Tree: - VariableDeclarationStatement (Rule): # 0..10 "var z = 0;" - - VariableDeclaration (Rule): # 0..5 "var z" - - VarKeyword (Token): "var" # 0..3 - - Identifier (Token): "z" # 4..5 - - Equal (Token): "=" # 6..7 - - Expression (Rule): # 7..9 " 0" - - DecimalNumberExpression (Rule): # 7..9 " 0" - - DecimalLiteral (Token): "0" # 8..9 + - VarKeyword (Token): "var" # 0..3 + - Identifier (Token): "z" # 4..5 + - VariableDeclarationValue (Rule): # 5..9 " = 0" + - Equal (Token): "=" # 6..7 + - Expression (Rule): # 7..9 " 0" + - DecimalNumberExpression (Rule): # 7..9 " 0" + - DecimalLiteral (Token): "0" # 8..9 - Semicolon (Token): ";" # 9..10 diff --git a/crates/solidity/testing/snapshots/cst_output/YulBlock/function_def/generated/0.4.11-success.yml b/crates/solidity/testing/snapshots/cst_output/YulBlock/function_def/generated/0.4.11-success.yml index e84ef77ea8..b57d8f9200 100644 --- a/crates/solidity/testing/snapshots/cst_output/YulBlock/function_def/generated/0.4.11-success.yml +++ b/crates/solidity/testing/snapshots/cst_output/YulBlock/function_def/generated/0.4.11-success.yml @@ -14,18 +14,18 @@ Tree: - OpenBrace (Token): "{" # 0..1 - YulStatements (Rule): # 2..60 "\tfunction mult(a, b) -> result {\n\t\tresult := mul(a..." - YulFunctionDefinition (Rule): # 2..60 "\tfunction mult(a, b) -> result {\n\t\tresult := mul(a..." - - FunctionKeyword (Token): "function" # 3..11 + - YulFunctionKeyword (Token): "function" # 3..11 - YulIdentifier (Token): "mult" # 12..16 - YulParametersDeclaration (Rule): # 16..22 "(a, b)" - OpenParen (Token): "(" # 16..17 - - YulIdentifiers (Rule): # 17..21 "a, b" + - YulParameters (Rule): # 17..21 "a, b" - YulIdentifier (Token): "a" # 17..18 - Comma (Token): "," # 18..19 - YulIdentifier (Token): "b" # 20..21 - CloseParen (Token): ")" # 21..22 - YulReturnsDeclaration (Rule): # 22..32 " -> result" - MinusGreaterThan (Token): "->" # 23..25 - - YulIdentifiers (Rule): # 25..32 " result" + - YulReturnVariables (Rule): # 25..32 " result" - YulIdentifier (Token): "result" # 26..32 - YulBlock (Rule): # 32..60 " {\n\t\tresult := mul(a, b)\n\t}\n" - OpenBrace (Token): "{" # 33..34 diff --git a/crates/solidity/testing/snapshots/cst_output/YulBlock/ignore_unknown_delim/generated/0.4.11-failure.yml b/crates/solidity/testing/snapshots/cst_output/YulBlock/ignore_unknown_delim/generated/0.4.11-failure.yml index 0d02e1b089..9ff24e440d 100644 --- a/crates/solidity/testing/snapshots/cst_output/YulBlock/ignore_unknown_delim/generated/0.4.11-failure.yml +++ b/crates/solidity/testing/snapshots/cst_output/YulBlock/ignore_unknown_delim/generated/0.4.11-failure.yml @@ -10,7 +10,7 @@ Source: > Errors: # 1 total - > - Error: Expected AsciiStringLiteral or BreakKeyword or CloseBrace or ContinueKeyword or FalseKeyword or ForKeyword or FunctionKeyword or HexStringLiteral or IfKeyword or LetKeyword or OpenBrace or SwitchKeyword or TrueKeyword or YulDecimalLiteral or YulHexLiteral or YulIdentifier. + Error: Expected AsciiStringLiteral or CloseBrace or HexStringLiteral or OpenBrace or YulBreakKeyword or YulContinueKeyword or YulDecimalLiteral or YulFalseKeyword or YulForKeyword or YulFunctionKeyword or YulHexLiteral or YulIdentifier or YulIfKeyword or YulLetKeyword or YulSwitchKeyword or YulTrueKeyword. ╭─[crates/solidity/testing/snapshots/cst_output/YulBlock/ignore_unknown_delim/input.sol:4:10] │ 4 │ ╭─▶ result := [mul(a, b) @@ -24,18 +24,18 @@ Tree: - OpenBrace (Token): "{" # 0..1 - YulStatements (Rule): # 2..83 "\tfunction mult(a, b) -> result {\n\t\tresult := mul(a..." - YulFunctionDefinition (Rule): # 2..83 "\tfunction mult(a, b) -> result {\n\t\tresult := mul(a..." - - FunctionKeyword (Token): "function" # 3..11 + - YulFunctionKeyword (Token): "function" # 3..11 - YulIdentifier (Token): "mult" # 12..16 - YulParametersDeclaration (Rule): # 16..22 "(a, b)" - OpenParen (Token): "(" # 16..17 - - YulIdentifiers (Rule): # 17..21 "a, b" + - YulParameters (Rule): # 17..21 "a, b" - YulIdentifier (Token): "a" # 17..18 - Comma (Token): "," # 18..19 - YulIdentifier (Token): "b" # 20..21 - CloseParen (Token): ")" # 21..22 - YulReturnsDeclaration (Rule): # 22..32 " -> result" - MinusGreaterThan (Token): "->" # 23..25 - - YulIdentifiers (Rule): # 25..32 " result" + - YulReturnVariables (Rule): # 25..32 " result" - YulIdentifier (Token): "result" # 26..32 - YulBlock (Rule): # 32..83 " {\n\t\tresult := mul(a, b)\n\t\tresult := [mul(a, b)\n\t}..." - OpenBrace (Token): "{" # 33..34 diff --git a/crates/solidity/testing/snapshots/cst_output/YulBlock/ignore_unknown_delim/generated/0.6.0-failure.yml b/crates/solidity/testing/snapshots/cst_output/YulBlock/ignore_unknown_delim/generated/0.6.0-failure.yml index bf6bddf2f8..61c967ad17 100644 --- a/crates/solidity/testing/snapshots/cst_output/YulBlock/ignore_unknown_delim/generated/0.6.0-failure.yml +++ b/crates/solidity/testing/snapshots/cst_output/YulBlock/ignore_unknown_delim/generated/0.6.0-failure.yml @@ -10,7 +10,7 @@ Source: > Errors: # 1 total - > - Error: Expected AsciiStringLiteral or BreakKeyword or CloseBrace or ContinueKeyword or FalseKeyword or ForKeyword or FunctionKeyword or HexStringLiteral or IfKeyword or LeaveKeyword or LetKeyword or OpenBrace or SwitchKeyword or TrueKeyword or YulDecimalLiteral or YulHexLiteral or YulIdentifier. + Error: Expected AsciiStringLiteral or CloseBrace or HexStringLiteral or OpenBrace or YulBreakKeyword or YulContinueKeyword or YulDecimalLiteral or YulFalseKeyword or YulForKeyword or YulFunctionKeyword or YulHexLiteral or YulIdentifier or YulIfKeyword or YulLeaveKeyword or YulLetKeyword or YulSwitchKeyword or YulTrueKeyword. ╭─[crates/solidity/testing/snapshots/cst_output/YulBlock/ignore_unknown_delim/input.sol:4:10] │ 4 │ ╭─▶ result := [mul(a, b) @@ -24,18 +24,18 @@ Tree: - OpenBrace (Token): "{" # 0..1 - YulStatements (Rule): # 2..83 "\tfunction mult(a, b) -> result {\n\t\tresult := mul(a..." - YulFunctionDefinition (Rule): # 2..83 "\tfunction mult(a, b) -> result {\n\t\tresult := mul(a..." - - FunctionKeyword (Token): "function" # 3..11 + - YulFunctionKeyword (Token): "function" # 3..11 - YulIdentifier (Token): "mult" # 12..16 - YulParametersDeclaration (Rule): # 16..22 "(a, b)" - OpenParen (Token): "(" # 16..17 - - YulIdentifiers (Rule): # 17..21 "a, b" + - YulParameters (Rule): # 17..21 "a, b" - YulIdentifier (Token): "a" # 17..18 - Comma (Token): "," # 18..19 - YulIdentifier (Token): "b" # 20..21 - CloseParen (Token): ")" # 21..22 - YulReturnsDeclaration (Rule): # 22..32 " -> result" - MinusGreaterThan (Token): "->" # 23..25 - - YulIdentifiers (Rule): # 25..32 " result" + - YulReturnVariables (Rule): # 25..32 " result" - YulIdentifier (Token): "result" # 26..32 - YulBlock (Rule): # 32..83 " {\n\t\tresult := mul(a, b)\n\t\tresult := [mul(a, b)\n\t}..." - OpenBrace (Token): "{" # 33..34 diff --git a/crates/solidity/testing/snapshots/cst_output/YulExpression/decimal_trailing_ident_start/generated/0.4.11-failure.yml b/crates/solidity/testing/snapshots/cst_output/YulExpression/decimal_trailing_ident_start/generated/0.4.11-failure.yml index 5ef6e83d6d..49dfe38937 100644 --- a/crates/solidity/testing/snapshots/cst_output/YulExpression/decimal_trailing_ident_start/generated/0.4.11-failure.yml +++ b/crates/solidity/testing/snapshots/cst_output/YulExpression/decimal_trailing_ident_start/generated/0.4.11-failure.yml @@ -5,7 +5,7 @@ Source: > Errors: # 1 total - > - Error: Expected AsciiStringLiteral or FalseKeyword or HexStringLiteral or TrueKeyword or YulDecimalLiteral or YulHexLiteral or YulIdentifier. + Error: Expected AsciiStringLiteral or HexStringLiteral or YulDecimalLiteral or YulFalseKeyword or YulHexLiteral or YulIdentifier or YulTrueKeyword. ╭─[crates/solidity/testing/snapshots/cst_output/YulExpression/decimal_trailing_ident_start/input.sol:1:1] │ 1 │ 1a diff --git a/crates/solidity/testing/snapshots/cst_output/YulExpression/hex_trailing_ident_start/generated/0.4.11-failure.yml b/crates/solidity/testing/snapshots/cst_output/YulExpression/hex_trailing_ident_start/generated/0.4.11-failure.yml index a3f3ae7d13..5ac4586226 100644 --- a/crates/solidity/testing/snapshots/cst_output/YulExpression/hex_trailing_ident_start/generated/0.4.11-failure.yml +++ b/crates/solidity/testing/snapshots/cst_output/YulExpression/hex_trailing_ident_start/generated/0.4.11-failure.yml @@ -5,7 +5,7 @@ Source: > Errors: # 1 total - > - Error: Expected AsciiStringLiteral or FalseKeyword or HexStringLiteral or TrueKeyword or YulDecimalLiteral or YulHexLiteral or YulIdentifier. + Error: Expected AsciiStringLiteral or HexStringLiteral or YulDecimalLiteral or YulFalseKeyword or YulHexLiteral or YulIdentifier or YulTrueKeyword. ╭─[crates/solidity/testing/snapshots/cst_output/YulExpression/hex_trailing_ident_start/input.sol:1:1] │ 1 │ 0x1$ diff --git a/crates/solidity/testing/snapshots/cst_output/YulLeaveStatement/leave/generated/0.6.0-success.yml b/crates/solidity/testing/snapshots/cst_output/YulLeaveStatement/leave/generated/0.6.0-success.yml index 5107cf5f6e..27a17b1ae9 100644 --- a/crates/solidity/testing/snapshots/cst_output/YulLeaveStatement/leave/generated/0.6.0-success.yml +++ b/crates/solidity/testing/snapshots/cst_output/YulLeaveStatement/leave/generated/0.6.0-success.yml @@ -7,4 +7,4 @@ Errors: [] Tree: - YulLeaveStatement (Rule): # 0..5 "leave" - - LeaveKeyword (Token): "leave" # 0..5 + - YulLeaveKeyword (Token): "leave" # 0..5