From: <ha...@us...> - 2008-07-18 12:40:20
|
Revision: 9612 http://jmol.svn.sourceforge.net/jmol/?rev=9612&view=rev Author: hansonr Date: 2008-07-18 12:40:14 +0000 (Fri, 18 Jul 2008) Log Message: ----------- version=11.4.6_dev # bug fix: DEFINE can cause compiling error, e.g. "[2MO]" in 1tmo Modified Paths: -------------- branches/v11_4/Jmol/src/org/jmol/modelset/BondCollection.java branches/v11_4/Jmol/src/org/jmol/modelset/ModelCollection.java branches/v11_4/Jmol/src/org/jmol/viewer/Compiler.java branches/v11_4/Jmol/src/org/jmol/viewer/Jmol.properties Modified: branches/v11_4/Jmol/src/org/jmol/modelset/BondCollection.java =================================================================== --- branches/v11_4/Jmol/src/org/jmol/modelset/BondCollection.java 2008-07-17 21:19:38 UTC (rev 9611) +++ branches/v11_4/Jmol/src/org/jmol/modelset/BondCollection.java 2008-07-18 12:40:14 UTC (rev 9612) @@ -460,7 +460,7 @@ for (int i = bondCount; --i >= 0;) { Bond bond = bonds[i]; if (bond.isAromatic()) - bond.order = JmolConstants.BOND_AROMATIC; + bond.setOrder(JmolConstants.BOND_AROMATIC); } } @@ -491,7 +491,7 @@ if (bsBonds == null || bsBonds.get(i)) { Bond bond = bonds[i]; if (bsAromatic.get(i)) - bond.order = JmolConstants.BOND_AROMATIC; + bond.setOrder(JmolConstants.BOND_AROMATIC); switch (bond.order) { case JmolConstants.BOND_AROMATIC: bsAromatic.set(i); @@ -522,12 +522,12 @@ if (bsAromaticDouble.get(i)) { if (bond.order != JmolConstants.BOND_AROMATIC_DOUBLE) { bsAromatic.set(i); - bond.order = JmolConstants.BOND_AROMATIC_DOUBLE; + bond.setOrder(JmolConstants.BOND_AROMATIC_DOUBLE); } } else if (bsAromaticSingle.get(i) || bond.isAromatic()) { if (bond.order != JmolConstants.BOND_AROMATIC_SINGLE) { bsAromatic.set(i); - bond.order = JmolConstants.BOND_AROMATIC_SINGLE; + bond.setOrder(JmolConstants.BOND_AROMATIC_SINGLE); } } } @@ -696,12 +696,12 @@ //next to trivalent C --> N=C if (valence == 3 && bondorder == 3 && charge < 1 && n2 == 6 && atom2.getValence() == 3) - bond.order = JmolConstants.BOND_AROMATIC_DOUBLE; + bond.setOrder(JmolConstants.BOND_AROMATIC_DOUBLE); break; case 8: //monovalent nonnegative O next to P or S if (valence == 1 && charge == 0 && (n2 == 14 || n2 == 16)) - bond.order = JmolConstants.BOND_AROMATIC_DOUBLE; + bond.setOrder(JmolConstants.BOND_AROMATIC_DOUBLE); break; } } Modified: branches/v11_4/Jmol/src/org/jmol/modelset/ModelCollection.java =================================================================== --- branches/v11_4/Jmol/src/org/jmol/modelset/ModelCollection.java 2008-07-17 21:19:38 UTC (rev 9611) +++ branches/v11_4/Jmol/src/org/jmol/modelset/ModelCollection.java 2008-07-18 12:40:14 UTC (rev 9612) @@ -1857,7 +1857,7 @@ continue; if (bondAB != null) { if (!identifyOnly && !matchAny) { - bondAB.order = order; + bondAB.setOrder(order); bsAromatic.clear(bondAB.index); } if (!identifyOnly || matchAny || order == bondAB.order || matchHbond Modified: branches/v11_4/Jmol/src/org/jmol/viewer/Compiler.java =================================================================== --- branches/v11_4/Jmol/src/org/jmol/viewer/Compiler.java 2008-07-17 21:19:38 UTC (rev 9611) +++ branches/v11_4/Jmol/src/org/jmol/viewer/Compiler.java 2008-07-18 12:40:14 UTC (rev 9612) @@ -407,9 +407,11 @@ if (nTokens == ptNewSetModifier) { ch = script.charAt(ichToken); if (tokCommand == Token.set || tokAttr(tokCommand, Token.setparam)) { - if (tokAttr(tokCommand, Token.setparam) && ch == '=' || - (isNewSet || isSetBrace) && (ch == '=' || ch == '[' || ch == '.')) { - tokenCommand = (ch == '=' ? Token.tokenSet : ch == '[' ? Token.tokenSetArray : Token.tokenSetProperty); + if (tokAttr(tokCommand, Token.setparam) && ch == '=' + || (isNewSet || isSetBrace) + && (ch == '=' || ch == '[' || ch == '.')) { + tokenCommand = (ch == '=' ? Token.tokenSet + : ch == '[' ? Token.tokenSetArray : Token.tokenSetProperty); tokCommand = Token.set; ltoken.insertElementAt(tokenCommand, 0); cchToken = 1; @@ -429,8 +431,7 @@ + cchToken - 1) : getUnescapedStringLiteral()); addTokenToPrefix(new Token(Token.string, str)); iHaveQuotedString = true; - if (tokCommand == Token.data && str.indexOf("@") < 0 - && !getData(str)) + if (tokCommand == Token.data && str.indexOf("@") < 0 && !getData(str)) return missingEnd("data"); continue; } @@ -520,8 +521,8 @@ } if (lookingAtSeqcode()) { ch = script.charAt(ichToken); - int seqNum = (ch == '*' || ch == '^' ? Integer.MAX_VALUE - : Integer.parseInt(script.substring(ichToken, ichToken + cchToken - 2))); + int seqNum = (ch == '*' || ch == '^' ? Integer.MAX_VALUE : Integer + .parseInt(script.substring(ichToken, ichToken + cchToken - 2))); char insertionCode = script.charAt(ichToken + cchToken - 1); if (insertionCode == '^') insertionCode = ' '; @@ -537,8 +538,8 @@ return badArgumentCount(); FlowContext f = getBreakableContext(val = Math.abs(val)); if (f == null) - return badContext((String)tokenCommand.value); - ((Token)ltoken.get(0)).intValue = f.pt0; //copy + return badContext((String) tokenCommand.value); + ((Token) ltoken.get(0)).intValue = f.pt0; //copy } addTokenToPrefix(new Token(Token.integer, val, intString)); continue; @@ -581,6 +582,13 @@ token = new Token(Token.identifier, ident); } int tok = token.tok; + switch (tok) { + case Token.leftsquare: + bracketCount++; + break; + case Token.rightsquare: + bracketCount--; + } switch (tokCommand) { // special cases case Token.nada: @@ -605,15 +613,13 @@ break; case Token.endifcmd: isEnd = true; - if (flowContext == null || - flowContext.token.tok != Token.ifcmd - && flowContext.token.tok != Token.elsecmd + if (flowContext == null || flowContext.token.tok != Token.ifcmd + && flowContext.token.tok != Token.elsecmd && flowContext.token.tok != Token.elseif) return badContext("endif"); break; case Token.elsecmd: - if (flowContext == null - || flowContext.token.tok != Token.ifcmd + if (flowContext == null || flowContext.token.tok != Token.ifcmd && flowContext.token.tok != Token.elseif) return badContext("else"); flowContext.token.intValue = flowContext.pt0 = pt; @@ -623,12 +629,11 @@ isNew = false; FlowContext f = getBreakableContext(0); if (f == null) - return badContext((String)token.value); + return badContext((String) token.value); token = new Token(tok, f.pt0, token.value); //copy break; case Token.elseif: - if (flowContext == null - || flowContext.token.tok != Token.ifcmd + if (flowContext == null || flowContext.token.tok != Token.ifcmd && flowContext.token.tok != Token.elseif && flowContext.token.tok != Token.elsecmd) return badContext("elseif"); @@ -693,9 +698,9 @@ if (nTokens != 1 || tok != Token.ifcmd) return badArgumentCount(); ltoken.removeElementAt(0); - ltoken.addElement(token = new Token (Token.elseif, "elseif")); + ltoken.addElement(token = new Token(Token.elseif, "elseif")); flowContext.token = token; - tokCommand = Token.elseif; + tokCommand = Token.elseif; continue; case Token.var: if (nTokens != 1) @@ -709,8 +714,7 @@ if (nTokens != 1) return badArgumentCount(); if (flowContext == null || flowContext.token.tok != tok) - if (tok != Token.ifcmd || - flowContext.token.tok != Token.elsecmd + if (tok != Token.ifcmd || flowContext.token.tok != Token.elsecmd && flowContext.token.tok != Token.elseif) return badContext("end " + ident); switch (tok) { @@ -720,7 +724,8 @@ break; case Token.function: if (!isCheckOnly) - (thisFunction.name.indexOf("_") == 0 ? localFunctions : globalFunctions).put(thisFunction.name, thisFunction); + (thisFunction.name.indexOf("_") == 0 ? localFunctions + : globalFunctions).put(thisFunction.name, thisFunction); flowContext.setFunction(script, ichCurrentCommand, lltoken.size(), lineNumbers, lineIndices, lltoken); thisFunction = null; @@ -739,18 +744,19 @@ return unrecognizedToken(ident); nSemiSkip = 2; //checked twice } - if (nTokens == 3 && ((Token)ltoken.get(2)).tok == Token.var) - addContextVariable(ident); + if (nTokens == 3 && ((Token) ltoken.get(2)).tok == Token.var) + addContextVariable(ident); break; case Token.set: if (tok == Token.leftbrace) braceCount++; else if (tok == Token.rightbrace) { braceCount--; - if (isSetBrace && braceCount == 0 && ptNewSetModifier == Integer.MAX_VALUE) + if (isSetBrace && braceCount == 0 + && ptNewSetModifier == Integer.MAX_VALUE) ptNewSetModifier = nTokens + 1; } - if (nTokens == ptNewSetModifier) { // 1 when { is not present + if (nTokens == ptNewSetModifier) { // 1 when { is not present boolean isSetArray = false; if (tok == Token.opEQ || tok == Token.leftsquare) { // x = or x[n] = @@ -783,68 +789,62 @@ } } break; + case Token.restrict: + case Token.select: + case Token.display: + case Token.hide: case Token.define: - if (nTokens == 1) { - // we are looking at the variable name - if (tok != Token.identifier) { - if (preDefining) { - if (!tokAttr(tok, Token.predefinedset)) - return compileError("ERROR IN Token.java or JmolConstants.java -- the following term was used in JmolConstants.java but not listed as predefinedset in Token.java: " - + ident); - } else if (tokAttr(tok, Token.predefinedset)) { - Logger - .warn("WARNING: predefined term '" - + ident - + "' has been redefined by the user until the next file load."); - } else if (!isCheckOnly && ident.length() > 1){ - Logger - .warn("WARNING: redefining " - + ident - + "; was " - + token - + "not all commands may continue to be functional for the life of the applet!"); - tok = token.tok = Token.identifier; - Token.addToken(ident, token); + if (tok == Token.define) { + if (nTokens == 1) { + // we are looking at the variable name + if (tok != Token.identifier) { + if (preDefining) { + if (!tokAttr(tok, Token.predefinedset)) + return compileError("ERROR IN Token.java or JmolConstants.java -- the following term was used in JmolConstants.java but not listed as predefinedset in Token.java: " + + ident); + } else if (tokAttr(tok, Token.predefinedset)) { + Logger + .warn("WARNING: predefined term '" + + ident + + "' has been redefined by the user until the next file load."); + } else if (!isCheckOnly && ident.length() > 1) { + Logger + .warn("WARNING: redefining " + + ident + + "; was " + + token + + "not all commands may continue to be functional for the life of the applet!"); + tok = token.tok = Token.identifier; + Token.addToken(ident, token); + } } + break; } - } else if (nTokens == 2 && tok == Token.opEQ) { - // we are looking at @x =.... just insert a SET command - // and ignore the =. It's the same as set @x ... - ltoken.insertElementAt(Token.tokenSet, 0); - continue; - } else { - // we are looking at the expression - if (tok != Token.identifier && tok != Token.set - && !(tokAttr(tok, Token.expression))) - return invalidExpressionToken(ident); + if (nTokens == 2 && tok == Token.opEQ) { + // we are looking at @x =.... just insert a SET command + // and ignore the =. It's the same as set @x ... + ltoken.insertElementAt(Token.tokenSet, 0); + continue; + } } + if (bracketCount == 0 && tok != Token.identifier + && !tokAttr(tok, Token.expression) && tok != Token.min + && tok != Token.max) + return invalidExpressionToken(ident); break; case Token.center: if (tok != Token.identifier && tok != Token.dollarsign && !tokAttr(tok, Token.expression)) return invalidExpressionToken(ident); break; - case Token.restrict: - case Token.select: - case Token.display: - case Token.hide: - if (tok == Token.leftsquare) - bracketCount++; - if (tok == Token.rightsquare) - bracketCount--; - //ensure anything goes for inside brackets - if (tok != Token.identifier && !tokAttr(tok, Token.expression) - && tok != Token.min && tok != Token.max && bracketCount == 0) - return invalidExpressionToken(ident); - break; } addTokenToPrefix(token); continue; } - if (nTokens == 0 || - (isNewSet || isSetBrace) && nTokens == ptNewSetModifier) + if (nTokens == 0 || (isNewSet || isSetBrace) + && nTokens == ptNewSetModifier) return commandExpected(); - return unrecognizedToken(script.substring(ichToken, ichToken+1)); + return unrecognizedToken(script.substring(ichToken, ichToken + 1)); } aatokenCompiled = new Token[lltoken.size()][]; lltoken.copyInto(aatokenCompiled); Modified: branches/v11_4/Jmol/src/org/jmol/viewer/Jmol.properties =================================================================== --- branches/v11_4/Jmol/src/org/jmol/viewer/Jmol.properties 2008-07-17 21:19:38 UTC (rev 9611) +++ branches/v11_4/Jmol/src/org/jmol/viewer/Jmol.properties 2008-07-18 12:40:14 UTC (rev 9612) @@ -1,5 +1,7 @@ version=11.4.6_dev +# bug fix: DEFINE can cause compiling error, e.g. "[2MO]" in 1tmo + # ----------------------------------------------------------------------------- #version=11.4.5 This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |