| 444 | | static char[char] escChars; |
|---|
| 445 | | static bool escCharsFilled; // will be initialised false |
|---|
| 446 | | |
|---|
| 447 | | if (!escCharsFilled) { |
|---|
| 448 | | // map of all supported escape sequences (cannot be static?) |
|---|
| 449 | | escChars = ['"' : '"', '\'' : '\'', |
|---|
| 450 | | '\\' : '\\', 'a' : '\a', |
|---|
| 451 | | 'b' : '\b', 'f' : '\f', |
|---|
| 452 | | 'n' : '\n', 'r' : '\r', |
|---|
| 453 | | 't' : '\t', 'v' : '\v']; |
|---|
| 454 | | escCharsFilled = true; |
|---|
| 455 | | } |
|---|
| 456 | | |
|---|
| 457 | | char* r = c in escChars; |
|---|
| 458 | | if (r != null) return *r; |
|---|
| 459 | | else throw new ParseException ("Invalid escape sequence: \\"~c); |
|---|
| | 444 | // This code was generated: |
|---|
| | 445 | if (c <= 'b') { |
|---|
| | 446 | if (c <= '\'') { |
|---|
| | 447 | if (c == '\"') { |
|---|
| | 448 | return '\"'; |
|---|
| | 449 | } else if (c == '\'') { |
|---|
| | 450 | return '\''; |
|---|
| | 451 | } |
|---|
| | 452 | } else { |
|---|
| | 453 | if (c == '\\') { |
|---|
| | 454 | return '\\'; |
|---|
| | 455 | } else if (c == 'a') { |
|---|
| | 456 | return '\a'; |
|---|
| | 457 | } else if (c == 'b') { |
|---|
| | 458 | return '\b'; |
|---|
| | 459 | } |
|---|
| | 460 | } |
|---|
| | 461 | } else { |
|---|
| | 462 | if (c <= 'n') { |
|---|
| | 463 | if (c == 'f') { |
|---|
| | 464 | return '\f'; |
|---|
| | 465 | } else if (c == 'n') { |
|---|
| | 466 | return '\n'; |
|---|
| | 467 | } |
|---|
| | 468 | } else { |
|---|
| | 469 | if (c == 'r') { |
|---|
| | 470 | return '\r'; |
|---|
| | 471 | } else if (c == 't') { |
|---|
| | 472 | return '\t'; |
|---|
| | 473 | } else if (c == 'v') { |
|---|
| | 474 | return '\v'; |
|---|
| | 475 | } |
|---|
| | 476 | } |
|---|
| | 477 | } |
|---|
| | 478 | |
|---|
| | 479 | // if we haven't returned: |
|---|
| | 480 | throw new ParseException ("Invalid escape sequence: \\"~c); |
|---|