Logo Search packages:      
Sourcecode: sablecc version File versions  Download package

AProductions.java

/* This file was generated by SableCC (http://www.sablecc.org/). */

package org.sablecc.sablecc.node;

import java.util.*;
import org.sablecc.sablecc.analysis.*;

public final class AProductions extends PProductions
{
  private TProductions _productions_;
  private final LinkedList _prods_ = new TypedLinkedList(new Prods_Cast());

  public AProductions()
  {}

  public AProductions(
    TProductions _productions_,
    List _prods_)
  {
    setProductions(_productions_);

    {
      this._prods_.clear();
      this._prods_.addAll(_prods_);
    }

  }

  public AProductions(
    TProductions _productions_,
    XPProd _prods_)
  {
    setProductions(_productions_);

    if(_prods_ != null)
    {
      while(_prods_ instanceof X1PProd)
      {
        this._prods_.addFirst(((X1PProd) _prods_).getPProd());
        _prods_ = ((X1PProd) _prods_).getXPProd();
      }
      this._prods_.addFirst(((X2PProd) _prods_).getPProd());
    }

  }
  public Object clone()
  {
    return new AProductions(
             (TProductions) cloneNode(_productions_),
             cloneList(_prods_));
  }

  public void apply(Switch sw)
  {
    ((Analysis) sw).caseAProductions(this);
  }

  public TProductions getProductions()
  {
    return _productions_;
  }

  public void setProductions(TProductions node)
  {
    if(_productions_ != null)
    {
      _productions_.parent(null);
    }

    if(node != null)
    {
      if(node.parent() != null)
      {
        node.parent().removeChild(node);
      }

      node.parent(this);
    }

    _productions_ = node;
  }

  public LinkedList getProds()
  {
    return _prods_;
  }

  public void setProds(List list)
  {
    _prods_.clear();
    _prods_.addAll(list);
  }

  public String toString()
  {
    return ""
           + toString(_productions_)
           + toString(_prods_);
  }

  void removeChild(Node child)
  {
    if(_productions_ == child)
    {
      _productions_ = null;
      return;
    }

    if(_prods_.remove(child))
    {
      return;
    }

  }

  void replaceChild(Node oldChild, Node newChild)
  {
    if(_productions_ == oldChild)
    {
      setProductions((TProductions) newChild);
      return;
    }

    for(ListIterator i = _prods_.listIterator(); i.hasNext();)
    {
      if(i.next() == oldChild)
      {
        if(newChild != null)
        {
          i.set(newChild);
          oldChild.parent(null);
          return;
        }

        i.remove();
        oldChild.parent(null);
        return;
      }
    }

  }

  private class Prods_Cast implements Cast
  {
    public Object cast(Object o)
    {
      PProd node = (PProd) o;

      if((node.parent() != null) &&
          (node.parent() != AProductions.this))
      {
        node.parent().removeChild(node);
      }

      if((node.parent() == null) ||
          (node.parent() != AProductions.this))
      {
        node.parent(AProductions.this);
      }

      return node;
    }
  }
}

Generated by  Doxygen 1.6.0   Back to index