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

ARegExp.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 ARegExp extends PRegExp
{
  private PConcat _concat_;
  private final LinkedList _concats_ = new TypedLinkedList(new Concats_Cast());

  public ARegExp()
  {}

  public ARegExp(
    PConcat _concat_,
    List _concats_)
  {
    setConcat(_concat_);

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

  }

  public ARegExp(
    PConcat _concat_,
    XPRegExpTail _concats_)
  {
    setConcat(_concat_);

    if(_concats_ != null)
    {
      while(_concats_ instanceof X1PRegExpTail)
      {
        this._concats_.addFirst(((X1PRegExpTail) _concats_).getPRegExpTail());
        _concats_ = ((X1PRegExpTail) _concats_).getXPRegExpTail();
      }
      this._concats_.addFirst(((X2PRegExpTail) _concats_).getPRegExpTail());
    }

  }
  public Object clone()
  {
    return new ARegExp(
             (PConcat) cloneNode(_concat_),
             cloneList(_concats_));
  }

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

  public PConcat getConcat()
  {
    return _concat_;
  }

  public void setConcat(PConcat node)
  {
    if(_concat_ != null)
    {
      _concat_.parent(null);
    }

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

      node.parent(this);
    }

    _concat_ = node;
  }

  public LinkedList getConcats()
  {
    return _concats_;
  }

  public void setConcats(List list)
  {
    _concats_.clear();
    _concats_.addAll(list);
  }

  public String toString()
  {
    return ""
           + toString(_concat_)
           + toString(_concats_);
  }

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

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

  }

  void replaceChild(Node oldChild, Node newChild)
  {
    if(_concat_ == oldChild)
    {
      setConcat((PConcat) newChild);
      return;
    }

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

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

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

      return node;
    }
  }
}

Generated by  Doxygen 1.6.0   Back to index