Package ai.test.comment

Examples of ai.test.comment.CommentParserException


  public Map<Variable, DI> parseItemDescription(String itemDescription) {
    if (DomainConstants.BOT.equals(itemDescription))
      return null;
    Matcher matcher = DOMAIN_ITEM_PATTERN.matcher(itemDescription);
    if (!matcher.matches())
      throw new CommentParserException("Invalid domain value '%s'", itemDescription);
    itemDescription = matcher.group(1).trim();
    Map<Variable, DI> result = new HashMap<Variable, DI>();
    // Map<Variable, DI> result = new HashMap<Variable, DI>();
    while (itemDescription.length() > 0) {
      Pair<Pair<String, DI>, String> res = getNextValue(itemDescription);
      String variableName = res.left.left;
      Variable var = match.getVariable(variableName);
      if (var == null)
        throw new RuntimeException("Unknown variable '" + variableName + "'");
      if (result.containsKey(var))
        throw new CommentParserException("Duplicate variable '%s'", variableName);
      DI value = res.left.right;
      result.put(var, value);
      String newitemDescription = res.right;
      if (newitemDescription.length() > 0 && itemDescription.indexOf(newitemDescription) <= 0)
        throw new CommentParserException("An error!!");
      itemDescription = newitemDescription;
    }
    return result;
  }
View Full Code Here


  @Override
  protected Pair<Pair<String, Interval>, String> getNextValue(String description) {
    Matcher matcher = NAME_VALUE_PATTERN_PREFIX.matcher(description);
    if (!matcher.matches())
      throw new CommentParserException("Invalid domain value '%s'", description);
    String variableName = matcher.group(1);
    String valueString = matcher.group(2);
    IntervalValue value = Utils.parseInterval(valueString);
    String descriptionSuffix = matcher.group(3).trim();
    return Pair.create(Pair.create(variableName, new Interval(value)), descriptionSuffix);
View Full Code Here

  @Override
  public final void parseLine(String line) {
    Matcher matcher = DomainConstants.NAME_VALUE_PATTERN.matcher(line);
    if (!matcher.matches())
      throw new CommentParserException("Invalid intervals line '%s'", line);
    String cp = matcher.group(1);
   
    if (!match.containsCommentVertice(cp))
      throw new CommentParserException("Invalid control point name '%s'", cp);
    if (mapping.containsKey(cp))
      throw new CommentParserException("Duplicate control point description '%s'", cp);
    String itemDescription = matcher.group(2).trim();
    mapping.put(cp, parseItemDescription(itemDescription));
  }
View Full Code Here

  public abstract DI createInitialValue(T parsedDescription);

  @Override
  public final void parseInitialValue(String value) {
    if (initialValue != null)
      throw new CommentParserException("Invalid usage, duplicate initial value");
    initialValue = parseItemDescription(value);
  }
View Full Code Here

    do {
      if (description.equals(EMPTY))
        break;
      Matcher matcher = INTV_BOX_PATTERN_PREFIX.matcher(description);
      if (!matcher.matches())
        throw new CommentParserException("Invalid domain value '%s'", description);
      String boxDescription = matcher.group(1).trim();
      //FIXME: add restrictions on box??
      Map<Variable, Interval> box = intvParser.parseItemDescription(boxDescription);
      result.add(box);
      description = matcher.group(2);
View Full Code Here

  @Override
  protected Pair<Pair<String, Bool>, String> getNextValue(String description) {
    Matcher matcher = NAME_VALUE_PATTERN_PREFIX.matcher(description);
    if (!matcher.matches())
      throw new CommentParserException("Invalid domain value '%s'", description);
    String variableName = matcher.group(1);
    String valueString = matcher.group(2);
    Bool value = Utils.parseBool(valueString);
    if (value == null)
      throw new CommentParserException("Invalid boolean value '%s'", valueString);
    description = matcher.group(3).trim();
    return Pair.create(Pair.create(variableName, value), description);
  }
View Full Code Here

TOP

Related Classes of ai.test.comment.CommentParserException

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.