01: /*
02: * JacORB - a free Java ORB
03: *
04: * Copyright (C) 1997-2004 Gerald Brose.
05: *
06: * This library is free software; you can redistribute it and/or
07: * modify it under the terms of the GNU Library General Public
08: * License as published by the Free Software Foundation; either
09: * version 2 of the License, or (at your option) any later version.
10: *
11: * This library is distributed in the hope that it will be useful,
12: * but WITHOUT ANY WARRANTY; without even the implied warranty of
13: * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
14: * Library General Public License for more details.
15: *
16: * You should have received a copy of the GNU Library General Public
17: * License along with this library; if not, write to the Free
18: * Software Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
19: */
20:
21: package org.jacorb.idl;
22:
23: /**
24: * @author Gerald Brose
25: * @version $Id: SimpleDeclarator.java,v 1.16 2004/05/06 12:39:58 nicolas Exp $
26: */
27:
28: public class SimpleDeclarator extends Declarator {
29: public SimpleDeclarator(int num) {
30: super (num);
31: }
32:
33: public String name() {
34: return name;
35: }
36:
37: /**
38: */
39:
40: public void escapeName() {
41: if (!name.startsWith("_") && lexer.strictJavaEscapeCheck(name)) {
42: name = "_" + name;
43: }
44: }
45:
46: public void parse() {
47: // add sloppy_declarator behavior here....
48: try {
49: NameTable.define(full_name(), "declarator");
50: } catch (NameAlreadyDefined p) {
51: parser.error("Declarator name " + full_name()
52: + " already declared in this scope.", token);
53: }
54: }
55:
56: public void setEnclosingSymbol(IdlSymbol s) {
57: if (enclosing_symbol != null && enclosing_symbol != s)
58: throw new RuntimeException(
59: "Compiler Error: trying to reassign container for "
60: + name);
61: enclosing_symbol = s;
62: }
63:
64: public IdlSymbol getEnclosingSymbol() {
65: return enclosing_symbol;
66: }
67:
68: public void setPackage(String s) {
69: s = parser.pack_replace(s);
70: if (pack_name.length() > 0)
71: pack_name = s + "." + pack_name;
72: else
73: pack_name = s;
74: }
75:
76: String full_name() {
77: if (name.length() == 0)
78: return null;
79: if (pack_name.length() > 0)
80: return pack_name + "." + name;
81: else
82: return name;
83: }
84:
85: public String toString() {
86: return name;
87: }
88: }
|