Skip to content
This repository

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Browse code

- Add TODO for comments

- Get rid of some things that don't need to be public anymore
  • Loading branch information...
commit 73d8af1bfc42eb577708cf8a8785a77f38a46640 1 parent 80607f1
andychu authored December 30, 2009

Showing 1 changed file with 15 additions and 13 deletions. Show diff stats Hide diff stats

  1. 28  patched/jsparse.js
28  patched/jsparse.js
@@ -28,7 +28,7 @@ var fpRegExp = /^\d+\.\d*(?:[eE][-+]?\d+)?|^\d+(?:\.\d*)?[eE][-+]?\d+|^\.\d+(?:[
28 28
 // A regexp to match regexp literals.
29 29
 var reRegExp = /^\/((?:\\.|\[(?:\\.|[^\]])*\]|[^\/])+)\/([gimy]*)/;
30 30
 
31  
-var Tokenizer = exports.Tokenizer = function Tokenizer(s, f, l) {
  31
+function Tokenizer(s, f, l) {
32 32
     this.cursor = 0;
33 33
     this.source = String(s);
34 34
     this.tokens = [];
@@ -111,6 +111,10 @@ Tokenizer.prototype = {
111 111
             if (!(match = /^\/(?:\*(?:.|\n)*?\*\/|\/.*)/(input)))
112 112
                 break;
113 113
             var comment = match[0];
  114
+
  115
+            // TODO: EXPOSE COMMENTS, with singleLine: true/false
  116
+            // print('GOT COMMENT ' + match[0]);
  117
+
114 118
             this.cursor += comment.length;
115 119
             newlines = comment.match(/\n/g);
116 120
             if (newlines)
@@ -183,7 +187,7 @@ Tokenizer.prototype = {
183 187
 
184 188
 };
185 189
 
186  
-var CompilerContext = exports.CompilerContext = function CompilerContext(inFunction) {
  190
+function CompilerContext(inFunction) {
187 191
     this.inFunction = inFunction;
188 192
     this.stmtStack = [];
189 193
     this.funDecls = [];
@@ -195,7 +199,7 @@ CCp.bracketLevel = CCp.curlyLevel = CCp.parenLevel = CCp.hookLevel = 0;
195 199
 CCp.ecmaStrictMode = CCp.inForLoopInit = false;
196 200
 
197 201
 // t, x: Tokenizer, CompilerContext
198  
-var Script = exports.Script = function Script(t, x) {
  202
+function Script(t, x) {
199 203
     var n = Statements(t, x);
200 204
     n.type = defs.SCRIPT;
201 205
     n.funDecls = x.funDecls;
@@ -207,7 +211,7 @@ var top = function (stack) {
207 211
     return stack.length && stack[stack.length-1];
208 212
 };
209 213
 
210  
-var Node = exports.Node = function Node(t, type) {
  214
+function Node(t, type) {
211 215
     var token = t.token;
212 216
     if (token) {
213 217
         this.type = type || token.type;
@@ -357,7 +361,7 @@ function nest(t, x, node, func, end) {
357 361
 }
358 362
 
359 363
 // t, x: Tokenizer, CompilerContext
360  
-var Statements = exports.Statements = function Statements(t, x) {
  364
+function Statements(t, x) {
361 365
     var n = new Node(t, defs.BLOCK);
362 366
     x.stmtStack.push(n);
363 367
     while (!t.done && t.peek() != defs.RIGHT_CURLY) {
@@ -368,7 +372,7 @@ var Statements = exports.Statements = function Statements(t, x) {
368 372
 }
369 373
 
370 374
 // t, x: Tokenizer, CompilerContext
371  
-var Block = exports.Block = function Block(t, x) {
  375
+function Block(t, x) {
372 376
     t.mustMatch(defs.LEFT_CURLY);
373 377
     var n = Statements(t, x);
374 378
     t.mustMatch(defs.RIGHT_CURLY);
@@ -377,7 +381,7 @@ var Block = exports.Block = function Block(t, x) {
377 381
 
378 382
 var DECLARED_FORM = 0, EXPRESSED_FORM = 1, STATEMENT_FORM = 2;
379 383
 
380  
-var Statement = exports.Statement = function Statement(t, x) {
  384
+function Statement(t, x) {
381 385
     var i, label, n, n2, ss, tt = t.get();
382 386
 
383 387
     // Cases for statements ending in a right curly return early, avoiding the
@@ -633,8 +637,6 @@ var Statement = exports.Statement = function Statement(t, x) {
633 637
     return n;
634 638
 }
635 639
 
636  
-var FunctionDefinition =
637  
-exports.FunctionDefinition =
638 640
 function FunctionDefinition(t, x, requireName, functionForm) {
639 641
     var f = new Node(t);
640 642
     if (f.type != defs.FUNCTION)
@@ -667,7 +669,7 @@ function FunctionDefinition(t, x, requireName, functionForm) {
667 669
     return f;
668 670
 }
669 671
 
670  
-var Variables = exports.Variables = function Variables(t, x) {
  672
+function Variables(t, x) {
671 673
     var n = new Node(t);
672 674
     do {
673 675
         t.mustMatch(defs.IDENTIFIER);
@@ -685,7 +687,7 @@ var Variables = exports.Variables = function Variables(t, x) {
685 687
     return n;
686 688
 }
687 689
 
688  
-var ParenExpression = exports.ParenExpression = function ParenExpression(t, x) {
  690
+function ParenExpression(t, x) {
689 691
     t.mustMatch(defs.LEFT_PAREN);
690 692
     var n = Expression(t, x);
691 693
     t.mustMatch(defs.RIGHT_PAREN);
@@ -743,7 +745,7 @@ var opArity = {
743 745
 for (i in opArity)
744 746
     opArity[defs[i]] = opArity[i];
745 747
 
746  
-var Expression = exports.Expression = function Expression(t, x, stop) {
  748
+function Expression(t, x, stop) {
747 749
     var n, id, tt, operators = [], operands = [];
748 750
     var bl = x.bracketLevel, cl = x.curlyLevel, pl = x.parenLevel,
749 751
         hl = x.hookLevel;
@@ -1066,7 +1068,7 @@ loop:
1066 1068
 //   s: string to parse
1067 1069
 //   f: filename, defaults to ""
1068 1070
 //   l: line number, defaults to 1
1069  
-var parse = exports.parse = function parse(s, f, l) {
  1071
+var parse = exports.parse = function (s, f, l) {
1070 1072
     var t = new Tokenizer(s, f, l);
1071 1073
     var x = new CompilerContext(false);
1072 1074
     var n = Script(t, x);

0 notes on commit 73d8af1

Please sign in to comment.
Something went wrong with that request. Please try again.