@@ -247,14 +247,6 @@ auto Parser::prec(TokenKind tk) -> Parser::Prec {
247247 } // switch
248248}
249249
250- auto Parser::is_c () const -> bool {
251- return unit->language () == LanguageKind::kC ;
252- }
253-
254- auto Parser::is_cxx () const -> bool {
255- return unit->language () == LanguageKind::kCXX ;
256- }
257-
258250auto Parser::LA (int n) const -> const Token& {
259251 return unit->tokenAt (SourceLocation (cursor_ + n));
260252}
@@ -1073,6 +1065,8 @@ auto Parser::parse_template_nested_name_specifier(
10731065auto Parser::parse_nested_name_specifier (NestedNameSpecifierAST*& yyast,
10741066 NestedNameSpecifierContext ctx)
10751067 -> bool {
1068+ if (!is_parsing_cxx ()) return false ;
1069+
10761070 if (SourceLocation scopeLoc; match (TokenKind::T_COLON_COLON, scopeLoc)) {
10771071 auto ast = make_node<GlobalNestedNameSpecifierAST>(pool_);
10781072 yyast = ast;
@@ -1471,7 +1465,7 @@ auto Parser::parse_nested_expession(ExpressionAST*& yyast,
14711465
14721466auto Parser::parse_fold_expression (ExpressionAST*& yyast,
14731467 const ExprContext& ctx) -> bool {
1474- if (!is_cxx ()) return false ;
1468+ if (!is_parsing_cxx ()) return false ;
14751469
14761470 if (!lookat (TokenKind::T_LPAREN)) return false ;
14771471
@@ -3524,7 +3518,7 @@ auto Parser::parse_for_statement(StatementAST*& yyast) -> bool {
35243518 SourceLocation colonLoc;
35253519
35263520 auto lookat_for_range_declaration = [&] {
3527- if (!is_cxx ()) return false ;
3521+ if (!is_parsing_cxx ()) return false ;
35283522
35293523 LookaheadParser lookahead{this };
35303524
@@ -6070,7 +6064,7 @@ auto Parser::parse_initializer_list(List<ExpressionAST*>*& yyast,
60706064auto Parser::lookat_designator () -> bool {
60716065 if (lookat (TokenKind::T_DOT)) return true ;
60726066
6073- if (is_c () && lookat (TokenKind::T_LBRACKET)) return true ;
6067+ if (is_parsing_c () && lookat (TokenKind::T_LBRACKET)) return true ;
60746068
60756069 return false ;
60766070}
@@ -6119,7 +6113,7 @@ auto Parser::parse_designated_initializer_clause(
61196113 *it = make_list_node (pool_, designator);
61206114 it = &(*it)->next ;
61216115
6122- if (is_c ()) {
6116+ if (is_parsing_c ()) {
61236117 while (lookat_designator ()) {
61246118 DesignatorAST* designator = nullptr ;
61256119 parse_designator (designator);
0 commit comments