ScriptTokenParser
Date: 2019-10-22

org.jmol.script

## Class ScriptTokenParser

- java.lang.Object
- - org.jmol.script.ScriptTokenParser

- Direct Known Subclasses:
    ScriptCompiler

      abstract class ScriptTokenParser
      extends java.lang.Object

- - ### Field Summary

    Fields
    Modifier and Type | Field and Description
    --- | ---
    `protected T[]` | `atokenInfix`
    `protected static int` | `ERROR_badArgumentCount`
    `protected static int` | `ERROR_badContext`
    `protected static int` | `ERROR_commandExpected`
    `private static int` | `ERROR_coordinateExpected`
    `protected static int` | `ERROR_endOfCommandUnexpected`
    `private static int` | `ERROR_endOfExpressionExpected`
    `private static int` | `ERROR_identifierOrResidueSpecificationExpected`
    `private static int` | `ERROR_invalidAtomSpecification`
    `private static int` | `ERROR_invalidChainSpecification`
    `protected static int` | `ERROR_invalidExpressionToken`
    `private static int` | `ERROR_invalidModelSpecification`
    `protected static int` | `ERROR_missingEnd`
    `private static int` | `ERROR_numberExpected`
    `private static int` | `ERROR_numberOrVariableNameExpected`
    `private static int` | `ERROR_residueSpecificationExpected`
    `protected static int` | `ERROR_tokenExpected`
    `protected static int` | `ERROR_tokenUnexpected`
    `private static int` | `ERROR_unrecognizedExpressionToken`
    `protected static int` | `ERROR_unrecognizedParameter`
    `protected static int` | `ERROR_unrecognizedToken`
    `protected java.lang.String` | `errorLine`
    `protected java.lang.String` | `errorMessage`
    `protected java.lang.String` | `errorMessageUntranslated`
    `protected java.lang.String` | `errorType`
    `protected boolean` | `haveMacro`
    `(package private) boolean` | `haveString`
    `protected java.util.Map<java.lang.String,java.lang.Boolean>` | `htUserFunctions`
    `protected int` | `ichComment`
    `protected int` | `ichCurrentCommand`
    `protected int` | `ichEnd`
    `protected int` | `ichToken`
    `protected int` | `iCommand`
    `protected boolean` | `isCommaAsOrAllowed`
    `protected boolean` | `isEmbeddedExpression`
    `protected boolean` | `isMathExpressionCommand`
    `protected boolean` | `isNewSet`
    `protected boolean` | `isSetBrace`
    `protected boolean` | `isSetOrDefine`
    `protected boolean` | `isStateScript`
    `protected int` | `itokenInfix`
    `protected T` | `lastFlowCommand`
    `protected T` | `lastToken`
    `protected short` | `lineCurrent`
    `protected boolean` | `logMessages`
    `private javajs.util.Lst<T>` | `ltokenPostfix`
    `protected int` | `nTokens`
    `protected int` | `ptNewSetModifier`
    `private boolean` | `residueSpecCodeGenerated`
    `protected java.lang.String` | `script`
    `protected int` | `theTok`
    `protected T` | `theToken`
    `private java.lang.Object` | `theValue`
    `protected int` | `tokCommand`
    `protected T` | `tokenAndEquals`
    `protected T` | `tokenCommand`
    `protected Viewer` | `vwr`

  - ### Constructor Summary

    Constructors
    Constructor and Description
    `ScriptTokenParser()`

  - ### Method Summary

    All Methods Static Methods Instance Methods Concrete Methods
    Modifier and Type | Method and Description
    --- | ---
    `private boolean` | `addCompare(T tokenAtomProperty, T tokenComparator)`
    `private boolean` | `addNextToken()`
    `private boolean` | `addNextTokenIf(int tok)`
    `private boolean` | `addSubstituteTokenIf(int tok, T token)`
    `private boolean` | `addTokenToPostfix(int tok, java.lang.Object value)`
    `private boolean` | `addTokenToPostfixInt(int tok, int intValue, java.lang.Object value)`
    `private boolean` | `addTokenToPostfixToken(T token)`
    `private boolean` | `checkForCoordinate(boolean isImplicitExpression)`
    `private boolean` | `checkForItemSelector(boolean allowNumeric)`
    `private boolean` | `clauseAlternateSpec()` check for %x or % (null alternate)
    `private boolean` | `clauseAnd()`
    `private boolean` | `clauseAtomSpec()`
    `private boolean` | `clauseCell(int tok)`
    `private boolean` | `clauseChainSpec(int tok)` [:] [chars] [:] ["chars"] [:] [*] [:] [0-9] [:] [?] [:] (empty chain)
    `private boolean` | `clauseComparator(boolean isOptional)`
    `private boolean` | `clauseConnected(boolean isPolyhedra)`
    `private boolean` | `clauseDefine(boolean haveToken, boolean forceString)`
    `private boolean` | `clauseItemSelector()`
    `private boolean` | `clauseModelSpec()` process /1 /1.1 / * or just /
    `private boolean` | `clauseNot()`
    `private boolean` | `clauseOr(boolean allowCommaAsOr)`
    `private boolean` | `clausePrimitive()`
    `private boolean` | `clauseResidueSpec()`
    `private boolean` | `clauseResNameSpec()` [a] or just a
    `private boolean` | `clauseSequenceSpec()`
    `private boolean` | `clauseSubstructure()`
    `private boolean` | `clauseWithin(boolean isWithin)`
    `protected boolean` | `commandExpected()`
    `protected boolean` | `compileExpression()`
    `protected boolean` | `compileExpressions()`
    `protected boolean` | `error(int error)`
    `protected boolean` | `errorIntStr2(int iError, java.lang.String value, java.lang.String more)`
    `protected boolean` | `errorStr(int error, java.lang.String value)`
    `protected boolean` | `errorStr2(java.lang.String errorMessage, java.lang.String strUntranslated)`
    `(package private) static java.lang.String` | `errorString(int iError, java.lang.String value, java.lang.String more, boolean translated)`
    `private int` | `fixModelSpec(T token)`
    `private float` | `floatValue()`
    `private boolean` | `generateResidueSpecCode(T token)`
    `private boolean` | `getNumericalToken()`
    `private T` | `getSequenceCode(boolean isSecond)`
    `private T` | `getToken()` gets the next token and sets global theToken and theValue
    `private int` | `intPeek()`
    `private boolean` | `isError()`
    `private boolean` | `isExpressionNext()`
    `private boolean` | `isTerminator(int tok)` we allow : and % to have null values
    `protected boolean` | `isUserFunction(java.lang.String name)`
    `private boolean` | `moreTokens()`
    `private boolean` | `returnToken()`
    `protected int` | `tokAt(int i)`
    `protected static boolean` | `tokenAttr(T token, int tok)`
    `private T` | `tokenNext()` increments the pointer; does NOT set theToken or theValue
    `private boolean` | `tokenNextTok(int tok)`
    `private int` | `tokPeek()`
    `private boolean` | `tokPeekIs(int tok)`
    `private java.lang.Object` | `valuePeek()`

    - ### Methods inherited from class java.lang.Object

      `clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait`

- - ### Field Detail

    - #### vwr

          protected Viewer vwr

    - #### script

          protected java.lang.String script

    - #### isStateScript

          protected boolean isStateScript

    - #### lineCurrent

          protected short lineCurrent

    - #### iCommand

          protected int iCommand

    - #### ichCurrentCommand

          protected int ichCurrentCommand

    - #### ichComment

          protected int ichComment

    - #### ichEnd

          protected int ichEnd

    - #### ichToken

          protected int ichToken

    - #### theToken

          protected T theToken

    - #### lastFlowCommand

          protected T lastFlowCommand

    - #### tokenCommand

          protected T tokenCommand

    - #### lastToken

          protected T lastToken

    - #### tokenAndEquals

          protected T tokenAndEquals

    - #### theTok

          protected int theTok

    - #### nTokens

          protected int nTokens

    - #### tokCommand

          protected int tokCommand

    - #### ptNewSetModifier

          protected int ptNewSetModifier

    - #### isNewSet

          protected boolean isNewSet

    - #### haveMacro

          protected boolean haveMacro

    - #### logMessages

          protected boolean logMessages

    - #### atokenInfix

          protected T[] atokenInfix

    - #### itokenInfix

          protected int itokenInfix

    - #### isSetBrace

          protected boolean isSetBrace

    - #### isMathExpressionCommand

          protected boolean isMathExpressionCommand

    - #### isSetOrDefine

          protected boolean isSetOrDefine

    - #### ltokenPostfix

          private javajs.util.Lst<T> ltokenPostfix

    - #### isEmbeddedExpression

          protected boolean isEmbeddedExpression

    - #### isCommaAsOrAllowed

          protected boolean isCommaAsOrAllowed

    - #### theValue

          private java.lang.Object theValue

    - #### htUserFunctions

          protected java.util.Map<java.lang.String,java.lang.Boolean> htUserFunctions

    - #### haveString

          boolean haveString

    - #### residueSpecCodeGenerated

          private boolean residueSpecCodeGenerated

    - #### errorMessage

          protected java.lang.String errorMessage

    - #### errorMessageUntranslated

          protected java.lang.String errorMessageUntranslated

    - #### errorLine

          protected java.lang.String errorLine

    - #### errorType

          protected java.lang.String errorType

    - #### ERROR_badArgumentCount

          protected static final int ERROR_badArgumentCount

      See Also:
        Constant Field Values

    - #### ERROR_badContext

          protected static final int ERROR_badContext

      See Also:
        Constant Field Values

    - #### ERROR_commandExpected

          protected static final int ERROR_commandExpected

      See Also:
        Constant Field Values

    - #### ERROR_endOfCommandUnexpected

          protected static final int ERROR_endOfCommandUnexpected

      See Also:
        Constant Field Values

    - #### ERROR_invalidExpressionToken

          protected static final int ERROR_invalidExpressionToken

      See Also:
        Constant Field Values

    - #### ERROR_missingEnd

          protected static final int ERROR_missingEnd

      See Also:
        Constant Field Values

    - #### ERROR_tokenExpected

          protected static final int ERROR_tokenExpected

      See Also:
        Constant Field Values

    - #### ERROR_tokenUnexpected

          protected static final int ERROR_tokenUnexpected

      See Also:
        Constant Field Values

    - #### ERROR_unrecognizedParameter

          protected static final int ERROR_unrecognizedParameter

      See Also:
        Constant Field Values

    - #### ERROR_unrecognizedToken

          protected static final int ERROR_unrecognizedToken

      See Also:
        Constant Field Values

    - #### ERROR_coordinateExpected

          private static final int ERROR_coordinateExpected

      See Also:
        Constant Field Values

    - #### ERROR_endOfExpressionExpected

          private static final int ERROR_endOfExpressionExpected

      See Also:
        Constant Field Values

    - #### ERROR_identifierOrResidueSpecificationExpected

          private static final int ERROR_identifierOrResidueSpecificationExpected

      See Also:
        Constant Field Values

    - #### ERROR_invalidAtomSpecification

          private static final int ERROR_invalidAtomSpecification

      See Also:
        Constant Field Values

    - #### ERROR_invalidChainSpecification

          private static final int ERROR_invalidChainSpecification

      See Also:
        Constant Field Values

    - #### ERROR_invalidModelSpecification

          private static final int ERROR_invalidModelSpecification

      See Also:
        Constant Field Values

    - #### ERROR_numberExpected

          private static final int ERROR_numberExpected

      See Also:
        Constant Field Values

    - #### ERROR_numberOrVariableNameExpected

          private static final int ERROR_numberOrVariableNameExpected

      See Also:
        Constant Field Values

    - #### ERROR_residueSpecificationExpected

          private static final int ERROR_residueSpecificationExpected

      See Also:
        Constant Field Values

    - #### ERROR_unrecognizedExpressionToken

          private static final int ERROR_unrecognizedExpressionToken

      See Also:
        Constant Field Values

  - ### Constructor Detail

    - #### ScriptTokenParser

          ScriptTokenParser()

  - ### Method Detail

    - #### compileExpressions

          protected boolean compileExpressions()

    - #### compileExpression

          protected boolean compileExpression()

    - #### isUserFunction

          protected boolean isUserFunction(java.lang.String name)

    - #### isExpressionNext

          private boolean isExpressionNext()

    - #### tokenAttr

          protected static boolean tokenAttr(T token,
                                             int tok)

    - #### moreTokens

          private boolean moreTokens()

    - #### tokAt

          protected int tokAt(int i)

    - #### tokPeek

          private int tokPeek()

    - #### tokPeekIs

          private boolean tokPeekIs(int tok)

    - #### intPeek

          private int intPeek()

    - #### valuePeek

          private java.lang.Object valuePeek()

    - #### tokenNext

          private T tokenNext()

      increments the pointer; does NOT set theToken or theValue
      Returns:
        the next token

    - #### tokenNextTok

          private boolean tokenNextTok(int tok)

    - #### returnToken

          private boolean returnToken()

    - #### getToken

          private T getToken()

      gets the next token and sets global theToken and theValue
      Returns:
        the next token

    - #### getNumericalToken

          private boolean getNumericalToken()

    - #### floatValue

          private float floatValue()

    - #### addTokenToPostfix

          private boolean addTokenToPostfix(int tok,
                                            java.lang.Object value)

    - #### addTokenToPostfixInt

          private boolean addTokenToPostfixInt(int tok,
                                               int intValue,
                                               java.lang.Object value)

    - #### addTokenToPostfixToken

          private boolean addTokenToPostfixToken(T token)

    - #### addNextToken

          private boolean addNextToken()

    - #### addNextTokenIf

          private boolean addNextTokenIf(int tok)

    - #### addSubstituteTokenIf

          private boolean addSubstituteTokenIf(int tok,
                                               T token)

    - #### clauseOr

          private boolean clauseOr(boolean allowCommaAsOr)

    - #### clauseAnd

          private boolean clauseAnd()

    - #### clauseNot

          private boolean clauseNot()

    - #### clausePrimitive

          private boolean clausePrimitive()

    - #### checkForCoordinate

          private boolean checkForCoordinate(boolean isImplicitExpression)

    - #### checkForItemSelector

          private boolean checkForItemSelector(boolean allowNumeric)

    - #### clauseWithin

          private boolean clauseWithin(boolean isWithin)

    - #### clauseConnected

          private boolean clauseConnected(boolean isPolyhedra)

    - #### clauseSubstructure

          private boolean clauseSubstructure()

    - #### clauseItemSelector

          private boolean clauseItemSelector()

    - #### clauseComparator

          private boolean clauseComparator(boolean isOptional)

    - #### addCompare

          private boolean addCompare(T tokenAtomProperty,
                                     T tokenComparator)

    - #### clauseCell

          private boolean clauseCell(int tok)

    - #### clauseDefine

          private boolean clauseDefine(boolean haveToken,
                                       boolean forceString)

    - #### generateResidueSpecCode

          private boolean generateResidueSpecCode(T token)

    - #### clauseResidueSpec

          private boolean clauseResidueSpec()

    - #### clauseResNameSpec

          private boolean clauseResNameSpec()

      [a] or just a
      Returns:
        true if handled

    - #### clauseSequenceSpec

          private boolean clauseSequenceSpec()

    - #### getSequenceCode

          private T getSequenceCode(boolean isSecond)

    - #### clauseChainSpec

          private boolean clauseChainSpec(int tok)

      [:] [chars] [:] ["chars"] [:] [*] [:] [0-9] [:] [?] [:] (empty chain)
      Parameters:
        `tok` -
      Returns:
        true if chain handled

    - #### clauseAlternateSpec

          private boolean clauseAlternateSpec()

      check for %x or % (null alternate)
      Returns:
        true if no error

    - #### isTerminator

          private boolean isTerminator(int tok)

      we allow : and % to have null values
      Parameters:
        `tok` -
      Returns:
        true if terminating

    - #### clauseModelSpec

          private boolean clauseModelSpec()

      process /1 /1.1 / * or just /
      Returns:
        true if no error

    - #### fixModelSpec

          private int fixModelSpec(T token)

    - #### clauseAtomSpec

          private boolean clauseAtomSpec()

    - #### errorString

          static java.lang.String errorString(int iError,
                                              java.lang.String value,
                                              java.lang.String more,
                                              boolean translated)

    - #### commandExpected

          protected boolean commandExpected()

    - #### error

          protected boolean error(int error)

    - #### errorStr

          protected boolean errorStr(int error,
                                     java.lang.String value)

    - #### errorIntStr2

          protected boolean errorIntStr2(int iError,
                                         java.lang.String value,
                                         java.lang.String more)

    - #### isError

          private boolean isError()

    - #### errorStr2

          protected boolean errorStr2(java.lang.String errorMessage,
                                      java.lang.String strUntranslated)