Changes in src/Parser/parser.yy [3d26610:3ed994e]
- File:
-
- 1 edited
-
src/Parser/parser.yy (modified) (52 diffs)
Legend:
- Unmodified
- Added
- Removed
-
src/Parser/parser.yy
r3d26610 r3ed994e 10 10 // Created On : Sat Sep 1 20:22:55 2001 11 11 // Last Modified By : Peter A. Buhr 12 // Last Modified On : T hu May 31 15:11:40201813 // Update Count : 3 44412 // Last Modified On : Tue May 22 08:41:57 2018 13 // Update Count : 3353 14 14 // 15 15 … … 265 265 %type<sn> statement labeled_statement compound_statement 266 266 %type<sn> statement_decl statement_decl_list statement_list_nodecl 267 %type<sn> selection_statement if_statement267 %type<sn> selection_statement 268 268 %type<sn> switch_clause_list_opt switch_clause_list 269 269 %type<en> case_value … … 326 326 %type<decl> cfa_identifier_parameter_declarator_tuple cfa_identifier_parameter_ptr 327 327 328 %type<decl> cfa_parameter_declaration cfa_parameter_list cfa_parameter_ ellipsis_list_opt328 %type<decl> cfa_parameter_declaration cfa_parameter_list cfa_parameter_type_list_opt 329 329 330 330 %type<decl> cfa_typedef_declaration cfa_variable_declaration cfa_variable_specifier … … 332 332 %type<decl> c_declaration static_assert 333 333 %type<decl> KR_function_declarator KR_function_no_ptr KR_function_ptr KR_function_array 334 %type<decl> KR_ parameter_list KR_parameter_list_opt334 %type<decl> KR_declaration_list KR_declaration_list_opt 335 335 336 336 %type<decl> parameter_declaration parameter_list parameter_type_list_opt … … 404 404 //************************* Namespace Management ******************************** 405 405 406 // The C grammar is not context free because it relies on the distinct terminal symbols "identifier" and "TYPEDEFname", 407 // which are lexically identical. 408 // 409 // typedef int foo; // identifier foo must now be scanned as TYPEDEFname 410 // foo f; // to allow it to appear in this context 411 // 412 // While it may be possible to write a purely context-free grammar, such a grammar would obscure the relationship 413 // between syntactic and semantic constructs. Cforall compounds this problem by introducing type names local to the 414 // scope of a declaration (for instance, those introduced through "forall" qualifiers), and by introducing "type 415 // generators" -- parameterized types. This latter type name creates a third class of identifiers, "TYPEGENname", which 416 // must be distinguished by the lexical scanner. 417 // 418 // Since the scanner cannot distinguish among the different classes of identifiers without some context information, 419 // there is a type table (typedefTable), which holds type names and identifiers that override type names, for each named 420 // scope. During parsing, semantic actions update the type table by adding new identifiers in the current scope. For 421 // each context that introduces a name scope, a new level is created in the type table and that level is popped on 422 // exiting the scope. Since type names can be local to a particular declaration, each declaration is itself a scope. 423 // This requires distinguishing between type names that are local to the current declaration scope and those that 424 // persist past the end of the declaration (i.e., names defined in "typedef" or "otype" declarations). 425 // 426 // The non-terminals "push" and "pop" denote the opening and closing of named scopes. Every push has a matching pop in 427 // the production rule. There are multiple lists of declarations, where each declaration is a named scope, so pop/push 428 // around the list separator. 429 // 430 // int f( forall(T) T (*f1) T , forall( S ) S (*f2)( S ) ); 431 // push pop push pop 406 // The grammar in the ANSI C standard is not strictly context-free, since it relies upon the distinct terminal symbols 407 // "identifier", "TYPEDEFname", and "TYPEGENname" that are lexically identical. While it is possible to write a purely 408 // context-free grammar, such a grammar would obscure the relationship between syntactic and semantic constructs. 409 // Hence, this grammar uses the ANSI style. 410 // 411 // Cforall compounds this problem by introducing type names local to the scope of a declaration (for instance, those 412 // introduced through "forall" qualifiers), and by introducing "type generators" -- parameterized types. This latter 413 // type name creates a third class of identifiers that must be distinguished by the scanner. 414 // 415 // Since the scanner cannot distinguish among the different classes of identifiers without some context information, it 416 // accesses a data structure (TypedefTable) to allow classification of an identifier that it has just read. Semantic 417 // actions during the parser update this data structure when the class of identifiers change. 418 // 419 // Because the Cforall language is block-scoped, an identifier can change its class in a local scope; it must revert to 420 // its original class at the end of the block. Since type names can be local to a particular declaration, each 421 // declaration is itself a scope. This requires distinguishing between type names that are local to the current 422 // declaration scope and those that persist past the end of the declaration (i.e., names defined in "typedef" or "otype" 423 // declarations). 424 // 425 // The non-terminals "push" and "pop" denote the opening and closing of scopes. Every push must have a matching pop, 426 // although it is regrettable the matching pairs do not always occur within the same rule. These non-terminals may 427 // appear in more contexts than strictly necessary from a semantic point of view. 432 428 433 429 push: … … 856 852 // '[' ']' 857 853 // { $$ = new ExpressionNode( build_tuple() ); } 858 // |'[' push assignment_expression pop ']'854 // '[' push assignment_expression pop ']' 859 855 // { $$ = new ExpressionNode( build_tuple( $3 ) ); } 860 856 '[' ',' tuple_expression_list ']' 861 857 { $$ = new ExpressionNode( build_tuple( (ExpressionNode *)(new ExpressionNode( nullptr ) )->set_last( $3 ) ) ); } 862 | '[' push assignment_expression pop',' tuple_expression_list ']'863 { $$ = new ExpressionNode( build_tuple( (ExpressionNode *)$ 3->set_last( $6) ) ); }858 | '[' assignment_expression ',' tuple_expression_list ']' 859 { $$ = new ExpressionNode( build_tuple( (ExpressionNode *)$2->set_last( $4 ) ) ); } 864 860 ; 865 861 … … 887 883 labeled_statement 888 884 | compound_statement 889 | expression_statement 885 | expression_statement { $$ = $1; } 890 886 | selection_statement 891 887 | iteration_statement … … 913 909 '{' '}' 914 910 { $$ = new StatementNode( build_compound( (StatementNode *)0 ) ); } 915 | '{' push 911 | '{' 912 // Two scopes are necessary because the block itself has a scope, but every declaration within the block also 913 // requires its own scope. 914 push push 916 915 local_label_declaration_opt // GCC, local labels 917 916 statement_decl_list // C99, intermix declarations and statements 918 917 pop '}' 919 { $$ = new StatementNode( build_compound( $ 4) ); }918 { $$ = new StatementNode( build_compound( $5 ) ); } 920 919 ; 921 920 922 921 statement_decl_list: // C99 923 922 statement_decl 924 | statement_decl_list statement_decl925 { if ( $1 != 0 ) { $1->set_last( $ 2); $$ = $1; } }923 | statement_decl_list push statement_decl 924 { if ( $1 != 0 ) { $1->set_last( $3 ); $$ = $1; } } 926 925 ; 927 926 … … 941 940 $$ = new StatementNode( $2 ); 942 941 } 943 | statement 942 | statement pop 944 943 ; 945 944 … … 956 955 957 956 selection_statement: 958 // pop causes a S/R conflict without separating the IF statement into a non-terminal even after resolving 959 // the inherent S/R conflict with THEN/ELSE. 960 push if_statement pop 961 { $$ = $2; } 957 IF '(' push if_control_expression ')' statement %prec THEN 958 // explicitly deal with the shift/reduce conflict on if/else 959 { $$ = new StatementNode( build_if( $4, $6, nullptr ) ); } 960 | IF '(' push if_control_expression ')' statement ELSE statement 961 { $$ = new StatementNode( build_if( $4, $6, $8 ) ); } 962 962 | SWITCH '(' comma_expression ')' case_clause 963 963 { $$ = new StatementNode( build_switch( true, $3, $5 ) ); } 964 | SWITCH '(' comma_expression ')' '{' push declaration_list_opt switch_clause_list_opt pop'}' // CFA964 | SWITCH '(' comma_expression ')' '{' push declaration_list_opt switch_clause_list_opt '}' // CFA 965 965 { 966 966 StatementNode *sw = new StatementNode( build_switch( true, $3, $8 ) ); … … 974 974 | CHOOSE '(' comma_expression ')' case_clause // CFA 975 975 { $$ = new StatementNode( build_switch( false, $3, $5 ) ); } 976 | CHOOSE '(' comma_expression ')' '{' push declaration_list_opt switch_clause_list_opt pop'}' // CFA976 | CHOOSE '(' comma_expression ')' '{' push declaration_list_opt switch_clause_list_opt '}' // CFA 977 977 { 978 978 StatementNode *sw = new StatementNode( build_switch( false, $3, $8 ) ); … … 981 981 ; 982 982 983 if_statement:984 IF '(' if_control_expression ')' statement %prec THEN985 // explicitly deal with the shift/reduce conflict on if/else986 { $$ = new StatementNode( build_if( $3, $5, nullptr ) ); }987 | IF '(' if_control_expression ')' statement ELSE statement988 { $$ = new StatementNode( build_if( $3, $5, $7 ) ); }989 ;990 991 992 983 if_control_expression: 993 comma_expression 984 comma_expression pop 994 985 { $$ = new IfCtl( nullptr, $1 ); } 995 | c_declaration // no semi-colon986 | c_declaration pop // no semi-colon 996 987 { $$ = new IfCtl( $1, nullptr ); } 997 | cfa_declaration // no semi-colon988 | cfa_declaration pop // no semi-colon 998 989 { $$ = new IfCtl( $1, nullptr ); } 999 990 | declaration comma_expression // semi-colon separated … … 1056 1047 | DO statement WHILE '(' comma_expression ')' ';' 1057 1048 { $$ = new StatementNode( build_while( $5, $2, true ) ); } 1058 | FOR '(' push for_control_expression ')' statement pop1049 | FOR '(' push for_control_expression ')' statement 1059 1050 { $$ = new StatementNode( build_for( $4, $6 ) ); } 1060 1051 ; 1061 1052 1062 1053 for_control_expression: 1063 comma_expression_opt ';' comma_expression_opt ';' comma_expression_opt1064 { $$ = new ForCtl( $1, $ 3, $5); }1054 comma_expression_opt pop ';' comma_expression_opt ';' comma_expression_opt 1055 { $$ = new ForCtl( $1, $4, $6 ); } 1065 1056 | declaration comma_expression_opt ';' comma_expression_opt // C99 1066 1057 { $$ = new ForCtl( $1, $2, $4 ); } … … 1184 1175 1185 1176 handler_clause: 1186 handler_key '(' push exception_declaration pop handler_predicate_opt ')' compound_statement pop1187 { $$ = new StatementNode( build_catch( $1, $ 4, $6, $8) ); }1188 | handler_clause handler_key '(' push exception_declaration pop handler_predicate_opt ')' compound_statement pop1189 { $$ = (StatementNode *)$1->set_last( new StatementNode( build_catch( $2, $ 5, $7, $9) ) ); }1177 handler_key '(' push push exception_declaration pop handler_predicate_opt ')' compound_statement pop 1178 { $$ = new StatementNode( build_catch( $1, $5, $7, $9 ) ); } 1179 | handler_clause handler_key '(' push push exception_declaration pop handler_predicate_opt ')' compound_statement pop 1180 { $$ = (StatementNode *)$1->set_last( new StatementNode( build_catch( $2, $6, $8, $10 ) ) ); } 1190 1181 ; 1191 1182 … … 1209 1200 type_specifier_nobody 1210 1201 | type_specifier_nobody declarator 1211 { $$ = $2->addType( $1 ); } 1202 { 1203 $$ = $2->addType( $1 ); 1204 } 1212 1205 | type_specifier_nobody variable_abstract_declarator 1213 1206 { $$ = $2->addType( $1 ); } 1214 1207 | cfa_abstract_declarator_tuple no_attr_identifier // CFA 1215 { $$ = $1->addName( $2 ); } 1208 { 1209 $$ = $1->addName( $2 ); 1210 } 1216 1211 | cfa_abstract_declarator_tuple // CFA 1217 1212 ; … … 1291 1286 1292 1287 declaration_list_opt: // used at beginning of switch statement 1288 pop 1289 { $$ = nullptr; } 1290 | declaration_list 1291 ; 1292 1293 declaration_list: 1294 declaration 1295 | declaration_list push declaration 1296 { $$ = $1->appendList( $3 ); } 1297 ; 1298 1299 KR_declaration_list_opt: // used to declare parameter types in K&R style functions 1293 1300 // empty 1294 1301 { $$ = nullptr; } 1295 | declaration_list 1296 ; 1297 1298 declaration_list: 1299 declaration 1300 | declaration_list declaration 1301 { $$ = $1->appendList( $2 ); } 1302 ; 1303 1304 KR_parameter_list_opt: // used to declare parameter types in K&R style functions 1305 // empty 1306 { $$ = nullptr; } 1307 | KR_parameter_list 1308 ; 1309 1310 KR_parameter_list: 1302 | KR_declaration_list 1303 ; 1304 1305 KR_declaration_list: 1311 1306 push c_declaration pop ';' 1312 1307 { $$ = $2; } 1313 | KR_ parameter_list push c_declaration pop ';'1308 | KR_declaration_list push c_declaration pop ';' 1314 1309 { $$ = $1->appendList( $3 ); } 1315 1310 ; … … 1326 1321 1327 1322 local_label_list: // GCC, local label 1328 no_attr_identifier_or_type_name 1329 | local_label_list ',' no_attr_identifier_or_type_name 1323 no_attr_identifier_or_type_name {} 1324 | local_label_list ',' no_attr_identifier_or_type_name {} 1330 1325 ; 1331 1326 1332 1327 declaration: // old & new style declarations 1333 c_declaration ';'1334 | cfa_declaration ';'// CFA1328 c_declaration pop ';' 1329 | cfa_declaration pop ';' // CFA 1335 1330 | static_assert 1336 1331 ; … … 1390 1385 | declaration_qualifier_list type_qualifier_list cfa_function_specifier 1391 1386 { $$ = $3->addQualifiers( $1 )->addQualifiers( $2 ); } 1392 | cfa_function_declaration ',' identifier_or_type_name '(' push cfa_parameter_ellipsis_list_opt pop')'1387 | cfa_function_declaration ',' identifier_or_type_name '(' cfa_parameter_type_list_opt ')' 1393 1388 { 1394 1389 // Append the return type at the start (left-hand-side) to each identifier in the list. 1395 1390 DeclarationNode * ret = new DeclarationNode; 1396 1391 ret->type = maybeClone( $1->type->base ); 1397 $$ = $1->appendList( DeclarationNode::newFunction( $3, ret, $ 6, nullptr ) );1392 $$ = $1->appendList( DeclarationNode::newFunction( $3, ret, $5, nullptr ) ); 1398 1393 } 1399 1394 ; 1400 1395 1401 1396 cfa_function_specifier: // CFA 1402 // '[' ']' identifier_or_type_name '(' push cfa_parameter_ ellipsis_list_opt pop ')' // S/R conflict1397 // '[' ']' identifier_or_type_name '(' push cfa_parameter_type_list_opt pop ')' // S/R conflict 1403 1398 // { 1404 1399 // $$ = DeclarationNode::newFunction( $3, DeclarationNode::newTuple( 0 ), $6, 0, true ); 1405 1400 // } 1406 // '[' ']' identifier '(' push cfa_parameter_ ellipsis_list_opt pop ')'1401 // '[' ']' identifier '(' push cfa_parameter_type_list_opt pop ')' 1407 1402 // { 1408 1403 // typedefTable.setNextIdentifier( *$5 ); 1409 1404 // $$ = DeclarationNode::newFunction( $5, DeclarationNode::newTuple( 0 ), $8, 0, true ); 1410 1405 // } 1411 // | '[' ']' TYPEDEFname '(' push cfa_parameter_ ellipsis_list_opt pop ')'1406 // | '[' ']' TYPEDEFname '(' push cfa_parameter_type_list_opt pop ')' 1412 1407 // { 1413 1408 // typedefTable.setNextIdentifier( *$5 ); … … 1417 1412 // identifier_or_type_name must be broken apart because of the sequence: 1418 1413 // 1419 // '[' ']' identifier_or_type_name '(' cfa_parameter_ ellipsis_list_opt ')'1414 // '[' ']' identifier_or_type_name '(' cfa_parameter_type_list_opt ')' 1420 1415 // '[' ']' type_specifier 1421 1416 // 1422 1417 // type_specifier can resolve to just TYPEDEFname (e.g., typedef int T; int f( T );). Therefore this must be 1423 1418 // flattened to allow lookahead to the '(' without having to reduce identifier_or_type_name. 1424 cfa_abstract_tuple identifier_or_type_name '(' push cfa_parameter_ellipsis_list_opt pop')'1419 cfa_abstract_tuple identifier_or_type_name '(' cfa_parameter_type_list_opt ')' 1425 1420 // To obtain LR(1 ), this rule must be factored out from function return type (see cfa_abstract_declarator). 1426 { $$ = DeclarationNode::newFunction( $2, $1, $ 5, 0 ); }1427 | cfa_function_return identifier_or_type_name '(' push cfa_parameter_ellipsis_list_opt pop')'1428 { $$ = DeclarationNode::newFunction( $2, $1, $ 5, 0 ); }1421 { $$ = DeclarationNode::newFunction( $2, $1, $4, 0 ); } 1422 | cfa_function_return identifier_or_type_name '(' cfa_parameter_type_list_opt ')' 1423 { $$ = DeclarationNode::newFunction( $2, $1, $4, 0 ); } 1429 1424 ; 1430 1425 1431 1426 cfa_function_return: // CFA 1432 '[' push cfa_parameter_list pop ']' 1433 { $$ = DeclarationNode::newTuple( $3 ); } 1434 | '[' push cfa_parameter_list pop ',' push cfa_abstract_parameter_list pop ']' 1435 // To obtain LR(1 ), the last cfa_abstract_parameter_list is added into this flattened rule to lookahead to the ']'. 1436 { $$ = DeclarationNode::newTuple( $3->appendList( $7 ) ); } 1427 '[' cfa_parameter_list ']' 1428 { $$ = DeclarationNode::newTuple( $2 ); } 1429 | '[' cfa_parameter_list ',' cfa_abstract_parameter_list ']' 1430 // To obtain LR(1 ), the last cfa_abstract_parameter_list is added into this flattened rule to lookahead to the 1431 // ']'. 1432 { $$ = DeclarationNode::newTuple( $2->appendList( $4 ) ); } 1437 1433 ; 1438 1434 … … 1440 1436 TYPEDEF cfa_variable_specifier 1441 1437 { 1442 typedefTable.addToEnclosingScope( *$2->name, TYPEDEFname /*, "1"*/);1438 typedefTable.addToEnclosingScope( *$2->name, TYPEDEFname ); 1443 1439 $$ = $2->addTypedef(); 1444 1440 } 1445 1441 | TYPEDEF cfa_function_specifier 1446 1442 { 1447 typedefTable.addToEnclosingScope( *$2->name, TYPEDEFname /*, "2"*/);1443 typedefTable.addToEnclosingScope( *$2->name, TYPEDEFname ); 1448 1444 $$ = $2->addTypedef(); 1449 1445 } 1450 1446 | cfa_typedef_declaration pop ',' push no_attr_identifier 1451 1447 { 1452 typedefTable.addToEnclosingScope( *$5, TYPEDEFname /*, "3"*/);1448 typedefTable.addToEnclosingScope( *$5, TYPEDEFname ); 1453 1449 $$ = $1->appendList( $1->cloneType( $5 ) ); 1454 1450 } … … 1461 1457 TYPEDEF type_specifier declarator 1462 1458 { 1463 typedefTable.addToEnclosingScope( *$3->name, TYPEDEFname /*, "4"*/);1459 typedefTable.addToEnclosingScope( *$3->name, TYPEDEFname ); 1464 1460 $$ = $3->addType( $2 )->addTypedef(); 1465 1461 } 1466 1462 | typedef_declaration pop ',' push declarator 1467 1463 { 1468 typedefTable.addToEnclosingScope( *$5->name, TYPEDEFname /*, "5"*/);1464 typedefTable.addToEnclosingScope( *$5->name, TYPEDEFname ); 1469 1465 $$ = $1->appendList( $1->cloneBaseType( $5 )->addTypedef() ); 1470 1466 } 1471 1467 | type_qualifier_list TYPEDEF type_specifier declarator // remaining OBSOLESCENT (see 2 ) 1472 1468 { 1473 typedefTable.addToEnclosingScope( *$4->name, TYPEDEFname /*, "6"*/);1469 typedefTable.addToEnclosingScope( *$4->name, TYPEDEFname ); 1474 1470 $$ = $4->addType( $3 )->addQualifiers( $1 )->addTypedef(); 1475 1471 } 1476 1472 | type_specifier TYPEDEF declarator 1477 1473 { 1478 typedefTable.addToEnclosingScope( *$3->name, TYPEDEFname /*, "7"*/);1474 typedefTable.addToEnclosingScope( *$3->name, TYPEDEFname ); 1479 1475 $$ = $3->addType( $1 )->addTypedef(); 1480 1476 } 1481 1477 | type_specifier TYPEDEF type_qualifier_list declarator 1482 1478 { 1483 typedefTable.addToEnclosingScope( *$4->name, TYPEDEFname /*, "8"*/);1479 typedefTable.addToEnclosingScope( *$4->name, TYPEDEFname ); 1484 1480 $$ = $4->addQualifiers( $1 )->addTypedef()->addType( $1 ); 1485 1481 } … … 1608 1604 1609 1605 forall: 1610 FORALL '(' type_parameter_list ')' // CFA 1611 { $$ = DeclarationNode::newForall( $3 ); } 1606 FORALL '(' 1607 { 1608 typedefTable.enterScope(); 1609 } 1610 type_parameter_list ')' // CFA 1611 { 1612 typedefTable.leaveScope(); 1613 $$ = DeclarationNode::newForall( $4 ); 1614 } 1612 1615 ; 1613 1616 … … 1977 1980 ; 1978 1981 1979 cfa_parameter_ ellipsis_list_opt: // CFA, abstract + real1982 cfa_parameter_type_list_opt: // CFA, abstract + real 1980 1983 // empty 1981 1984 { $$ = DeclarationNode::newBasicType( DeclarationNode::Void ); } … … 1984 1987 | cfa_abstract_parameter_list 1985 1988 | cfa_parameter_list 1986 | cfa_parameter_list pop ',' pushcfa_abstract_parameter_list1987 { $$ = $1->appendList( $ 5); }1988 | cfa_abstract_parameter_list pop ',' pushELLIPSIS1989 | cfa_parameter_list ',' cfa_abstract_parameter_list 1990 { $$ = $1->appendList( $3 ); } 1991 | cfa_abstract_parameter_list ',' ELLIPSIS 1989 1992 { $$ = $1->addVarArgs(); } 1990 | cfa_parameter_list pop ',' pushELLIPSIS1993 | cfa_parameter_list ',' ELLIPSIS 1991 1994 { $$ = $1->addVarArgs(); } 1992 1995 ; … … 1996 1999 // factored out from cfa_parameter_list, flattening the rules to get lookahead to the ']'. 1997 2000 cfa_parameter_declaration 1998 | cfa_abstract_parameter_list pop ',' pushcfa_parameter_declaration1999 { $$ = $1->appendList( $ 5); }2000 | cfa_parameter_list pop ',' pushcfa_parameter_declaration2001 { $$ = $1->appendList( $ 5); }2002 | cfa_parameter_list pop ',' push cfa_abstract_parameter_list pop ',' pushcfa_parameter_declaration2003 { $$ = $1->appendList( $ 5 )->appendList( $9); }2001 | cfa_abstract_parameter_list ',' cfa_parameter_declaration 2002 { $$ = $1->appendList( $3 ); } 2003 | cfa_parameter_list ',' cfa_parameter_declaration 2004 { $$ = $1->appendList( $3 ); } 2005 | cfa_parameter_list ',' cfa_abstract_parameter_list ',' cfa_parameter_declaration 2006 { $$ = $1->appendList( $3 )->appendList( $5 ); } 2004 2007 ; 2005 2008 2006 2009 cfa_abstract_parameter_list: // CFA, new & old style abstract 2007 2010 cfa_abstract_parameter_declaration 2008 | cfa_abstract_parameter_list pop ',' pushcfa_abstract_parameter_declaration2009 { $$ = $1->appendList( $ 5); }2011 | cfa_abstract_parameter_list ',' cfa_abstract_parameter_declaration 2012 { $$ = $1->appendList( $3 ); } 2010 2013 ; 2011 2014 … … 2156 2159 '.' no_attr_identifier // C99, field name 2157 2160 { $$ = new ExpressionNode( build_varref( $2 ) ); } 2158 | '[' push assignment_expression pop ']'// C99, single array element2161 | '[' assignment_expression ']' // C99, single array element 2159 2162 // assignment_expression used instead of constant_expression because of shift/reduce conflicts with tuple. 2163 { $$ = $2; } 2164 | '[' subrange ']' // CFA, multiple array elements 2165 { $$ = $2; } 2166 | '[' constant_expression ELLIPSIS constant_expression ']' // GCC, multiple array elements 2167 { $$ = new ExpressionNode( new RangeExpr( maybeMoveBuild< Expression >( $2 ), maybeMoveBuild< Expression >( $4 ) ) ); } 2168 | '.' '[' field_list ']' // CFA, tuple field selector 2160 2169 { $$ = $3; } 2161 | '[' push subrange pop ']' // CFA, multiple array elements2162 { $$ = $3; }2163 | '[' push constant_expression ELLIPSIS constant_expression pop ']' // GCC, multiple array elements2164 { $$ = new ExpressionNode( new RangeExpr( maybeMoveBuild< Expression >( $3 ), maybeMoveBuild< Expression >( $5 ) ) ); }2165 | '.' '[' push field_list pop ']' // CFA, tuple field selector2166 { $$ = $4; }2167 2170 ; 2168 2171 … … 2201 2204 type_parameter: // CFA 2202 2205 type_class no_attr_identifier_or_type_name 2203 { typedefTable.addTo Scope( *$2, TYPEDEFname /*, "9"*/); }2206 { typedefTable.addToEnclosingScope( *$2, TYPEDEFname ); } 2204 2207 type_initializer_opt assertion_list_opt 2205 2208 { $$ = DeclarationNode::newTypeParam( $1, $2 )->addTypeInitializer( $4 )->addAssertions( $5 ); } … … 2235 2238 '|' no_attr_identifier_or_type_name '(' type_list ')' 2236 2239 { $$ = DeclarationNode::newTraitUse( $2, $4 ); } 2237 | '|' '{' push trait_declaration_list pop'}'2240 | '|' '{' push trait_declaration_list '}' 2238 2241 { $$ = $4; } 2239 // | '|' '(' push type_parameter_list pop ')' '{' push trait_declaration_list pop'}' '(' type_list ')'2240 //{ SemanticError( yylloc, "Generic data-type assertion is currently unimplemented." ); $$ = nullptr; }2242 | '|' '(' push type_parameter_list pop ')' '{' push trait_declaration_list '}' '(' type_list ')' 2243 { SemanticError( yylloc, "Generic data-type assertion is currently unimplemented." ); $$ = nullptr; } 2241 2244 ; 2242 2245 … … 2270 2273 no_attr_identifier_or_type_name 2271 2274 { 2272 typedefTable.addToEnclosingScope( *$1, TYPEDEFname /*, "10"*/);2275 typedefTable.addToEnclosingScope( *$1, TYPEDEFname ); 2273 2276 $$ = DeclarationNode::newTypeDecl( $1, 0 ); 2274 2277 } 2275 | no_attr_identifier_or_type_name '(' type_parameter_list')'2276 { 2277 typedefTable.addToEnclosingScope( *$1, TYPEGENname /*, "11"*/);2278 $$ = DeclarationNode::newTypeDecl( $1, $ 3);2278 | no_attr_identifier_or_type_name '(' push type_parameter_list pop ')' 2279 { 2280 typedefTable.addToEnclosingScope( *$1, TYPEGENname ); 2281 $$ = DeclarationNode::newTypeDecl( $1, $4 ); 2279 2282 } 2280 2283 ; 2281 2284 2282 2285 trait_specifier: // CFA 2283 TRAIT no_attr_identifier_or_type_name '(' type_parameter_list ')' '{' '}' 2284 { $$ = DeclarationNode::newTrait( $2, $4, 0 ); } 2285 | TRAIT no_attr_identifier_or_type_name '(' type_parameter_list ')' '{' push trait_declaration_list pop '}' 2286 { $$ = DeclarationNode::newTrait( $2, $4, $8 ); } 2286 TRAIT no_attr_identifier_or_type_name '(' push type_parameter_list pop ')' '{' '}' 2287 { $$ = DeclarationNode::newTrait( $2, $5, 0 ); } 2288 | TRAIT no_attr_identifier_or_type_name '(' push type_parameter_list pop ')' '{' 2289 { typedefTable.enterScope(); } 2290 trait_declaration_list '}' 2291 { $$ = DeclarationNode::newTrait( $2, $5, $10 ); } 2287 2292 ; 2288 2293 2289 2294 trait_declaration_list: // CFA 2290 2295 trait_declaration 2291 | trait_declaration_list p op push trait_declaration2292 { $$ = $1->appendList( $ 4); }2296 | trait_declaration_list push trait_declaration 2297 { $$ = $1->appendList( $3 ); } 2293 2298 ; 2294 2299 2295 2300 trait_declaration: // CFA 2296 cfa_trait_declaring_list ';'2297 | trait_declaring_list ';'2301 cfa_trait_declaring_list pop ';' 2302 | trait_declaring_list pop ';' 2298 2303 ; 2299 2304 2300 2305 cfa_trait_declaring_list: // CFA 2301 2306 cfa_variable_specifier 2307 { $$ = $1; } 2302 2308 | cfa_function_specifier 2309 { $$ = $1; } 2303 2310 | cfa_trait_declaring_list pop ',' push identifier_or_type_name 2304 2311 { $$ = $1->appendList( $1->cloneType( $5 ) ); } … … 2322 2329 2323 2330 external_definition_list: 2324 push external_definition pop 2325 { $$ = $2; } 2331 external_definition 2326 2332 | external_definition_list 2327 2333 { forall = xxx; } 2328 push external_definition pop2334 push external_definition 2329 2335 { $$ = $1 ? $1->appendList( $4 ) : $4; } 2330 2336 ; … … 2348 2354 linkage = LinkageSpec::linkageUpdate( yylloc, linkage, $2 ); 2349 2355 } 2350 // SKULLDUGGERY: Declarations in extern "X" need to be added to the current lexical scope. However, 2351 // external_definition_list_opt creates a new scope that loses the types at the end of the extern block. The 2352 // correction is a pop/push (reverse order) to undo the push/pop from external_definition_list_opt. This 2353 // trick works for nested extern "X"s, as each one undoes itself in the nesting. 2354 '{' pop external_definition_list_opt push '}' 2356 '{' external_definition_list_opt '}' 2355 2357 { 2356 2358 linkage = linkageStack.top(); 2357 2359 linkageStack.pop(); 2358 $$ = $ 6;2360 $$ = $5; 2359 2361 } 2360 2362 | EXTENSION external_definition // GCC, multiple __extension__ allowed, meaning unknown … … 2364 2366 } 2365 2367 | type_qualifier_list 2366 { if ( $1->type->forall ) xxx = forall = true; } // remember generic type 2367 '{' external_definition_list push '}' // CFA, namespace 2368 { 2369 for ( DeclarationNode * iter = $4; iter != nullptr; iter = (DeclarationNode *)iter->get_next() ) { 2368 { 2369 if ( $1->type->forall ) xxx = forall = true; // remember generic type 2370 } 2371 push '{' external_definition_list '}' // CFA, namespace 2372 { 2373 for ( DeclarationNode * iter = $5; iter != nullptr; iter = (DeclarationNode *)iter->get_next() ) { 2370 2374 if ( isMangled( iter->linkage ) ) { // ignore extern "C" 2371 2375 iter->addQualifiers( $1->clone() ); … … 2374 2378 xxx = false; 2375 2379 delete $1; 2376 $$ = $ 4;2380 $$ = $5; 2377 2381 } 2378 2382 | declaration_qualifier_list 2379 { if ( $1->type->forall ) xxx = forall = true; } // remember generic type 2380 '{' external_definition_list '}' // CFA, namespace 2381 { 2382 for ( DeclarationNode * iter = $4; iter != nullptr; iter = (DeclarationNode *)iter->get_next() ) { 2383 { 2384 if ( $1->type->forall ) xxx = forall = true; // remember generic type 2385 } 2386 push '{' external_definition_list '}' // CFA, namespace 2387 { 2388 for ( DeclarationNode * iter = $5; iter != nullptr; iter = (DeclarationNode *)iter->get_next() ) { 2383 2389 if ( isMangled( iter->linkage ) ) { // ignore extern "C" 2384 2390 iter->addQualifiers( $1->clone() ); … … 2387 2393 xxx = false; 2388 2394 delete $1; 2389 $$ = $ 4;2395 $$ = $5; 2390 2396 } 2391 2397 | declaration_qualifier_list type_qualifier_list … … 2394 2400 if ( $2->type->forall ) xxx = forall = true; // remember generic type 2395 2401 } 2396 '{' external_definition_list '}'// CFA, namespace2397 { 2398 for ( DeclarationNode * iter = $ 5; iter != nullptr; iter = (DeclarationNode *)iter->get_next() ) {2402 push '{' external_definition_list '}' // CFA, namespace 2403 { 2404 for ( DeclarationNode * iter = $6; iter != nullptr; iter = (DeclarationNode *)iter->get_next() ) { 2399 2405 if ( isMangled( iter->linkage ) && isMangled( $2->linkage ) ) { // ignore extern "C" 2400 2406 iter->addQualifiers( $1->clone() ); … … 2405 2411 delete $1; 2406 2412 delete $2; 2407 $$ = $ 5;2413 $$ = $6; 2408 2414 } 2409 2415 ; … … 2417 2423 // declaration must still have a type_specifier. OBSOLESCENT (see 1) 2418 2424 | function_declarator compound_statement 2419 { $$ = $1->addFunctionBody( $2 ); } 2420 | KR_function_declarator KR_parameter_list_opt compound_statement 2421 { $$ = $1->addOldDeclList( $2 )->addFunctionBody( $3 ); } 2425 { 2426 typedefTable.leaveScope(); 2427 $$ = $1->addFunctionBody( $2 ); 2428 } 2429 | KR_function_declarator KR_declaration_list_opt compound_statement 2430 { 2431 typedefTable.leaveScope(); 2432 $$ = $1->addOldDeclList( $2 )->addFunctionBody( $3 ); 2433 } 2422 2434 ; 2423 2435 … … 2432 2444 cfa_function_declaration with_clause_opt compound_statement // CFA 2433 2445 { 2446 typedefTable.leaveScope(); 2434 2447 // Add the function body to the last identifier in the function definition list, i.e., foo3: 2435 2448 // [const double] foo1(), foo2( int ), foo3( double ) { return 3.0; } … … 2440 2453 { 2441 2454 rebindForall( $1, $2 ); 2455 typedefTable.leaveScope(); 2442 2456 $$ = $2->addFunctionBody( $4, $3 )->addType( $1 ); 2443 2457 } … … 2445 2459 { 2446 2460 rebindForall( $1, $2 ); 2461 typedefTable.leaveScope(); 2447 2462 $$ = $2->addFunctionBody( $4, $3 )->addType( $1 ); 2448 2463 } 2449 2464 // handles default int return type, OBSOLESCENT (see 1) 2450 2465 | type_qualifier_list function_declarator with_clause_opt compound_statement 2451 { $$ = $2->addFunctionBody( $4, $3 )->addQualifiers( $1 ); } 2466 { 2467 typedefTable.leaveScope(); 2468 $$ = $2->addFunctionBody( $4, $3 )->addQualifiers( $1 ); 2469 } 2452 2470 // handles default int return type, OBSOLESCENT (see 1) 2453 2471 | declaration_qualifier_list function_declarator with_clause_opt compound_statement 2454 { $$ = $2->addFunctionBody( $4, $3 )->addQualifiers( $1 ); } 2472 { 2473 typedefTable.leaveScope(); 2474 $$ = $2->addFunctionBody( $4, $3 )->addQualifiers( $1 ); 2475 } 2455 2476 // handles default int return type, OBSOLESCENT (see 1) 2456 2477 | declaration_qualifier_list type_qualifier_list function_declarator with_clause_opt compound_statement 2457 { $$ = $3->addFunctionBody( $5, $4 )->addQualifiers( $2 )->addQualifiers( $1 ); } 2478 { 2479 typedefTable.leaveScope(); 2480 $$ = $3->addFunctionBody( $5, $4 )->addQualifiers( $2 )->addQualifiers( $1 ); 2481 } 2458 2482 2459 2483 // Old-style K&R function definition, OBSOLESCENT (see 4) 2460 | declaration_specifier KR_function_declarator KR_ parameter_list_opt with_clause_opt compound_statement2484 | declaration_specifier KR_function_declarator KR_declaration_list_opt with_clause_opt compound_statement 2461 2485 { 2462 2486 rebindForall( $1, $2 ); 2487 typedefTable.leaveScope(); 2463 2488 $$ = $2->addOldDeclList( $3 )->addFunctionBody( $5, $4 )->addType( $1 ); 2464 2489 } 2465 2490 // handles default int return type, OBSOLESCENT (see 1) 2466 | type_qualifier_list KR_function_declarator KR_parameter_list_opt with_clause_opt compound_statement 2467 { $$ = $2->addOldDeclList( $3 )->addFunctionBody( $5, $4 )->addQualifiers( $1 ); } 2491 | type_qualifier_list KR_function_declarator KR_declaration_list_opt with_clause_opt compound_statement 2492 { 2493 typedefTable.leaveScope(); 2494 $$ = $2->addOldDeclList( $3 )->addFunctionBody( $5, $4 )->addQualifiers( $1 ); 2495 } 2468 2496 // handles default int return type, OBSOLESCENT (see 1) 2469 | declaration_qualifier_list KR_function_declarator KR_parameter_list_opt with_clause_opt compound_statement 2470 { $$ = $2->addOldDeclList( $3 )->addFunctionBody( $5, $4 )->addQualifiers( $1 ); } 2497 | declaration_qualifier_list KR_function_declarator KR_declaration_list_opt with_clause_opt compound_statement 2498 { 2499 typedefTable.leaveScope(); 2500 $$ = $2->addOldDeclList( $3 )->addFunctionBody( $5, $4 )->addQualifiers( $1 ); 2501 } 2471 2502 // handles default int return type, OBSOLESCENT (see 1) 2472 | declaration_qualifier_list type_qualifier_list KR_function_declarator KR_parameter_list_opt with_clause_opt compound_statement 2473 { $$ = $3->addOldDeclList( $4 )->addFunctionBody( $6, $5 )->addQualifiers( $2 )->addQualifiers( $1 ); } 2503 | declaration_qualifier_list type_qualifier_list KR_function_declarator KR_declaration_list_opt with_clause_opt compound_statement 2504 { 2505 typedefTable.leaveScope(); 2506 $$ = $3->addOldDeclList( $4 )->addFunctionBody( $6, $5 )->addQualifiers( $2 )->addQualifiers( $1 ); 2507 } 2474 2508 ; 2475 2509 … … 2668 2702 paren_identifier '(' identifier_list ')' // function_declarator handles empty parameter 2669 2703 { $$ = $1->addIdList( $3 ); } 2670 | '(' KR_function_ptr ')' '(' p ush parameter_type_list_opt pop')'2671 { $$ = $2->addParamList( $ 6); }2704 | '(' KR_function_ptr ')' '(' parameter_type_list_opt ')' 2705 { $$ = $2->addParamList( $5 ); } 2672 2706 | '(' KR_function_no_ptr ')' // redundant parenthesis 2673 2707 { $$ = $2; } … … 2715 2749 typedef 2716 2750 // hide type name in enclosing scope by variable name 2717 { typedefTable.addToEnclosingScope( *$1->name, IDENTIFIER /*, "ID"*/); }2751 { typedefTable.addToEnclosingScope( *$1->name, IDENTIFIER ); } 2718 2752 | '(' paren_type ')' 2719 2753 { $$ = $2; } … … 2787 2821 2788 2822 identifier_parameter_function: 2789 paren_identifier '(' p ush parameter_type_list_opt pop ')'// empty parameter list OBSOLESCENT (see 3)2790 { $$ = $1->addParamList( $ 4); }2791 | '(' identifier_parameter_ptr ')' '(' p ush parameter_type_list_opt pop')' // empty parameter list OBSOLESCENT (see 3)2792 { $$ = $2->addParamList( $ 6); }2823 paren_identifier '(' parameter_type_list_opt ')' // empty parameter list OBSOLESCENT (see 3) 2824 { $$ = $1->addParamList( $3 ); } 2825 | '(' identifier_parameter_ptr ')' '(' parameter_type_list_opt ')' // empty parameter list OBSOLESCENT (see 3) 2826 { $$ = $2->addParamList( $5 ); } 2793 2827 | '(' identifier_parameter_function ')' // redundant parenthesis 2794 2828 { $$ = $2; } … … 2840 2874 2841 2875 type_parameter_function: 2842 typedef '(' p ush parameter_type_list_opt pop ')'// empty parameter list OBSOLESCENT (see 3)2843 { $$ = $1->addParamList( $ 4); }2844 | '(' type_parameter_ptr ')' '(' p ush parameter_type_list_opt pop')' // empty parameter list OBSOLESCENT (see 3)2845 { $$ = $2->addParamList( $ 6); }2876 typedef '(' parameter_type_list_opt ')' // empty parameter list OBSOLESCENT (see 3) 2877 { $$ = $1->addParamList( $3 ); } 2878 | '(' type_parameter_ptr ')' '(' parameter_type_list_opt ')' // empty parameter list OBSOLESCENT (see 3) 2879 { $$ = $2->addParamList( $5 ); } 2846 2880 ; 2847 2881 … … 2890 2924 2891 2925 abstract_function: 2892 '(' p ush parameter_type_list_opt pop ')'// empty parameter list OBSOLESCENT (see 3)2893 { $$ = DeclarationNode::newFunction( nullptr, nullptr, $ 3, nullptr ); }2894 | '(' abstract_ptr ')' '(' p ush parameter_type_list_opt pop')' // empty parameter list OBSOLESCENT (see 3)2895 { $$ = $2->addParamList( $ 6); }2926 '(' parameter_type_list_opt ')' // empty parameter list OBSOLESCENT (see 3) 2927 { $$ = DeclarationNode::newFunction( nullptr, nullptr, $2, nullptr ); } 2928 | '(' abstract_ptr ')' '(' parameter_type_list_opt ')' // empty parameter list OBSOLESCENT (see 3) 2929 { $$ = $2->addParamList( $5 ); } 2896 2930 | '(' abstract_function ')' // redundant parenthesis 2897 2931 { $$ = $2; } … … 2908 2942 2909 2943 multi_array_dimension: 2910 '[' push assignment_expression pop']'2911 { $$ = DeclarationNode::newArray( $ 3, 0, false ); }2912 | '[' push '*' pop ']'// C992944 '[' assignment_expression ']' 2945 { $$ = DeclarationNode::newArray( $2, 0, false ); } 2946 | '[' '*' ']' // C99 2913 2947 { $$ = DeclarationNode::newVarArray( 0 ); } 2914 | multi_array_dimension '[' push assignment_expression pop']'2915 { $$ = $1->addArray( DeclarationNode::newArray( $ 4, 0, false ) ); }2916 | multi_array_dimension '[' push '*' pop ']'// C992948 | multi_array_dimension '[' assignment_expression ']' 2949 { $$ = $1->addArray( DeclarationNode::newArray( $3, 0, false ) ); } 2950 | multi_array_dimension '[' '*' ']' // C99 2917 2951 { $$ = $1->addArray( DeclarationNode::newVarArray( 0 ) ); } 2918 2952 ; … … 2981 3015 2982 3016 abstract_parameter_function: 2983 '(' p ush parameter_type_list_opt pop ')'// empty parameter list OBSOLESCENT (see 3)2984 { $$ = DeclarationNode::newFunction( nullptr, nullptr, $ 3, nullptr ); }2985 | '(' abstract_parameter_ptr ')' '(' p ush parameter_type_list_opt pop')' // empty parameter list OBSOLESCENT (see 3)2986 { $$ = $2->addParamList( $ 6); }3017 '(' parameter_type_list_opt ')' // empty parameter list OBSOLESCENT (see 3) 3018 { $$ = DeclarationNode::newFunction( nullptr, nullptr, $2, nullptr ); } 3019 | '(' abstract_parameter_ptr ')' '(' parameter_type_list_opt ')' // empty parameter list OBSOLESCENT (see 3) 3020 { $$ = $2->addParamList( $5 ); } 2987 3021 | '(' abstract_parameter_function ')' // redundant parenthesis 2988 3022 { $$ = $2; } … … 3005 3039 '[' ']' 3006 3040 { $$ = DeclarationNode::newArray( 0, 0, false ); } 3007 // multi_array_dimension handles the '[' '*' ']' case3008 | '[' push type_qualifier_list '*' pop ']'// remaining C993009 { $$ = DeclarationNode::newVarArray( $ 3); }3010 | '[' push type_qualifier_list pop']'3011 { $$ = DeclarationNode::newArray( 0, $ 3, false ); }3012 // multi_array_dimension handles the '[' assignment_expression ']' case3013 | '[' push type_qualifier_list assignment_expression pop']'3014 { $$ = DeclarationNode::newArray( $ 4, $3, false ); }3015 | '[' push STATIC type_qualifier_list_opt assignment_expression pop']'3016 { $$ = DeclarationNode::newArray( $ 5, $4, true ); }3017 | '[' push type_qualifier_list STATIC assignment_expression pop']'3018 { $$ = DeclarationNode::newArray( $ 5, $3, true ); }3041 // multi_array_dimension handles the '[' '*' ']' case 3042 | '[' type_qualifier_list '*' ']' // remaining C99 3043 { $$ = DeclarationNode::newVarArray( $2 ); } 3044 | '[' type_qualifier_list ']' 3045 { $$ = DeclarationNode::newArray( 0, $2, false ); } 3046 // multi_array_dimension handles the '[' assignment_expression ']' case 3047 | '[' type_qualifier_list assignment_expression ']' 3048 { $$ = DeclarationNode::newArray( $3, $2, false ); } 3049 | '[' STATIC type_qualifier_list_opt assignment_expression ']' 3050 { $$ = DeclarationNode::newArray( $4, $3, true ); } 3051 | '[' type_qualifier_list STATIC assignment_expression ']' 3052 { $$ = DeclarationNode::newArray( $4, $2, true ); } 3019 3053 ; 3020 3054 … … 3060 3094 3061 3095 variable_abstract_function: 3062 '(' variable_abstract_ptr ')' '(' p ush parameter_type_list_opt pop')' // empty parameter list OBSOLESCENT (see 3)3063 { $$ = $2->addParamList( $ 6); }3096 '(' variable_abstract_ptr ')' '(' parameter_type_list_opt ')' // empty parameter list OBSOLESCENT (see 3) 3097 { $$ = $2->addParamList( $5 ); } 3064 3098 | '(' variable_abstract_function ')' // redundant parenthesis 3065 3099 { $$ = $2; } … … 3124 3158 3125 3159 cfa_array_parameter_1st_dimension: 3126 '[' push type_qualifier_list '*' pop ']'// remaining C993127 { $$ = DeclarationNode::newVarArray( $ 3); }3128 | '[' push type_qualifier_list assignment_expression pop']'3129 { $$ = DeclarationNode::newArray( $ 4, $3, false ); }3130 | '[' push declaration_qualifier_list assignment_expression pop']'3160 '[' type_qualifier_list '*' ']' // remaining C99 3161 { $$ = DeclarationNode::newVarArray( $2 ); } 3162 | '[' type_qualifier_list assignment_expression ']' 3163 { $$ = DeclarationNode::newArray( $3, $2, false ); } 3164 | '[' declaration_qualifier_list assignment_expression ']' 3131 3165 // declaration_qualifier_list must be used because of shift/reduce conflict with 3132 3166 // assignment_expression, so a semantic check is necessary to preclude them as a type_qualifier cannot 3133 3167 // appear in this context. 3134 { $$ = DeclarationNode::newArray( $ 4, $3, true ); }3135 | '[' push declaration_qualifier_list type_qualifier_list assignment_expression pop']'3136 { $$ = DeclarationNode::newArray( $ 5, $4->addQualifiers( $3 ), true ); }3168 { $$ = DeclarationNode::newArray( $3, $2, true ); } 3169 | '[' declaration_qualifier_list type_qualifier_list assignment_expression ']' 3170 { $$ = DeclarationNode::newArray( $4, $3->addQualifiers( $3 ), true ); } 3137 3171 ; 3138 3172 … … 3146 3180 // 3147 3181 // cfa_abstract_tuple identifier_or_type_name 3148 // '[' cfa_parameter_list ']' identifier_or_type_name '(' cfa_parameter_ ellipsis_list_opt ')'3182 // '[' cfa_parameter_list ']' identifier_or_type_name '(' cfa_parameter_type_list_opt ')' 3149 3183 // 3150 3184 // since a function return type can be syntactically identical to a tuple type: … … 3203 3237 3204 3238 cfa_abstract_tuple: // CFA 3205 '[' push cfa_abstract_parameter_list pop ']' 3206 { $$ = DeclarationNode::newTuple( $3 ); } 3207 | '[' push type_specifier_nobody ELLIPSIS pop ']' 3208 { SemanticError( yylloc, "Tuple array currently unimplemented." ); $$ = nullptr; } 3209 | '[' push type_specifier_nobody ELLIPSIS constant_expression pop ']' 3210 { SemanticError( yylloc, "Tuple array currently unimplemented." ); $$ = nullptr; } 3239 '[' cfa_abstract_parameter_list ']' 3240 { $$ = DeclarationNode::newTuple( $2 ); } 3211 3241 ; 3212 3242 3213 3243 cfa_abstract_function: // CFA 3214 // '[' ']' '(' cfa_parameter_ ellipsis_list_opt ')'3244 // '[' ']' '(' cfa_parameter_type_list_opt ')' 3215 3245 // { $$ = DeclarationNode::newFunction( nullptr, DeclarationNode::newTuple( nullptr ), $4, nullptr ); } 3216 cfa_abstract_tuple '(' push cfa_parameter_ellipsis_list_opt pop')'3217 { $$ = DeclarationNode::newFunction( nullptr, $1, $ 4, nullptr ); }3218 | cfa_function_return '(' push cfa_parameter_ellipsis_list_opt pop')'3219 { $$ = DeclarationNode::newFunction( nullptr, $1, $ 4, nullptr ); }3246 cfa_abstract_tuple '(' cfa_parameter_type_list_opt ')' 3247 { $$ = DeclarationNode::newFunction( nullptr, $1, $3, nullptr ); } 3248 | cfa_function_return '(' cfa_parameter_type_list_opt ')' 3249 { $$ = DeclarationNode::newFunction( nullptr, $1, $3, nullptr ); } 3220 3250 ; 3221 3251
Note:
See TracChangeset
for help on using the changeset viewer.