Package: com.arsi.mj.maprpt.lexer.ptree.cmd.equation
previous next contents
Package com.arsi.mj.maprpt.lexer.ptree.cmd.equation
contains the following classes and interfaces.
Classes and Interfaces |
DefaultPrecedenceFactory |
Assigns typical precedence (e.g., multiplication has higher precedence than addition) to
mathematical, relational and boolean operators supported by Mapper commands such as
CAL and ART . |
EquationOption |
Enumerated options for a Mapper equation (essentially the same options used by the
CAL command) associated with option letter. |
EquationOptionConcatExpr |
A concatenation expression that wraps the various ways an equation option may be
specified. |
EquationOptions |
Bundle of options and option arguments for a Mapper equation (essentially the
same options used by the CAL command). |
EquationOptionsResult |
Result returned by EquationTokenizer.parseEquationOptions method,
encapsulates equation options and option arguments obtained by parsing a Mapper
equation(s) such as that found in CAL . |
EquationParser |
Parses equation tokens into a parse tree of equation nodes. |
EquationParseResult |
Result returned by several methods in EquationParser , encapsulates
parse tree(s) of equation nodes and any remaining equation token lists after
parsing an aspect of the Mapper equation(s) such as that found in CHG ,
CAL and DC . |
EquationTokenizer |
Parses a CHG , CAL or DC equation into tokens. |
IPrecedenceFactory |
Defines a simple factory for determine precedence of mathematical, relational
and boolean operators. |
TokenizedEquation |
Equation tokens obtained by parsing a Mapper equation such as that found in
CHG , CAL and DC . |
TokenizedEquationResult |
Result returned by EquationTokenizer.parseEquation method, encapsulates
lists of equation tokens obtained by parsing a Mapper equation(s) such as that found
in CHG , CAL and DC . |
TopLevelParseResult |
Result returned by EquationParser.parseTopLevelTerm , encapsulates
parse tree(s) of equation nodes after parsing top-level constructs of Mapper equation(s). |
Class: DefaultPrecedenceFactory
next
package
Assigns typical precedence (e.g., multiplication has higher precedence than addition) to
mathematical, relational and boolean operators supported by Mapper commands such as
CAL
and
ART
.
Treat this class as "thread-safe" since it is immutable once created.
Constructors |
public DefaultPrecedenceFactory()
|
Enumerated options for a Mapper equation (essentially the same options used by the
CAL
command) associated with option letter. This class must implement
the static method
fromLetter
for use with class
EquationOptionConcatExpr
.
public final class com.arsi.mj.maprpt.lexer.ptree.cmd.equation.EquationOption
extends java.lang.Enum
A concatenation expression that wraps the various ways an equation option may be
specified. For example, while equation options are usually a literal string
such as
aa,E-J(z)R.01=123456.789
, the options might be stored as
a quoted string or even a variable (e.g.,
aa,=123456.789
or
aa,E-J()R=123456.789
).
- Parameters:
<E>
- the enumeration that lists the equation options and is wrapped by this class. The
enumeration must implement a static method fromLetter
with the following
signature for reflection to be compatible with command option pattern:
public static E fromLetter(final char aLetter);
Constructors |
Initializes an instance of this class.
- Parameters:
aConcatExpr - a concatenation expression, containing text and/or variable dereferences.
aUserRID - report ID string that is meaningful to user as an error context.
aLineNumber - line number in report where command option occurs.
public EquationOptionConcatExpr(com.arsi.mj.maprpt.lexer.ptree.expr.ConcatExpr aConcatExpr, java.lang.String aUserRID, int aLineNumber)
|
Bundle of options and option arguments for a Mapper equation (essentially the
same options used by the
CAL
command).
Treat this class as "thread-safe", since it is immutable once created.
public class com.arsi.mj.maprpt.lexer.ptree.cmd.equation.EquationOptions
extends java.lang.Object
Result returned by
EquationTokenizer.parseEquationOptions
method,
encapsulates equation options and option arguments obtained by parsing a Mapper
equation(s) such as that found in
CAL
.
Treat this class as "thread-safe", since it is immutable once created.
public class com.arsi.mj.maprpt.lexer.ptree.cmd.equation.EquationOptionsResult
extends java.lang.Object
Parses equation tokens into a parse tree of equation nodes.
Treat this class as "thread-hostile", as it is intended to be created, used
and discarded by a single thread.
public class com.arsi.mj.maprpt.lexer.ptree.cmd.equation.EquationParser
extends java.lang.Object
Constructors |
Public ctor for initializing an instance of this class.
- Parameters:
aPrecedenceFactory - factory for determining precedence of operators, may be NULL to use order in
which operator are encountered in input.
public EquationParser(com.arsi.mj.maprpt.lexer.ptree.cmd.equation.IPrecedenceFactory aPrecedenceFactory)
|
Methods |
Parse top-level term (IF, FIRST, SKIP, EXIT or an assignment expression) from
tokenized equation.
- Parameters:
anInitialEquation - tokenized equation that is expected to contain the top-level term. Upon return,
this equation can be discarded since it has been parsed into a node.
anEquationIterator - iterator for obtaining additional tokenized equations that follow IF such
as THEN and ELSE. Upon return, the next equation (if any) from this iterator
should become the initial tokenized equation.
aUserRID - report ID string that is meaningful to user as an error context.
aLineNumber - line number in report where command that contains equation occurs.
- Returns:
- result that contains parsed equation nodes.
public com.arsi.mj.maprpt.lexer.ptree.cmd.equation.TopLevelParseResult parseTopLevelTerm(com.arsi.mj.maprpt.lexer.ptree.cmd.equation.TokenizedEquation anInitialEquation, java.util.ListIterator anEquationIterator, java.lang.String aUserRID, int aLineNumber)
|
Result returned by several methods in
EquationParser
, encapsulates
parse tree(s) of equation nodes and any remaining equation token lists after
parsing an aspect of the Mapper equation(s) such as that found in
CHG
,
CAL
and
DC
.
Treat this class as "thread-safe", since it is immutable once created.
public class com.arsi.mj.maprpt.lexer.ptree.cmd.equation.EquationParseResult
extends java.lang.Object
Fields |
Equations whose tokenized form have been further parsed into parse trees of nodes. public final java.util.List equationsAsParseTrees
|
Equations that have been tokenized, naturally enough, into tokens. public final java.util.List equationsAsTokenLists
|
Constructors |
Public ctor for initializing an instanced of this class.
- Parameters:
aLastTokenReadIndex - index of last token read during parse, which should become the new initial token.
someEquationsAsTokenLists - equations that have been parsed into tokens.
public EquationParseResult(int aLastTokenReadIndex, java.util.List someEquationsAsTokenLists)
|
Methods |
public final int getIndexOfLastTokenRead()
|
public final void setIndexOfLastTokenRead(int anIndex)
|
Parses a
CHG
,
CAL
or
DC
equation into tokens.
Treat this class as "thread-hostile"; an instance should be created, used and discarded
by a single thread.
Inner Interface IEquationEndOfExpr |
Defines method to check for end of equation, simple re-naming of IConcatEndOfExpr .
|
Constructors |
Public ctor for initializing an instance of this class.
- Parameters:
aPrecedenceFactory - factory for determining precedence of operators, may be NULL to use order in
which operator are encountered in input.
anAllowQuotedEquationsFlag - true if command allows whitespace in equations to be escaped by quoting equation
in single quotes (e.g., CAL ), false if quoted equations are not
supported (e.g., CHG ).
aTreatSingleQuotedAsVariable - true if command treats a string enclosed in single quotes as a variable name,
false if string enclosed in single quotes is treated as a string literal.
aTreatFirstAsInitializationBlock - true to attempt to treat all FIRST directives as simple initialization block,
false if FIRST directives cannot be treated be placed in an initialization block
(e.g., FIRST directive is conditional or different order and place of execution
of FIRST directive has side effects).
public EquationTokenizer(com.arsi.mj.maprpt.lexer.ptree.cmd.equation.IPrecedenceFactory aPrecedenceFactory, boolean anAllowQuotedEquationsFlag, boolean aTreatSingleQuotedAsVariable, boolean aTreatFirstAsInitializationBlock)
|
Methods |
Attempt to parse equation options such as R.01 (round option
with argument) or E-j(Z)*k-1.0 (disable E option, set J, * and
K options) from the Mapper report lexer.
- Parameters:
anInitialToken - initial token to examine returned from a previous call to lexer.
aLexer - lexer for obtaining additional tokens; these tokens are pushed back by this
method if the input is not recognized as equation options.
anEoqParser - parser to detect premature end of equation.
aCommandName - name of Mapper command whose equation(s) are being parsed.
- Throws:
MJTranslateException - if an unexpected error occurs attempting to parse equation options.
- Returns:
- parse result object, or NULL if equation option(s) not recognized.
public com.arsi.mj.maprpt.lexer.ptree.cmd.equation.EquationOptionsResult parseEquationOptions(com.arsi.mj.maprpt.lexer.tokens.IMaprptToken anInitialToken, com.arsi.mj.maprpt.lexer.MaprptLexer aLexer, com.arsi.mj.maprpt.lexer.ptree.cmd.equation.EquationTokenizer.IEquationEndOfExpr anEoqParser, java.lang.String aCommandName) throws com.arsi.mj.MJTranslateException
|
Parse equation tokens from input, imposing a higher level of lexical analysis on
the stream of command tokens returned by the specified lexer. This method eats all
tokens it reads except for the last token read, so invoke only when an equation is
the next thing expected in the input.
- Parameters:
anInitialToken - initial token to examine returned from a previous call to lexer.
aLexer - lexer for obtaining additional tokens (tokens are eaten).
anEoqParser - parser to detect end of equation.
aCommandName - name of Mapper command whose equation(s) are being parsed.
- Throws:
MJTranslateException - if an unexpected error occurs while parsing the equation(s) into tokens.
- Returns:
- one or more equations, parsed into equation tokens.
public com.arsi.mj.maprpt.lexer.ptree.cmd.equation.TokenizedEquationResult tokenizeEquation(com.arsi.mj.maprpt.lexer.tokens.IMaprptToken anInitialToken, com.arsi.mj.maprpt.lexer.MaprptLexer aLexer, com.arsi.mj.maprpt.lexer.ptree.cmd.equation.EquationTokenizer.IEquationEndOfExpr anEoqParser, java.lang.String aCommandName) throws com.arsi.mj.MJTranslateException
|
Defines a simple factory for determine precedence of mathematical, relational
and boolean operators.
public interface com.arsi.mj.maprpt.lexer.ptree.cmd.equation.IPrecedenceFactory
Methods |
Determines precedence of a boolean operator.
- Parameters:
aBoolop - a boolean operator (e.g., Boolop.AND ).
- Returns:
- relative, integer magnitude to be used to order evaluation of operations.
public int precedence(com.arsi.mj.maprpt.lexer.ptree.symbol.BooleanOperator.Boolop aBoolop)
|
Determines precedence of a mathematical operator.
- Parameters:
aRelop - a relational operator (e.g., Mathop.MULTIPLICATION ).
- Returns:
- relative, integer magnitude to be used to order evaluation of operations.
public int precedence(com.arsi.mj.maprpt.lexer.ptree.symbol.MathOperator.Mathop aMathop)
|
Determines precedence of a relational operator.
- Parameters:
aRelop - a relational operator (e.g., Relop.EQUAL ).
- Returns:
- relative, integer magnitude to be used to order evaluation of operations.
public int precedence(com.arsi.mj.maprpt.lexer.ptree.symbol.RelationalOperator.Relop aRelop)
|
Defines lowest and highest precedence.
- Returns:
- relative, integer magnitude of lowest (first array element) and highest
precedence (second element), where magnitude of lowest <= magnitude of highest.
public int precedenceRange()
|
Equation tokens obtained by parsing a Mapper equation such as that found in
CHG
,
CAL
and
DC
.
Treat this class as "thread-safe", since it is immutable once created.
public class com.arsi.mj.maprpt.lexer.ptree.cmd.equation.TokenizedEquation
extends java.lang.Object
Fields |
Equation tokens resulting from parsing an equation. public final java.util.List equationsAsTokens
|
Constructors |
Initializes an instance of this class.
- Parameters:
someEquationsAsTokens - equation tokens resulting from parsing equation.
public TokenizedEquation(java.util.List someEquationsAsTokens)
|
Result returned by
EquationTokenizer.parseEquation
method, encapsulates
lists of equation tokens obtained by parsing a Mapper equation(s) such as that found
in
CHG
,
CAL
and
DC
.
Treat this class as "thread-safe", since it is immutable once created.
public class com.arsi.mj.maprpt.lexer.ptree.cmd.equation.TokenizedEquationResult
extends java.lang.Object
Fields |
Allow FIRST directives to be treated as simple initialization block? public final boolean allowFirstAsInitializationBlock
|
Equations that have been tokenized, naturally enough, into tokens. public final java.util.List equationsAsTokenLists
|
Last token read during tokenization, which should become the new initial token. public final com.arsi.mj.maprpt.lexer.tokens.IMaprptToken lastTokenRead
|
Constructors |
Initializes an instance of this class.
- Parameters:
aLastTokenRead - last token read during tokenization, which should become the new initial token. This
is typically the token that ends the equation, such as PeriodToken .
anAllowFirstAsInitializationBlock - allow FIRST directives to be treated as simple initialization block?
someEquationsAsTokenLists - lists of equation tokens resulting from tokenizing equation(s).
public TokenizedEquationResult(com.arsi.mj.maprpt.lexer.tokens.IMaprptToken aLastTokenRead, boolean anAllowFirstAsInitializationBlock, java.util.List someEquationsAsTokenLists)
|
Result returned by
EquationParser.parseTopLevelTerm
, encapsulates
parse tree(s) of equation nodes after parsing top-level constructs of Mapper equation(s).
Treat this class as "thread-safe", since it is immutable once created.
public class com.arsi.mj.maprpt.lexer.ptree.cmd.equation.TopLevelParseResult
extends java.lang.Object