(ParserUtils.StringPosition source)
| 85 | } |
| 86 | |
| 87 | public static String parseName(ParserUtils.StringPosition source) { |
| 88 | if (source.position == source.length) { |
| 89 | throw new IllegalArgumentException("Missing name at " + source); |
| 90 | } |
| 91 | final int start = source.position; |
| 92 | if (source.value.charAt(source.position) == '`') { |
| 93 | source.position += 1; |
| 94 | StringBuilder buffer = new StringBuilder(); |
| 95 | boolean closed = false; |
| 96 | while (source.position < source.length) { |
| 97 | char ch = source.value.charAt(source.position); |
| 98 | source.position += 1; |
| 99 | if (ch == '`') { |
| 100 | if (source.position < source.length && |
| 101 | source.value.charAt(source.position) == '`') { |
| 102 | source.position += 1; |
| 103 | buffer.append('`'); |
| 104 | } else { |
| 105 | closed = true; |
| 106 | break; |
| 107 | } |
| 108 | } else { |
| 109 | buffer.append(ch); |
| 110 | } |
| 111 | } |
| 112 | if (!closed) { |
| 113 | source.position = start; |
| 114 | throw new IllegalArgumentException("Unmatched quote at " + source); |
| 115 | } else if (buffer.length() == 0) { |
| 116 | throw new IllegalArgumentException("Empty quoted field name at " + source); |
| 117 | } |
| 118 | return buffer.toString(); |
| 119 | } else { |
| 120 | while (source.position < source.length) { |
| 121 | char ch = source.value.charAt(source.position); |
| 122 | if (!Character.isLetterOrDigit(ch) && ch != '_') { |
| 123 | break; |
| 124 | } |
| 125 | source.position += 1; |
| 126 | } |
| 127 | if (source.position == start) { |
| 128 | throw new IllegalArgumentException("Missing name at " + source); |
| 129 | } |
| 130 | return source.value.substring(start, source.position); |
| 131 | } |
| 132 | } |
| 133 | |
| 134 | static void requireChar(ParserUtils.StringPosition source, char required) { |
| 135 | if (source.position >= source.length || |
no test coverage detected