blob: f83f683a7d6857a1c61f02f61aefe137eb64f063 [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 AltRule extends Rule {
private AltRuleDecl _decl;
private AltRuleBody _body;
private GymnastTokenNode _semi;
public AltRuleDecl getDecl() {
return _decl;
}
public AltRuleBody getBody() {
return _body;
}
public GymnastTokenNode getSemi() {
return _semi;
}
/**
* @return the number of children of this ASTNode
*/
public int getChildCount() {
int count = 0;
if (_decl != null) count++;
if (_body != null) count++;
if (_semi != 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 ((_decl != null) && (++count == index)) return _decl;
if ((_body != null) && (++count == index)) return _body;
if ((_semi != null) && (++count == index)) return _semi;
throw new IndexOutOfBoundsException();
}
/**
* Construct a new AltRule.
*/
public AltRule(
AltRuleDecl decl,
AltRuleBody body,
Token semi
) {
super();
if (decl != null) {
_decl = decl;
if (_decl._parent != null) throw new RuntimeException();
_decl._parent = this;
}
if (body != null) {
_body = body;
if (_body._parent != null) throw new RuntimeException();
_body._parent = this;
}
if (semi != null) {
_semi = new GymnastTokenNode(semi);
if (_semi._parent != null) throw new RuntimeException();
_semi._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);
}
}