From 0f1055b8d7f97d86c66fa602c17666bc2ff9c437 Mon Sep 17 00:00:00 2001 From: Constantin Jucovschi Date: Tue, 31 Mar 2009 06:18:54 -0400 Subject: Initial commit --- src/grammar/IndexExpr.java | 50 ++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 50 insertions(+) create mode 100644 src/grammar/IndexExpr.java (limited to 'src/grammar/IndexExpr.java') diff --git a/src/grammar/IndexExpr.java b/src/grammar/IndexExpr.java new file mode 100644 index 0000000..38ba6d4 --- /dev/null +++ b/src/grammar/IndexExpr.java @@ -0,0 +1,50 @@ +package grammar; + +/** IndexExpr + * + * @author Andrei Aiordachioaie + */ +public class IndexExpr implements IParseTreeNode +{ + + String op; + IParseTreeNode e1, e2; + String constant; + String function; + + public IndexExpr(String op, IndexExpr e1, IndexExpr e2) + { + this.op = op; + this.e1 = e1; + this.e2 = e2; + function = "op2"; + } + + public IndexExpr(String constant) + { + function = "constant"; + this.constant = constant; + } + + public IndexExpr(String op, NumericScalarExpr e1) + { + this.op = op; + this.e1 = e1; + function = "op1"; + } + + public String toXML() + { + String result = ""; + String tag1 = "<" + op + ">", tag2 = ""; + if (function.equals("constant")) + result = "" + constant + ""; + else if (function.equals("op1")) + result = tag1 + e1.toXML() + tag2; + else if (function.equals("op2")) + result = tag1 + e1.toXML() + e2.toXML() + tag2; + + return result; + } + +} -- cgit