Skip to main content
aboutsummaryrefslogtreecommitdiffstats
blob: 3f4f5ab35f79ca636d0db37ab2ed836e4209a496 (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
package org.eclipse.cdt.internal.core.parser;

import java.util.Stack;
/**
 * @author aniefer
 *
 * To change this generated comment edit the template variable "typecomment":
 * Window>Preferences>Java>Templates.
 * To enable and disable the creation of type comments go to
 * Window>Preferences>Java>Code Generation.
 */
public class ParserSymbolTable {

	/**
	 * Constructor for ParserSymbolTable.
	 */
	public ParserSymbolTable() {
		super();
		_compilationUnit = new Declaration();
		push( _compilationUnit );
	}

	public void push( Declaration obj ){
		if( _contextStack.empty() == false )
			obj.setContainingScope( (Declaration) _contextStack.peek() );
		_contextStack.push( obj );
	}
	
	public Declaration pop(){
		return (Declaration) _contextStack.pop();
	}
	
	public Declaration peek(){
		return (Declaration) _contextStack.peek();
	}
	
	public Declaration Lookup( String name ) throws ParserSymbolTableException {
		return ( (Declaration) _contextStack.peek() ).Lookup( -1, name );
	}
	
	public Declaration ElaboratedLookup( int type, String name ) throws ParserSymbolTableException{
		return ( (Declaration) _contextStack.peek() ).Lookup( type, name );
	}
	
	public void addDeclaration( Declaration obj ){
		((Declaration) _contextStack.peek() ).addDeclaration( obj );
	}
	
	public Declaration getCompilationUnit(){
		return _compilationUnit;
	}
	
	private Stack _contextStack = new Stack();
	private Declaration _compilationUnit;
}

Back to the top