diff --git a/boa/src/syntax/parser/expression/mod.rs b/boa/src/syntax/parser/expression/mod.rs index fe9060854e8..66ef2a99dec 100644 --- a/boa/src/syntax/parser/expression/mod.rs +++ b/boa/src/syntax/parser/expression/mod.rs @@ -45,16 +45,21 @@ impl PartialEq for Keyword { } } -/// Generates an expression parser. +/// Generates an expression parser for a number of expressions whose production rules are of the following pattern. +/// [allowed_identifiers] +/// => [?allowed_identifiers] +/// => [?allowed_identifiers] [?allowed_identifiers] +/// => [?allowed_identifiers] [?allowed_identifiers] +/// ... /// /// This macro has 2 mandatory identifiers: -/// - The `$name` identifier will contain the name of the parsing structure. -/// - The `$lower` identifier will contain the parser for lower level expressions. +/// - The `$name` identifier is the name of the TargetExpression struct that the parser will be implemented for. +/// - The `$lower` identifier is the name of the InnerExpression struct according to the pattern above. /// -/// Those exressions are divided by the punctuators passed as the third parameter. +/// A list of punctuators (operands between the and ) are passed as the third parameter. /// /// The fifth parameter is an Option which sets the goal symbol to set before parsing (or None to leave it as is). -macro_rules! expression { ($name:ident, $lower:ident, [$( $op:path ),*], [$( $low_param:ident ),*], $goal:expr, $profile:expr ) => { +macro_rules! expression { ($name:ident, $lower:ident, [$( $op:path ),*], [$( $low_param:ident ),*], $goal:expr ) => { impl TokenParser for $name where R: Read @@ -62,7 +67,7 @@ macro_rules! expression { ($name:ident, $lower:ident, [$( $op:path ),*], [$( $lo type Output = Node; fn parse(self, cursor: &mut Cursor)-> ParseResult { - let _timer = BoaProfiler::global().start_event($profile, "Parsing"); + let _timer = BoaProfiler::global().start_event(stringify!($name), "Parsing"); if $goal.is_some() { cursor.set_goal($goal.unwrap()); @@ -132,8 +137,7 @@ expression!( AssignmentExpression, [Punctuator::Comma], [allow_in, allow_yield, allow_await], - None::, - "Expression" + None:: ); /// Parses a logical `OR` expression. @@ -172,8 +176,7 @@ expression!( LogicalANDExpression, [Punctuator::BoolOr], [allow_in, allow_yield, allow_await], - None::, - "LogicalOrExpression" + None:: ); /// Parses a logical `AND` expression. @@ -212,8 +215,7 @@ expression!( BitwiseORExpression, [Punctuator::BoolAnd], [allow_in, allow_yield, allow_await], - None::, - "LogicalANDExpression" + None:: ); /// Parses a bitwise `OR` expression. @@ -252,8 +254,7 @@ expression!( BitwiseXORExpression, [Punctuator::Or], [allow_in, allow_yield, allow_await], - None::, - "BitwiseORExpression" + None:: ); /// Parses a bitwise `XOR` expression. @@ -292,8 +293,7 @@ expression!( BitwiseANDExpression, [Punctuator::Xor], [allow_in, allow_yield, allow_await], - None::, - "BitwiseXORExpression" + None:: ); /// Parses a bitwise `AND` expression. @@ -332,8 +332,7 @@ expression!( EqualityExpression, [Punctuator::And], [allow_in, allow_yield, allow_await], - None::, - "BitwiseANDExpression" + None:: ); /// Parses an equality expression. @@ -377,8 +376,7 @@ expression!( Punctuator::StrictNotEq ], [allow_in, allow_yield, allow_await], - None::, - "EqualityExpression" + None:: ); /// Parses a relational expression. @@ -424,8 +422,7 @@ expression!( Keyword::In ], [allow_yield, allow_await], - None::, - "RelationoalExpression" + None:: ); /// Parses a bitwise shift expression. @@ -465,8 +462,7 @@ expression!( Punctuator::URightSh ], [allow_yield, allow_await], - None::, - "ShiftExpression" + None:: ); /// Parses an additive expression. @@ -504,8 +500,7 @@ expression!( MultiplicativeExpression, [Punctuator::Add, Punctuator::Sub], [allow_yield, allow_await], - None::, - "AdditiveExpression" + None:: ); /// Parses a multiplicative expression. @@ -543,6 +538,5 @@ expression!( ExponentiationExpression, [Punctuator::Mul, Punctuator::Div, Punctuator::Mod], [allow_yield, allow_await], - Some(InputElement::Div), - "MultiplicativeExpression" + Some(InputElement::Div) );