KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > Tnumber


1 /* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * *
2  * Copyright (C) 2001 Gerwin Klein <lsf@jflex.de> *
3  * Copyright (C) 2001 Bernhard Rumpe <rumpe@in.tum.de> *
4  * All rights reserved. *
5  * *
6  * This program is free software; you can redistribute it and/or modify *
7  * it under the terms of the GNU General Public License. See the file *
8  * COPYRIGHT for more information. *
9  * *
10  * This program is distributed in the hope that it will be useful, *
11  * but WITHOUT ANY WARRANTY; without even the implied warranty of *
12  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the *
13  * GNU General Public License for more details. *
14  * *
15  * You should have received a copy of the GNU General Public License along *
16  * with this program; if not, write to the Free Software Foundation, Inc., *
17  * 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA *
18  * *
19  * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * */

20
21
22 /**
23  * AST node for a number
24  */

25 class Tnumber extends Texp implements AST {
26   int n; // value of the number
27

28   public Tnumber(String JavaDoc s) {
29     try { n = Integer.parseInt(s); }
30     catch (NumberFormatException JavaDoc e) { n=-1; };
31   }
32
33   public String JavaDoc toString() {
34     return(""+n);
35   }
36
37   public void checkcontext(SymTab st) {
38   }
39
40   public void prepInterp(SymTab st) {
41   }
42
43   public int interpret(int[] in, int[] par) {
44     return(n);
45   }
46 }
47
48
Popular Tags