From: <ha...@us...> - 2014-02-08 16:47:58
|
Revision: 19289 http://sourceforge.net/p/jmol/code/19289 Author: hansonr Date: 2014-02-08 16:47:53 +0000 (Sat, 08 Feb 2014) Log Message: ----------- ___JmolVersion="14.1.8" bug fix: label @{math expression...} not working Modified Paths: -------------- trunk/Jmol/src/org/jmol/script/ScriptCompilationTokenParser.java trunk/Jmol/src/org/jmol/script/ScriptCompiler.java trunk/Jmol/src/org/jmol/script/T.java trunk/Jmol/src/org/jmol/viewer/Jmol.properties Modified: trunk/Jmol/src/org/jmol/script/ScriptCompilationTokenParser.java =================================================================== --- trunk/Jmol/src/org/jmol/script/ScriptCompilationTokenParser.java 2014-02-08 12:30:56 UTC (rev 19288) +++ trunk/Jmol/src/org/jmol/script/ScriptCompilationTokenParser.java 2014-02-08 16:47:53 UTC (rev 19289) @@ -101,12 +101,18 @@ protected boolean compileExpressions() { boolean isScriptExpression = (tokCommand == T.script && tokAt(2) == T.leftparen); - isEmbeddedExpression = isScriptExpression || (tokCommand != T.nada - && (tokCommand != T.function && tokCommand != T.parallel - && tokCommand != T.trycmd && tokCommand != T.catchcmd - || tokenCommand.intValue != Integer.MAX_VALUE) - && tokCommand != T.end && !T.tokAttrOr(tokCommand, T.atomExpressionCommand, - T.implicitStringCommand)); + isEmbeddedExpression = (isScriptExpression + || (tokCommand != T.nada + && (tokCommand != T.function + && tokCommand != T.parallel + && tokCommand != T.trycmd + && tokCommand != T.catchcmd + || tokenCommand.intValue != Integer.MAX_VALUE) + && tokCommand != T.end + && !T.tokAttr(tokCommand, T.atomExpressionCommand) + && (nTokens > 2 || !T.tokAttr(tokCommand, T.implicitStringCommand)) + ) + ); isMathExpressionCommand = (tokCommand == T.identifier || isScriptExpression || T.tokAttr(tokCommand, T.mathExpressionCommand)); Modified: trunk/Jmol/src/org/jmol/script/ScriptCompiler.java =================================================================== --- trunk/Jmol/src/org/jmol/script/ScriptCompiler.java 2014-02-08 12:30:56 UTC (rev 19288) +++ trunk/Jmol/src/org/jmol/script/ScriptCompiler.java 2014-02-08 16:47:53 UTC (rev 19289) @@ -1122,6 +1122,9 @@ } break; } + // cd echo goto help hover javascript label message pause + // possibly script + implicitString &= (nTokens == 1); if (implicitString && !(tokCommand == T.script && iHaveQuotedString) && lookingAtImpliedString(true, true, true)) { String str = script.substring(ichToken, ichToken + cchToken); @@ -2294,11 +2297,12 @@ /** * 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 - * the @xxxx. Then we consume the entire math syntax @{......} or any set of - * characters not involving white space. echo, hover, label, message, pause - * are odd-valued; no initial parsing of variables for them. + * position in a command is implied to be a string. First we must exclude the * + * @xxxx. Then we consume the entire math syntax @{......} or any set of + * characters not involving white space. echo, hover, message, and + * pause are odd-valued; no initial parsing of variables for them. + * * @param allowSpace * as in commands such as echo * @param allowEquals @@ -2315,15 +2319,21 @@ int ichT = ichToken; char ch = script.charAt(ichT); boolean isID = (lastToken.tok == T.id); - boolean parseVariables = (isID || !T.tokAttr(tokCommand, + boolean passVariableToString = (T.tokAttr(tokCommand, T.implicitStringCommand) && (tokCommand & 1) == 1); boolean isVariable = (ch == '@'); boolean isMath = (isVariable && ichT + 3 < cchScript && script .charAt(ichT + 1) == '{'); - if (isMath && parseVariables) { - ichT = Txt.ichMathTerminator(script, ichToken + 1, cchScript); - return (!isID && ichT != cchScript && (cchToken = ichT + 1 - ichToken) > 0); - } + if (isMath && (isID || !passVariableToString)) + return false; + // if (isMath && passVariableToString) { + // // zip past math expression untested. + // ichT = Txt.ichMathTerminator(script, ichToken + 1, cchScript); + // return (!isID && ichT != cchScript && (cchToken = ichT + 1 - ichToken) > 0); + // } + // if (isMath && !passVariableToString) + // return false; + // check implicit string for math expression here int ptSpace = -1; int ptLastChar = -1; // look ahead to \n, \r, terminal ;, or } @@ -2334,10 +2344,10 @@ case '(': if (!allowSptParen) { // script command - if (ichT >= 5 && ( - script.substring(ichT - 4, ichT).equals(".spt") - || script.substring(ichT - 4, ichT).equals(".png") - || script.substring(ichT - 5, ichT).equals(".pngj"))) { + if (ichT >= 5 + && (script.substring(ichT - 4, ichT).equals(".spt") + || script.substring(ichT - 4, ichT).equals(".png") || script + .substring(ichT - 5, ichT).equals(".pngj"))) { isOK = false; continue; } @@ -2353,13 +2363,13 @@ parenpt++; break; case '}': - // only consider this if it is extra + // fail if improperly nested parenpt--; if (parenpt < 0 && (braceCount > 0 || iBrace > 0)) { isOK = false; continue; } - break; + //$FALL-THROUGH$ default: if (Character.isWhitespace(ch)) { if (ptSpace < 0) @@ -2380,7 +2390,9 @@ ichT = ptLastChar + 1; else if (ptSpace > 0) ichT = ptSpace; - if (isVariable && (!allowSpace || ptSpace < 0 && parenpt <= 0 && ichT - ichToken > 1)) { + if (isVariable + && (!allowSpace || ptSpace < 0 && parenpt <= 0 + && ichT - ichToken > 1)) { // if we have @xxx then this is not an implied string return false; } Modified: trunk/Jmol/src/org/jmol/script/T.java =================================================================== --- trunk/Jmol/src/org/jmol/script/T.java 2014-02-08 12:30:56 UTC (rev 19288) +++ trunk/Jmol/src/org/jmol/script/T.java 2014-02-08 16:47:53 UTC (rev 19289) @@ -688,8 +688,8 @@ public final static int format = 7 | 0 << 9 | mathfunc | mathproperty | strproperty | settable; public final static int function = 9 | 0 << 9 | mathfunc | flowCommand; public final static int getproperty = 10 | 0 << 9 | mathfunc | mathproperty | scriptCommand; - public final static int label = 11 /* must be odd */| 0 << 9 | mathfunc | mathproperty | strproperty | settable | implicitStringCommand | shapeCommand | defaultON | deprecatedparam; - public final static int helix = 12 | 0 << 9 | mathfunc | predefinedset; + public final static int helix = 11 | 0 << 9 | mathfunc | predefinedset; + public final static int label = 12 /* must NOT be odd */| 0 << 9 | mathfunc | mathproperty | strproperty | settable | implicitStringCommand | shapeCommand | defaultON | deprecatedparam; public final static int measure = 13 | 0 << 9| mathfunc | shapeCommand | deprecatedparam | defaultON; public final static int now = 14 | 0 << 9 | mathfunc; public final static int plane = 15 | 0 << 9 | mathfunc; Modified: trunk/Jmol/src/org/jmol/viewer/Jmol.properties =================================================================== --- trunk/Jmol/src/org/jmol/viewer/Jmol.properties 2014-02-08 12:30:56 UTC (rev 19288) +++ trunk/Jmol/src/org/jmol/viewer/Jmol.properties 2014-02-08 16:47:53 UTC (rev 19289) @@ -15,6 +15,7 @@ ___JmolVersion="14.1.8" +bug fix: label @{math expression...} not working bug fix: interpretation of x and @x in select commands and {...} phrases -- Variable substitution has been unintuitive and inconsistent. For instance: This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |