01: package org.jacorb.idl;
02:
03: /*
04: * JacORB - a free Java ORB
05: *
06: * Copyright (C) 1997-2004 Gerald Brose.
07: *
08: * This library is free software; you can redistribute it and/or
09: * modify it under the terms of the GNU Library General Public
10: * License as published by the Free Software Foundation; either
11: * version 2 of the License, or (at your option) any later version.
12: *
13: * This library is distributed in the hope that it will be useful,
14: * but WITHOUT ANY WARRANTY; without even the implied warranty of
15: * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
16: * Library General Public License for more details.
17: *
18: * You should have received a copy of the GNU Library General Public
19: * License along with this library; if not, write to the Free
20: * Software Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
21: */
22:
23: /**
24: * Represents positive integer constants, used in array sizes and
25: * sequence bounds declarations.
26: *
27: * @author Gerald Brose
28: * @version $Id: PosIntConst.java,v 1.14 2006/06/26 14:37:44 alphonse.bendt Exp $
29: */
30:
31: public class PosIntConst extends IdlSymbol {
32: private int value = -1;
33: ConstExpr const_expr;
34:
35: public PosIntConst(int num) {
36: super (num);
37: }
38:
39: void setExpression(ConstExpr const_expr) {
40: this .const_expr = const_expr;
41: }
42:
43: public void parse() {
44: const_expr.parse();
45: }
46:
47: public int value() {
48: if (value == -1) {
49: value = const_expr.pos_int_const();
50: if (value <= 0) {
51: lexer.restorePosition(myPosition);
52: parser.fatal_error(
53: "Integer constant value must be greater 0.",
54: token);
55: }
56: }
57: return value;
58: }
59:
60: public String toString() {
61: return const_expr.toString();
62: }
63:
64: public void setPackage(String s) {
65: s = parser.pack_replace(s);
66: if (pack_name.length() > 0) {
67: pack_name = s + "." + pack_name;
68: } else {
69: pack_name = s;
70: }
71: const_expr.setPackage(s);
72: }
73: }
|