private static int parseIdentifier(CharSequence identifier, int offset) {
        if (identifier == null || identifier.length() <= offset) {
            return -1;
        }

        // Parse the required IdentifierStart production.
        char startingChar = identifier.charAt(offset);
        if (startingChar == '_') {
            while (offset < identifier.length() && identifier.charAt(offset) == '_') {
                offset++;
            }
            if (offset == identifier.length()) {
                return -1;
            }
            char current = identifier.charAt(offset);
            if (!ParserUtils.isAlphabetic(current) && !ParserUtils.isDigit(current)) {
                return -1;
            }
            offset++;
        } else if (!ParserUtils.isAlphabetic(startingChar)) {
            return -1;
        }

        // Parse the optional IdentifierChars production.
        while (offset < identifier.length()) {
            if (!ParserUtils.isValidIdentifierCharacter(identifier.charAt(offset))) {
                // Return the position of the character that stops the identifier.
                // This is either an invalid case (e.g., isValidIdentifier), or
                // just the marker needed for isValidNamespace to find '.'.
                return offset;
            }
            offset++;
        }

        return offset;
    }
Checks if the given string is a valid identifier.

@param identifier Identifier value to check.
@return Returns true if this is a valid identifier.
smithy-model/src/main/java/software/amazon/smithy/model/shapes/ShapeId.java