// $ANTLR 2.7.4: "boolean.g" -> "BooleanAntlrTree.java"$
package org.jostraca.util;
import org.jostraca.comp.antlr.TreeParser;
import org.jostraca.comp.antlr.Token;
import org.jostraca.comp.antlr.collections.AST;
import org.jostraca.comp.antlr.RecognitionException;
import org.jostraca.comp.antlr.ANTLRException;
import org.jostraca.comp.antlr.NoViableAltException;
import org.jostraca.comp.antlr.MismatchedTokenException;
import org.jostraca.comp.antlr.SemanticException;
import org.jostraca.comp.antlr.collections.impl.BitSet;
import org.jostraca.comp.antlr.ASTPair;
import org.jostraca.comp.antlr.collections.impl.ASTArray;
public class BooleanAntlrTree extends org.jostraca.comp.antlr.TreeParser implements BooleanAntlrLexerTokenTypes
{
public BooleanAntlrTree() {
tokenNames = _tokenNames;
}
public final boolean expr(AST _t) throws RecognitionException {
boolean r;
AST expr_AST_in = (_t == ASTNULL) ? null : (AST)_t;
boolean a,b;
r = false;
try { // for error handling
if (_t==null) _t=ASTNULL;
switch ( _t.getType()) {
case XOR:
{
AST __t31 = _t;
AST tmp1_AST_in = (AST)_t;
match(_t,XOR);
_t = _t.getFirstChild();
a=expr(_t);
_t = _retTree;
b=expr(_t);
_t = _retTree;
_t = __t31;
_t = _t.getNextSibling();
r = !(a && b) && (a || b);
break;
}
case OR:
{
AST __t32 = _t;
AST tmp2_AST_in = (AST)_t;
match(_t,OR);
_t = _t.getFirstChild();
a=expr(_t);
_t = _retTree;
b=expr(_t);
_t = _retTree;
_t = __t32;
_t = _t.getNextSibling();
r = a || b;
break;
}
case AND:
{
AST __t33 = _t;
AST tmp3_AST_in = (AST)_t;
match(_t,AND);
_t = _t.getFirstChild();
a=expr(_t);
_t = _retTree;
b=expr(_t);
_t = _retTree;
_t = __t33;
_t = _t.getNextSibling();
r = a && b;
break;
}
case NOT:
{
AST __t34 = _t;
AST tmp4_AST_in = (AST)_t;
match(_t,NOT);
_t = _t.getFirstChild();
a=expr(_t);
_t = _retTree;
_t = __t34;
_t = _t.getNextSibling();
r = !a;
break;
}
case TRUE:
{
AST tmp5_AST_in = (AST)_t;
match(_t,TRUE);
_t = _t.getNextSibling();
r = true;
break;
}
case FALSE:
{
AST tmp6_AST_in = (AST)_t;
match(_t,FALSE);
_t = _t.getNextSibling();
r = false;
break;
}
default:
{
throw new NoViableAltException(_t);
}
}
}
catch (RecognitionException ex) {
reportError(ex);
if (_t!=null) {_t = _t.getNextSibling();}
}
_retTree = _t;
return r;
}
public static final String[] _tokenNames = {
"<0>",
"EOF",
"<2>",
"NULL_TREE_LOOKAHEAD",
"TRUE",
"FALSE",
"AND",
"OR",
"XOR",
"NOT",
"LP",
"RP",
"WS"
};
}