~ubuntu-branches/ubuntu/gutsy/jflex/gutsy

« back to all changes in this revision

Viewing changes to examples/interpreter/Tparlist.java

  • Committer: Bazaar Package Importer
  • Author(s): Takashi Okamoto
  • Date: 2002-02-16 13:38:21 UTC
  • Revision ID: james.westby@ubuntu.com-20020216133821-5wsdprpt9xl7ondr
Tags: upstream-1.3.5
ImportĀ upstreamĀ versionĀ 1.3.5

Show diffs side-by-side

added added

removed removed

Lines of Context:
 
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 parameter list.
 
24
 */ 
 
25
class Tparlist implements AST {
 
26
  Tparlist parlist;           // rest of the liste (optional null)
 
27
  Tident ident;               // identifier
 
28
 
 
29
  public Tparlist(Tparlist p, Tident i) {
 
30
    parlist=p;
 
31
    ident=i;
 
32
  }
 
33
 
 
34
  public Tparlist(Tident i) {
 
35
    parlist=null;
 
36
    ident=i;
 
37
  }
 
38
 
 
39
  public String toString() {
 
40
    if (parlist!=null) 
 
41
      return parlist+","+ident;
 
42
    else 
 
43
      return ident.toString();
 
44
  }
 
45
 
 
46
  public void setSymtab(SymTab st, boolean isInput, int index) {
 
47
    boolean isNew = st.enter(ident.toString(),
 
48
                             new STEvar(ident.toString(), isInput, index));
 
49
    
 
50
    if (!isNew) Main.error("Variable "+ident+" defined twice!");
 
51
    if (parlist!=null) parlist.setSymtab(st, isInput, index+1);
 
52
  }
 
53
}
 
54