Commits

bookaa committed 2a2273f

629

Comments (0)

Files changed (3)

 
     def ExpectVRight(self):
         v = self.ExpectOneToken()
-        v = self.Complete_MostToken(v)
         tokenstack = [v]
         self.Complete_CombineToken(tokenstack)
         assert len(tokenstack) == 1
         return tokenstack[0]
 
-    def Complete_MostToken(self, vleft):
-        tp = self.tp
-        if tp.IsLineEnd():
-            return vleft
-
-        c = tp.PickChar()
-        if c == '(':
-            params = self.ParseParams()
-            v = VarDefine.FuncToken(vleft, params)
-            return self.Complete_MostToken(v)
-        if c == '.':
-            tp.SkipChar()
-            wd2 = tp.SkipOneWord()
-            assert wd2
-            var2 = VarDefine.NameToken(wd2)
-            var2 = self.Complete_MostToken(var2)
-            v = VarDefine.CombineToken(vleft, var2, '.')
-            return v
-        return vleft
     def Complete_CombineToken(self, tokenstack):
         tp = self.tp
-        verb = self.CheckIfStartWith(self.langdef.linkverbs)
-        if verb:
+        while True:
+            if tp.IsLineEnd():
+                break
+            c = tp.PickChar()
+            if c == '(':
+                params = self.ParseParams()
+                tokenstack[-1] = VarDefine.FuncToken(tokenstack[-1], params)
+                continue
+            verb = self.CheckIfStartWith(self.langdef.linkverbs)
+            if not verb:
+                break
             self.Complete_CombineToken_verb(tokenstack, verb)
             tp.SkipTheWord(verb)
             tokenstack.append(verb)
             vright = self.ExpectOneToken()
             tokenstack.append(vright)
-            self.Complete_CombineToken(tokenstack)
-            return
         self.Complete_CombineToken_verb(tokenstack, None)
 
     def Complete_CombineToken_verb(self, tokenstack, verb):
         if c == "'":
             s = tp.PopString("'")
             return VarDefine.StringToken(s)
+        if c == '(':
+            tp.SkipChar('(')
+            v = self.ExpectVRight()
+            tp.SkipChar(')')
+            return v
         assert False
 
     def Parse_Class_likepython(self):
         return 'unknown'
 
 the = C()
-print the.a + 5, the.b, the.c
+print the.a - (5-2), the.b, the.c
 '''
 
 mb = MainBrain()
             v2 = int(v.val)
             return Value('number', str(v1 + v2))
         assert False
+    def Minus(self, v):
+        if self.typestr == 'number' and v.typestr == 'number':
+            v1 = int(self.val)
+            v2 = int(v.val)
+            return Value('number', str(v1 - v2))
+        assert False
 
 def IsPythonNumber(s):
     # support more number format later
             v1 = self.vleft.GetValue(rs)
             v2 = self.vright.GetValue(rs)
             return v1.Plus(v2)
+        if self.op == '-':
+            v1 = self.vleft.GetValue(rs)
+            v2 = self.vright.GetValue(rs)
+            return v1.Minus(v2)
         assert False
     def GetValueInList(self, rs):
         if self.op == ',':
Tip: Filter by directory path e.g. /media app.js to search for public/media/app.js.
Tip: Use camelCasing e.g. ProjME to search for ProjectModifiedEvent.java.
Tip: Filter by extension type e.g. /repo .js to search for all .js files in the /repo directory.
Tip: Separate your search with spaces e.g. /ssh pom.xml to search for src/ssh/pom.xml.
Tip: Use ↑ and ↓ arrow keys to navigate and return to view the file.
Tip: You can also navigate files with Ctrl+j (next) and Ctrl+k (previous) and view the file with Ctrl+o.
Tip: You can also navigate files with Alt+j (next) and Alt+k (previous) and view the file with Alt+o.