- return false;
- }
- }
- }
-
- bool parse_type ()
- {
- int next = peek_token ();
-
- if (is_simple_type (next)){
- token ();
- next = peek_token ();
- if (next == Token.INTERR)
- token ();
- return parse_opt_rank (peek_token ());
- }
- if (parse_namespace_or_typename (next)){
- next = peek_token ();
- if (next == Token.INTERR)
- token ();
- return parse_opt_rank (peek_token ());
- } else if (is_builtin_reference_type (next)){
- token ();
- return parse_opt_rank (peek_token ());
- }
-
- return false;
- }
-
- //
- // Invoked after '(' has been seen and tries to parse:
- // type identifier [, type identifier]*
- //
- // if this is the case, instead of returning an
- // OPEN_PARENS token we return a special token that
- // triggers lambda parsing.
- //
- // This is needed because we can not introduce the
- // explicitly_typed_lambda_parameter_list after a '(' in the
- // grammar without introducing reduce/reduce conflicts.
- //
- // We need to parse a type and if it is followed by an
- // identifier, we know it has to be parsed as a lambda
- // expression.
- //
- // the type expression can be prefixed with `ref' or `out'
- //
- public bool parse_lambda_parameters ()
- {
- while (true){
- int next = peek_token ();
-
- if (next == Token.REF || next == Token.OUT)
- token ();
-
- if (parse_type ()){
- next = peek_token ();
- if (next == Token.IDENTIFIER){
- token ();
- next = peek_token ();
- if (next == Token.COMMA){
- token ();
- continue;
- }
- if (next == Token.CLOSE_PARENS)
- return true;
- }
- }
- return false;
- }
- }
-