Package org.jmol.script
Class ScriptExpr
java.lang.Object
org.jmol.script.ScriptError
org.jmol.script.ScriptParam
org.jmol.script.ScriptExpr
- All Implemented Interfaces:
JmolScriptEvaluator
- Direct Known Subclasses:
ScriptEval
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 Summary
FieldsModifier and TypeFieldDescriptionprivate CmdExt
boolean
private IsoExt
private MathExt
protected Map<String,
ScriptFunction> private javajs.util.P3
private SmilesExt
protected T[]
Fields inherited from class org.jmol.script.ScriptParam
contextFunctions, contextVariables, coordinatesAreFractional, fractionalPoint, isBondSet, iToken, MODE_P_ALLOW_FRACTIONAL, MODE_P_CONVERT_TO_CARTESIAN, MODE_P_IMPLICIT_FRACTIONAL, MODE_P_INT_ONLY, MODE_P_NULL_ON_ERROR, MODE_P3, MODE_P34, MODE_P4, slen, st, theTok, theToken, thisContext
Fields inherited from class org.jmol.script.ScriptError
chk, error, ERROR_axisExpected, ERROR_backgroundModelError, ERROR_badArgumentCount, ERROR_badMillerIndices, ERROR_badRGBColor, ERROR_booleanExpected, ERROR_booleanOrNumberExpected, ERROR_booleanOrWhateverExpected, ERROR_cannotSet, ERROR_colorExpected, ERROR_colorOrPaletteRequired, ERROR_commandExpected, ERROR_coordinateOrNameOrExpressionRequired, ERROR_drawObjectNotDefined, ERROR_endOfStatementUnexpected, ERROR_expressionExpected, ERROR_expressionOrIntegerExpected, ERROR_filenameExpected, ERROR_fileNotFoundException, ERROR_incompatibleArguments, ERROR_insufficientArguments, ERROR_integerExpected, ERROR_integerOutOfRange, ERROR_invalidArgument, ERROR_invalidParameterOrder, ERROR_keywordExpected, ERROR_moCoefficients, ERROR_moIndex, ERROR_moModelError, ERROR_moOccupancy, ERROR_moOnlyOne, ERROR_multipleModelsDisplayedNotOK, ERROR_multipleModelsNotOK, ERROR_noData, ERROR_noPartialCharges, ERROR_noUnitCell, ERROR_numberExpected, ERROR_numberMustBe, ERROR_numberOutOfRange, ERROR_objectNameExpected, ERROR_planeExpected, ERROR_propertyNameExpected, ERROR_spaceGroupNotFound, ERROR_stringExpected, ERROR_stringOrIdentifierExpected, ERROR_tooManyPoints, ERROR_tooManyScriptLevels, ERROR_unrecognizedAtomProperty, ERROR_unrecognizedBondProperty, ERROR_unrecognizedCommand, ERROR_unrecognizedExpression, ERROR_unrecognizedObject, ERROR_unrecognizedParameter, ERROR_unrecognizedParameterWarning, ERROR_unrecognizedShowParameter, ERROR_what, ERROR_writeWhat, errorMessage, errorMessageUntranslated, errorType, iCommandError, ignoreError, vwr
-
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionprotected void
javajs.util.BS
atomExpression
(T[] code, int pcStart, int pcStop, boolean allowRefresh, boolean allowUnderflow, Object[] ret, boolean andNotDeleted) javajs.util.BS
atomExpressionAt
(int index) private javajs.util.BS
bitSetForModelFileNumber
(int m) protected boolean
compareFloat
(int tokOperator, float a, float b) protected javajs.util.BS
compareFloatData
(int tokWhat, float[] data, int tokOperator, float comparisonFloat) private javajs.util.BS
compareInt
(int tokWhat, int tokOperator, int ival) private javajs.util.BS
compareString
(int tokWhat, int tokOperator, String comparisonString) private boolean
compareStringValues
(int tokOperator, String propertyValue, String comparisonValue) getAssocArray
(int i) protected javajs.util.BS
getAtomBits
(int tokType, Object specInfo) 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) private SV
getBitsetPropertySelector
(int i, int xTok) private javajs.util.BS
getComparison
(T t, int tokWhat, int tokOp, String strOp, float[] data) private Object
protected ScriptFunction
getFunction
(String sf) protected static int
getSeqCode
(T instruction) private Object
protected boolean
isFunction
(String sf) protected javajs.util.Lst<SV>
listBS
(javajs.util.BS bs) protected boolean
noCopy
(int i, int dir) 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) This is the primary driver of the RPN (reverse Polish notation) expression processor.protected boolean
parameterExpressionBoolean
(int pt, int ptMax) protected javajs.util.Lst<SV>
parameterExpressionList
(int pt, int ptAtom, boolean isArrayItem) protected boolean
parameterExpressionSelect
(Map<String, SV> h, T[] where) protected String
parameterExpressionString
(int pt, int ptMax) protected SV
parameterExpressionToken
(int pt) private void
setBitsetProperty
(javajs.util.BS bs, int tok, int iValue, float fValue, T tokenValue) protected boolean
setStatement
(T[] st0, int pt0) provides support for @x and @{....} in statements.protected SV
setVariable
(int pt, int ptMax, String key, boolean isSet) Methods inherited from class org.jmol.script.ScriptParam
atomCenterOrCoordinateParameter, centerParameter, centerParameterForModel, checkHKL, checkLast, checkLength, checkLength23, checkLength34, checkLengthErrorPt, checkToken, floatParameter, floatParameterRange, floatParameterSet, getArgbParam, getArgbParamLast, getArgbParamOrNone, getAtomsStartingAt, getBondOrderFromString, getContextVariableAsVariable, getFloatEncodedInt, getFractionalPoint, getHklPlane, getMadParameter, getParameter, getPartialBondOrderFromFloatEncodedInt, getPoint3f, getPoint4f, getPointArray, getPointOrCenterVector, getPointOrPlane, getPointVector, getQuaternionParameter, getToken, getVarParameter, hklParameter, intParameter, intParameterRange, isArrayParameter, isCenterParameter, isColorParam, isFloatParameter, isPoint3f, listParameter, listParameter4, modelNumberParameter, objectNameParameter, optParameterAsString, paramAsStr, planeParameter, planeValue, setBooleanProperty, setFloatProperty, setIntProperty, setStringProperty, stringParameter, stringParameterSet, tickParamAsStr, tokAt, xypParameter, xyzpParameter
Methods inherited from class org.jmol.script.ScriptError
bad, error, errorMore, errorStr, errorStr2, errorString, evalError, getErrorLineMessage, getErrorMessage, getErrorMessageUntranslated, integerOutOfRange, invArg, numberOutOfRange, setCursorWait, setErrorMessage, showStringPrint, warning
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
Methods inherited from interface org.jmol.api.JmolScriptEvaluator
checkScriptSilent, checkSelect, compileScriptFile, compileScriptString, deleteAtomsInVariables, evalFunctionFloat, evalParallel, evaluateCompiledScript, evaluateExpression, getAllowJSThreads, getAtomBitSet, getNextStatement, getScript, getScriptContext, getThisContext, haltExecution, isExecuting, isPaused, isStateScript, isStepping, isStopped, loadFileResourceAsync, notifyResumeStatus, pauseExecution, pushContextDown, resumeEval, resumePausedExecution, runScript, runScriptBuffer, setCompiler, setDebugging, setObjectPropSafe, setStatic, setViewer, stepPausedExecution, stopScriptThreads
-
Field Details
-
debugHigh
public boolean debugHigh -
privateFuncs
-
cmdExt
-
isoExt
-
mathExt
-
smilesExt
-
tempStatement
-
ptTemp
private javajs.util.P3 ptTemp
-
-
Constructor Details
-
ScriptExpr
ScriptExpr()
-
-
Method Details
-
getCmdExt
-
getIsoExt
-
getMathExt
-
getSmilesExt
-
getExt
-
parameterExpressionList
protected javajs.util.Lst<SV> parameterExpressionList(int pt, int ptAtom, boolean isArrayItem) throws ScriptException - Throws:
ScriptException
-
parameterExpressionString
- Throws:
ScriptException
-
parameterExpressionBoolean
- Throws:
ScriptException
-
parameterExpressionToken
- Throws:
ScriptException
-
parameterExpressionSelect
- 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 ScriptExceptionThis 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 expressionkey
- variable name for debugging reference only -- null indicates return Boolean -- "" indicates return StringignoreComma
-asVector
- a flag passed on to RPN;ptAtom
- this is a for() or select() function with a specific atom selectedisArrayItem
- we are storing A[x] = ... so we need to deliver "x" as welllocalVars
- see below -- lists all nested for(x, {exp}, select(y, {ex},...)) variableslocalVar
- x or y in above for(), select() examplesisSpecialAssignment
- x[n] = ....- Returns:
- either a vector or a value, caller's choice.
- Throws:
ScriptException
- errors are thrown directly to the Eval error system.
-
atomExpressionAt
- 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 BSandNotDeleted
- 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
- Throws:
ScriptException
-
listBS
-
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
- 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
-
getAtomBits
-
getSeqCode
-
setVariable
- Parameters:
pt
- starting point in command token sequenceptMax
- 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 globalisSet
- 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
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
-
addFunction
-
getFunction
-