/*
* Name: BooleanParser
* Author: Richard Rodger
*
* Copyright (c) 2000-2004 Richard Rodger
*
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published
* by the Free Software Foundation; either version 2 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program; if not, write to the Free Software
* Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
*
*/
// package
package org.jostraca.util;
// import
import org.jostraca.comp.antlr.CommonAST;
import java.io.StringReader;
import java.io.Reader;
/** */
public class BooleanParser {
// public static
// public methods
public static final boolean parse( String pBooleanExpr ) throws Exception {
StringReader booleanExprReader = new StringReader( pBooleanExpr );
return parse( booleanExprReader );
}
public static final boolean parse( Reader pReader ) throws Exception {
BooleanAntlrLexer lexer = new BooleanAntlrLexer( pReader );
BooleanAntlrParser parser = new BooleanAntlrParser( lexer );
parser.expr();
CommonAST ast = (CommonAST) parser.getAST();
BooleanAntlrTree tree = new BooleanAntlrTree();
return tree.expr( ast );
}
public static final CommonAST tree( String pBooleanExpr ) throws Exception {
StringReader booleanExprReader = new StringReader( pBooleanExpr );
return tree( booleanExprReader );
}
public static final CommonAST tree( Reader pReader ) throws Exception {
BooleanAntlrLexer lexer = new BooleanAntlrLexer( pReader );
BooleanAntlrParser parser = new BooleanAntlrParser( lexer );
parser.expr();
CommonAST ast = (CommonAST) parser.getAST();
return ast;
}
}