blob: 1b9c6ded7519739de5f133d507a8ba536e9ecbb0 [file] [log] [blame]
/*******************************************************************************
* Copyright (c) 2004, 2006 IBM Corporation and others.
* All rights reserved. This program and the accompanying materials
* are made available under the terms of the Eclipse Public License v1.0
* which accompanies this distribution, and is available at
* http://www.eclipse.org/legal/epl-v10.html
*
* Contributors:
* IBM Corporation - initial API and implementation
*******************************************************************************/
package org.eclipse.gymnast.generator.core.ast;
import org.eclipse.gymnast.runtime.core.ast.ASTNode;
import antlr.Token;
/**
*
* @generated by Gymnast from gymnast.ast on Aug 15, 2004 2:28:15 PM
*/
public class OptSubSeq extends Expr {
private GymnastTokenNode _lparen;
private Seq _seq;
private GymnastTokenNode _rparen;
private GymnastTokenNode _qmark;
public GymnastTokenNode getLparen() {
return _lparen;
}
public Seq getSeq() {
return _seq;
}
public GymnastTokenNode getRparen() {
return _rparen;
}
public GymnastTokenNode getQmark() {
return _qmark;
}
/**
* @return the number of children of this ASTNode
*/
public int getChildCount() {
int count = 0;
if (_lparen != null) count++;
if (_seq != null) count++;
if (_rparen != null) count++;
if (_qmark != null) count++;
return count;
}
/**
* @param index the index of a child ASTNode to get
* @return the child ASTNode at the given index
* @throws IndexOutOfBoundsException when the index is out of bounds
*/
public ASTNode getChild(int index) {
int count = -1;
if ((_lparen != null) && (++count == index)) return _lparen;
if ((_seq != null) && (++count == index)) return _seq;
if ((_rparen != null) && (++count == index)) return _rparen;
if ((_qmark != null) && (++count == index)) return _qmark;
throw new IndexOutOfBoundsException();
}
/**
* Construct a new OptSubSeq.
*/
public OptSubSeq(
Token lparen,
Seq seq,
Token rparen,
Token qmark
) {
super();
if (lparen != null) {
_lparen = new GymnastTokenNode(lparen);
if (_lparen._parent != null) throw new RuntimeException();
_lparen._parent = this;
}
if (seq != null) {
_seq = seq;
if (_seq._parent != null) throw new RuntimeException();
_seq._parent = this;
}
if (rparen != null) {
_rparen = new GymnastTokenNode(rparen);
if (_rparen._parent != null) throw new RuntimeException();
_rparen._parent = this;
}
if (qmark != null) {
_qmark = new GymnastTokenNode(qmark);
if (_qmark._parent != null) throw new RuntimeException();
_qmark._parent = this;
}
}
/**
* This method overrides the superclass <code>acceptImpl</code> providing
* the same implementation. Here <code>this</code> refers to this specific node
* class, so the <code>beginVisit</code> and <code>endVisit</code> methods
* specific to this type in the visitor will be invoked.
*/
public void acceptImpl(GymnastASTNodeVisitor visitor) {
boolean visitChildren = visitor.beginVisit(this);
if (visitChildren) visitChildren(visitor);
visitor.endVisit(this);
}
}