com.jstatcom.parser
Class NumberRangeParser

java.lang.Object
  extended by com.jstatcom.parser.NumberRangeParser
All Implemented Interfaces:
NumberRangeParserConstants

public class NumberRangeParser
extends java.lang.Object
implements NumberRangeParserConstants

Parser that assembles number range objects from an input string, for example

[1,100]
(-Infinity,Infinity)
[lowerBound",20)
(-Infinity, upperBound]
[1.2,1.2]
(-1.3e-2,1.3e-2)

One can use the parser via the parseString, parseStringToRange methods. If parseString is used, symbol names may be specified for the bounds. Valid symbol names start with a non digit and may contain letters, digits and "_" . Reserved keywords are ("+" | "-")? "Infinity" and "NaN" (all case insensititve). If a bound is specified as "NaN", the parser throws an exception. If parseStringToRange is used, only numbers are allowed for the bounds, not symbol names.

The parser has been generated with javacc.

Author:
Markus Kraetzig
See Also:
NumberRange

Field Summary
 Token jj_nt
           
 Token token
           
 NumberRangeParserTokenManager token_source
           
 
Fields inherited from interface com.jstatcom.parser.NumberRangeParserConstants
CONSTANT, DEFAULT, DELIM, DIGIT, EOF, EOL, FLOAT, INTEGER, LEFT_BRACKET, LETTER, MINUS, NAN, NEG_INF, POS_INF, RIGHT_BRACKET, SYMBOL_NAME, tokenImage
 
Constructor Summary
NumberRangeParser()
          Default constructor.
NumberRangeParser(java.io.InputStream stream)
           
NumberRangeParser(NumberRangeParserTokenManager tm)
           
NumberRangeParser(java.io.Reader stream)
           
 
Method Summary
 void disable_tracing()
           
 void enable_tracing()
           
 ParseException generateParseException()
           
 Token getNextToken()
           
 Token getToken(int index)
           
 void leftBracket()
           
 void lowerBound_noSymbols()
           
 void lowerBound()
           
static void main(java.lang.String[] args)
           
 java.lang.Object[] parseString(java.lang.String inputString)
          Reinitializes this engine and parses an input string.
 NumberRange parseStringToRange(java.lang.String inputString)
          Reinitializes this engine and parses an input string.
 void ReInit(java.io.InputStream stream)
           
 void ReInit(NumberRangeParserTokenManager tm)
           
 void ReInit(java.io.Reader stream)
           
 void rightBracket()
           
 int toeval_noSymbols()
          Parses the expression allowing only for numbers.
 int toeval()
          Parses the expression allowing for symbol names as well as numbers.
 void upperBound_noSymbols()
           
 void upperBound()
           
 
Methods inherited from class java.lang.Object
equals, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

token_source

public NumberRangeParserTokenManager token_source

token

public Token token

jj_nt

public Token jj_nt
Constructor Detail

NumberRangeParser

public NumberRangeParser()
Default constructor.


NumberRangeParser

public NumberRangeParser(NumberRangeParserTokenManager tm)

NumberRangeParser

public NumberRangeParser(java.io.InputStream stream)

NumberRangeParser

public NumberRangeParser(java.io.Reader stream)
Method Detail

disable_tracing

public final void disable_tracing()

enable_tracing

public final void enable_tracing()

generateParseException

public final ParseException generateParseException()

getNextToken

public final Token getNextToken()

getToken

public final Token getToken(int index)

leftBracket

public final void leftBracket()
                       throws ParseException
Throws:
ParseException

lowerBound

public final void lowerBound()
                      throws ParseException
Throws:
ParseException

lowerBound_noSymbols

public final void lowerBound_noSymbols()
                                throws ParseException
Throws:
ParseException

main

public static void main(java.lang.String[] args)
                 throws ParseException
Throws:
ParseException

parseString

public java.lang.Object[] parseString(java.lang.String inputString)
                               throws ParseException,
                                      TokenMgrError
Reinitializes this engine and parses an input string. In this parser run numbers as well as symbol names are allowed for the bounds specification.

Valid symbol names start with a non digit and may contain letters, digits and "_" . Reserved keywords are ("+" | "-")? "Infinity" and "NaN" (all case insensititve). If a bound is specified as "NaN", the parser throws an exception, because this stands usually for missing value.

Parameters:
inputString - the string to parse
Returns:
object array (3 x 1) if parser and assembly where successful,
object[0] = lower bound
object[1] = upper bound
object[2] = range type
Throws:
ParseException - if parsing failed, contains error description
TokenMgrError - if tokenizing failed, contains error description

parseStringToRange

public NumberRange parseStringToRange(java.lang.String inputString)
                               throws ParseException,
                                      TokenMgrError
Reinitializes this engine and parses an input string. In this parser run, symbol names are not allowed for the bounds specification, only numbers with ("+" | "-")? "Infinity" as possible identifiers.

Parameters:
inputString - the string to parse
Returns:
a number range if parser and assembly where successful
Throws:
ParseException - if parsing failed, contains error description
TokenMgrError - if tokenizing failed, contains error description

ReInit

public void ReInit(NumberRangeParserTokenManager tm)

ReInit

public void ReInit(java.io.InputStream stream)

ReInit

public void ReInit(java.io.Reader stream)

rightBracket

public final void rightBracket()
                        throws ParseException
Throws:
ParseException

toeval

public final int toeval()
                 throws ParseException
Parses the expression allowing for symbol names as well as numbers.

Throws:
ParseException

toeval_noSymbols

public final int toeval_noSymbols()
                           throws ParseException
Parses the expression allowing only for numbers.

Throws:
ParseException

upperBound

public final void upperBound()
                      throws ParseException
Throws:
ParseException

upperBound_noSymbols

public final void upperBound_noSymbols()
                                throws ParseException
Throws:
ParseException