1/* NOTE: 2 Do not include this file in your project. The fparser.cc file #includes 3this file internally and thus you don't need to do anything (other than keep 4this file in the same directory as fparser.cc). 5 6 Part of this file is generated code (by using the make_function_name_parser 7utility, found in the development version of this library). It's not intended 8to be modified by hand. 9*/ 10 11 unsigned nameLength = 0; 12 const unsigned maximumNameLength = 0x80000000U-8; 13 /* 14 Due to the manner the identifier lengths are returned from 15 the readOpcode() function, the maximum supported length for 16 identifiers is 0x7FFFFFFF bytes. We minus 8 here to add some 17 buffer, because of the multibyteness of UTF-8. 18 Function names are limited to 0xFFFF bytes instead, but because 19 function names that long just are not defined, the point is moot. 20 */ 21 const unsigned char* const uptr = (const unsigned char*) input; 22 typedef signed char schar; 23 while(likely(nameLength < maximumNameLength)) 24 { 25 unsigned char byte = uptr[nameLength+0]; 26 /* Handle the common case of A-Za-z first */ 27 if(byte >= 0x40) 28 { 29 if(byte < 0x80) // 0x40..0x7F - most common case 30 { 31 // Valid characters in 40..7F: A-Za-z_ 32 // Valid bitmask for 40..5F: 01111111111111111111111111100001 33 // Valid bitmask for 60..7F: 01111111111111111111111111100000 34 if(sizeof(unsigned long) == 8) 35 { 36 const unsigned n = sizeof(unsigned long)*8-32; 37 // ^ avoids compiler warning when not 64-bit 38 unsigned long masklow6bits = 1UL << (byte & 0x3F); 39 if(masklow6bits & ~((1UL << 0) | (0x0FUL << (0x1B )) 40 | (1UL << n) | (0x1FUL << (0x1B+n)))) 41 { ++nameLength; continue; } 42 } 43 else 44 { 45 unsigned masklow5bits = 1 << (byte & 0x1F); 46 if((masklow5bits & ~(1 | (0x1F << 0x1B))) || byte == '_') 47 { ++nameLength; continue; } 48 } 49 break; 50 } 51 if(byte < 0xF0) 52 { 53 if(byte < 0xE0) 54 { 55 if(byte < 0xC2) break; // 0x80..0xC1 56 if(byte == 0xC2 && uptr[nameLength+1]==0xA0) break; // skip nbsp 57 // C2-DF - next common case when >= 0x40 58 // Valid sequence: C2-DF 80-BF 59 if(schar(uptr[nameLength+1]) > schar(0xBF)) break; 60 nameLength += 2; 61 continue; 62 } 63 if(byte == 0xE0) // E0 64 { 65 // Valid sequence: E0 A0-BF 80-BF 66 if((unsigned char)(uptr[nameLength+1] - 0xA0) > (0xBF-0xA0)) break; 67 } 68 else 69 { 70 if(byte == 0xED) break; // ED is invalid 71 // Valid sequence: E1-EC 80-BF 80-BF 72 // And: EE-EF 80-BF 80-BF 73 if(byte == 0xE2) 74 { 75 // break on various space characters 76 if(uptr[nameLength+1] == 0x80 77 && (schar(uptr[nameLength+2]) <= schar(0x8B) 78 || (uptr[nameLength+2] == 0xAF))) break; 79 if(uptr[nameLength+1] == 0x81 80 && uptr[nameLength+2] == 0x9F) break; 81 } else 82 if(byte == 0xE3 && uptr[nameLength+1] == 0x80 83 && uptr[nameLength+2] == 0x80) break; // this too 84 85 if(schar(uptr[nameLength+1]) > schar(0xBF)) break; 86 } 87 if(schar(uptr[nameLength+2]) > schar(0xBF)) break; 88 nameLength += 3; 89 continue; 90 } 91 if(byte == 0xF0) // F0 92 { 93 // Valid sequence: F0 90-BF 80-BF 80-BF 94 if((unsigned char)(uptr[nameLength+1] - 0x90) > (0xBF-0x90)) break; 95 } 96 else 97 { 98 if(byte > 0xF4) break; // F5-FF are invalid 99 if(byte == 0xF4) // F4 100 { 101 // Valid sequence: F4 80-8F 102 if(schar(uptr[nameLength+1]) > schar(0x8F)) break; 103 } 104 else 105 { 106 // F1-F3 107 // Valid sequence: F1-F3 80-BF 80-BF 80-BF 108 if(schar(uptr[nameLength+1]) > schar(0xBF)) break; 109 } 110 } 111 if(schar(uptr[nameLength+2]) > schar(0xBF)) break; 112 if(schar(uptr[nameLength+3]) > schar(0xBF)) break; 113 nameLength += 4; 114 continue; 115 } 116 if(nameLength > 0) 117 { 118 if(sizeof(unsigned long) == 8) 119 { 120 // Valid bitmask for 00..1F: 00000000000000000000000000000000 121 // Valid bitmask for 20..3F: 00000000000000001111111111000000 122 const unsigned n = sizeof(unsigned long)*8-32; 123 // ^ avoids compiler warning when not 64-bit 124 unsigned long masklow6bits = 1UL << byte; 125 if(masklow6bits & (((1UL << 10)-1UL) << (16+n))) 126 { ++nameLength; continue; } 127 } 128 else 129 { 130 if(byte >= '0' && byte <= '9') 131 { ++nameLength; continue; } 132 } 133 } 134 break; 135 } 136 137 /* This function generated with make_function_name_parser.cc */ 138#define lO l3 lH 139#define lN switch( 140#define lM l4 lH 141#define lL if('i' l5 142#define lK 'n' l5 143#define lJ 0x80000003U; 144#define lI l1 3]={ 145#define lH case 146#define lG 0x80000005U; 147#define lF )==0)l0( 148#define lE l8 3;}lH 149#define lD std::memcmp(uptr+ 150#define lC l2 3 lF 151#define lB lA 1]){lH 152#define lA :lN uptr[ 153#define l9 'a' lB 154#define l8 default:l0 155#define l7 lG l0 5;}lH 156#define l6 <<16)| 157#define l5 ==uptr[ 158#define l4 lJ l0 3; 159#define l3 0x80000004U;l0 4; 160#define l2 lD 1,tmp, 161#define l1 static const char tmp[ 162#define l0 return 163lN 164nameLength){lH 1652:lL 1660]&&'f' l5 1671])l0(cIf 168l6 1690x80000002U;l0 1702;lH 1713 172lA 1730]){lH 174l9'b':if('s' l5 1752])l0(cAbs 176l6 177lM'r':if('g' l5 1782])l0(cArg 179l6 180l4 181lE'c' lB'o' lA 1822]){lH's':l0(cCos 183l6 184lJ 185lH't':l0(cCot 186l6 187lJ 188lE's':if('d' l5 1892])l0(cCsd 190l6 191l4 192lE'e':if('x' l5 1931]&&'p' l5 1942])l0(cExp 195l6 196lM'i':if(lK 1971]&&'t' l5 1982])l0(cInt 199l6 200lM'l':if('o' l5 2011]&&'g' l5 2022])l0(cLog 203l6 204lM'm' lB'a':if('x' l5 2052])l0(cMax 206l6 207lM'i':if(lK 2082])l0(cMin 209l6 210l4 211lE'p':if('s' l5 2121]&&'h' l5 2132])l0(cPsh 214l6 215lM's' lB'e':if('c' l5 2162])l0(cSec 217l6 218lM'i':if(lK 2192])l0(cSin 220l6 221l4 222lE't':if('a' l5 2231]&&lK 2242])l0(cTan 225l6 226l4 227lE 2284 229lA 2300]){lH 231l9'c':if('o' l5 2322]&&'s' l5 2333])l0(cAcos 234l6 235lO's':lL 2362]&&lK 2373])l0(cAsin 238l6 239lO't':if('a' l5 2402]&&lK 2413])l0(cAtan 242l6 243l3 244l8 2454;} 246lH'c' lB'b':if('r' l5 2472]&&'t' l5 2483])l0(cCbrt 249l6 250lO'e':lL 2512]&&'l' l5 2523])l0(cCeil 253l6 254lO'o' lA 2552]){lH'n':if('j' l5 2563])l0(cConj 257l6 258lO's':if('h' l5 2593])l0(cCosh 260l6 261l3 262l8 2634;} 264l8 2654;} 266lH'e':{lI'x','p','2'} 267;if(lC 268cExp2 269l6 270l3} 271lH'i':{lI'm','a','g'} 272;if(lC 273cImag 274l6 275l3} 276lH'l':{lI'o','g','2'} 277;if(lC 278cLog2 279l6 280l3} 281lH'r':{lI'e','a','l'} 282;if(lC 283cReal 284l6 285l3} 286lH's' lB'i':if(lK 2872]&&'h' l5 2883])l0(cSinh 289l6 290lO'q':if('r' l5 2912]&&'t' l5 2923])l0(cSqrt 293l6 294l3 295l8 2964;} 297lH't':{lI'a','n','h'} 298;if(lC 299cTanh 300l6 301l3} 302l8 3034;} 304lH 3055 306lA 3070]){lH 308l9'c':{lI'o','s','h'} 309;if(lD 3102,tmp,3 311lF 312cAcosh 313l6 314l7's':{lI'i','n','h'} 315;if(lD 3162,tmp,3 317lF 318cAsinh 319l6 320l7't':if('a' l5 3212]){if(lK 3223]){lN 323uptr[4]){lH'2':l0(cAtan2 324l6 325lG 326lH'h':l0(cAtanh 327l6 328lG 329l8 3305;} 331} 332l0 3335;} 334l0 3355;l8 3365;} 337lH'f':{l1 3384]={'l','o','o','r'} 339;if(l2 3404 341lF 342cFloor 343l6 344l7'h':{l1 3454]={'y','p','o','t'} 346;if(l2 3474 348lF 349cHypot 350l6 351l7'l':{l1 3524]={'o','g','1','0'} 353;if(l2 3544 355lF 356cLog10 357l6 358l7'p':{l1 3594]={'o','l','a','r'} 360;if(l2 3614 362lF 363cPolar 364l6 365l7't':{l1 3664]={'r','u','n','c'} 367;if(l2 3684 369lF 370cTrunc 371l6 372lG 373l0 3745;} 375l8 3765;} 377default:break;} 378l0 379nameLength; 380