Changeset 99fc978
- Timestamp:
- May 21, 2025, 1:38:02 PM (4 weeks ago)
- Branches:
- master
- Children:
- 1a40870
- Parents:
- d92bc97
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
src/Parser/parser.yy
rd92bc97 r99fc978 10 10 // Created On : Sat Sep 1 20:22:55 2001 11 11 // Last Modified By : Peter A. Buhr 12 // Last Modified On : Fri Apr 18 15:23:42202513 // Update Count : 72 8312 // Last Modified On : Wed May 21 11:25:13 2025 13 // Update Count : 7295 14 14 // 15 15 … … 777 777 postfix_expression: 778 778 primary_expression 779 | postfix_expression '[' assignment_expression ',' tuple_expression_list ']'779 | postfix_expression '[' tuple_expression_list ']' // CFA 780 780 // Historic, transitional: Disallow commas in subscripts. 781 781 // Switching to this behaviour may help check if a C compatibilty case uses comma-exprs in subscripts. 782 782 // Current: Commas in subscripts make tuples. 783 { $$ = new ExpressionNode( build_binary_val( yylloc, OperKinds::Index, $1, new ExpressionNode( build_tuple( yylloc, $3->set_last( $5 ) ) ) ) ); } 784 | postfix_expression '[' assignment_expression ']' 785 // CFA, comma_expression disallowed in this context because it results in a common user error: subscripting a 786 // matrix with x[i,j] instead of x[i][j]. While this change is not backwards compatible, there seems to be 787 // little advantage to this feature and many disadvantages. It is possible to write x[(i,j)] in CFA, which is 788 // equivalent to the old x[i,j]. 789 { $$ = new ExpressionNode( build_binary_val( yylloc, OperKinds::Index, $1, $3 ) ); } 783 { $$ = new ExpressionNode( build_binary_val( yylloc, OperKinds::Index, $1, new ExpressionNode( build_tuple( yylloc, $3 ) ) ) ); } 790 784 | constant '[' assignment_expression ']' // 3[a], 'a'[a], 3.5[a] 791 785 { $$ = new ExpressionNode( build_binary_val( yylloc, OperKinds::Index, $1, $3 ) ); } … … 3132 3126 type_initializer_opt assertion_list_opt 3133 3127 { $$ = DeclarationNode::newTypeParam( $2, $1 )->addTypeInitializer( $4 )->addAssertions( $5 ); } 3134 | '[' identifier_or_type_name ']' 3128 | '[' identifier_or_type_name ']' assertion_list_opt 3135 3129 { 3136 3130 typedefTable.addToScope( *$2, TYPEDIMname, "type_parameter 3" ); 3137 $$ = DeclarationNode::newTypeParam( ast::TypeDecl::Dimension, $2 ) ;3131 $$ = DeclarationNode::newTypeParam( ast::TypeDecl::Dimension, $2 )->addAssertions( $4 ); 3138 3132 } 3139 3133 // | type_specifier identifier_parameter_declarator … … 4035 4029 { $$ = DeclarationNode::newArray( nullptr, nullptr, false )->addArray( $3 ); } 4036 4030 // Cannot use constant_expression because of tuples => semantic check 4031 | '[' assignment_expression ',' ']' // CFA 4032 { SemanticError( yylloc, "New array dimension is currently unimplemented." ); $$ = nullptr; } 4033 // { $$ = DeclarationNode::newArray( $2, nullptr, false ); } 4037 4034 | '[' assignment_expression ',' comma_expression ']' // CFA 4038 { $$ = DeclarationNode::newArray( $2, nullptr, false )->addArray( DeclarationNode::newArray( $4, nullptr, false ) ); }4039 // { SemanticError( yylloc, "New array dimension is currently unimplemented." ); $$ = nullptr; }4035 { SemanticError( yylloc, "New array dimension is currently unimplemented." ); $$ = nullptr; } 4036 // { $$ = DeclarationNode::newArray( $2, nullptr, false )->addArray( DeclarationNode::newArray( $4, nullptr, false ) ); } 4040 4037 4041 4038 // If needed, the following parses and does not use comma_expression, so the array structure can be built.
Note: See TracChangeset
for help on using the changeset viewer.