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

AAlts.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 AAlts extends PAlts
{
  private PAlt _alt_;
  private final LinkedList _alts_ = new TypedLinkedList(new Alts_Cast());

  public AAlts()
  {}

  public AAlts(
    PAlt _alt_,
    List _alts_)
  {
    setAlt(_alt_);

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

  }

  public AAlts(
    PAlt _alt_,
    XPAltsTail _alts_)
  {
    setAlt(_alt_);

    if(_alts_ != null)
    {
      while(_alts_ instanceof X1PAltsTail)
      {
        this._alts_.addFirst(((X1PAltsTail) _alts_).getPAltsTail());
        _alts_ = ((X1PAltsTail) _alts_).getXPAltsTail();
      }
      this._alts_.addFirst(((X2PAltsTail) _alts_).getPAltsTail());
    }

  }
  public Object clone()
  {
    return new AAlts(
             (PAlt) cloneNode(_alt_),
             cloneList(_alts_));
  }

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

  public PAlt getAlt()
  {
    return _alt_;
  }

  public void setAlt(PAlt node)
  {
    if(_alt_ != null)
    {
      _alt_.parent(null);
    }

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

      node.parent(this);
    }

    _alt_ = node;
  }

  public LinkedList getAlts()
  {
    return _alts_;
  }

  public void setAlts(List list)
  {
    _alts_.clear();
    _alts_.addAll(list);
  }

  public String toString()
  {
    return ""
           + toString(_alt_)
           + toString(_alts_);
  }

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

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

  }

  void replaceChild(Node oldChild, Node newChild)
  {
    if(_alt_ == oldChild)
    {
      setAlt((PAlt) newChild);
      return;
    }

    for(ListIterator i = _alts_.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 Alts_Cast implements Cast
  {
    public Object cast(Object o)
    {
      PAltsTail node = (PAltsTail) o;

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

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

      return node;
    }
  }
}

Generated by  Doxygen 1.6.0   Back to index