Reports whether the string is a valid identifier.
(String name)
| 73 | |
| 74 | /** Reports whether the string is a valid identifier. */ |
| 75 | public static boolean isValid(String name) { |
| 76 | // Keep consistent with Lexer.scanIdentifier. |
| 77 | for (int i = 0; i < name.length(); i++) { |
| 78 | char c = name.charAt(i); |
| 79 | if (!(('a' <= c && c <= 'z') |
| 80 | || ('A' <= c && c <= 'Z') |
| 81 | || (i > 0 && '0' <= c && c <= '9') |
| 82 | || (c == '_'))) { |
| 83 | return false; |
| 84 | } |
| 85 | } |
| 86 | return !name.isEmpty(); |
| 87 | } |
| 88 | |
| 89 | /** |
| 90 | * Returns all names bound by an LHS expression. |
no test coverage detected