930 var ret = [this.LValue(start), this.LValue(end)]; |
930 var ret = [this.LValue(start), this.LValue(end)]; |
931 for(var i=1; i<result.length; i++) |
931 for(var i=1; i<result.length; i++) |
932 ret.push(this.LValue(result[i])); |
932 ret.push(this.LValue(result[i])); |
933 return ret; |
933 return ret; |
934 }, |
934 }, |
|
935 format: function (format_) |
|
936 { |
|
937 var format = format_.value, result = ""; |
|
938 var re = new RegExp("%([0-9. ]*)([a-zA-Z%])", "g"); |
|
939 var match, currpos = 0, currparam = 1; |
|
940 while(match = re.exec(format)) |
|
941 { |
|
942 result += format.substring(currpos, match.index); |
|
943 currpos = re.lastIndex; |
|
944 switch(match[2]) |
|
945 { |
|
946 case "f": case "d": |
|
947 if(match[1].length>0) |
|
948 throw "string.format(): Number format modifers not yet implemented"; |
|
949 case "s": |
|
950 result+=arguments[currparam++].value.toString(); |
|
951 case "%": |
|
952 break; |
|
953 default: |
|
954 throw "string.format(): Format %"+match[2]+" not implemented"; |
|
955 } |
|
956 } |
|
957 result += format.substring(currpos); |
|
958 return [this.LValue(result)]; |
|
959 }, |
935 gmatch: function (str, patt) |
960 gmatch: function (str, patt) |
936 { |
961 { |
937 var re = _patternToRegExp(patt.value); |
962 var re = _patternToRegExp(patt.value); |
938 var matches = str.value.match(re)||[]; |
963 var matches = str.value.match(re)||[]; |
939 var curr = 0; |
964 var curr = 0; |