[KSS-checkins] r46069 - in kukit/kukit.js/branch/commas-in-selectors: kukit tests

gotcha at codespeak.net gotcha at codespeak.net
Tue Aug 28 10:16:52 CEST 2007


Author: gotcha
Date: Tue Aug 28 10:16:51 2007
New Revision: 46069

Modified:
   kukit/kukit.js/branch/commas-in-selectors/kukit/kssparser.js
   kukit/kukit.js/branch/commas-in-selectors/kukit/tokenizer.js
   kukit/kukit.js/branch/commas-in-selectors/tests/test_tokenizer.js
Log:
identifiers rename

Modified: kukit/kukit.js/branch/commas-in-selectors/kukit/kssparser.js
==============================================================================
--- kukit/kukit.js/branch/commas-in-selectors/kukit/kssparser.js	(original)
+++ kukit/kukit.js/branch/commas-in-selectors/kukit/kssparser.js	Tue Aug 28 10:16:51 2007
@@ -45,29 +45,29 @@
 * class Document 
 */
 kukit.kssp.Document = kukit.tk.mkParser('document', {
-    "\/\*": 'new kukit.kssp.Comment(this.src, kukit.kssp.commentbegin)',
-    "{": 'new kukit.kssp.Block(this.src, kukit.kssp.openbrace)'
+    "\/\*": 'new kukit.kssp.Comment(this.cursor, kukit.kssp.commentbegin)',
+    "{": 'new kukit.kssp.Block(this.cursor, kukit.kssp.openbrace)'
     });
 kukit.kssp.Document.prototype.process = function() {
     this.eventRules = [];
     // Parse all tokens (including first and last)
-    var cursor = {'next': 0};
-    while (cursor.next < this.result.length) {
-        this.digestTxt(cursor, kukit.tk.Fraction, kukit.kssp.Comment);
-        var key = cursor.txt;
+    var context = {'nextTokenIndex': 0};
+    while (context.nextTokenIndex < this.result.length) {
+        this.digestTxt(context, kukit.tk.Fraction, kukit.kssp.Comment);
+        var key = context.txt;
         if (! key) {
             break;
         }
-        this.expectToken(cursor, kukit.kssp.Block);
-        this.addBlock(key, cursor.token);
+        this.expectToken(context, kukit.kssp.Block);
+        this.addBlock(key, context.token);
     }
     this.result = [];
     this.txt = '';
 }; 
 kukit.kssp.Document.prototype.addBlock = function(key, block) {
     // Parse the part in an embedded parser
-    var src = new kukit.tk.Cursor(key + ' ');
-    var parser = new kukit.kssp.KssSelectors(src, null, true);
+    var cursor = new kukit.tk.Cursor(key + ' ');
+    var parser = new kukit.kssp.KssSelectors(cursor, null, true);
     // check the event name and namespace use in evt- rules
     // equals the event name and namespace set in the KSS selector.
 //  XXX GC do not forget to check event names    
@@ -102,7 +102,7 @@
 */
 kukit.kssp.Comment = kukit.tk.mkParser('comment', {
     // it's not 100% good, but will do
-    "\*\/": 'this.emitAndReturn(new kukit.kssp.commentend(this.src))'
+    "\*\/": 'this.emitAndReturn(new kukit.kssp.commentend(this.cursor))'
     });
 kukit.kssp.Comment.prototype.process = function() {
     this.result = [];
@@ -113,9 +113,9 @@
 * class Block 
 */
 kukit.kssp.Block = kukit.tk.mkParser('block', {
-    ";": 'new kukit.kssp.semicolon(this.src)',
-    ":": '[new kukit.kssp.colon(this.src), new kukit.kssp.PropValue(this.src)]',
-    "}": 'this.emitAndReturn(new kukit.kssp.closebrace(this.src))'
+    ";": 'new kukit.kssp.semicolon(this.cursor)',
+    ":": '[new kukit.kssp.colon(this.cursor), new kukit.kssp.PropValue(this.cursor)]',
+    "}": 'this.emitAndReturn(new kukit.kssp.closebrace(this.cursor))'
     });
 kukit.kssp.Block.prototype.process = function() {
     //this.parms = {};
@@ -124,19 +124,19 @@
     this.evt_namespace = null; // we don't know at this point
     this.actions = new kukit.rd.ActionSet();
     // Parse all tokens (except first and last)
-    var cursor = {'next': 1};
-    while (cursor.next < this.result.length-1) {
-        this.digestTxt(cursor, kukit.tk.Fraction, kukit.kssp.Comment);
-        var key = cursor.txt;
+    var context = {'nextTokenIndex': 1};
+    while (context.nextTokenIndex < this.result.length-1) {
+        this.digestTxt(context, kukit.tk.Fraction, kukit.kssp.Comment);
+        var key = context.txt;
         if (! key) {
             break;
         }
-        this.expectToken(cursor, kukit.kssp.colon);
-        this.expectToken(cursor, kukit.kssp.PropValue);
+        this.expectToken(context, kukit.kssp.colon);
+        this.expectToken(context, kukit.kssp.PropValue);
         // store the wrapped prop
-        this.addDeclaration(key, cursor.token.value);
-        if (cursor.next == this.result.length-1) break;
-        this.expectToken(cursor, kukit.kssp.semicolon);
+        this.addDeclaration(key, context.token.value);
+        if (context.nextTokenIndex == this.result.length-1) break;
+        this.expectToken(context, kukit.kssp.semicolon);
     }
     this.result = [];
     this.txt = '';
@@ -347,17 +347,17 @@
     "}": 'this.emitAndReturn()',
     ")": 'this.emitAndReturn()',
     ",": 'this.emitAndReturn()',
-    "'": 'new kukit.kssp.String(this.src, kukit.kssp.quote)',
-    '"': 'new kukit.kssp.String2(this.src, kukit.kssp.dquote)',
-    "\/\*": 'new kukit.kssp.Comment(this.src, kukit.kssp.commentbegin)',
-    "(": 'new kukit.kssp.MethodArgs(this.src, kukit.kssp.openparent)'
+    "'": 'new kukit.kssp.String(this.cursor, kukit.kssp.quote)',
+    '"': 'new kukit.kssp.String2(this.cursor, kukit.kssp.dquote)',
+    "\/\*": 'new kukit.kssp.Comment(this.cursor, kukit.kssp.commentbegin)',
+    "(": 'new kukit.kssp.MethodArgs(this.cursor, kukit.kssp.openparent)'
     });
 kukit.kssp.PropValue.prototype.process = function() {
-    var cursor = {'next': 0};
-    this.digestTxt(cursor, kukit.tk.Fraction, kukit.kssp.Comment);
+    var context = {'nextTokenIndex': 0};
+    this.digestTxt(context, kukit.tk.Fraction, kukit.kssp.Comment);
     this.txt = '';
-    var txt = cursor.txt;
-    if (this.notInTokens(cursor, kukit.kssp.String)) {
+    var txt = context.txt;
+    if (this.notInTokens(context, kukit.kssp.String)) {
         // The previous txt must be all whitespace.
         if (txt) {
 ;;;         kukit.E = 'Wrong value : unallowed characters [' + txt + ']';
@@ -365,9 +365,9 @@
             this.emitError(kukit.E);
         }
         // the next one must be a string.
-        this.expectToken(cursor, kukit.kssp.String);
-        this.produceTxt(cursor.token.txt);
-    } else if (this.notInTokens(cursor, kukit.kssp.MethodArgs)) {
+        this.expectToken(context, kukit.kssp.String);
+        this.produceTxt(context.token.txt);
+    } else if (this.notInTokens(context, kukit.kssp.MethodArgs)) {
         // see if not empty and has no spaces in it 
         if (! txt || txt.indexOf(' ') != -1) {
 ;;;         kukit.E = 'Wrong value : method name [' + txt + '] cannot ';
@@ -375,8 +375,8 @@
             this.emitError(kukit.E);
         }
         // the next one must be the rules
-        this.expectToken(cursor, kukit.kssp.MethodArgs);
-        this.value = new this.valueClass(txt, cursor.token.args);
+        this.expectToken(context, kukit.kssp.MethodArgs);
+        this.value = new this.valueClass(txt, context.token.args);
     } else {
         // not a string or method: check if we allowed multiword.
         if (! this.multiword_allowed && txt.indexOf(' ') != -1) {
@@ -386,10 +386,10 @@
         this.produceTxt(txt);
     }
     // see what's after
-    if (cursor.next < this.result.length) {
-        this.digestTxt(cursor, kukit.tk.Fraction, kukit.kssp.Comment);
+    if (context.nextTokenIndex < this.result.length) {
+        this.digestTxt(context, kukit.tk.Fraction, kukit.kssp.Comment);
         // we have to be at the end and have no text after
-        if (cursor.next < this.result.length || cursor.txt) {
+        if (context.nextTokenIndex < this.result.length || context.txt) {
 ;;;         kukit.E = 'Wrong value : unallowed characters after ';
 ;;;         kukit.E += 'the property.';
             this.emitError(kukit.E);
@@ -415,9 +415,9 @@
     ")": 'this.emitAndReturn()',
     "]": 'this.emitAndReturn()',
     ",": 'this.emitAndReturn()',
-    "'": 'new kukit.kssp.String(this.src, kukit.kssp.quote)',
-    '"': 'new kukit.kssp.String2(this.src, kukit.kssp.dquote)',
-    "\/\*": 'new kukit.kssp.Comment(this.src, kukit.kssp.commentbegin)'
+    "'": 'new kukit.kssp.String(this.cursor, kukit.kssp.quote)',
+    '"': 'new kukit.kssp.String2(this.cursor, kukit.kssp.dquote)',
+    "\/\*": 'new kukit.kssp.Comment(this.cursor, kukit.kssp.commentbegin)'
     });
 kukit.kssp.PropValueInMethod.prototype.multiword_allowed = false;
 kukit.kssp.PropValueInMethod.prototype.process =
@@ -440,7 +440,7 @@
     "\r": 'this.emitAndReturn()',
     "\/\*": 'this.emitAndReturn()',
     ":": 'this.emitAndReturn()',
-    "(": 'this.emitAndReturn(new kukit.kssp.MethodArgs(this.src,' +
+    "(": 'this.emitAndReturn(new kukit.kssp.MethodArgs(this.cursor,' +
         'kukit.kssp.openparent))'
     });
 kukit.kssp.EventValue.prototype.multiword_allowed = false;
@@ -456,8 +456,8 @@
 * class String
 */
 kukit.kssp.String = kukit.tk.mkParser('string', {
-    "'": 'this.emitAndReturn(new kukit.kssp.quote(this.src))',
-    '\x5c': 'new kukit.kssp.Backslashed(this.src, kukit.kssp.backslash)'
+    "'": 'this.emitAndReturn(new kukit.kssp.quote(this.cursor))',
+    '\x5c': 'new kukit.kssp.Backslashed(this.cursor, kukit.kssp.backslash)'
     });
 kukit.kssp.String.prototype.process = function() {
     // collect up the value of the string, omitting the quotes
@@ -471,8 +471,8 @@
 * class String2
 */
 kukit.kssp.String2 = kukit.tk.mkParser('string', {
-    '"': 'this.emitAndReturn(new kukit.kssp.dquote(this.src))',
-    '\x5c': 'new kukit.kssp.Backslashed(this.src, kukit.kssp.backslash)'
+    '"': 'this.emitAndReturn(new kukit.kssp.dquote(this.cursor))',
+    '\x5c': 'new kukit.kssp.Backslashed(this.cursor, kukit.kssp.backslash)'
     });
 kukit.kssp.String2.prototype.process = kukit.kssp.String.prototype.process; 
 
@@ -483,14 +483,14 @@
 kukit.kssp.Backslashed = kukit.tk.mkParser('backslashed', {});
 kukit.kssp.Backslashed.prototype.nextStep = function(table) {
     // digest the next character and store it as txt
-    var src = this.src;
-    var length = src.text.length;
-    if (length < src.pos + 1) {
+    var cursor = this.cursor;
+    var length = cursor.text.length;
+    if (length < cursor.pos + 1) {
 ;;;     kukit.E = 'Missing character after backslash.';
         this.emitError(kukit.E);
     } else { 
-        this.result.push(new kukit.tk.Fraction(src, src.pos+1));
-        this.src.pos += 1;
+        this.result.push(new kukit.tk.Fraction(cursor, cursor.pos+1));
+        this.cursor.pos += 1;
         this.finished = true;
     }
 };
@@ -504,25 +504,25 @@
 * methodargs are (a, b, c) lists.
 */
 kukit.kssp.MethodArgs = kukit.tk.mkParser('methodargs', {
-    "'": 'new kukit.kssp.String(this.src, kukit.kssp.quote)',
-    '"': 'new kukit.kssp.String2(this.src, kukit.kssp.dquote)',
-    ",": 'new kukit.kssp.comma(this.src)',
-    ")": 'this.emitAndReturn(new kukit.kssp.closeparent(this.src))',
-    "\/\*": 'new kukit.kssp.Comment(this.src, kukit.kssp.commentbegin)'
+    "'": 'new kukit.kssp.String(this.cursor, kukit.kssp.quote)',
+    '"': 'new kukit.kssp.String2(this.cursor, kukit.kssp.dquote)',
+    ",": 'new kukit.kssp.comma(this.cursor)',
+    ")": 'this.emitAndReturn(new kukit.kssp.closeparent(this.cursor))',
+    "\/\*": 'new kukit.kssp.Comment(this.cursor, kukit.kssp.commentbegin)'
     });
 kukit.kssp.MethodArgs.prototype.process = function() {
     this.args = [];
     // Parse all tokens (except first and last)
-    var cursor = {'next': 1};
-    while (cursor.next < this.result.length-1) {
-        this.digestTxt(cursor, kukit.tk.Fraction, kukit.kssp.Comment);
-        var value = cursor.txt;
+    var context = {'nextTokenIndex': 1};
+    while (context.nextTokenIndex < this.result.length-1) {
+        this.digestTxt(context, kukit.tk.Fraction, kukit.kssp.Comment);
+        var value = context.txt;
         if (! value) {
             // allow to bail out after widow ,
-            if (cursor.next == this.result.length-1) break;
+            if (context.nextTokenIndex == this.result.length-1) break;
             // here be a string then.
-            this.expectToken(cursor, kukit.kssp.String);
-            value = cursor.token.txt;
+            this.expectToken(context, kukit.kssp.String);
+            value = context.token.txt;
         } else {
             // Just a value, must be one word then.
             if (value.indexOf(' ') != -1) {
@@ -533,8 +533,8 @@
             }
         }
         this.args.push(value);
-        if (cursor.next == this.result.length-1) break;
-        this.expectToken(cursor, kukit.kssp.comma);
+        if (context.nextTokenIndex == this.result.length-1) break;
+        this.expectToken(context, kukit.kssp.comma);
     }
     this.result = [];
     this.txt = '';
@@ -550,21 +550,21 @@
 *      document:name(id) or behaviour:name(id)
 */
 kukit.kssp.KssSelectors = kukit.tk.mkParser('kssselectors', {
-    ",": 'new kukit.kssp.comma(this.src)',
+    ",": 'new kukit.kssp.comma(this.cursor)',
     "{": 'this.emitAndReturn()',
-    "\/\*": 'new kukit.kssp.Comment(this.src, kukit.kssp.commentbegin)'
+    "\/\*": 'new kukit.kssp.Comment(this.cursor, kukit.kssp.commentbegin)'
     });
 kukit.kssp.KssSelectors.prototype.process = function() {
     this.selectors = [];
     // Parse all tokens (including first and last)
-    var cursor = {'next': 0};
-    while (cursor.next < this.result.length) {
-        this.digestTxt(cursor, kukit.tk.Fraction, kukit.kssp.Comment);
-        var src = new kukit.tk.Cursor(cursor.txt + ' ')
-        var parser = new kukit.kssp.KssSelector(src, null, true);
+    var context = {'nextTokenIndex': 0};
+    while (context.nextTokenIndex < this.result.length) {
+        this.digestTxt(context, kukit.tk.Fraction, kukit.kssp.Comment);
+        var cursor = new kukit.tk.Cursor(context.txt + ' ')
+        var parser = new kukit.kssp.KssSelector(cursor, null, true);
         this.selectors.push(parser.kssSelector);
-        if (cursor.next == this.result.length) break;
-        this.expectToken(cursor, kukit.kssp.comma);
+        if (context.nextTokenIndex == this.result.length) break;
+        this.expectToken(context, kukit.kssp.comma);
     };
     this.result = [];
     this.txt = '';
@@ -580,10 +580,10 @@
 *      document:name(id) or behaviour:name(id)
 */
 kukit.kssp.KssSelector = kukit.tk.mkParser('kssselector', {
-    ":": '[new kukit.kssp.colon(this.src), new ' + 
-        'kukit.kssp.EventValue(this.src)]',
+    ":": '[new kukit.kssp.colon(this.cursor), new ' + 
+        'kukit.kssp.EventValue(this.cursor)]',
     "{": 'this.emitAndReturn()',
-    "\/\*": 'new kukit.kssp.Comment(this.src, kukit.kssp.commentbegin)'
+    "\/\*": 'new kukit.kssp.Comment(this.cursor, kukit.kssp.commentbegin)'
     });
 kukit.kssp.KssSelector.prototype.process = function() {
     var name;
@@ -647,7 +647,7 @@
 ;;;     kukit.E += ':<EVENTNAME>(<ID>) can have only one parameter.';
         this.emitError(kukit.E);
     }
-    css = this.src.text.substring(this.startpos, commatoken.startpos);
+    css = this.cursor.text.substring(this.startpos, commatoken.startpos);
     // Decide if we have an event or a method selector.
     // We have a method selector if a single word "document" or "behaviour".
     var singleword = css.replace(/[\r\n\t ]/g, ' ');
@@ -715,8 +715,8 @@
 kukit.kssp.KssRuleProcessor.prototype.parse = function() {
 ;;; try {
         //Build a parser and parse the text into it
-        var src = new kukit.tk.Cursor(this.txt);
-        var parser = new kukit.kssp.Document(src, null, true);
+        var cursor = new kukit.tk.Cursor(this.txt);
+        var parser = new kukit.kssp.Document(cursor, null, true);
         // Store event rules in the common list
         for (var i=0; i<parser.eventRules.length; i++) {
             var rule = parser.eventRules[i];

Modified: kukit/kukit.js/branch/commas-in-selectors/kukit/tokenizer.js
==============================================================================
--- kukit/kukit.js/branch/commas-in-selectors/kukit/tokenizer.js	(original)
+++ kukit/kukit.js/branch/commas-in-selectors/kukit/tokenizer.js	Tue Aug 28 10:16:51 2007
@@ -29,13 +29,13 @@
 
 kukit.tk._TokenBase.prototype.emitError = function(msg) {
     // Use the start position of the token for the error report.
-;;; var marker = this.src.makeMarker(this.startpos);
+;;; var marker = this.cursor.makeMarker(this.startpos);
 ;;; kukit.E = new kukit.err.tk.ParsingError(msg, marker);
     throw kukit.E;
 };
 
 kukit.tk._TokenBase.prototype.updateFinished = function() {
-    if (! this.finished && this.src.text.length == this.src.pos) {
+    if (! this.finished && this.cursor.text.length == this.cursor.pos) {
         if (this.isTopLevelParser) {
             this.finished = true;
         } else {
@@ -61,23 +61,22 @@
 };
 
 kukit.tk._ParserBase.prototype.nextStep = function(table) {
-    var src = this.src;
+    var cursor = this.cursor;
     // Search for symbol according to table.
-    var best_pos = src.text.length;
+    var best_pos = cursor.text.length;
     var best_symbol = null;
     for (var symbol in table) {
-        var pos = src.text.indexOf(symbol, src.pos);
+        var pos = cursor.text.indexOf(symbol, cursor.pos);
         if (pos != -1 && pos < best_pos) {
             best_pos = pos;
             best_symbol = symbol;
         }
     }
     // eat up till the symbol found (of EOF)
-    if (best_pos > src.pos) {
-        this.result.push(new kukit.tk.Fraction(src, best_pos));
-        src.pos = best_pos;
+    if (best_pos > cursor.pos) {
+        this.result.push(new kukit.tk.Fraction(cursor, best_pos));
+        cursor.pos = best_pos;
     }
-    // handle cursor point
     if (best_symbol) {
         // found a symbol, handle that
         // make the token and push it
@@ -103,8 +102,8 @@
     }
 };
 
-kukit.tk._ParserBase.prototype.expectToken = function(cursor, token) {
-    var i = cursor.next;
+kukit.tk._ParserBase.prototype.expectToken = function(context, token) {
+    var i = context.nextTokenIndex;
     if (token) {
         var symbol = token.prototype.symbol;
         if (i >= this.result.length) {
@@ -121,8 +120,8 @@
             this.emitError(kukit.E);
         }
     }
-    cursor.token = this.result[i];
-    cursor.next += 1;
+    context.token = this.result[i];
+    context.nextTokenIndex += 1;
 };
 
 kukit.tk._ParserBase.prototype.resultIsNullOrNotToken = 
@@ -131,8 +130,8 @@
 };
 
 kukit.tk._ParserBase.prototype.notInTokens = 
-    function(cursor, token1, token2, token3, token4) {
-    var i = cursor.next;
+    function(context, token1, token2, token3, token4) {
+    var i = context.nextTokenIndex;
     var currentValue = this.result[i];
     return !(
         (i >= this.result.length) ||
@@ -144,23 +143,23 @@
 };
 
 kukit.tk._ParserBase.prototype.digestTxt =
-    function(cursor, token1, token2, token3, token4) {
+    function(context, token1, token2, token3, token4) {
     // digests the txt from the tokens, ignores given token
     // plus whitespace removal
-    this.digestExactTxt(cursor, token1, token2, token3, token4);
-    cursor.txt = this.removeWhitespacesAndTrim(cursor.txt);
+    this.digestExactTxt(context, token1, token2, token3, token4);
+    context.txt = this.removeWhitespacesAndTrim(context.txt);
 };
 
 kukit.tk._ParserBase.prototype.digestExactTxt =
-    function(cursor, token1, token2, token3, token4) {
+    function(context, token1, token2, token3, token4) {
     // digests the txt from the tokens, ignores given token
     // exact value: no whitespace removal
     var result = '';
-    while (this.notInTokens(cursor, token1, token2, token3, token4)) {
-        result += this.result[cursor.next].txt;
-        cursor.next ++;
+    while (this.notInTokens(context, token1, token2, token3, token4)) {
+        result += this.result[context.nextTokenIndex].txt;
+        context.nextTokenIndex ++;
         }
-    cursor.txt = result;
+    context.txt = result;
 };
 
 
@@ -188,10 +187,10 @@
 /*
 * class Fraction
 */
-kukit.tk.Fraction = function(src, endpos) {
-    this.txt = src.text.substring(src.pos, endpos);
-    this.startpos = src.pos;
-    this.endpos = src.pos;
+kukit.tk.Fraction = function(cursor, endpos) {
+    this.txt = cursor.text.substring(cursor.pos, endpos);
+    this.startpos = cursor.pos;
+    this.endpos = cursor.pos;
     this.finished = true;
 };
 kukit.tk.Fraction.prototype.symbol = 'fraction';
@@ -201,20 +200,20 @@
 
 kukit.tk.mkToken = function(symbol, txt) {
     // Poor man's subclassing.
-    f = function(src) {
-        this.src = src;
-        this.startpos = src.pos;
-        if (src.text.substr(src.pos, txt.length) != txt) {
+    f = function(cursor) {
+        this.cursor = cursor;
+        this.startpos = cursor.pos;
+        if (cursor.text.substr(cursor.pos, txt.length) != txt) {
 ;;;         kukit.E = 'Unexpected token : [';
-;;;         kukit.E += src.text.substr(src.pos, txt.length) + '] found,';
+;;;         kukit.E += cursor.text.substr(cursor.pos, txt.length) + '] found,';
 ;;;         kukit.E += ' [' + txt + '] was expected.';
             this.emitError(kukit.E);
         } else {
-            src.pos += txt.length;
+            cursor.pos += txt.length;
             this.finished = true;
         }
-        this.endpos = src.pos;
-        //this.src = null;
+        this.endpos = cursor.pos;
+        //this.cursor = null;
     };
     f.prototype = new kukit.tk._TokenBase;
     f.prototype.symbol = symbol;
@@ -224,32 +223,35 @@
 
 kukit.tk.mkParser = function(symbol, table) {
     // Poor man's subclassing.
-    f = function(src, tokenClass, isTopLevelParser) {
-        this.src = src;
-        this.startpos = src.pos;
+    f = function(cursor, tokenClass, isTopLevelParser) {
+        this.cursor = cursor;
+        this.startpos = cursor.pos;
         this.finished = false;
         this.isTopLevelParser = isTopLevelParser;
         this.result = [];
         if (tokenClass) {
             // Reentry with starting token propagated.
-            this.result.push(new tokenClass(this.src));
+            this.result.push(new tokenClass(this.cursor));
         }
         this.updateFinished();
         while (!this.finished) {
             this.nextStep(table);
             this.updateFinished();
         }
-        this.endpos = src.pos;
+        this.endpos = cursor.pos;
         // post processing
         this.process();
         
-        //this.src = null;
+        //this.cursor = null;
     };
     f.prototype = new kukit.tk._ParserBase;
     f.prototype.symbol = symbol;
     return f;
 };
 
+/*
+* class Cursor
+*/
 kukit.tk.Cursor = function(txt) {
     this.text = txt;
     this.pos = 0;

Modified: kukit/kukit.js/branch/commas-in-selectors/tests/test_tokenizer.js
==============================================================================
--- kukit/kukit.js/branch/commas-in-selectors/tests/test_tokenizer.js	(original)
+++ kukit/kukit.js/branch/commas-in-selectors/tests/test_tokenizer.js	Tue Aug 28 10:16:51 2007
@@ -45,12 +45,12 @@
         }
     };
 
-    this.assertParsingError = function(pclass, src, tokenClass, eofOk, errtxt, errpos) {
+    this.assertParsingError = function(pclass, cursor, tokenClass, eofOk, errtxt, errpos) {
         if (! kukit.Engine.develMode) {
             return; }
         var exc = null;
         try {
-            new pclass(src, tokenClass, eofOk);
+            new pclass(cursor, tokenClass, eofOk);
         } catch(e) {
             exc = e;
             if (e.name != 'ParsingError') {
@@ -122,42 +122,42 @@
     this.testBasic = function() {
         // Basic parser creation
         var txt="abc def";
-        var src = new kukit.tk.Cursor(txt);
+        var cursor = new kukit.tk.Cursor(txt);
 
         kukit.tk.openbrace = kukit.tk.mkToken('openbrace', '{');
         kukit.tk.openbracket = kukit.tk.mkToken('openbracket', '[');
 
         var pf = kukit.tk.mkParser('block', {
-            '[': 'this.emitAndReturn(new kukit.tk.openbracket(this.src))',
-            '{': 'new kukit.tk.openbrace(this.src)'
+            '[': 'this.emitAndReturn(new kukit.tk.openbracket(this.cursor))',
+            '{': 'new kukit.tk.openbrace(this.cursor)'
             });
 
-        var parser = new pf(src, null, true);
+        var parser = new pf(cursor, null, true);
         this.assertEquals(parser.finished, true);
         this.assertEquals(parser.result.length, 1);
         this.assertEquals(parser.result[0].symbol, 'fraction');
         this.assertEquals(parser.result[0].txt, 'abc def');
         
-        this.assertParsingError(pf, src, null, false, 'Unexpected EOF');
+        this.assertParsingError(pf, cursor, null, false, 'Unexpected EOF');
         
         var txt="abc{def";
-        var src = new kukit.tk.Cursor(txt);
-        var parser = new pf(src, null, true);
+        var cursor = new kukit.tk.Cursor(txt);
+        var parser = new pf(cursor, null, true);
         this.assertEquals(parser.finished, true);
         this.assertEquals(parser.result.length, 3);
         
         var txt="abc[def";
-        var src = new kukit.tk.Cursor(txt);
-        var parser = new pf(src, null, true);
+        var cursor = new kukit.tk.Cursor(txt);
+        var parser = new pf(cursor, null, true);
         this.assertEquals(parser.finished, true);
         this.assertEquals(parser.result.length, 2);
-        this.assertEquals(src.pos, 4);
+        this.assertEquals(cursor.pos, 4);
     };
     
     this.testRecursive = function() {
         // Recursive parser creation
         var txt="a[bc{de[f}ghi";
-        var src = new kukit.tk.Cursor(txt);
+        var cursor = new kukit.tk.Cursor(txt);
 
         kukit.tk.openbrace = kukit.tk.mkToken('openbrace', '{');
         kukit.tk.openbracket = kukit.tk.mkToken('openbracket', '[');
@@ -165,16 +165,16 @@
         kukit.tk.wrappedbracket = kukit.tk.mkToken('wrappedbracket', '[');
 
         kukit.tk.global = kukit.tk.mkParser('global', {
-            '[': 'new kukit.tk.openbracket(this.src)',
-            '{': 'new kukit.tk.inside(this.src, kukit.tk.openbrace)'
+            '[': 'new kukit.tk.openbracket(this.cursor)',
+            '{': 'new kukit.tk.inside(this.cursor, kukit.tk.openbrace)'
             });
             
         kukit.tk.inside = kukit.tk.mkParser('inside', {
-            '[': 'new kukit.tk.wrappedbracket(this.src)',
-            '}': 'this.emitAndReturn(new kukit.tk.closebrace(this.src))'
+            '[': 'new kukit.tk.wrappedbracket(this.cursor)',
+            '}': 'this.emitAndReturn(new kukit.tk.closebrace(this.cursor))'
             });
 
-        var parser = new kukit.tk.global(src, null, true);
+        var parser = new kukit.tk.global(cursor, null, true);
         //this.printDebug(parser);
         this.assertEquals(parser.finished, true);
         this.assertEquals(parser.result.length, 5);
@@ -207,16 +207,16 @@
         //
 
         var txt="";
-        var src = new kukit.tk.Cursor(txt);
-        parser = new kukit.tk.global(src, null, true);
+        var cursor = new kukit.tk.Cursor(txt);
+        parser = new kukit.tk.global(cursor, null, true);
         //this.printDebug(parser);
         this.assertEquals(parser.finished, true);
         this.assertEquals(parser.result.length, 0);
 
         // In particular, the next one should not raise unexpected eof.
         var txt="{}";
-        var src = new kukit.tk.Cursor(txt);
-        parser = new kukit.tk.global(src, null, true);
+        var cursor = new kukit.tk.Cursor(txt);
+        parser = new kukit.tk.global(cursor, null, true);
         //this.printDebug(parser);
         this.assertEquals(parser.finished, true);
         this.assertEquals(parser.result.length, 1);
@@ -226,18 +226,18 @@
     this.testProcessing = function() {
         // Processing parser creation
         var txt="abc'de\\'f'ghi";
-        var src = new kukit.tk.Cursor(txt);
+        var cursor = new kukit.tk.Cursor(txt);
 
         kukit.tk.quote = kukit.tk.mkToken('quote', "'");
         kukit.tk.backslash = kukit.tk.mkToken('backslash', "\\");
 
         kukit.tk.global = kukit.tk.mkParser('global', {
-            "'": 'new kukit.tk.string(this.src, kukit.tk.quote)'
+            "'": 'new kukit.tk.string(this.cursor, kukit.tk.quote)'
             });
             
         kukit.tk.string = kukit.tk.mkParser('string', {
-            "'": 'this.emitAndReturn(new kukit.tk.quote(this.src))',
-            "\\": 'new kukit.tk.backslashed(this.src, kukit.tk.backslash)'
+            "'": 'this.emitAndReturn(new kukit.tk.quote(this.cursor))',
+            "\\": 'new kukit.tk.backslashed(this.cursor, kukit.tk.backslash)'
             });
         kukit.tk.string.prototype.process = function() {
             // collect up the value of the string, omitting the quotes
@@ -250,13 +250,13 @@
         kukit.tk.backslashed = kukit.tk.mkParser('backslashed', {});
         kukit.tk.backslashed.prototype.nextStep = function(table) {
             // digest the next character and store it as txt
-            var src = this.src;
-            var length = src.text.length;
-            if (length < src.pos + 1) {
+            var cursor = this.cursor;
+            var length = cursor.text.length;
+            if (length < cursor.pos + 1) {
                 this.emitError('Missing character after backslash');
             } else { 
-                this.result.push(new kukit.tk.Fraction(src, src.pos+1));
-                this.src.pos += 1;
+                this.result.push(new kukit.tk.Fraction(cursor, cursor.pos+1));
+                this.cursor.pos += 1;
                 this.finished = true;
             }
         }
@@ -264,7 +264,7 @@
             this.txt = this.result[1].txt;
         }
 
-        var parser = new kukit.tk.global(src, null, true);
+        var parser = new kukit.tk.global(cursor, null, true);
         //this.printDebug(parser);
         this.assertEquals(parser.finished, true);
         this.assertEquals(parser.result.length, 3);
@@ -302,7 +302,7 @@
         // this means make independend parsing of separate tokens
         // only makes sense if we don't want LR parse inside a token.
         var txt="a[bc{de fg[h] ij[kl]mn}opq";
-        var src = new kukit.tk.Cursor(txt);
+        var cursor = new kukit.tk.Cursor(txt);
 
         kukit.tk.openbrace = kukit.tk.mkToken('openbrace', '{');
         kukit.tk.openbracket = kukit.tk.mkToken('openbracket', '[');
@@ -310,12 +310,12 @@
         kukit.tk.closebracket = kukit.tk.mkToken('closebracket', ']');
 
         kukit.tk.global = kukit.tk.mkParser('global', {
-            '[': 'new kukit.tk.openbracket(this.src)',
-            '{': 'new kukit.tk.inside(this.src, kukit.tk.openbrace)'
+            '[': 'new kukit.tk.openbracket(this.cursor)',
+            '{': 'new kukit.tk.inside(this.cursor, kukit.tk.openbrace)'
             });
             
         kukit.tk.inside = kukit.tk.mkParser('inside', {
-            '}': 'this.emitAndReturn(new kukit.tk.closebrace(this.src))'
+            '}': 'this.emitAndReturn(new kukit.tk.closebrace(this.cursor))'
             });
         kukit.tk.inside.prototype.process = function() {
             // collect up the value of the string, omitting the quotes
@@ -327,22 +327,22 @@
             var parts = this.txt.split(' ');
             var last_part = parts[parts.length - 1];
             // make embedded parsing
-            var embedded_src =new kukit.tk.Cursor(last_part);
-            this.embedded_parser = new kukit.tk.embedded(embedded_src, null, true);
+            var embedded_cursor =new kukit.tk.Cursor(last_part);
+            this.embedded_parser = new kukit.tk.embedded(embedded_cursor, null, true);
             if (this.embedded_parser == 2) {
-                this.emitError('Error in embedded parser: ' + embedded_src.errtxt);
+                this.emitError('Error in embedded parser: ' + embedded_cursor.errtxt);
                 }
         }
             
         kukit.tk.embedded = kukit.tk.mkParser('embedded', {
-            '[': 'new kukit.tk.embedded_inside(this.src, kukit.tk.openbracket)'
+            '[': 'new kukit.tk.embedded_inside(this.cursor, kukit.tk.openbracket)'
             });
  
         kukit.tk.embedded_inside = kukit.tk.mkParser('embedded_inside', {
-            ']': 'this.emitAndReturn(new kukit.tk.closebracket(this.src))'
+            ']': 'this.emitAndReturn(new kukit.tk.closebracket(this.cursor))'
             });
             
-        var parser = new kukit.tk.global(src, null, true);
+        var parser = new kukit.tk.global(cursor, null, true);
         //this.printDebug(parser);
         this.assertEquals(parser.finished, true);
         this.assertEquals(parser.result.length, 5);
@@ -372,7 +372,7 @@
     this.testMoreTokens = function() {
         // More tokens, empty entries
         var txt="a[bc{de[f}ghi";
-        var src = new kukit.tk.Cursor(txt);
+        var cursor = new kukit.tk.Cursor(txt);
 
         kukit.tk.openbrace = kukit.tk.mkToken('openbrace', '{');
         kukit.tk.openbracket = kukit.tk.mkToken('openbracket', '[');
@@ -380,17 +380,17 @@
         kukit.tk.wrappedbracket = kukit.tk.mkToken('wrappedbracket', '[');
 
         kukit.tk.global = kukit.tk.mkParser('global', {
-            '[': 'new kukit.tk.openbracket(this.src)',
-            '{': '[new kukit.tk.openbrace(this.src), new kukit.tk.inside(this.src)]',
-            '}': 'new kukit.tk.closebrace(this.src)'
+            '[': 'new kukit.tk.openbracket(this.cursor)',
+            '{': '[new kukit.tk.openbrace(this.cursor), new kukit.tk.inside(this.cursor)]',
+            '}': 'new kukit.tk.closebrace(this.cursor)'
             });
             
         kukit.tk.inside = kukit.tk.mkParser('inside', {
-            '[': 'new kukit.tk.wrappedbracket(this.src)',
+            '[': 'new kukit.tk.wrappedbracket(this.cursor)',
             '}': 'this.emitAndReturn()'
             });
 
-        var parser = new kukit.tk.global(src, null, true);
+        var parser = new kukit.tk.global(cursor, null, true);
         //this.printDebug(parser);
         this.assertEquals(parser.finished, true);
         this.assertEquals(parser.result.length, 7);


More information about the Kukit-checkins mailing list