Revision: 20930 http://sourceforge.net/p/jmol/code/20930 Author: hansonr Date: 2016-01-15 22:25:54 +0000 (Fri, 15 Jan 2016) Log Message: ----------- Jmol.___JmolVersion="14.4.1_2016.01.15"
bug fix: d = [start:1,end:10] fails due to reserved word "end" (also "select", "case", "default", "if", "for", etc.) bug fix: color "chain" (with quotes) should work, allowing for x="chain"; color @x bug fix: inappropriate use of REGEX in ["a","b"].find("x") bug fix: ".xxx" should be allowed as a math continuation: print script("show spacegroup all") .split() .find("Hall symbol:") JavaScript Info._makeLiveImage Modified Paths: -------------- branches/v14_4/Jmol/src/org/jmol/script/ScriptCompiler.java branches/v14_4/Jmol/src/org/jmol/script/ScriptEval.java branches/v14_4/Jmol/src/org/jmol/script/ScriptFunction.java branches/v14_4/Jmol/src/org/jmol/scriptext/MathExt.java branches/v14_4/Jmol/src/org/jmol/viewer/Jmol.properties trunk/Jmol/src/org/jmol/script/ScriptCompiler.java trunk/Jmol/src/org/jmol/script/ScriptEval.java trunk/Jmol/src/org/jmol/script/ScriptFunction.java trunk/Jmol/src/org/jmol/scriptext/MathExt.java trunk/Jmol/src/org/jmol/viewer/Jmol.properties Modified: branches/v14_4/Jmol/src/org/jmol/script/ScriptCompiler.java =================================================================== --- branches/v14_4/Jmol/src/org/jmol/script/ScriptCompiler.java 2016-01-09 13:13:09 UTC (rev 20929) +++ branches/v14_4/Jmol/src/org/jmol/script/ScriptCompiler.java 2016-01-15 22:25:54 UTC (rev 20930) @@ -1425,8 +1425,8 @@ if (tokLastMath != 0) tokLastMath = tok; if (flowContext != null && flowContext.token.tok == T.switchcmd - && flowContext.var != null && tok != T.casecmd - && tok != T.defaultcmd && lastToken.tok != T.switchcmd) + && flowContext.var != null && tok != T.casecmd && tok != T.defaultcmd + && lastToken.tok != T.switchcmd) return ERROR(ERROR_badContext, ident); if (lastToken.tok == T.define && tok != T.leftbrace && nTokens != 1) { addTokenToPrefix(tok == T.define ? lastToken : T.o(T.string, ident)); @@ -1479,44 +1479,6 @@ } // otherwise ignore return CONTINUE; - case T.end: - if (tokCommand == T.cgo || tokCommand == T.capture && nTokens == 1) - return OK; - if (!haveENDIF) - return RESTART; - // end for, end function - //$FALL-THROUGH$ - case T.endifcmd: - if (flowContext != null) - flowContext.forceEndIf = false; - - //$FALL-THROUGH$ - case T.elsecmd: - if (nTokens > 0) { - isEndOfCommand = true; - cchToken = 0; - return CONTINUE; - } - break; - case T.forcmd: - if (bracketCount > 0) // ignore [FOR], as in 1C4D - break; - //$FALL-THROUGH$ - case T.casecmd: - case T.defaultcmd: - case T.elseif: - case T.ifcmd: - case T.switchcmd: - case T.whilecmd: - case T.catchcmd: - if (nTokens > 1 && tokCommand != T.set && nSemiSkip == 0) { - isEndOfCommand = true; - if (flowContext != null) - flowContext.forceEndIf = true; - cchToken = 0; - return CONTINUE; - } - break; case T.minusMinus: case T.plusPlus: if (afterWhite == ichToken || afterMath == ichToken) @@ -1626,8 +1588,54 @@ addTokenToPrefix(T.tokenArrayOpen); return CONTINUE; } + // check for token in [start:3,end:5] + // x.end + // x..end + switch (lastToken.tok) { + case T.per: + case T.perper: + case T.comma: + case T.leftsquare: return OK; } + switch (tok) { + case T.end: + if (tokCommand == T.cgo || tokCommand == T.capture && nTokens == 1) + return OK; + if (!haveENDIF) + return RESTART; + // end for, end function + //$FALL-THROUGH$ + case T.endifcmd: + if (flowContext != null) + flowContext.forceEndIf = false; + //$FALL-THROUGH$ + case T.elsecmd: + if (nTokens > 0) { + isEndOfCommand = true; + cchToken = 0; + return CONTINUE; + } + break; + case T.forcmd: + case T.casecmd: + case T.defaultcmd: + case T.elseif: + case T.ifcmd: + case T.switchcmd: + case T.whilecmd: + case T.catchcmd: + if (nTokens > 1 && tokCommand != T.set && nSemiSkip == 0) { + isEndOfCommand = true; + if (flowContext != null) + flowContext.forceEndIf = true; + cchToken = 0; + return CONTINUE; + } + break; + } + return OK; + } private void tokenizePlusPlus(int tok, boolean isPlusPlusX) { // ++ipt; or ipt++ @@ -1707,8 +1715,7 @@ flowContext.forceEndIf = true; lltoken.remove(--iCommand); } else if (flowContext != null && flowContext.addLine > 0) { - while (flowContext != null - && !isFlowIfContextOK(flowContext)) { + while (flowContext != null && !isFlowIfContextOK(flowContext)) { if (flowContext.checkForceEndIf(0)) { forceFlowEnd(flowContext.token); processTokenList(iLine, isFull); @@ -1761,6 +1768,8 @@ } if (theTok == T.rightbrace) { // if }, just push onto vBrace, but NOT onto ltoken + // no longer necessary to force end + forceFlowContext = null; addBrace(tokenCommand); tokCommand = T.nada; return CONTINUE; @@ -1847,9 +1856,10 @@ if (nTokens == 1) { if (thisFunction != null) vFunctionStack.add(0, thisFunction); - thisFunction = (ScriptFunction) Interface.getInterface( - "org.jmol.script.ScriptParallelProcessor", null, null); - thisFunction.set(ident, T.parallel); + thisFunction = (tokCommand == T.parallel ? (ScriptFunction) Interface + .getInterface("org.jmol.script.ScriptParallelProcessor", null, null) + : new ScriptFunction(ident, tokCommand)); + thisFunction.set(ident, tokCommand); htUserFunctions.put(ident, Boolean.TRUE); flowContext.setFunction(thisFunction); break; // function f @@ -2955,6 +2965,7 @@ case '.': if (charAt(ichT) == '.') ++ichT; + tokLastMath = 1; break; case '@': case '{': Modified: branches/v14_4/Jmol/src/org/jmol/script/ScriptEval.java =================================================================== --- branches/v14_4/Jmol/src/org/jmol/script/ScriptEval.java 2016-01-09 13:13:09 UTC (rev 20929) +++ branches/v14_4/Jmol/src/org/jmol/script/ScriptEval.java 2016-01-15 22:25:54 UTC (rev 20930) @@ -392,7 +392,7 @@ this.historyDisabled = historyDisabled; this.outputBuffer = outputBuffer; currentThread = Thread.currentThread(); - this.allowJSThreads = allowThreads; + allowJSThreads = allowThreads; this.listCommands = listCommands; timeBeginExecution = System.currentTimeMillis(); executionStopped = executionPaused = false; @@ -3053,12 +3053,18 @@ private void cmdColor() throws ScriptException { int i = 1; + String strColor = (tokAt(1) == T.string ? stringParameter(1) : null); if (isColorParam(1)) { theTok = T.atoms; } else { int argb = 0; i = 2; int tok = getToken(1).tok; + if (tok == T.string) { + tok = T.getTokFromName(strColor); + if (tok == T.nada) + tok = T.string; + } switch (tok) { case T.dollarsign: setObjectProperty(); @@ -3094,8 +3100,7 @@ i = 1; break; case T.string: - i = 1; - String strColor = stringParameter(i++); + i = 2; if (isArrayParameter(i)) { strColor = strColor += "=" + SV.sValue(SV.getVariableAS(stringParameterSet(i))).replace( @@ -4303,7 +4308,7 @@ // LOAD [[APPEND]] SMILES // LOAD [[APPEND]] TRAJECTORY // LOAD [[APPEND]] MODEL - // LOAD SYNC (asynchronous -- flag for RecentFileDialog) + // LOAD ASYNC (asynchronous -- flag for RecentFileDialog) // LOAD [[APPEND]] "fileNameInQuotes" switch (tok) { Modified: branches/v14_4/Jmol/src/org/jmol/script/ScriptFunction.java =================================================================== --- branches/v14_4/Jmol/src/org/jmol/script/ScriptFunction.java 2016-01-09 13:13:09 UTC (rev 20929) +++ branches/v14_4/Jmol/src/org/jmol/script/ScriptFunction.java 2016-01-15 22:25:54 UTC (rev 20930) @@ -173,7 +173,7 @@ @Override public String toString() { SB s = new SB().append("/*\n * ").append(name) - .append("\n */\n").append(getSignature()).append("{\n"); + .append("\n */\n").append(getSignature()).append(" {\n"); if (script != null) s.append(script); s.append("}\n"); @@ -185,7 +185,7 @@ if (typeName == null) return T.nameOf(tok); SB s = new SB().append(typeName) - .append(" ").append(name).append(" ("); + .append(" ").append(name).append("("); for (int i = 0; i < nParameters; i++) { if (i > 0) s.append(", "); Modified: branches/v14_4/Jmol/src/org/jmol/scriptext/MathExt.java =================================================================== --- branches/v14_4/Jmol/src/org/jmol/scriptext/MathExt.java 2016-01-09 13:13:09 UTC (rev 20929) +++ branches/v14_4/Jmol/src/org/jmol/scriptext/MathExt.java 2016-01-15 22:25:54 UTC (rev 20930) @@ -1308,22 +1308,21 @@ boolean isReverse = (flags.indexOf("v") >= 0); boolean isCaseInsensitive = (flags.indexOf("i") >= 0); boolean asMatch = (flags.indexOf("m") >= 0); - boolean isPattern = (args.length == 2); + boolean checkEmpty = (sFind.length() == 0); + boolean isPattern = (!checkEmpty && args.length == 2); if (isList || isPattern) { - JmolPatternMatcher pm = getPatternMatcher(); + JmolPatternMatcher pm = (isPattern ? getPatternMatcher() : null); Pattern pattern = null; - String[] list = null; Lst<SV> svlist = (isList ? x1.getList() : null); - if (sFind.length() > 0) { + if (isPattern) { try { - pattern = (sFind.length() == 0 ? null : pm.compile(sFind, - isCaseInsensitive)); - list = SV.strListValue(x1); + pattern = pm.compile(sFind, isCaseInsensitive); } catch (Exception ex) { e.evalError(ex.toString(), null); } } - int nlist = (list == null ? svlist.size() : list.length); + String[] list = (checkEmpty ? null : SV.strListValue(x1)); + int nlist = (checkEmpty ? svlist.size() : list.length); if (Logger.debugging) Logger.debug("finding " + sFind); BS bs = new BS(); @@ -1333,7 +1332,7 @@ String what = ""; for (int i = 0; i < nlist; i++) { boolean isMatch; - if (pattern == null) { + if (checkEmpty) { SV o = svlist.get(i); switch (o.tok) { case T.hash: @@ -1348,10 +1347,12 @@ default: isMatch = true; } - } else { + } else if (isPattern) { what = list[i]; matcher = pattern.matcher(what); isMatch = matcher.find(); + } else { + isMatch = (SV.sValue(svlist.get(i)).indexOf(sFind) >= 0); } if (asMatch && isMatch || !asMatch && isMatch == !isReverse) { n++; Modified: branches/v14_4/Jmol/src/org/jmol/viewer/Jmol.properties =================================================================== --- branches/v14_4/Jmol/src/org/jmol/viewer/Jmol.properties 2016-01-09 13:13:09 UTC (rev 20929) +++ branches/v14_4/Jmol/src/org/jmol/viewer/Jmol.properties 2016-01-15 22:25:54 UTC (rev 20930) @@ -7,8 +7,20 @@ # see also http://chemapps.stolaf.edu/jmol/zip for daily updates -Jmol.___JmolVersion="14.4.1_2016.01.09" +Jmol.___JmolVersion="14.4.1_2016.01.15" +bug fix: d = [start:1,end:10] fails due to reserved word "end" (also "select", "case", "default", "if", "for", etc.) +bug fix: color "chain" (with quotes) should work, allowing for x="chain"; color @x +bug fix: inappropriate use of REGEX in ["a","b"].find("x") +bug fix: ".xxx" should be allowed as a math continuation: + + print script("show spacegroup all") + .split() + .find("Hall symbol:") + + +JmolVersion="14.4.1_2016.01.09" + code: (JavaScript) refactoring to allow faster, cleaner load for biomodels JmolVersion="14.4.1_2016.01.08" Modified: trunk/Jmol/src/org/jmol/script/ScriptCompiler.java =================================================================== --- trunk/Jmol/src/org/jmol/script/ScriptCompiler.java 2016-01-09 13:13:09 UTC (rev 20929) +++ trunk/Jmol/src/org/jmol/script/ScriptCompiler.java 2016-01-15 22:25:54 UTC (rev 20930) @@ -1425,8 +1425,8 @@ if (tokLastMath != 0) tokLastMath = tok; if (flowContext != null && flowContext.token.tok == T.switchcmd - && flowContext.var != null && tok != T.casecmd - && tok != T.defaultcmd && lastToken.tok != T.switchcmd) + && flowContext.var != null && tok != T.casecmd && tok != T.defaultcmd + && lastToken.tok != T.switchcmd) return ERROR(ERROR_badContext, ident); if (lastToken.tok == T.define && tok != T.leftbrace && nTokens != 1) { addTokenToPrefix(tok == T.define ? lastToken : T.o(T.string, ident)); @@ -1479,44 +1479,6 @@ } // otherwise ignore return CONTINUE; - case T.end: - if (tokCommand == T.cgo || tokCommand == T.capture && nTokens == 1) - return OK; - if (!haveENDIF) - return RESTART; - // end for, end function - //$FALL-THROUGH$ - case T.endifcmd: - if (flowContext != null) - flowContext.forceEndIf = false; - - //$FALL-THROUGH$ - case T.elsecmd: - if (nTokens > 0) { - isEndOfCommand = true; - cchToken = 0; - return CONTINUE; - } - break; - case T.forcmd: - if (bracketCount > 0) // ignore [FOR], as in 1C4D - break; - //$FALL-THROUGH$ - case T.casecmd: - case T.defaultcmd: - case T.elseif: - case T.ifcmd: - case T.switchcmd: - case T.whilecmd: - case T.catchcmd: - if (nTokens > 1 && tokCommand != T.set && nSemiSkip == 0) { - isEndOfCommand = true; - if (flowContext != null) - flowContext.forceEndIf = true; - cchToken = 0; - return CONTINUE; - } - break; case T.minusMinus: case T.plusPlus: if (afterWhite == ichToken || afterMath == ichToken) @@ -1557,14 +1519,14 @@ if (++braceCount == 1 && parenCount == 0 && checkFlowStartBrace(false)) { // specifically for else { but not elseIf ( ) { isEndOfCommand = true; - ScriptFlowContext f = (flowContext != null && flowContext.addLine == 0 + ScriptFlowContext f = (flowContext != null && flowContext.addLine == 0 || forceFlowContext == null ? flowContext : forceFlowContext); if (f != null) { f.addLine = 0; f.forceEndIf = false; lastToken = T.tokenLeftBrace; forceFlowContext = f; - } + } return CONTINUE; } parenCount++; @@ -1626,6 +1588,52 @@ addTokenToPrefix(T.tokenArrayOpen); return CONTINUE; } + // check for token in [start:3,end:5] + // x.end + // x..end + switch (lastToken.tok) { + case T.per: + case T.perper: + case T.comma: + case T.leftsquare: + return OK; + } + switch (tok) { + case T.end: + if (tokCommand == T.cgo || tokCommand == T.capture && nTokens == 1) + return OK; + if (!haveENDIF) + return RESTART; + // end for, end function + //$FALL-THROUGH$ + case T.endifcmd: + if (flowContext != null) + flowContext.forceEndIf = false; + //$FALL-THROUGH$ + case T.elsecmd: + if (nTokens > 0) { + isEndOfCommand = true; + cchToken = 0; + return CONTINUE; + } + break; + case T.forcmd: + case T.casecmd: + case T.defaultcmd: + case T.elseif: + case T.ifcmd: + case T.switchcmd: + case T.whilecmd: + case T.catchcmd: + if (nTokens > 1 && tokCommand != T.set && nSemiSkip == 0) { + isEndOfCommand = true; + if (flowContext != null) + flowContext.forceEndIf = true; + cchToken = 0; + return CONTINUE; + } + break; + } return OK; } @@ -1707,8 +1715,7 @@ flowContext.forceEndIf = true; lltoken.remove(--iCommand); } else if (flowContext != null && flowContext.addLine > 0) { - while (flowContext != null - && !isFlowIfContextOK(flowContext)) { + while (flowContext != null && !isFlowIfContextOK(flowContext)) { if (flowContext.checkForceEndIf(0)) { forceFlowEnd(flowContext.token); processTokenList(iLine, isFull); @@ -1849,9 +1856,10 @@ if (nTokens == 1) { if (thisFunction != null) vFunctionStack.add(0, thisFunction); - thisFunction = (ScriptFunction) Interface.getInterface( - "org.jmol.script.ScriptParallelProcessor", null, null); - thisFunction.set(ident, T.parallel); + thisFunction = (tokCommand == T.parallel ? (ScriptFunction) Interface + .getInterface("org.jmol.script.ScriptParallelProcessor", null, null) + : new ScriptFunction(ident, tokCommand)); + thisFunction.set(ident, tokCommand); htUserFunctions.put(ident, Boolean.TRUE); flowContext.setFunction(thisFunction); break; // function f @@ -2957,6 +2965,7 @@ case '.': if (charAt(ichT) == '.') ++ichT; + tokLastMath = 1; break; case '@': case '{': Modified: trunk/Jmol/src/org/jmol/script/ScriptEval.java =================================================================== --- trunk/Jmol/src/org/jmol/script/ScriptEval.java 2016-01-09 13:13:09 UTC (rev 20929) +++ trunk/Jmol/src/org/jmol/script/ScriptEval.java 2016-01-15 22:25:54 UTC (rev 20930) @@ -3053,12 +3053,18 @@ private void cmdColor() throws ScriptException { int i = 1; + String strColor = (tokAt(1) == T.string ? stringParameter(1) : null); if (isColorParam(1)) { theTok = T.atoms; } else { int argb = 0; i = 2; int tok = getToken(1).tok; + if (tok == T.string) { + tok = T.getTokFromName(strColor); + if (tok == T.nada) + tok = T.string; + } switch (tok) { case T.dollarsign: setObjectProperty(); @@ -3094,8 +3100,7 @@ i = 1; break; case T.string: - i = 1; - String strColor = stringParameter(i++); + i = 2; if (isArrayParameter(i)) { strColor = strColor += "=" + SV.sValue(SV.getVariableAS(stringParameterSet(i))).replace( Modified: trunk/Jmol/src/org/jmol/script/ScriptFunction.java =================================================================== --- trunk/Jmol/src/org/jmol/script/ScriptFunction.java 2016-01-09 13:13:09 UTC (rev 20929) +++ trunk/Jmol/src/org/jmol/script/ScriptFunction.java 2016-01-15 22:25:54 UTC (rev 20930) @@ -173,7 +173,7 @@ @Override public String toString() { SB s = new SB().append("/*\n * ").append(name) - .append("\n */\n").append(getSignature()).append("{\n"); + .append("\n */\n").append(getSignature()).append(" {\n"); if (script != null) s.append(script); s.append("}\n"); @@ -185,7 +185,7 @@ if (typeName == null) return T.nameOf(tok); SB s = new SB().append(typeName) - .append(" ").append(name).append(" ("); + .append(" ").append(name).append("("); for (int i = 0; i < nParameters; i++) { if (i > 0) s.append(", "); Modified: trunk/Jmol/src/org/jmol/scriptext/MathExt.java =================================================================== --- trunk/Jmol/src/org/jmol/scriptext/MathExt.java 2016-01-09 13:13:09 UTC (rev 20929) +++ trunk/Jmol/src/org/jmol/scriptext/MathExt.java 2016-01-15 22:25:54 UTC (rev 20930) @@ -1379,22 +1379,21 @@ boolean isReverse = (flags.indexOf("v") >= 0); boolean isCaseInsensitive = (flags.indexOf("i") >= 0); boolean asMatch = (flags.indexOf("m") >= 0); - boolean isPattern = (args.length == 2); + boolean checkEmpty = (sFind.length() == 0); + boolean isPattern = (!checkEmpty && args.length == 2); if (isList || isPattern) { - JmolPatternMatcher pm = getPatternMatcher(); + JmolPatternMatcher pm = (isPattern ? getPatternMatcher() : null); Pattern pattern = null; - String[] list = null; Lst<SV> svlist = (isList ? x1.getList() : null); - if (sFind.length() > 0) { + if (isPattern) { try { - pattern = (sFind.length() == 0 ? null : pm.compile(sFind, - isCaseInsensitive)); - list = SV.strListValue(x1); + pattern = pm.compile(sFind, isCaseInsensitive); } catch (Exception ex) { e.evalError(ex.toString(), null); } } - int nlist = (list == null ? svlist.size() : list.length); + String[] list = (checkEmpty ? null : SV.strListValue(x1)); + int nlist = (checkEmpty ? svlist.size() : list.length); if (Logger.debugging) Logger.debug("finding " + sFind); BS bs = new BS(); @@ -1404,7 +1403,7 @@ String what = ""; for (int i = 0; i < nlist; i++) { boolean isMatch; - if (pattern == null) { + if (checkEmpty) { SV o = svlist.get(i); switch (o.tok) { case T.hash: @@ -1419,10 +1418,12 @@ default: isMatch = true; } - } else { + } else if (isPattern) { what = list[i]; matcher = pattern.matcher(what); isMatch = matcher.find(); + } else { + isMatch = (SV.sValue(svlist.get(i)).indexOf(sFind) >= 0); } if (asMatch && isMatch || !asMatch && isMatch == !isReverse) { n++; Modified: trunk/Jmol/src/org/jmol/viewer/Jmol.properties =================================================================== --- trunk/Jmol/src/org/jmol/viewer/Jmol.properties 2016-01-09 13:13:09 UTC (rev 20929) +++ trunk/Jmol/src/org/jmol/viewer/Jmol.properties 2016-01-15 22:25:54 UTC (rev 20930) @@ -63,8 +63,19 @@ TODO: consider if models with no atoms will cause issues in relation to model.firstAtomIndex -Jmol.___JmolVersion="14.5.1_2016.01.09" +Jmol.___JmolVersion="14.5.1_2016.01.15" +bug fix: d = [start:1,end:10] fails due to reserved word "end" (also "select", "case", "default", "if", "for", etc.) +bug fix: color "chain" (with quotes) should work, allowing for x="chain"; color @x +bug fix: inappropriate use of REGEX in ["a","b"].find("x") +bug fix: ".xxx" should be allowed as a math continuation: + + print script("show spacegroup all") + .split() + .find("Hall symbol:") + +JmolVersion="14.5.1_2016.01.09" + code: (JavaScript) refactoring to allow faster, cleaner load for biomodels JmolVersion="14.5.1_2016.01.08" This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. ------------------------------------------------------------------------------ Site24x7 APM Insight: Get Deep Visibility into Application Performance APM + Mobile APM + RUM: Monitor 3 App instances at just $35/Month Monitor end-to-end web transactions and take corrective actions now Troubleshoot faster and improve end-user experience. Signup Now! http://pubads.g.doubleclick.net/gampad/clk?id=267308311&iu=/4140 _______________________________________________ Jmol-commits mailing list Jmol-commits@lists.sourceforge.net https://lists.sourceforge.net/lists/listinfo/jmol-commits