source: other-projects/rsyntax-textarea/devel-packages/jflex-1.4.3/examples/interpreter/Tboolexp.java@ 25584

Last change on this file since 25584 was 25584, checked in by davidb, 12 years ago

Initial cut an a text edit area for GLI that supports color syntax highlighting

File size: 2.3 KB
Line 
1/* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * *
2 * Copyright (C) 2001 Gerwin Klein <[email protected]> *
3 * Copyright (C) 2001 Bernhard Rumpe <[email protected]> *
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 bool expressions
24 */
25class Tboolexp implements AST {
26 Texp exp1, exp2; // left and right subexpression
27 char kind; // '=', '<' and '!' for "<="
28
29 public Tboolexp(Texp e1, char k, Texp e2) {
30 exp1=e1;
31 kind=k;
32 exp2=e2;
33 }
34
35 public String toString() {
36 if (kind!='!')
37 return(""+exp1+kind+exp2);
38 else
39 return(exp1+"<="+exp2);
40 }
41
42 public void checkcontext(SymTab st) { // context conditions
43 exp1.checkcontext(st);
44 exp2.checkcontext(st);
45 }
46
47 public void prepInterp(SymTab st) { // set pointers and indices
48 exp1.prepInterp(st);
49 exp2.prepInterp(st);
50 }
51
52 public boolean interpret(int[] in, int[] par) {
53 int e1 = exp1.interpret(in,par);
54 int e2 = exp2.interpret(in,par);
55 switch(kind) {
56 case '=': return(e1==e2);
57 case '<': return(e1<e2);
58 case '!': return(e1<=e2);
59 }
60
61 return(false); // error
62 }
63}
64
Note: See TracBrowser for help on using the repository browser.