Package net.sourceforge.chaperon.model.symbol

Examples of net.sourceforge.chaperon.model.symbol.SymbolSet.addSymbol()


                  b2.addSymbol(productiondefinition.getSymbol(pos));
                }
                else
                {
                  b2.clear();
                  b2.addSymbol(firstsets.getFirstSet(productiondefinition.getSymbol(pos)));
                }

                b.addSymbol(b2);
                pos++;
              }
View Full Code Here


    for (int i = 0; i<elementCount; i++)
    {
      if (getItemNext(i).equals(EMPTYLIST))  // for all A=u^ and all symbols in FOLLOW(A)

        reducesymbols.addSymbol(lookaheads[i]);
    }

    return reducesymbols;
  }
View Full Code Here

  {
    SymbolSet firstset = new SymbolSet();

    if (symbols.getSymbolCount()==0)
    {
      firstset.addSymbol(EMPTYLIST);
      return firstset;
    }

    int position = 0;
    do
View Full Code Here

    do
    {
      firstset.removeSymbol(EMPTYLIST);

      if (symbols.getSymbol(position) instanceof Terminal)
        firstset.addSymbol(symbols.getSymbol(position));
      else
        firstset.addSymbol(getFirstSet(symbols.getSymbol(position)));

      position++;
    }
View Full Code Here

      firstset.removeSymbol(EMPTYLIST);

      if (symbols.getSymbol(position) instanceof Terminal)
        firstset.addSymbol(symbols.getSymbol(position));
      else
        firstset.addSymbol(getFirstSet(symbols.getSymbol(position)));

      position++;
    }
    while ((firstset.contains(EMPTYLIST)) && (position<symbols.getSymbolCount()));
View Full Code Here

    SymbolSet firstset = new SymbolSet();

    // if the symbol is a terminal symbol
    if (symbol instanceof Terminal)
    {
      firstset.addSymbol(symbol);
      return firstset;
    }

    if (visited.contains(symbol))
      return firstset;
View Full Code Here

    SymbolSet followset = new SymbolSet();

    // if symbol is start symbol, then add symbol for end of file
    if (symbol.equals(grammar.getStartSymbol()))
      followset.addSymbol(new EndOfFile());

    // if production A -> a B b exists, then add every symbol of
    // FIRST(b) except the symbol for an empty list to FOLLOW(B)
    SymbolList definition;
    for (int production = 0; production<grammar.getProductionCount(); production++)
View Full Code Here

    SymbolList productiondefinition;
    for (int item = 0; item<productions.length; item++)
      if ((positions[item]<((productiondefinition = productions[item].getDefinition()).getSymbolCount())) &&
          (productiondefinition.getSymbol(positions[item]) instanceof Terminal))
        set.addSymbol(productiondefinition.getSymbol(positions[item]));

    return set;
  }

  public SymbolSet getNextNonterminals()
View Full Code Here

    SymbolList productiondefinition;
    for (int item = 0; item<productions.length; item++)
      if ((positions[item]<((productiondefinition = productions[item].getDefinition()).getSymbolCount())) &&
          (productiondefinition.getSymbol(positions[item]) instanceof Nonterminal))
        set.addSymbol(productiondefinition.getSymbol(positions[item]));

    return set;
  }

  /**
 
View Full Code Here

  {
    FirstSetCollection firstsets = new FirstSetCollection(grammar)/*, new ConsoleLogger());*/
    FollowSetCollection followsets = new FollowSetCollection(grammar, firstsets);

    SymbolSet result = new SymbolSet();
    result.addSymbol(bclose);
    result.addSymbol(eof);
    assertEquals("Test if sets are equal", result, followsets.getFollowSet(E));
    assertEquals("Test if sets are equal", result, followsets.getFollowSet(Eprime));

    result = new SymbolSet();
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.