Revision: 20365
          http://sourceforge.net/p/jmol/code/20365
Author:   hansonr
Date:     2015-03-07 16:47:20 +0000 (Sat, 07 Mar 2015)
Log Message:
-----------
Jmol.___JmolVersion="14.3.13_2015.03.07"
synchronized with 14.2.12_2015.03.07

bug fix: x[2] = y[2] fails

Modified Paths:
--------------
    trunk/Jmol/src/org/jmol/script/ScriptCompiler.java
    trunk/Jmol/src/org/jmol/script/ScriptEval.java
    trunk/Jmol/src/org/jmol/script/ScriptExpr.java
    trunk/Jmol/src/org/jmol/script/ScriptMathProcessor.java
    trunk/Jmol/src/org/jmol/script/T.java
    trunk/Jmol/src/org/jmol/viewer/Jmol.properties

Modified: trunk/Jmol/src/org/jmol/script/ScriptCompiler.java
===================================================================
--- trunk/Jmol/src/org/jmol/script/ScriptCompiler.java  2015-03-07 16:45:45 UTC 
(rev 20364)
+++ trunk/Jmol/src/org/jmol/script/ScriptCompiler.java  2015-03-07 16:47:20 UTC 
(rev 20365)
@@ -1024,12 +1024,12 @@
           cchToken = 1;
           switch (ch) {
           case '[':
-            addTokenToPrefix(T.o(T.leftsquare, "["));
+            addTokenToPrefix(T.tokenArrayOpen);
             bracketCount++;
             return CONTINUE;
           case '.':
             if (ch2 == '.') {
-              addTokenToPrefix(T.o(T.leftsquare, "["));
+              addTokenToPrefix(T.tokenArrayOpen);
               cchToken = 2;
               isDotDot = true;
               return CONTINUE;
@@ -1301,7 +1301,7 @@
 
     if (isDotDot) {
       addTokenToPrefix(T.o(T.string, ident));
-      addTokenToPrefix(T.o(T.rightsquare, "]"));
+      addTokenToPrefix(T.tokenArrayClose);
       isDotDot = false;
       return CONTINUE;
     }
@@ -1496,7 +1496,7 @@
       break;
     case T.perper:
       isDotDot = true;
-      addTokenToPrefix(T.o(T.leftsquare, "["));
+      addTokenToPrefix(T.tokenArrayOpen);
       return CONTINUE;
     }
     return OK;
@@ -1763,24 +1763,23 @@
         flowContext.setLine();
       }
       break;
-    case T.set:
     case T.var:
-      if (tokCommand == T.var) {
-        if (nTokens == 1) {
-          replaceCommand(T.tokenSetVar);
-          newContextVariable(ident);
-          break;
-        } else if (ident.equals(",")) {
-          return CONTINUE;
-        } else if (!PT.isLetter(ident.charAt(0))) {
-          if (nTokens != 2)
-            return ERROR(ERROR_badArgumentCount);
-          replaceCommand(T.tokenSet);
-        } else {
-          newContextVariable(ident);
-          break;
-        }
+      if (nTokens == 1) {
+        replaceCommand(T.tokenSetVar);
+        newContextVariable(ident);
+        break;
+      } else if (ident.equals(",")) {
+        return CONTINUE;
+      } else if (!PT.isLetter(ident.charAt(0))) {
+        if (nTokens != 2 || ident.equals("["))
+          return ERROR(ERROR_badArgumentCount);
+        replaceCommand(T.tokenSet);
+      } else {
+        newContextVariable(ident);
+        break;
       }
+      //$FALL-THROUGH$
+    case T.set:
       if (theTok == T.leftbrace)
         setBraceCount++;
       else if (theTok == T.rightbrace) {

Modified: trunk/Jmol/src/org/jmol/script/ScriptEval.java
===================================================================
--- trunk/Jmol/src/org/jmol/script/ScriptEval.java      2015-03-07 16:45:45 UTC 
(rev 20364)
+++ trunk/Jmol/src/org/jmol/script/ScriptEval.java      2015-03-07 16:47:20 UTC 
(rev 20365)
@@ -7071,7 +7071,6 @@
         vwr.removeUserVariable(key.toLowerCase());
       justShow = true;
     }
-
     if (!justShow) {
       setVariable(1, 0, key, true);
       if (!isJmolSet)

Modified: trunk/Jmol/src/org/jmol/script/ScriptExpr.java
===================================================================
--- trunk/Jmol/src/org/jmol/script/ScriptExpr.java      2015-03-07 16:45:45 UTC 
(rev 20364)
+++ trunk/Jmol/src/org/jmol/script/ScriptExpr.java      2015-03-07 16:47:20 UTC 
(rev 20365)
@@ -122,7 +122,8 @@
    *        variables
    * @param localVar
    *        x or y in above for(), select() examples
-   * @param isSpecialAssignment TODO
+   * @param isSpecialAssignment 
+   *        x[n] = .... 
    * @return either a vector or a value, caller's choice.
    * @throws ScriptException
    *         errors are thrown directly to the Eval error system.
@@ -448,9 +449,10 @@
               break;
             //$FALL-THROUGH$
           default:
-            rpn.addOp(T.o(T.leftsquare, "["));
+            // turn x.y into x[y] prior to equal sign
+            rpn.addOp(T.tokenArrayOpen);
             rpn.addXStr(optParameterAsString(++i));
-            rpn.addOp(T.o(T.rightsquare, "]"));
+            rpn.addOp(T.tokenArrayClose);
             continue;
           }
         }
@@ -1984,28 +1986,38 @@
     // special assignment of a known variable
 
     if (isSet && !isExpression) {
-      // pt will be 1 unless...
+      // not {....}.x = 
       switch (tokAt(2)) {
+      default:
+        // standard case
+        // a = ...
+        // set a ...
+        pt = 2;
+        break;
+      case T.opEQ:
+        // standard case for var
+        // var a = ...
+        pt = 3;
+        break;
       case T.spacebeforesquare:
       case T.leftsquare:
-        if (st[0].intValue == '=')
+        // x[n] = ...
+        if (st[0].intValue == 61) { // '='
+          // not clear what this is about...
           pt = 2;
-        break;
+          break;
+        } 
+        //$FALL-THROUGH$
       case T.per:
       case T.perper:
+        // x.y = ...
+        // pt will be 1 in this case -- evaluate x
+        // result array will hold selector .y and result
+        // do not assign a variable
+        // isspecialAssignment
+        key = null;
         break;
-      case T.opEQ:
-        // var a = ...
-        pt = 3;
-        break;
-      default:
-        // a = ...
-        // set a ...
-        pt = 2;
-        break;
       }
-      if (pt == 1)
-        key = null;
     }
     int nv = 0;
     Lst<SV> v = (Lst<SV>) parameterExpression(pt, ptMax, key, true, true, -1,
@@ -2015,7 +2027,7 @@
       invArg();
     if (chk)
       return null;
-    SV tv = SV.newS("").setv(v.get(nv - 1));
+    SV tv = SV.selectItemVar(SV.newS("").setv(v.get(nv - 1)));
     if (nv > 1) {
       SV sel = (nv > 2 ? v.get(1) : null);
       t = v.get(0);

Modified: trunk/Jmol/src/org/jmol/script/ScriptMathProcessor.java
===================================================================
--- trunk/Jmol/src/org/jmol/script/ScriptMathProcessor.java     2015-03-07 
16:45:45 UTC (rev 20364)
+++ trunk/Jmol/src/org/jmol/script/ScriptMathProcessor.java     2015-03-07 
16:47:20 UTC (rev 20365)
@@ -98,6 +98,21 @@
   private boolean allowUnderflow;
   private boolean isAssignment;
 
+  /**
+   * 
+   * @param eval
+   * @param isSpecialAssignment  
+   *       x[n] = ...
+   * @param isArrayItem
+   * @param asVector
+   *       return a Lst(SV) from getResult()
+   * @param asBitSet
+   *       return a (SV)bitset
+   * @param allowUnderflow
+   *       expression can terminate prior to end of statement
+   *       
+   * @param key
+   */
   ScriptMathProcessor(ScriptExpr eval, boolean isSpecialAssignment, boolean 
isArrayItem,
       boolean asVector, boolean asBitSet, boolean allowUnderflow, String key) {
     this.eval = eval;
@@ -538,7 +553,7 @@
           // x[3] = .... ; add a special flag for this, 
           // waiting until the very end to apply it.
           wasX = false;
-          addX(SV.newT(T.tokenArraySelector));
+          addX(SV.newT(T.tokenArrayOpen));
           break;
         }
         if (!doSelection())
@@ -851,7 +866,7 @@
       return true;
 
     SV x2 = getX();
-    if (x2 == T.tokenArraySelector)
+    if (x2 == T.tokenArrayOpen)
       return false;
 
     //unnecessary  -- getX() does this. x2 = selectX(x2);

Modified: trunk/Jmol/src/org/jmol/script/T.java
===================================================================
--- trunk/Jmol/src/org/jmol/script/T.java       2015-03-07 16:45:45 UTC (rev 
20364)
+++ trunk/Jmol/src/org/jmol/script/T.java       2015-03-07 16:47:20 UTC (rev 
20365)
@@ -1379,8 +1379,9 @@
 
   public final static T tokenLeftParen = o(leftparen, "(");
   public final static T tokenRightParen = o(rightparen, ")");
-  public final static T tokenArraySquare = o(array, "[");
-  public final static T tokenArraySelector = o(leftsquare, "[");
+  public final static T tokenArraySquare = o(array, "[");        // special 
operator stack flag
+  public final static T tokenArrayOpen = o(leftsquare, "[");     // used also 
as special operand stack flag
+  public final static T tokenArrayClose = o(rightsquare, "]");   
  
   public final static T tokenExpressionBegin = o(expressionBegin, 
"expressionBegin");
   public final static T tokenExpressionEnd   = o(expressionEnd, 
"expressionEnd");

Modified: trunk/Jmol/src/org/jmol/viewer/Jmol.properties
===================================================================
--- trunk/Jmol/src/org/jmol/viewer/Jmol.properties      2015-03-07 16:45:45 UTC 
(rev 20364)
+++ trunk/Jmol/src/org/jmol/viewer/Jmol.properties      2015-03-07 16:47:20 UTC 
(rev 20365)
@@ -13,8 +13,12 @@
 #  important for the JavaScript version of Jmol.
 
 TODO: remove HTML5 dependency on synchronous file loading (check SCRIPT 
command for problems)
-Jmol.___JmolVersion="14.3.12_2015.03.06"
 
+Jmol.___JmolVersion="14.3.13_2015.03.07"
+synchronized with 14.2.12_2015.03.07
+
+bug fix: x[2] = y[2] fails
+
 new feature: NBO command with no arguments starts NBO panel (Java application 
only)
 
 JmolVersion="14.3.12_2015.03.05b"

This was sent by the SourceForge.net collaborative development platform, the 
world's largest Open Source development site.


------------------------------------------------------------------------------
Dive into the World of Parallel Programming The Go Parallel Website, sponsored
by Intel and developed in partnership with Slashdot Media, is your hub for all
things parallel software development, from weekly thought leadership blogs to
news, videos, case studies, tutorials and more. Take a look and join the 
conversation now. http://goparallel.sourceforge.net/
_______________________________________________
Jmol-commits mailing list
Jmol-commits@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/jmol-commits

Reply via email to