Changeset 12f1156


Ignore:
Timestamp:
Jun 11, 2024, 9:42:39 PM (4 months ago)
Author:
Peter A. Buhr <pabuhr@…>
Branches:
master
Children:
5144898
Parents:
2ab31fd
Message:

simplify grammar in a few places

File:
1 edited

Legend:

Unmodified
Added
Removed
  • src/Parser/parser.yy

    r2ab31fd r12f1156  
    1010// Created On       : Sat Sep  1 20:22:55 2001
    1111// Last Modified By : Peter A. Buhr
    12 // Last Modified On : Tue Jun 11 16:56:42 2024
    13 // Update Count     : 6638
     12// Last Modified On : Tue Jun 11 21:32:15 2024
     13// Update Count     : 6641
    1414//
    1515
     
    387387// names and constants: lexer differentiates between identifier and typedef names
    388388%token<tok> IDENTIFIER          TYPEDIMname             TYPEDEFname             TYPEGENname
    389 %token<tok> TIMEOUT                     WAND    WOR                     CATCH                   RECOVER                 CATCHRESUME             FIXUP           FINALLY         // CFA
     389%token<tok> TIMEOUT                     WAND    WOR             CATCH                   RECOVER                 CATCHRESUME             FIXUP           FINALLY         // CFA
    390390%token<tok> INTEGERconstant     CHARACTERconstant       STRINGliteral
    391391%token<tok> DIRECTIVE
     
    493493%type<decl> exception_declaration
    494494
    495 %type<decl> field_declaration_list_opt field_declaration field_declaring_list_opt field_declaring_list field_declarator field_abstract_list_opt field_abstract
     495%type<decl> field_declaration_list_opt field_declaration field_declaring_list_opt field_declarator field_abstract_list_opt field_abstract
    496496%type<expr> field field_name_list field_name fraction_constants_opt
    497497
     
    678678        | '@'                                                                                           // CFA
    679679                { Token tok = { new string( DeclarationNode::anonymous.newName() ), yylval.tok.loc }; $$ = tok; }
     680        ;
     681
     682identifier_or_type_name:
     683        identifier
     684        | TYPEDEFname
     685        | TYPEGENname
    680686        ;
    681687
     
    811817                //       z.E;  // lexer returns E is TYPEDEFname
    812818                //   }
    813         | postfix_expression '.' identifier
    814                 { $$ = new ExpressionNode( build_fieldSel( yylloc, $1, build_varref( yylloc, $3 ) ) ); }
    815         | postfix_expression '.' TYPEDEFname                            // CFA, SKULLDUGGERY
    816                 { $$ = new ExpressionNode( build_fieldSel( yylloc, $1, build_varref( yylloc, $3 ) ) ); }
    817         | postfix_expression '.' TYPEGENname                            // CFA, SKULLDUGGERY
     819        | postfix_expression '.' identifier_or_type_name
    818820                { $$ = new ExpressionNode( build_fieldSel( yylloc, $1, build_varref( yylloc, $3 ) ) ); }
    819821
     
    16131615enum_key:
    16141616        TYPEDEFname
    1615         | ENUM TYPEDEFname
     1617        | ENUM identifier_or_type_name
    16161618        ;
    16171619
     
    26922694        // empty
    26932695                { $$ = nullptr; }
    2694         | field_declaring_list
    2695         ;
    2696 
    2697 field_declaring_list:
    2698         field_declarator
    2699         | field_declaring_list ',' attribute_list_opt field_declarator
     2696        | field_declarator
     2697        | field_declaring_list_opt ',' attribute_list_opt field_declarator
    27002698                { $$ = $1->set_last( $4->addQualifiers( $3 ) ); }
    27012699        ;
     
    29612959        ;
    29622960
    2963 identifier_or_type_name:
    2964         identifier
    2965         | TYPEDEFname
    2966         | TYPEGENname
    2967         ;
    2968 
    29692961type_no_function:                                                                               // sizeof, alignof, cast (constructor)
    29702962        cfa_abstract_declarator_tuple                                           // CFA
     
    32303222        // empty, input file
    32313223        | external_definition_list
    3232                 { parseTree = parseTree ? parseTree->set_last( $1 ) : $1;       }
     3224                { parseTree = parseTree ? parseTree->set_last( $1 ) : $1; }
    32333225        ;
    32343226
     
    34883480
    34893481attr_name:                                                                                              // GCC
    3490         IDENTIFIER
    3491         | quasi_keyword
    3492         | TYPEDEFname
    3493         | TYPEGENname
     3482        identifier_or_type_name
    34943483        | FALLTHROUGH
    34953484                { $$ = Token{ new string( "fallthrough" ), { nullptr, -1 } }; }
Note: See TracChangeset for help on using the changeset viewer.