Changeset e16eb460 for src


Ignore:
Timestamp:
Oct 3, 2021, 5:19:12 PM (3 years ago)
Author:
Peter A. Buhr <pabuhr@…>
Branches:
ADT, ast-experimental, enum, forall-pointer-decay, master, pthread-emulation, qualifiedEnum
Children:
8dcb832
Parents:
96f01d7f
Message:

further restrict locations where @ occurs, remove empty argument list for mutex statement, add mutex @ has placeholder for mutex expression

File:
1 edited

Legend:

Unmodified
Added
Removed
  • src/Parser/parser.yy

    r96f01d7f re16eb460  
    1010// Created On       : Sat Sep  1 20:22:55 2001
    1111// Last Modified By : Peter A. Buhr
    12 // Last Modified On : Sat Sep 11 08:20:44 2021
    13 // Update Count     : 5040
     12// Last Modified On : Sat Oct  2 08:27:21 2021
     13// Update Count     : 5080
    1414//
    1515
     
    3131// from ANSI90 to ANSI11 C are marked with the comment "C99/C11".
    3232
    33 // This grammar also has two levels of extensions. The first extensions cover most of the GCC C extensions All of the
     33// This grammar also has two levels of extensions. The first extensions cover most of the GCC C extensions. All of the
    3434// syntactic extensions for GCC C are marked with the comment "GCC". The second extensions are for Cforall (CFA), which
    3535// fixes several of C's outstanding problems and extends C with many modern language concepts. All of the syntactic
     
    310310%token ATassign                                                                                 // @=
    311311
    312 %type<tok> identifier
    313 %type<tok> identifier_or_type_name  attr_name
     312%type<tok> identifier                                   identifier_at                           identifier_or_type_name         attr_name
    314313%type<tok> quasi_keyword
    315314%type<constant> string_literal
     
    327326%type<en> conditional_expression                constant_expression                     assignment_expression           assignment_expression_opt
    328327%type<en> comma_expression                              comma_expression_opt
    329 %type<en> argument_expression_list_opt  argument_expression                     default_initializer_opt
     328%type<en> argument_expression_list_opt  argument_expression_list        argument_expression                     default_initializer_opt
    330329%type<ifctl> if_control_expression
    331330%type<fctl> for_control_expression              for_control_expression_list
     
    559558        IDENTIFIER
    560559        | quasi_keyword
     560        ;
     561
     562identifier_at:
     563        identifier
    561564        | '@'                                                                                           // CFA
    562565                { Token tok = { new string( DeclarationNode::anonymous.newName() ), yylval.tok.loc }; $$ = tok; }
     
    693696        // empty
    694697                { $$ = nullptr; }
    695         | argument_expression
     698        | argument_expression_list
     699        ;
     700
     701argument_expression_list:
     702        argument_expression
    696703        | argument_expression_list_opt ',' argument_expression
    697704                { $$ = (ExpressionNode *)($1->set_last( $3 )); }
     
    731738        | FLOATINGconstant fraction_constants_opt
    732739                { $$ = new ExpressionNode( build_field_name_fraction_constants( build_field_name_FLOATINGconstant( *$1 ), $2 ) ); }
    733         | identifier fraction_constants_opt
     740        | identifier_at fraction_constants_opt                          // CFA, allow anonymous fields
    734741                {
    735742                        $$ = new ExpressionNode( build_field_name_fraction_constants( build_varref( $1 ), $2 ) );
     
    10841091        comma_expression_opt ';'
    10851092                { $$ = new StatementNode( build_expr( $1 ) ); }
     1093        | MUTEX '@' comma_expression ';'
     1094                // { $$ = new StatementNode( build_mutex( nullptr, new StatementNode( build_expr( $3 ) ) ) ); }
     1095                { SemanticError( yylloc, "Mutex expression is currently unimplemented." ); $$ = nullptr; }
    10861096        ;
    10871097
     
    13391349with_statement:
    13401350        WITH '(' tuple_expression_list ')' statement
    1341                 {
    1342                         $$ = new StatementNode( build_with( $3, $5 ) );
    1343                 }
     1351                { $$ = new StatementNode( build_with( $3, $5 ) ); }
    13441352        ;
    13451353
    13461354// If MUTEX becomes a general qualifier, there are shift/reduce conflicts, so change syntax to "with mutex".
    13471355mutex_statement:
    1348         MUTEX '(' argument_expression_list_opt ')' statement
     1356        MUTEX '(' argument_expression_list ')' statement
    13491357                { $$ = new StatementNode( build_mutex( $3, $5 ) ); }
    13501358        ;
     
    24752483designation:
    24762484        designator_list ':'                                                                     // C99, CFA uses ":" instead of "="
    2477         | identifier ':'                                                                        // GCC, field name
     2485        | identifier_at ':'                                                                     // GCC, field name
    24782486                { $$ = new ExpressionNode( build_varref( $1 ) ); }
    24792487        ;
     
    24872495
    24882496designator:
    2489         '.' identifier                                                                          // C99, field name
     2497        '.' identifier_at                                                                       // C99, field name
    24902498                { $$ = new ExpressionNode( build_varref( $2 ) ); }
    24912499        | '[' push assignment_expression pop ']'                        // C99, single array element
     
    29192927
    29202928paren_identifier:
    2921         identifier
     2929        identifier_at
    29222930                { $$ = DeclarationNode::newName( $1 ); }
    29232931        | '(' paren_identifier ')'                                                      // redundant parenthesis
Note: See TracChangeset for help on using the changeset viewer.