private char skipSeparator()

in freemarker-docgen-core/src/main/java/org/freemarker/docgen/core/CJSONInterpreter.java [1326:1402]


    private char skipSeparator(
            char terminator, String commaBadReason, String colonBadReason)
            throws EvaluationException {
        int intialP = p;
        char c = skipWS();
        boolean plusConverted = false;
        if (c == '+') {
            // deprecated the old map-union syntax
            throw newSyntaxError(
                    "The + operator is not supported. (Hint: if you want to "
                    + "break a string into multiple lines, use a quoted string "
                    + "literal, finish the line with \\, then just continue "
                    + "the literal in the next line with optional "
                    + "indentation.");
        }
        if (c == ',' || c == ':') {
            if (commaBadReason != null && c == ',') {
                if (!plusConverted)  {
                    throw newSyntaxError(
                            "Comma (,) shouldn't be used here. "
                            + commaBadReason);
                } else {
                    throw newSyntaxError(
                            "Plus sign (+), which is treated as comma (,) "
                            + "in this case, shouldn't be used here. "
                            + commaBadReason);
                }
            }
            if (colonBadReason != null && c == ':') {
                throw newSyntaxError(
                        "Colon (:) shouldn't be used here. " + colonBadReason);
            }
            p++;
            skipWS();
            return c;
        } else if (c == terminator) {
            return terminator;
        } else if (c == ';') {
            throw newSyntaxError(
                    "Semicolon (;) was unexpected here. If you want to "
                    + "separate items in a listing then use comma "
                    + "(,) instead.");
        } else if (c == '=') {
            throw newSyntaxError(
                    "Equals sign (=) was unexpected here. If you want to "
                    + "associate a key with a value then use "
                    + "colon (:) instead.");
        } else {
            if (c == 0x20) {
                // EOS
                return c;
            }
            if (skipWSFoundNL) {
                // implicit comma
                if (commaBadReason != null) {
                    throw newSyntaxError(
                            "Line-break shouldn't be used before this iteam as "
                            + "separator (which is the same as using comma). "
                            + commaBadReason);
                }
                return ',';
            } else {
                if (p == intialP) {
                    throw newSyntaxError("Character "
                            + TextUtil.jQuoteOrName(tx.charAt(p))
                            + " shouldn't occur here.");
                } else {
                    // WS* separator
                    throw newSyntaxError("No separator was used before "
                            + "the item. Items in listings should be "
                            + "separated with comma (,) or line-break. Keys "
                            + "and values in maps should be separated with "
                            + "colon (:).");
                }
            }
        }
    }