net.sf.jga.parser
Class FunctorParser

java.lang.Object
  extended by net.sf.jga.parser.FunctorParser
All Implemented Interfaces:
FunctorParserConstants
Direct Known Subclasses:
GenericParser

public class FunctorParser
extends java.lang.Object
implements FunctorParserConstants

Parser that converts java-like expressions into functors.


Field Summary
static java.lang.String[] ARG_NAME
           
 Token jj_nt
           
 boolean lookingAhead
           
 Token token
           
 FunctorParserTokenManager token_source
           
 
Fields inherited from interface net.sf.jga.parser.FunctorParserConstants
CHARACTER_LITERAL, DECIMAL_LITERAL, DEFAULT, DIGIT, EOF, EXPONENT, FALSE, FLOATING_POINT_LITERAL, HEX_LITERAL, IDENTIFIER, INTEGER_LITERAL, LETTER, LPAREN, NEW, NULL, OCTAL_LITERAL, STRING_LITERAL, tokenImage, TRUE
 
Constructor Summary
FunctorParser(FunctorParserTokenManager tm)
           
FunctorParser(java.io.InputStream stream)
           
FunctorParser(java.io.Reader stream)
           
 
Method Summary
protected  FunctorRef checkReservedNames(java.lang.String name)
          Allows for functor names to be added to the grammar.
 java.lang.Class getReturnType()
          Returns the type of object returned by the last functor parsed.
 BinaryFunctor parseBinary(java.lang.Class arg1Type, java.lang.Class arg2Type)
          Parses the current input to create a BinaryFunctor that takes arguments of the given types.
 BinaryFunctor parseBinary(java.lang.String str, java.lang.Class arg1Type, java.lang.Class arg2Type)
          Parses the string to create a BinaryFunctor that takes arguments of the given types.
 Generator parseGenerator()
          Parses the contents of the current input to create a Generator
 Generator parseGenerator(java.lang.String str)
          Parses the string to create a Generator.
 UnaryFunctor parseUnary(java.lang.Class argType)
          Parses the current input to create a UnaryFunctor that takes an argument of the given type.
 UnaryFunctor parseUnary(java.lang.String str, java.lang.Class argType)
          Parses the string to create a UnaryFunctor that takes an argument of the given type.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

ARG_NAME

public static final java.lang.String[] ARG_NAME

token_source

public FunctorParserTokenManager token_source

token

public Token token

jj_nt

public Token jj_nt

lookingAhead

public boolean lookingAhead
Constructor Detail

FunctorParser

public FunctorParser(java.io.InputStream stream)

FunctorParser

public FunctorParser(java.io.Reader stream)

FunctorParser

public FunctorParser(FunctorParserTokenManager tm)
Method Detail

main

public static void main(java.lang.String[] args)

importClasses

public void importClasses(java.util.ResourceBundle classmap)
Configures a set of classnames such that the parser can refer to them without their full package names. This is the functional equivalent of a set of import statements. The keys of this resource bundle must be Stringscontaining the name of the class within its package, and the values may be either Strings containing the fully qualified classnames or the corresponding Class objects.

Classes in the java.lang package are imported by default, and they will not be looked up in the resource bundle passed to this method.


checkReservedNames

protected FunctorRef checkReservedNames(java.lang.String name)
                                 throws ParseException
Allows for functor names to be added to the grammar.

Throws:
ParseException

parseGenerator

public Generator parseGenerator(java.lang.String str)
                         throws ParseException
Parses the string to create a Generator.

Throws:
ParseException

parseGenerator

public Generator parseGenerator()
                         throws ParseException
Parses the contents of the current input to create a Generator

Throws:
ParseException

parseUnary

public UnaryFunctor parseUnary(java.lang.String str,
                               java.lang.Class argType)
                        throws ParseException
Parses the string to create a UnaryFunctor that takes an argument of the given type.

Throws:

parseUnary

public UnaryFunctor parseUnary(java.lang.Class argType)
                        throws ParseException
Parses the current input to create a UnaryFunctor that takes an argument of the given type.

Throws:
ParseException

parseBinary

public BinaryFunctor parseBinary(java.lang.String str,
                                 java.lang.Class arg1Type,
                                 java.lang.Class arg2Type)
                          throws ParseException
Parses the string to create a BinaryFunctor that takes arguments of the given types.

Throws:
ParseException

parseBinary

public BinaryFunctor parseBinary(java.lang.Class arg1Type,
                                 java.lang.Class arg2Type)
                          throws ParseException
Parses the current input to create a BinaryFunctor that takes arguments of the given types.

Throws:
ParseException

getReturnType

public java.lang.Class getReturnType()
Returns the type of object returned by the last functor parsed.

Throws:
java.lang.IllegalStateException - if the parser has not been used or if parsing the last functor resulted in an exception being thrown.



Copyright © 2002-2004 David A. Hall. All Rights Reserved.