Changeset dd54139 for src


Ignore:
Timestamp:
Nov 16, 2024, 6:36:58 PM (26 hours ago)
Author:
Peter A. Buhr <pabuhr@…>
Branches:
master
Children:
ea10f64
Parents:
95707a3
Message:

empty tuple prints a syntax error, first attempt at tuple arrays with new declaration syntax

File:
1 edited

Legend:

Unmodified
Added
Removed
  • src/Parser/parser.yy

    r95707a3 rdd54139  
    1010// Created On       : Sat Sep  1 20:22:55 2001
    1111// Last Modified By : Peter A. Buhr
    12 // Last Modified On : Sun Oct 13 12:18:15 2024
    13 // Update Count     : 6845
     12// Last Modified On : Fri Nov 15 15:01:33 2024
     13// Update Count     : 6915
    1414//
    1515
     
    2424// the grammar.
    2525
    26 // The root language for this grammar is ANSI99/11 C. All of ANSI99/11 is parsed, except for:
    27 //
    28 //   designation with '=' (use ':' instead)
    29 //
    30 // This incompatibility is discussed in detail before the "designation" grammar rule.  Most of the syntactic extensions
    31 // from ANSI90 to ANSI11 C are marked with the comment "C99/C11".
     26// The root language for this grammar is ANSI99/11 C. All of ANSI99/11 is parsed.  Most of the syntactic extensions from
     27// ANSI90 to ANSI11 C are marked with the comment "C99/C11".
    3228
    3329// This grammar also has two levels of extensions. The first extensions cover most of the GCC C extensions. All of the
     
    11701166                // comma_expression in cfa_identifier_parameter_array and cfa_abstract_array
    11711167        '[' ',' ']'
    1172                 { $$ = new ExpressionNode( build_tuple( yylloc, nullptr ) ); }
     1168                // { $$ = new ExpressionNode( build_tuple( yylloc, nullptr ) ); }
     1169                { SemanticError( yylloc, "Empty tuple is meaningless." ); $$ = nullptr; }
    11731170        | '[' assignment_expression ',' ']'
    11741171                { $$ = new ExpressionNode( build_tuple( yylloc, $2 ) ); }
     
    12241221        | DIRECTIVE
    12251222                { $$ = new StatementNode( build_directive( yylloc, $1 ) ); }
     1223//      | attribute ';'
     1224//              { $$ = new StatementNode( $1 ); }
    12261225        ;
    12271226
     
    20572056        | cfa_abstract_tuple identifier_or_type_name asm_name_opt
    20582057                { $$ = $1->addName( $2 )->addAsmName( $3 ); }
    2059         | type_qualifier_list cfa_abstract_tuple identifier_or_type_name asm_name_opt
    2060                 { $$ = $2->addQualifiers( $1 )->addName( $3 )->addAsmName( $4 ); }
     2058        | multi_array_dimension cfa_abstract_tuple identifier_or_type_name asm_name_opt
     2059                { $$ = $2->addNewArray( $1 )->addName( $3 )->addAsmName( $4 ); }
     2060        | multi_array_dimension type_qualifier_list cfa_abstract_tuple identifier_or_type_name asm_name_opt
     2061                { $$ = $3->addNewArray( $1 )->addQualifiers( $2 )->addName( $4 )->addAsmName( $5 ); }
    20612062
    20622063                // [ int s, int t ];                    // declare s and t
     
    42234224        cfa_identifier_parameter_ptr
    42244225        | cfa_identifier_parameter_array
     4226        | type_qualifier_list cfa_identifier_parameter_array
     4227                { $$ = $2->addQualifiers( $1 ); }
    42254228        ;
    42264229
     
    42464249        '[' ']' type_specifier_nobody
    42474250                { $$ = $3->addNewArray( DeclarationNode::newArray( nullptr, nullptr, false ) ); }
     4251        | '[' ']' cfa_abstract_tuple
     4252                { $$ = $3->addNewArray( DeclarationNode::newArray( nullptr, nullptr, false ) ); }
    42484253        | cfa_array_parameter_1st_dimension type_specifier_nobody
     4254                { $$ = $2->addNewArray( $1 ); }
     4255        | cfa_array_parameter_1st_dimension cfa_abstract_tuple
    42494256                { $$ = $2->addNewArray( $1 ); }
    42504257        | '[' ']' multi_array_dimension type_specifier_nobody
    42514258                { $$ = $4->addNewArray( $3 )->addNewArray( DeclarationNode::newArray( nullptr, nullptr, false ) ); }
     4259        | '[' ']' multi_array_dimension cfa_abstract_tuple
     4260                { $$ = $4->addNewArray( $3 )->addNewArray( DeclarationNode::newArray( nullptr, nullptr, false ) ); }
    42524261        | cfa_array_parameter_1st_dimension multi_array_dimension type_specifier_nobody
    42534262                { $$ = $3->addNewArray( $2 )->addNewArray( $1 ); }
     4263        | cfa_array_parameter_1st_dimension multi_array_dimension cfa_abstract_tuple
     4264                { $$ = $3->addNewArray( $2 )->addNewArray( $1 ); }
    42544265        | multi_array_dimension type_specifier_nobody
     4266                { $$ = $2->addNewArray( $1 ); }
     4267        | multi_array_dimension cfa_abstract_tuple
    42554268                { $$ = $2->addNewArray( $1 ); }
    42564269
Note: See TracChangeset for help on using the changeset viewer.