ソースを参照

VMD parser debugged

yakomaxa 2 年 前
コミット
fcd5b2ce0a
1 ファイル変更25 行追加21 行削除
  1. 25 21
      src/mol-script/transpilers/vmd/parser.ts

+ 25 - 21
src/mol-script/transpilers/vmd/parser.ts

@@ -57,31 +57,35 @@ const valueOperators: OperatorList = [
         type: h.binaryLeft,
         rule: P.MonadicParser.alt(P.MonadicParser.regexp(/\s*(=~|==|>=|<=|=|!=|>|<)\s*/, 1), P.MonadicParser.whitespace.result('=')),
         map: (op, e1, e2) => {
-	    console.log(e1.head !== undefined && e2.head !==undefined)
+//	    console.log(e1.head !== undefined && e2.head !==undefined)
             console.log(op, e1, e2)
             let expr;
-	    if (e1.head !== undefined && e2.head !== undefined){
+	    if (e1.head !== undefined){
 		if (e1.head.name === 'structure-query.atom-property.macromolecular.secondary-structure-flags') {
-                    expr = B.core.flags.hasAny([e1, sstrucMap(e2)]);
-		} else if (e2.head.name === 'structure-query.atom-property.macromolecular.secondary-structure-flags') {
-                    expr = B.core.flags.hasAny([e2, sstrucMap(e1)]);
-		} else if (e1.head.name === 'core.type.regex') {
-                    expr = B.core.str.match([e1, B.core.type.str([e2])]);
-		} else if (e2.head.name === 'core.type.regex') {
-                    expr = B.core.str.match([e2, B.core.type.str([e1])]);
-		} else if (op === '=~') {
-                    if (e1.head.name) {
-			expr = B.core.str.match([
-                            B.core.type.regex([`^${e2}$`, 'i']),
-                            B.core.type.str([e1])
-			]);
-                    } else {
-			expr = B.core.str.match([
-                            B.core.type.regex([`^${e1}$`, 'i']),
-                            B.core.type.str([e2])
-			]);
-                    }
+		    expr = B.core.flags.hasAny([e1, sstrucMap(e2)]);
 		}
+		if (e1.head.name === 'core.type.regex') {
+		    expr = B.core.str.match([e1, B.core.type.str([e2])]);
+		}
+	    }else if (e2.head !== undefined){
+		if (e2.head.name === 'structure-query.atom-property.macromolecular.secondary-structure-flags') {
+		    expr = B.core.flags.hasAny([e2, sstrucMap(e1)]);
+		}
+		if (e2.head.name === 'core.type.regex') {
+		    expr = B.core.str.match([e2, B.core.type.str([e1])]);
+		}
+	    }else if (op === '=~') {
+                if (e1.head) {
+		    expr = B.core.str.match([
+                        B.core.type.regex([`^${e2}$`, 'i']),
+                        B.core.type.str([e1])
+		    ]);
+                }else{
+		    expr = B.core.str.match([
+                        B.core.type.regex([`^${e1}$`, 'i']),
+                        B.core.type.str([e2])
+		    ]);
+                }
 	    }
             if (!expr) {
                 if (e1.head) e2 = h.wrapValue(e1, e2);