org.jmol.viewer
Class ScriptCompiler
java.lang.Object
org.jmol.viewer.ScriptCompilationTokenParser
org.jmol.viewer.ScriptCompiler
class ScriptCompiler
- extends ScriptCompilationTokenParser
Fields inherited from class org.jmol.viewer.ScriptCompilationTokenParser |
atokenInfix, ERROR_badArgumentCount, ERROR_badContext, ERROR_commandExpected, ERROR_endOfCommandUnexpected, ERROR_invalidExpressionToken, ERROR_missingEnd, ERROR_tokenExpected, ERROR_tokenUnexpected, ERROR_unrecognizedParameter, ERROR_unrecognizedToken, errorLine, errorMessage, errorMessageUntranslated, errorType, haveString, ichComment, ichCurrentCommand, ichEnd, ichToken, iCommand, isCommaAsOrAllowed, isEmbeddedExpression, isImplicitExpression, isNewSet, isSetBrace, isSetOrDefine, itokenInfix, lastFlowCommand, lastToken, lineCurrent, logMessages, nTokens, ptNewSetModifier, script, theTok, theToken, tokCommand, tokenAndEquals, tokenCommand |
Method Summary |
private void |
addContextVariable(java.lang.String ident)
|
private void |
addTokenToPrefix(Token token)
|
private boolean |
charToken()
|
private boolean |
checkFlowCommand(java.lang.String ident)
|
private boolean |
checkFlowEnd(int tok,
java.lang.String ident,
int pt1)
|
private int |
checkFlowEndBrace()
|
private boolean |
checkFlowStartBrace(boolean atEnd)
|
private int |
checkSpecialParameterSyntax()
|
private java.lang.String |
cleanScriptComments(java.lang.String script)
allows for three kinds of comments. |
(package private) ScriptContext |
compile(java.lang.String filename,
java.lang.String script,
boolean isPredefining,
boolean isSilent,
boolean debugScript,
boolean isCheckOnly)
|
private boolean |
compile0(boolean isFull)
|
private boolean |
compileCommand()
|
private boolean |
eol(char ch)
|
(package private) static boolean |
eol(char ch,
int nSkip)
|
private int |
ERROR(int error)
|
private int |
ERROR(int error,
java.lang.String value)
|
private int |
forceFlowEnd(Token token)
|
private boolean |
getData(java.lang.String key)
|
(package private) static int |
getHexitValue(char ch)
|
private java.lang.String |
getPrefixToken()
|
(package private) java.lang.String |
getUnescapedStringLiteral()
|
private boolean |
handleError()
|
(package private) static int |
ichMathTerminator(java.lang.String script,
int ichT,
int len)
For @{....} |
private int |
incrementLineCount(java.lang.String str)
|
private boolean |
isContextVariable(java.lang.String ident)
|
private boolean |
isLineContinuation(int ichT,
boolean checkMathop)
|
private static boolean |
isSpaceOrTab(char ch)
|
(package private) java.util.BitSet |
lookingAtBitset()
|
private boolean |
lookingAtBraceSyntax()
|
private int |
lookingAtComment()
|
private boolean |
lookingAtDecimal()
|
private boolean |
lookingAtEndOfLine()
|
private boolean |
lookingAtEndOfStatement()
|
private float |
lookingAtExponential()
|
private boolean |
lookingAtImpliedString()
An "implied string" is a parameter that is not quoted
but because of its position in a command is implied to
be a string. |
private boolean |
lookingAtInteger()
|
private boolean |
lookingAtLeadingWhitespace()
|
private boolean |
lookingAtLoadFormat()
|
private boolean |
lookingAtLookupToken(int ichT)
|
private boolean |
lookingAtMathContinuation(int ichT)
|
private boolean |
lookingAtObjectID(boolean allowWildID)
|
private boolean |
lookingAtSeqcode()
|
private boolean |
lookingAtString(boolean allowPrime)
|
private int |
nCharNewLine(int ichT)
|
private int |
parseCommandParameter(java.lang.String ident)
|
private int |
parseKnownToken(java.lang.String ident)
|
private ScriptContext |
parseScript(boolean doFull)
|
(package private) ScriptContext |
parseScriptForTokens(java.lang.String script)
return a structure that is only the first part of the process - identifying lines and commands
for the scriptEditor |
private int |
processTokenList(short iLine,
boolean doCompile)
|
private void |
setAaTokenCompiled()
|
Methods inherited from class java.lang.Object |
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
LOAD_TYPES
private static final java.lang.String LOAD_TYPES
- The Compiler clas is really two parts --
Compiler.class going from characters to tokens
CompilationTokenParser further syntax checking and modifications
The data structures follow the following sequences:
String script ==> Vector lltoken[][] --> Token[][] aatokenCompiled[][]
A given command goes through the sequence:
String characters --> Token token --> Vector ltoken[] --> Token[][] aatokenCompiled[][]
- See Also:
- Constant Field Values
viewer
private Viewer viewer
filename
private java.lang.String filename
isSilent
private boolean isSilent
contextVariables
private java.util.Hashtable contextVariables
aatokenCompiled
private Token[][] aatokenCompiled
lineNumbers
private short[] lineNumbers
lineIndices
private int[][] lineIndices
lnLength
private int lnLength
preDefining
private boolean preDefining
isShowScriptOutput
private boolean isShowScriptOutput
isCheckOnly
private boolean isCheckOnly
haveComments
private boolean haveComments
scriptExtensions
java.lang.String scriptExtensions
thisFunction
private ScriptFunction thisFunction
flowContext
private ScriptFlowContext flowContext
ltoken
private java.util.Vector ltoken
lltoken
private java.util.Vector lltoken
vBraces
private java.util.Vector vBraces
ichBrace
private int ichBrace
cchToken
private int cchToken
cchScript
private int cchScript
nSemiSkip
private int nSemiSkip
parenCount
private int parenCount
braceCount
private int braceCount
setBraceCount
private int setBraceCount
bracketCount
private int bracketCount
ptSemi
private int ptSemi
forPoint3
private int forPoint3
setEqualPt
private int setEqualPt
iBrace
private int iBrace
iHaveQuotedString
private boolean iHaveQuotedString
isEndOfCommand
private boolean isEndOfCommand
needRightParen
private boolean needRightParen
endOfLine
private boolean endOfLine
comment
private java.lang.String comment
OK
private static final int OK
- See Also:
- Constant Field Values
OK2
private static final int OK2
- See Also:
- Constant Field Values
CONTINUE
private static final int CONTINUE
- See Also:
- Constant Field Values
EOL
private static final int EOL
- See Also:
- Constant Field Values
ERROR
private static final int ERROR
- See Also:
- Constant Field Values
tokLastMath
private int tokLastMath
isShowCommand
private boolean isShowCommand
chFirst
char chFirst
ScriptCompiler
ScriptCompiler(Viewer viewer)
parseScriptForTokens
ScriptContext parseScriptForTokens(java.lang.String script)
- return a structure that is only the first part of the process - identifying lines and commands
for the scriptEditor
- Parameters:
script
-
- Returns:
- ScriptContext
parseScript
private ScriptContext parseScript(boolean doFull)
compile
ScriptContext compile(java.lang.String filename,
java.lang.String script,
boolean isPredefining,
boolean isSilent,
boolean debugScript,
boolean isCheckOnly)
addContextVariable
private void addContextVariable(java.lang.String ident)
isContextVariable
private boolean isContextVariable(java.lang.String ident)
cleanScriptComments
private java.lang.String cleanScriptComments(java.lang.String script)
- allows for three kinds of comments.
NOTE: closing involves asterisks and slash together, but that can't be shown here.
1) /** .... ** / super-comment
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 /** .... ** /
The terminator is not necessary -- so you can quickly escape anything in a file
after /** or /*
In addition, we can have [/*|/**] .... **** Jmol Embedded Script **** [script commands] [** /|* /]
Then ONLY that script is taken. This is a powerful and simple way then to include Jmol scripting
in any file -- including, for example, HTML as an HTML comment. Just send the whole file to
Jmol, and it will find its script!
- Parameters:
script
-
- Returns:
- cleaned script
addTokenToPrefix
private void addTokenToPrefix(Token token)
compile0
private boolean compile0(boolean isFull)
setAaTokenCompiled
private void setAaTokenCompiled()
lookingAtLeadingWhitespace
private boolean lookingAtLeadingWhitespace()
isLineContinuation
private boolean isLineContinuation(int ichT,
boolean checkMathop)
lookingAtMathContinuation
private boolean lookingAtMathContinuation(int ichT)
lookingAtEndOfLine
private boolean lookingAtEndOfLine()
nCharNewLine
private int nCharNewLine(int ichT)
lookingAtEndOfStatement
private boolean lookingAtEndOfStatement()
lookingAtComment
private int lookingAtComment()
processTokenList
private int processTokenList(short iLine,
boolean doCompile)
compileCommand
private boolean compileCommand()
getPrefixToken
private java.lang.String getPrefixToken()
checkSpecialParameterSyntax
private int checkSpecialParameterSyntax()
parseKnownToken
private int parseKnownToken(java.lang.String ident)
parseCommandParameter
private int parseCommandParameter(java.lang.String ident)
checkFlowStartBrace
private boolean checkFlowStartBrace(boolean atEnd)
checkFlowEndBrace
private int checkFlowEndBrace()
forceFlowEnd
private int forceFlowEnd(Token token)
checkFlowCommand
private boolean checkFlowCommand(java.lang.String ident)
checkFlowEnd
private boolean checkFlowEnd(int tok,
java.lang.String ident,
int pt1)
getData
private boolean getData(java.lang.String key)
incrementLineCount
private int incrementLineCount(java.lang.String str)
isSpaceOrTab
private static boolean isSpaceOrTab(char ch)
eol
private boolean eol(char ch)
eol
static boolean eol(char ch,
int nSkip)
lookingAtBraceSyntax
private boolean lookingAtBraceSyntax()
lookingAtString
private boolean lookingAtString(boolean allowPrime)
getUnescapedStringLiteral
java.lang.String getUnescapedStringLiteral()
getHexitValue
static int getHexitValue(char ch)
lookingAtLoadFormat
private boolean lookingAtLoadFormat()
lookingAtImpliedString
private boolean lookingAtImpliedString()
- An "implied string" is a parameter that is not quoted
but because of its position in a command is implied to
be a string. First we must exclude @xxxx. Then we consume
the entire math syntax @{......} or any set of characters
not involving white space.
- Returns:
- true or false
ichMathTerminator
static int ichMathTerminator(java.lang.String script,
int ichT,
int len)
- For @{....}
- Parameters:
script
- ichT
- len
-
- Returns:
- position of "}"
lookingAtExponential
private float lookingAtExponential()
lookingAtDecimal
private boolean lookingAtDecimal()
lookingAtSeqcode
private boolean lookingAtSeqcode()
lookingAtInteger
private boolean lookingAtInteger()
lookingAtBitset
java.util.BitSet lookingAtBitset()
lookingAtObjectID
private boolean lookingAtObjectID(boolean allowWildID)
lookingAtLookupToken
private boolean lookingAtLookupToken(int ichT)
charToken
private boolean charToken()
ERROR
private int ERROR(int error)
ERROR
private int ERROR(int error,
java.lang.String value)
handleError
private boolean handleError()