Overview | Package | Class | Tree | Deprecated | Index | Help
PREV CLASS NEXT CLASS | FRAMES NO FRAMES
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD

## com.singularsys.jep.configurableparser
Class ConfigurableParser

    java.lang.Object
      com.singularsys.jep.configurableparser.ConfigurableParser

All Implemented Interfaces:
  JepComponent, Parser, java.io.Serializable

Direct Known Subclasses:
  StandardConfigurableParser

    public class ConfigurableParser

extends java.lang.Object
implements Parser

A configurable parser.

See Also:
  Serialized Form

Field Summary
`protected java.util.List<TokenFilter>` | `filters`
`protected java.util.List<GrammarMatcher>` | `g`
`protected Jep` | `jep`
`protected java.util.List<TokenMatcher>` | `m`
`protected OperatorTokenMatcher` | `otm`
`protected SymbolTokenMatcher` | `stm`
`protected Tokenizer` | `tk`

Constructor Summary
`ConfigurableParser()` Create a configurable parser with no matchers set.

Method Summary
`GrammarMatcher` | `addArrayAccessMatcher(java.lang.String open, java.lang.String close)` Matches array access: a[3]
`GrammarMatcher` | `addBracketMatcher(java.lang.String open, java.lang.String close)` Matches bracketed expressions: (2+3).
`TokenMatcher` | `addDoubleQuoteStrings()` Recognize double quote strings "...".
`TokenMatcher` | `addExponentNumbers()` Recognize numbers with optional exponents, 1.2e3, 1.2E-3, 1.2, 1.
`GrammarMatcher` | `addFunctionMatcher(java.lang.String open, java.lang.String close, java.lang.String sep)` Matches functions: atan2(y,x).
`GrammarMatcher` | `addGrammarMatcher(GrammarMatcher gm)` Adds a GrammarMatcher
`TokenMatcher` | `addHashComments()` Recognize comments of the form #....
`TokenMatcher` | `addIdentifiers()` Adds java-style function and variable names.
`GrammarMatcher` | `addListMatcher(java.lang.String open, java.lang.String close, java.lang.String sep)` Matches vectors/list: [1,2,3]
`GrammarMatcher` | `addListOrBracketMatcher(java.lang.String open, java.lang.String close, java.lang.String sep)` Matches bracketed expressions or lists depending on number of arguments.
`TokenMatcher` | `addOperatorTokenMatcher()` Recognize operators.
`TokenMatcher` | `addSemiColonTerminator()` Adds a matcher which will terminate the parsing process when a semi-colon is encountered.
`TokenMatcher` | `addSimpleNumbers()` Recognize numbers without exponents 1.2.
`TokenMatcher` | `addSingleQuoteStrings()` Recognize single quote strings '...'.
`void` | `addSlashComments()` Recognize comments of the form //...
`TokenMatcher` | `addSymbols(java.lang.String... symbols)` Recognize given symbols.
`TokenFilter` | `addTokenFilter(TokenFilter tf)` Adds a TokenFilter.
`TokenMatcher` | `addTokenMatcher(TokenMatcher tm)` Adds a TokenMatcher.
`TokenMatcher` | `addWhiteSpace()` Recognize java white space characters.
`TokenFilter` | `addWhiteSpaceCommentFilter()` Filter out whitespace and comments between the tokenizing and grammar matching stages.
`Node` | `continueParse()` Parse the next expressions from existing stream.
`java.util.Iterator<Token>` | `filter(java.util.List<Token> input)` Filters the tokens to remove whitespace etc.
`java.util.List<GrammarMatcher>` | `getGrammarMatchers()` Return the list of GrammarMatchers.
`JepComponent` | `getLightWeightInstance()` Returns a light weight instance, suitable for use in multiple evaluation threads.
`TokenMatcher` | `getOperatorTokenMatcher()` Return the OperatorTokenMatcher.
`SymbolToken` | `getSymbolToken(java.lang.String sym)` Return the SymbolToken for the given string.
`SymbolTokenMatcher` | `getSymbolTokenMatcher()` Return the SymbolTokenMatcher.
`java.util.List<TokenFilter>` | `getTokenFilters()` Return the list of filters.
`java.util.List<TokenMatcher>` | `getTokenMatchers()` Return the list of TokenMatchers
`void` | `init(Jep jep)` Initialize the component.
`Node` | `parse(java.util.Iterator<Token> it)` Perform the syntax analysis stage.
`Node` | `parse(java.io.Reader stream)` Parse a single equation.
`void` | `restart(java.io.Reader stream)` Load a new stream to read from.
`java.util.List<Token>` | `scan()` Scan next equations from an existing stream.
`java.util.List<Token>` | `scan(java.io.Reader stream)` Scan the input.
`void` | `setImplicitMultiplicationSymbols(java.lang.String... symbols)` Sets those symbols which can appear on the right hand side of implicit multiplication.

Methods inherited from class java.lang.Object
`clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait`

Field Detail

### m

    protected java.util.List<TokenMatcher> m

### filters

    protected java.util.List<TokenFilter> filters

### g

    protected java.util.List<GrammarMatcher> g

### tk

    protected transient Tokenizer tk

### jep

    protected transient Jep jep

### otm

    protected OperatorTokenMatcher otm

### stm

    protected SymbolTokenMatcher stm

Constructor Detail

### ConfigurableParser

    public ConfigurableParser()

  Create a configurable parser with no matchers set.

Method Detail

### init

    public void init(Jep jep)

  Description copied from interface: `JepComponent`
  Initialize the component. This methods is called whenever a component is added to Jep. Hence it allows components to keep track of the other components they may rely on.

  Specified by:
    `init` in interface `JepComponent`
  Parameters:
    `jep` - the current Jep instance

### parse

    public Node parse(java.io.Reader stream)
               throws ParseException

  Parse a single equation.

  Specified by:
    `parse` in interface `Parser`
  Parameters:
    `stream` - the input stream to read from
  Returns:
    top node of the expression
  Throws:
    `ParseException` - if an error in the input or an empty expression

### restart

    public void restart(java.io.Reader stream)

  Load a new stream to read from.

  Specified by:
    `restart` in interface `Parser`
  See Also:
    `continueParse()`

### continueParse

    public Node continueParse()
                       throws ParseException

  Parse the next expressions from existing stream. Empty expressions such as ;; are silently ignored.

  Specified by:
    `continueParse` in interface `Parser`
  Returns:
    top node of the expression or null at end of file
  Throws:
    `ParseException`
  See Also:
    `restart(java.io.Reader)`

### scan

    public java.util.List<Token> scan(java.io.Reader stream)
                               throws ParseException

  Scan the input. Just perform the tokenizing stage. Not for normal use.

  Parameters:
    `stream` -
  Returns:
    a list of tokens, including white space and comments, null at end of input. An empty list is returned for empty equations.
  Throws:
    `ParseException`

### scan

    public java.util.List<Token> scan()
                               throws ParseException

  Scan next equations from an existing stream. Not for normal use.

  Returns:
    List of tokens, including white space and comments, null at end of input. An empty list is returned for empty equations.
  Throws:
    `ParseException`

### filter

    public java.util.Iterator<Token> filter(java.util.List<Token> input)
                                     throws ParseException

  Filters the tokens to remove whitespace etc. Not for normal use.

  Parameters:
    `input` -
  Returns:
    and iterator with the filtered tokens
  Throws:
    `ParseException`

### parse

    public Node parse(java.util.Iterator<Token> it)
               throws ParseException

  Perform the syntax analysis stage. Not for normal used.

  Parameters:
    `it` - an iterator with a list of tokens
  Returns:
    top node of the parsed expression
  Throws:
    `ParseException`

### getLightWeightInstance

    public JepComponent getLightWeightInstance()

  Returns a light weight instance, suitable for use in multiple evaluation threads. In this case returns null.

  Specified by:
    `getLightWeightInstance` in interface `JepComponent`
  Returns:
    null

### addTokenMatcher

    public TokenMatcher addTokenMatcher(TokenMatcher tm)

  Adds a TokenMatcher.

  Parameters:
    `tm` - the TokenMatcher to add
  Returns:
    the TokenMatcher

### getTokenMatchers

    public java.util.List<TokenMatcher> getTokenMatchers()

  Return the list of TokenMatchers

  Returns:
    the list

### addGrammarMatcher

    public GrammarMatcher addGrammarMatcher(GrammarMatcher gm)

  Adds a GrammarMatcher

  Parameters:
    `gm` - the GrammarMatcher to add
  Returns:
    the GrammarMatcher

### getGrammarMatchers

    public java.util.List<GrammarMatcher> getGrammarMatchers()

  Return the list of GrammarMatchers.

  Returns:
    the list

### addTokenFilter

    public TokenFilter addTokenFilter(TokenFilter tf)

  Adds a TokenFilter.

  Parameters:
    `tf` - the TokenFilter to add
  Returns:
    the TokenFilter

### getTokenFilters

    public java.util.List<TokenFilter> getTokenFilters()

  Return the list of filters.

  Returns:
    the list

### addHashComments

    public TokenMatcher addHashComments()

  Recognize comments of the form #....

  Returns:
    the corresponding matcher.

### addSlashComments

    public void addSlashComments()

  Recognize comments of the form //... or /* ... */. Does not return a given matcher.

### addDoubleQuoteStrings

    public TokenMatcher addDoubleQuoteStrings()

  Recognize double quote strings "...".

  Returns:
    the corresponding matcher.

### addSingleQuoteStrings

    public TokenMatcher addSingleQuoteStrings()

  Recognize single quote strings '...'.

  Returns:
    the corresponding matcher.

### addWhiteSpace

    public TokenMatcher addWhiteSpace()

  Recognize java white space characters.

  Returns:
    the corresponding matcher.

### addWhiteSpaceCommentFilter

    public TokenFilter addWhiteSpaceCommentFilter()

  Filter out whitespace and comments between the tokenizing and grammar matching stages.

  Returns:
    the WhiteSpaceCommentFilter

### addExponentNumbers

    public TokenMatcher addExponentNumbers()

  Recognize numbers with optional exponents, 1.2e3, 1.2E-3, 1.2, 1.

  Returns:
    the corresponding matcher.

### addSimpleNumbers

    public TokenMatcher addSimpleNumbers()

  Recognize numbers without exponents 1.2.

  Returns:
    the corresponding matcher.

### addOperatorTokenMatcher

    public TokenMatcher addOperatorTokenMatcher()

  Recognize operators.

  Returns:
    the OperatorTokenMatcher.

### getOperatorTokenMatcher

    public TokenMatcher getOperatorTokenMatcher()

  Return the OperatorTokenMatcher. Note this matcher is only added if addOperatorTokenMatcher() is called.

  Returns:
    the OperatorTokenMatcher.

### addSymbols

    public TokenMatcher addSymbols(java.lang.String... symbols)

  Recognize given symbols.

  Parameters:
    `symbols` - one or more string for the symbols.
  Returns:
    the SymbolTokenMatcher.

### getSymbolTokenMatcher

    public SymbolTokenMatcher getSymbolTokenMatcher()

  Return the SymbolTokenMatcher. Note this matcher is only added if addSymbols() is called.

  Returns:
    the SymbolTokenMatcher

### getSymbolToken

    public SymbolToken getSymbolToken(java.lang.String sym)

  Return the SymbolToken for the given string.

  Parameters:
    `sym` - string representing the symbol.
  Returns:
    the corresponding SymbolToken.

### setImplicitMultiplicationSymbols

    public void setImplicitMultiplicationSymbols(java.lang.String... symbols)

  Sets those symbols which can appear on the right hand side of implicit multiplication.

  Parameters:
    `symbols` - one or more string for the symbols.

### addIdentifiers

    public TokenMatcher addIdentifiers()

  Adds java-style function and variable names. These start with A-Z, a-z, or _ and are followed by zero or more alpha-numeric characters or _.

  Returns:
    the IdentifierTokenMatcher.

### addSemiColonTerminator

    public TokenMatcher addSemiColonTerminator()

  Adds a matcher which will terminate the parsing process when a semi-colon is encountered.

  Returns:
    the TerminatorTokenMatcher

### addBracketMatcher

    public GrammarMatcher addBracketMatcher(java.lang.String open,
                                            java.lang.String close)

  Matches bracketed expressions: (2+3).

  Parameters:
    `open` - symbol for opening brace
    `close` - symbol for closing brace
  Returns:
    the corresponding GrammarMatcher

### addFunctionMatcher

    public GrammarMatcher addFunctionMatcher(java.lang.String open,
                                             java.lang.String close,
                                             java.lang.String sep)

  Matches functions: atan2(y,x).

  Parameters:
    `open` - symbol for opening brace
    `close` - symbol for closing brace
    `sep` - symbol for argument separator
  Returns:
    the corresponding GrammarMatcher

### addListMatcher

    public GrammarMatcher addListMatcher(java.lang.String open,
                                         java.lang.String close,
                                         java.lang.String sep)

  Matches vectors/list: [1,2,3]

  Parameters:
    `open` - symbol for opening brace
    `close` - symbol for closing brace
    `sep` - symbol for argument separator
  Returns:
    the corresponding GrammarMatcher

### addArrayAccessMatcher

    public GrammarMatcher addArrayAccessMatcher(java.lang.String open,
                                                java.lang.String close)

  Matches array access: a[3]

  Parameters:
    `open` - symbol for opening brace
    `close` - symbol for closing brace
  Returns:
    the corresponding GrammarMatcher

### addListOrBracketMatcher

    public GrammarMatcher addListOrBracketMatcher(java.lang.String open,
                                                  java.lang.String close,
                                                  java.lang.String sep)

  Matches bracketed expressions or lists depending on number of arguments.

  Parameters:
    `open` - symbol for opening brace
    `close` - symbol for closing brace
    `sep` - symbol for argument separator
  Returns:
    the corresponding GrammarMatcher

Overview | Package | Class | Tree | Deprecated | Index | Help
PREV CLASS NEXT CLASS | FRAMES NO FRAMES
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD

Copyright © 2008 Singular Systems http://www.singularsys.com/jep