Examples of Violations


Examples of net.sourceforge.chaperon.model.Violations

    catch (CloneNotSupportedException cnse)
    {
      throw new IllegalArgumentException("Lexicon is nor cloneable");
    }

    Violations violations = lexicon.validate();

    if ((violations!=null) && (violations.getViolationCount()>0))
      throw new IllegalArgumentException("Lexicon is not valid: "+violations.getViolation(0));

    LexicalAutomaton automaton = new LexicalAutomaton(lexicon.getLexemeCount());

    Lexeme lexeme;
    PatternAutomaton definition = null;
View Full Code Here

Examples of net.sourceforge.chaperon.model.Violations

  public ParserAutomatonBuilder(Grammar grammar, Log log)
  {
    this.grammar = (Grammar)grammar.clone();
    this.log = log;

    Violations violations = grammar.validate();

    if ((violations!=null) && (violations.getViolationCount()>0))
      throw new IllegalArgumentException("Grammar is not valid: "+violations.getViolation(0));

    SymbolSet symbols = grammar.getSymbols();

    tsymbols = symbols.getTerminals();
    ntsymbols = symbols.getNonterminals();
View Full Code Here

Examples of net.sourceforge.chaperon.model.Violations

   *
   * @return Return a list of violations, if this pattern isn't valid.
   */
  public Violations validate()
  {
    Violations violations = new Violations();

    if (getCharacterClassElementCount()<1)
      violations.addViolation("Character class doesn't contain 1 or more elements", getLocation());

    for (int i = 0; i<getCharacterClassElementCount(); i++)
      violations.addViolations(getCharacterClassElement(i).validate());

    return violations;
  }
View Full Code Here

Examples of net.sourceforge.chaperon.model.Violations

   *
   * @return Return a list of violations, if this pattern isn't valid.
   */
  public Violations validate()
  {
    Violations violations = new Violations();

    if ((characters.length+intervals.length)==0)
      violations.addViolation("Character class is empty", getLocation());

    for (int i = 0; i<characters.length; i++)
      violations.addViolations(characters[i].validate());

    for (int i = 0; i<intervals.length; i++)
      violations.addViolations(intervals[i].validate());

    return violations;
  }
View Full Code Here

Examples of net.sourceforge.chaperon.model.Violations

   *
   * @return Return a list of violations, if this pattern isn't valid.
   */
  public Violations validate()
  {
    Violations violations = new Violations();

    if (getPatternCount()==0)
      violations.addViolation("Alternation doesn't contain any elements", getLocation());

    for (int i = 0; i<getPatternCount(); i++)
      violations.addViolations(getPattern(i).validate());

    return violations;
  }
View Full Code Here

Examples of net.sourceforge.chaperon.model.Violations

   *
   * @return Return a list of violations, if this pattern isn't valid.
   */
  public Violations validate()
  {
    Violations violations = new Violations();

    if (getPatternCount()==0)
      violations.addViolation("Choice doesn't contain any elements", getLocation());

    for (int i = 0; i<getPatternCount(); i++)
      violations.addViolations(getPattern(i).validate());

    return violations;
  }
View Full Code Here

Examples of net.sourceforge.chaperon.model.Violations

   */
  public void setExtendedGrammar(ExtendedGrammar grammar)
  {
    this.grammar = grammar;

    Violations violations = grammar.validate();

    if ((violations!=null) && (violations.getViolationCount()>0))
      throw new IllegalArgumentException("Grammar is not valid: "+violations.getViolation(0));

    if ((log!=null) && (log.isDebugEnabled()))
      log.debug("grammar:\n"+grammar);

    grammar.update();
View Full Code Here

Examples of net.sourceforge.chaperon.model.Violations

   * @return Return a list of violations, if this
   *         object isn't correct
   */
  public Violations validate()
  {
    Violations violations = new Violations();
    if (startsymbol==null)
      violations.addViolation("Start symbol is not defined", location);

    if (getProductionCount() <= 0)
      violations.addViolation("No productions are defined", location);

    for (Enumeration e = productions.elements(); e.hasMoreElements() ;)
      violations.addViolations(((Production)e.nextElement()).validate());

    SymbolSet ntsymbols = getSymbols().getNonterminals();
    for (int i = 0; i < ntsymbols.getSymbolCount(); i++)
      if (!contains(ntsymbols.getSymbol(i)))
        violations.addViolation("Nonterminal symbol \"" + ntsymbols.getSymbol(i) + "\"" +
                                "is not defined through a production", location);

    return violations;
  }
View Full Code Here

Examples of net.sourceforge.chaperon.model.Violations

   *
   * @return Return a list of violations, if this object isn't valid.
   */
  public Violations validate()
  {
    Violations violations = new Violations();

    if (startsymbol==null)
      violations.addViolation("Start symbol is not defined", location);
    else if (!contains(startsymbol))
      violations.addViolation("Start symbol \""+startsymbol+"\""+
                              "is not defined through a production", location);

    if (getProductionCount()<=0)
      violations.addViolation("No productions are defined", location);

    for (Enumeration e = productions.elements(); e.hasMoreElements();)
      violations.addViolations(((Production)e.nextElement()).validate());

    SymbolSet ntsymbols = getSymbols().getNonterminals();

    for (int i = 0; i<ntsymbols.getSymbolCount(); i++)
    {
      if (!contains(ntsymbols.getSymbol(i)))
        violations.addViolation("Nonterminal symbol \""+ntsymbols.getSymbol(i)+"\""+
                                "is not defined through a production", location);

      if (ntsymbols.getSymbol(i).getName().equals("error"))
        violations.addViolation("Nonterminal symbol with name \"error\" is not allowed", location);
    }

    SymbolSet tsymbols = getSymbols().getTerminals();

    for (int i = 0; i<tsymbols.getSymbolCount(); i++)
    {
      if ((!(tsymbols.getSymbol(i) instanceof Error)) &&
          (tsymbols.getSymbol(i).getName().equals("error")))
        violations.addViolation("Terminal symbol with name \"error\" is not allowed", location);
    }

    return violations;
  }
View Full Code Here

Examples of net.sourceforge.chaperon.model.Violations

   *
   * @return Return a list of violations, if this pattern isn't valid.
   */
  public Violations validate()
  {
    Violations violations = new Violations();

    if ((set==null) || (set.length()==0))
      violations.addViolation("Character set contains no characters", getLocation());

    return violations;
  }
View Full Code Here
TOP
Copyright © 2018 www.massapi.com. 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.