Skip to main content
aboutsummaryrefslogtreecommitdiffstats
blob: 9168669d0cebba2a4632497feb8bd63a8261f7d9 (plain) (blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
/*******************************************************************************
 * 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 Option extends GymnastASTNode  {


	private Id _name;
	private GymnastTokenNode _equals;
	private OptionValue _value;
	private GymnastTokenNode _semi;

	public Id getName() {
		return _name;
	}
	public GymnastTokenNode getEquals() {
		return _equals;
	}
	public OptionValue getValue() {
		return _value;
	}
	public GymnastTokenNode getSemi() {
		return _semi;
	}


	/**
	 * @return the number of children of this ASTNode
	 */
	public int getChildCount() {
		int count = 0;
		if (_name != null) count++;
		if (_equals != null) count++;
		if (_value != 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 ((_name != null) && (++count == index)) return _name;
		if ((_equals != null) && (++count == index)) return _equals;
		if ((_value != null) && (++count == index)) return _value;
		if ((_semi != null) && (++count == index)) return _semi;

		throw new IndexOutOfBoundsException();
	}
	
	/**
	 * Construct a new Option.
	 */
	public Option(
		Id name,
		Token equals,
		OptionValue value,
		Token semi
	) {
		super();

		if (name != null) {
			_name = name;
			if (_name._parent != null) throw new RuntimeException();
			_name._parent = this;
		}
		if (equals != null) {
			_equals = new GymnastTokenNode(equals);
			if (_equals._parent != null) throw new RuntimeException();
			_equals._parent = this;
		}
		if (value != null) {
			_value = value;
			if (_value._parent != null) throw new RuntimeException();
			_value._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);
	}

}

Back to the top