Package net.sourceforge.chaperon.grammar.symbol

Examples of net.sourceforge.chaperon.grammar.symbol.Symbol


   */
  private boolean contains(ItemSet itemset)
  {
    int i, j;
    int production, position;
    Symbol lookahead;
    boolean found;

    for (i = 0; i < itemset._elementCount; i++)
    {
      production = itemset._productions[i];
View Full Code Here


    int i, j, k;                                       // Index variables
    SymbolList productiondefinition;
    SymbolList b = new SymbolList();
    SymbolList b2 = new SymbolList(true);
    IntegerList productionlist;
    Symbol symbol;

    // for every item in itemset I
    for (i = 0; i < J._elementCount; i++)
    {
      productiondefinition = _grammar.getProductionList().getProduction(J._productions[i]).getDefinition();

      // and not A=XYZ^
      if (J._positions[i] < productiondefinition.getSymbolCount())
      {
        symbol = productiondefinition.getSymbol(J._positions[i]); // A=X ^symbol Z

        // for every item [A=u^Bv,a] in J and production B=w in G
        if (!symbol.isTerminal())
        {
          int pos = J._positions[i] + 1;              // for the FIRST set from (va)

          b.clear();
View Full Code Here

    IntegerList changedState = new IntegerList(); // 0=not changed 1=changed

    ItemSet I = new ItemSet(_grammar, _firstsets);
    IntegerList startlist = _grammar.getProductionList().getProductionList(_grammar.getStartSymbol());
    Symbol endsymbol = _tsymbols.getSymbol("EOF");

    for (int i = 0; i < startlist.getSize(); i++)
      I.addItem(startlist.get(i), 0, endsymbol);

    C.add(I.closure());
View Full Code Here

    if (_logger!=null)
      _logger.debug("Grammar:"+_grammar);

    // symbol for the end of file
    Symbol endsymbol = _tsymbols.getSymbol("EOF");

    // for alle terminal symbols
    for (i = 0; i < _tsymbols.getSymbolCount(); i++)
      _table.setTerminalSymbol(i, _tsymbols.getSymbol(i).getName());
View Full Code Here

    IntegerList productions = _grammar.getProductionList().getProductionList(symbol);
    SymbolList examined = new SymbolList(true); // List of all examined symbols
    SymbolList productiondefinition, newfirstset;
    boolean foundEMPTY;
    int i, j, k; // index variables
    Symbol newsymbol;

    for (i = 0; i < productions.getSize(); i++)
    {
      productiondefinition = _grammar.getProductionList().getProduction(
        productions.get(i)).getDefinition();
      if (productiondefinition.getSymbolCount() == 0)
      {
        // Symbol for a empty firstset added
        firstset.addSymbol(EmptySymbol.EMPTY);
      }
      else
      {
        // for every symbol in the production
        j = 0;
        do
        {
          foundEMPTY = true;
          newsymbol = productiondefinition.getSymbol(j);
          if (newsymbol.isTerminal())
          {
            // if a terminal symbol
            firstset.addSymbol(newsymbol);
          }
          else if (!newsymbol.equals(symbol))
          {
            // and if a non terminal symbol
            if (!examined.contains(newsymbol))
            {
              newfirstset = first(newsymbol, visited);
              foundEMPTY = newfirstset.contains(EmptySymbol.EMPTY);
              for (k = 0; k < newfirstset.getSymbolCount(); k++)
                if (!newfirstset.getSymbol(k).isEmpty())
                  firstset.addSymbol(newfirstset.getSymbol(k));
              examined.addSymbol(newsymbol);
            }
          }

          j++;
        }
        while ((!newsymbol.isTerminal()) && (foundEMPTY) &&
               (j < productiondefinition.getSymbolCount()) &&
               (!productiondefinition.getSymbol(j - 1).equals(symbol)));
      }
    }
    //System.out.println("Symbol="+symbol.toString()+" beendet");
View Full Code Here

        productions.addProduction(production);
      }
      else if (localName.equals(NONTERMINALSYMBOL_ELEMENT))
      {
        Symbol ntsymbol = (Symbol) stack.pop();
        Production production = (Production) stack.peek();

        production.getDefinition().addSymbol(ntsymbol);
      }
      else if (localName.equals(TERMINALSYMBOL_ELEMENT))
      {
        Symbol tsymbol = (Symbol) stack.pop();
        Production production = (Production) stack.peek();

        production.getDefinition().addSymbol(tsymbol);
      }
      else if (localName.equals(STARTSYMBOL_ELEMENT))
View Full Code Here

TOP

Related Classes of net.sourceforge.chaperon.grammar.symbol.Symbol

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.