manifoldcf-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From kwri...@apache.org
Subject svn commit: r1329123 - /incubator/lcf/trunk/framework/core/src/test/resources/org/apache/manifoldcf/core/tests/Javascript.py
Date Mon, 23 Apr 2012 08:30:27 GMT
Author: kwright
Date: Mon Apr 23 08:30:27 2012
New Revision: 1329123

URL: http://svn.apache.org/viewvc?rev=1329123&view=rev
Log:
Add ++ and -- operators to Javscript emulator.

Modified:
    incubator/lcf/trunk/framework/core/src/test/resources/org/apache/manifoldcf/core/tests/Javascript.py

Modified: incubator/lcf/trunk/framework/core/src/test/resources/org/apache/manifoldcf/core/tests/Javascript.py
URL: http://svn.apache.org/viewvc/incubator/lcf/trunk/framework/core/src/test/resources/org/apache/manifoldcf/core/tests/Javascript.py?rev=1329123&r1=1329122&r2=1329123&view=diff
==============================================================================
--- incubator/lcf/trunk/framework/core/src/test/resources/org/apache/manifoldcf/core/tests/Javascript.py
(original)
+++ incubator/lcf/trunk/framework/core/src/test/resources/org/apache/manifoldcf/core/tests/Javascript.py
Mon Apr 23 08:30:27 2012
@@ -1463,7 +1463,10 @@ class JSTokenStream:
     def evaluate_expr9( self, context, place, parse_only=False ):
         # expr9 -> "!" expr9
         # expr9 -> "-" expr9
-        # expr9 -> expr10
+        # expr9 -> "++" expr9
+        # expr9 -> "--" expr9
+        # expr9 -> expr10 ["++" ...]
+        # expr9 -> expr10 ["--" ...]
         token = self.peek( )
         if token != None and token.get_punc( ) == "!":
             self.advance( )
@@ -1481,6 +1484,14 @@ class JSTokenStream:
             if parse_only:
                 return JSNull()
             return self.negate ( nextvalue )
+        elif token != None and token.get_punc( ) == "--":
+            self.advance( )
+            nextvalue = self.evaluate_expr9( context, place, parse_only )
+            if nextvalue == None:
+                raise Exception("Missing expression after '--' in %s" % place)
+            if parse_only:
+                return JSNull()
+            return self.pre_minusminus ( nextvalue )
         elif token != None and token.get_punc( ) == "+":
             self.advance( )
             nextvalue = self.evaluate_expr9( context, place, parse_only )
@@ -1489,6 +1500,14 @@ class JSTokenStream:
             if parse_only:
                 return JSNull()
             return self.positive ( nextvalue )
+        elif token != None and token.get_punc( ) == "++":
+            self.advance( )
+            nextvalue = self.evaluate_expr9( context, place, parse_only )
+            if nextvalue == None:
+                raise Exception("Missing expression after '++' in %s" % place)
+            if parse_only:
+                return JSNull()
+            return self.pre_plusplus ( nextvalue )
         elif token != None and token.get_symbol( ) == "new":
             self.advance( )
             token = self.peek( )
@@ -1530,8 +1549,24 @@ class JSTokenStream:
 
             return value.construct( arguments, context )
 
-        return self.evaluate_expr10( context, place, parse_only )
-
+        rval = self.evaluate_expr10( context, place, parse_only )
+        if rval == None:
+            return rval
+        while True:
+            token = self.peek( )
+            if token != None and token.get_punc( ) == "++":
+                # ++ operator
+                self.advance( )
+                if parse_only==False:
+                    rval = self.post_plusplus( rval )
+            elif token != None and token.get_punc( ) == "--":
+                # -- operator
+                self.advance( )
+                if parse_only==False:
+                    rval = self.post_minusminus( rval )
+            else:
+                return rval
+        
     def logical_not( self, value1 ):
         return JSBoolean( not value1.bool_value( ) )
 
@@ -1541,6 +1576,24 @@ class JSTokenStream:
     def positive( self, value1 ):
         return JSNumber( +value1.num_value( ) )
 
+    def post_minusminus( self, value1 ):
+        rval = value1.dereference( )
+        value1.set_reference( self.minus( value1, JSNumber( 1 ) ).dereference( ) )
+        return rval
+      
+    def post_plusplus( self, value1 ):
+        rval = value1.dereference( )
+        value1.set_reference( self.plus( value1, JSNumber( 1 ) ).dereference( ) )
+        return rval
+
+    def pre_minusminus( self, value1 ):
+        value1.set_reference( self.minus( value1, JSNumber( 1 ) ).dereference( ) )
+        return value1
+      
+    def pre_plusplus( self, value1 ):
+        value1.set_reference( self.plus( value1, JSNumber( 1 ) ).dereference( ) )
+        return value1
+
     def evaluate_expr10( self, context, place, parse_only=False ):
         # expr10 -> expr11
         # expr10 -> expr11 "(" [expr ["," ...]] ")"



Mime
View raw message