RPA Toolkit
work on AST 2
authorMartin Stoilov <martin@rpasearch.com>
Tue, 8 Feb 2011 04:07:18 +0000 (20:07 -0800)
committerMartin Stoilov <martin@rpasearch.com>
Tue, 8 Feb 2011 04:07:18 +0000 (20:07 -0800)
datafiles/js2.txt
rast/rastnode.c
rast/rastnode.h
rpa/rpaconfig.h
tests/astecma262.rpa
tests/rast-test.c

index 61a575c..323c5eb 100644 (file)
@@ -1,4 +1,5 @@
 function factorial(n) {
+        var result;
         if ( ( ( ( ( ( ( ( ( (( ( n == 0 ) ) ) ) || (n == 1) ) ) ) ) ) ) ) )
            return 1;
            else {
@@ -8,7 +9,8 @@ function factorial(n) {
 }
 
 
-function factorial(n) {
+function factorial1(n) {
+        var result;
         if ( ( ( ( ( ( ( ( ( (( ( n == 0 ) ) ) ) || (n == 1) ) ) ) ) ) ) ) )
            return 1;
            else {
@@ -16,7 +18,8 @@ function factorial(n) {
                        return result;
                        }
 }
-function factorial(n) {
+function factorial2(n) {
+        var result;
         if ( ( ( ( ( ( ( ( ( (( ( n == 0 ) ) ) ) || (n == 1) ) ) ) ) ) ) ) )
            return 1;
            else {
@@ -24,7 +27,8 @@ function factorial(n) {
                        return result;
                        }
 }
-function factorial(n) {
+function factorial3(n) {
+        var result;
         if ( ( ( ( ( ( ( ( ( (( ( n == 0 ) ) ) ) || (n == 1) ) ) ) ) ) ) ) )
            return 1;
            else {
@@ -32,7 +36,8 @@ function factorial(n) {
                        return result;
                        }
 }
-function factorial(n) {
+function factorial4(n) {
+        var result;
         if ( ( ( ( ( ( ( ( ( (( ( n == 0 ) ) ) ) || (n == 1) ) ) ) ) ) ) ) )
            return 1;
            else {
@@ -41,7 +46,8 @@ function factorial(n) {
                        }
 }
 
-function factorial(n) {
+function factorial5(n) {
+        var result;
         if ( ( ( ( ( ( ( ( ( (((n == 0)))) || (n == 1)))))))))
            return 1;
            else {
@@ -50,7 +56,8 @@ function factorial(n) {
                        }
 }
 
-function factorial(n) {
+function factorial6(n) {
+        var result;
         if ( ( ( ( ( ( ( ( ( (((n == 0)))) || (n == 1)))))))))
            return 1;
            else {
@@ -59,7 +66,19 @@ function factorial(n) {
                        }
 }
 
-function factorial(n) {
+function factorial7(n) {
+        var result;
+        if ( ( ( ( ( ( ( ( ( (((n == 0)))) || (n == 1)))))))))
+           return 1;
+           else {
+                result = (n * factorial(n-1) );
+                       return result;
+                       }
+}
+
+
+function factorial8(n) {
+        var result;
         if ( ( ( ( ( ( ( ( ( (((n == 0)))) || (n == 1)))))))))
            return 1;
            else {
@@ -68,4 +87,932 @@ function factorial(n) {
                        }
 }
 
+function factorial9(n) {
+        var result;
+        if ( ( ( ( ( ( ( ( ( (((n == 0)))) || (n == 1)))))))))
+           return 1;
+           else {
+                result = (n * factorial(n-1) );
+                       return result;
+                       }
+}
+
+
+
+function factorial771(n) {
+        var result;
+        if ( ( ( ( ( ( ( ( ( (( ( n == 0 ) ) ) ) || (n == 1) ) ) ) ) ) ) ) )
+           return 1;
+           else {
+                result = (n * factorial771(n-1) );
+                       return result;
+                       }
+}
+function factorial772(n) {
+        var result;
+        if ( ( ( ( ( ( ( ( ( (( ( n == 0 ) ) ) ) || (n == 1) ) ) ) ) ) ) ) )
+           return 1;
+           else {
+                result = (n * factorial771(n-1) );
+                       return result;
+                       }
+}
+function factorial773(n) {
+        var result;
+        if ( ( ( ( ( ( ( ( ( (( ( n == 0 ) ) ) ) || (n == 1) ) ) ) ) ) ) ) )
+           return 1;
+           else {
+                result = (n * factorial771(n-1) );
+                       return result;
+                       }
+}
+function factorial774(n) {
+        var result;
+        if ( ( ( ( ( ( ( ( ( (( ( n == 0 ) ) ) ) || (n == 1) ) ) ) ) ) ) ) )
+           return 1;
+           else {
+                result = (n * factorial771(n-1) );
+                       return result;
+                       }
+}
+
+function factorial775(n) {
+        var result;
+        if ( ( ( ( ( ( ( ( ( (((n == 0)))) || (n == 1)))))))))
+           return 1;
+           else {
+                result = (n * factorial771(n-1) );
+                       return result;
+                       }
+}
+
+function factorial776(n) {
+        var result;
+        if ( ( ( ( ( ( ( ( ( (((n == 0)))) || (n == 1)))))))))
+           return 1;
+           else {
+                result = (n * factorial771(n-1) );
+                       return result;
+                       }
+}
+
+function factorial777(n) {
+        var result;
+        if ( ( ( ( ( ( ( ( ( (((n == 0)))) || (n == 1)))))))))
+           return 1;
+           else {
+                result = (n * factorial771(n-1) );
+                       return result;
+                       }
+}
+
+
+function factorial778(n) {
+        var result;
+        if ( ( ( ( ( ( ( ( ( (((n == 0)))) || (n == 1)))))))))
+           return 1;
+           else {
+                result = (n * factorial771(n-1) );
+                       return result;
+                       }
+}
+
+function factorial779(n) {
+        var result;
+        if ( ( ( ( ( ( ( ( ( (((n == 0)))) || (n == 1)))))))))
+           return 1;
+           else {
+                result = (n * factorial771(n-1) );
+                       return result;
+                       }
+}
+
+
+
+
+function factorial781(n) {
+        var result;
+        if ( ( ( ( ( ( ( ( ( (( ( n == 0 ) ) ) ) || (n == 1) ) ) ) ) ) ) ) )
+           return 1;
+           else {
+                result = (n * factorial781(n-1) );
+                       return result;
+                       }
+}
+function factorial782(n) {
+        var result;
+        if ( ( ( ( ( ( ( ( ( (( ( n == 0 ) ) ) ) || (n == 1) ) ) ) ) ) ) ) )
+           return 1;
+           else {
+                result = (n * factorial781(n-1) );
+                       return result;
+                       }
+}
+function factorial783(n) {
+        var result;
+        if ( ( ( ( ( ( ( ( ( (( ( n == 0 ) ) ) ) || (n == 1) ) ) ) ) ) ) ) )
+           return 1;
+           else {
+                result = (n * factorial781(n-1) );
+                       return result;
+                       }
+}
+function factorial784(n) {
+        var result;
+        if ( ( ( ( ( ( ( ( ( (( ( n == 0 ) ) ) ) || (n == 1) ) ) ) ) ) ) ) )
+           return 1;
+           else {
+                result = (n * factorial781(n-1) );
+                       return result;
+                       }
+}
+
+function factorial785(n) {
+        var result;
+        if ( ( ( ( ( ( ( ( ( (((n == 0)))) || (n == 1)))))))))
+           return 1;
+           else {
+                result = (n * factorial781(n-1) );
+                       return result;
+                       }
+}
+
+function factorial786(n) {
+        var result;
+        if ( ( ( ( ( ( ( ( ( (((n == 0)))) || (n == 1)))))))))
+           return 1;
+           else {
+                result = (n * factorial781(n-1) );
+                       return result;
+                       }
+}
+
+function factorial787(n) {
+        var result;
+        if ( ( ( ( ( ( ( ( ( (((n == 0)))) || (n == 1)))))))))
+           return 1;
+           else {
+                result = (n * factorial781(n-1) );
+                       return result;
+                       }
+}
+
+
+function factorial788(n) {
+        var result;
+        if ( ( ( ( ( ( ( ( ( (((n == 0)))) || (n == 1)))))))))
+           return 1;
+           else {
+                result = (n * factorial781(n-1) );
+                       return result;
+                       }
+}
+
+function factorial789(n) {
+        var result;
+        if ( ( ( ( ( ( ( ( ( (((n == 0)))) || (n == 1)))))))))
+           return 1;
+           else {
+                result = (n * factorial781(n-1) );
+                       return result;
+                       }
+}
+
+
+
+
+function factorial751(n) {
+        var result;
+        if ( ( ( ( ( ( ( ( ( (( ( n == 0 ) ) ) ) || (n == 1) ) ) ) ) ) ) ) )
+           return 1;
+           else {
+                result = (n * factorial751(n-1) );
+                       return result;
+                       }
+}
+function factorial752(n) {
+        var result;
+        if ( ( ( ( ( ( ( ( ( (( ( n == 0 ) ) ) ) || (n == 1) ) ) ) ) ) ) ) )
+           return 1;
+           else {
+                result = (n * factorial751(n-1) );
+                       return result;
+                       }
+}
+function factorial753(n) {
+        var result;
+        if ( ( ( ( ( ( ( ( ( (( ( n == 0 ) ) ) ) || (n == 1) ) ) ) ) ) ) ) )
+           return 1;
+           else {
+                result = (n * factorial751(n-1) );
+                       return result;
+                       }
+}
+function factorial754(n) {
+        var result;
+        if ( ( ( ( ( ( ( ( ( (( ( n == 0 ) ) ) ) || (n == 1) ) ) ) ) ) ) ) )
+           return 1;
+           else {
+                result = (n * factorial751(n-1) );
+                       return result;
+                       }
+}
+
+function factorial755(n) {
+        var result;
+        if ( ( ( ( ( ( ( ( ( (((n == 0)))) || (n == 1)))))))))
+           return 1;
+           else {
+                result = (n * factorial751(n-1) );
+                       return result;
+                       }
+}
+
+function factorial756(n) {
+        var result;
+        if ( ( ( ( ( ( ( ( ( (((n == 0)))) || (n == 1)))))))))
+           return 1;
+           else {
+                result = (n * factorial751(n-1) );
+                       return result;
+                       }
+}
+
+function factorial757(n) {
+        var result;
+        if ( ( ( ( ( ( ( ( ( (((n == 0)))) || (n == 1)))))))))
+           return 1;
+           else {
+                result = (n * factorial751(n-1) );
+                       return result;
+                       }
+}
+
+
+function factorial758(n) {
+        var result;
+        if ( ( ( ( ( ( ( ( ( (((n == 0)))) || (n == 1)))))))))
+           return 1;
+           else {
+                result = (n * factorial751(n-1) );
+                       return result;
+                       }
+}
+
+function factorial759(n) {
+        var result;
+        if ( ( ( ( ( ( ( ( ( (((n == 0)))) || (n == 1)))))))))
+           return 1;
+           else {
+                result = (n * factorial751(n-1) );
+                       return result;
+                       }
+}
+
+
+
+function factorial741(n) {
+        var result;
+        if ( ( ( ( ( ( ( ( ( (( ( n == 0 ) ) ) ) || (n == 1) ) ) ) ) ) ) ) )
+           return 1;
+           else {
+                result = (n * factorial741(n-1) );
+                       return result;
+                       }
+}
+function factorial742(n) {
+        var result;
+        if ( ( ( ( ( ( ( ( ( (( ( n == 0 ) ) ) ) || (n == 1) ) ) ) ) ) ) ) )
+           return 1;
+           else {
+                result = (n * factorial741(n-1) );
+                       return result;
+                       }
+}
+function factorial743(n) {
+        var result;
+        if ( ( ( ( ( ( ( ( ( (( ( n == 0 ) ) ) ) || (n == 1) ) ) ) ) ) ) ) )
+           return 1;
+           else {
+                result = (n * factorial741(n-1) );
+                       return result;
+                       }
+}
+function factorial744(n) {
+        var result;
+        if ( ( ( ( ( ( ( ( ( (( ( n == 0 ) ) ) ) || (n == 1) ) ) ) ) ) ) ) )
+           return 1;
+           else {
+                result = (n * factorial741(n-1) );
+                       return result;
+                       }
+}
+
+function factorial745(n) {
+        var result;
+        if ( ( ( ( ( ( ( ( ( (((n == 0)))) || (n == 1)))))))))
+           return 1;
+           else {
+                result = (n * factorial741(n-1) );
+                       return result;
+                       }
+}
+
+function factorial746(n) {
+        var result;
+        if ( ( ( ( ( ( ( ( ( (((n == 0)))) || (n == 1)))))))))
+           return 1;
+           else {
+                result = (n * factorial741(n-1) );
+                       return result;
+                       }
+}
+
+function factorial747(n) {
+        var result;
+        if ( ( ( ( ( ( ( ( ( (((n == 0)))) || (n == 1)))))))))
+           return 1;
+           else {
+                result = (n * factorial741(n-1) );
+                       return result;
+                       }
+}
+
+
+function factorial748(n) {
+        var result;
+        if ( ( ( ( ( ( ( ( ( (((n == 0)))) || (n == 1)))))))))
+           return 1;
+           else {
+                result = (n * factorial741(n-1) );
+                       return result;
+                       }
+}
+
+function factorial749(n) {
+        var result;
+        if ( ( ( ( ( ( ( ( ( (((n == 0)))) || (n == 1)))))))))
+           return 1;
+           else {
+                result = (n * factorial741(n-1) );
+                       return result;
+                       }
+}
+
+
+
+function factorial731(n) {
+        var result;
+        if ( ( ( ( ( ( ( ( ( (( ( n == 0 ) ) ) ) || (n == 1) ) ) ) ) ) ) ) )
+           return 1;
+           else {
+                result = (n * factorial731(n-1) );
+                       return result;
+                       }
+}
+function factorial732(n) {
+        var result;
+        if ( ( ( ( ( ( ( ( ( (( ( n == 0 ) ) ) ) || (n == 1) ) ) ) ) ) ) ) )
+           return 1;
+           else {
+                result = (n * factorial731(n-1) );
+                       return result;
+                       }
+}
+function factorial733(n) {
+        var result;
+        if ( ( ( ( ( ( ( ( ( (( ( n == 0 ) ) ) ) || (n == 1) ) ) ) ) ) ) ) )
+           return 1;
+           else {
+                result = (n * factorial731(n-1) );
+                       return result;
+                       }
+}
+function factorial734(n) {
+        var result;
+        if ( ( ( ( ( ( ( ( ( (( ( n == 0 ) ) ) ) || (n == 1) ) ) ) ) ) ) ) )
+           return 1;
+           else {
+                result = (n * factorial731(n-1) );
+                       return result;
+                       }
+}
+
+function factorial735(n) {
+        var result;
+        if ( ( ( ( ( ( ( ( ( (((n == 0)))) || (n == 1)))))))))
+           return 1;
+           else {
+                result = (n * factorial731(n-1) );
+                       return result;
+                       }
+}
+
+function factorial736(n) {
+        var result;
+        if ( ( ( ( ( ( ( ( ( (((n == 0)))) || (n == 1)))))))))
+           return 1;
+           else {
+                result = (n * factorial731(n-1) );
+                       return result;
+                       }
+}
+
+function factorial737(n) {
+        var result;
+        if ( ( ( ( ( ( ( ( ( (((n == 0)))) || (n == 1)))))))))
+           return 1;
+           else {
+                result = (n * factorial731(n-1) );
+                       return result;
+                       }
+}
+
+
+function factorial738(n) {
+        var result;
+        if ( ( ( ( ( ( ( ( ( (((n == 0)))) || (n == 1)))))))))
+           return 1;
+           else {
+                result = (n * factorial731(n-1) );
+                       return result;
+                       }
+}
+
+function factorial739(n) {
+        var result;
+        if ( ( ( ( ( ( ( ( ( (((n == 0)))) || (n == 1)))))))))
+           return 1;
+           else {
+                result = (n * factorial731(n-1) );
+                       return result;
+                       }
+}
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+function factorial571(n) {
+        var result;
+        if ( ( ( ( ( ( ( ( ( (( ( n == 0 ) ) ) ) || (n == 1) ) ) ) ) ) ) ) )
+           return 1;
+           else {
+                result = (n * factorial571(n-1) );
+                       return result;
+                       }
+}
+function factorial572(n) {
+        var result;
+        if ( ( ( ( ( ( ( ( ( (( ( n == 0 ) ) ) ) || (n == 1) ) ) ) ) ) ) ) )
+           return 1;
+           else {
+                result = (n * factorial571(n-1) );
+                       return result;
+                       }
+}
+function factorial573(n) {
+        var result;
+        if ( ( ( ( ( ( ( ( ( (( ( n == 0 ) ) ) ) || (n == 1) ) ) ) ) ) ) ) )
+           return 1;
+           else {
+                result = (n * factorial571(n-1) );
+                       return result;
+                       }
+}
+function factorial574(n) {
+        var result;
+        if ( ( ( ( ( ( ( ( ( (( ( n == 0 ) ) ) ) || (n == 1) ) ) ) ) ) ) ) )
+           return 1;
+           else {
+                result = (n * factorial571(n-1) );
+                       return result;
+                       }
+}
+
+function factorial575(n) {
+        var result;
+        if ( ( ( ( ( ( ( ( ( (((n == 0)))) || (n == 1)))))))))
+           return 1;
+           else {
+                result = (n * factorial571(n-1) );
+                       return result;
+                       }
+}
+
+function factorial576(n) {
+        var result;
+        if ( ( ( ( ( ( ( ( ( (((n == 0)))) || (n == 1)))))))))
+           return 1;
+           else {
+                result = (n * factorial571(n-1) );
+                       return result;
+                       }
+}
+
+function factorial577(n) {
+        var result;
+        if ( ( ( ( ( ( ( ( ( (((n == 0)))) || (n == 1)))))))))
+           return 1;
+           else {
+                result = (n * factorial571(n-1) );
+                       return result;
+                       }
+}
+
+
+function factorial578(n) {
+        var result;
+        if ( ( ( ( ( ( ( ( ( (((n == 0)))) || (n == 1)))))))))
+           return 1;
+           else {
+                result = (n * factorial571(n-1) );
+                       return result;
+                       }
+}
+
+function factorial579(n) {
+        var result;
+        if ( ( ( ( ( ( ( ( ( (((n == 0)))) || (n == 1)))))))))
+           return 1;
+           else {
+                result = (n * factorial571(n-1) );
+                       return result;
+                       }
+}
+
+
+
+
+function factorial581(n) {
+        var result;
+        if ( ( ( ( ( ( ( ( ( (( ( n == 0 ) ) ) ) || (n == 1) ) ) ) ) ) ) ) )
+           return 1;
+           else {
+                result = (n * factorial581(n-1) );
+                       return result;
+                       }
+}
+function factorial582(n) {
+        var result;
+        if ( ( ( ( ( ( ( ( ( (( ( n == 0 ) ) ) ) || (n == 1) ) ) ) ) ) ) ) )
+           return 1;
+           else {
+                result = (n * factorial581(n-1) );
+                       return result;
+                       }
+}
+function factorial583(n) {
+        var result;
+        if ( ( ( ( ( ( ( ( ( (( ( n == 0 ) ) ) ) || (n == 1) ) ) ) ) ) ) ) )
+           return 1;
+           else {
+                result = (n * factorial581(n-1) );
+                       return result;
+                       }
+}
+function factorial584(n) {
+        var result;
+        if ( ( ( ( ( ( ( ( ( (( ( n == 0 ) ) ) ) || (n == 1) ) ) ) ) ) ) ) )
+           return 1;
+           else {
+                result = (n * factorial581(n-1) );
+                       return result;
+                       }
+}
+
+function factorial585(n) {
+        var result;
+        if ( ( ( ( ( ( ( ( ( (((n == 0)))) || (n == 1)))))))))
+           return 1;
+           else {
+                result = (n * factorial581(n-1) );
+                       return result;
+                       }
+}
+
+function factorial586(n) {
+        var result;
+        if ( ( ( ( ( ( ( ( ( (((n == 0)))) || (n == 1)))))))))
+           return 1;
+           else {
+                result = (n * factorial581(n-1) );
+                       return result;
+                       }
+}
+
+function factorial587(n) {
+        var result;
+        if ( ( ( ( ( ( ( ( ( (((n == 0)))) || (n == 1)))))))))
+           return 1;
+           else {
+                result = (n * factorial581(n-1) );
+                       return result;
+                       }
+}
+
+
+function factorial588(n) {
+        var result;
+        if ( ( ( ( ( ( ( ( ( (((n == 0)))) || (n == 1)))))))))
+           return 1;
+           else {
+                result = (n * factorial581(n-1) );
+                       return result;
+                       }
+}
+
+function factorial589(n) {
+        var result;
+        if ( ( ( ( ( ( ( ( ( (((n == 0)))) || (n == 1)))))))))
+           return 1;
+           else {
+                result = (n * factorial581(n-1) );
+                       return result;
+                       }
+}
+
+
+
+
+function factorial551(n) {
+        var result;
+        if ( ( ( ( ( ( ( ( ( (( ( n == 0 ) ) ) ) || (n == 1) ) ) ) ) ) ) ) )
+           return 1;
+           else {
+                result = (n * factorial551(n-1) );
+                       return result;
+                       }
+}
+function factorial552(n) {
+        var result;
+        if ( ( ( ( ( ( ( ( ( (( ( n == 0 ) ) ) ) || (n == 1) ) ) ) ) ) ) ) )
+           return 1;
+           else {
+                result = (n * factorial551(n-1) );
+                       return result;
+                       }
+}
+function factorial553(n) {
+        var result;
+        if ( ( ( ( ( ( ( ( ( (( ( n == 0 ) ) ) ) || (n == 1) ) ) ) ) ) ) ) )
+           return 1;
+           else {
+                result = (n * factorial551(n-1) );
+                       return result;
+                       }
+}
+function factorial554(n) {
+        var result;
+        if ( ( ( ( ( ( ( ( ( (( ( n == 0 ) ) ) ) || (n == 1) ) ) ) ) ) ) ) )
+           return 1;
+           else {
+                result = (n * factorial551(n-1) );
+                       return result;
+                       }
+}
+
+function factorial555(n) {
+        var result;
+        if ( ( ( ( ( ( ( ( ( (((n == 0)))) || (n == 1)))))))))
+           return 1;
+           else {
+                result = (n * factorial551(n-1) );
+                       return result;
+                       }
+}
+
+function factorial556(n) {
+        var result;
+        if ( ( ( ( ( ( ( ( ( (((n == 0)))) || (n == 1)))))))))
+           return 1;
+           else {
+                result = (n * factorial551(n-1) );
+                       return result;
+                       }
+}
+
+function factorial557(n) {
+        var result;
+        if ( ( ( ( ( ( ( ( ( (((n == 0)))) || (n == 1)))))))))
+           return 1;
+           else {
+                result = (n * factorial551(n-1) );
+                       return result;
+                       }
+}
+
+
+function factorial558(n) {
+        var result;
+        if ( ( ( ( ( ( ( ( ( (((n == 0)))) || (n == 1)))))))))
+           return 1;
+           else {
+                result = (n * factorial551(n-1) );
+                       return result;
+                       }
+}
+
+function factorial559(n) {
+        var result;
+        if ( ( ( ( ( ( ( ( ( (((n == 0)))) || (n == 1)))))))))
+           return 1;
+           else {
+                result = (n * factorial551(n-1) );
+                       return result;
+                       }
+}
+
+
+
+function factorial541(n) {
+        var result;
+        if ( ( ( ( ( ( ( ( ( (( ( n == 0 ) ) ) ) || (n == 1) ) ) ) ) ) ) ) )
+           return 1;
+           else {
+                result = (n * factorial541(n-1) );
+                       return result;
+                       }
+}
+function factorial542(n) {
+        var result;
+        if ( ( ( ( ( ( ( ( ( (( ( n == 0 ) ) ) ) || (n == 1) ) ) ) ) ) ) ) )
+           return 1;
+           else {
+                result = (n * factorial541(n-1) );
+                       return result;
+                       }
+}
+function factorial543(n) {
+        var result;
+        if ( ( ( ( ( ( ( ( ( (( ( n == 0 ) ) ) ) || (n == 1) ) ) ) ) ) ) ) )
+           return 1;
+           else {
+                result = (n * factorial541(n-1) );
+                       return result;
+                       }
+}
+function factorial544(n) {
+        var result;
+        if ( ( ( ( ( ( ( ( ( (( ( n == 0 ) ) ) ) || (n == 1) ) ) ) ) ) ) ) )
+           return 1;
+           else {
+                result = (n * factorial541(n-1) );
+                       return result;
+                       }
+}
+
+function factorial545(n) {
+        var result;
+        if ( ( ( ( ( ( ( ( ( (((n == 0)))) || (n == 1)))))))))
+           return 1;
+           else {
+                result = (n * factorial541(n-1) );
+                       return result;
+                       }
+}
+
+function factorial546(n) {
+        var result;
+        if ( ( ( ( ( ( ( ( ( (((n == 0)))) || (n == 1)))))))))
+           return 1;
+           else {
+                result = (n * factorial541(n-1) );
+                       return result;
+                       }
+}
+
+function factorial547(n) {
+        var result;
+        if ( ( ( ( ( ( ( ( ( (((n == 0)))) || (n == 1)))))))))
+           return 1;
+           else {
+                result = (n * factorial541(n-1) );
+                       return result;
+                       }
+}
+
+
+function factorial548(n) {
+        var result;
+        if ( ( ( ( ( ( ( ( ( (((n == 0)))) || (n == 1)))))))))
+           return 1;
+           else {
+                result = (n * factorial541(n-1) );
+                       return result;
+                       }
+}
+
+function factorial549(n) {
+        var result;
+        if ( ( ( ( ( ( ( ( ( (((n == 0)))) || (n == 1)))))))))
+           return 1;
+           else {
+                result = (n * factorial541(n-1) );
+                       return result;
+                       }
+}
+
+
+
+function factorial531(n) {
+        var result;
+        if ( ( ( ( ( ( ( ( ( (( ( n == 0 ) ) ) ) || (n == 1) ) ) ) ) ) ) ) )
+           return 1;
+           else {
+                result = (n * factorial531(n-1) );
+                       return result;
+                       }
+}
+function factorial532(n) {
+        var result;
+        if ( ( ( ( ( ( ( ( ( (( ( n == 0 ) ) ) ) || (n == 1) ) ) ) ) ) ) ) )
+           return 1;
+           else {
+                result = (n * factorial531(n-1) );
+                       return result;
+                       }
+}
+function factorial533(n) {
+        var result;
+        if ( ( ( ( ( ( ( ( ( (( ( n == 0 ) ) ) ) || (n == 1) ) ) ) ) ) ) ) )
+           return 1;
+           else {
+                result = (n * factorial531(n-1) );
+                       return result;
+                       }
+}
+function factorial534(n) {
+        var result;
+        if ( ( ( ( ( ( ( ( ( (( ( n == 0 ) ) ) ) || (n == 1) ) ) ) ) ) ) ) )
+           return 1;
+           else {
+                result = (n * factorial531(n-1) );
+                       return result;
+                       }
+}
+
+function factorial535(n) {
+        var result;
+        if ( ( ( ( ( ( ( ( ( (((n == 0)))) || (n == 1)))))))))
+           return 1;
+           else {
+                result = (n * factorial531(n-1) );
+                       return result;
+                       }
+}
+
+function factorial536(n) {
+        var result;
+        if ( ( ( ( ( ( ( ( ( (((n == 0)))) || (n == 1)))))))))
+           return 1;
+           else {
+                result = (n * factorial531(n-1) );
+                       return result;
+                       }
+}
+
+function factorial537(n) {
+        var result;
+        if ( ( ( ( ( ( ( ( ( (((n == 0)))) || (n == 1)))))))))
+           return 1;
+           else {
+                result = (n * factorial531(n-1) );
+                       return result;
+                       }
+}
+
+
+function factorial538(n) {
+        var result;
+        if ( ( ( ( ( ( ( ( ( (((n == 0)))) || (n == 1)))))))))
+           return 1;
+           else {
+                result = (n * factorial531(n-1) );
+                       return result;
+                       }
+}
+
+function factorial539(n) {
+        var result;
+        if ( ( ( ( ( ( ( ( ( (((n == 0)))) || (n == 1)))))))))
+           return 1;
+           else {
+                result = (n * factorial531(n-1) );
+                       return result;
+                       }
+}
+
+
+
+
 print(factorial(4));
index feb1c09..37f1ed6 100644 (file)
@@ -5,9 +5,8 @@
 robject_t *r_astnode_init(robject_t *obj, ruint32 type, r_object_cleanupfun cleanup, r_object_copyfun copy)
 {
        rastnode_t *node = (rastnode_t*)obj;
-
+       r_list_init(&node->lnk);
        r_object_init(obj, type, cleanup, copy);
-       node->props = r_harray_create(sizeof(rastval_t));
        return obj;
 }
 
@@ -22,13 +21,11 @@ rastnode_t *r_astnode_create()
 
 void r_astnode_addchild(rastnode_t *node, rastnode_t *child)
 {
-       if (node->val.type != R_ASTVAL_ARRAY) {
-               rcarray_t *arr = r_carray_create(sizeof(rastval_t));
-               if (((robject_t*)child)->gc)
-                       r_gc_add((rgc_t*)((robject_t*)child)->gc, (robject_t*)arr);
-               R_ASTVAL_SET_ARRAY(&node->val, arr);
+       if (node->val.type != R_ASTVAL_HEAD) {
+               r_list_init(&node->val.v.h);
+               node->val.type = R_ASTVAL_HEAD;
        }
-       r_carray_add(node->val.v.arr, &child);
+       r_list_addt(&node->val.v.h, &child->lnk);
 }
 
 
@@ -36,7 +33,8 @@ void r_astnode_cleanup(robject_t *obj)
 {
        rastnode_t *node = (rastnode_t*)obj;
 
-       r_object_destroy((robject_t*)node->props);
+//     if (node->props)
+//             r_object_destroy((robject_t*)node->props);
        r_object_cleanup(obj);
 }
 
index 7629dca..adcb50e 100644 (file)
@@ -22,16 +22,18 @@ typedef struct rastsource_s {
 #define R_ASTVAL_WORD 0
 #define R_ASTVAL_LONG 1
 #define R_ASTVAL_DOUBLE 2
-#define R_ASTVAL_POINTER 3
-#define R_ASTVAL_STRING 4
-#define R_ASTVAL_ARRAY 5
-#define R_ASTVAL_NODE 6
+#define R_ASTVAL_HEAD 3
+#define R_ASTVAL_POINTER 4
+#define R_ASTVAL_STRING 5
+#define R_ASTVAL_ARRAY 6
+#define R_ASTVAL_NODE 7
 
 typedef struct rastval_s {
        union {
                rword w;
                rlong l;
                rdouble d;
+               rhead_t h;
                rpointer ptr;
                rstring_t *str;
                rcarray_t *arr;
@@ -45,10 +47,13 @@ typedef struct rastval_s {
 
 struct rastnode_s {
        robject_t obj;
+       rlink_t lnk;
        rastnode_t *parent;
        rastval_t val;
        rastsource_t src;
-       rharray_t *props;
+       const rchar *name;
+       rhash_t *props;
+//     rharray_t *props;
 };
 
 
index e307152..c063ffc 100644 (file)
@@ -23,7 +23,7 @@
 
 #define RPA_VERSION_STRING "1.0.4-pre"
 #define RPA_LOOPHASH_BITS 8
-#define RPA_MCACHE_BITS 5
+#define RPA_MCACHE_BITS 8
 #define RPA_MAXSTACK_SIZE (64 * 1024 * sizeof(void*))
 
 
index d30c9c8..25892aa 100644 (file)
 SourceCharacter                ::= .
 
 # 7.2 White space
-WhiteSpace             ::= [#0x0009] | [#0x000B] | [#0x000C] | [#0x0020] | [#0x00A0] | [#0xFEFF]
+WhiteSpace                             ::= [#0x0009] | [#0x000B] | [#0x000C] | [#0x0020] | [#0x00A0] | [#0xFEFF]
 
 # 7.3 Line Terminators
-LineTerminator         ::= [#0x000D] [#0x000A] | [#0x000A] | [#0x000D] | [#0x2028] | [#0x2029]
-LineTerminatorSequence ::= [#0x000D] [#0x000A] |
-                           [#0x000A] | 
-                           [#0x000D] | 
-                           [#0x2028] | 
-                           [#0x2029]
-
-S                      ::= ( <WhiteSpace> | <LineTerminator> )+
+LineTerminator                 ::= [#0x000D] [#0x000A] | [#0x000A] | [#0x000D] | [#0x2028] | [#0x2029]
+LineTerminatorSequence ::= [#0x000D] [#0x000A] | [#0x000A] | [#0x000D] | [#0x2028] | [#0x2029]
+S                                              ::= ( <WhiteSpace> | <LineTerminator> )+
+SC                                             ::= <S>? ';' <S>?
+COMMA                                  ::= <S>? ',' <S>?
+EQ                                             ::= <S>? '=' <S>?
 
 # 7.4 Comments
-Comment                        ::= <:MultiLineComment:> | <:SingleLineComment:>
-MultiLineComment       ::= '/*' <:MultiLineCommentChar:>* '*/'
+Comment                                ::= <:MultiLineComment:> | <:SingleLineComment:>
+MultiLineComment               ::= '/*' <:MultiLineCommentChar:>* '*/'
 MultiLineCommentChar   ::= . - '*/'
-SingleLineComment      ::= '//' <:SingleLineCommentChar:>*
-SingleLineCommentChar  ::= <:SourceCharacter:> - <:LineTerminator:>
-
+SingleLineComment              ::= '#' <:SingleLineCommentChar:>*
+SingleLineCommentChar  ::= <SourceCharacter> - <LineTerminator>
 
 # 7.5 Tokens
-Token                  ::= <:IdentifierName:> |
-                           <:Punctuator:> |
-                           <:NumericLiteral:> |
-                           <:StringLiteral:>
+Token                                  ::= <:IdentifierName:> |
+                                               <:Punctuator:> |
+                                               <:NumericLiteral:> |
+                                               <:StringLiteral:>
 
 # 7.6 Identifier Names and Identifiers
 
-Identifier             ::= <IdentifierName> - <ReservedWord> - <ReservedWord> <IdentifierPart>
-IdentifierName         ::= <IdentifierStart> <IdentifierPart>*
+Identifier                             ::= <IdentifierName> - <ReservedWord> - <ReservedWord> <IdentifierPart>
+IdentifierName                 ::= <IdentifierStart> <IdentifierPart>*
 IdentifierStart                ::= <UnicodeLetter> | '$' | '_' | '\' <:UnicodeEscapeSequence:>
-UnicodeLetter          ::= <Lu> |
+UnicodeLetter                  ::= <Lu> |
                        <Ll> |
                        <Lt> |
                        <Lm> |
                        <Lo> |
                        <Nl>
 
-Lu                     ::= [#0x0041-#0x005A] | [#0x00C0-#0x00DE] | [#0x0100-#0x0232]   # TBD
-Ll                     ::= [#0x0061-#0x007A] | [#0x00C0-#0x00DE]                       # TBD
-IdentifierPart         ::= <IdentifierStart> | 
-                       <:UnicodeCombiningMark:> |
-                       <:UnicodeDigit:> | 
-                       <:UnicodeConnectorPunctuation:>                                 # TBD
-
+Lu                                             ::= [#0x0041-#0x005A] | [#0x00C0-#0x00DE] | [#0x0100-#0x0232]   # TBD
+Ll                                             ::= [#0x0061-#0x007A] | [#0x00C0-#0x00DE]                                               # TBD
+IdentifierPart                 ::= <IdentifierStart> | 
+                                                       <:UnicodeCombiningMark:> |
+                                                       <:UnicodeDigit:> | 
+                                                       <:UnicodeConnectorPunctuation:>                                                         # TBD
 UnicodeDigit           ::= [0-9] | [#0x0660-#0x0669]                                   # TBD
-ReservedWord           ::= <:Keyword:>
-                       <:Keyword:> | 
-                       <:FutureReservedWord:> |
-                       <:NullLiteral:> |
-                       <:BooleanLiteral:>
-
-Keyword                        ::= 'instanceof' | 'typeof'     | 'break' | 
-                           'do' | 'new' | 'var' |
-                           'case' | 'else' | 'return' | 'void' | 
-                           'catch' | 'finally' | 'continue' | 'for' | 
-                           'switch' | 'while' | 'this' | 'with' | 
-                           'debugger' | 'function' | 'throw' | 'default' |  
-                           'if' | 'try' | 'delete' | 'in'
-
-FutureReservedWord     ::= 'class' | 'enum' | 'extends' | 'import' | 'const' | 'export' |
-                           'implements' | 'let' | 'private' | 'public' |
-                            'static' | 'interface' | 'package' | 'protected'
-
-NullLiteral            ::= 'null'
-BooleanLiteral                 ::= 'true' | 'false'
-Literal                ::= <:NullLiteral:> |
-                           <:BooleanLiteral:> |
-                           <:NumericLiteral:> |
-                           <:StringLiteral:> |
-                           <:RegularExpressionLiteral:>
-
-
-
-# 7.7 Punctuators
-Punctuator             ::= '{' | '}' | '(' | ')' | '[' | ']' |
-                            '===' | '!==' | '>=' | '<=' | '==' | '!=' |
-                           '<<' | '>>>' | '>>' | '&' | '^=' | '^' |
-                           '!' | '~' | '&&' | '||' | '?' | ':' |
-                           '>>=' | '>>>=' | '&=' | '|=' |
-                           '=' | '+='| '-=' | '*=' | '%=' | '<<=' |
-                           '.' | ';' | ',' | '<' | '>' | '|' |
-                           '+' | '-' | '*' | '%' | '++' | '--'
-DivPunctuator          ::= '/' | '/='
-
 
+ReservedWord                   ::= <:Keyword:>
+                                                       <:FutureReservedWord:> |
+                                                       <:NullLiteral:> |
+                                                       <:BooleanLiteral:>
+
+Keyword                                ::= 'instanceof' | 'typeof'     | 'break' |
+                                               'do' | 'new' | 'var' |
+                                               'case' | 'else' | 'return' | 'void' | 
+                                               'catch' | 'finally' | 'continue' | 'for' | 
+                                               'switch' | 'while' | 'this' | 'with' | 
+                                               'debugger' | 'function' | 'throw' | 'default' |  
+                                               'if' | 'try' | 'delete' | 'in'
+
+FutureReservedWord                     ::= 'class' | 'enum' | 'extends' | 'import' | 'const' | 'export' |
+                                                       'implements' | 'let' | 'private' | 'public' |
+                               'static' | 'interface' | 'package' | 'protected'
+
+NullLiteral                                    ::= 'null'
+BooleanLiteral                                 ::= 'true' | 'false'
+Literal                                        ::= <:NullLiteral:> |
+                                                       <:BooleanLiteral:> |
+                                                       <:NumericLiteral:> |
+                                                       <:StringLiteral:> |
+                                                       <:RegularExpressionLiteral:>
+                                                       
+LiteralOp                                      ::= <:Literal:>
 
 # 7.8.3 Numeric Literals
-NumericLiteral         ::= <:HexIntegerLiteral:> | <:DecimalLiteral:>
-DecimalLiteral         ::= <:DecimalIntegerLiteral:> '.' <:DecimalDigits:>? <:ExponentPart:>? |
-                           '.' <:DecimalDigits:> <:ExponentPart:>? |
-                           <:DecimalIntegerLiteral:> <:ExponentPart:>?
-
-DecimalIntegerLiteral  ::= '0' |
-                           <:NonZeroDigit:> <:DecimalDigits:>?
-
-DecimalDigits          ::= <:DecimalDigit:>+
-DecimalDigit           ::= [0-9]
-NonZeroDigit           ::= [1-9]
-ExponentPart           ::= <:ExponentIndicator:> <:SignedInteger:>
-ExponentIndicator      ::= [eE]
-SignedInteger          ::= <:DecimalDigits:> |
-                           '+' <:DecimalDigits:> |
-                           '-' <:DecimalDigits:>
-HexIntegerLiteral      ::= '0' [xX] <:HexDigit:>+
-HexDigit               ::= [0-9a-fA-F]
 
+NumericLiteral                                 ::= <:HexIntegerLiteral:> | <:DecimalNonIntegerLiteral:> | <:DecimalIntegerLiteral:>
+DecimalNonIntegerLiteral               ::= ('0' | <:NonZeroDigit:> <DecimalDigits>?) '.' <DecimalDigits>? <:ExponentPart:>? |
+                                                               '.' <:DecimalDigits:> <:ExponentPart:>? 
+DecimalIntegerLiteral                  ::= '0' | <:NonZeroDigit:> <:DecimalDigits:>? <:ExponentPart:>?
+DecimalDigits                                  ::= <:DecimalDigit:>+
+DecimalDigit                                   ::= [0-9]
+NonZeroDigit                                   ::= [1-9]
+ExponentPart                                   ::= <:ExponentIndicator:> <:SignedInteger:>
+ExponentIndicator                              ::= [eE]
+SignedInteger                                  ::= '-' <:DecimalDigits:> |
+                                                               '+' <:DecimalDigits:> |
+                                                               <:DecimalDigits:>
+HexIntegerLiteral                              ::= '0' [xX] <:HexDigit:>+
+HexDigit                                               ::= [0-9a-fA-F]
 
 # 7.8.4 String Literals
+StringLiteral                                  ::= '"' <:DoubleStringCharacters:>? '"' |
+                                                               "'" <:SingleStringCharacters:>? "'"
 
-StringLiteral          ::= '"' <:DoubleStringCharacters:>? '"' |
-                           "'" <:SingleStringCharacters:>? "'"
-
-DoubleStringCharacters ::= <:DoubleStringCharacter:>+
-SingleStringCharacters ::= <:SingleStringCharacter:>+
-
-
-DoubleStringCharacter  ::= '\' <:EscapeSequence:> |
-                           <:LineContinuation:> |
-                           <:SourceCharacter:> - ('"' | '\' | <:LineTerminator:>)
-
-SingleStringCharacter  ::= '\' <:EscapeSequence:> |
-                           <:LineContinuation:> |
-                           <:SourceCharacter:> - ("'" | '\' | <:LineTerminator:>)
-
-LineContinuation       ::= '\' <:LineTerminatorSequence:>
-
-
-EscapeSequence                 ::= <:CharacterEscapeSequence:> |
-                                   '0' ^<:DecimalDigit:> |
-                           <:HexEscapeSequence:> |
-                           <:UnicodeEscapeSequence:>
-
-CharacterEscapeSequence ::= <:SingleEscapeCharacter:> |
-                           <:NonEscapeCharacter:>
-
-SingleEscapeCharacter  ::= "'" | '"' | '\' | [bfnrtv]
-NonEscapeCharacter     ::= <:SourceCharacter:> - (<:EscapeCharacter:> | <:LineTerminator:>)
-EscapeCharacter        ::= <:SingleEscapeCharacter:> |
-                           <:DecimalDigit:> |
-                           'x' |
-                           'u'
-
-HexEscapeSequence      ::= 'x' <:HexDigit:> <:HexDigit:>
-UnicodeEscapeSequence  ::= 'u' <:HexDigit:> <:HexDigit:> <:HexDigit:> <:HexDigit:>
-
+DoubleStringCharacters                 ::= <DoubleStringCharacter>+
+SingleStringCharacters                 ::= <SingleStringCharacter>+
 
-# 7.8.5 Regular Expression Literals
-RegularExpressionLiteral::= '/' <:RegularExpressionBody:> '/' <:RegularExpressionFlags:>
-RegularExpressionBody  ::= <:RegularExpressionFirstChar:> <:RegularExpressionChars:>?
-RegularExpressionChars ::= <:RegularExpressionChar:>+
-RegularExpressionFirstChar ::= <:RegularExpressionNonTerminator:> - ( '*' | '\' | '/' | '[' ) |
-                              <:RegularExpressionBackslashSequence:> |
-                              <:RegularExpressionClass:>
+DoubleStringCharacter                  ::= '\\' <:EscapeSequence:> |
+                                                               <:LineContinuation:> |
+                                                               <:SourceCharacter:> - ('"' | '\\' | <:LineTerminator:>)
 
-RegularExpressionChar  ::= <:RegularExpressionNonTerminator:> - ( '\' | '/' | '[') |
-                           <:RegularExpressionBackslashSequence:> |
-                           <:RegularExpressionClass:>
+SingleStringCharacter                  ::= '\\' <:EscapeSequence:> |
+                                                               <:LineContinuation:> |
+                                                               <:SourceCharacter:> - ("'" | '\\' | <:LineTerminator:>)
 
+BracketExpressionOp                            ::= '(' <S>? <:Expression:> <S>? ')'
+ThisOp                                                 ::= 'this'
 
-RegularExpressionBackslashSequence ::= '\' <:RegularExpressionNonTerminator:>
-RegularExpressionNonTerminator    ::= <:SourceCharacter:> - <:LineTerminator:>
-RegularExpressionClass                    ::= '[' <:RegularExpressionClassChars:> ']'
-RegularExpressionClassChars       ::= <:RegularExpressionClassChar:>+
-RegularExpressionClassChar        ::= <:RegularExpressionNonTerminator:> - ( ']' | '\' ) |
-                                      <:RegularExpressionBackslashSequence:>
+PrimaryExpression                              ::= <:ThisOp:> | 
+                                                               '(' <S>? <:Expression:> <S>? ')' |
+                                                               <:LiteralOp:> |
+                                                               <:IdentifierOp:>
 
-RegularExpressionFlags            ::= <:IdentifierPart:> <:RegularExpressionFlags:> | <:IdentifierPart:>
+# The next line is mine
+IdentifierOp                                   ::= <:Identifier:> 
+SwiId                                                  ::= <:Identifier:> 
+SwiIdExist                                             ::= <SwiId> 
 
-# 11.1 Primary Expressions
 
-PrimaryExpression      ::= <:Identifier:> |
-                           <:Literal:> |
-                           <:ArrayLiteral:> |
-                           <:ObjectLiteral:> |
-                           '(' <S>? <:Expression:> <S>? ')' |
-                           'this'
-
-ArrayLiteral           ::= '[' <S>? <:Elision:>? <S>? ']' |
-                           '[' <S>? <:ElementList:> <S>? ']' |
-                           '[' <S>? <:ElementList:> <S>? ',' <S>? <:Elision:> <S>? ']'
-
-
-ElementList            ::= <:Elision:>? <S>? <:AssignmentExpression:> (<S>? ',' <S>? <:Elision:>? <S>? <:AssignmentExpression:> )*
-Elision                        ::= ',' <S>? <:Elision:> | <S>? ','
-ObjectLiteral          ::= '{' <S>? '}' |
-                           '{' <S>? <:PropertyNameAndValueList:>  <S>? '}' |
-                           '{' <S>? <:PropertyNameAndValueList:>  <S>? ','  <S>? '}'
-
-PropertyNameAndValueList::= <:PropertyAssignment:> ( <S>? ','  <S>? <:PropertyAssignment:>)*
-
-PropertyAssignment     ::= <:PropertyName:>  <S>? ':'  <S>? <:AssignmentExpression:> |
-                           'get'  <S>? <:PropertyName:>  <S>? '(' <S>? ')'  <S>? '{' <S>? <:FunctionBody:>?  <S>? '}' |
-                           'set'  <S>? <:PropertyName:>  <S>? '(' <S>? <:PropertySetParameterList:>  <S>? ')' <S>? '{' <S>? <:FunctionBody:>?  <S>? '}'
-
-
-PropertyName           ::= <:IdentifierName:> |
-                                               <:StringLiteral:> |
-                                               <:NumericLiteral:>
-
-PropertySetParameterList::= <:Identifier:>
+ArrayLiteral                                   ::= '[' <S>? <:Elision:>? <S>? ']' |
+                                                               '[' <S>? <:ElementList:> <S>? ']' |
+                                                               '[' <S>? <:ElementList:> <S>? ',' <S>? <:Elision:> <S>? ']'
+ElementList                                            ::= <:Elision:>? <S>? <:AssignmentExpression:> (<S>? ',' <S>? <:Elision:>? <S>? <:AssignmentExpression:> )*
+Elision                                                        ::= ',' <S>? <:Elision:> | <S>? ','
 
 
 # 11.2 Left-Hand-Side Expressions
-MemberExpression                               ::= <:MemberExpression:> <S>? '[' <S>? <:Expression:> <S>? ']' |
-                                                                       <:MemberExpression:> '.' <:IdentifierName:> |
-                                                                       'new' <S> <:MemberExpression:> <S>? <:Arguments:> |
+NewKeyword                                             ::= 'new' - 'new' <IdentifierPart>
+LSB                                                            ::= <S>? '[' <S>?
+RSB                                                            ::= <S>? ']' <S>?
+dot                                                            ::= '.'
+MemberIdentifierNameOp                 ::= <:Identifier:>
+MemberIdentifierNameLookupOp   ::= <:Identifier:>
+MemberExpressionBaseOp                 ::= <:MemberExpression:>
+MemberExpressionIndexOp                        ::= <:MemberExpressionBaseOp:>  <:LSB:> <:Expression:> <:RSB:>
+MemberExpressionNameOp                 ::= <:MemberExpressionBaseOp:> <:dot:> <:MemberIdentifierNameOp:>
+MemberExpressionNewOp                  ::= <:NewKeyword:> <S>? <:CallExpression:>
+
+MemberExpression                               ::= <:MemberExpressionIndexOp:>  |
+                                                                       <:MemberExpressionNameOp:> |
                                                                        <:FunctionExpression:> |
                                                                        <:PrimaryExpression:>
 
-NewExpression                                  ::= <:NewKeyword:> <S>? <:NewExpression:> |
+NewExpressionCallName                  ::= <:MemberExpression:>
+NewExpressionCallOp                            ::= <:NewKeyword:> <S>? <NewExpressionCallName> <S>? <:ArgumentsOp:>? & 
+                                                                       <NewKeyword> <S>? <:NewExpressionCallName:> <S>? <ArgumentsOp>?
+NewArrayExpressionOp                   ::= <S>? 'new' <S> ( 'Array' | 'Object') <S>? <ArgumentsOp>?
+
+NewExpression                                  ::= <:NewArrayExpressionOp:> |
+                                                                       <:NewExpressionCallOp:> |
                                                                        <:MemberExpression:>
 
+FunctionCallName                               ::= <:CallExpression:> | <:MemberExpression:>
+CallExpressionOp                               ::= <FunctionCallName> <S>? <:ArgumentsOp:> & 
+                                                                       <:FunctionCallName:> <S>? <ArgumentsOp>
+CallExpressionBaseOp                   ::= <:CallExpression:>
+CallExpressionIndexOp                  ::= <:CallExpressionBaseOp:> <S>? '[' <S>? <:Expression:> <S>? ']'
+CallExpressionNameOp                   ::= <:CallExpressionBaseOp:> '.' <:MemberIdentifierNameOp:>
 
-CallExpression                                 ::= <:CallExpression:> <:Arguments:> |
-                                                                       <:CallExpression:> <S>? '[' <S>? Expression <S>? ']' |
-                                                                       <:CallExpression:> '.' <:IdentifierName:> |
-                                                                       <:MemberExpression:> <S>? <:Arguments:>
+CallExpression                                 ::= <:CallExpressionIndexOp:> |
+                                                                       <:CallExpressionNameOp:> |
+                                                                       <:CallExpressionOp:>
 
-Arguments                                              ::= '(' <S>? ')' |
+ArgumentsOp                                            ::= '(' <S>? ')' |
                                                                '(' <S>? <:ArgumentList:> <S>? ')'
 ArgumentList                                   ::= <:ArgumentList:> <S>? ',' <S>? <:AssignmentExpression:> |
                                                                        <:AssignmentExpression:>
-LeftHandSideExpression                 ::= <:CallExpression:> | <:NewExpression:>
-       
+
+ArgumentList                                   ::= <:ArgumentList:> <S>? ',' <S>? <:FunctionCallParameter:> |
+                                                                       <:FunctionCallParameter:>
+FunctionCallParameter                  ::= <:AssignmentExpression:>
+                                                                       
+ValLeftHandSideExpression              ::= <:CallExpression:> | <:NewExpression:>
+AddressLeftHandSideExpression  ::= <:ValLeftHandSideExpression:>
+LeftHandSideExpression                 ::= <:AddressLeftHandSideExpression:>
+
+
 # 11.3 Postfix Expressions
-PostfixOperator        ::= '++' | '--'
-PostfixExpression      ::= <:LeftHandSideExpression:> <:PostfixOperator:>?
+# RULE: LeftHandSideExpression always ends up in R0 (Let see if this would work)
+PostfixOperator                                ::= '++' | '--'
+PostfixExpressionOp                    ::= <:LeftHandSideExpression:> <:PostfixOperator:>
+PostfixExpressionValOp                 ::= <:ValLeftHandSideExpression:>
+PostfixExpression                              ::= <:PostfixExpressionOp:> |
+                                                                       <:PostfixExpressionValOp:> 
+
+PrefixOperator                                         ::= <:PostfixOperator:>
+PrefixExpressionOp                             ::= <:PrefixOperator:> <:LeftHandSideExpression:>
+PrefixExpression                               ::= <:PrefixExpressionOp:>
 
 # 11.4 Unary Operators
-UnaryOperator              ::= 'delete' | 'void' | 'typeof' | '++' | '--' | '+' | '-' | '~' | '!'
-UnaryExpression                    ::= <S>? <:UnaryOperator:> <S>? <:UnaryExpression:> | <:PostfixExpression:>
+UnaryOperatorOpcode                            ::= '~' | '!' | ('+' - '++') | ('-' - '--') | 'delete' | 'void' | 'typeof'
+UnaryOperator                          ::= <:UnaryOperatorOpcode:>
+UnaryExpressionOp                      ::=     <S>? <:UnaryOperator:> <S>? <:UnaryExpression:>
+UnaryExpression                                ::=     <:UnaryExpressionOp:> | <:PrefixExpression:> | <:PostfixExpression:>
 
 
 # 11.5 Multiplicative Operators
-MultiplicativeOperator         ::= '*' | '/' | '%'
+MultiplicativeOperator                         ::= '*' | '/' | '%'
 MultiplicativeExpressionOp             ::= <:MultiplicativeExpression:> <S>? <:MultiplicativeOperator:> <S>? <:UnaryExpression:>
-MultiplicativeExpression               ::= <:MultiplicativeExpressionOp:> |
-                                                               <:UnaryExpression:>
-
+MultiplicativeExpression               ::= <:MultiplicativeExpressionOp:> | 
+                                                                       <:UnaryExpression:>
 
 # 11.6 Additive Operators
 AdditiveOperator                               ::= '+' | '-'
 AdditiveExpressionOp                   ::= <:AdditiveExpression:> <S>? <:AdditiveOperator:> <S>? <:MultiplicativeExpression:>
-AdditiveExpression                             ::= <:AdditiveExpressionOp:> |
-                                                               <:MultiplicativeExpression:>
+AdditiveExpression                             ::= <:AdditiveExpressionOp:> | 
+                                                                       <:MultiplicativeExpression:>
+
 
 11.7 Bitwise Shift Operators
 ShiftOperator                                  ::= '>>>' | '<<' | '>>'
-ShiftExpression                                        ::= <:ShiftExpression:> <S>? <:ShiftOperator:> <S>? <:AdditiveExpression:> |
-                                                               <:AdditiveExpression:>
+ShiftExpressionOp                              ::= <:ShiftExpression:> <S>? <:ShiftOperator:> <S>? <:AdditiveExpression:>
+ShiftExpression                                        ::= <:ShiftExpressionOp:> |
+                                                               <:AdditiveExpression:> 
 
-# 11.8 Relational Operators
-RelationalOperatorNoIn         ::= '<=' | '>=' | '<' | '>' | 'instanceof'
-RelationalOperator     ::= <:RelationalOperatorNoIn:> | 'in'
-RelationalExpression   ::= <:RelationalExpression:> <S>? <:RelationalOperator:> <S>? <:ShiftExpression:> |
-                           <:ShiftExpression:>
-RelationalExpressionNoIn::= <:RelationalExpressionNoIn:> <S>? <:RelationalOperatorNoIn:> <S>? <:ShiftExpression:> |
-                           <:ShiftExpression:>
 
+# 11.8 Relational Operators
+RelationalOperator                             ::= '<=' | '>=' | '<' | '>' | 'instanceof'
+RelationalExpressionOp                 ::= <:RelationalExpression:> <S>? <:RelationalOperator:> <S>? <:ShiftExpression:>
+RelationalExpression                   ::= <:RelationalExpressionOp:> |
+                                                               <:ShiftExpression:>
 
 # 11.9 Equality Operators
-EqualityOperator       ::= '===' | '==' | '!==' | '!='
-EqualityExpression     ::= <:EqualityExpression:> <S>? <:EqualityOperator:> <S>? <:RelationalExpression:> |
-                           <:RelationalExpression:>
-EqualityExpressionNoIn         ::= <:EqualityExpression:> <S>? <:EqualityOperator:> <S>? <:RelationalExpressionNoIn:> |
-                           <:RelationalExpressionNoIn:>
-
-# 11.10 Binary Bitwise Operators
-BitwiseANDExpression   ::= <:BitwiseANDExpression:> <S>? <:BitwiseANDOperator:> <S>? <:EqualityExpression:> |
-                           <:EqualityExpression:>
-BitwiseANDExpressionNoIn::= <:BitwiseANDExpressionNoIn:> <S>? <:BitwiseANDOperator:> <S>? <:EqualityExpressionNoIn:> |
-                           <:EqualityExpressionNoIn:>
-BitwiseANDOperator     ::= '&'
+EqualityOperator                               ::= '===' | '==' | '!==' | '!='
+EqualityExpressionOp                   ::= <:EqualityExpression:> <S>? <:EqualityOperator:> <S>? <:RelationalExpression:> 
+EqualityExpression                             ::= <:EqualityExpressionOp:> |
+                                                               <:RelationalExpression:>
+
+BitwiseANDOperator                             ::= '&' - '&&'
+BitwiseANDOp                                   ::= <:BitwiseANDExpression:> <S>? <:BitwiseANDOperator:> <S>? <:EqualityExpression:>
+BitwiseANDExpression                   ::= <:BitwiseANDOp:> |
+                                                               <:EqualityExpression:>
+
+BitwiseXOROperator                             ::= '^'
+BitwiseXOROp                                   ::= <:BitwiseXORExpression:> <S>? <:BitwiseXOROperator:> <S>? <:BitwiseANDExpression:>
+BitwiseXORExpression                   ::= <:BitwiseXOROp:> |
+                                                               <:BitwiseANDExpression:>
+
+BitwiseOROperator                              ::= '|' - '||'
+BitwiseOROp                                            ::= <:BitwiseORExpression:> <S>? <:BitwiseOROperator:> <S>? <:BitwiseXORExpression:>
+BitwiseORExpression                    ::= <:BitwiseOROp:> |
+                                                               <:BitwiseXORExpression:>
 
+# 11.11 Binary Logical Operators
+LogicalANDOperator                             ::= '&&'
+LogicalANDOp                                   ::= <:LogicalANDExpression:> <S>? <:LogicalANDOperator:>  <S>? <:BitwiseORExpression:>
+LogicalANDExpression                   ::= <:LogicalANDOp:> |
+                                                               <:BitwiseORExpression:>
 
-BitwiseXORExpression   ::= <:BitwiseXORExpression:> <S>? <:BitwiseXOROperator:> <S>? <:BitwiseANDExpression:> |
-                           <:BitwiseANDExpression:>
-BitwiseXORExpressionNoIn::= <:BitwiseXORExpressionNoIn:> <S>? <:BitwiseXOROperator:> <S>? <:BitwiseANDExpressionNoIn:> |
-                           <:BitwiseANDExpressionNoIn:>
-BitwiseXOROperator     ::= '^'
-
-BitwiseORExpression    ::= <:BitwiseORExpression:> <S>? <:BitwiseOROperator:> <S>? <:BitwiseXORExpression:> |
-                           <:BitwiseXORExpression:>
-BitwiseORExpressionNoIn::= <:BitwiseORExpressionNoIn:> <S>? <:BitwiseOROperator:> <S>? <:BitwiseXORExpressionNoIn:> |
-                          <:BitwiseXORExpressionNoIn:>
-BitwiseOROperator      ::= '|'
-
+LogicalOROperator                              ::= '||'
+LogicalOROp                                            ::= <:LogicalORExpression:> <S>? <:LogicalOROperator:> <S>? <:LogicalANDExpression:>
+LogicalORExpression                    ::= <:LogicalOROp:> |
+                                                               <:LogicalANDExpression:>
 
 
-# 11.11 Binary Logical Operators
-LogicalANDExpression   ::= <:LogicalANDExpression:> <S>? <:LogicalANDOperator:>  <S>? <:BitwiseORExpression:> |
-                           <:BitwiseORExpression:>
-LogicalANDExpressionNoIn::= <:LogicalANDExpressionNoIn:> <S>? <:LogicalANDOperator:>  <S>? <:BitwiseORExpressionNoIn:> |
-                           <:BitwiseORExpressionNoIn:>
-LogicalANDOperator     ::= '&&'
-
-LogicalORExpression    ::= <:LogicalORExpression:> <S>? <:LogicalOROperator:> <S>? <:LogicalANDExpression:> |
-                           <:LogicalANDExpression:>
-LogicalORExpressionNoIn ::= <:LogicalORExpressionNoIn:> <S>? <:LogicalOROperator:> <S>? <:LogicalANDExpressionNoIn:> |
-                           <:LogicalANDExpressionNoIn:> 
-LogicalOROperator      ::= '||'
-
 # 11.12 Conditional Operator ( ? : )
-ConditionalExpression  ::= <:LogicalORExpression:> ( <S>? '?' <S>? <:AssignmentExpression:> <S>? ':' <S>? <:AssignmentExpression:> )?
-ConditionalExpressionNoIn::=<:LogicalORExpressionNoIn:> ( <S>? '?' <S>? <:AssignmentExpression:> <S>? ':' <S>? <:AssignmentExpressionNoIn:> )?
+AssignmentExpressionIfTrueOp           ::= <:AssignmentExpression:>
+AssignmentExpressionIfFalseOp          ::= <:AssignmentExpression:>
+QuestionMarkOp                                         ::= '?'
+ConditionalExpression                          ::= <:LogicalORExpression:> (<S>? <:QuestionMarkOp:> <S>? <:AssignmentExpressionIfTrueOp:> <S>? ':' <S>? <:AssignmentExpressionIfFalseOp:>)?
 
 # 11.13 Assignment Operators
-AssignmentExpression   ::= <:LeftHandSideExpression:> <S>? <:AssignmentOperator:> <S>? <:AssignmentExpression:> | <:ConditionalExpression:>
-AssignmentExpressionNoIn::= <:LeftHandSideExpression:> <S>? <:AssignmentOperator:> <S>? <:AssignmentExpressionNoIn:> | <:ConditionalExpressionNoIn:>
-AssignmentOperator     ::= '=' | '*=' | '/=' | '%=' | '+=' | '-=' | '<<=' | '>>=' | '>>>=' | '&=' | '^=' | '|='
+LeftHandSideExpressionPush             ::= <:LeftHandSideExpression:>
+IdentifierAddressPush                  ::= <:Identifier:>
+AssignmentExpressionOp                         ::= <:LeftHandSideExpressionPush:> <S>? <:AssignmentOperator:> <S>? <:AssignmentExpression:>
+AssignmentExpression                   ::= <:AssignmentExpressionOp:> | 
+                                                                       <:ConditionalExpression:>
+
+AssignmentExpressionNoIn               ::= <:LeftHandSideExpression:> <S>? <:AssignmentOperator:> <S>? <:AssignmentExpressionNoIn:> | <:ConditionalExpressionNoIn:>
+AssignmentOperator                             ::= '=' | '*=' | '/=' | '%=' | '+=' | '-=' | '<<=' | '>>=' | '>>>=' | '&=' | '^=' | '|='
 
 
 # 11.14 Comma Operator         ( , )
@@ -321,125 +277,141 @@ ExpressionNoIn          ::= <:AssignmentExpressionNoIn:> ( <S>? ',' <S>? <:AssignmentExp
 
 
 # 12 Statements
-
-Statement              ::= <:Block:> |
-                           <:Comment:> |
-                           <:VariableStatement:> |
-                           <:EmptyStatement:> |
-                           <:ExpressionStatement:> |
-                           <:IfStatement:> |
-                           <:IterationStatement:> |
-                           <:ContinueStatement:> |
-                           <:BreakStatement:> |
-                           <:ReturnStatement:> |
-                           <:ImportStatement:> |
-                           <:WithStatement:> |
-                           <:LabelledStatement:> |
-                           <:SwitchStatement:> |
-                           <:ThrowStatement:> |
-                           <:TryStatement:> |
-                           <:DebuggerStatement:>
+Statement                                              ::= <:FunctionDefinitionStatement:> |
+                                                                       <:BreakStatement:> |
+                                                                       <:ContinueStatement:> |
+                                                                       <:Block:> |
+                                                               <:Comment:> |
+                                                               <:VariableStatement:> |
+                                                               <:EmptyStatement:> |
+                                                               <:ExpressionStatement:> |
+                                                               <:IfStatement:> |
+                                                               <:IterationStatement:> |
+                                                               <:ContinueStatement:> |
+                                                               <:BreakStatement:> |
+                                                               <:ReturnStatement:> |
+                                                               <:ImportStatement:> |
+                                                               <:WithStatement:> |
+                                                               <:LabelledStatement:> |
+                                                               <:SwitchStatementOp:> |
+                                                               <:ThrowStatement:> |
+                                                               <:TryStatement:> |
+                                                               <:DebuggerStatement:>
 
 # 12.1 Block
-Block                  ::= '{' <S>? <:StatementList:>? <S>? '}'
-StatementList          ::= (<S>? <:Statement:>)+
+BlockBegin                                                     ::= <S>? '{' <S>?
+BlockEnd                                                       ::= <S>? '}' <S>?
+Block                                                          ::= <:BlockBegin:> <:StatementList:>? <:BlockEnd:>
+StatementList                                          ::= (<S>? <:Statement:>)+
 
 # 12.2 Variable Statement
-VariableStatement      ::= 'var' <S>? <:VariableDeclarationList:> (<S>? ';')
-VariableDeclarationList ::= <:VariableDeclaration:> (<S>? ',' <S>? <:VariableDeclaration:> )*
-VariableDeclarationListNoIn::= <:VariableDeclarationNoIn:> (<S>? ',' <S>? <:VariableDeclarationNoIn:> )*
-VariableDeclaration    ::= <:Identifier:> <:Initialiser:>?
-VariableDeclarationNoIn ::= <:Identifier:> <:InitialiserNoIn:>?
-Initialiser            ::= <S>? '=' <S>? <:AssignmentExpression:>
-InitialiserNoIn        ::= <S>? '=' <S>? <:AssignmentExpressionNoIn:>
+VariableStatement                                      ::= 'var' <S>? <:VariableDeclarationList:> <:SC:>
+VariableDeclarationList                        ::= <:VariableDeclaration:> (<:COMMA:> <:VariableDeclaration:> )*
+VariableAllocate                                       ::= <:Identifier:>
+VariableAllocateAndInit                                ::= <:Identifier:>
+VariableDeclaration                                    ::= <:VariableAllocateAndInit:> <:Initialiser:> | <:VariableAllocate:>
+Initialiser                                                    ::= <:EQ:> <:AssignmentExpression:>
 
-# 12.3 Empty Statement
-EmptyStatement         ::= <S>? ';'
 
+# 12.3 Empty Statement
+EmptyStatement                                         ::= <:SC:>
 
 # 12.4 Expression Statement
-ExpressionStatement    ::= (<:Expression:> - ('function' | '{')) (<S>? ';')
+ExpressionStatement                            ::= (<:Expression:> - ('function' | '{')) <:SC:>
 
-12.5 The if Statement
-IfStatement            ::= 'if' <S>? '(' <S>? <:Expression:> <S>? ')'<S>? <:Statement:> <S>? 'else' <S>? <:Statement:> |
-                           'if' <S>? '(' <S>? <:Expression:> <S>? ')'<S>? <:Statement:> 
 
+# 12.5 The if Statement
 
+ElseOp                                                         ::= 'else'
+IfConditionOp                                          ::= 'if' <S>? '(' <S>? <:Expression:> <S>? ')'
+IfOp                                                           ::= <:IfConditionOp:> <S>? <:Statement:>
+IfElseOp                                                       ::= <:IfConditionOp:> <S>? <:Statement:> <S>? <:ElseOp:> <S>? <:Statement:>
 
+IfStatement                                                    ::= <:IfElseOp:> |
+                                                                               <:IfOp:>
 
 # 12.6 Iteration Statements
-IterationStatement     ::= 'do' <S>? <:Statement:> <S>? 'while' <S>? '(' <S>? <:Expression:> <S>? ')' (<S>? ';') |
-           'while' <S>? '(' <S>? <:Expression:> <S>? ')' <S>? <:Statement:> |
-           'for' <S>? '(' <S>?'var' <S>? <:VariableDeclarationListNoIn:> <S>? ';' <S>? <:Expression:>? <S>? ';'<S>? <:Expression:>? <S>? ')' <S>? <:Statement:> |
-           'for' <S>? '(' <S>?'var' <S>? <:VariableDeclarationNoIn:> <S>? 'in' <S>? <:Expression:> <S>? ')' <S>?  <:Statement:> |
-           'for' <S>? '(' <S>? <:LeftHandSideExpression:> <S>? 'in' <S>? <:Expression:> <S>? ')' <S>?  <:Statement:> |
-           'for' <S>? '(' <S>? <:ExpressionNoIn:>? <S>? ';' <S>? <:Expression:>? <S>? ';' <S>? <:Expression:>? <S>? ')' <S>? <:Statement:>
-
-
-# 12.7 The continue Statement
-ContinueStatement      ::= ('continue' - 'continue' <:IdentifierPart:>) <WhiteSpace>* <:Identifier:>? (<S>? ';')
+# 12.6a Iteration do ... while() 
+WhileKeyword                                           ::= 'while'
+WhileExpression                                                ::= <:WhileKeyword:> <S>? '(' <S>? <:Expression:> <S>? ')'
+DoKeyword                                                      ::= 'do'
+IterationDo                                                    ::= <:DoKeyword:> <S>? <:Statement:> <S>? <:WhileExpression:> (<S>? ';')
+
+# 12.6b Iteration while()
+WhileConditionOp                                       ::= 'while' <S>? '(' <S>? <:Expression:> <S>? ')'
+IterationWhileOp                                       ::= <:WhileConditionOp:> <S>? <:Statement:>
+
+# 12.6c Iteration for ( ; ; )
+ForKeyword                                                     ::= 'for'
+ExpressionNoIn                                         ::= <:Expression:>
+ForExpressionInitOp                                    ::= ('var' <S>? <:VariableDeclarationList:>) | <:ExpressionNoIn:>
+ForExpressionCompareOp                         ::= <:Expression:>
+ForExpressionIncrementOp                       ::= <:Expression:>
+
+# The following & expression is done in order to swap the places of the code generated for the comparison and increment.
+# This is done by selectively turning on/off callbacks in both statement so that the final result appears as if the
+# <:ForExpressionCompareOp:> <:ForExpressionIncrementOp:> appear in the opposite order.
+ForIterationStatementOp                                ::= <:ForKeyword:> <S>? '(' <S>? <:ForExpressionInitOp:>? <S>? ';' <S>? <ForExpressionCompareOp>? <S>? ';' <S>? <:ForExpressionIncrementOp:>? <S>? ')' &
+                                                                               <ForKeyword> <S>? '(' <S>? <ForExpressionInitOp>? <S>? ';' <S>? <:ForExpressionCompareOp:>? <S>? ';' <S>? <ForExpressionIncrementOp>? <S>? ')'
+IterationForOp                                         ::= <:ForIterationStatementOp:> <S>? <:Statement:>
+
+
+IterationStatement                                     ::= <:IterationWhileOp:> |
+                                                                               <:IterationForOp:> |
+                                                                       <:IterationDo:>
 
+# 12.9 The return Statement
+ReturnOp                                                       ::= ('return' - 'return' <:IdentifierPart:>) <WhiteSpace>* <:AssignmentExpression:>? (<S>? ';')
+ReturnStatement                                                ::= <:ReturnOp:>
 
-# 12.8 The break Statement
-BreakStatement         ::= ('break' - 'break' <:IdentifierPart:>)<WhiteSpace>* <:Identifier:>? (<S>? ';')
+# The Break Statement
+BreakOp                                                                ::= 'break' - 'break' <:IdentifierPart:>
+BreakStatement                                         ::= <S>? <:BreakOp:> <:SC:>
 
+# The Continue Statement
+ContinueOp                                                     ::= 'continue' - 'continue' <:IdentifierPart:>
+ContinueStatement                                      ::= <S>? <:ContinueOp:> <:SC:>
 
-# 12.9 The return Statement
-ReturnStatement                ::= ('return' - 'return' <:IdentifierPart:>) <WhiteSpace>* <:Expression:>? (<S>? ';')
 
 
 # 12.10 The with Statement
-WithStatement          ::= 'with' <S>? '(' <S>? <:Expression:> <S>? ')' <S>? <:Statement:>
+WithStatement                                          ::= 'with' <S>? '(' <S>? <:Expression:> <S>? ')' <S>? <:Statement:>
 
 
 # 12.11 The switch Statement
-SwitchStatement                ::= 'switch' <S>? '(' <S>? <:Expression:> <S>? ')' <S>? <:CaseBlock:>
-
-CaseBlock              ::= '{' <S>? <:CaseClauses:>? <S>? <:DefaultClause:> <S>? <:CaseClauses:>? <S>? '}' |
-                           '{' <S>? <:CaseClauses:>? <S>? '}'
-
-
-
-CaseClauses            ::= (<S>? <:CaseClause:>)+
-
-CaseClause             ::= 'case' <S>? <:Expression:> <S>? ':' <S>? <:StatementList:>?
-DefaultClause          ::= 'default' <S>? ':' <S>? <:StatementList:>
+SwitchExpressionOp                                     ::= ('switch' - 'switch' <IdentifierPart>) <S>? '(' <S>? <:Expression:> <S>? ')'
+SwitchStatementOp                                      ::= <:SwitchExpressionOp:> <S>? <:CaseBlock:>
 
-# 12.12 Labelled Statements
-LabelledStatement      ::= <:Identifier:> <S>? ':' <S>? <:Statement:>
+CaseBlock                                                      ::= '{' <S>? <:CaseClauses:>? <S>? <:DefaultClauseOp:>? <S>? <:CaseClauses:>? <S>? '}' |
+                                                                       '{' <S>? <:CaseClauses:>? <S>? '}'
 
-# 12.13 The throw Statement
-ThrowStatement         ::= ('throw' - 'throw' <:IdentifierPart:>) <WhiteSpace>* <:Expression:> (<S>? ';')
 
-12.14 The try Statement
-TryStatement           ::= 'try' <S>? <:Block:> <S>? <:Catch:> <S>? <:Finally:> |
-                           'try' <S>? <:Block:> <S>? <:Catch:> |
-                           'try' <S>? <:Block:> <S>? <:Finally:>
 
-
-Catch                  ::= 'catch' <S>? '(' <:Identifier:> ')' <S>? <:Block:>
-Finally                ::= 'finally' <S>? <:Block:>
-
-# 12.15 The debugger statement
-DebuggerStatement      ::= 'debugger' <S>? ';'
+CaseClauses                                            ::= (<S>? <:CaseClauseOp:>)+
+CaseExpressionOp                                       ::= ('case' - 'case' <IdentifierPart>) <S>? <:Expression:> <S>? ':'
+CaseClauseOp                                           ::= <:CaseExpressionOp:> <S>? <:StatementList:>?
+DefaultKeywordOp                                       ::= 'default' - 'default' <IdentifierPart>
+DefaultClauseOp                                                ::= <:DefaultKeywordOp:> <S>? ':' <S>? <:StatementList:>?
 
 
 # 13 Function Definition
-FunctionDeclaration    ::= ('function'-'function'<:IdentifierPart:>)<S>?<:Identifier:><S>?'('<S>?<:FormalParameterList:>?<S>?')'<S>?'{'<S>?<:FunctionBody:>?<S>?'}'
-FunctionExpression     ::= ('function'-'function'<:IdentifierPart:>)<S>?<:Identifier:>?<S>?'('<S>?<:FormalParameterList:>?<S>?')'<S>?'{'<S>?<:FunctionBody:>?<S>?'}'
-FormalParameterList    ::= <:Identifier:> ( <S>? ',' <S>? <:Identifier:> )*
-FunctionBody           ::= <:SourceElements:>
-
-
-# Other
-ImportStatement        ::= 'import' <:Name:> ( '.' '*' )? (<S>? ';')
-Name                   ::= <:IdentifierName:> ( '.' <:IdentifierName:> )*
+FunctionName                                           ::= <:Identifier:>
+FunctionNameLookupAlloc                                ::= <:Identifier:>
+FunctionDefinition                                     ::= ('function' - 'function' <IdentifierPart>)<S>?<:FunctionName:><S>?'('<S>?<:FormalParameterList:>?<S>?')'
+FunctionDeclaration                                    ::= <:FunctionDefinition:><S>?'{'<S>?<:FunctionBody:>?<S>?'}'
+FunctionExpression                                     ::= ('function' - 'function'<IdentifierPart>)<S>?<:FunctionName:>?<S>?'('<S>?<:FormalParameterList:>?<S>?')'<S>?'{'<S>?<:FunctionBody:>?<S>?'}'
+FunctionParameter                                      ::= <:Identifier:>
+FormalParameterList                            ::= <:FunctionParameter:> ( <S>? ',' <S>? <:FunctionParameter:> )*
+FunctionDefinitionStatement                    ::= ('function' - 'function' <IdentifierPart>)<S>?<:FunctionNameLookupAlloc:><S>?'('<S>?<FormalParameterList>?<S>?')' <:SC:>
+FunctionBody                                           ::= <:SourceElements:>
 
 
 # 14 Program
-SourceElements                 ::= (<S>? <:SourceElement:>)+
-SourceElement          ::= <:FunctionDeclaration:> |
-                           <:Statement:>
-Program                        ::= <:SourceElements:>?
-
+SourceElements                                         ::= (<S>? <:SourceElement:>)+
+SourceElement                                          ::= <:FunctionDeclaration:> |
+                                                                       <:Statement:>
+Program                                                        ::= <:SourceElements:>
+# The root rule, it is anonymous
 <:Program:>
+       
+
index 518493d..0959a1c 100644 (file)
@@ -105,27 +105,29 @@ void r_astcompiler_destroy(rastcompiler_t *aco)
 void r_astnode_dump(rastnode_t *node, ruint level)
 {
        ruint i;
-       rastval_t *nodename;
+       rlink_t *pos;
 
        for (i = 0; i < level; i++)
                fprintf(stdout, "  ");
-       nodename = (rastval_t*)r_harray_get(node->props, r_harray_lookup_s(node->props, "name"));
 
-       if (node->val.type == R_ASTVAL_ARRAY) {
-               if (nodename) {
-                       fprintf(stdout, "%s: ", nodename->v.str->s.str);
+       if (node->val.type == R_ASTVAL_HEAD) {
+               if (node->name) {
+                       fprintf(stdout, "%s: ", node->name);
                        fwrite(node->src.ptr, sizeof(char), node->src.size, stdout);
                        fprintf(stdout, "\n");
                }
 
-               for (i = 0; i < r_carray_length(node->val.v.arr); i++) {
-                       rastval_t *val = (rastval_t *)r_carray_slot(node->val.v.arr, i);
-                       r_astnode_dump(val->v.node, level + 1);
+               r_list_foreach(pos, &node->val.v.h) {
+                       r_astnode_dump(r_list_entry(pos, rastnode_t, lnk), level + 1);
                }
+//             for (i = 0; i < r_carray_length(node->val.v.arr); i++) {
+//                     rastval_t *val = (rastval_t *)r_carray_slot(node->val.v.arr, i);
+//                     r_astnode_dump(val->v.node, level + 1);
+//             }
 
        } else {
-               if (nodename) {
-                       fprintf(stdout, "%s: ", nodename->v.str->s.str);
+               if (node->name) {
+                       fprintf(stdout, "%s: ", node->name);
                }
                fwrite(node->src.ptr, sizeof(char), node->src.size, stdout);
                fprintf(stdout, "\n");
@@ -138,7 +140,9 @@ void r_astnode_propery_set_string(rastnode_t *node, const char *key, rstring_t *
 {
        rastval_t val;
        R_ASTVAL_SET_STRING(&val, str);
-       r_harray_add_s(node->props, key, &val);
+//     if (!node->props)
+//             node->props = r_harray_create(sizeof(rastval_t));
+//     r_harray_add_s(node->props, key, &val);
 }
 
 void r_astcompiler_dumptree(rastcompiler_t *aco)
@@ -170,6 +174,9 @@ int r_astcompiler_notify(rpa_stat_handle stat, const char *name, void *userdata,
        if (parseinfo)
                r_astcompiler_dumpnotification(stat, name, userdata, input, size, reason);
 
+       if (compileonly)
+               return size;
+
        if (reason & RPA_REASON_START) {
                rastnode_t *node = r_astnode_create();
                r_gc_add(aco->gc, (robject_t*)node);
@@ -177,9 +184,7 @@ int r_astcompiler_notify(rpa_stat_handle stat, const char *name, void *userdata,
                aco->root = node;
        } else if (reason & RPA_REASON_MATCHED) {
                rastnode_t *node = aco->root;
-               rstring_t *nodename = r_string_create_from_ansistr(name);
-               r_gc_add(aco->gc, (robject_t*)nodename);
-               r_astnode_propery_set_string(node, "name", nodename);
+               node->name = name;
                aco->root = node->parent;
                r_astnode_addchild(aco->root, node);
                node->src.ptr = (rpointer)input;
@@ -197,9 +202,11 @@ int main(int argc, char *argv[])
        int res, i;
        rstr_t *script = NULL, *unmapscript = NULL;
        rastcompiler_t *aco = r_astcompiler_create();
-       aco->dbex = rpa_dbex_create();
+       rastnode_t *node;
 
 
+       aco->dbex = rpa_dbex_create();
+
        for (i = 1; i < argc; i++) {
                if (r_strcmp(argv[i], "-L") == 0) {
                } else if (r_strcmp(argv[i], "-d") == 0) {
@@ -218,6 +225,12 @@ int main(int argc, char *argv[])
                }
        }
 
+//     for (i = 0; i < 500000; i++) {
+//             node = r_astnode_create();
+//             r_gc_add(aco->gc, (robject_t*)node);
+//     }
+
+
        r_astcompiler_loadrules(aco);
 
        for (i = 1; i < argc; i++) {
@@ -257,7 +270,8 @@ exec:
 end:
        if (unmapscript)
                codegen_unmap_file(unmapscript);
-       rpa_dbex_destroy(aco->dbex);
+       if (aco->dbex)
+               rpa_dbex_destroy(aco->dbex);
        r_astcompiler_destroy(aco);
 
        if (debuginfo) {
@@ -281,9 +295,6 @@ void r_astcompiler_loadrules(rastcompiler_t *aco)
        const char *pattern = buffer;
 
        rpa_dbex_open(aco->dbex);
-       rpa_dbex_add_callback_exact(aco->dbex, "Identifier", RPA_REASON_ALL, r_astcompiler_notify, aco);
-
-
 
        rpa_dbex_add_callback_exact(aco->dbex, "BitwiseANDOp", RPA_REASON_ALL, r_astcompiler_notify, aco);
        rpa_dbex_add_callback_exact(aco->dbex, "BitwiseXOROp", RPA_REASON_ALL, r_astcompiler_notify, aco);
@@ -291,10 +302,6 @@ void r_astcompiler_loadrules(rastcompiler_t *aco)
        rpa_dbex_add_callback_exact(aco->dbex, "AdditiveExpressionOp", RPA_REASON_ALL, r_astcompiler_notify, aco);
        rpa_dbex_add_callback_exact(aco->dbex, "MultiplicativeExpressionOp", RPA_REASON_ALL, r_astcompiler_notify, aco);
 
-//     rpa_dbex_add_callback_exact(aco->dbex, "AdditiveExpression", RPA_REASON_ALL, r_astcompiler_notify, aco);
-//     rpa_dbex_add_callback_exact(aco->dbex, "MultiplicativeExpression", RPA_REASON_ALL, r_astcompiler_notify, aco);
-
-
        rpa_dbex_add_callback_exact(aco->dbex, "ShiftExpressionOp", RPA_REASON_ALL, r_astcompiler_notify, aco);
        rpa_dbex_add_callback_exact(aco->dbex, "EqualityExpressionOp", RPA_REASON_ALL, r_astcompiler_notify, aco);
        rpa_dbex_add_callback_exact(aco->dbex, "RelationalExpressionOp", RPA_REASON_ALL, r_astcompiler_notify, aco);