identifierNeedsQuoting reports whether name must be backtick-quoted to be a valid bare identifier: it is empty, contains a character outside [letter,digit,_,$], starts with a digit, or is a reserved keyword.
(name string)
| 363 | // valid bare identifier: it is empty, contains a character outside |
| 364 | // [letter,digit,_,$], starts with a digit, or is a reserved keyword. |
| 365 | func identifierNeedsQuoting(name string) bool { |
| 366 | if name == "" { |
| 367 | return true |
| 368 | } |
| 369 | for _, r := range name { |
| 370 | if !unicode.IsLetter(r) && !unicode.IsDigit(r) && r != '_' && r != '$' { |
| 371 | return true |
| 372 | } |
| 373 | } |
| 374 | if unicode.IsDigit(rune(name[0])) { |
| 375 | return true |
| 376 | } |
| 377 | return isReservedKeyword(name) |
| 378 | } |
| 379 | |
| 380 | // isReservedKeyword reports whether a bare-shaped name is a reserved keyword |
| 381 | // that cannot be used as an unquoted identifier. omni exposes no reserved-word |
no test coverage detected