Changeset df22130 for src/Parser


Ignore:
Timestamp:
May 9, 2018, 5:56:19 PM (7 years ago)
Author:
Peter A. Buhr <pabuhr@…>
Branches:
ADT, aaron-thesis, arm-eh, ast-experimental, cleanup-dtors, deferred_resn, demangler, enum, forall-pointer-decay, jacob/cs343-translation, jenkins-sandbox, master, new-ast, new-ast-unique-expr, new-env, no_list, persistent-indexer, pthread-emulation, qualifiedEnum, with_gc
Children:
a8de0f4
Parents:
b4a835d
Message:

allow spaces for tuple index in expression

File:
1 edited

Legend:

Unmodified
Added
Removed
  • src/Parser/parser.yy

    rb4a835d rdf22130  
    1010// Created On       : Sat Sep  1 20:22:55 2001
    1111// Last Modified By : Peter A. Buhr
    12 // Last Modified On : Thu May  3 08:20:09 2018
    13 // Update Count     : 3225
     12// Last Modified On : Wed May  9 17:17:35 2018
     13// Update Count     : 3244
    1414//
    1515
     
    302302
    303303%type<decl> field_declaration field_declaration_list field_declarator field_declaring_list
    304 %type<en> field field_list field_name fraction_constants
     304%type<en> field field_list field_name fraction_constants_opt
    305305
    306306%type<decl> external_function_definition function_definition function_array function_declarator function_no_ptr function_ptr
     
    499499        | type_name '.' no_attr_identifier                                      // CFA, nested type
    500500                { SemanticError( yylloc, "Qualified names are currently unimplemented." ); $$ = nullptr; }
     501//              { $$ = nullptr; }
    501502        | type_name '.' '[' push field_list pop ']'                     // CFA, nested type / tuple field selector
    502503                { SemanticError( yylloc, "Qualified names are currently unimplemented." ); $$ = nullptr; }
     504//              { $$ = nullptr; }
    503505        | GENERIC '(' assignment_expression ',' generic_assoc_list ')' // C11
    504506                { SemanticError( yylloc, "_Generic is currently unimplemented." ); $$ = nullptr; }
     
    533535        | postfix_expression '.' no_attr_identifier
    534536                { $$ = new ExpressionNode( build_fieldSel( $1, build_varref( $3 ) ) ); }
     537        | postfix_expression '.' INTEGERconstant                        // CFA, tuple index
     538                { $$ = new ExpressionNode( build_fieldSel( $1, build_constantInteger( *$3 ) ) ); }
     539        | postfix_expression FLOATING_FRACTIONconstant          // CFA, tuple index
     540                { $$ = new ExpressionNode( build_fieldSel( $1, build_field_name_FLOATING_FRACTIONconstant( *$2 ) ) ); }
    535541        | postfix_expression '.' '[' push field_list pop ']' // CFA, tuple field selector
    536542                { $$ = new ExpressionNode( build_fieldSel( $1, build_tuple( $5 ) ) ); }
    537         | postfix_expression FLOATING_FRACTIONconstant          // CFA, tuple index
    538                 { $$ = new ExpressionNode( build_fieldSel( $1, build_field_name_FLOATING_FRACTIONconstant( *$2 ) ) ); }
    539543        | postfix_expression ARROW no_attr_identifier
    540544                {
    541545                        $$ = new ExpressionNode( build_pfieldSel( $1, *$3 == "0" || *$3 == "1" ? build_constantInteger( *$3 ) : build_varref( $3 ) ) );
    542546                }
    543         | postfix_expression ARROW '[' push field_list pop ']' // CFA, tuple field selector
    544                         { $$ = new ExpressionNode( build_pfieldSel( $1, build_tuple( $5 ) ) ); }
    545547        | postfix_expression ARROW INTEGERconstant                      // CFA, tuple index
    546548                { $$ = new ExpressionNode( build_pfieldSel( $1, build_constantInteger( *$3 ) ) ); }
     549        | postfix_expression ARROW '[' push field_list pop ']' // CFA, tuple field selector
     550                { $$ = new ExpressionNode( build_pfieldSel( $1, build_tuple( $5 ) ) ); }
    547551        | postfix_expression ICR
    548552                { $$ = new ExpressionNode( build_unary_ptr( OperKinds::IncrPost, $1 ) ); }
     
    597601
    598602field_name:
    599         INTEGERconstant fraction_constants
     603        INTEGERconstant fraction_constants_opt
    600604                { $$ = new ExpressionNode( build_field_name_fraction_constants( build_constantInteger( *$1 ), $2 ) ); }
    601         | FLOATINGconstant fraction_constants
     605        | FLOATINGconstant fraction_constants_opt
    602606                { $$ = new ExpressionNode( build_field_name_fraction_constants( build_field_name_FLOATINGconstant( *$1 ), $2 ) ); }
    603         | no_attr_identifier fraction_constants
     607        | no_attr_identifier fraction_constants_opt
    604608                {
    605609                        $$ = new ExpressionNode( build_field_name_fraction_constants( build_varref( $1 ), $2 ) );
     
    607611        ;
    608612
    609 fraction_constants:
     613fraction_constants_opt:
    610614        // empty
    611615                { $$ = nullptr; }
    612         | fraction_constants FLOATING_FRACTIONconstant
     616        | fraction_constants_opt FLOATING_FRACTIONconstant
    613617                {
    614618                        Expression * constant = build_field_name_FLOATING_FRACTIONconstant( *$2 );
     
    23902394external_definition_list:
    23912395        external_definition
    2392         | external_definition_list { forall = xxx; } push external_definition
     2396        | external_definition_list
     2397                { forall = xxx; }
     2398          push external_definition
    23932399                { $$ = $1 ? $1->appendList( $4 ) : $4; }
    23942400        ;
Note: See TracChangeset for help on using the changeset viewer.