Examples of SymbolSet


Examples of net.sourceforge.chaperon.model.symbol.SymbolSet

   *
   * @return Set of symbols, which were used.
   */
  public SymbolSet getSymbols()
  {
    SymbolSet set = new SymbolSet();

    for (int i = 0; i<getProductionCount(); i++)
      set.addSymbol(getProduction(i).getSymbols());

    return set;
  }
View Full Code Here

Examples of net.sourceforge.chaperon.model.symbol.SymbolSet

      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.symbol.SymbolSet

  {
    StringBuffer buffer = new StringBuffer();

    buffer.append("Terminal symbols:\n");

    SymbolSet tsymbols = getSymbols().getTerminals();

    for (int i = 0; i<tsymbols.getSymbolCount(); i++)
    {
      buffer.append(String.valueOf(i));
      buffer.append(".Terminal: ");
      buffer.append(tsymbols.getSymbol(i));
      buffer.append(" Priority=");
      buffer.append(String.valueOf(getPriority((Terminal)tsymbols.getSymbol(i))));
      buffer.append(" Associativity=");
      buffer.append(String.valueOf(getAssociativity((Terminal)tsymbols.getSymbol(i))));
      buffer.append("\n");
    }

    buffer.append("Produktions:\n");
    for (int i = 0; i<getProductionCount(); i++)
View Full Code Here

Examples of net.sourceforge.chaperon.model.symbol.SymbolSet

   *
   * @return Set of symbols.
   */
  public SymbolSet getSymbols()
  {
    SymbolSet set = new SymbolSet();

    set.addSymbol(ntsymbol);
    set.addSymbol(definition);
    if (precedence!=null)
      set.addSymbol(precedence);

    return set;
  }
View Full Code Here

Examples of net.sourceforge.chaperon.model.symbol.SymbolSet

  public void testFirstOfASymbol()
  {
    FirstSetCollection sets = new FirstSetCollection(grammar)/*, new ConsoleLogger());*/

    SymbolSet result = new SymbolSet();
    result.addSymbol(id);
    result.addSymbol(bopen);
    assertEquals("Test if sets are equal", result, sets.getFirstSet(E));
    assertEquals("Test if sets are equal", result, sets.getFirstSet(T));
    assertEquals("Test if sets are equal", result, sets.getFirstSet(F));

    result = new SymbolSet();
    result.addSymbol(plus);
    result.addSymbol(emptylist);
    assertEquals("Test if sets are equal", result, sets.getFirstSet(Eprime));

    result = new SymbolSet();
    result.addSymbol(mult);
    result.addSymbol(emptylist);
    assertEquals("Test if sets are equal", result, sets.getFirstSet(Tprime));
  }
View Full Code Here

Examples of net.sourceforge.chaperon.model.symbol.SymbolSet

    FirstSetCollection sets = new FirstSetCollection(grammar)/*, new ConsoleLogger());*/

    SymbolList list = new SymbolList();
    list.addSymbol(Eprime);

    SymbolSet result = new SymbolSet();
    result.addSymbol(plus);
    result.addSymbol(emptylist);
    assertEquals("Test if sets are equal", result, sets.getFirstSet(list));

    list = new SymbolList();
    list.addSymbol(Eprime);
    list.addSymbol(id);
    list.addSymbol(Tprime);

    result = new SymbolSet();
    result.addSymbol(plus);
    result.addSymbol(id);
    assertEquals("Test if sets are equal", result, sets.getFirstSet(list));

    list = new SymbolList();
    list.addSymbol(Eprime);
    list.addSymbol(Tprime);

    result = new SymbolSet();
    result.addSymbol(plus);
    result.addSymbol(mult);
    result.addSymbol(emptylist);
    assertEquals("Test if sets are equal", result, sets.getFirstSet(list));

    list = new SymbolList();

    result = new SymbolSet();
    result.addSymbol(emptylist);
    assertEquals("Test if sets are equal", result, sets.getFirstSet(list));
  }
View Full Code Here

Examples of net.sourceforge.chaperon.model.symbol.SymbolSet

   *
   * @return Set of symbols, which were used.
   */
  public SymbolSet getSymbols()
  {
    SymbolSet set = new SymbolSet();

    for (int i = 0; i<getProductionCount(); i++)
      set.addSymbol(getProduction(i).getSymbols());
    return set;
  }
View Full Code Here

Examples of net.sourceforge.chaperon.model.symbol.SymbolSet

      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.symbol.SymbolSet

  public String toString()
  {
    StringBuffer buffer = new StringBuffer();

    buffer.append("Terminal symbols:\n");
    SymbolSet tsymbols = getSymbols().getTerminals();

    for (int i = 0; i<tsymbols.getSymbolCount(); i++)
    {
      buffer.append(String.valueOf(i));
      buffer.append(".Terminal: ");
      buffer.append(tsymbols.getSymbol(i));
      buffer.append(" Priority=");
      buffer.append(String.valueOf(getPriority((Terminal) tsymbols.getSymbol(i))));
      buffer.append(" Associativity=");
      buffer.append(String.valueOf(getAssociativity((Terminal) tsymbols.getSymbol(i))));
      buffer.append("\n");
    }

    buffer.append("Produktions:\n");
    for (int i = 0; i<getProductionCount(); i++)
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.