org.yaml.snakeyaml.error.Mark Java Examples

The following examples show how to use org.yaml.snakeyaml.error.Mark. You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example #1
Source File: ScannerImpl.java    From snake-yaml with Apache License 2.0 6 votes vote down vote up
/**
 * Scan a flow-style scalar. Flow scalars are presented in one of two forms;
 * first, a flow scalar may be a double-quoted string; second, a flow scalar
 * may be a single-quoted string.
 * 
 * @see <a href="http://www.yaml.org/spec/1.1/#flow"></a> style/syntax
 * 
 *      <pre>
 * See the specification for details.
 * Note that we loose indentation rules for quoted scalars. Quoted
 * scalars don't need to adhere indentation because &quot; and ' clearly
 * mark the beginning and the end of them. Therefore we are less
 * restrictive then the specification requires. We only need to check
 * that document separators are not included in scalars.
 * </pre>
 */
private Token scanFlowScalar(char style) {
    boolean _double;
    // The style will be either single- or double-quoted; we determine this
    // by the first character in the entry (supplied)
    if (style == '"') {
        _double = true;
    } else {
        _double = false;
    }
    StringBuilder chunks = new StringBuilder();
    Mark startMark = reader.getMark();
    char quote = reader.peek();
    reader.forward();
    chunks.append(scanFlowScalarNonSpaces(_double, startMark));
    while (reader.peek() != quote) {
        chunks.append(scanFlowScalarSpaces(startMark));
        chunks.append(scanFlowScalarNonSpaces(_double, startMark));
    }
    reader.forward();
    Mark endMark = reader.getMark();
    return new ScalarToken(chunks.toString(), false, startMark, endMark, style);
}
 
Example #2
Source File: ScannerImpl.java    From orion.server with Eclipse Public License 1.0 6 votes vote down vote up
private String scanDirectiveIgnoredLine(Mark startMark) {
    // See the specification for details.
    int ff = 0;
    while (reader.peek(ff) == ' ') {
        ff++;
    }
    if (ff > 0) {
        reader.forward(ff);
    }
    if (reader.peek() == '#') {
        ff = 0;
        while (Constant.NULL_OR_LINEBR.hasNo(reader.peek(ff))) {
            ff++;
        }
        reader.forward(ff);
    }
    char ch = reader.peek();
    String lineBreak = scanLineBreak();
    if (lineBreak.length() == 0 && ch != '\0') {
        throw new ScannerException("while scanning a directive", startMark,
                "expected a comment or a line break, but found " + ch + "(" + ((int) ch) + ")",
                reader.getMark());
    }
    return lineBreak;
}
 
Example #3
Source File: ScannerImpl.java    From snake-yaml with Apache License 2.0 6 votes vote down vote up
/**
 * Fetch a flow-style collection end, which is either a sequence or a
 * mapping. The type is determined by the given boolean.
 * 
 * A flow-style collection is in a format similar to JSON. Sequences are
 * started by '[' and ended by ']'; mappings are started by '{' and ended by
 * '}'.
 * 
 * @see <a href="http://www.yaml.org/spec/1.1/#id863975"></a>
 */
private void fetchFlowCollectionEnd(boolean isMappingEnd) {
    // Reset possible simple key on the current level.
    removePossibleSimpleKey();

    // Decrease the flow level.
    this.flowLevel--;

    // No simple keys after ']' or '}'.
    this.allowSimpleKey = false;

    // Add FLOW-SEQUENCE-END or FLOW-MAPPING-END.
    Mark startMark = reader.getMark();
    reader.forward();
    Mark endMark = reader.getMark();
    Token token;
    if (isMappingEnd) {
        token = new FlowMappingEndToken(startMark, endMark);
    } else {
        token = new FlowSequenceEndToken(startMark, endMark);
    }
    this.tokens.add(token);
}
 
Example #4
Source File: ParserImpl.java    From snake-yaml with Apache License 2.0 6 votes vote down vote up
public Event produce() {
    // Parse the document end.
    Token token = scanner.peekToken();
    Mark startMark = token.getStartMark();
    Mark endMark = startMark;
    boolean explicit = false;
    if (scanner.checkToken(Token.ID.DocumentEnd)) {
        token = scanner.getToken();
        endMark = token.getEndMark();
        explicit = true;
    }
    Event event = new DocumentEndEvent(startMark, endMark, explicit);
    // Prepare the next state.
    state = new ParseDocumentStart();
    return event;
}
 
Example #5
Source File: ScannerImpl.java    From orion.server with Eclipse Public License 1.0 6 votes vote down vote up
/**
 * Scan a flow-style scalar. Flow scalars are presented in one of two forms;
 * first, a flow scalar may be a double-quoted string; second, a flow scalar
 * may be a single-quoted string.
 * 
 * @see http://www.yaml.org/spec/1.1/#flow style/syntax
 * 
 *      <pre>
 * See the specification for details.
 * Note that we loose indentation rules for quoted scalars. Quoted
 * scalars don't need to adhere indentation because &quot; and ' clearly
 * mark the beginning and the end of them. Therefore we are less
 * restrictive then the specification requires. We only need to check
 * that document separators are not included in scalars.
 * </pre>
 */
private Token scanFlowScalar(char style) {
    boolean _double;
    // The style will be either single- or double-quoted; we determine this
    // by the first character in the entry (supplied)
    if (style == '"') {
        _double = true;
    } else {
        _double = false;
    }
    StringBuilder chunks = new StringBuilder();
    Mark startMark = reader.getMark();
    char quote = reader.peek();
    reader.forward();
    chunks.append(scanFlowScalarNonSpaces(_double, startMark));
    while (reader.peek() != quote) {
        chunks.append(scanFlowScalarSpaces(startMark));
        chunks.append(scanFlowScalarNonSpaces(_double, startMark));
    }
    reader.forward();
    Mark endMark = reader.getMark();
    return new ScalarToken(chunks.toString(), false, startMark, endMark, style);
}
 
Example #6
Source File: ScannerImpl.java    From orion.server with Eclipse Public License 1.0 6 votes vote down vote up
/**
 * Fetch a flow-style collection end, which is either a sequence or a
 * mapping. The type is determined by the given boolean.
 * 
 * A flow-style collection is in a format similar to JSON. Sequences are
 * started by '[' and ended by ']'; mappings are started by '{' and ended by
 * '}'.
 * 
 * @see http://www.yaml.org/spec/1.1/#id863975
 */
private void fetchFlowCollectionEnd(boolean isMappingEnd) {
    // Reset possible simple key on the current level.
    removePossibleSimpleKey();

    // Decrease the flow level.
    this.flowLevel--;

    // No simple keys after ']' or '}'.
    this.allowSimpleKey = false;

    // Add FLOW-SEQUENCE-END or FLOW-MAPPING-END.
    Mark startMark = reader.getMark();
    reader.forward();
    Mark endMark = reader.getMark();
    Token token;
    if (isMappingEnd) {
        token = new FlowMappingEndToken(startMark, endMark);
    } else {
        token = new FlowSequenceEndToken(startMark, endMark);
    }
    this.tokens.add(token);
}
 
Example #7
Source File: ScannerImpl.java    From orion.server with Eclipse Public License 1.0 6 votes vote down vote up
/**
 * <p>
 * Read a %TAG directive value:
 * 
 * <pre>
 * s-ignored-space+ c-tag-handle s-ignored-space+ ns-tag-prefix s-l-comments
 * </pre>
 * 
 * </p>
 * 
 * @see http://www.yaml.org/spec/1.1/#id896044
 */
private List<String> scanTagDirectiveValue(Mark startMark) {
    // See the specification for details.
    while (reader.peek() == ' ') {
        reader.forward();
    }
    String handle = scanTagDirectiveHandle(startMark);
    while (reader.peek() == ' ') {
        reader.forward();
    }
    String prefix = scanTagDirectivePrefix(startMark);
    List<String> result = new ArrayList<String>(2);
    result.add(handle);
    result.add(prefix);
    return result;
}
 
Example #8
Source File: ScannerImpl.java    From orion.server with Eclipse Public License 1.0 6 votes vote down vote up
/**
 * Fetch a flow-style collection start, which is either a sequence or a
 * mapping. The type is determined by the given boolean.
 * 
 * A flow-style collection is in a format similar to JSON. Sequences are
 * started by '[' and ended by ']'; mappings are started by '{' and ended by
 * '}'.
 * 
 * @see http://www.yaml.org/spec/1.1/#id863975
 * 
 * @param isMappingStart
 */
private void fetchFlowCollectionStart(boolean isMappingStart) {
    // '[' and '{' may start a simple key.
    savePossibleSimpleKey();

    // Increase the flow level.
    this.flowLevel++;

    // Simple keys are allowed after '[' and '{'.
    this.allowSimpleKey = true;

    // Add FLOW-SEQUENCE-START or FLOW-MAPPING-START.
    Mark startMark = reader.getMark();
    reader.forward(1);
    Mark endMark = reader.getMark();
    Token token;
    if (isMappingStart) {
        token = new FlowMappingStartToken(startMark, endMark);
    } else {
        token = new FlowSequenceStartToken(startMark, endMark);
    }
    this.tokens.add(token);
}
 
Example #9
Source File: ScannerImpl.java    From orion.server with Eclipse Public License 1.0 6 votes vote down vote up
private void fetchStreamEnd() {
    // Set the current intendation to -1.
    unwindIndent(-1);

    // Reset simple keys.
    removePossibleSimpleKey();
    this.allowSimpleKey = false;
    this.possibleSimpleKeys.clear();

    // Read the token.
    Mark mark = reader.getMark();

    // Add STREAM-END.
    Token token = new StreamEndToken(mark, mark);
    this.tokens.add(token);

    // The stream is finished.
    this.done = true;
}
 
Example #10
Source File: ScannerImpl.java    From orion.server with Eclipse Public License 1.0 6 votes vote down vote up
/**
 * Fetch a document indicator, either "---" for "document-start", or else
 * "..." for "document-end. The type is chosen by the given boolean.
 */
private void fetchDocumentIndicator(boolean isDocumentStart) {
    // Set the current intendation to -1.
    unwindIndent(-1);

    // Reset simple keys. Note that there could not be a block collection
    // after '---'.
    removePossibleSimpleKey();
    this.allowSimpleKey = false;

    // Add DOCUMENT-START or DOCUMENT-END.
    Mark startMark = reader.getMark();
    reader.forward(3);
    Mark endMark = reader.getMark();
    Token token;
    if (isDocumentStart) {
        token = new DocumentStartToken(startMark, endMark);
    } else {
        token = new DocumentEndToken(startMark, endMark);
    }
    this.tokens.add(token);
}
 
Example #11
Source File: ScannerImpl.java    From snake-yaml with Apache License 2.0 6 votes vote down vote up
/**
 * Fetch a document indicator, either "---" for "document-start", or else
 * "..." for "document-end. The type is chosen by the given boolean.
 */
private void fetchDocumentIndicator(boolean isDocumentStart) {
    // Set the current intendation to -1.
    unwindIndent(-1);

    // Reset simple keys. Note that there could not be a block collection
    // after '---'.
    removePossibleSimpleKey();
    this.allowSimpleKey = false;

    // Add DOCUMENT-START or DOCUMENT-END.
    Mark startMark = reader.getMark();
    reader.forward(3);
    Mark endMark = reader.getMark();
    Token token;
    if (isDocumentStart) {
        token = new DocumentStartToken(startMark, endMark);
    } else {
        token = new DocumentEndToken(startMark, endMark);
    }
    this.tokens.add(token);
}
 
Example #12
Source File: ScannerImpl.java    From snake-yaml with Apache License 2.0 6 votes vote down vote up
/**
 * Fetch a flow-style collection start, which is either a sequence or a
 * mapping. The type is determined by the given boolean.
 * 
 * A flow-style collection is in a format similar to JSON. Sequences are
 * started by '[' and ended by ']'; mappings are started by '{' and ended by
 * '}'.
 * 
 * @see <a href="http://www.yaml.org/spec/1.1/#id863975"></a>
 * 
 * @param isMappingStart
 */
private void fetchFlowCollectionStart(boolean isMappingStart) {
    // '[' and '{' may start a simple key.
    savePossibleSimpleKey();

    // Increase the flow level.
    this.flowLevel++;

    // Simple keys are allowed after '[' and '{'.
    this.allowSimpleKey = true;

    // Add FLOW-SEQUENCE-START or FLOW-MAPPING-START.
    Mark startMark = reader.getMark();
    reader.forward(1);
    Mark endMark = reader.getMark();
    Token token;
    if (isMappingStart) {
        token = new FlowMappingStartToken(startMark, endMark);
    } else {
        token = new FlowSequenceStartToken(startMark, endMark);
    }
    this.tokens.add(token);
}
 
Example #13
Source File: ScannerImpl.java    From orion.server with Eclipse Public License 1.0 5 votes vote down vote up
/**
 * Scan a %TAG directive's handle. This is YAML's c-tag-handle.
 * 
 * @see http://www.yaml.org/spec/1.1/#id896876
 * @param startMark
 * @return
 */
private String scanTagDirectiveHandle(Mark startMark) {
    // See the specification for details.
    String value = scanTagHandle("directive", startMark);
    char ch = reader.peek();
    if (ch != ' ') {
        throw new ScannerException("while scanning a directive", startMark,
                "expected ' ', but found " + reader.peek() + "(" + ch + ")", reader.getMark());
    }
    return value;
}
 
Example #14
Source File: PyMarkTest.java    From snake-yaml with Apache License 2.0 5 votes vote down vote up
public void testMarks() {
    String content = getResource("test_mark.marks");
    String[] inputs = content.split("---\n");
    for (int i = 1; i < inputs.length; i++) {
        String input = inputs[i];
        int index = 0;
        int line = 0;
        int column = 0;
        while (input.charAt(index) != '*') {
            if (input.charAt(index) != '\n') {
                line += 1;
                column = 0;
            } else {
                column += 1;
            }
            index += 1;
        }
        Mark mark = new Mark("testMarks", index, line, column, input, index);
        String snippet = mark.get_snippet(2, 79);
        assertTrue("Must only have one '\n'.", snippet.indexOf("\n") > -1);
        assertEquals("Must only have only one '\n'.", snippet.indexOf("\n"),
                snippet.lastIndexOf("\n"));
        String[] lines = snippet.split("\n");
        String data = lines[0];
        String pointer = lines[1];
        assertTrue("Mark must be restricted: " + data, data.length() < 82);
        int dataPosition = data.indexOf("*");
        int pointerPosition = pointer.indexOf("^");
        assertEquals("Pointer should coincide with '*':\n " + snippet, dataPosition,
                pointerPosition);
    }
}
 
Example #15
Source File: ScannerImpl.java    From orion.server with Eclipse Public License 1.0 5 votes vote down vote up
/**
 * <p>
 * Scan a Tag handle. A Tag handle takes one of three forms:
 * 
 * <pre>
 * "!" (c-primary-tag-handle)
 * "!!" (ns-secondary-tag-handle)
 * "!(name)!" (c-named-tag-handle)
 * </pre>
 * 
 * Where (name) must be formatted as an ns-word-char.
 * </p>
 * 
 * @see http://www.yaml.org/spec/1.1/#c-tag-handle
 * @see http://www.yaml.org/spec/1.1/#ns-word-char
 * 
 *      <pre>
 * See the specification for details.
 * For some strange reasons, the specification does not allow '_' in
 * tag handles. I have allowed it anyway.
 * </pre>
 */
private String scanTagHandle(String name, Mark startMark) {
    char ch = reader.peek();
    if (ch != '!') {
        throw new ScannerException("while scanning a " + name, startMark,
                "expected '!', but found " + ch + "(" + ((int) ch) + ")", reader.getMark());
    }
    // Look for the next '!' in the stream, stopping if we hit a
    // non-word-character. If the first character is a space, then the
    // tag-handle is a c-primary-tag-handle ('!').
    int length = 1;
    ch = reader.peek(length);
    if (ch != ' ') {
        // Scan through 0+ alphabetic characters.
        // FIXME According to the specification, these should be
        // ns-word-char only, which prohibits '_'. This might be a
        // candidate for a configuration option.
        while (Constant.ALPHA.has(ch)) {
            length++;
            ch = reader.peek(length);
        }
        // Found the next non-word-char. If this is not a space and not an
        // '!', then this is an error, as the tag-handle was specified as:
        // !(name) or similar; the trailing '!' is missing.
        if (ch != '!') {
            reader.forward(length);
            throw new ScannerException("while scanning a " + name, startMark,
                    "expected '!', but found " + ch + "(" + ((int) ch) + ")", reader.getMark());
        }
        length++;
    }
    String value = reader.prefixForward(length);
    return value;
}
 
Example #16
Source File: ScannerImpl.java    From orion.server with Eclipse Public License 1.0 5 votes vote down vote up
/**
 * Scans for the indentation of a block scalar implicitly. This mechanism is
 * used only if the block did not explicitly state an indentation to be
 * used.
 * 
 * @see http://www.yaml.org/spec/1.1/#id927035
 */
private Object[] scanBlockScalarIndentation() {
    // See the specification for details.
    StringBuilder chunks = new StringBuilder();
    int maxIndent = 0;
    Mark endMark = reader.getMark();
    // Look ahead some number of lines until the first non-blank character
    // occurs; the determined indentation will be the maximum number of
    // leading spaces on any of these lines.
    while (Constant.LINEBR.has(reader.peek(), " \r")) {
        if (reader.peek() != ' ') {
            // If the character isn't a space, it must be some kind of
            // line-break; scan the line break and track it.
            chunks.append(scanLineBreak());
            endMark = reader.getMark();
        } else {
            // If the character is a space, move forward to the next
            // character; if we surpass our previous maximum for indent
            // level, update that too.
            reader.forward();
            if (this.reader.getColumn() > maxIndent) {
                maxIndent = reader.getColumn();
            }
        }
    }
    // Pass several results back together.
    return new Object[] { chunks.toString(), maxIndent, endMark };
}
 
Example #17
Source File: ParserImpl.java    From orion.server with Eclipse Public License 1.0 5 votes vote down vote up
public ParserImpl(StreamReader reader) {
    this.scanner = new ScannerImpl(reader);
    currentEvent = null;
    directives = new VersionTagsTuple(null, new HashMap<String, String>(DEFAULT_TAGS));
    states = new ArrayStack<Production>(100);
    marks = new ArrayStack<Mark>(10);
    state = new ParseStreamStart();
}
 
Example #18
Source File: ScannerImpl.java    From snake-yaml with Apache License 2.0 5 votes vote down vote up
/**
 * <pre>
 * The specification does not restrict characters for anchors and
 * aliases. This may lead to problems, for instance, the document:
 *   [ *alias, value ]
 * can be interpreted in two ways, as
 *   [ &quot;value&quot; ]
 * and
 *   [ *alias , &quot;value&quot; ]
 * Therefore we restrict aliases to numbers and ASCII letters.
 * </pre>
 */
private Token scanAnchor(boolean isAnchor) {
    Mark startMark = reader.getMark();
    char indicator = reader.peek();
    String name = indicator == '*' ? "alias" : "anchor";
    reader.forward();
    int length = 0;
    char ch = reader.peek(length);
    while (Constant.ALPHA.has(ch)) {
        length++;
        ch = reader.peek(length);
    }
    if (length == 0) {
        throw new ScannerException("while scanning an " + name, startMark,
                "expected alphabetic or numeric character, but found " + ch,
                reader.getMark());
    }
    String value = reader.prefixForward(length);
    ch = reader.peek();
    if (Constant.NULL_BL_T_LINEBR.hasNo(ch, "?:,]}%@`")) {
        throw new ScannerException("while scanning an " + name, startMark,
                "expected alphabetic or numeric character, but found " + ch + "("
                        + ((int) reader.peek()) + ")", reader.getMark());
    }
    Mark endMark = reader.getMark();
    Token tok;
    if (isAnchor) {
        tok = new AnchorToken(value, startMark, endMark);
    } else {
        tok = new AliasToken(value, startMark, endMark);
    }
    return tok;
}
 
Example #19
Source File: ScalarNode.java    From snake-yaml with Apache License 2.0 5 votes vote down vote up
public ScalarNode(Tag tag, boolean resolved, String value, Mark startMark, Mark endMark,
        Character style) {
    super(tag, startMark, endMark);
    if (value == null) {
        throw new NullPointerException("value in a Node is required.");
    }
    this.value = value;
    this.style = style;
    this.resolved = resolved;
}
 
Example #20
Source File: ScannerImpl.java    From orion.server with Eclipse Public License 1.0 5 votes vote down vote up
@SuppressWarnings({ "unchecked", "rawtypes" })
private Token scanDirective() {
    // See the specification for details.
    Mark startMark = reader.getMark();
    Mark endMark;
    reader.forward();
    String name = scanDirectiveName(startMark);
    List<?> value = null;
    if ("YAML".equals(name)) {
        value = scanYamlDirectiveValue(startMark);
        endMark = reader.getMark();
    } else if ("TAG".equals(name)) {
        value = scanTagDirectiveValue(startMark);
        endMark = reader.getMark();
    } else {
        endMark = reader.getMark();
        int ff = 0;
        while (Constant.NULL_OR_LINEBR.hasNo(reader.peek(ff))) {
            ff++;
        }
        if (ff > 0) {
            reader.forward(ff);
        }
    }
    scanDirectiveIgnoredLine(startMark);
    return new DirectiveToken(name, value, startMark, endMark);
}
 
Example #21
Source File: ScannerImpl.java    From snake-yaml with Apache License 2.0 5 votes vote down vote up
/**
 * We always add STREAM-START as the first token and STREAM-END as the last
 * token.
 */
private void fetchStreamStart() {
    // Read the token.
    Mark mark = reader.getMark();

    // Add STREAM-START.
    Token token = new StreamStartToken(mark, mark);
    this.tokens.add(token);
}
 
Example #22
Source File: ScalarNode.java    From orion.server with Eclipse Public License 1.0 5 votes vote down vote up
public ScalarNode(Tag tag, boolean resolved, String value, Mark startMark, Mark endMark,
        Character style) {
    super(tag, startMark, endMark);
    if (value == null) {
        throw new NullPointerException("value in a Node is required.");
    }
    this.value = value;
    this.style = style;
    this.resolved = resolved;
}
 
Example #23
Source File: Node.java    From snake-yaml with Apache License 2.0 5 votes vote down vote up
public Node(Tag tag, Mark startMark, Mark endMark) {
    setTag(tag);
    this.startMark = startMark;
    this.endMark = endMark;
    this.type = Object.class;
    this.twoStepsConstruction = false;
    this.resolved = true;
    this.useClassConstructor = null;
}
 
Example #24
Source File: ScannerImpl.java    From snake-yaml with Apache License 2.0 5 votes vote down vote up
/**
 * Scan a %TAG directive's prefix. This is YAML's ns-tag-prefix.
 * 
 * @see <a href="http://www.yaml.org/spec/1.1/#ns-tag-prefix"></a>
 */
private String scanTagDirectivePrefix(Mark startMark) {
    // See the specification for details.
    String value = scanTagUri("directive", startMark);
    if (Constant.NULL_BL_LINEBR.hasNo(reader.peek())) {
        throw new ScannerException("while scanning a directive", startMark,
                "expected ' ', but found " + reader.peek() + "(" + ((int) reader.peek()) + ")",
                reader.getMark());
    }
    return value;
}
 
Example #25
Source File: TagTokenTest.java    From snake-yaml with Apache License 2.0 5 votes vote down vote up
public void testNoTag() {
    try {
        Mark mark = new Mark("test1", 0, 0, 0, "*The first line.\nThe last line.", 0);
        new TagToken(new TagTuple("!foo", null), mark, mark);
        fail("Marks must be provided.");
    } catch (NullPointerException e) {
        assertEquals("Suffix must be provided.", e.getMessage());
    }
}
 
Example #26
Source File: ScannerImpl.java    From orion.server with Eclipse Public License 1.0 5 votes vote down vote up
/**
 * We always add STREAM-START as the first token and STREAM-END as the last
 * token.
 */
private void fetchStreamStart() {
    // Read the token.
    Mark mark = reader.getMark();

    // Add STREAM-START.
    Token token = new StreamStartToken(mark, mark);
    this.tokens.add(token);
}
 
Example #27
Source File: ScannerImpl.java    From snake-yaml with Apache License 2.0 5 votes vote down vote up
/**
 * Fetch a key in a block-style mapping.
 * 
 * @see <a href="http://www.yaml.org/spec/1.1/#id863975"></a>
 */
private void fetchKey() {
    // Block context needs additional checks.
    if (this.flowLevel == 0) {
        // Are we allowed to start a key (not necessary a simple)?
        if (!this.allowSimpleKey) {
            throw new ScannerException(null, null, "mapping keys are not allowed here",
                    reader.getMark());
        }
        // We may need to add BLOCK-MAPPING-START.
        if (addIndent(this.reader.getColumn())) {
            Mark mark = reader.getMark();
            this.tokens.add(new BlockMappingStartToken(mark, mark));
        }
    }
    // Simple keys are allowed after '?' in the block context.
    this.allowSimpleKey = this.flowLevel == 0;

    // Reset possible simple key on the current level.
    removePossibleSimpleKey();

    // Add KEY.
    Mark startMark = reader.getMark();
    reader.forward();
    Mark endMark = reader.getMark();
    Token token = new KeyToken(startMark, endMark);
    this.tokens.add(token);
}
 
Example #28
Source File: ScalarEvent.java    From orion.server with Eclipse Public License 1.0 5 votes vote down vote up
public ScalarEvent(String anchor, String tag, ImplicitTuple implicit, String value,
        Mark startMark, Mark endMark, Character style) {
    super(anchor, startMark, endMark);
    this.tag = tag;
    this.implicit = implicit;
    this.value = value;
    this.style = style;
}
 
Example #29
Source File: SortingRuleAliasProcessor.java    From BungeeTabListPlus with GNU General Public License v3.0 5 votes vote down vote up
@Override
public String process(String sortingRule, ErrorHandler errorHandler, Mark mark) {
    RewriteData rewriteData = map.get(sortingRule.toLowerCase());
    if (rewriteData != null) {
        if (rewriteData.deprecated) {
            errorHandler.addWarning("Sorting rule '" + sortingRule + "' has been deprecated. Use '" + rewriteData.rewrite + "' instead.", mark);
        }
        return rewriteData.rewrite;
    }
    return sortingRule;
}
 
Example #30
Source File: DocumentStartEvent.java    From orion.server with Eclipse Public License 1.0 5 votes vote down vote up
public DocumentStartEvent(Mark startMark, Mark endMark, boolean explicit, Version version,
        Map<String, String> tags) {
    super(startMark, endMark);
    this.explicit = explicit;
    this.version = version;
    // TODO enforce not null
    // if (tags == null) {
    // throw new NullPointerException("Tags must be provided.");
    // }
    this.tags = tags;
}