Package net.sourceforge.chaperon.model.symbol

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


    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

   *
   * @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

      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

  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

Related Classes of net.sourceforge.chaperon.model.symbol.SymbolSet

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.