From: <ha...@us...> - 2009-09-03 00:41:18
|
Revision: 11437 http://jmol.svn.sourceforge.net/jmol/?rev=11437&view=rev Author: hansonr Date: 2009-09-03 00:41:00 +0000 (Thu, 03 Sep 2009) Log Message: ----------- version=11.9.2 # bug fix: compiler error for {xxx}.yy = n \n {xxx}.yy = n Modified Paths: -------------- trunk/Jmol/src/org/jmol/script/ScriptCompiler.java Modified: trunk/Jmol/src/org/jmol/script/ScriptCompiler.java =================================================================== --- trunk/Jmol/src/org/jmol/script/ScriptCompiler.java 2009-09-03 00:37:58 UTC (rev 11436) +++ trunk/Jmol/src/org/jmol/script/ScriptCompiler.java 2009-09-03 00:41:00 UTC (rev 11437) @@ -2041,6 +2041,7 @@ case '}': case '.': break; + case '@': case '{': tokLastMath = 2; // NOT considered a continuation if at beginning of a line break; @@ -2049,7 +2050,6 @@ case '$': case ':': case ';': - case '@': case '%': case '[': tokLastMath = 1; This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <ha...@us...> - 2010-07-18 14:25:49
|
Revision: 13609 http://jmol.svn.sourceforge.net/jmol/?rev=13609&view=rev Author: hansonr Date: 2010-07-18 14:25:42 +0000 (Sun, 18 Jul 2010) Log Message: ----------- version=12.0.RC26_dev PROMPT # new feature: PROMPT command with 0 or 1 arguments # new feature: prompt(label,data,asButtons) # x = prompt("testing") # just shows an OK box # x = prompt("testing","defaultInput") # returns user input or "null" # x = prompt("testing","yes|no|cancel", true) # returns 0, 1, or 2 # Modified Paths: -------------- trunk/Jmol/src/org/jmol/script/ScriptCompiler.java Modified: trunk/Jmol/src/org/jmol/script/ScriptCompiler.java =================================================================== --- trunk/Jmol/src/org/jmol/script/ScriptCompiler.java 2010-07-18 13:37:17 UTC (rev 13608) +++ trunk/Jmol/src/org/jmol/script/ScriptCompiler.java 2010-07-18 14:25:42 UTC (rev 13609) @@ -384,7 +384,7 @@ cchToken = 0; continue; } - if (lookingAtImpliedString()) { + if (lookingAtImpliedString(false)) { ichEnd = ichToken + cchToken; } } @@ -934,25 +934,15 @@ } else if ((bs = lookingAtBitset()) != null) { addTokenToPrefix(new Token(Token.bitset, bs)); return CONTINUE; - } else if (!iHaveQuotedString && lookingAtImpliedString()) { + } else if (!iHaveQuotedString && lookingAtImpliedString(false)) { String str = script.substring(ichToken, ichToken + cchToken); - int pt = str.indexOf(" "); - if (pt > 0) { - cchToken = pt; - str = str.substring(0, pt); - } addTokenToPrefix(new Token(Token.string, str)); iHaveQuotedString = true; return CONTINUE; } } else if (tokCommand == Token.script || tokCommand == Token.getproperty) { - if (!iHaveQuotedString && lookingAtImpliedString()) { + if (!iHaveQuotedString && lookingAtImpliedString(false)) { String str = script.substring(ichToken, ichToken + cchToken); - int pt = str.indexOf(" "); - if (pt > 0) { - cchToken = pt; - str = str.substring(0, pt); - } addTokenToPrefix(new Token(Token.string, str)); iHaveQuotedString = true; return CONTINUE; @@ -966,7 +956,7 @@ // write filename if (nTokens == 2 && lastToken.tok == Token.frame) iHaveQuotedString = true; - if (!iHaveQuotedString && lookingAtImpliedString()) { + if (!iHaveQuotedString && lookingAtImpliedString(true)) { String str = script.substring(ichToken, ichToken + cchToken); if (str.startsWith("@{")) { iHaveQuotedString = true; @@ -980,7 +970,7 @@ } if (Token.tokAttr(tokCommand, Token.implicitStringCommand) && !(tokCommand == Token.script && iHaveQuotedString) - && lookingAtImpliedString()) { + && lookingAtImpliedString(false)) { String str = script.substring(ichToken, ichToken + cchToken); if (tokCommand == Token.label && Parser.isOneOf(str.toLowerCase(), "on;off;hide;display")) @@ -1923,34 +1913,42 @@ * 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. + * @param allowSpace TODO * * @return true or false */ - private boolean lookingAtImpliedString() { + private boolean lookingAtImpliedString(boolean allowSpace) { int ichT = ichToken; + int ptSpace = -1; + int ptLastChar = -1; char ch = ' '; // look ahead to \n, \r, terminal ;, or } - while (ichT < cchScript && !eol(ch = script.charAt(ichT)) && ch != '}') + while (ichT < cchScript && !eol(ch = script.charAt(ichT)) && ch != '}') { + if (Character.isWhitespace(ch)) { + if (ptSpace < 0) + ptSpace = ichT; + } else { + ptLastChar = ichT; + } ++ichT; + } boolean isMath = false; boolean isVariable = false; // if we have @xxx then this is not an implied string if (ichT > ichToken && - ((isVariable = (script.charAt(ichToken) == '@')) || script.charAt(ichToken) == '%')) { + ((isVariable = (script.charAt(ichToken) == '@')) || script.charAt(ichToken) == '%')) isMath = (ichT > ichToken + 1 && script.charAt(ichToken + 1) == '{'); - if (isVariable && !isMath) - return false; - if (isMath) { - ichT = ichMathTerminator(script, ichToken + 1, cchScript); - return (ichT != cchScript && (cchToken = ichT + 1 - ichToken) > 0); - } + if (isMath) { + ichT = ichMathTerminator(script, ichToken + 1, cchScript); + return (ichT != cchScript && (cchToken = ichT + 1 - ichToken) > 0); + } else if (isVariable) { + return false; } - if (ch == '}') - while (ichT < cchScript && !eol(ch = script.charAt(ichT))) - ++ichT; - while (--ichT > ichToken && Character.isWhitespace(script.charAt(ichT))) { - } - return (cchToken = ++ichT - ichToken) > 0; + if (allowSpace) + ichT = ptLastChar + 1; + else if (ptSpace > 0) + ichT = ptSpace; + return (cchToken = ichT - ichToken) > 0; } /** This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <ha...@us...> - 2010-07-18 14:39:31
|
Revision: 13610 http://jmol.svn.sourceforge.net/jmol/?rev=13610&view=rev Author: hansonr Date: 2010-07-18 14:39:25 +0000 (Sun, 18 Jul 2010) Log Message: ----------- version=12.0.RC26_dev PROMPT # new feature: PROMPT command with 0 or 1 arguments # new feature: prompt(label,data,asButtons) # x = prompt("testing") # just shows an OK box # x = prompt("testing","defaultInput") # returns user input or "null" # x = prompt("testing","yes|no|cancel", true) # returns 0, 1, or 2 # Modified Paths: -------------- trunk/Jmol/src/org/jmol/script/ScriptCompiler.java Modified: trunk/Jmol/src/org/jmol/script/ScriptCompiler.java =================================================================== --- trunk/Jmol/src/org/jmol/script/ScriptCompiler.java 2010-07-18 14:25:42 UTC (rev 13609) +++ trunk/Jmol/src/org/jmol/script/ScriptCompiler.java 2010-07-18 14:39:25 UTC (rev 13610) @@ -384,9 +384,8 @@ cchToken = 0; continue; } - if (lookingAtImpliedString(false)) { + if (lookingAtImpliedString(true)) ichEnd = ichToken + cchToken; - } } return commandExpected(); } @@ -970,7 +969,7 @@ } if (Token.tokAttr(tokCommand, Token.implicitStringCommand) && !(tokCommand == Token.script && iHaveQuotedString) - && lookingAtImpliedString(false)) { + && lookingAtImpliedString(true)) { String str = script.substring(ichToken, ichToken + cchToken); if (tokCommand == Token.label && Parser.isOneOf(str.toLowerCase(), "on;off;hide;display")) This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <ha...@us...> - 2010-07-30 18:31:09
|
Revision: 13765 http://jmol.svn.sourceforge.net/jmol/?rev=13765&view=rev Author: hansonr Date: 2010-07-30 18:31:03 +0000 (Fri, 30 Jul 2010) Log Message: ----------- Modified Paths: -------------- trunk/Jmol/src/org/jmol/script/ScriptCompiler.java Modified: trunk/Jmol/src/org/jmol/script/ScriptCompiler.java =================================================================== --- trunk/Jmol/src/org/jmol/script/ScriptCompiler.java 2010-07-30 18:30:45 UTC (rev 13764) +++ trunk/Jmol/src/org/jmol/script/ScriptCompiler.java 2010-07-30 18:31:03 UTC (rev 13765) @@ -1264,7 +1264,6 @@ // all command starts are handled by case Token.nada - System.out.println("parseCommandParam " + ident); nTokens = ltoken.size(); switch (tokCommand) { case Token.nada: This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <ha...@us...> - 2010-08-25 02:12:48
|
Revision: 14129 http://jmol.svn.sourceforge.net/jmol/?rev=14129&view=rev Author: hansonr Date: 2010-08-25 02:12:41 +0000 (Wed, 25 Aug 2010) Log Message: ----------- 12.1.7 VERSION # bug fix: undo and smilesurlformat tokens missing # new feature: load SMILES to use http://cactus.nci.nih.gov/chemical/structure/..../file?format=sdf&get3d=True # bug fix: isosurface ... map SQUARED ... nonfunctional # new feature: zSlab, zDepth -- default 0,0 meaning "use slab and depth" settings # new feature: slab and depth are variables and can be read and set as for any other # bug fix: exit, quit are stopping spinning -- should just be stopping moveTo # unless !exit or !quit. # bug fix: associative array problems with some auxiliaryInfo data saving to state # new feature: Vasp reader shows enthalpy and Gibbs energy in model name # bug fix: binary map files within zip directories cannot be read # bug fix: mouse-based slab does not refresh # bug fix: JME reader misreading "Br+" # bug fix: Writing PDB file with residue number > 9999 trashes file. Now writes "0000" "0001" etc. # new feature: getProperty can drill down a list for a hashtable entry: # print getProperty("shapeInfo.isosurface.id") # s2 # isosurface1 Modified Paths: -------------- trunk/Jmol/src/org/jmol/script/ScriptCompiler.java Modified: trunk/Jmol/src/org/jmol/script/ScriptCompiler.java =================================================================== --- trunk/Jmol/src/org/jmol/script/ScriptCompiler.java 2010-08-25 00:05:15 UTC (rev 14128) +++ trunk/Jmol/src/org/jmol/script/ScriptCompiler.java 2010-08-25 02:12:41 UTC (rev 14129) @@ -818,6 +818,11 @@ return token; } + private void replaceCommand(Token token) { + ltoken.remove(0); + ltoken.add(0, setCommand(token)); + } + private String getPrefixToken() { String ident = script.substring(ichToken, ichToken + cchToken); //System.out.println(ident); @@ -1138,6 +1143,13 @@ setEqualPt = ichToken; return OK; } + if (tokCommand == Token.slab || tokCommand == Token.depth) { + addTokenToPrefix(tokenCommand); + replaceCommand(Token.tokenSet); + tokenAndEquals = Token.getTokenFromName(ident.substring(0, 1)); + setEqualPt = ichToken; + return OK; + } // otherwise ignore return CONTINUE; } @@ -1437,16 +1449,14 @@ } if (nTokens != 1 || theTok != Token.ifcmd && theTok != Token.leftbrace) return ERROR(ERROR_badArgumentCount); - ltoken.remove(0); - ltoken.add(flowContext.token = new ContextToken(Token.elseif, "elseif")); + replaceCommand(flowContext.token = new ContextToken(Token.elseif, "elseif")); tokCommand = Token.elseif; return CONTINUE; case Token.var: if (nTokens != 1) break; addContextVariable(ident); - ltoken.remove(0); - ltoken.add(Token.tokenSetVar); + replaceCommand(Token.tokenSetVar); tokCommand = Token.set; break; case Token.end: @@ -1530,8 +1540,7 @@ // theTok = Token.leftsquare; } else if (nTokens == 1 && (lastToken.tok == Token.plusPlus || lastToken.tok == Token.minusMinus)) { - ltoken.remove(0); - ltoken.add(0, setCommand(Token.tokenSet)); + replaceCommand(Token.tokenSet); addTokenToPrefix(lastToken); break; } This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <ha...@us...> - 2010-08-25 02:54:41
|
Revision: 14131 http://jmol.svn.sourceforge.net/jmol/?rev=14131&view=rev Author: hansonr Date: 2010-08-25 02:54:35 +0000 (Wed, 25 Aug 2010) Log Message: ----------- 12.1.7 VERSION # bug fix: undo and smilesurlformat tokens missing # new feature: load SMILES to use http://cactus.nci.nih.gov/chemical/structure/..../file?format=sdf&get3d=True # bug fix: isosurface ... map SQUARED ... nonfunctional # new feature: zSlab, zDepth -- default 0,0 meaning "use slab and depth" settings # new feature: slab and depth are variables and can be read and set as for any other # bug fix: exit, quit are stopping spinning -- should just be stopping moveTo # unless !exit or !quit. # bug fix: associative array problems with some auxiliaryInfo data saving to state # new feature: Vasp reader shows enthalpy and Gibbs energy in model name # bug fix: binary map files within zip directories cannot be read # bug fix: mouse-based slab does not refresh # bug fix: JME reader misreading "Br+" # bug fix: Writing PDB file with residue number > 9999 trashes file. Now writes "0000" "0001" etc. # new feature: getProperty can drill down a list for a hashtable entry: # print getProperty("shapeInfo.isosurface.id") # s2 # isosurface1 Modified Paths: -------------- trunk/Jmol/src/org/jmol/script/ScriptCompiler.java Modified: trunk/Jmol/src/org/jmol/script/ScriptCompiler.java =================================================================== --- trunk/Jmol/src/org/jmol/script/ScriptCompiler.java 2010-08-25 02:54:23 UTC (rev 14130) +++ trunk/Jmol/src/org/jmol/script/ScriptCompiler.java 2010-08-25 02:54:35 UTC (rev 14131) @@ -937,11 +937,9 @@ } if (nTokens == 1 && lookingAtLoadFormat()) { String strFormat = script.substring(ichToken, ichToken + cchToken); - strFormat = strFormat.toLowerCase(); - int tok = (strFormat.equals("data") ? Token.data - : Parser.isOneOf(strFormat, LOAD_TYPES) ? Token.identifier - : strFormat.indexOf("=") == 0 || strFormat.indexOf("$") == 0 ? Token.string - : 0); + int tok = (strFormat.indexOf("=") == 0 || strFormat.indexOf("$") == 0 ? Token.string + : (strFormat = strFormat.toLowerCase()).equals("data") ? Token.data + : Parser.isOneOf(strFormat, LOAD_TYPES) ? Token.identifier : 0); if (tok != 0) { addTokenToPrefix(new Token(tok, strFormat)); iHaveQuotedString = (tok == Token.string); @@ -2064,7 +2062,7 @@ && (Character.isLetterOrDigit(ch = script.charAt(ichT)) || allchar && (!eol(ch) && !Character.isWhitespace(ch)))) ++ichT; - if (!allchar && ichT == ichToken || !eol(ch) && !isSpaceOrTab(ch)) + if (!allchar && ichT == ichToken || !isSpaceOrTab(ch)) return false; cchToken = ichT - ichToken; return true; This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <ha...@us...> - 2010-08-29 04:28:46
|
Revision: 14186 http://jmol.svn.sourceforge.net/jmol/?rev=14186&view=rev Author: hansonr Date: 2010-08-29 04:28:39 +0000 (Sun, 29 Aug 2010) Log Message: ----------- version=12.1.9_dev # bug fix: % at end of line in SET command acts as a line continuation Modified Paths: -------------- trunk/Jmol/src/org/jmol/script/ScriptCompiler.java Modified: trunk/Jmol/src/org/jmol/script/ScriptCompiler.java =================================================================== --- trunk/Jmol/src/org/jmol/script/ScriptCompiler.java 2010-08-29 04:08:24 UTC (rev 14185) +++ trunk/Jmol/src/org/jmol/script/ScriptCompiler.java 2010-08-29 04:28:39 UTC (rev 14186) @@ -431,7 +431,7 @@ return false; if (parenCount > 0 || bracketCount > 0) return true; - if (tokCommand != Token.set && tokCommand != Token.print && tokCommand != Token.log) + if ((tokCommand != Token.set || !isNewSet) && tokCommand != Token.print && tokCommand != Token.log) return false; if (lastToken.tok == tokLastMath) return true; @@ -2374,7 +2374,6 @@ case ']': case '}': case '.': - case '%': // not a continuation -- set echo myecho 10% 20% break; case '@': case '{': @@ -2388,6 +2387,7 @@ case '$': case ';': case '[': + case '%': tokLastMath = 1; break; case '<': This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <ha...@us...> - 2011-10-02 12:48:45
|
Revision: 16201 http://jmol.svn.sourceforge.net/jmol/?rev=16201&view=rev Author: hansonr Date: 2011-10-02 12:48:38 +0000 (Sun, 02 Oct 2011) Log Message: ----------- x.sort, x.reverse Modified Paths: -------------- trunk/Jmol/src/org/jmol/script/ScriptCompiler.java Modified: trunk/Jmol/src/org/jmol/script/ScriptCompiler.java =================================================================== --- trunk/Jmol/src/org/jmol/script/ScriptCompiler.java 2011-10-01 22:36:09 UTC (rev 16200) +++ trunk/Jmol/src/org/jmol/script/ScriptCompiler.java 2011-10-02 12:48:38 UTC (rev 16201) @@ -623,22 +623,30 @@ } else if (setBraceCount > 0 && endOfLine && ichToken < cchScript) { return CONTINUE; } - if (tokCommand == Token.script && checkImpliedScriptCmd && nTokens > 2) { - // check for improperly parsed implied script command - ichToken = ichCurrentCommand; - nTokens = 0; - ltoken.clear(); - cchToken = 0; - tokCommand = Token.nada; - return CONTINUE; + if (tokCommand == Token.script && checkImpliedScriptCmd) { + String s = (nTokens == 2 ? lastToken.value.toString().toUpperCase() : null); + if (nTokens > 2 || s != null && (s.endsWith(".SORT") || s.endsWith(".REVERSE"))) { + // check for improperly parsed implied script command + ichToken = ichCurrentCommand; + nTokens = 0; + ltoken.clear(); + cchToken = 0; + tokCommand = Token.nada; + return CONTINUE; + } } - - if (tokInitialPlusPlus != Token.nada) { + if (isNewSet && nTokens > 2 && tokAt(2) == Token.per + && (tokAt(3) == Token.sort || tokAt(3) == Token.reverse)) { + // check for x.sort or x.reverse + // x.sort / x.reverse ==> x = x.sort / x = x.reverse + ltoken.set(0, Token.tokenSet); + ltoken.add(1, ltoken.get(1)); + } else if (tokInitialPlusPlus != Token.nada) { + // check for ++x or --x if (!isNewSet) checkNewSetCommand(); tokenizePlusPlus(tokInitialPlusPlus, true); } - // end of command or comment iCommand = lltoken.size(); if (thisFunction != null && thisFunction.cmdpt0 < 0) { thisFunction.cmdpt0 = iCommand; @@ -2221,6 +2229,7 @@ while (isOK && ichT < cchScript && !eol(ch = script.charAt(ichT))) { switch (ch) { case '=': + case '(': if (!allowEquals) { isOK = false; continue; This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <ha...@us...> - 2011-12-21 15:19:14
|
Revision: 16618 http://jmol.svn.sourceforge.net/jmol/?rev=16618&view=rev Author: hansonr Date: 2011-12-21 15:19:04 +0000 (Wed, 21 Dec 2011) Log Message: ----------- Modified Paths: -------------- trunk/Jmol/src/org/jmol/script/ScriptCompiler.java Modified: trunk/Jmol/src/org/jmol/script/ScriptCompiler.java =================================================================== --- trunk/Jmol/src/org/jmol/script/ScriptCompiler.java 2011-12-21 14:29:15 UTC (rev 16617) +++ trunk/Jmol/src/org/jmol/script/ScriptCompiler.java 2011-12-21 15:19:04 UTC (rev 16618) @@ -992,56 +992,51 @@ } switch (tokCommand) { case Token.load: + case Token.script: + case Token.getproperty: if (script.charAt(ichToken) == '@') { iHaveQuotedString = true; return OK; } - if (nTokens == 1 && lookingAtLoadFormat()) { - String strFormat = script.substring(ichToken, ichToken + cchToken); - Token token = Token.getTokenFromName(strFormat.toLowerCase()); - switch (token == null ? Token.nada : token.tok) { - case Token.append: - case Token.data: - case Token.file: - case Token.inline: - case Token.menu: - case Token.model: - case Token.smiles: - case Token.trajectory: - addTokenToPrefix(token); - break; - default: - // skip entirely if not recognized - int tok = (strFormat.indexOf("=") == 0 || strFormat.indexOf("$") == 0 ? Token.string - : Parser.isOneOf(strFormat = strFormat.toLowerCase(), - JmolConstants.LOAD_ATOM_DATA_TYPES) ? Token.identifier : 0); - if (tok != 0) { - addTokenToPrefix(new Token(tok, strFormat)); - iHaveQuotedString = (tok == Token.string); + if (tokCommand == Token.load) { + if (nTokens == 1 && lookingAtLoadFormat()) { + String strFormat = script.substring(ichToken, ichToken + cchToken); + Token token = Token.getTokenFromName(strFormat.toLowerCase()); + switch (token == null ? Token.nada : token.tok) { + case Token.append: + case Token.data: + case Token.file: + case Token.inline: + case Token.menu: + case Token.model: + case Token.smiles: + case Token.trajectory: + addTokenToPrefix(token); + break; + default: + // skip entirely if not recognized + int tok = (strFormat.indexOf("=") == 0 + || strFormat.indexOf("$") == 0 ? Token.string : Parser.isOneOf( + strFormat = strFormat.toLowerCase(), + JmolConstants.LOAD_ATOM_DATA_TYPES) ? Token.identifier : 0); + if (tok != 0) { + addTokenToPrefix(new Token(tok, strFormat)); + iHaveQuotedString = (tok == Token.string); + } } + return CONTINUE; } - return CONTINUE; + BitSet bs; + if (script.charAt(ichToken) == '{' || parenCount > 0) + break; + if ((bs = lookingAtBitset()) != null) { + addTokenToPrefix(new Token(Token.bitset, bs)); + return CONTINUE; + } } - BitSet bs; - if (script.charAt(ichToken) == '{' || parenCount > 0) { - } else if ((bs = lookingAtBitset()) != null) { - addTokenToPrefix(new Token(Token.bitset, bs)); - return CONTINUE; - } else if (!iHaveQuotedString && lookingAtImpliedString(false, true)) { + if (!iHaveQuotedString + && lookingAtImpliedString(false, tokCommand == Token.load)) { String str = script.substring(ichToken, ichToken + cchToken); - addTokenToPrefix(new Token(Token.string, str)); - iHaveQuotedString = true; - return CONTINUE; - } - break; - case Token.script: - case Token.getproperty: - if (script.charAt(ichToken) == '@') { - iHaveQuotedString = true; - return OK; - } - if (!iHaveQuotedString && lookingAtImpliedString(false, false)) { - String str = script.substring(ichToken, ichToken + cchToken); if (tokCommand == Token.script && str.startsWith("javascript:")) { lookingAtImpliedString(true, true); str = script.substring(ichToken, ichToken + cchToken); This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <ha...@us...> - 2012-02-02 22:59:18
|
Revision: 16722 http://jmol.svn.sourceforge.net/jmol/?rev=16722&view=rev Author: hansonr Date: 2012-02-02 22:59:12 +0000 (Thu, 02 Feb 2012) Log Message: ----------- ;print "#" Modified Paths: -------------- trunk/Jmol/src/org/jmol/script/ScriptCompiler.java Modified: trunk/Jmol/src/org/jmol/script/ScriptCompiler.java =================================================================== --- trunk/Jmol/src/org/jmol/script/ScriptCompiler.java 2012-02-02 22:58:28 UTC (rev 16721) +++ trunk/Jmol/src/org/jmol/script/ScriptCompiler.java 2012-02-02 22:59:12 UTC (rev 16722) @@ -557,7 +557,7 @@ for (; ichT < cchScript; ichT++) { if (eol(ch = script.charAt(ichT))) { ichEnd = ichT; - if (isLineContinuation(ichT - 1, false)) { + if (ichT > 0 && isLineContinuation(ichT - 1, false)) { ichT += nCharNewLine(ichT); continue; } This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <ha...@us...> - 2012-03-14 12:50:59
|
Revision: 16885 http://jmol.svn.sourceforge.net/jmol/?rev=16885&view=rev Author: hansonr Date: 2012-03-14 12:50:47 +0000 (Wed, 14 Mar 2012) Log Message: ----------- preliminary UTF-8 fix. Modified Paths: -------------- trunk/Jmol/src/org/jmol/script/ScriptCompiler.java Modified: trunk/Jmol/src/org/jmol/script/ScriptCompiler.java =================================================================== --- trunk/Jmol/src/org/jmol/script/ScriptCompiler.java 2012-03-14 11:06:41 UTC (rev 16884) +++ trunk/Jmol/src/org/jmol/script/ScriptCompiler.java 2012-03-14 12:50:47 UTC (rev 16885) @@ -34,6 +34,7 @@ import org.jmol.modelset.Group; import org.jmol.modelset.Bond.BondSet; +import java.io.UnsupportedEncodingException; import java.util.ArrayList; import java.util.Hashtable; import java.util.BitSet; @@ -193,6 +194,16 @@ * @return cleaned script */ private String cleanScriptComments(String script) { + if (script.indexOf((char) 0xEF) == 0) { + byte[] bytes = script.getBytes(); + try { + script = new String(bytes, "UTF8"); + } catch (UnsupportedEncodingException e) { + // ignore + } + } + //for (int i = 0; i < script.length(); i++) + //System.out.println(i + " \'" + script.charAt(i) + "\' " + Character.codePointAt(script, i)); if (script.indexOf('\u201C') >= 0) script = script.replace('\u201C', '"'); if (script.indexOf('\u201D') >= 0) This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <ha...@us...> - 2012-04-08 01:42:51
|
Revision: 16979 http://jmol.svn.sourceforge.net/jmol/?rev=16979&view=rev Author: hansonr Date: 2012-04-08 01:42:44 +0000 (Sun, 08 Apr 2012) Log Message: ----------- Modified Paths: -------------- trunk/Jmol/src/org/jmol/script/ScriptCompiler.java Modified: trunk/Jmol/src/org/jmol/script/ScriptCompiler.java =================================================================== --- trunk/Jmol/src/org/jmol/script/ScriptCompiler.java 2012-04-08 01:40:55 UTC (rev 16978) +++ trunk/Jmol/src/org/jmol/script/ScriptCompiler.java 2012-04-08 01:42:44 UTC (rev 16979) @@ -733,7 +733,7 @@ } if (endOfLine) { - if (tokCommand != Token.nada && flowContext != null && flowContext.checkForceEndIf()) { + if (flowContext != null && tokCommand != Token.nada && flowContext.checkForceEndIf()) { forceFlowEnd(flowContext.token); isEndOfCommand = true; cchToken = 0; This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <ha...@us...> - 2012-09-13 12:02:52
|
Revision: 17559 http://jmol.svn.sourceforge.net/jmol/?rev=17559&view=rev Author: hansonr Date: 2012-09-13 12:02:41 +0000 (Thu, 13 Sep 2012) Log Message: ----------- refactoring for JavaScript Modified Paths: -------------- trunk/Jmol/src/org/jmol/script/ScriptCompiler.java Modified: trunk/Jmol/src/org/jmol/script/ScriptCompiler.java =================================================================== --- trunk/Jmol/src/org/jmol/script/ScriptCompiler.java 2012-09-12 18:11:19 UTC (rev 17558) +++ trunk/Jmol/src/org/jmol/script/ScriptCompiler.java 2012-09-13 12:02:41 UTC (rev 17559) @@ -2078,11 +2078,20 @@ return ch == ' ' || ch == '\t'; } + @SuppressWarnings("unused") + private boolean eol(String ch) { + // for JavaScript + return eol2(ch.charAt(0)); + } private boolean eol(char ch) { - return eol(ch, nSemiSkip); + return eol2(ch); } + + private boolean eol2(char ch) { + return eol3(ch, nSemiSkip); + } - static boolean eol(char ch, int nSkip) { + static boolean eol3(char ch, int nSkip) { return (ch == '\r' || ch == '\n' || ch == ';' && nSkip <= 0); } This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <ha...@us...> - 2014-02-24 13:59:33
|
Revision: 19378 http://sourceforge.net/p/jmol/code/19378 Author: hansonr Date: 2014-02-24 13:59:28 +0000 (Mon, 24 Feb 2014) Log Message: ----------- Modified Paths: -------------- trunk/Jmol/src/org/jmol/script/ScriptCompiler.java Modified: trunk/Jmol/src/org/jmol/script/ScriptCompiler.java =================================================================== --- trunk/Jmol/src/org/jmol/script/ScriptCompiler.java 2014-02-24 13:34:47 UTC (rev 19377) +++ trunk/Jmol/src/org/jmol/script/ScriptCompiler.java 2014-02-24 13:59:28 UTC (rev 19378) @@ -883,11 +883,12 @@ boolean isUserVar = isContextVariable(identLC); if (nTokens == 0) isUserToken = isUserVar; - if (nTokens == 1 && (tokCommand == T.function || tokCommand == T.parallel || tokCommand == T.var) - || nTokens != 0 && isUserVar - || isUserFunction(identLC) && (thisFunction == null || !thisFunction.name.equals(identLC))) { + if (nTokens == 1 + && (tokCommand == T.function || tokCommand == T.parallel || tokCommand == T.var) + || nTokens != 0 && isUserVar || isUserFunction(identLC) + && (thisFunction == null || !thisFunction.name.equals(identLC))) { // we need to allow: - + // var color = "xxx" // color @color // print color @@ -896,7 +897,7 @@ // color = ... // color += ... // color[ ... - + ident = identLC; theToken = null; } else if (ident.length() == 1 || lastToken.tok == T.colon) { @@ -909,15 +910,18 @@ && (theToken = T.getTokenFromName(identLC)) != null) theToken = T.tv(theToken.tok, theToken.intValue, ident); } else { - ident = identLC; - theToken = T.getTokenFromName(ident); + theToken = T.getTokenFromName(identLC); + if (theToken != null && (lastToken.tok == T.per || lastToken.tok == T.leftsquare)) + theToken = T.o(theToken.tok, identFullCase); } if (theToken == null) { - if (ident.indexOf("property_") == 0) - theToken = T.o(T.property, ident); + if (identLC.indexOf("property_") == 0) + theToken = T.o(T.property, identLC); + else if (lastToken.tok == T.per || lastToken.tok == T.leftsquare) + theToken = T.o(T.identifier, identFullCase); else theToken = T.o(T.identifier, ident); - } + } theTok = theToken.tok; return ident; } This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <ha...@us...> - 2014-02-24 14:25:45
|
Revision: 19379 http://sourceforge.net/p/jmol/code/19379 Author: hansonr Date: 2014-02-24 14:25:41 +0000 (Mon, 24 Feb 2014) Log Message: ----------- Modified Paths: -------------- trunk/Jmol/src/org/jmol/script/ScriptCompiler.java Modified: trunk/Jmol/src/org/jmol/script/ScriptCompiler.java =================================================================== --- trunk/Jmol/src/org/jmol/script/ScriptCompiler.java 2014-02-24 13:59:28 UTC (rev 19378) +++ trunk/Jmol/src/org/jmol/script/ScriptCompiler.java 2014-02-24 14:25:41 UTC (rev 19379) @@ -138,7 +138,8 @@ private int tokInitialPlusPlus; private int afterWhite; private boolean isDotDot; - private String identFullCase; + private String ident; + private String identLC; synchronized ScriptContext compile(String filename, String script, boolean isPredefining, boolean isSilent, boolean debugScript, boolean isCheckOnly) { @@ -372,15 +373,14 @@ return false; } } - if (lookingAtLookupToken(ichToken)) { - String ident = getPrefixToken(); - switch (parseKnownToken(ident)) { + if (lookingAtLookupToken(ichToken)) { + switch (parseKnownToken()) { case CONTINUE: continue; case ERROR: return false; } - switch (parseCommandParameter(ident)) { + switch (parseCommandParameter()) { case CONTINUE: continue; case ERROR: @@ -876,17 +876,15 @@ ltoken.add(0, setCommand(token)); } - private String getPrefixToken() { - String ident = script.substring(ichToken, ichToken + cchToken); - String identLC = ident.toLowerCase(); - identFullCase = ident; - boolean isUserVar = isContextVariable(identLC); + private void getPrefixToken() { + ident = script.substring(ichToken, ichToken + cchToken); + identLC = ident.toLowerCase(); + boolean isUserVar = (isContextVariable(identLC)); if (nTokens == 0) isUserToken = isUserVar; - if (nTokens == 1 - && (tokCommand == T.function || tokCommand == T.parallel || tokCommand == T.var) - || nTokens != 0 && isUserVar || isUserFunction(identLC) - && (thisFunction == null || !thisFunction.name.equals(identLC))) { + if (nTokens == 1 && (tokCommand == T.function || tokCommand == T.parallel || tokCommand == T.var) + || nTokens != 0 && isUserVar && lastToken.tok != T.per + || isUserFunction(identLC) && (thisFunction == null || !thisFunction.name.equals(identLC))) { // we need to allow: // var color = "xxx" @@ -911,19 +909,18 @@ theToken = T.tv(theToken.tok, theToken.intValue, ident); } else { theToken = T.getTokenFromName(identLC); - if (theToken != null && (lastToken.tok == T.per || lastToken.tok == T.leftsquare)) - theToken = T.o(theToken.tok, identFullCase); + if (theToken != null + && (lastToken.tok == T.per || lastToken.tok == T.leftsquare)) + theToken = T.o(theToken.tok, ident); } + if (theToken == null) { if (identLC.indexOf("property_") == 0) theToken = T.o(T.property, identLC); - else if (lastToken.tok == T.per || lastToken.tok == T.leftsquare) - theToken = T.o(T.identifier, identFullCase); else theToken = T.o(T.identifier, ident); } theTok = theToken.tok; - return ident; } /** @@ -1253,14 +1250,16 @@ return m; } - private int parseKnownToken(String ident) { + private int parseKnownToken() { + getPrefixToken(); + // specific token-based issues depend upon where we are in the command T token; if (isDotDot) { - addTokenToPrefix(T.o(T.string, identFullCase)); + addTokenToPrefix(T.o(T.string, ident)); addTokenToPrefix(T.o(T.rightsquare, "]")); isDotDot = false; return CONTINUE; @@ -1483,7 +1482,7 @@ return true; } - private int parseCommandParameter(String ident) { + private int parseCommandParameter() { // PART II: // // checking tokens based on the current command @@ -1572,7 +1571,7 @@ break; default: if (!T.tokAttr(theTok, T.misc) && !T.tokAttr(theTok, T.setparam) - && !isContextVariable(ident)) { + && !isContextVariable(identLC)) { commandExpected(); return ERROR; } This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <ha...@us...> - 2014-03-21 13:52:14
|
Revision: 19497 http://sourceforge.net/p/jmol/code/19497 Author: hansonr Date: 2014-03-21 13:52:11 +0000 (Fri, 21 Mar 2014) Log Message: ----------- org.jmol.parallel --> org.jmol.script Modified Paths: -------------- trunk/Jmol/src/org/jmol/script/ScriptCompiler.java Modified: trunk/Jmol/src/org/jmol/script/ScriptCompiler.java =================================================================== --- trunk/Jmol/src/org/jmol/script/ScriptCompiler.java 2014-03-21 13:51:19 UTC (rev 19496) +++ trunk/Jmol/src/org/jmol/script/ScriptCompiler.java 2014-03-21 13:52:11 UTC (rev 19497) @@ -1858,7 +1858,7 @@ } private static ScriptFunction newScriptParallelProcessor(String name, int tok) { - ScriptFunction jpp = (ScriptFunction) Interface.getOption("parallel.ScriptParallelProcessor"); + ScriptFunction jpp = (ScriptFunction) Interface.getOption("script.ScriptParallelProcessor"); jpp.set(name, tok); return jpp; } This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <ha...@us...> - 2015-04-01 12:06:12
|
Revision: 20425 http://sourceforge.net/p/jmol/code/20425 Author: hansonr Date: 2015-04-01 12:06:11 +0000 (Wed, 01 Apr 2015) Log Message: ----------- Jmol.___JmolVersion="14.3.13_2015.04.01" bug fix: local var xxx with same name of ..xxx forces lower case xxx Modified Paths: -------------- trunk/Jmol/src/org/jmol/script/ScriptCompiler.java Modified: trunk/Jmol/src/org/jmol/script/ScriptCompiler.java =================================================================== --- trunk/Jmol/src/org/jmol/script/ScriptCompiler.java 2015-04-01 11:58:10 UTC (rev 20424) +++ trunk/Jmol/src/org/jmol/script/ScriptCompiler.java 2015-04-01 12:06:11 UTC (rev 20425) @@ -907,13 +907,13 @@ private void getPrefixToken() { ident = script.substring(ichToken, ichToken + cchToken); identLC = ident.toLowerCase(); - boolean isUserVar = (!isDotDot && isContextVariable(identLC)); + boolean isUserVar = (lastToken.tok != T.per && !isDotDot && isContextVariable(identLC)); String preserveCase = null; if (nTokens == 0) isUserToken = isUserVar; if (nTokens == 1 && (tokCommand == T.function || tokCommand == T.parallel || tokCommand == T.var) - || nTokens != 0 && isUserVar && lastToken.tok != T.per || !isDotDot + || nTokens != 0 && isUserVar || !isDotDot && isUserFunction(identLC) && ((preserveCase = ident) != null) && (thisFunction == null || !thisFunction.name.equals(identLC))) { // we need to allow: This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <ha...@us...> - 2015-10-04 04:29:02
|
Revision: 20807 http://sourceforge.net/p/jmol/code/20807 Author: hansonr Date: 2015-10-04 04:28:59 +0000 (Sun, 04 Oct 2015) Log Message: ----------- Modified Paths: -------------- trunk/Jmol/src/org/jmol/script/ScriptCompiler.java Modified: trunk/Jmol/src/org/jmol/script/ScriptCompiler.java =================================================================== --- trunk/Jmol/src/org/jmol/script/ScriptCompiler.java 2015-10-04 04:16:41 UTC (rev 20806) +++ trunk/Jmol/src/org/jmol/script/ScriptCompiler.java 2015-10-04 04:28:59 UTC (rev 20807) @@ -2255,7 +2255,7 @@ private void fixFlowAddLine(ScriptFlowContext flowContext) { while (flowContext != null) { - if (flowContext.addLine > 0) { + if (flowContext.addLine > 0 || flowContext.forceEndIf) { flowContext.addLine = lineCurrent - flowContext.ptLine; flowContext.forceEndIf = true; } This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <ha...@us...> - 2015-11-03 12:34:19
|
Revision: 20855 http://sourceforge.net/p/jmol/code/20855 Author: hansonr Date: 2015-11-03 12:34:16 +0000 (Tue, 03 Nov 2015) Log Message: ----------- Modified Paths: -------------- trunk/Jmol/src/org/jmol/script/ScriptCompiler.java Modified: trunk/Jmol/src/org/jmol/script/ScriptCompiler.java =================================================================== --- trunk/Jmol/src/org/jmol/script/ScriptCompiler.java 2015-11-03 12:17:44 UTC (rev 20854) +++ trunk/Jmol/src/org/jmol/script/ScriptCompiler.java 2015-11-03 12:34:16 UTC (rev 20855) @@ -811,16 +811,27 @@ setEqualPt = Integer.MAX_VALUE; } + boolean isOneLine = (flowContext != null && flowContext.addLine == 0); // if (....) xxxxx; + boolean isEndFlow = ((endOfLine || !isOneLine) && !haveENDIF && flowContext != null && flowContext.checkForceEndIf(-1)); if (endOfLine) { - if (!haveENDIF && flowContext != null - && flowContext.checkForceEndIf(-1)) { - boolean isOneLine = (flowContext.addLine == 0); // if (....) xxxxx; + if (isEndFlow) { if (isComment) { if (!isOneLine) { flowContext.addLine++; flowContext.forceEndIf = true; } } else if (n > 0 && !haveENDIF || isOneLine) { + // looking for + // for (...) + // print ... + // + // but not empty line after for: + // + // for (...) + // + // print ... + // + forceFlowEnd(flowContext.token); if (!isOneLine) { forceFlowContext.forceEndIf = true; @@ -829,13 +840,19 @@ isEndOfCommand = true; cchToken = 0; ichCurrentCommand = ichToken; -// if (n > 0 || isOneLine) - // lineCurrent--; return CONTINUE; } isComment = false; isShowCommand = false; ++lineCurrent; + } else if (isEndFlow) { + // looking at something like + // + // for (...) + // print ... ; + // + forceFlowEnd(flowContext.token); + forceFlowContext.forceEndIf = true; } if (ichToken >= cchScript) { // check for end of all brace work This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |