Changeset 2337

Show
Ignore:
Timestamp:
12/03/07 16:08:52 (5 years ago)
Author:
nshuyo
Message:

lang/javascript/jsruby/trunk/src/parse.js : tidied up some of the code

Files:
1 modified

Legend:

Unmodified
Added
Removed
  • lang/javascript/jsruby/trunk/src/parse.js

    r2328 r2337  
    1111//  CompStmt: Stmt (Term+ Stmt)* 
    1212RubyEngine.Parser.prototype.compstmt = function() { 
    13         var x, y; 
    14         x=this.stmt(); 
    15         if (x==null || typeof(x)=="undefined") return undefined; 
     13        var x; 
     14        if ((x=this.stmt())==undefined) return undefined; 
    1615        var ret = [x]; 
    1716        var prebody = this.body; 
    18         while (x=this.term()) { 
     17        while (this.term()) { 
    1918                while(this.term()); 
    20                 if (!(y=this.stmt())) break; 
     19                if (!(x=this.stmt())) break; 
    2120                prebody = this.body; 
    22                 ret.push(y); 
     21                ret.push(x); 
    2322        } 
    2423        this.body = prebody; 
     
    3433RubyEngine.Parser.prototype.expr = function() { 
    3534        var x, y; 
    36         x=this.expr2(); 
    37         if (x==null || typeof(x)=="undefined") return undefined; 
     35        if ((x=this.expr2())==undefined) return undefined; 
    3836        var ret = [x] 
    3937        while (this.body.match(/^[ \t]*(if|unless|while|until)/)) { 
     
    5250//  Expr2: Command | Arg  
    5351RubyEngine.Parser.prototype.expr2 = function() { 
    54         var x, y, z; 
    55         var prebody = this.body; 
    56         if (x=this.command()) return x; 
    57   x=this.arg() 
    58         if (x!=null && typeof(x)!="undefined") return x; 
    59         this.body = prebody; 
     52        var x; 
     53        if ((x=this.command())!=undefined) return x; 
     54        if ((x=this.arg())!=undefined) return x; 
    6055        return undefined; 
    6156} 
     
    6964                this.body=prebody; 
    7065        } 
    71   x=this.primary() 
    72         if (x!=null && typeof(x)!="undefined") { 
     66 
     67        if ((x=this.primary())!=undefined) { 
    7368                if (this.body.match(/^[ \t]*\./)) { 
    7469                        this.body = RegExp.rightContext; 
     
    8883RubyEngine.Parser.prototype.args = function() { 
    8984        var x, y; 
    90         if (!(x=this.arg())) return undefined; 
     85        if ((x=this.arg())==undefined) return undefined; 
    9186        var ret = [x]; 
    9287        var prebody = this.body; 
     
    110105                this.body=prebody; 
    111106        } 
    112         x=this.primary(); 
    113         if (x!=null && typeof(x)!="undefined") { 
     107 
     108        if ((x=this.primary())!=undefined) { 
    114109                var ret = [x]; 
    115110                prebody = this.body; 
    116                 while ((x=this.operator()) && ((y=this.primary())!=null)) { 
     111                while ((x=this.operator()) && ((y=this.primary())!=undefined)) { 
    117112                        prebody = this.body; 
    118113                        ret.push(x, y); 
     
    223218                return x; 
    224219        } 
     220 
     221  // if Arg Then CompStmt (elsif Arg Then CompStmt)* (else CompStmt)? end 
    225222        if (this.body.match(/^[ \t]*(if)/)) { 
    226223                this.body = RegExp.rightContext;