Changes in / [e982385:b4f0dde]
- Location:
- src
- Files:
-
- 6 added
- 2 deleted
- 7 edited
Legend:
- Unmodified
- Added
- Removed
-
src/Parser/parser.yy
re982385 rb4f0dde 10 10 // Created On : Sat Sep 1 20:22:55 2001 11 11 // Last Modified By : Peter A. Buhr 12 // Last Modified On : T ue May 22 08:41:57201813 // Update Count : 33 5312 // Last Modified On : Thu May 24 16:49:58 2018 13 // Update Count : 3367 14 14 // 15 15 … … 837 837 // '[' push assignment_expression pop ']' 838 838 // { $$ = new ExpressionNode( build_tuple( $3 ) ); } 839 '[' ',' tuple_expression_list']'840 { $$ = new ExpressionNode( build_tuple( (ExpressionNode *)(new ExpressionNode( nullptr ) )->set_last( $ 3) ) ); }841 | '[' assignment_expression ',' tuple_expression_list']'842 { $$ = new ExpressionNode( build_tuple( (ExpressionNode *)$ 2->set_last( $4) ) ); }839 '[' push ',' tuple_expression_list pop ']' 840 { $$ = new ExpressionNode( build_tuple( (ExpressionNode *)(new ExpressionNode( nullptr ) )->set_last( $4 ) ) ); } 841 | '[' push assignment_expression ',' tuple_expression_list pop ']' 842 { $$ = new ExpressionNode( build_tuple( (ExpressionNode *)$3->set_last( $5 ) ) ); } 843 843 ; 844 844 … … 866 866 labeled_statement 867 867 | compound_statement 868 | expression_statement { $$ = $1; }868 | expression_statement 869 869 | selection_statement 870 870 | iteration_statement … … 1183 1183 type_specifier_nobody 1184 1184 | type_specifier_nobody declarator 1185 { 1186 $$ = $2->addType( $1 ); 1187 } 1185 { $$ = $2->addType( $1 ); } 1188 1186 | type_specifier_nobody variable_abstract_declarator 1189 1187 { $$ = $2->addType( $1 ); } 1190 1188 | cfa_abstract_declarator_tuple no_attr_identifier // CFA 1191 { 1192 $$ = $1->addName( $2 ); 1193 } 1189 { $$ = $1->addName( $2 ); } 1194 1190 | cfa_abstract_declarator_tuple // CFA 1195 1191 ; … … 1304 1300 1305 1301 local_label_list: // GCC, local label 1306 no_attr_identifier_or_type_name {}1307 | local_label_list ',' no_attr_identifier_or_type_name {}1302 no_attr_identifier_or_type_name 1303 | local_label_list ',' no_attr_identifier_or_type_name 1308 1304 ; 1309 1305 … … 1400 1396 // type_specifier can resolve to just TYPEDEFname (e.g., typedef int T; int f( T );). Therefore this must be 1401 1397 // flattened to allow lookahead to the '(' without having to reduce identifier_or_type_name. 1402 cfa_abstract_tuple identifier_or_type_name '(' cfa_parameter_type_list_opt')'1398 cfa_abstract_tuple identifier_or_type_name '(' push cfa_parameter_type_list_opt pop ')' 1403 1399 // To obtain LR(1 ), this rule must be factored out from function return type (see cfa_abstract_declarator). 1404 { $$ = DeclarationNode::newFunction( $2, $1, $ 4, 0 ); }1405 | cfa_function_return identifier_or_type_name '(' cfa_parameter_type_list_opt')'1406 { $$ = DeclarationNode::newFunction( $2, $1, $ 4, 0 ); }1400 { $$ = DeclarationNode::newFunction( $2, $1, $5, 0 ); } 1401 | cfa_function_return identifier_or_type_name '(' push cfa_parameter_type_list_opt pop ')' 1402 { $$ = DeclarationNode::newFunction( $2, $1, $5, 0 ); } 1407 1403 ; 1408 1404 1409 1405 cfa_function_return: // CFA 1410 '[' cfa_parameter_list']'1411 { $$ = DeclarationNode::newTuple( $ 2); }1412 | '[' cfa_parameter_list ',' cfa_abstract_parameter_list']'1406 '[' push cfa_parameter_list pop ']' 1407 { $$ = DeclarationNode::newTuple( $3 ); } 1408 | '[' push cfa_parameter_list pop ',' push cfa_abstract_parameter_list pop ']' 1413 1409 // To obtain LR(1 ), the last cfa_abstract_parameter_list is added into this flattened rule to lookahead to the 1414 1410 // ']'. 1415 { $$ = DeclarationNode::newTuple( $ 2->appendList( $4) ); }1411 { $$ = DeclarationNode::newTuple( $3->appendList( $7 ) ); } 1416 1412 ; 1417 1413 … … 1587 1583 1588 1584 forall: 1589 FORALL '(' 1590 { 1591 typedefTable.enterScope(); 1592 } 1593 type_parameter_list ')' // CFA 1594 { 1595 typedefTable.leaveScope(); 1596 $$ = DeclarationNode::newForall( $4 ); 1597 } 1585 FORALL '(' push type_parameter_list pop ')' // CFA 1586 { $$ = DeclarationNode::newForall( $4 ); } 1598 1587 ; 1599 1588 … … 1970 1959 | cfa_abstract_parameter_list 1971 1960 | cfa_parameter_list 1972 | cfa_parameter_list ','cfa_abstract_parameter_list1973 { $$ = $1->appendList( $ 3); }1974 | cfa_abstract_parameter_list ','ELLIPSIS1961 | cfa_parameter_list pop ',' push cfa_abstract_parameter_list 1962 { $$ = $1->appendList( $5 ); } 1963 | cfa_abstract_parameter_list pop ',' push ELLIPSIS 1975 1964 { $$ = $1->addVarArgs(); } 1976 | cfa_parameter_list ','ELLIPSIS1965 | cfa_parameter_list pop ',' push ELLIPSIS 1977 1966 { $$ = $1->addVarArgs(); } 1978 1967 ; … … 1982 1971 // factored out from cfa_parameter_list, flattening the rules to get lookahead to the ']'. 1983 1972 cfa_parameter_declaration 1984 | cfa_abstract_parameter_list ','cfa_parameter_declaration1985 { $$ = $1->appendList( $ 3); }1986 | cfa_parameter_list ','cfa_parameter_declaration1987 { $$ = $1->appendList( $ 3); }1988 | cfa_parameter_list ',' cfa_abstract_parameter_list ','cfa_parameter_declaration1989 { $$ = $1->appendList( $ 3 )->appendList( $5); }1973 | cfa_abstract_parameter_list pop ',' push cfa_parameter_declaration 1974 { $$ = $1->appendList( $5 ); } 1975 | cfa_parameter_list pop ',' push cfa_parameter_declaration 1976 { $$ = $1->appendList( $5 ); } 1977 | cfa_parameter_list pop ',' push cfa_abstract_parameter_list pop ',' push cfa_parameter_declaration 1978 { $$ = $1->appendList( $5 )->appendList( $9 ); } 1990 1979 ; 1991 1980 1992 1981 cfa_abstract_parameter_list: // CFA, new & old style abstract 1993 1982 cfa_abstract_parameter_declaration 1994 | cfa_abstract_parameter_list ','cfa_abstract_parameter_declaration1995 { $$ = $1->appendList( $ 3); }1983 | cfa_abstract_parameter_list pop ',' push cfa_abstract_parameter_declaration 1984 { $$ = $1->appendList( $5 ); } 1996 1985 ; 1997 1986 … … 2142 2131 '.' no_attr_identifier // C99, field name 2143 2132 { $$ = new ExpressionNode( build_varref( $2 ) ); } 2144 | '[' assignment_expression ']'// C99, single array element2133 | '[' push assignment_expression pop ']' // C99, single array element 2145 2134 // assignment_expression used instead of constant_expression because of shift/reduce conflicts with tuple. 2146 { $$ = $2; }2147 | '[' subrange ']' // CFA, multiple array elements2148 { $$ = $2; }2149 | '[' constant_expression ELLIPSIS constant_expression ']' // GCC, multiple array elements2150 { $$ = new ExpressionNode( new RangeExpr( maybeMoveBuild< Expression >( $2 ), maybeMoveBuild< Expression >( $4 ) ) ); }2151 | '.' '[' field_list ']' // CFA, tuple field selector2152 2135 { $$ = $3; } 2136 | '[' push subrange pop ']' // CFA, multiple array elements 2137 { $$ = $3; } 2138 | '[' push constant_expression ELLIPSIS constant_expression pop ']' // GCC, multiple array elements 2139 { $$ = new ExpressionNode( new RangeExpr( maybeMoveBuild< Expression >( $3 ), maybeMoveBuild< Expression >( $5 ) ) ); } 2140 | '.' '[' push field_list pop ']' // CFA, tuple field selector 2141 { $$ = $4; } 2153 2142 ; 2154 2143 … … 2288 2277 cfa_trait_declaring_list: // CFA 2289 2278 cfa_variable_specifier 2290 { $$ = $1; }2291 2279 | cfa_function_specifier 2292 { $$ = $1; }2293 2280 | cfa_trait_declaring_list pop ',' push identifier_or_type_name 2294 2281 { $$ = $1->appendList( $1->cloneType( $5 ) ); } … … 2349 2336 } 2350 2337 | type_qualifier_list 2351 { 2352 if ( $1->type->forall ) xxx = forall = true; // remember generic type 2353 } 2338 { if ( $1->type->forall ) xxx = forall = true; } // remember generic type 2354 2339 push '{' external_definition_list '}' // CFA, namespace 2355 2340 { … … 2364 2349 } 2365 2350 | declaration_qualifier_list 2366 { 2367 if ( $1->type->forall ) xxx = forall = true; // remember generic type 2368 } 2351 { if ( $1->type->forall ) xxx = forall = true; } // remember generic type 2369 2352 push '{' external_definition_list '}' // CFA, namespace 2370 2353 { … … 2406 2389 // declaration must still have a type_specifier. OBSOLESCENT (see 1) 2407 2390 | function_declarator compound_statement 2408 { 2409 typedefTable.leaveScope(); 2410 $$ = $1->addFunctionBody( $2 ); 2411 } 2391 { $$ = $1->addFunctionBody( $2 ); } 2412 2392 | KR_function_declarator KR_declaration_list_opt compound_statement 2413 { 2414 typedefTable.leaveScope(); 2415 $$ = $1->addOldDeclList( $2 )->addFunctionBody( $3 ); 2416 } 2393 { $$ = $1->addOldDeclList( $2 )->addFunctionBody( $3 ); } 2417 2394 ; 2418 2395 … … 2427 2404 cfa_function_declaration with_clause_opt compound_statement // CFA 2428 2405 { 2429 typedefTable.leaveScope();2430 2406 // Add the function body to the last identifier in the function definition list, i.e., foo3: 2431 2407 // [const double] foo1(), foo2( int ), foo3( double ) { return 3.0; } … … 2436 2412 { 2437 2413 rebindForall( $1, $2 ); 2438 typedefTable.leaveScope();2439 2414 $$ = $2->addFunctionBody( $4, $3 )->addType( $1 ); 2440 2415 } … … 2442 2417 { 2443 2418 rebindForall( $1, $2 ); 2444 typedefTable.leaveScope();2445 2419 $$ = $2->addFunctionBody( $4, $3 )->addType( $1 ); 2446 2420 } 2447 2421 // handles default int return type, OBSOLESCENT (see 1) 2448 2422 | type_qualifier_list function_declarator with_clause_opt compound_statement 2449 { 2450 typedefTable.leaveScope(); 2451 $$ = $2->addFunctionBody( $4, $3 )->addQualifiers( $1 ); 2452 } 2423 { $$ = $2->addFunctionBody( $4, $3 )->addQualifiers( $1 ); } 2453 2424 // handles default int return type, OBSOLESCENT (see 1) 2454 2425 | declaration_qualifier_list function_declarator with_clause_opt compound_statement 2455 { 2456 typedefTable.leaveScope(); 2457 $$ = $2->addFunctionBody( $4, $3 )->addQualifiers( $1 ); 2458 } 2426 { $$ = $2->addFunctionBody( $4, $3 )->addQualifiers( $1 ); } 2459 2427 // handles default int return type, OBSOLESCENT (see 1) 2460 2428 | declaration_qualifier_list type_qualifier_list function_declarator with_clause_opt compound_statement 2461 { 2462 typedefTable.leaveScope(); 2463 $$ = $3->addFunctionBody( $5, $4 )->addQualifiers( $2 )->addQualifiers( $1 ); 2464 } 2429 { $$ = $3->addFunctionBody( $5, $4 )->addQualifiers( $2 )->addQualifiers( $1 ); } 2465 2430 2466 2431 // Old-style K&R function definition, OBSOLESCENT (see 4) … … 2468 2433 { 2469 2434 rebindForall( $1, $2 ); 2470 typedefTable.leaveScope();2471 2435 $$ = $2->addOldDeclList( $3 )->addFunctionBody( $5, $4 )->addType( $1 ); 2472 2436 } 2473 2437 // handles default int return type, OBSOLESCENT (see 1) 2474 2438 | type_qualifier_list KR_function_declarator KR_declaration_list_opt with_clause_opt compound_statement 2475 { 2476 typedefTable.leaveScope(); 2477 $$ = $2->addOldDeclList( $3 )->addFunctionBody( $5, $4 )->addQualifiers( $1 ); 2478 } 2439 { $$ = $2->addOldDeclList( $3 )->addFunctionBody( $5, $4 )->addQualifiers( $1 ); } 2479 2440 // handles default int return type, OBSOLESCENT (see 1) 2480 2441 | declaration_qualifier_list KR_function_declarator KR_declaration_list_opt with_clause_opt compound_statement 2481 { 2482 typedefTable.leaveScope(); 2483 $$ = $2->addOldDeclList( $3 )->addFunctionBody( $5, $4 )->addQualifiers( $1 ); 2484 } 2442 { $$ = $2->addOldDeclList( $3 )->addFunctionBody( $5, $4 )->addQualifiers( $1 ); } 2485 2443 // handles default int return type, OBSOLESCENT (see 1) 2486 2444 | declaration_qualifier_list type_qualifier_list KR_function_declarator KR_declaration_list_opt with_clause_opt compound_statement 2487 { 2488 typedefTable.leaveScope(); 2489 $$ = $3->addOldDeclList( $4 )->addFunctionBody( $6, $5 )->addQualifiers( $2 )->addQualifiers( $1 ); 2490 } 2445 { $$ = $3->addOldDeclList( $4 )->addFunctionBody( $6, $5 )->addQualifiers( $2 )->addQualifiers( $1 ); } 2491 2446 ; 2492 2447 … … 2685 2640 paren_identifier '(' identifier_list ')' // function_declarator handles empty parameter 2686 2641 { $$ = $1->addIdList( $3 ); } 2687 | '(' KR_function_ptr ')' '(' p arameter_type_list_opt')'2688 { $$ = $2->addParamList( $ 5); }2642 | '(' KR_function_ptr ')' '(' push parameter_type_list_opt pop ')' 2643 { $$ = $2->addParamList( $6 ); } 2689 2644 | '(' KR_function_no_ptr ')' // redundant parenthesis 2690 2645 { $$ = $2; } … … 2804 2759 2805 2760 identifier_parameter_function: 2806 paren_identifier '(' p arameter_type_list_opt ')'// empty parameter list OBSOLESCENT (see 3)2807 { $$ = $1->addParamList( $ 3); }2808 | '(' identifier_parameter_ptr ')' '(' p arameter_type_list_opt')' // empty parameter list OBSOLESCENT (see 3)2809 { $$ = $2->addParamList( $ 5); }2761 paren_identifier '(' push parameter_type_list_opt pop ')' // empty parameter list OBSOLESCENT (see 3) 2762 { $$ = $1->addParamList( $4 ); } 2763 | '(' identifier_parameter_ptr ')' '(' push parameter_type_list_opt pop ')' // empty parameter list OBSOLESCENT (see 3) 2764 { $$ = $2->addParamList( $6 ); } 2810 2765 | '(' identifier_parameter_function ')' // redundant parenthesis 2811 2766 { $$ = $2; } … … 2857 2812 2858 2813 type_parameter_function: 2859 typedef '(' p arameter_type_list_opt ')'// empty parameter list OBSOLESCENT (see 3)2860 { $$ = $1->addParamList( $ 3); }2861 | '(' type_parameter_ptr ')' '(' p arameter_type_list_opt')' // empty parameter list OBSOLESCENT (see 3)2862 { $$ = $2->addParamList( $ 5); }2814 typedef '(' push parameter_type_list_opt pop ')' // empty parameter list OBSOLESCENT (see 3) 2815 { $$ = $1->addParamList( $4 ); } 2816 | '(' type_parameter_ptr ')' '(' push parameter_type_list_opt pop ')' // empty parameter list OBSOLESCENT (see 3) 2817 { $$ = $2->addParamList( $6 ); } 2863 2818 ; 2864 2819 … … 2907 2862 2908 2863 abstract_function: 2909 '(' p arameter_type_list_opt ')'// empty parameter list OBSOLESCENT (see 3)2910 { $$ = DeclarationNode::newFunction( nullptr, nullptr, $ 2, nullptr ); }2911 | '(' abstract_ptr ')' '(' p arameter_type_list_opt')' // empty parameter list OBSOLESCENT (see 3)2912 { $$ = $2->addParamList( $ 5); }2864 '(' push parameter_type_list_opt pop ')' // empty parameter list OBSOLESCENT (see 3) 2865 { $$ = DeclarationNode::newFunction( nullptr, nullptr, $3, nullptr ); } 2866 | '(' abstract_ptr ')' '(' push parameter_type_list_opt pop ')' // empty parameter list OBSOLESCENT (see 3) 2867 { $$ = $2->addParamList( $6 ); } 2913 2868 | '(' abstract_function ')' // redundant parenthesis 2914 2869 { $$ = $2; } … … 2925 2880 2926 2881 multi_array_dimension: 2927 '[' assignment_expression']'2928 { $$ = DeclarationNode::newArray( $ 2, 0, false ); }2929 | '[' '*' ']'// C992882 '[' push assignment_expression pop ']' 2883 { $$ = DeclarationNode::newArray( $3, 0, false ); } 2884 | '[' push '*' pop ']' // C99 2930 2885 { $$ = DeclarationNode::newVarArray( 0 ); } 2931 | multi_array_dimension '[' assignment_expression']'2932 { $$ = $1->addArray( DeclarationNode::newArray( $ 3, 0, false ) ); }2933 | multi_array_dimension '[' '*' ']'// C992886 | multi_array_dimension '[' push assignment_expression pop ']' 2887 { $$ = $1->addArray( DeclarationNode::newArray( $4, 0, false ) ); } 2888 | multi_array_dimension '[' push '*' pop ']' // C99 2934 2889 { $$ = $1->addArray( DeclarationNode::newVarArray( 0 ) ); } 2935 2890 ; … … 2998 2953 2999 2954 abstract_parameter_function: 3000 '(' p arameter_type_list_opt ')'// empty parameter list OBSOLESCENT (see 3)3001 { $$ = DeclarationNode::newFunction( nullptr, nullptr, $ 2, nullptr ); }3002 | '(' abstract_parameter_ptr ')' '(' p arameter_type_list_opt')' // empty parameter list OBSOLESCENT (see 3)3003 { $$ = $2->addParamList( $ 5); }2955 '(' push parameter_type_list_opt pop ')' // empty parameter list OBSOLESCENT (see 3) 2956 { $$ = DeclarationNode::newFunction( nullptr, nullptr, $3, nullptr ); } 2957 | '(' abstract_parameter_ptr ')' '(' push parameter_type_list_opt pop ')' // empty parameter list OBSOLESCENT (see 3) 2958 { $$ = $2->addParamList( $6 ); } 3004 2959 | '(' abstract_parameter_function ')' // redundant parenthesis 3005 2960 { $$ = $2; } … … 3023 2978 { $$ = DeclarationNode::newArray( 0, 0, false ); } 3024 2979 // multi_array_dimension handles the '[' '*' ']' case 3025 | '[' type_qualifier_list '*' ']'// remaining C993026 { $$ = DeclarationNode::newVarArray( $ 2); }3027 | '[' type_qualifier_list']'3028 { $$ = DeclarationNode::newArray( 0, $ 2, false ); }2980 | '[' push type_qualifier_list '*' pop ']' // remaining C99 2981 { $$ = DeclarationNode::newVarArray( $3 ); } 2982 | '[' push type_qualifier_list pop ']' 2983 { $$ = DeclarationNode::newArray( 0, $3, false ); } 3029 2984 // multi_array_dimension handles the '[' assignment_expression ']' case 3030 | '[' type_qualifier_list assignment_expression']'3031 { $$ = DeclarationNode::newArray( $ 3, $2, false ); }3032 | '[' STATIC type_qualifier_list_opt assignment_expression']'3033 { $$ = DeclarationNode::newArray( $ 4, $3, true ); }3034 | '[' type_qualifier_list STATIC assignment_expression']'3035 { $$ = DeclarationNode::newArray( $ 4, $2, true ); }2985 | '[' push type_qualifier_list assignment_expression pop ']' 2986 { $$ = DeclarationNode::newArray( $4, $3, false ); } 2987 | '[' push STATIC type_qualifier_list_opt assignment_expression pop ']' 2988 { $$ = DeclarationNode::newArray( $5, $4, true ); } 2989 | '[' push type_qualifier_list STATIC assignment_expression pop ']' 2990 { $$ = DeclarationNode::newArray( $5, $3, true ); } 3036 2991 ; 3037 2992 … … 3077 3032 3078 3033 variable_abstract_function: 3079 '(' variable_abstract_ptr ')' '(' p arameter_type_list_opt')' // empty parameter list OBSOLESCENT (see 3)3080 { $$ = $2->addParamList( $ 5); }3034 '(' variable_abstract_ptr ')' '(' push parameter_type_list_opt pop ')' // empty parameter list OBSOLESCENT (see 3) 3035 { $$ = $2->addParamList( $6 ); } 3081 3036 | '(' variable_abstract_function ')' // redundant parenthesis 3082 3037 { $$ = $2; } … … 3141 3096 3142 3097 cfa_array_parameter_1st_dimension: 3143 '[' type_qualifier_list '*' ']'// remaining C993144 { $$ = DeclarationNode::newVarArray( $ 2); }3145 | '[' type_qualifier_list assignment_expression']'3146 { $$ = DeclarationNode::newArray( $ 3, $2, false ); }3147 | '[' declaration_qualifier_list assignment_expression']'3098 '[' push type_qualifier_list '*' pop ']' // remaining C99 3099 { $$ = DeclarationNode::newVarArray( $3 ); } 3100 | '[' push type_qualifier_list assignment_expression pop ']' 3101 { $$ = DeclarationNode::newArray( $4, $3, false ); } 3102 | '[' push declaration_qualifier_list assignment_expression pop ']' 3148 3103 // declaration_qualifier_list must be used because of shift/reduce conflict with 3149 3104 // assignment_expression, so a semantic check is necessary to preclude them as a type_qualifier cannot 3150 3105 // appear in this context. 3151 { $$ = DeclarationNode::newArray( $ 3, $2, true ); }3152 | '[' declaration_qualifier_list type_qualifier_list assignment_expression']'3153 { $$ = DeclarationNode::newArray( $ 4, $3->addQualifiers( $3 ), true ); }3106 { $$ = DeclarationNode::newArray( $4, $3, true ); } 3107 | '[' push declaration_qualifier_list type_qualifier_list assignment_expression pop ']' 3108 { $$ = DeclarationNode::newArray( $5, $4->addQualifiers( $3 ), true ); } 3154 3109 ; 3155 3110 … … 3220 3175 3221 3176 cfa_abstract_tuple: // CFA 3222 '[' cfa_abstract_parameter_list']'3223 { $$ = DeclarationNode::newTuple( $ 2); }3177 '[' push cfa_abstract_parameter_list pop ']' 3178 { $$ = DeclarationNode::newTuple( $3 ); } 3224 3179 ; 3225 3180 … … 3227 3182 // '[' ']' '(' cfa_parameter_type_list_opt ')' 3228 3183 // { $$ = DeclarationNode::newFunction( nullptr, DeclarationNode::newTuple( nullptr ), $4, nullptr ); } 3229 cfa_abstract_tuple '(' cfa_parameter_type_list_opt')'3230 { $$ = DeclarationNode::newFunction( nullptr, $1, $ 3, nullptr ); }3231 | cfa_function_return '(' cfa_parameter_type_list_opt')'3232 { $$ = DeclarationNode::newFunction( nullptr, $1, $ 3, nullptr ); }3184 cfa_abstract_tuple '(' push cfa_parameter_type_list_opt pop ')' 3185 { $$ = DeclarationNode::newFunction( nullptr, $1, $4, nullptr ); } 3186 | cfa_function_return '(' push cfa_parameter_type_list_opt pop ')' 3187 { $$ = DeclarationNode::newFunction( nullptr, $1, $4, nullptr ); } 3233 3188 ; 3234 3189 -
src/tests/.expect/math1.x64.txt
re982385 rb4f0dde 12 12 \ 16 256 13 13 \ 912673 256 64 -64 0.015625 -0.015625 18.3791736799526 0.264715-1.1922i 14 log:0 0 0 0.346574+0.785398i 0.346573590279973+0.785398163397448i 0.346573590279972655+0.78539816339744831i15 log2:3 3 316 log10:2 2 217 log1p:0.693147 0.693147180559945 0.69314718055994530918 ilogb:0 0 019 logb:3 3 320 sqrt:1 1 1 1.09868+0.45509i 1.09868411346781+0.455089860562227i 1.09868411346780997+0.455089860562227341i21 cbrt:3 3 322 hypot:1.41421 1.4142135623731 1.41421356237309505 -
src/tests/.expect/math2.x64.txt
re982385 rb4f0dde 1 log:0 0 0 0.346574+0.785398i 0.346573590279973+0.785398163397448i 0.346573590279972655+0.78539816339744831i 2 log2:3 3 3 3 log10:2 2 2 4 log1p:0.693147 0.693147180559945 0.693147180559945309 5 ilogb:0 0 0 6 logb:3 3 3 7 sqrt:1 1 1 1.09868+0.45509i 1.09868411346781+0.455089860562227i 1.09868411346780997+0.455089860562227341i 8 cbrt:3 3 3 9 hypot:1.41421 1.4142135623731 1.41421356237309505 1 10 sin:0.841471 0.841470984807897 0.841470984807896507 1.29846+0.634964i 1.29845758141598+0.634963914784736i 1.29845758141597729+0.634963914784736108i 2 11 cos:0.540302 0.54030230586814 0.540302305868139717 0.83373-0.988898i 0.833730025131149-0.988897705762865i 0.833730025131149049-0.988897705762865096i … … 6 15 atan:0.785398 0.785398163397448 0.78539816339744831 1.01722+0.402359i 1.01722196789785+0.402359478108525i 1.01722196789785137+0.402359478108525094i 7 16 atan2:0.785398 0.785398163397448 0.78539816339744831 atan:0.785398 0.785398163397448 0.78539816339744831 8 sinh:1.1752 1.1752011936438 1.17520119364380146 0.634964+1.29846i 0.634963914784736+1.29845758141598i 0.634963914784736108+1.29845758141597729i9 cosh:1.54308 1.54308063481524 1.54308063481524378 0.83373+0.988898i 0.833730025131149+0.988897705762865i 0.833730025131149049+0.988897705762865096i10 tanh:0.761594 0.761594155955765 0.761594155955764888 1.08392+0.271753i 1.08392332733869+0.271752585319512i 1.08392332733869454+0.271752585319511717i11 acosh:0 0 0 1.06128+0.904557i 1.06127506190504+0.904556894302381i 1.06127506190503565+0.904556894302381364i12 asinh:0.881374 0.881373587019543 0.881373587019543025 1.06128+0.666239i 1.06127506190504+0.666239432492515i 1.06127506190503565+0.666239432492515255i13 atanh:inf inf inf 0.402359+1.01722i 0.402359478108525+1.01722196789785i 0.402359478108525094+1.01722196789785137i14 erf:0.842701 0.842700792949715 0.84270079294971486915 erfc:0.157299 0.157299207050285 0.15729920705028513116 lgamma:1.79176 1.79175946922805 1.79175946922805517 lgamma:1.79176 1 1.79175946922805 1 1.791759469228055 118 tgamma:6 6 6 -
src/tests/.expect/math3.x64.txt
re982385 rb4f0dde 1 floor:1 1 1 2 ceil:2 2 2 3 trunc:3 3 3 4 rint:2 2 2 5 rint:2 2 2 6 rint:2 2 2 7 lrint:2 2 2 8 llrint:2 2 2 9 nearbyint:4 4 4 10 round:2 2 2 11 round:2 2 2 12 round:2 2 2 13 lround:2 2 2 14 llround:2 2 2 15 copysign:-1 -1 -1 16 frexp:0.5 3 0.5 3 0.5 3 17 ldexp:8 8 8 18 modf:2 0.3 2 0.3 2 0.3 19 modf:2, 0.3 2, 0.3 2, 0.3 20 nextafter:2 2 2 21 nexttoward:2 2 2 22 scalbn:16 16 16 23 scalbln:16 16 16 1 sinh:1.1752 1.1752011936438 1.17520119364380146 0.634964+1.29846i 0.634963914784736+1.29845758141598i 0.634963914784736108+1.29845758141597729i 2 cosh:1.54308 1.54308063481524 1.54308063481524378 0.83373+0.988898i 0.833730025131149+0.988897705762865i 0.833730025131149049+0.988897705762865096i 3 tanh:0.761594 0.761594155955765 0.761594155955764888 1.08392+0.271753i 1.08392332733869+0.271752585319512i 1.08392332733869454+0.271752585319511717i 4 acosh:0 0 0 1.06128+0.904557i 1.06127506190504+0.904556894302381i 1.06127506190503565+0.904556894302381364i 5 asinh:0.881374 0.881373587019543 0.881373587019543025 1.06128+0.666239i 1.06127506190504+0.666239432492515i 1.06127506190503565+0.666239432492515255i 6 atanh:inf inf inf 0.402359+1.01722i 0.402359478108525+1.01722196789785i 0.402359478108525094+1.01722196789785137i 7 erf:0.842701 0.842700792949715 0.842700792949714869 8 erfc:0.157299 0.157299207050285 0.157299207050285131 9 lgamma:1.79176 1.79175946922805 1.791759469228055 10 lgamma:1.79176 1 1.79175946922805 1 1.791759469228055 1 11 tgamma:6 6 6 -
src/tests/math1.c
re982385 rb4f0dde 10 10 // Created On : Fri Apr 22 14:59:21 2016 11 11 // Last Modified By : Peter A. Buhr 12 // Last Modified On : Fri Aug 11 15:16:41 201713 // Update Count : 8 412 // Last Modified On : Thu May 24 21:01:15 2018 13 // Update Count : 85 14 14 // 15 15 … … 48 48 sout | "\\" | b | b \ e | endl; 49 49 sout | "\\" | 'a' \ 3u | 2 \ 8u | 4 \ 3u | -4 \ 3u | 4 \ -3 | -4 \ -3 | 4.0 \ 2.1 | (1.0f+2.0fi) \ (3.0f+2.0fi) | endl; 50 51 //---------------------- Logarithm ----------------------52 53 sout | "log:" | log( 1.0F ) | log( 1.0D ) | log( 1.0L ) | log( 1.0F+1.0FI ) | log( 1.0D+1.0DI ) | log( 1.0DL+1.0LI ) | endl;54 sout | "log2:" | log2( 8.0F ) | log2( 8.0D ) | log2( 8.0L ) | endl;55 sout | "log10:" | log10( 100.0F ) | log10( 100.0D ) | log10( 100.0L ) | endl;56 sout | "log1p:" | log1p( 1.0F ) | log1p( 1.0D ) | log1p( 1.0L ) | endl;57 sout | "ilogb:" | ilogb( 1.0F ) | ilogb( 1.0D ) | ilogb( 1.0L ) | endl;58 sout | "logb:" | logb( 8.0F ) | logb( 8.0D ) | logb( 8.0L ) | endl;59 60 sout | "sqrt:" | sqrt( 1.0F ) | sqrt( 1.0D ) | sqrt( 1.0L ) | sqrt( 1.0F+1.0FI ) | sqrt( 1.0D+1.0DI ) | sqrt( 1.0DL+1.0LI ) | endl;61 sout | "cbrt:" | cbrt( 27.0F ) | cbrt( 27.0D ) | cbrt( 27.0L ) | endl;62 sout | "hypot:" | hypot( 1.0F, -1.0F ) | hypot( 1.0D, -1.0D ) | hypot( 1.0L, -1.0L ) | endl;63 50 } // main 64 51 -
src/tests/math2.c
re982385 rb4f0dde 10 10 // Created On : Fri Apr 22 14:59:21 2016 11 11 // Last Modified By : Peter A. Buhr 12 // Last Modified On : Fri Aug 11 15:40:04 201713 // Update Count : 8 112 // Last Modified On : Thu May 24 21:06:10 2018 13 // Update Count : 82 14 14 // 15 15 … … 21 21 double d; 22 22 long double l; 23 24 //---------------------- Logarithm ---------------------- 25 26 sout | "log:" | log( 1.0F ) | log( 1.0D ) | log( 1.0L ) | log( 1.0F+1.0FI ) | log( 1.0D+1.0DI ) | log( 1.0DL+1.0LI ) | endl; 27 sout | "log2:" | log2( 8.0F ) | log2( 8.0D ) | log2( 8.0L ) | endl; 28 sout | "log10:" | log10( 100.0F ) | log10( 100.0D ) | log10( 100.0L ) | endl; 29 sout | "log1p:" | log1p( 1.0F ) | log1p( 1.0D ) | log1p( 1.0L ) | endl; 30 sout | "ilogb:" | ilogb( 1.0F ) | ilogb( 1.0D ) | ilogb( 1.0L ) | endl; 31 sout | "logb:" | logb( 8.0F ) | logb( 8.0D ) | logb( 8.0L ) | endl; 32 33 sout | "sqrt:" | sqrt( 1.0F ) | sqrt( 1.0D ) | sqrt( 1.0L ) | sqrt( 1.0F+1.0FI ) | sqrt( 1.0D+1.0DI ) | sqrt( 1.0DL+1.0LI ) | endl; 34 sout | "cbrt:" | cbrt( 27.0F ) | cbrt( 27.0D ) | cbrt( 27.0L ) | endl; 35 sout | "hypot:" | hypot( 1.0F, -1.0F ) | hypot( 1.0D, -1.0D ) | hypot( 1.0L, -1.0L ) | endl; 23 36 24 37 //---------------------- Trigonometric ---------------------- … … 32 45 sout | "atan2:" | atan2( 1.0F, 1.0F ) | atan2( 1.0D, 1.0D ) | atan2( 1.0L, 1.0L ); 33 46 sout | "atan:" | atan( 1.0F, 1.0F ) | atan( 1.0D, 1.0D ) | atan( 1.0L, 1.0L ) | endl; 34 35 //---------------------- Hyperbolic ----------------------36 37 sout | "sinh:" | sinh( 1.0F ) | sinh( 1.0D ) | sinh( 1.0L ) | sinh( 1.0F+1.0FI ) | sinh( 1.0D+1.0DI ) | sinh( 1.0DL+1.0LI ) | endl;38 sout | "cosh:" | cosh( 1.0F ) | cosh( 1.0D ) | cosh( 1.0L ) | cosh( 1.0F+1.0FI ) | cosh( 1.0D+1.0DI ) | cosh( 1.0DL+1.0LI ) | endl;39 sout | "tanh:" | tanh( 1.0F ) | tanh( 1.0D ) | tanh( 1.0L ) | tanh( 1.0F+1.0FI ) | tanh( 1.0D+1.0DI ) | tanh( 1.0DL+1.0LI ) | endl;40 sout | "acosh:" | acosh( 1.0F ) | acosh( 1.0D ) | acosh( 1.0L ) | acosh( 1.0F+1.0FI ) | acosh( 1.0D+1.0DI ) | acosh( 1.0DL+1.0LI ) | endl;41 sout | "asinh:" | asinh( 1.0F ) | asinh( 1.0D ) | asinh( 1.0L ) | asinh( 1.0F+1.0FI ) | asinh( 1.0D+1.0DI ) | asinh( 1.0DL+1.0LI ) | endl;42 sout | "atanh:" | atanh( 1.0F ) | atanh( 1.0D ) | atanh( 1.0L ) | atanh( 1.0F+1.0FI ) | atanh( 1.0D+1.0DI ) | atanh( 1.0DL+1.0LI ) | endl;43 44 //---------------------- Error / Gamma ----------------------45 46 sout | "erf:" | erf( 1.0F ) | erf( 1.0D ) | erf( 1.0L ) | endl;47 sout | "erfc:" | erfc( 1.0F ) | erfc( 1.0D ) | erfc( 1.0L ) | endl;48 sout | "lgamma:" | lgamma( 4.0F ) | lgamma( 4.0D ) | lgamma( 4.0L ) | endl;49 int sign;50 f = lgamma( 4.0F, &sign );51 sout | "lgamma:" | f | sign;52 d = lgamma( 4.0D, &sign );53 sout | d | sign;54 l = lgamma( 4.0L, &sign );55 sout | l | sign | endl;56 sout | "tgamma:" | tgamma( 4.0F ) | tgamma( 4.0D ) | tgamma( 4.0L ) | endl;57 47 } // main 58 48 -
src/tests/math3.c
re982385 rb4f0dde 10 10 // Created On : Fri Apr 22 14:59:21 2016 11 11 // Last Modified By : Peter A. Buhr 12 // Last Modified On : Fri Aug 11 15:40:03 201713 // Update Count : 8 112 // Last Modified On : Thu May 24 21:06:12 2018 13 // Update Count : 82 14 14 // 15 15 … … 22 22 long double l; 23 23 24 //---------------------- Nearest Integer----------------------24 //---------------------- Hyperbolic ---------------------- 25 25 26 sout | "floor:" | floor( 1.2F ) | floor( 1.2D ) | floor( 1.2L ) | endl; 27 sout | "ceil:" | ceil( 1.6F ) | ceil( 1.6D ) | ceil( 1.6L ) | endl; 28 sout | "trunc:" | trunc( 3.5F ) | trunc( 3.5D ) | trunc( 3.5L ) | endl; 29 sout | "rint:" | (float)rint( 1.5F ) | (double)rint( 1.5D ) | (long double)rint( 1.5L ) | endl; 30 sout | "rint:" | (long int)rint( 1.5F ) | (long int)rint( 1.5D ) | (long int)rint( 1.5L ) | endl; 31 sout | "rint:" | (long long int)rint( 1.5F ) | (long long int)rint( 1.5D ) | (long long int)rint( 1.5L ) | endl; 32 sout | "lrint:" | lrint( 1.5F ) | lrint( 1.5D ) | lrint( 1.5L ) | endl; 33 sout | "llrint:" | llrint( 1.5F ) | llrint( 1.5D ) | llrint( 1.5L ) | endl; 34 sout | "nearbyint:" | nearbyint( 3.5F ) | nearbyint( 3.5D ) | nearbyint( 3.5L ) | endl; 35 sout | "round:" | (float)round( 1.5F ) | (double)round( 1.5D ) | (long double)round( 1.5L ) | endl; 36 sout | "round:" | (long int)round( 1.5F ) | (long int)round( 1.5D ) | (long int)round( 1.5L ) | endl; 37 sout | "round:" | (long long int)round( 1.5F ) | (long long int)round( 1.5D ) | (long long int)round( 1.5L ) | endl; 38 sout | "lround:" | lround( 1.5F ) | lround( 1.5D ) | lround( 1.5L ) | endl; 39 sout | "llround:" | llround( 1.5F ) | llround( 1.5D ) | llround( 1.5L ) | endl; 26 sout | "sinh:" | sinh( 1.0F ) | sinh( 1.0D ) | sinh( 1.0L ) | sinh( 1.0F+1.0FI ) | sinh( 1.0D+1.0DI ) | sinh( 1.0DL+1.0LI ) | endl; 27 sout | "cosh:" | cosh( 1.0F ) | cosh( 1.0D ) | cosh( 1.0L ) | cosh( 1.0F+1.0FI ) | cosh( 1.0D+1.0DI ) | cosh( 1.0DL+1.0LI ) | endl; 28 sout | "tanh:" | tanh( 1.0F ) | tanh( 1.0D ) | tanh( 1.0L ) | tanh( 1.0F+1.0FI ) | tanh( 1.0D+1.0DI ) | tanh( 1.0DL+1.0LI ) | endl; 29 sout | "acosh:" | acosh( 1.0F ) | acosh( 1.0D ) | acosh( 1.0L ) | acosh( 1.0F+1.0FI ) | acosh( 1.0D+1.0DI ) | acosh( 1.0DL+1.0LI ) | endl; 30 sout | "asinh:" | asinh( 1.0F ) | asinh( 1.0D ) | asinh( 1.0L ) | asinh( 1.0F+1.0FI ) | asinh( 1.0D+1.0DI ) | asinh( 1.0DL+1.0LI ) | endl; 31 sout | "atanh:" | atanh( 1.0F ) | atanh( 1.0D ) | atanh( 1.0L ) | atanh( 1.0F+1.0FI ) | atanh( 1.0D+1.0DI ) | atanh( 1.0DL+1.0LI ) | endl; 40 32 41 //---------------------- Manipulation----------------------33 //---------------------- Error / Gamma ---------------------- 42 34 43 sout | "copysign:" | copysign( 1.0F, -1.0F ) | copysign( 1.0D, -1.0D ) | copysign( 1.0L, -1.0L ) | endl; 44 int exp; 45 f = frexp( 4.0F, &exp ); 46 sout | "frexp:" | f | exp; 47 d = frexp( 4.0D, &exp ); 48 sout | d | exp; 49 l = frexp( 4.0L, &exp ); 50 sout | l | exp | endl; 51 sout | "ldexp:" | ldexp( 2.0F, 2 ) | ldexp( 2.0D, 2 ) | ldexp( 2.0L, 2 ) | endl; 52 float fi; 53 double di; 54 long double ldi; 55 f = modf( 2.3F, &fi ); 56 sout | "modf:" | fi | f; 57 d = modf( 2.3D, &di ); 58 sout | di | d; 59 l = modf( 2.3L, &ldi ); 60 sout | ldi | l | endl; 61 sout | "modf:" | modf( 2.3F ) | modf( 2.3D ) | modf( 2.3L ) | endl; 62 sout | "nextafter:" | nextafter( 2.0F, 3.0F ) | nextafter( 2.0D, 3.0D ) | nextafter( 2.0L, 3.0L ) | endl; 63 sout | "nexttoward:" | nexttoward( 2.0F, 3.0F ) | nexttoward( 2.0D, 3.0D ) | nexttoward( 2.0L, 3.0L ) | endl; 64 65 sout | "scalbn:" | scalbn( 2.0F, 3 ) | scalbn( 2.0D, 3 ) | scalbn( 2.0L, 3 ) | endl; 66 sout | "scalbln:" | scalbln( 2.0F, 3L ) | scalbln( 2.0D, 3L ) | scalbln( 2.0L, 3L ) | endl; 35 sout | "erf:" | erf( 1.0F ) | erf( 1.0D ) | erf( 1.0L ) | endl; 36 sout | "erfc:" | erfc( 1.0F ) | erfc( 1.0D ) | erfc( 1.0L ) | endl; 37 sout | "lgamma:" | lgamma( 4.0F ) | lgamma( 4.0D ) | lgamma( 4.0L ) | endl; 38 int sign; 39 f = lgamma( 4.0F, &sign ); 40 sout | "lgamma:" | f | sign; 41 d = lgamma( 4.0D, &sign ); 42 sout | d | sign; 43 l = lgamma( 4.0L, &sign ); 44 sout | l | sign | endl; 45 sout | "tgamma:" | tgamma( 4.0F ) | tgamma( 4.0D ) | tgamma( 4.0L ) | endl; 67 46 } // main 68 47
Note: See TracChangeset
for help on using the changeset viewer.