KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > Texplist


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 list of expressions.
24  *
25  * The interpretation of a list of expressions stores the
26  * results of the expressions in an array that can be used
27  * as parameter list for function calls.
28  */

29 class Texplist implements AST {
30   Texplist explist; // next list element (optional null)
31
Texp exp; // expression of this list node
32

33   public Texplist(Texplist p, Texp e) {
34     explist=p;
35     exp=e;
36   }
37
38   public Texplist(Texp e) {
39     explist=null;
40     exp=e;
41   }
42
43   public String JavaDoc toString() {
44     if (explist!=null)
45       return explist+","+exp;
46     else
47       return exp.toString();
48   }
49
50   public void checkcontext(SymTab st) {
51     if (explist!=null)
52       explist.checkcontext(st);
53     exp.checkcontext(st); // CoCo (DefFun,DefVar,Arity)
54
} // in expression
55

56   public int length() {
57     if (explist!=null)
58       return 1+explist.length();
59     else
60       return 1;
61   }
62   
63   public void prepInterp(SymTab st) { // set pointers and indices
64
exp.prepInterp(st);
65     if (explist!=null) explist.prepInterp(st);
66   }
67   
68   public void interpret(int[] in, int[] par, int[] res, int index) {
69     res[index] = exp.interpret(in,par);
70     if (explist!=null) explist.interpret(in,par,res,index+1);
71   }
72 }
73
74
Popular Tags