if (token.getName().equals("YAML")) { if (yamlVersion != null) { throw new ParserException(null, null, "found duplicate YAML directive", token.getStartMark()); Integer major = value.get(0); if (major != 1) { throw new ParserException(null, null, "found incompatible YAML document (version 1.* is required)", token.getStartMark()); String prefix = value.get(1); if (tagHandles.containsKey(handle)) { throw new ParserException(null, null, "duplicate tag handle " + handle, token.getStartMark());
public ParseConfigException(ParserException e) { Problem problem = new ConfigProblemBuilder(Problem.Severity.FATAL, "Could not parse your halconfig: " + e.getMessage()).build(); getProblems().add(problem); }
@Override public void reconcile(IDocument doc, IProblemCollector problemCollector) { problemCollector.beginCollecting(); try { YamlFileAST ast = parser.getAST(doc); YamlASTReconciler reconciler = getASTReconciler(doc, problemCollector); if (reconciler!=null) { reconciler.reconcile(ast); } } catch (ParserException e) { String msg = e.getProblem(); Mark mark = e.getProblemMark(); problemCollector.accept(syntaxError(msg, mark.getIndex(), 1)); } catch (ScannerException e) { String msg = e.getProblem(); Mark mark = e.getProblemMark(); problemCollector.accept(syntaxError(msg, mark.getIndex(), 1)); } catch (Exception e) { logger.error("unexpected error during reconcile", e); } finally { problemCollector.endCollecting(); } }
@Override public Object convertRenderedValue(String renderedValue) { if (containsEL(renderedValue) || isYamlKeyword(renderedValue) || containsYamlParsingExceptions(renderedValue)) { return renderedValue; } if (containsNoExpandMarker(renderedValue)) { return trimNoExpandMarker(renderedValue); } try { Object converted = yaml.get().load(renderedValue); if (converted == null || converted instanceof String) { return "".equals(converted) || "".equals(renderedValue) ? null : renderedValue; } return converted; } catch (ComposerException ce) { throw new TemplateRenderException("template produced invalid yaml", ce); } catch (ParserException pe) { if (pe.getProblem().contains("expected '<document start>'")) { log.info("YAML parser expected start of document, assuming rendered value is desired state"); return renderedValue; } throw pe; } }
System.err.println( pse.getProblemMark() );
public String rewriteMessage(YAMLException exception) { if (exception instanceof ParserException) { if ("while parsing a block mapping".equals(((ParserException) exception).getContext())) { return Messages.error_yaml_parser_indentation; } } return exception != null ? exception.getLocalizedMessage() : null; }
private PolicyCollection createEntry(final YamlSource source, final ValidationSet validation) throws PoliciesParseException { try { return YamlProvider.policiesFromSource(source, forcedContext, validation); } catch (ParserException e1) { throw new PoliciesParseException("YAML syntax error: " + e1.toString(), e1); }catch (Exception e1) { throw new PoliciesParseException(e1); } }
public ParseConfigException(ParserException e) { Problem problem = new ConfigProblemBuilder(Problem.Severity.FATAL, "Could not parse your halconfig: " + e.getMessage()).build(); getProblems().add(problem); }
public Event produce() { if (scanner.checkToken(Token.ID.Key)) { Token token = scanner.getToken(); if (!scanner.checkToken(Token.ID.Key, Token.ID.Value, Token.ID.BlockEnd)) { states.push(new ParseBlockMappingValue()); return parseBlockNodeOrIndentlessSequence(); } else { state = new ParseBlockMappingValue(); return processEmptyScalar(token.getEndMark()); } } if (!scanner.checkToken(Token.ID.BlockEnd)) { Token token = scanner.peekToken(); throw new ParserException("while parsing a block mapping", marks.pop(), "expected <block end>, but found '" + token.getTokenId() + "'", token.getStartMark()); } Token token = scanner.getToken(); Event event = new MappingEndEvent(token.getStartMark(), token.getEndMark()); state = states.pop(); marks.pop(); return event; } }
@Override public Object renderGraph(String template, RenderContext context) { String renderedValue = render(template, context); try { return renderedValueConverter.convertRenderedValue(renderedValue); } catch (ParserException e) { throw TemplateRenderException.fromError( new Error() .withMessage("Failed converting rendered value to YAML") .withLocation(context.getLocation()) .withDetail("source", template) .withCause(e.getMessage()), e ); } }
public Event produce() { if (scanner.checkToken(Token.ID.BlockEntry)) { BlockEntryToken token = (BlockEntryToken) scanner.getToken(); if (!scanner.checkToken(Token.ID.BlockEntry, Token.ID.BlockEnd)) { states.push(new ParseBlockSequenceEntry()); return new ParseBlockNode().produce(); } else { state = new ParseBlockSequenceEntry(); return processEmptyScalar(token.getEndMark()); } } if (!scanner.checkToken(Token.ID.BlockEnd)) { Token token = scanner.peekToken(); throw new ParserException("while parsing a block collection", marks.pop(), "expected <block end>, but found '" + token.getTokenId() + "'", token.getStartMark()); } Token token = scanner.getToken(); Event event = new SequenceEndEvent(token.getStartMark(), token.getEndMark()); state = states.pop(); marks.pop(); return event; } }
public Event produce() { if (!scanner.checkToken(Token.ID.FlowSequenceEnd)) { if (!first) { if (scanner.checkToken(Token.ID.FlowEntry)) { scanner.getToken(); } else { Token token = scanner.peekToken(); throw new ParserException("while parsing a flow sequence", marks.pop(), "expected ',' or ']', but got " + token.getTokenId(), token.getStartMark()); } } if (scanner.checkToken(Token.ID.Key)) { Token token = scanner.peekToken(); Event event = new MappingStartEvent(null, null, true, token.getStartMark(), token.getEndMark(), DumperOptions.FlowStyle.FLOW); state = new ParseFlowSequenceEntryMappingKey(); return event; } else if (!scanner.checkToken(Token.ID.FlowSequenceEnd)) { states.push(new ParseFlowSequenceEntry(false)); return parseFlowNode(); } } Token token = scanner.getToken(); Event event = new SequenceEndEvent(token.getStartMark(), token.getEndMark()); state = states.pop(); marks.pop(); return event; } }
} else { Token token = scanner.peekToken(); throw new ParserException("while parsing a flow mapping", marks.pop(), "expected ',' or '}', but got " + token.getTokenId(), token.getStartMark());
VersionTagsTuple tuple = processDirectives(); if (!scanner.checkToken(Token.ID.DocumentStart)) { throw new ParserException(null, null, "expected '<document start>', but found '" + scanner.peekToken().getTokenId() + "'", scanner.peekToken().getStartMark());
if (handle != null) { if (!directives.getTags().containsKey(handle)) { throw new ParserException("while parsing a node", startMark, "found undefined tag handle " + handle, tagMark); throw new ParserException("while parsing a " + node + " node", startMark, "expected the node content, but found '" + token.getTokenId() + "'", token.getStartMark());
@Override protected Map<Object, Object> constructMapping(MappingNode node) { try { return super.constructMapping(node); } catch (IllegalStateException ex) { throw new ParserException("while parsing MappingNode", node.getStartMark(), ex.getMessage(), node.getEndMark()); } }
@Override protected Map<Object, Object> constructMapping(MappingNode node) { try { return super.constructMapping(node); } catch (IllegalStateException ex) { throw new ParserException("while parsing MappingNode", node.getStartMark(), ex.getMessage(), node.getEndMark()); } }
if (token.getName().equals("YAML")) { if (yamlVersion != null) { throw new ParserException(null, null, "found duplicate YAML directive", token.getStartMark()); Integer major = value.get(0); if (major != 1) { throw new ParserException(null, null, "found incompatible YAML document (version 1.* is required)", token.getStartMark()); String prefix = value.get(1); if (tagHandles.containsKey(handle)) { throw new ParserException(null, null, "duplicate tag handle " + handle, token.getStartMark());
if (token.getName().equals("YAML")) { if (yamlVersion != null) { throw new ParserException(null, null, "found duplicate YAML directive", token.getStartMark()); Integer major = value.get(0); if (major != 1) { throw new ParserException(null, null, "found incompatible YAML document (version 1.* is required)", token.getStartMark()); String prefix = value.get(1); if (tagHandles.containsKey(handle)) { throw new ParserException(null, null, "duplicate tag handle " + handle, token.getStartMark());
if (token.getName().equals("YAML")) { if (yamlVersion != null) { throw new ParserException(null, null, "found duplicate YAML directive", token.getStartMark()); Integer major = value.get(0); if (major != 1) { throw new ParserException(null, null, "found incompatible YAML document (version 1.* is required)", token.getStartMark()); String prefix = value.get(1); if (tagHandles.containsKey(handle)) { throw new ParserException(null, null, "duplicate tag handle " + handle, token.getStartMark());