diff jsparser.js @ 4:559378a3ec26

renamed computeSelf and computeLeft to nullDenotation and leftDenotation.
author Atul Varma <varmaa@toolness.com>
date Sat, 30 May 2009 13:28:20 -0700
parents f174153281a9
children f66ec534e75a
line wrap: on
line diff
--- a/jsparser.js	Sat May 30 13:23:01 2009 -0700
+++ b/jsparser.js	Sat May 30 13:28:20 2009 -0700
@@ -9,11 +9,11 @@
 
 Parsing.Symbol.prototype = {
   leftBindingPower: 0,
-  computeSelf: function() {
-    throw new Error("No computeSelf for " + this.name);
+  nullDenotation: function() {
+    throw new Error("No nullDenotation for " + this.name);
   },
-  computeLeft: function() {
-    throw new Error("No computeLeft for " + this.name);
+  leftDenotation: function() {
+    throw new Error("No leftDenotation for " + this.name);
   },
   extend: function(contents) {
     function Subclass() {}
@@ -47,13 +47,13 @@
 };
 
 Parsing.BinaryOrUnaryOp.prototype = new Parsing.Symbol(
-  {computeSelf: function(parser) {
+  {nullDenotation: function(parser) {
      var unaryOp = this.extend(Parsing.UnaryOperator.prototype);
-     return unaryOp.computeSelf(parser);
+     return unaryOp.nullDenotation(parser);
    },
-   computeLeft: function(parser, left) {
+   leftDenotation: function(parser, left) {
      var binaryOp = this.extend(Parsing.BinaryOperator.prototype);
-     return binaryOp.computeLeft(parser, left);
+     return binaryOp.leftDenotation(parser, left);
    }
   });
 
@@ -62,7 +62,7 @@
 };
 
 Parsing.UnaryOperator.prototype = new Parsing.Symbol(
-  {computeSelf: function(parser) {
+  {nullDenotation: function(parser) {
      this.arity = "unary";
      this.operand = parser.token;
      parser.advance();
@@ -78,7 +78,7 @@
 };
 
 Parsing.BinaryOperator.prototype = new Parsing.Symbol(
-  {computeLeft: function(parser, left) {
+  {leftDenotation: function(parser, left) {
      this.arity = "binary";
      this.leftOperand = left;
      this.rightOperand = parser.expression(this.leftBindingPower);
@@ -148,11 +148,11 @@
   this.expression = function expression(rightBindingPower) {
     var leftToken = self.token;
     self.advance();
-    var leftValue = leftToken.computeSelf(self);
+    var leftValue = leftToken.nullDenotation(self);
     while (rightBindingPower < self.token.leftBindingPower) {
       leftToken = self.token;
       self.advance();
-      leftValue = leftToken.computeLeft(self, leftValue);
+      leftValue = leftToken.leftDenotation(self, leftValue);
     }
     return leftValue;
   };
@@ -175,7 +175,7 @@
 
     new Parsing.Symbol({name: 'number',
                         match: /^[0-9]+/,
-                        computeSelf: function() {
+                        nullDenotation: function() {
                           return this;
                         },
                         toString: function() {