Class ScriptExpr

All Implemented Interfaces:
JmolScriptEvaluator
Direct Known Subclasses:
ScriptEval

abstract class ScriptExpr extends ScriptParam
The ScriptExpr class holds the main functions for processing mathematical and atom selection expressions. The two methods, parameterExpression and atomExpression are the key starting points for this processing.
  • Field Details

    • debugHigh

      public boolean debugHigh
    • privateFuncs

      protected Map<String,ScriptFunction> privateFuncs
    • cmdExt

      private CmdExt cmdExt
    • isoExt

      private IsoExt isoExt
    • mathExt

      private MathExt mathExt
    • smilesExt

      private SmilesExt smilesExt
    • tempStatement

      protected T[] tempStatement
    • ptTemp

      private javajs.util.P3 ptTemp
  • Constructor Details

    • ScriptExpr

      ScriptExpr()
  • Method Details

    • getCmdExt

      public CmdExt getCmdExt()
    • getIsoExt

      public IsoExt getIsoExt()
    • getMathExt

      public MathExt getMathExt()
    • getSmilesExt

      public SmilesExt getSmilesExt()
    • getExt

      private Object getExt(String type)
    • parameterExpressionList

      protected javajs.util.Lst<SV> parameterExpressionList(int pt, int ptAtom, boolean isArrayItem) throws ScriptException
      Throws:
      ScriptException
    • parameterExpressionString

      protected String parameterExpressionString(int pt, int ptMax) throws ScriptException
      Throws:
      ScriptException
    • parameterExpressionBoolean

      protected boolean parameterExpressionBoolean(int pt, int ptMax) throws ScriptException
      Throws:
      ScriptException
    • parameterExpressionToken

      protected SV parameterExpressionToken(int pt) throws ScriptException
      Throws:
      ScriptException
    • parameterExpressionSelect

      protected boolean parameterExpressionSelect(Map<String,SV> h, T[] where) throws ScriptException
      Throws:
      ScriptException
    • parameterExpression

      private Object parameterExpression(int pt, int ptMax, String key, boolean ignoreComma, boolean asVector, int ptAtom, boolean isArrayItem, Map<String,SV> localVars, String localVar, boolean isSpecialAssignment) throws ScriptException
      This is the primary driver of the RPN (reverse Polish notation) expression processor. It handles all math outside of a "traditional" Jmol SELECT/RESTRICT context. [Object atomExpression() takes care of that, and also uses the RPN class.]
      Parameters:
      pt - token index in statement start of expression or negative for one expression only.
      ptMax - token index in statement end of expression
      key - variable name for debugging reference only -- null indicates return Boolean -- "" indicates return String
      ignoreComma -
      asVector - a flag passed on to RPN;
      ptAtom - this is a for() or select() function with a specific atom selected
      isArrayItem - we are storing A[x] = ... so we need to deliver "x" as well
      localVars - see below -- lists all nested for(x, {exp}, select(y, {ex},...)) variables
      localVar - x or y in above for(), select() examples
      isSpecialAssignment - x[n] = ....
      Returns:
      either a vector or a value, caller's choice.
      Throws:
      ScriptException - errors are thrown directly to the Eval error system.
    • atomExpressionAt

      public javajs.util.BS atomExpressionAt(int index) throws ScriptException
      Throws:
      ScriptException
    • atomExpression

      public javajs.util.BS atomExpression(T[] code, int pcStart, int pcStop, boolean allowRefresh, boolean allowUnderflow, Object[] ret, boolean andNotDeleted) throws ScriptException
      Parameters:
      code -
      pcStart -
      pcStop -
      allowRefresh -
      allowUnderflow -
      ret - -- true return value; may not be a BS
      andNotDeleted - IGNORED
      Returns:
      atom bitset
      Throws:
      ScriptException
    • getComparison

      private javajs.util.BS getComparison(T t, int tokWhat, int tokOp, String strOp, float[] data) throws ScriptException
      Throws:
      ScriptException
    • noCopy

      protected boolean noCopy(int i, int dir)
    • getAssocArray

      protected Map<String,Object> getAssocArray(int i) throws ScriptException
      Throws:
      ScriptException
    • listBS

      protected javajs.util.Lst<SV> listBS(javajs.util.BS bs)
    • compareFloatData

      protected javajs.util.BS compareFloatData(int tokWhat, float[] data, int tokOperator, float comparisonFloat)
      Parameters:
      tokWhat -
      data -
      tokOperator -
      comparisonFloat -
      Returns:
      BitSet
    • compareFloat

      protected boolean compareFloat(int tokOperator, float a, float b)
    • compareString

      private javajs.util.BS compareString(int tokWhat, int tokOperator, String comparisonString) throws ScriptException
      Throws:
      ScriptException
    • compareStringValues

      private boolean compareStringValues(int tokOperator, String propertyValue, String comparisonValue) throws ScriptException
      Throws:
      ScriptException
    • compareInt

      private javajs.util.BS compareInt(int tokWhat, int tokOperator, int ival)
    • getBitsetPropertySelector

      private SV getBitsetPropertySelector(int i, int xTok) throws ScriptException
      Throws:
      ScriptException
    • getBitsetProperty

      public Object getBitsetProperty(javajs.util.BS bs, javajs.util.Lst<SV> pts, int tok, javajs.util.P3 ptRef, javajs.util.P4 planeRef, Object tokenValue, Object opValue, boolean useAtomMap, int index, boolean asVectorIfAll) throws ScriptException
      Throws:
      ScriptException
    • bitSetForModelFileNumber

      private javajs.util.BS bitSetForModelFileNumber(int m)
    • getStringObjectAsVariable

      private Object getStringObjectAsVariable(Object obj)
    • getAtomBits

      protected javajs.util.BS getAtomBits(int tokType, Object specInfo)
    • getSeqCode

      protected static int getSeqCode(T instruction)
    • setVariable

      protected SV setVariable(int pt, int ptMax, String key, boolean isSet) throws ScriptException
      Parameters:
      pt - starting point in command token sequence
      ptMax - ending point in command token sequenec, possibly -1 for "all"
      key - the variable name to save the result in. This must be a standard user variable, either local or global
      isSet - from Set ... or Var .... or just xxx ....
      Returns:
      a variable or null
      Throws:
      ScriptException
    • setBitsetProperty

      private void setBitsetProperty(javajs.util.BS bs, int tok, int iValue, float fValue, T tokenValue) throws ScriptException
      Throws:
      ScriptException
    • setStatement

      protected boolean setStatement(T[] st0, int pt0) throws ScriptException
      provides support for @x and @{....} in statements. The compiler passes on these, because they must be integrated with the statement dynamically.
      Parameters:
      st0 - aaToken[i]
      pt0 -
      Returns:
      a fixed token set -- with possible overrun of unused null tokens
      Throws:
      ScriptException
    • isFunction

      protected boolean isFunction(String sf)
    • addFunction

      protected void addFunction(ScriptFunction f)
    • getFunction

      protected ScriptFunction getFunction(String sf)