org.jmol.viewer

Class Compiler

class Compiler extends Object

Nested Class Summary
static classCompiler.FlowContext
Field Summary
Token[][]aatokenCompiled
Token[]atokenInfix
intcchScript
intcchToken
HashtablecontextVariables
StringerrorLine
StringerrorMessage
static String[]errors
static intERROR_badArgumentCount
static intERROR_badContext
static intERROR_commandExpected
static intERROR_coordinateExpected
static intERROR_endOfCommandUnexpected
static intERROR_endOfExpressionExpected
static intERROR_identifierOrResidueSpecificationExpected
static intERROR_invalidAtomSpecification
static intERROR_invalidChainSpecification
static intERROR_invalidExpressionToken
static intERROR_invalidModelSpecification
static intERROR_missingEnd
static intERROR_numberExpected
static intERROR_numberOrVariableNameExpected
static intERROR_residueSpecificationExpected
static intERROR_tokenExpected
static intERROR_tokenUnexpected
static intERROR_unrecognizedExpressionToken
static intERROR_unrecognizedParameter
static intERROR_unrecognizedToken
Stringfilename
Compiler.FlowContextflowContext
static HashtableglobalFunctions
booleanhaveString
intichCurrentCommand
intichToken
intiCommand
booleaniHaveQuotedString
booleanisCheckOnly
booleanisCommaAsOrAllowed
booleanisEmbeddedExpression
booleanisImplicitExpression
booleanisNewSet
booleanisSetBrace
booleanisSetOrDefine
booleanisShowCommand
booleanisShowScriptOutput
booleanisSilent
intitokenInfix
TokenlastToken
shortlineCurrent
int[]lineIndices
short[]lineNumbers
static String[]loadFormats
HashtablelocalFunctions
booleanlogMessages
Vectorltoken
VectorltokenPostfix
intnSemiSkip
booleanpreDefining
intptNewSetModifier
booleanresidueSpecCodeGenerated
Stringscript
TokentheToken
ObjecttheValue
FunctionthisFunction
inttokCommand
TokentokenCommand
Viewerviewer
Constructor Summary
Compiler(Viewer viewer)
Method Summary
voidaddContextVariable(String ident)
voidaddFunction(Function function)
booleanaddNextToken()
booleanaddNextTokenIf(int tok)
booleanaddSubstituteTokenIf(int tok, Token token)
booleanaddTokenToPostfix(int tok, Object value)
booleanaddTokenToPostfix(int tok, int intValue, Object value)
booleanaddTokenToPostfix(Token token)
voidaddTokenToPrefix(Token token)
booleancharToken()
booleancheckForCoordinate(boolean isImplicitExpression)
booleancheckForItemSelector()
booleanclauseAlternateSpec()
booleanclauseAnd()
booleanclauseAtomSpec()
booleanclauseCell()
booleanclauseChainSpec(int tok)
booleanclauseComparator()
booleanclauseConnected()
booleanclauseDefine()
booleanclauseItemSelector()
booleanclauseModelSpec()
booleanclauseNot()
booleanclauseOr(boolean allowComma)
booleanclausePrimitive()
booleanclauseResidueSpec()
booleanclauseResNameSpec()
booleanclauseSequenceSpec()
booleanclauseSubstructure()
booleanclauseWithin()
static StringcleanScriptComments(String script)
allows for three kinds of comments.
booleancommandExpected()
booleancompile(String filename, String script, boolean isPredefining, boolean isSilent, boolean debugScript, boolean isCheckOnly)
booleancompile0()
booleancompileCommand()
booleancompileExpression()
booleaneol(char ch)
booleanerror(int error)
booleanerror(int error, String value)
booleanerror(int error, String value, String more)
booleanerror(String errorMessage)
floatfloatValue()
booleangenerateResidueSpecCode(Token token)
Token[][]getAatokenCompiled()
Compiler.FlowContextgetBreakableContext(int nLevelsUp)
HashtablegetContextVariables()
booleangetData(String key)
StringgetErrorMessage()
static intgetHexitValue(char ch)
int[]getLineIndices()
short[]getLineNumbers()
booleangetNumericalToken()
StringgetScript()
TokengetSequenceCode(boolean isSecond)
TokengetToken()
gets the next token and sets global theToken and theValue
StringgetUnescapedStringLiteral()
booleanhandleError()
intintPeek()
booleanisExpressionNext()
booleanisFunction(String name)
booleanisLineContinuation(int ichT)
static booleanisSpaceOrTab(char ch)
booleanisSpecTerminator(int tok)
booleanisToken(int tok)
BitSetlookingAtBitset()
booleanlookingAtComment()
booleanlookingAtDecimal()
booleanlookingAtEndOfLine()
check for leading #jx or if you see it, then only strip those 4 characters if they put in #jx then they are not going to execute anything, and the regular code will take care of it
booleanlookingAtEndOfStatement()
floatlookingAtExponential()
booleanlookingAtInteger()
booleanlookingAtLeadingWhitespace()
booleanlookingAtLoadFormat()
booleanlookingAtLookupToken()
booleanlookingAtObjectID(boolean allowWildID)
booleanlookingAtSeqcode()
booleanlookingAtSpecialString()
booleanlookingAtString()
static intmodelValue(String strDecimal)
booleanmoreTokens()
booleanreturnToken()
static voidsetErrorMessages()
inttokAt(int i)
static booleantokAttr(int a, int b)
static booleantokAttrOr(int a, int b1, int b2)
static booleantokenAttr(Token token, int tok)
TokentokenNext()
increments the pointer; does NOT set theToken or theValue
booleantokenNext(int tok)
inttokPeek()
booleantokPeek(int tok)
ObjectvaluePeek()

Field Detail

aatokenCompiled

private Token[][] aatokenCompiled

atokenInfix

Token[] atokenInfix

cchScript

private int cchScript

cchToken

private int cchToken

contextVariables

private Hashtable contextVariables

errorLine

private String errorLine

errorMessage

private String errorMessage

errors

private static String[] errors

ERROR_badArgumentCount

private static final int ERROR_badArgumentCount

ERROR_badContext

private static final int ERROR_badContext

ERROR_commandExpected

private static final int ERROR_commandExpected

ERROR_coordinateExpected

private static final int ERROR_coordinateExpected

ERROR_endOfCommandUnexpected

private static final int ERROR_endOfCommandUnexpected

ERROR_endOfExpressionExpected

private static final int ERROR_endOfExpressionExpected

ERROR_identifierOrResidueSpecificationExpected

private static final int ERROR_identifierOrResidueSpecificationExpected

ERROR_invalidAtomSpecification

private static final int ERROR_invalidAtomSpecification

ERROR_invalidChainSpecification

private static final int ERROR_invalidChainSpecification

ERROR_invalidExpressionToken

private static final int ERROR_invalidExpressionToken

ERROR_invalidModelSpecification

private static final int ERROR_invalidModelSpecification

ERROR_missingEnd

private static final int ERROR_missingEnd

ERROR_numberExpected

private static final int ERROR_numberExpected

ERROR_numberOrVariableNameExpected

private static final int ERROR_numberOrVariableNameExpected

ERROR_residueSpecificationExpected

private static final int ERROR_residueSpecificationExpected

ERROR_tokenExpected

private static final int ERROR_tokenExpected

ERROR_tokenUnexpected

private static final int ERROR_tokenUnexpected

ERROR_unrecognizedExpressionToken

private static final int ERROR_unrecognizedExpressionToken

ERROR_unrecognizedParameter

private static final int ERROR_unrecognizedParameter

ERROR_unrecognizedToken

private static final int ERROR_unrecognizedToken

filename

private String filename

flowContext

private Compiler.FlowContext flowContext

globalFunctions

static Hashtable globalFunctions

haveString

boolean haveString

ichCurrentCommand

private int ichCurrentCommand

ichToken

private int ichToken

iCommand

private int iCommand

iHaveQuotedString

private boolean iHaveQuotedString

isCheckOnly

private boolean isCheckOnly

isCommaAsOrAllowed

boolean isCommaAsOrAllowed

isEmbeddedExpression

boolean isEmbeddedExpression

isImplicitExpression

boolean isImplicitExpression

isNewSet

private boolean isNewSet

isSetBrace

private boolean isSetBrace

isSetOrDefine

boolean isSetOrDefine

isShowCommand

private boolean isShowCommand

isShowScriptOutput

private boolean isShowScriptOutput

isSilent

private boolean isSilent

itokenInfix

int itokenInfix

lastToken

private Token lastToken

lineCurrent

private short lineCurrent

lineIndices

private int[] lineIndices

lineNumbers

private short[] lineNumbers

loadFormats

static String[] loadFormats

localFunctions

Hashtable localFunctions

logMessages

private boolean logMessages

ltoken

private Vector ltoken

ltokenPostfix

Vector ltokenPostfix

nSemiSkip

private int nSemiSkip

preDefining

private boolean preDefining

ptNewSetModifier

private int ptNewSetModifier

residueSpecCodeGenerated

private boolean residueSpecCodeGenerated

script

private String script

theToken

Token theToken

theValue

Object theValue

thisFunction

private Function thisFunction

tokCommand

int tokCommand

tokenCommand

Token tokenCommand

viewer

private Viewer viewer

Constructor Detail

Compiler

Compiler(Viewer viewer)

Method Detail

addContextVariable

private void addContextVariable(String ident)

addFunction

void addFunction(Function function)

addNextToken

private boolean addNextToken()

addNextTokenIf

private boolean addNextTokenIf(int tok)

addSubstituteTokenIf

private boolean addSubstituteTokenIf(int tok, Token token)

addTokenToPostfix

private boolean addTokenToPostfix(int tok, Object value)

addTokenToPostfix

private boolean addTokenToPostfix(int tok, int intValue, Object value)

addTokenToPostfix

private boolean addTokenToPostfix(Token token)

addTokenToPrefix

private void addTokenToPrefix(Token token)

charToken

private boolean charToken()

checkForCoordinate

private boolean checkForCoordinate(boolean isImplicitExpression)

checkForItemSelector

private boolean checkForItemSelector()

clauseAlternateSpec

private boolean clauseAlternateSpec()

clauseAnd

private boolean clauseAnd()

clauseAtomSpec

private boolean clauseAtomSpec()

clauseCell

private boolean clauseCell()

clauseChainSpec

private boolean clauseChainSpec(int tok)

clauseComparator

private boolean clauseComparator()

clauseConnected

private boolean clauseConnected()

clauseDefine

private boolean clauseDefine()

clauseItemSelector

private boolean clauseItemSelector()

clauseModelSpec

private boolean clauseModelSpec()

clauseNot

private boolean clauseNot()

clauseOr

private boolean clauseOr(boolean allowComma)

clausePrimitive

private boolean clausePrimitive()

clauseResidueSpec

private boolean clauseResidueSpec()

clauseResNameSpec

private boolean clauseResNameSpec()

clauseSequenceSpec

private boolean clauseSequenceSpec()

clauseSubstructure

private boolean clauseSubstructure()

clauseWithin

private boolean clauseWithin()

cleanScriptComments

private static String cleanScriptComments(String script)
allows for three kinds of comments. NOTE: closing involves two asterisks and slash together, but that can't be shown here. 1) /** .... ** / 2) /* ..... * / may be INSIDE /**....** /). 3) \n//.....\n single-line comments -- like #, but removed entirely The reason is that /* ... * / will appear as standard in MOVETO command but we still might want to escape it, so around that you can have /** .... ** / also,

Parameters: script

Returns: cleaned script

commandExpected

private boolean commandExpected()

compile

boolean compile(String filename, String script, boolean isPredefining, boolean isSilent, boolean debugScript, boolean isCheckOnly)

compile0

private boolean compile0()

compileCommand

private boolean compileCommand()

compileExpression

private boolean compileExpression()

eol

private boolean eol(char ch)

error

private boolean error(int error)

error

private boolean error(int error, String value)

error

private boolean error(int error, String value, String more)

error

private boolean error(String errorMessage)

floatValue

private float floatValue()

generateResidueSpecCode

private boolean generateResidueSpecCode(Token token)

getAatokenCompiled

Token[][] getAatokenCompiled()

getBreakableContext

private Compiler.FlowContext getBreakableContext(int nLevelsUp)

getContextVariables

Hashtable getContextVariables()

getData

private boolean getData(String key)

getErrorMessage

String getErrorMessage()

getHexitValue

static int getHexitValue(char ch)

getLineIndices

int[] getLineIndices()

getLineNumbers

short[] getLineNumbers()

getNumericalToken

private boolean getNumericalToken()

getScript

String getScript()

getSequenceCode

private Token getSequenceCode(boolean isSecond)

getToken

private Token getToken()
gets the next token and sets global theToken and theValue

Returns: the next token

getUnescapedStringLiteral

String getUnescapedStringLiteral()

handleError

private boolean handleError()

intPeek

private int intPeek()

isExpressionNext

private boolean isExpressionNext()

isFunction

boolean isFunction(String name)

isLineContinuation

private boolean isLineContinuation(int ichT)

isSpaceOrTab

private static boolean isSpaceOrTab(char ch)

isSpecTerminator

private boolean isSpecTerminator(int tok)

isToken

private boolean isToken(int tok)

lookingAtBitset

BitSet lookingAtBitset()

lookingAtComment

private boolean lookingAtComment()

lookingAtDecimal

private boolean lookingAtDecimal()

lookingAtEndOfLine

private boolean lookingAtEndOfLine()
check for leading #jx or if you see it, then only strip those 4 characters if they put in #jx then they are not going to execute anything, and the regular code will take care of it

lookingAtEndOfStatement

private boolean lookingAtEndOfStatement()

lookingAtExponential

private float lookingAtExponential()

lookingAtInteger

private boolean lookingAtInteger()

lookingAtLeadingWhitespace

private boolean lookingAtLeadingWhitespace()

lookingAtLoadFormat

private boolean lookingAtLoadFormat()

lookingAtLookupToken

private boolean lookingAtLookupToken()

lookingAtObjectID

private boolean lookingAtObjectID(boolean allowWildID)

lookingAtSeqcode

private boolean lookingAtSeqcode()

lookingAtSpecialString

private boolean lookingAtSpecialString()

lookingAtString

private boolean lookingAtString()

modelValue

static int modelValue(String strDecimal)

moreTokens

private boolean moreTokens()

returnToken

private boolean returnToken()

setErrorMessages

static void setErrorMessages()

tokAt

private int tokAt(int i)

tokAttr

static boolean tokAttr(int a, int b)

tokAttrOr

static boolean tokAttrOr(int a, int b1, int b2)

tokenAttr

private static boolean tokenAttr(Token token, int tok)

tokenNext

private Token tokenNext()
increments the pointer; does NOT set theToken or theValue

Returns: the next token

tokenNext

private boolean tokenNext(int tok)

tokPeek

private int tokPeek()

tokPeek

private boolean tokPeek(int tok)

valuePeek

private Object valuePeek()