com.bc.jexp.impl
Class ParserImpl

java.lang.Object
  extended by com.bc.jexp.impl.ParserImpl
All Implemented Interfaces:
Parser

public final class ParserImpl
extends Object
implements Parser

A default implementation for the com.bc.jexp.Parser interface.

Version:
$Revision$ $Date$
Author:
Norman Fomferra (norman.fomferra@brockmann-consult.de)

Constructor Summary
ParserImpl()
          Constructs a new parser instance which uses a DefaultNamespace and type-checking enabled.
ParserImpl(boolean typeChecking)
          Constructs a new parser instance which uses a DefaultNamespace and the given type-checking setting.
ParserImpl(Namespace namespace)
          Constructs a new parser instance which uses the given namespace and type-checking enabled.
ParserImpl(Namespace namespace, boolean typeChecking)
          Constructs a new parser instance which uses the given namespace and the given type-checking setting.
 
Method Summary
 Namespace getDefaultNamespace()
          Gets this parser's default namespace.
 boolean isTypeChecking()
          Gets whether or not this parser performs type checking on expressions.
 Term parse(String code)
          Parses the expression given in the code string.
 Term parse(String code, Namespace namespace)
          Parses the expression given in the code string.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

ParserImpl

public ParserImpl()
Constructs a new parser instance which uses a DefaultNamespace and type-checking enabled.


ParserImpl

public ParserImpl(boolean typeChecking)
Constructs a new parser instance which uses a DefaultNamespace and the given type-checking setting.

Parameters:
typeChecking - if true, the parser performs strong type-checking on expressions

ParserImpl

public ParserImpl(Namespace namespace)
Constructs a new parser instance which uses the given namespace and type-checking enabled.

Parameters:
namespace - the environment used to resolve names.

ParserImpl

public ParserImpl(Namespace namespace,
                  boolean typeChecking)
Constructs a new parser instance which uses the given namespace and the given type-checking setting.

Parameters:
namespace - the environment used to resolve names.
typeChecking - if true, the parser performs type checking on expressions
Method Detail

getDefaultNamespace

public final Namespace getDefaultNamespace()
Gets this parser's default namespace.

Specified by:
getDefaultNamespace in interface Parser
Returns:
the default environment used to resolve names.

isTypeChecking

public boolean isTypeChecking()
Gets whether or not this parser performs type checking on expressions.

Returns:
if true, the parser performs type checking on expressions

parse

public final Term parse(String code)
                 throws ParseException
Parses the expression given in the code string. Names in the code string are resolved using the default namespace.

Specified by:
parse in interface Parser
Parameters:
code - the code string, for the syntax of valid expressions refer to the class description
Throws:
ParseException - if a parse reportError occurs

parse

public final Term parse(String code,
                        Namespace namespace)
                 throws ParseException
Parses the expression given in the code string. Names in the code string are resolved using the given namespace.

Specified by:
parse in interface Parser
Parameters:
code - the code string, for the syntax of valid expressions refer to the class description
namespace - the environment which is used to resolve names
Throws:
ParseException - if a parse error occurs


Copyright © 2002-2012 Brockmann Consult GmbH. All Rights Reserved.