- Timestamp:
- May 25, 2017, 11:10:42 AM (8 years ago)
- Branches:
- ADT, aaron-thesis, arm-eh, ast-experimental, cleanup-dtors, deferred_resn, demangler, enum, forall-pointer-decay, jacob/cs343-translation, jenkins-sandbox, master, new-ast, new-ast-unique-expr, new-env, no_list, persistent-indexer, pthread-emulation, qualifiedEnum, resolv-new, with_gc
- Children:
- e883a4b
- Parents:
- a8e64c4 (diff), 58ed882 (diff)
Note: this is a merge changeset, the changes displayed below correspond to the merge itself.
Use the(diff)
links above to see all the changes relative to each parent. - Location:
- src
- Files:
-
- 4 added
- 12 edited
Legend:
- Unmodified
- Added
- Removed
-
src/Parser/lex.ll
ra8e64c4 r0a208b8 10 10 * Created On : Sat Sep 22 08:58:10 2001 11 11 * Last Modified By : Peter A. Buhr 12 * Last Modified On : Thu May 18 09:03:49201713 * Update Count : 5 1312 * Last Modified On : Mon May 22 07:46:30 2017 13 * Update Count : 525 14 14 */ 15 15 … … 377 377 "?"{op_binary_over}"?" { IDENTIFIER_RETURN(); } // binary 378 378 /* 379 This rule handles ambiguous cases with operator identifiers, e.g., "int *?*?()", where the string "*?*?" 380 can be lexed as "*"/"?*?" or "*?"/"*?". Since it is common practise to put a unary operator juxtaposed381 to an identifier, e.g., "*i", users will be annoyed if they cannot do this with respect to operator382 identifiers. Even with this special hack, there are 5 general cases that cannot be handled. The first383 case is for the function-call identifier "?()":384 385 int * ?()(); // declaration: space required after '*' 386 * ?()(); // expression: space required after '*'387 388 Without the space, the string "*?()" is ambiguous without N character look ahead; it requires scanning389 ahead to determine if there is a '(', which is the start of an argument/parameter list.390 391 The 4 remaining cases occur in expressions: 392 393 i++?i:0; // space required before '?' 394 i --?i:0; // space required before '?'395 i?++ i:0; // space required after '?'396 i?--i:0; // space required after '?' 397 398 In the first two cases, the string "i++?" is ambiguous, where this string can be lexed as "i"/"++?" or 399 "i++"/"?"; it requires scanning ahead to determine if there is a '(', which is the start of an argument 400 list. In the second two cases, the string "?++x" is ambiguous, where this string can be lexed as 401 "?++"/"x" or "?"/"++x"; it requires scanning ahead to determine if there is a '(', which is the start of402 an argument list.379 This rule handles ambiguous cases with operator identifiers, e.g., "int *?*?()", where the string "*?*?" can be 380 lexed as "*?"/"*?" or "*"/"?*?". Since it is common practise to put a unary operator juxtaposed to an identifier, 381 e.g., "*i", users will be annoyed if they cannot do this with respect to operator identifiers. Therefore, there is 382 a lexical look-ahead for the second case, with backtracking to return the leading unary operator and then 383 reparsing the trailing operator identifier. Otherwise a space is needed between the unary operator and operator 384 identifier to disambiguate this common case. 385 386 A similar issue occurs with the dereference, *?(...), and routine-call, ?()(...) identifiers. The ambiguity 387 occurs when the deference operator has no parameters, *?() and *?()(...), requiring arbitrary whitespace 388 look-ahead for the routine-call parameter-list to disambiguate. However, the dereference operator must have a 389 parameter/argument to dereference *?(...). Hence, always interpreting the string *?() as * ?() does not preclude 390 any meaningful program. 391 392 The remaining cases are with the increment/decrement operators and conditional expression: 393 394 i++? ...(...); 395 i?++ ...(...); 396 397 requiring arbitrary whitespace look-ahead for the operator parameter-list, even though that interpretation is an 398 incorrect expression (juxtaposed identifiers). Therefore, it is necessary to disambiguate these cases with a 399 space: 400 401 i++ ? i : 0; 402 i? ++i : 0; 403 403 */ 404 {op_unary}"?"({op_unary_pre_post}|" [?]"|{op_binary_over}"?") {404 {op_unary}"?"({op_unary_pre_post}|"()"|"[?]"|{op_binary_over}"?") { 405 405 // 1 or 2 character unary operator ? 406 406 int i = yytext[1] == '?' ? 1 : 2; -
src/libcfa/math
ra8e64c4 r0a208b8 10 10 // Created On : Mon Apr 18 23:37:04 2016 11 11 // Last Modified By : Peter A. Buhr 12 // Last Modified On : Sun Apr 24 12:45:02 201613 // Update Count : 5912 // Last Modified On : Wed May 24 17:40:39 2017 13 // Update Count : 60 14 14 // 15 15 … … 20 20 #include <math.h> // fpclassify, isfinite, isnormal, isnan, isinf 21 21 } // extern "C" 22 23 float fabs( float );24 // extern "C" { double fabs( double ); }25 long double fabs( long double );26 float cabs( float _Complex );27 // extern "C" { double cabs( double _Complex ); }28 long double cabs( long double _Complex );29 22 30 23 float ?%?( float, float ); -
src/libcfa/math.c
ra8e64c4 r0a208b8 10 10 // Created On : Tue Apr 19 22:23:08 2016 11 11 // Last Modified By : Peter A. Buhr 12 // Last Modified On : Sun Apr 24 08:52:31 201613 // Update Count : 7 512 // Last Modified On : Tue May 23 22:52:13 2017 13 // Update Count : 76 14 14 // 15 15 … … 19 19 #include <complex.h> 20 20 } // extern "C" 21 22 float fabs( float x ) { return fabsf( x ); }23 long double fabs( long double x ) { return fabsl( x ); }24 float cabs( float _Complex x ) { return cabsf( x ); }25 long double cabs( long double _Complex x ) { return cabsl( x ); }26 21 27 22 float ?%?( float x, float y ) { return fmodf( x, y ); } -
src/libcfa/stdlib
ra8e64c4 r0a208b8 10 10 // Created On : Thu Jan 28 17:12:35 2016 11 11 // Last Modified By : Peter A. Buhr 12 // Last Modified On : Tue May 9 08:42:44201713 // Update Count : 1 0712 // Last Modified On : Wed May 24 18:06:27 2017 13 // Update Count : 115 14 14 // 15 15 … … 28 28 //--------------------------------------- 29 29 30 extern "C" { void * malloc( size_t ); } // use default C routine for void *31 30 forall( dtype T | sized(T) ) T * malloc( void ); 32 31 forall( dtype T | sized(T) ) T * malloc( char fill ); … … 42 41 forall( dtype T | sized(T) ) T * memalign( size_t alignment ); // deprecated 43 42 forall( dtype T | sized(T) ) int posix_memalign( T ** ptr, size_t alignment ); 44 45 extern "C" {46 void * memset( void * ptr, int fill, size_t size );47 void free( void * ptr );48 } // extern "C"49 43 50 44 forall( dtype T, ttype Params | sized(T) | { void ?{}(T *, Params); } ) T * new( Params p ); … … 109 103 double abs( double _Complex ); 110 104 long double abs( long double _Complex ); 111 forall 105 forall( otype T | { void ?{}( T *, zero_t ); int ?<?( T, T ); T -?( T ); } ) 112 106 T abs( T ); 113 107 … … 115 109 116 110 void rand48seed( long int s ); 117 char rand48( );118 int rand48( );119 unsigned int rand48( );120 long int rand48( );121 unsigned long int rand48( );122 float rand48( );123 double rand48( );124 float _Complex rand48( );125 double _Complex rand48( );126 long double _Complex rand48( );111 char rand48( void ); 112 int rand48( void ); 113 unsigned int rand48( void ); 114 long int rand48( void ); 115 unsigned long int rand48( void ); 116 float rand48( void ); 117 double rand48( void ); 118 float _Complex rand48( void ); 119 double _Complex rand48( void ); 120 long double _Complex rand48( void ); 127 121 128 122 //--------------------------------------- -
src/libcfa/stdlib.c
ra8e64c4 r0a208b8 10 10 // Created On : Thu Jan 28 17:10:29 2016 11 11 // Last Modified By : Peter A. Buhr 12 // Last Modified On : Tue May 9 08:43:00201713 // Update Count : 19 112 // Last Modified On : Wed May 24 18:13:15 2017 13 // Update Count : 198 14 14 // 15 15 … … 279 279 280 280 void rand48seed( long int s ) { srand48( s ); } 281 char rand48( ) { return mrand48(); }282 int rand48( ) { return mrand48(); }283 unsigned int rand48( ) { return lrand48(); }284 long int rand48( ) { return mrand48(); }285 unsigned long int rand48( ) { return lrand48(); }286 float rand48( ) { return (float)drand48(); }// otherwise float uses lrand48287 double rand48( ) { return drand48(); }288 float _Complex rand48( ) { return (float)drand48() + (float _Complex)(drand48() * _Complex_I); }289 double _Complex rand48( ) { return drand48() + (double _Complex)(drand48() * _Complex_I); }290 long double _Complex rand48( ) { return (long double)drand48() + (long double _Complex)(drand48() * _Complex_I); }281 char rand48( void ) { return mrand48(); } 282 int rand48( void ) { return mrand48(); } 283 unsigned int rand48( void ) { return lrand48(); } 284 long int rand48( void ) { return mrand48(); } 285 unsigned long int rand48( void ) { return lrand48(); } 286 float rand48( void ) { return (float)drand48(); } // otherwise float uses lrand48 287 double rand48( void ) { return drand48(); } 288 float _Complex rand48( void ) { return (float)drand48() + (float _Complex)(drand48() * _Complex_I); } 289 double _Complex rand48( void ) { return drand48() + (double _Complex)(drand48() * _Complex_I); } 290 long double _Complex rand48( void) { return (long double)drand48() + (long double _Complex)(drand48() * _Complex_I); } 291 291 292 292 //--------------------------------------- -
src/tests/.expect/64/math.txt
ra8e64c4 r0a208b8 1 fabs: 1 1 1 1.41421 1.41421356237309505 1.41421356237309505 2 fmod: 1 1 1 1 1 1 3 remainder: -1 -1 -1 4 remquo: 7 0.0999999 7 0.1 7 0.0999999999999999999 5 div: 7 0.0999999 7 0.1 7 0.0999999999999999999 6 fma: -2 -2 -2 7 fdim: 2 2 2 8 nan: nan nan nan 9 exp: 2.71828 2.71828182845905 2.71828182845904524 1.46869+2.28736i 1.46869393991589+2.28735528717884i 1.46869393991588516+2.28735528717884239i 10 exp2: 2 2 2 11 expm1: 1.71828 1.71828182845905 1.71828182845904524 12 log: 0 0 0 0.346574+0.785398i 0.346573590279973+0.785398163397448i 0.346573590279972655+0.78539816339744831i 13 log2: 3 3 3 14 log10: 2 2 2 15 log1p: 0.693147 0.693147180559945 0.693147180559945309 16 ilogb: 0 0 0 17 logb: 3 3 3 18 sqrt: 1 1 1 1.09868+0.45509i 1.09868411346781+0.455089860562227i 1.09868411346780997+0.455089860562227341i 19 cbrt: 3 3 3 20 hypot: 1.41421 1.4142135623731 1.41421356237309505 21 pow: 1 1 1 0.273957+0.583701i 0.273957253830121+0.583700758758615i 0.273957253830121071+0.583700758758614628i 22 sin: 0.841471 0.841470984807897 0.841470984807896507 1.29846+0.634964i 1.29845758141598+0.634963914784736i 1.29845758141597729+0.634963914784736108i 23 cos: 0.540302 0.54030230586814 0.540302305868139717 0.83373-0.988898i 0.833730025131149-0.988897705762865i 0.833730025131149049-0.988897705762865096i 24 tan: 1.55741 1.5574077246549 1.55740772465490223 0.271753+1.08392i 0.271752585319512+1.08392332733869i 0.271752585319511717+1.08392332733869454i 25 asin: 1.5708 1.5707963267949 1.57079632679489662 0.666239+1.06128i 0.666239432492515+1.06127506190504i 0.666239432492515255+1.06127506190503565i 26 acos: 0 0 0 0.904557-1.06128i 0.904556894302381-1.06127506190504i 0.904556894302381364-1.06127506190503565i 27 atan: 0.785398 0.785398163397448 0.78539816339744831 1.01722+0.402359i 1.01722196789785+0.402359478108525i 1.01722196789785137+0.402359478108525094i 28 atan2: 0.785398 0.785398163397448 0.78539816339744831 atan: 0.785398 0.785398163397448 0.78539816339744831 sinh: 1.1752 1.1752011936438 1.17520119364380146 0.634964+1.29846i 0.634963914784736+1.29845758141598i 0.634963914784736108+1.29845758141597729i 29 cosh: 1.54308 1.54308063481524 1.54308063481524378 0.83373+0.988898i 0.833730025131149+0.988897705762865i 0.833730025131149049+0.988897705762865096i 30 tanh: 0.761594 0.761594155955765 0.761594155955764888 1.08392+0.271753i 1.08392332733869+0.271752585319512i 1.08392332733869454+0.271752585319511717i 31 acosh: 0 0 0 1.06128+0.904557i 1.06127506190504+0.904556894302381i 1.06127506190503565+0.904556894302381364i 32 asinh: 0.881374 0.881373587019543 0.881373587019543025 1.06128+0.666239i 1.06127506190504+0.666239432492515i 1.06127506190503565+0.666239432492515255i 33 atanh: inf inf inf 0.402359+1.01722i 0.402359478108525+1.01722196789785i 0.402359478108525094+1.01722196789785137i 34 erf: 0.842701 0.842700792949715 0.842700792949714869 35 erfc: 0.157299 0.157299207050285 0.157299207050285131 36 lgamma: 1.79176 1.79175946922805 1.791759469228055 37 lgamma: 1.79176 1 1.79175946922805 1 1.791759469228055 1 38 tgamma: 6 6 6 39 floor: 1 1 1 40 ceil: 2 2 2 41 trunc: 3 3 3 42 rint: 2 2 2 43 rint: 2 2 2 44 rint: 2 2 2 45 lrint: 2 2 2 46 llrint: 2 2 2 47 nearbyint: 4 4 4 48 round: 2 2 2 49 round: 2 2 2 50 round: 2 2 2 51 lround: 2 2 2 52 llround: 2 2 2 53 copysign: -1 -1 -1 54 frexp: 0.5 3 0.5 3 0.5 3 55 ldexp: 8 8 8 56 modf: 2 0.3 2 0.3 2 0.3 nextafter: 2 2 2 57 nexttoward: 2 2 2 58 scalbn: 16 16 16 59 scalbln: 16 16 16 1 fmod:1 1 1 1 1 1 2 remainder:-1 -1 -1 3 remquo:7 0.0999999 7 0.1 7 0.0999999999999999999 4 div:7 0.0999999 7 0.1 7 0.0999999999999999999 5 fma:-2 -2 -2 6 fdim:2 2 2 7 nan:nan nan nan 8 exp:2.71828 2.71828182845905 2.71828182845904524 1.46869+2.28736i 1.46869393991589+2.28735528717884i 1.46869393991588516+2.28735528717884239i 9 exp2:2 2 2 10 expm1:1.71828 1.71828182845905 1.71828182845904524 11 log:0 0 0 0.346574+0.785398i 0.346573590279973+0.785398163397448i 0.346573590279972655+0.78539816339744831i 12 log2:3 3 3 13 log10:2 2 2 14 log1p:0.693147 0.693147180559945 0.693147180559945309 15 ilogb:0 0 0 16 logb:3 3 3 17 sqrt:1 1 1 1.09868+0.45509i 1.09868411346781+0.455089860562227i 1.09868411346780997+0.455089860562227341i 18 cbrt:3 3 3 19 hypot:1.41421 1.4142135623731 1.41421356237309505 20 pow:1 1 1 0.273957+0.583701i 0.273957253830121+0.583700758758615i 0.273957253830121071+0.583700758758614628i 21 sin:0.841471 0.841470984807897 0.841470984807896507 1.29846+0.634964i 1.29845758141598+0.634963914784736i 1.29845758141597729+0.634963914784736108i 22 cos:0.540302 0.54030230586814 0.540302305868139717 0.83373-0.988898i 0.833730025131149-0.988897705762865i 0.833730025131149049-0.988897705762865096i 23 tan:1.55741 1.5574077246549 1.55740772465490223 0.271753+1.08392i 0.271752585319512+1.08392332733869i 0.271752585319511717+1.08392332733869454i 24 asin:1.5708 1.5707963267949 1.57079632679489662 0.666239+1.06128i 0.666239432492515+1.06127506190504i 0.666239432492515255+1.06127506190503565i 25 acos:0 0 0 0.904557-1.06128i 0.904556894302381-1.06127506190504i 0.904556894302381364-1.06127506190503565i 26 atan:0.785398 0.785398163397448 0.78539816339744831 1.01722+0.402359i 1.01722196789785+0.402359478108525i 1.01722196789785137+0.402359478108525094i 27 atan2:0.785398 0.785398163397448 0.78539816339744831 atan:0.785398 0.785398163397448 0.78539816339744831 sinh:1.1752 1.1752011936438 1.17520119364380146 0.634964+1.29846i 0.634963914784736+1.29845758141598i 0.634963914784736108+1.29845758141597729i 28 cosh:1.54308 1.54308063481524 1.54308063481524378 0.83373+0.988898i 0.833730025131149+0.988897705762865i 0.833730025131149049+0.988897705762865096i 29 tanh:0.761594 0.761594155955765 0.761594155955764888 1.08392+0.271753i 1.08392332733869+0.271752585319512i 1.08392332733869454+0.271752585319511717i 30 acosh:0 0 0 1.06128+0.904557i 1.06127506190504+0.904556894302381i 1.06127506190503565+0.904556894302381364i 31 asinh:0.881374 0.881373587019543 0.881373587019543025 1.06128+0.666239i 1.06127506190504+0.666239432492515i 1.06127506190503565+0.666239432492515255i 32 atanh:inf inf inf 0.402359+1.01722i 0.402359478108525+1.01722196789785i 0.402359478108525094+1.01722196789785137i 33 erf:0.842701 0.842700792949715 0.842700792949714869 34 erfc:0.157299 0.157299207050285 0.157299207050285131 35 lgamma:1.79176 1.79175946922805 1.791759469228055 36 lgamma:1.79176 1 1.79175946922805 1 1.791759469228055 1 37 tgamma:6 6 6 38 floor:1 1 1 39 ceil:2 2 2 40 trunc:3 3 3 41 rint:2 2 2 42 rint:2 2 2 43 rint:2 2 2 44 lrint:2 2 2 45 llrint:2 2 2 46 nearbyint:4 4 4 47 round:2 2 2 48 round:2 2 2 49 round:2 2 2 50 lround:2 2 2 51 llround:2 2 2 52 copysign:-1 -1 -1 53 frexp:0.5 3 0.5 3 0.5 3 54 ldexp:8 8 8 55 modf:2 0.3 2 0.3 2 0.3 nextafter:2 2 2 56 nexttoward:2 2 2 57 scalbn:16 16 16 58 scalbln:16 16 16 -
src/tests/KRfunctions.c
ra8e64c4 r0a208b8 1 // -*- Mode: C -*-2 1 // 3 2 // Cforall Version 1.0.0 Copyright (C) 2017 University of Waterloo … … 11 10 // Created On : Thu Feb 16 15:23:17 2017 12 11 // Last Modified By : Peter A. Buhr 13 // Last Modified On : Thu Feb 16 15:25:52201714 // Update Count : 212 // Last Modified On : Wed May 24 22:05:00 2017 13 // Update Count : 3 15 14 // 16 15 -
src/tests/complex.c
ra8e64c4 r0a208b8 1 // 2 // Cforall Version 1.0.0 Copyright (C) 2017 University of Waterloo 3 // 4 // The contents of this file are covered under the licence agreement in the 5 // file "LICENCE" distributed with Cforall. 6 // 7 // complex.c -- 8 // 9 // Author : Peter A. Buhr 10 // Created On : Wed May 24 22:07:31 2017 11 // Last Modified By : Peter A. Buhr 12 // Last Modified On : Wed May 24 22:08:01 2017 13 // Update Count : 1 14 // 15 1 16 #include <stdio.h> 2 17 #include <complex.h> … … 20 35 #endif // __CFA 21 36 } 37 38 // Local Variables: // 39 // tab-width: 4 // 40 // compile-command: "cfa complex.c" // 41 // End: // -
src/tests/gmp.c
ra8e64c4 r0a208b8 10 10 // Created On : Tue Apr 19 08:55:51 2016 11 11 // Last Modified By : Peter A. Buhr 12 // Last Modified On : Mon May 22 09:05:09201713 // Update Count : 5 3812 // Last Modified On : Wed May 24 22:05:38 2017 13 // Update Count : 540 14 14 // 15 15 … … 88 88 sout | (int)0 | fact | endl; 89 89 for ( unsigned int i = 1; i <= 40; i += 1 ) { 90 fact = fact * i;// general case90 fact *= i; // general case 91 91 sout | i | fact | endl; 92 92 } // for … … 94 94 95 95 // Local Variables: // 96 // mode: c //97 96 // tab-width: 4 // 97 // compile-command: "cfa gmp.c -l gmp" // 98 98 // End: // -
src/tests/math.c
ra8e64c4 r0a208b8 10 10 // Created On : Fri Apr 22 14:59:21 2016 11 11 // Last Modified By : Peter A. Buhr 12 // Last Modified On : Sun Apr 24 13:24:20 201613 // Update Count : 7 012 // Last Modified On : Wed May 24 13:04:33 2017 13 // Update Count : 71 14 14 // 15 15 … … 22 22 long double l; 23 23 24 sout | "fabs:" | fabs( -1.0F ) | fabs( -1.0D ) | fabs( -1.0L ) | cabs( -1.0F+1.0FI ) | cabs( -1.0D+1.0DI ) | cabs( -1.0DL+1.0LI ) | endl;25 24 sout | "fmod:" | 5.0F % -2.0F | fmod( 5.0F, -2.0F ) | 5.0D % -2.0D | fmod( 5.0D, -2.0D ) | 5.0L % -2.0L | fmod( 5.0L, -2.0L ) | endl; 26 25 sout | "remainder:" | remainder( 2.0F, 3.0F ) | remainder( 2.0D, 3.0D ) | remainder( 2.0L, 3.0L ) | endl; -
src/tests/numericConstants.c
ra8e64c4 r0a208b8 1 // 2 // Cforall Version 1.0.0 Copyright (C) 2015 University of Waterloo 3 // 4 // The contents of this file are covered under the licence agreement in the 5 // file "LICENCE" distributed with Cforall. 6 // 7 // numericConstants.c -- 8 // 9 // Author : Peter A. Buhr 10 // Created On : Wed May 24 22:10:36 2017 11 // Last Modified By : Peter A. Buhr 12 // Last Modified On : Wed May 24 22:11:36 2017 13 // Update Count : 2 14 // 15 1 16 int main() { 2 17 1; // decimal … … 48 63 0x_ff.ffp0; // hex real 49 64 0x_1.ffff_ffff_p_128_l; 50 } 65 } // main 66 67 // Local Variables: // 68 // tab-width: 4 // 69 // compile-command: "cfa minmax.c" // 70 // End: // -
src/tests/rational.c
ra8e64c4 r0a208b8 10 10 // Created On : Mon Mar 28 08:43:12 2016 11 11 // Last Modified By : Peter A. Buhr 12 // Last Modified On : Mon May 15 21:32:22201713 // Update Count : 6 412 // Last Modified On : Wed May 17 15:46:35 2017 13 // Update Count : 65 14 14 // 15 15
Note:
See TracChangeset
for help on using the changeset viewer.