From: <ha...@us...> - 2009-06-05 07:43:18
|
Revision: 10956 http://jmol.svn.sourceforge.net/jmol/?rev=10956&view=rev Author: hansonr Date: 2009-06-05 07:43:08 +0000 (Fri, 05 Jun 2009) Log Message: ----------- version=11.7.40 flow control { } and inline IF ( ... ? .... : .... ) # new feature: complete freedom from lines and "end if, end for, end while" -- # just use standard { } notation. If no braces are used, then END must be used: # # for (var x = 1; x < {*}; x = x + 1) # if ({*}[x].temperature < 10) # ({*}[x]).radius = 1 # else # ({*}[x]).radius = 0 # end if # end for # # same as: # # for (var x = 1; x < {*}; x = x + 1){ # if ({*}[x].temperature < 10) { # ({*}[x]).radius = 1 # } else { # ({*}[x]).radius = 0 # } # } # # same as: # # for (var x = 1; x < {*}; x = x + 1){ # {{*}[x]}.radius = ({*}[x].temperature < 10 ? 1 : 0) # } # # same as: # # for (var x = 1; x < {*}; x = x + 1){{{*}[x]}.radius = ({*}[x].temperature < 10 ? 1 : 0)} # # new feature: standard { ... ? ... : ... ) notation in Jmol math: # # print ({*} < 100 ? "a small molecule" : "at least 100 atoms") # Modified Paths: -------------- trunk/Jmol/src/org/jmol/viewer/Compiler.java Modified: trunk/Jmol/src/org/jmol/viewer/Compiler.java =================================================================== --- trunk/Jmol/src/org/jmol/viewer/Compiler.java 2009-06-05 06:54:03 UTC (rev 10955) +++ trunk/Jmol/src/org/jmol/viewer/Compiler.java 2009-06-05 07:43:08 UTC (rev 10956) @@ -382,6 +382,7 @@ int tok = 0; int setBraceCount = 0; int bracketCount = 0; + int setEqualPt = 0; String comment = null; boolean endOfLine = false; boolean isEndOfCommand = false; @@ -481,9 +482,12 @@ char ch; if (nTokens > 0) { if (nTokens == ptNewSetModifier) { - ch = script.charAt(ichToken); if (tokCommand == Token.set || Token.tokAttr(tokCommand, Token.setparam)) { + ch = script.charAt(ichToken); + if (ch == '=') + setEqualPt = ichToken; + // axes, background, define, display, echo, frank, hbond, history, // set, var // can all appear with or without "set" in front of them. These @@ -494,8 +498,8 @@ if (Token.tokAttr(tokCommand, Token.setparam) && ch == '=' || (isNewSet || isSetBrace) && (ch == '=' || ch == '[' || ch == '.')) { - tokenCommand = (ch == '=' ? Token.tokenSet - : ch == '[' ? Token.tokenSetArray : Token.tokenSetProperty); + tokenCommand = (ch == '=' ? Token.tokenSet : ch == '[' + && !isSetBrace ? Token.tokenSetArray : Token.tokenSetProperty); tokCommand = Token.set; ltoken.insertElementAt(tokenCommand, 0); cchToken = 1; @@ -507,7 +511,6 @@ } else { lastToken = Token.tokenMinus; // just to allow for {(....)} } - continue; } } @@ -708,6 +711,16 @@ } tok = token.tok; switch (tok) { + case Token.opEQ: + if (isSetBrace) + setEqualPt = ichToken; + break; + case Token.dot: + if (isSetBrace && ichToken < setEqualPt) { + ltoken.insertElementAt(Token.tokenExpressionBegin, 1); + addTokenToPrefix(Token.tokenExpressionEnd); + } + break; case Token.leftbrace: braceCount++; if (braceCount == 1 && parenCount == 0 && checkFlowStartBrace(false)) { @@ -820,7 +833,7 @@ isNewSet = !isSetBrace; setBraceCount = (isSetBrace ? 1 : 0); bracketCount = 0; - ptNewSetModifier = (isNewSet ? 1 : Integer.MAX_VALUE); + setEqualPt = ptNewSetModifier = (isNewSet ? 1 : Integer.MAX_VALUE); break; case Token.function: if (tokenCommand.intValue == 0) { This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |