source: trunk/yao/share/antlr-2.7.7/examples/java/pascal/IntegerConstant.java @ 1

Last change on this file since 1 was 1, checked in by lnalod, 15 years ago

Initial import of YAO sources

File size: 871 bytes
Line 
1/** The symbol table representation of CONST i=3; You would
2 *  create new IntegerConstant("i", 3)
3 */
4public class IntegerConstant extends Constant {
5        protected int value;
6
7        public IntegerConstant(String name, int value) {
8                super(name);
9                setValue(value);
10                setType(PascalParser.symbolTable.getPredefinedType("integer"));
11        }
12
13        public IntegerConstant(String svalue) {
14                this(null,svalue);
15        }
16
17        public IntegerConstant(String name, String svalue) {
18                super(name);
19                setType(PascalParser.symbolTable.getPredefinedType("integer"));
20                int v = 0;
21                try {
22                        v = Integer.parseInt(svalue);
23                }
24                catch (NumberFormatException nfe) {
25                        ;
26                }
27                setValue(v);
28        }
29
30        public int getValue() {
31                return value;
32        }
33
34        public void setValue(int value) {
35                this.value = value;
36        }
37
38        public String toString() {
39                return super.toString()+"="+value;
40        }
41}
Note: See TracBrowser for help on using the repository browser.