changeset 0:7de0c0d19f97

Origination. The narcissus code has been slightly modified from its snapshot at mozilla-central rev. 2ad9a0f79e7d to support comment tracking in the parser.
author Atul Varma <varmaa@toolness.com>
date Mon, 05 Jan 2009 15:54:01 -0800
parents
children 4f72ee5859eb
files jquery-1.2.6.min.js js.js jsdefs.js jsexec.js jsparse.js samplecode.js server.py thingy.html thingy.js wikicreole.js
diffstat 10 files changed, 2687 insertions(+), 0 deletions(-) [+]
line wrap: on
line diff
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/jquery-1.2.6.min.js	Mon Jan 05 15:54:01 2009 -0800
@@ -0,0 +1,32 @@
+/*
+ * jQuery 1.2.6 - New Wave Javascript
+ *
+ * Copyright (c) 2008 John Resig (jquery.com)
+ * Dual licensed under the MIT (MIT-LICENSE.txt)
+ * and GPL (GPL-LICENSE.txt) licenses.
+ *
+ * $Date: 2008-05-24 14:22:17 -0400 (Sat, 24 May 2008) $
+ * $Rev: 5685 $
+ */
+(function(){var _jQuery=window.jQuery,_$=window.$;var jQuery=window.jQuery=window.$=function(selector,context){return new jQuery.fn.init(selector,context);};var quickExpr=/^[^<]*(<(.|\s)+>)[^>]*$|^#(\w+)$/,isSimple=/^.[^:#\[\.]*$/,undefined;jQuery.fn=jQuery.prototype={init:function(selector,context){selector=selector||document;if(selector.nodeType){this[0]=selector;this.length=1;return this;}if(typeof selector=="string"){var match=quickExpr.exec(selector);if(match&&(match[1]||!context)){if(match[1])selector=jQuery.clean([match[1]],context);else{var elem=document.getElementById(match[3]);if(elem){if(elem.id!=match[3])return jQuery().find(selector);return jQuery(elem);}selector=[];}}else
+return jQuery(context).find(selector);}else if(jQuery.isFunction(selector))return jQuery(document)[jQuery.fn.ready?"ready":"load"](selector);return this.setArray(jQuery.makeArray(selector));},jquery:"1.2.6",size:function(){return this.length;},length:0,get:function(num){return num==undefined?jQuery.makeArray(this):this[num];},pushStack:function(elems){var ret=jQuery(elems);ret.prevObject=this;return ret;},setArray:function(elems){this.length=0;Array.prototype.push.apply(this,elems);return this;},each:function(callback,args){return jQuery.each(this,callback,args);},index:function(elem){var ret=-1;return jQuery.inArray(elem&&elem.jquery?elem[0]:elem,this);},attr:function(name,value,type){var options=name;if(name.constructor==String)if(value===undefined)return this[0]&&jQuery[type||"attr"](this[0],name);else{options={};options[name]=value;}return this.each(function(i){for(name in options)jQuery.attr(type?this.style:this,name,jQuery.prop(this,options[name],type,i,name));});},css:function(key,value){if((key=='width'||key=='height')&&parseFloat(value)<0)value=undefined;return this.attr(key,value,"curCSS");},text:function(text){if(typeof text!="object"&&text!=null)return this.empty().append((this[0]&&this[0].ownerDocument||document).createTextNode(text));var ret="";jQuery.each(text||this,function(){jQuery.each(this.childNodes,function(){if(this.nodeType!=8)ret+=this.nodeType!=1?this.nodeValue:jQuery.fn.text([this]);});});return ret;},wrapAll:function(html){if(this[0])jQuery(html,this[0].ownerDocument).clone().insertBefore(this[0]).map(function(){var elem=this;while(elem.firstChild)elem=elem.firstChild;return elem;}).append(this);return this;},wrapInner:function(html){return this.each(function(){jQuery(this).contents().wrapAll(html);});},wrap:function(html){return this.each(function(){jQuery(this).wrapAll(html);});},append:function(){return this.domManip(arguments,true,false,function(elem){if(this.nodeType==1)this.appendChild(elem);});},prepend:function(){return this.domManip(arguments,true,true,function(elem){if(this.nodeType==1)this.insertBefore(elem,this.firstChild);});},before:function(){return this.domManip(arguments,false,false,function(elem){this.parentNode.insertBefore(elem,this);});},after:function(){return this.domManip(arguments,false,true,function(elem){this.parentNode.insertBefore(elem,this.nextSibling);});},end:function(){return this.prevObject||jQuery([]);},find:function(selector){var elems=jQuery.map(this,function(elem){return jQuery.find(selector,elem);});return this.pushStack(/[^+>] [^+>]/.test(selector)||selector.indexOf("..")>-1?jQuery.unique(elems):elems);},clone:function(events){var ret=this.map(function(){if(jQuery.browser.msie&&!jQuery.isXMLDoc(this)){var clone=this.cloneNode(true),container=document.createElement("div");container.appendChild(clone);return jQuery.clean([container.innerHTML])[0];}else
+return this.cloneNode(true);});var clone=ret.find("*").andSelf().each(function(){if(this[expando]!=undefined)this[expando]=null;});if(events===true)this.find("*").andSelf().each(function(i){if(this.nodeType==3)return;var events=jQuery.data(this,"events");for(var type in events)for(var handler in events[type])jQuery.event.add(clone[i],type,events[type][handler],events[type][handler].data);});return ret;},filter:function(selector){return this.pushStack(jQuery.isFunction(selector)&&jQuery.grep(this,function(elem,i){return selector.call(elem,i);})||jQuery.multiFilter(selector,this));},not:function(selector){if(selector.constructor==String)if(isSimple.test(selector))return this.pushStack(jQuery.multiFilter(selector,this,true));else
+selector=jQuery.multiFilter(selector,this);var isArrayLike=selector.length&&selector[selector.length-1]!==undefined&&!selector.nodeType;return this.filter(function(){return isArrayLike?jQuery.inArray(this,selector)<0:this!=selector;});},add:function(selector){return this.pushStack(jQuery.unique(jQuery.merge(this.get(),typeof selector=='string'?jQuery(selector):jQuery.makeArray(selector))));},is:function(selector){return!!selector&&jQuery.multiFilter(selector,this).length>0;},hasClass:function(selector){return this.is("."+selector);},val:function(value){if(value==undefined){if(this.length){var elem=this[0];if(jQuery.nodeName(elem,"select")){var index=elem.selectedIndex,values=[],options=elem.options,one=elem.type=="select-one";if(index<0)return null;for(var i=one?index:0,max=one?index+1:options.length;i<max;i++){var option=options[i];if(option.selected){value=jQuery.browser.msie&&!option.attributes.value.specified?option.text:option.value;if(one)return value;values.push(value);}}return values;}else
+return(this[0].value||"").replace(/\r/g,"");}return undefined;}if(value.constructor==Number)value+='';return this.each(function(){if(this.nodeType!=1)return;if(value.constructor==Array&&/radio|checkbox/.test(this.type))this.checked=(jQuery.inArray(this.value,value)>=0||jQuery.inArray(this.name,value)>=0);else if(jQuery.nodeName(this,"select")){var values=jQuery.makeArray(value);jQuery("option",this).each(function(){this.selected=(jQuery.inArray(this.value,values)>=0||jQuery.inArray(this.text,values)>=0);});if(!values.length)this.selectedIndex=-1;}else
+this.value=value;});},html:function(value){return value==undefined?(this[0]?this[0].innerHTML:null):this.empty().append(value);},replaceWith:function(value){return this.after(value).remove();},eq:function(i){return this.slice(i,i+1);},slice:function(){return this.pushStack(Array.prototype.slice.apply(this,arguments));},map:function(callback){return this.pushStack(jQuery.map(this,function(elem,i){return callback.call(elem,i,elem);}));},andSelf:function(){return this.add(this.prevObject);},data:function(key,value){var parts=key.split(".");parts[1]=parts[1]?"."+parts[1]:"";if(value===undefined){var data=this.triggerHandler("getData"+parts[1]+"!",[parts[0]]);if(data===undefined&&this.length)data=jQuery.data(this[0],key);return data===undefined&&parts[1]?this.data(parts[0]):data;}else
+return this.trigger("setData"+parts[1]+"!",[parts[0],value]).each(function(){jQuery.data(this,key,value);});},removeData:function(key){return this.each(function(){jQuery.removeData(this,key);});},domManip:function(args,table,reverse,callback){var clone=this.length>1,elems;return this.each(function(){if(!elems){elems=jQuery.clean(args,this.ownerDocument);if(reverse)elems.reverse();}var obj=this;if(table&&jQuery.nodeName(this,"table")&&jQuery.nodeName(elems[0],"tr"))obj=this.getElementsByTagName("tbody")[0]||this.appendChild(this.ownerDocument.createElement("tbody"));var scripts=jQuery([]);jQuery.each(elems,function(){var elem=clone?jQuery(this).clone(true)[0]:this;if(jQuery.nodeName(elem,"script"))scripts=scripts.add(elem);else{if(elem.nodeType==1)scripts=scripts.add(jQuery("script",elem).remove());callback.call(obj,elem);}});scripts.each(evalScript);});}};jQuery.fn.init.prototype=jQuery.fn;function evalScript(i,elem){if(elem.src)jQuery.ajax({url:elem.src,async:false,dataType:"script"});else
+jQuery.globalEval(elem.text||elem.textContent||elem.innerHTML||"");if(elem.parentNode)elem.parentNode.removeChild(elem);}function now(){return+new Date;}jQuery.extend=jQuery.fn.extend=function(){var target=arguments[0]||{},i=1,length=arguments.length,deep=false,options;if(target.constructor==Boolean){deep=target;target=arguments[1]||{};i=2;}if(typeof target!="object"&&typeof target!="function")target={};if(length==i){target=this;--i;}for(;i<length;i++)if((options=arguments[i])!=null)for(var name in options){var src=target[name],copy=options[name];if(target===copy)continue;if(deep&&copy&&typeof copy=="object"&&!copy.nodeType)target[name]=jQuery.extend(deep,src||(copy.length!=null?[]:{}),copy);else if(copy!==undefined)target[name]=copy;}return target;};var expando="jQuery"+now(),uuid=0,windowData={},exclude=/z-?index|font-?weight|opacity|zoom|line-?height/i,defaultView=document.defaultView||{};jQuery.extend({noConflict:function(deep){window.$=_$;if(deep)window.jQuery=_jQuery;return jQuery;},isFunction:function(fn){return!!fn&&typeof fn!="string"&&!fn.nodeName&&fn.constructor!=Array&&/^[\s[]?function/.test(fn+"");},isXMLDoc:function(elem){return elem.documentElement&&!elem.body||elem.tagName&&elem.ownerDocument&&!elem.ownerDocument.body;},globalEval:function(data){data=jQuery.trim(data);if(data){var head=document.getElementsByTagName("head")[0]||document.documentElement,script=document.createElement("script");script.type="text/javascript";if(jQuery.browser.msie)script.text=data;else
+script.appendChild(document.createTextNode(data));head.insertBefore(script,head.firstChild);head.removeChild(script);}},nodeName:function(elem,name){return elem.nodeName&&elem.nodeName.toUpperCase()==name.toUpperCase();},cache:{},data:function(elem,name,data){elem=elem==window?windowData:elem;var id=elem[expando];if(!id)id=elem[expando]=++uuid;if(name&&!jQuery.cache[id])jQuery.cache[id]={};if(data!==undefined)jQuery.cache[id][name]=data;return name?jQuery.cache[id][name]:id;},removeData:function(elem,name){elem=elem==window?windowData:elem;var id=elem[expando];if(name){if(jQuery.cache[id]){delete jQuery.cache[id][name];name="";for(name in jQuery.cache[id])break;if(!name)jQuery.removeData(elem);}}else{try{delete elem[expando];}catch(e){if(elem.removeAttribute)elem.removeAttribute(expando);}delete jQuery.cache[id];}},each:function(object,callback,args){var name,i=0,length=object.length;if(args){if(length==undefined){for(name in object)if(callback.apply(object[name],args)===false)break;}else
+for(;i<length;)if(callback.apply(object[i++],args)===false)break;}else{if(length==undefined){for(name in object)if(callback.call(object[name],name,object[name])===false)break;}else
+for(var value=object[0];i<length&&callback.call(value,i,value)!==false;value=object[++i]){}}return object;},prop:function(elem,value,type,i,name){if(jQuery.isFunction(value))value=value.call(elem,i);return value&&value.constructor==Number&&type=="curCSS"&&!exclude.test(name)?value+"px":value;},className:{add:function(elem,classNames){jQuery.each((classNames||"").split(/\s+/),function(i,className){if(elem.nodeType==1&&!jQuery.className.has(elem.className,className))elem.className+=(elem.className?" ":"")+className;});},remove:function(elem,classNames){if(elem.nodeType==1)elem.className=classNames!=undefined?jQuery.grep(elem.className.split(/\s+/),function(className){return!jQuery.className.has(classNames,className);}).join(" "):"";},has:function(elem,className){return jQuery.inArray(className,(elem.className||elem).toString().split(/\s+/))>-1;}},swap:function(elem,options,callback){var old={};for(var name in options){old[name]=elem.style[name];elem.style[name]=options[name];}callback.call(elem);for(var name in options)elem.style[name]=old[name];},css:function(elem,name,force){if(name=="width"||name=="height"){var val,props={position:"absolute",visibility:"hidden",display:"block"},which=name=="width"?["Left","Right"]:["Top","Bottom"];function getWH(){val=name=="width"?elem.offsetWidth:elem.offsetHeight;var padding=0,border=0;jQuery.each(which,function(){padding+=parseFloat(jQuery.curCSS(elem,"padding"+this,true))||0;border+=parseFloat(jQuery.curCSS(elem,"border"+this+"Width",true))||0;});val-=Math.round(padding+border);}if(jQuery(elem).is(":visible"))getWH();else
+jQuery.swap(elem,props,getWH);return Math.max(0,val);}return jQuery.curCSS(elem,name,force);},curCSS:function(elem,name,force){var ret,style=elem.style;function color(elem){if(!jQuery.browser.safari)return false;var ret=defaultView.getComputedStyle(elem,null);return!ret||ret.getPropertyValue("color")=="";}if(name=="opacity"&&jQuery.browser.msie){ret=jQuery.attr(style,"opacity");return ret==""?"1":ret;}if(jQuery.browser.opera&&name=="display"){var save=style.outline;style.outline="0 solid black";style.outline=save;}if(name.match(/float/i))name=styleFloat;if(!force&&style&&style[name])ret=style[name];else if(defaultView.getComputedStyle){if(name.match(/float/i))name="float";name=name.replace(/([A-Z])/g,"-$1").toLowerCase();var computedStyle=defaultView.getComputedStyle(elem,null);if(computedStyle&&!color(elem))ret=computedStyle.getPropertyValue(name);else{var swap=[],stack=[],a=elem,i=0;for(;a&&color(a);a=a.parentNode)stack.unshift(a);for(;i<stack.length;i++)if(color(stack[i])){swap[i]=stack[i].style.display;stack[i].style.display="block";}ret=name=="display"&&swap[stack.length-1]!=null?"none":(computedStyle&&computedStyle.getPropertyValue(name))||"";for(i=0;i<swap.length;i++)if(swap[i]!=null)stack[i].style.display=swap[i];}if(name=="opacity"&&ret=="")ret="1";}else if(elem.currentStyle){var camelCase=name.replace(/\-(\w)/g,function(all,letter){return letter.toUpperCase();});ret=elem.currentStyle[name]||elem.currentStyle[camelCase];if(!/^\d+(px)?$/i.test(ret)&&/^\d/.test(ret)){var left=style.left,rsLeft=elem.runtimeStyle.left;elem.runtimeStyle.left=elem.currentStyle.left;style.left=ret||0;ret=style.pixelLeft+"px";style.left=left;elem.runtimeStyle.left=rsLeft;}}return ret;},clean:function(elems,context){var ret=[];context=context||document;if(typeof context.createElement=='undefined')context=context.ownerDocument||context[0]&&context[0].ownerDocument||document;jQuery.each(elems,function(i,elem){if(!elem)return;if(elem.constructor==Number)elem+='';if(typeof elem=="string"){elem=elem.replace(/(<(\w+)[^>]*?)\/>/g,function(all,front,tag){return tag.match(/^(abbr|br|col|img|input|link|meta|param|hr|area|embed)$/i)?all:front+"></"+tag+">";});var tags=jQuery.trim(elem).toLowerCase(),div=context.createElement("div");var wrap=!tags.indexOf("<opt")&&[1,"<select multiple='multiple'>","</select>"]||!tags.indexOf("<leg")&&[1,"<fieldset>","</fieldset>"]||tags.match(/^<(thead|tbody|tfoot|colg|cap)/)&&[1,"<table>","</table>"]||!tags.indexOf("<tr")&&[2,"<table><tbody>","</tbody></table>"]||(!tags.indexOf("<td")||!tags.indexOf("<th"))&&[3,"<table><tbody><tr>","</tr></tbody></table>"]||!tags.indexOf("<col")&&[2,"<table><tbody></tbody><colgroup>","</colgroup></table>"]||jQuery.browser.msie&&[1,"div<div>","</div>"]||[0,"",""];div.innerHTML=wrap[1]+elem+wrap[2];while(wrap[0]--)div=div.lastChild;if(jQuery.browser.msie){var tbody=!tags.indexOf("<table")&&tags.indexOf("<tbody")<0?div.firstChild&&div.firstChild.childNodes:wrap[1]=="<table>"&&tags.indexOf("<tbody")<0?div.childNodes:[];for(var j=tbody.length-1;j>=0;--j)if(jQuery.nodeName(tbody[j],"tbody")&&!tbody[j].childNodes.length)tbody[j].parentNode.removeChild(tbody[j]);if(/^\s/.test(elem))div.insertBefore(context.createTextNode(elem.match(/^\s*/)[0]),div.firstChild);}elem=jQuery.makeArray(div.childNodes);}if(elem.length===0&&(!jQuery.nodeName(elem,"form")&&!jQuery.nodeName(elem,"select")))return;if(elem[0]==undefined||jQuery.nodeName(elem,"form")||elem.options)ret.push(elem);else
+ret=jQuery.merge(ret,elem);});return ret;},attr:function(elem,name,value){if(!elem||elem.nodeType==3||elem.nodeType==8)return undefined;var notxml=!jQuery.isXMLDoc(elem),set=value!==undefined,msie=jQuery.browser.msie;name=notxml&&jQuery.props[name]||name;if(elem.tagName){var special=/href|src|style/.test(name);if(name=="selected"&&jQuery.browser.safari)elem.parentNode.selectedIndex;if(name in elem&&notxml&&!special){if(set){if(name=="type"&&jQuery.nodeName(elem,"input")&&elem.parentNode)throw"type property can't be changed";elem[name]=value;}if(jQuery.nodeName(elem,"form")&&elem.getAttributeNode(name))return elem.getAttributeNode(name).nodeValue;return elem[name];}if(msie&&notxml&&name=="style")return jQuery.attr(elem.style,"cssText",value);if(set)elem.setAttribute(name,""+value);var attr=msie&&notxml&&special?elem.getAttribute(name,2):elem.getAttribute(name);return attr===null?undefined:attr;}if(msie&&name=="opacity"){if(set){elem.zoom=1;elem.filter=(elem.filter||"").replace(/alpha\([^)]*\)/,"")+(parseInt(value)+''=="NaN"?"":"alpha(opacity="+value*100+")");}return elem.filter&&elem.filter.indexOf("opacity=")>=0?(parseFloat(elem.filter.match(/opacity=([^)]*)/)[1])/100)+'':"";}name=name.replace(/-([a-z])/ig,function(all,letter){return letter.toUpperCase();});if(set)elem[name]=value;return elem[name];},trim:function(text){return(text||"").replace(/^\s+|\s+$/g,"");},makeArray:function(array){var ret=[];if(array!=null){var i=array.length;if(i==null||array.split||array.setInterval||array.call)ret[0]=array;else
+while(i)ret[--i]=array[i];}return ret;},inArray:function(elem,array){for(var i=0,length=array.length;i<length;i++)if(array[i]===elem)return i;return-1;},merge:function(first,second){var i=0,elem,pos=first.length;if(jQuery.browser.msie){while(elem=second[i++])if(elem.nodeType!=8)first[pos++]=elem;}else
+while(elem=second[i++])first[pos++]=elem;return first;},unique:function(array){var ret=[],done={};try{for(var i=0,length=array.length;i<length;i++){var id=jQuery.data(array[i]);if(!done[id]){done[id]=true;ret.push(array[i]);}}}catch(e){ret=array;}return ret;},grep:function(elems,callback,inv){var ret=[];for(var i=0,length=elems.length;i<length;i++)if(!inv!=!callback(elems[i],i))ret.push(elems[i]);return ret;},map:function(elems,callback){var ret=[];for(var i=0,length=elems.length;i<length;i++){var value=callback(elems[i],i);if(value!=null)ret[ret.length]=value;}return ret.concat.apply([],ret);}});var userAgent=navigator.userAgent.toLowerCase();jQuery.browser={version:(userAgent.match(/.+(?:rv|it|ra|ie)[\/: ]([\d.]+)/)||[])[1],safari:/webkit/.test(userAgent),opera:/opera/.test(userAgent),msie:/msie/.test(userAgent)&&!/opera/.test(userAgent),mozilla:/mozilla/.test(userAgent)&&!/(compatible|webkit)/.test(userAgent)};var styleFloat=jQuery.browser.msie?"styleFloat":"cssFloat";jQuery.extend({boxModel:!jQuery.browser.msie||document.compatMode=="CSS1Compat",props:{"for":"htmlFor","class":"className","float":styleFloat,cssFloat:styleFloat,styleFloat:styleFloat,readonly:"readOnly",maxlength:"maxLength",cellspacing:"cellSpacing"}});jQuery.each({parent:function(elem){return elem.parentNode;},parents:function(elem){return jQuery.dir(elem,"parentNode");},next:function(elem){return jQuery.nth(elem,2,"nextSibling");},prev:function(elem){return jQuery.nth(elem,2,"previousSibling");},nextAll:function(elem){return jQuery.dir(elem,"nextSibling");},prevAll:function(elem){return jQuery.dir(elem,"previousSibling");},siblings:function(elem){return jQuery.sibling(elem.parentNode.firstChild,elem);},children:function(elem){return jQuery.sibling(elem.firstChild);},contents:function(elem){return jQuery.nodeName(elem,"iframe")?elem.contentDocument||elem.contentWindow.document:jQuery.makeArray(elem.childNodes);}},function(name,fn){jQuery.fn[name]=function(selector){var ret=jQuery.map(this,fn);if(selector&&typeof selector=="string")ret=jQuery.multiFilter(selector,ret);return this.pushStack(jQuery.unique(ret));};});jQuery.each({appendTo:"append",prependTo:"prepend",insertBefore:"before",insertAfter:"after",replaceAll:"replaceWith"},function(name,original){jQuery.fn[name]=function(){var args=arguments;return this.each(function(){for(var i=0,length=args.length;i<length;i++)jQuery(args[i])[original](this);});};});jQuery.each({removeAttr:function(name){jQuery.attr(this,name,"");if(this.nodeType==1)this.removeAttribute(name);},addClass:function(classNames){jQuery.className.add(this,classNames);},removeClass:function(classNames){jQuery.className.remove(this,classNames);},toggleClass:function(classNames){jQuery.className[jQuery.className.has(this,classNames)?"remove":"add"](this,classNames);},remove:function(selector){if(!selector||jQuery.filter(selector,[this]).r.length){jQuery("*",this).add(this).each(function(){jQuery.event.remove(this);jQuery.removeData(this);});if(this.parentNode)this.parentNode.removeChild(this);}},empty:function(){jQuery(">*",this).remove();while(this.firstChild)this.removeChild(this.firstChild);}},function(name,fn){jQuery.fn[name]=function(){return this.each(fn,arguments);};});jQuery.each(["Height","Width"],function(i,name){var type=name.toLowerCase();jQuery.fn[type]=function(size){return this[0]==window?jQuery.browser.opera&&document.body["client"+name]||jQuery.browser.safari&&window["inner"+name]||document.compatMode=="CSS1Compat"&&document.documentElement["client"+name]||document.body["client"+name]:this[0]==document?Math.max(Math.max(document.body["scroll"+name],document.documentElement["scroll"+name]),Math.max(document.body["offset"+name],document.documentElement["offset"+name])):size==undefined?(this.length?jQuery.css(this[0],type):null):this.css(type,size.constructor==String?size:size+"px");};});function num(elem,prop){return elem[0]&&parseInt(jQuery.curCSS(elem[0],prop,true),10)||0;}var chars=jQuery.browser.safari&&parseInt(jQuery.browser.version)<417?"(?:[\\w*_-]|\\\\.)":"(?:[\\w\u0128-\uFFFF*_-]|\\\\.)",quickChild=new RegExp("^>\\s*("+chars+"+)"),quickID=new RegExp("^("+chars+"+)(#)("+chars+"+)"),quickClass=new RegExp("^([#.]?)("+chars+"*)");jQuery.extend({expr:{"":function(a,i,m){return m[2]=="*"||jQuery.nodeName(a,m[2]);},"#":function(a,i,m){return a.getAttribute("id")==m[2];},":":{lt:function(a,i,m){return i<m[3]-0;},gt:function(a,i,m){return i>m[3]-0;},nth:function(a,i,m){return m[3]-0==i;},eq:function(a,i,m){return m[3]-0==i;},first:function(a,i){return i==0;},last:function(a,i,m,r){return i==r.length-1;},even:function(a,i){return i%2==0;},odd:function(a,i){return i%2;},"first-child":function(a){return a.parentNode.getElementsByTagName("*")[0]==a;},"last-child":function(a){return jQuery.nth(a.parentNode.lastChild,1,"previousSibling")==a;},"only-child":function(a){return!jQuery.nth(a.parentNode.lastChild,2,"previousSibling");},parent:function(a){return a.firstChild;},empty:function(a){return!a.firstChild;},contains:function(a,i,m){return(a.textContent||a.innerText||jQuery(a).text()||"").indexOf(m[3])>=0;},visible:function(a){return"hidden"!=a.type&&jQuery.css(a,"display")!="none"&&jQuery.css(a,"visibility")!="hidden";},hidden:function(a){return"hidden"==a.type||jQuery.css(a,"display")=="none"||jQuery.css(a,"visibility")=="hidden";},enabled:function(a){return!a.disabled;},disabled:function(a){return a.disabled;},checked:function(a){return a.checked;},selected:function(a){return a.selected||jQuery.attr(a,"selected");},text:function(a){return"text"==a.type;},radio:function(a){return"radio"==a.type;},checkbox:function(a){return"checkbox"==a.type;},file:function(a){return"file"==a.type;},password:function(a){return"password"==a.type;},submit:function(a){return"submit"==a.type;},image:function(a){return"image"==a.type;},reset:function(a){return"reset"==a.type;},button:function(a){return"button"==a.type||jQuery.nodeName(a,"button");},input:function(a){return/input|select|textarea|button/i.test(a.nodeName);},has:function(a,i,m){return jQuery.find(m[3],a).length;},header:function(a){return/h\d/i.test(a.nodeName);},animated:function(a){return jQuery.grep(jQuery.timers,function(fn){return a==fn.elem;}).length;}}},parse:[/^(\[) *@?([\w-]+) *([!*$^~=]*) *('?"?)(.*?)\4 *\]/,/^(:)([\w-]+)\("?'?(.*?(\(.*?\))?[^(]*?)"?'?\)/,new RegExp("^([:.#]*)("+chars+"+)")],multiFilter:function(expr,elems,not){var old,cur=[];while(expr&&expr!=old){old=expr;var f=jQuery.filter(expr,elems,not);expr=f.t.replace(/^\s*,\s*/,"");cur=not?elems=f.r:jQuery.merge(cur,f.r);}return cur;},find:function(t,context){if(typeof t!="string")return[t];if(context&&context.nodeType!=1&&context.nodeType!=9)return[];context=context||document;var ret=[context],done=[],last,nodeName;while(t&&last!=t){var r=[];last=t;t=jQuery.trim(t);var foundToken=false,re=quickChild,m=re.exec(t);if(m){nodeName=m[1].toUpperCase();for(var i=0;ret[i];i++)for(var c=ret[i].firstChild;c;c=c.nextSibling)if(c.nodeType==1&&(nodeName=="*"||c.nodeName.toUpperCase()==nodeName))r.push(c);ret=r;t=t.replace(re,"");if(t.indexOf(" ")==0)continue;foundToken=true;}else{re=/^([>+~])\s*(\w*)/i;if((m=re.exec(t))!=null){r=[];var merge={};nodeName=m[2].toUpperCase();m=m[1];for(var j=0,rl=ret.length;j<rl;j++){var n=m=="~"||m=="+"?ret[j].nextSibling:ret[j].firstChild;for(;n;n=n.nextSibling)if(n.nodeType==1){var id=jQuery.data(n);if(m=="~"&&merge[id])break;if(!nodeName||n.nodeName.toUpperCase()==nodeName){if(m=="~")merge[id]=true;r.push(n);}if(m=="+")break;}}ret=r;t=jQuery.trim(t.replace(re,""));foundToken=true;}}if(t&&!foundToken){if(!t.indexOf(",")){if(context==ret[0])ret.shift();done=jQuery.merge(done,ret);r=ret=[context];t=" "+t.substr(1,t.length);}else{var re2=quickID;var m=re2.exec(t);if(m){m=[0,m[2],m[3],m[1]];}else{re2=quickClass;m=re2.exec(t);}m[2]=m[2].replace(/\\/g,"");var elem=ret[ret.length-1];if(m[1]=="#"&&elem&&elem.getElementById&&!jQuery.isXMLDoc(elem)){var oid=elem.getElementById(m[2]);if((jQuery.browser.msie||jQuery.browser.opera)&&oid&&typeof oid.id=="string"&&oid.id!=m[2])oid=jQuery('[@id="'+m[2]+'"]',elem)[0];ret=r=oid&&(!m[3]||jQuery.nodeName(oid,m[3]))?[oid]:[];}else{for(var i=0;ret[i];i++){var tag=m[1]=="#"&&m[3]?m[3]:m[1]!=""||m[0]==""?"*":m[2];if(tag=="*"&&ret[i].nodeName.toLowerCase()=="object")tag="param";r=jQuery.merge(r,ret[i].getElementsByTagName(tag));}if(m[1]==".")r=jQuery.classFilter(r,m[2]);if(m[1]=="#"){var tmp=[];for(var i=0;r[i];i++)if(r[i].getAttribute("id")==m[2]){tmp=[r[i]];break;}r=tmp;}ret=r;}t=t.replace(re2,"");}}if(t){var val=jQuery.filter(t,r);ret=r=val.r;t=jQuery.trim(val.t);}}if(t)ret=[];if(ret&&context==ret[0])ret.shift();done=jQuery.merge(done,ret);return done;},classFilter:function(r,m,not){m=" "+m+" ";var tmp=[];for(var i=0;r[i];i++){var pass=(" "+r[i].className+" ").indexOf(m)>=0;if(!not&&pass||not&&!pass)tmp.push(r[i]);}return tmp;},filter:function(t,r,not){var last;while(t&&t!=last){last=t;var p=jQuery.parse,m;for(var i=0;p[i];i++){m=p[i].exec(t);if(m){t=t.substring(m[0].length);m[2]=m[2].replace(/\\/g,"");break;}}if(!m)break;if(m[1]==":"&&m[2]=="not")r=isSimple.test(m[3])?jQuery.filter(m[3],r,true).r:jQuery(r).not(m[3]);else if(m[1]==".")r=jQuery.classFilter(r,m[2],not);else if(m[1]=="["){var tmp=[],type=m[3];for(var i=0,rl=r.length;i<rl;i++){var a=r[i],z=a[jQuery.props[m[2]]||m[2]];if(z==null||/href|src|selected/.test(m[2]))z=jQuery.attr(a,m[2])||'';if((type==""&&!!z||type=="="&&z==m[5]||type=="!="&&z!=m[5]||type=="^="&&z&&!z.indexOf(m[5])||type=="$="&&z.substr(z.length-m[5].length)==m[5]||(type=="*="||type=="~=")&&z.indexOf(m[5])>=0)^not)tmp.push(a);}r=tmp;}else if(m[1]==":"&&m[2]=="nth-child"){var merge={},tmp=[],test=/(-?)(\d*)n((?:\+|-)?\d*)/.exec(m[3]=="even"&&"2n"||m[3]=="odd"&&"2n+1"||!/\D/.test(m[3])&&"0n+"+m[3]||m[3]),first=(test[1]+(test[2]||1))-0,last=test[3]-0;for(var i=0,rl=r.length;i<rl;i++){var node=r[i],parentNode=node.parentNode,id=jQuery.data(parentNode);if(!merge[id]){var c=1;for(var n=parentNode.firstChild;n;n=n.nextSibling)if(n.nodeType==1)n.nodeIndex=c++;merge[id]=true;}var add=false;if(first==0){if(node.nodeIndex==last)add=true;}else if((node.nodeIndex-last)%first==0&&(node.nodeIndex-last)/first>=0)add=true;if(add^not)tmp.push(node);}r=tmp;}else{var fn=jQuery.expr[m[1]];if(typeof fn=="object")fn=fn[m[2]];if(typeof fn=="string")fn=eval("false||function(a,i){return "+fn+";}");r=jQuery.grep(r,function(elem,i){return fn(elem,i,m,r);},not);}}return{r:r,t:t};},dir:function(elem,dir){var matched=[],cur=elem[dir];while(cur&&cur!=document){if(cur.nodeType==1)matched.push(cur);cur=cur[dir];}return matched;},nth:function(cur,result,dir,elem){result=result||1;var num=0;for(;cur;cur=cur[dir])if(cur.nodeType==1&&++num==result)break;return cur;},sibling:function(n,elem){var r=[];for(;n;n=n.nextSibling){if(n.nodeType==1&&n!=elem)r.push(n);}return r;}});jQuery.event={add:function(elem,types,handler,data){if(elem.nodeType==3||elem.nodeType==8)return;if(jQuery.browser.msie&&elem.setInterval)elem=window;if(!handler.guid)handler.guid=this.guid++;if(data!=undefined){var fn=handler;handler=this.proxy(fn,function(){return fn.apply(this,arguments);});handler.data=data;}var events=jQuery.data(elem,"events")||jQuery.data(elem,"events",{}),handle=jQuery.data(elem,"handle")||jQuery.data(elem,"handle",function(){if(typeof jQuery!="undefined"&&!jQuery.event.triggered)return jQuery.event.handle.apply(arguments.callee.elem,arguments);});handle.elem=elem;jQuery.each(types.split(/\s+/),function(index,type){var parts=type.split(".");type=parts[0];handler.type=parts[1];var handlers=events[type];if(!handlers){handlers=events[type]={};if(!jQuery.event.special[type]||jQuery.event.special[type].setup.call(elem)===false){if(elem.addEventListener)elem.addEventListener(type,handle,false);else if(elem.attachEvent)elem.attachEvent("on"+type,handle);}}handlers[handler.guid]=handler;jQuery.event.global[type]=true;});elem=null;},guid:1,global:{},remove:function(elem,types,handler){if(elem.nodeType==3||elem.nodeType==8)return;var events=jQuery.data(elem,"events"),ret,index;if(events){if(types==undefined||(typeof types=="string"&&types.charAt(0)=="."))for(var type in events)this.remove(elem,type+(types||""));else{if(types.type){handler=types.handler;types=types.type;}jQuery.each(types.split(/\s+/),function(index,type){var parts=type.split(".");type=parts[0];if(events[type]){if(handler)delete events[type][handler.guid];else
+for(handler in events[type])if(!parts[1]||events[type][handler].type==parts[1])delete events[type][handler];for(ret in events[type])break;if(!ret){if(!jQuery.event.special[type]||jQuery.event.special[type].teardown.call(elem)===false){if(elem.removeEventListener)elem.removeEventListener(type,jQuery.data(elem,"handle"),false);else if(elem.detachEvent)elem.detachEvent("on"+type,jQuery.data(elem,"handle"));}ret=null;delete events[type];}}});}for(ret in events)break;if(!ret){var handle=jQuery.data(elem,"handle");if(handle)handle.elem=null;jQuery.removeData(elem,"events");jQuery.removeData(elem,"handle");}}},trigger:function(type,data,elem,donative,extra){data=jQuery.makeArray(data);if(type.indexOf("!")>=0){type=type.slice(0,-1);var exclusive=true;}if(!elem){if(this.global[type])jQuery("*").add([window,document]).trigger(type,data);}else{if(elem.nodeType==3||elem.nodeType==8)return undefined;var val,ret,fn=jQuery.isFunction(elem[type]||null),event=!data[0]||!data[0].preventDefault;if(event){data.unshift({type:type,target:elem,preventDefault:function(){},stopPropagation:function(){},timeStamp:now()});data[0][expando]=true;}data[0].type=type;if(exclusive)data[0].exclusive=true;var handle=jQuery.data(elem,"handle");if(handle)val=handle.apply(elem,data);if((!fn||(jQuery.nodeName(elem,'a')&&type=="click"))&&elem["on"+type]&&elem["on"+type].apply(elem,data)===false)val=false;if(event)data.shift();if(extra&&jQuery.isFunction(extra)){ret=extra.apply(elem,val==null?data:data.concat(val));if(ret!==undefined)val=ret;}if(fn&&donative!==false&&val!==false&&!(jQuery.nodeName(elem,'a')&&type=="click")){this.triggered=true;try{elem[type]();}catch(e){}}this.triggered=false;}return val;},handle:function(event){var val,ret,namespace,all,handlers;event=arguments[0]=jQuery.event.fix(event||window.event);namespace=event.type.split(".");event.type=namespace[0];namespace=namespace[1];all=!namespace&&!event.exclusive;handlers=(jQuery.data(this,"events")||{})[event.type];for(var j in handlers){var handler=handlers[j];if(all||handler.type==namespace){event.handler=handler;event.data=handler.data;ret=handler.apply(this,arguments);if(val!==false)val=ret;if(ret===false){event.preventDefault();event.stopPropagation();}}}return val;},fix:function(event){if(event[expando]==true)return event;var originalEvent=event;event={originalEvent:originalEvent};var props="altKey attrChange attrName bubbles button cancelable charCode clientX clientY ctrlKey currentTarget data detail eventPhase fromElement handler keyCode metaKey newValue originalTarget pageX pageY prevValue relatedNode relatedTarget screenX screenY shiftKey srcElement target timeStamp toElement type view wheelDelta which".split(" ");for(var i=props.length;i;i--)event[props[i]]=originalEvent[props[i]];event[expando]=true;event.preventDefault=function(){if(originalEvent.preventDefault)originalEvent.preventDefault();originalEvent.returnValue=false;};event.stopPropagation=function(){if(originalEvent.stopPropagation)originalEvent.stopPropagation();originalEvent.cancelBubble=true;};event.timeStamp=event.timeStamp||now();if(!event.target)event.target=event.srcElement||document;if(event.target.nodeType==3)event.target=event.target.parentNode;if(!event.relatedTarget&&event.fromElement)event.relatedTarget=event.fromElement==event.target?event.toElement:event.fromElement;if(event.pageX==null&&event.clientX!=null){var doc=document.documentElement,body=document.body;event.pageX=event.clientX+(doc&&doc.scrollLeft||body&&body.scrollLeft||0)-(doc.clientLeft||0);event.pageY=event.clientY+(doc&&doc.scrollTop||body&&body.scrollTop||0)-(doc.clientTop||0);}if(!event.which&&((event.charCode||event.charCode===0)?event.charCode:event.keyCode))event.which=event.charCode||event.keyCode;if(!event.metaKey&&event.ctrlKey)event.metaKey=event.ctrlKey;if(!event.which&&event.button)event.which=(event.button&1?1:(event.button&2?3:(event.button&4?2:0)));return event;},proxy:function(fn,proxy){proxy.guid=fn.guid=fn.guid||proxy.guid||this.guid++;return proxy;},special:{ready:{setup:function(){bindReady();return;},teardown:function(){return;}},mouseenter:{setup:function(){if(jQuery.browser.msie)return false;jQuery(this).bind("mouseover",jQuery.event.special.mouseenter.handler);return true;},teardown:function(){if(jQuery.browser.msie)return false;jQuery(this).unbind("mouseover",jQuery.event.special.mouseenter.handler);return true;},handler:function(event){if(withinElement(event,this))return true;event.type="mouseenter";return jQuery.event.handle.apply(this,arguments);}},mouseleave:{setup:function(){if(jQuery.browser.msie)return false;jQuery(this).bind("mouseout",jQuery.event.special.mouseleave.handler);return true;},teardown:function(){if(jQuery.browser.msie)return false;jQuery(this).unbind("mouseout",jQuery.event.special.mouseleave.handler);return true;},handler:function(event){if(withinElement(event,this))return true;event.type="mouseleave";return jQuery.event.handle.apply(this,arguments);}}}};jQuery.fn.extend({bind:function(type,data,fn){return type=="unload"?this.one(type,data,fn):this.each(function(){jQuery.event.add(this,type,fn||data,fn&&data);});},one:function(type,data,fn){var one=jQuery.event.proxy(fn||data,function(event){jQuery(this).unbind(event,one);return(fn||data).apply(this,arguments);});return this.each(function(){jQuery.event.add(this,type,one,fn&&data);});},unbind:function(type,fn){return this.each(function(){jQuery.event.remove(this,type,fn);});},trigger:function(type,data,fn){return this.each(function(){jQuery.event.trigger(type,data,this,true,fn);});},triggerHandler:function(type,data,fn){return this[0]&&jQuery.event.trigger(type,data,this[0],false,fn);},toggle:function(fn){var args=arguments,i=1;while(i<args.length)jQuery.event.proxy(fn,args[i++]);return this.click(jQuery.event.proxy(fn,function(event){this.lastToggle=(this.lastToggle||0)%i;event.preventDefault();return args[this.lastToggle++].apply(this,arguments)||false;}));},hover:function(fnOver,fnOut){return this.bind('mouseenter',fnOver).bind('mouseleave',fnOut);},ready:function(fn){bindReady();if(jQuery.isReady)fn.call(document,jQuery);else
+jQuery.readyList.push(function(){return fn.call(this,jQuery);});return this;}});jQuery.extend({isReady:false,readyList:[],ready:function(){if(!jQuery.isReady){jQuery.isReady=true;if(jQuery.readyList){jQuery.each(jQuery.readyList,function(){this.call(document);});jQuery.readyList=null;}jQuery(document).triggerHandler("ready");}}});var readyBound=false;function bindReady(){if(readyBound)return;readyBound=true;if(document.addEventListener&&!jQuery.browser.opera)document.addEventListener("DOMContentLoaded",jQuery.ready,false);if(jQuery.browser.msie&&window==top)(function(){if(jQuery.isReady)return;try{document.documentElement.doScroll("left");}catch(error){setTimeout(arguments.callee,0);return;}jQuery.ready();})();if(jQuery.browser.opera)document.addEventListener("DOMContentLoaded",function(){if(jQuery.isReady)return;for(var i=0;i<document.styleSheets.length;i++)if(document.styleSheets[i].disabled){setTimeout(arguments.callee,0);return;}jQuery.ready();},false);if(jQuery.browser.safari){var numStyles;(function(){if(jQuery.isReady)return;if(document.readyState!="loaded"&&document.readyState!="complete"){setTimeout(arguments.callee,0);return;}if(numStyles===undefined)numStyles=jQuery("style, link[rel=stylesheet]").length;if(document.styleSheets.length!=numStyles){setTimeout(arguments.callee,0);return;}jQuery.ready();})();}jQuery.event.add(window,"load",jQuery.ready);}jQuery.each(("blur,focus,load,resize,scroll,unload,click,dblclick,"+"mousedown,mouseup,mousemove,mouseover,mouseout,change,select,"+"submit,keydown,keypress,keyup,error").split(","),function(i,name){jQuery.fn[name]=function(fn){return fn?this.bind(name,fn):this.trigger(name);};});var withinElement=function(event,elem){var parent=event.relatedTarget;while(parent&&parent!=elem)try{parent=parent.parentNode;}catch(error){parent=elem;}return parent==elem;};jQuery(window).bind("unload",function(){jQuery("*").add(document).unbind();});jQuery.fn.extend({_load:jQuery.fn.load,load:function(url,params,callback){if(typeof url!='string')return this._load(url);var off=url.indexOf(" ");if(off>=0){var selector=url.slice(off,url.length);url=url.slice(0,off);}callback=callback||function(){};var type="GET";if(params)if(jQuery.isFunction(params)){callback=params;params=null;}else{params=jQuery.param(params);type="POST";}var self=this;jQuery.ajax({url:url,type:type,dataType:"html",data:params,complete:function(res,status){if(status=="success"||status=="notmodified")self.html(selector?jQuery("<div/>").append(res.responseText.replace(/<script(.|\s)*?\/script>/g,"")).find(selector):res.responseText);self.each(callback,[res.responseText,status,res]);}});return this;},serialize:function(){return jQuery.param(this.serializeArray());},serializeArray:function(){return this.map(function(){return jQuery.nodeName(this,"form")?jQuery.makeArray(this.elements):this;}).filter(function(){return this.name&&!this.disabled&&(this.checked||/select|textarea/i.test(this.nodeName)||/text|hidden|password/i.test(this.type));}).map(function(i,elem){var val=jQuery(this).val();return val==null?null:val.constructor==Array?jQuery.map(val,function(val,i){return{name:elem.name,value:val};}):{name:elem.name,value:val};}).get();}});jQuery.each("ajaxStart,ajaxStop,ajaxComplete,ajaxError,ajaxSuccess,ajaxSend".split(","),function(i,o){jQuery.fn[o]=function(f){return this.bind(o,f);};});var jsc=now();jQuery.extend({get:function(url,data,callback,type){if(jQuery.isFunction(data)){callback=data;data=null;}return jQuery.ajax({type:"GET",url:url,data:data,success:callback,dataType:type});},getScript:function(url,callback){return jQuery.get(url,null,callback,"script");},getJSON:function(url,data,callback){return jQuery.get(url,data,callback,"json");},post:function(url,data,callback,type){if(jQuery.isFunction(data)){callback=data;data={};}return jQuery.ajax({type:"POST",url:url,data:data,success:callback,dataType:type});},ajaxSetup:function(settings){jQuery.extend(jQuery.ajaxSettings,settings);},ajaxSettings:{url:location.href,global:true,type:"GET",timeout:0,contentType:"application/x-www-form-urlencoded",processData:true,async:true,data:null,username:null,password:null,accepts:{xml:"application/xml, text/xml",html:"text/html",script:"text/javascript, application/javascript",json:"application/json, text/javascript",text:"text/plain",_default:"*/*"}},lastModified:{},ajax:function(s){s=jQuery.extend(true,s,jQuery.extend(true,{},jQuery.ajaxSettings,s));var jsonp,jsre=/=\?(&|$)/g,status,data,type=s.type.toUpperCase();if(s.data&&s.processData&&typeof s.data!="string")s.data=jQuery.param(s.data);if(s.dataType=="jsonp"){if(type=="GET"){if(!s.url.match(jsre))s.url+=(s.url.match(/\?/)?"&":"?")+(s.jsonp||"callback")+"=?";}else if(!s.data||!s.data.match(jsre))s.data=(s.data?s.data+"&":"")+(s.jsonp||"callback")+"=?";s.dataType="json";}if(s.dataType=="json"&&(s.data&&s.data.match(jsre)||s.url.match(jsre))){jsonp="jsonp"+jsc++;if(s.data)s.data=(s.data+"").replace(jsre,"="+jsonp+"$1");s.url=s.url.replace(jsre,"="+jsonp+"$1");s.dataType="script";window[jsonp]=function(tmp){data=tmp;success();complete();window[jsonp]=undefined;try{delete window[jsonp];}catch(e){}if(head)head.removeChild(script);};}if(s.dataType=="script"&&s.cache==null)s.cache=false;if(s.cache===false&&type=="GET"){var ts=now();var ret=s.url.replace(/(\?|&)_=.*?(&|$)/,"$1_="+ts+"$2");s.url=ret+((ret==s.url)?(s.url.match(/\?/)?"&":"?")+"_="+ts:"");}if(s.data&&type=="GET"){s.url+=(s.url.match(/\?/)?"&":"?")+s.data;s.data=null;}if(s.global&&!jQuery.active++)jQuery.event.trigger("ajaxStart");var remote=/^(?:\w+:)?\/\/([^\/?#]+)/;if(s.dataType=="script"&&type=="GET"&&remote.test(s.url)&&remote.exec(s.url)[1]!=location.host){var head=document.getElementsByTagName("head")[0];var script=document.createElement("script");script.src=s.url;if(s.scriptCharset)script.charset=s.scriptCharset;if(!jsonp){var done=false;script.onload=script.onreadystatechange=function(){if(!done&&(!this.readyState||this.readyState=="loaded"||this.readyState=="complete")){done=true;success();complete();head.removeChild(script);}};}head.appendChild(script);return undefined;}var requestDone=false;var xhr=window.ActiveXObject?new ActiveXObject("Microsoft.XMLHTTP"):new XMLHttpRequest();if(s.username)xhr.open(type,s.url,s.async,s.username,s.password);else
+xhr.open(type,s.url,s.async);try{if(s.data)xhr.setRequestHeader("Content-Type",s.contentType);if(s.ifModified)xhr.setRequestHeader("If-Modified-Since",jQuery.lastModified[s.url]||"Thu, 01 Jan 1970 00:00:00 GMT");xhr.setRequestHeader("X-Requested-With","XMLHttpRequest");xhr.setRequestHeader("Accept",s.dataType&&s.accepts[s.dataType]?s.accepts[s.dataType]+", */*":s.accepts._default);}catch(e){}if(s.beforeSend&&s.beforeSend(xhr,s)===false){s.global&&jQuery.active--;xhr.abort();return false;}if(s.global)jQuery.event.trigger("ajaxSend",[xhr,s]);var onreadystatechange=function(isTimeout){if(!requestDone&&xhr&&(xhr.readyState==4||isTimeout=="timeout")){requestDone=true;if(ival){clearInterval(ival);ival=null;}status=isTimeout=="timeout"&&"timeout"||!jQuery.httpSuccess(xhr)&&"error"||s.ifModified&&jQuery.httpNotModified(xhr,s.url)&&"notmodified"||"success";if(status=="success"){try{data=jQuery.httpData(xhr,s.dataType,s.dataFilter);}catch(e){status="parsererror";}}if(status=="success"){var modRes;try{modRes=xhr.getResponseHeader("Last-Modified");}catch(e){}if(s.ifModified&&modRes)jQuery.lastModified[s.url]=modRes;if(!jsonp)success();}else
+jQuery.handleError(s,xhr,status);complete();if(s.async)xhr=null;}};if(s.async){var ival=setInterval(onreadystatechange,13);if(s.timeout>0)setTimeout(function(){if(xhr){xhr.abort();if(!requestDone)onreadystatechange("timeout");}},s.timeout);}try{xhr.send(s.data);}catch(e){jQuery.handleError(s,xhr,null,e);}if(!s.async)onreadystatechange();function success(){if(s.success)s.success(data,status);if(s.global)jQuery.event.trigger("ajaxSuccess",[xhr,s]);}function complete(){if(s.complete)s.complete(xhr,status);if(s.global)jQuery.event.trigger("ajaxComplete",[xhr,s]);if(s.global&&!--jQuery.active)jQuery.event.trigger("ajaxStop");}return xhr;},handleError:function(s,xhr,status,e){if(s.error)s.error(xhr,status,e);if(s.global)jQuery.event.trigger("ajaxError",[xhr,s,e]);},active:0,httpSuccess:function(xhr){try{return!xhr.status&&location.protocol=="file:"||(xhr.status>=200&&xhr.status<300)||xhr.status==304||xhr.status==1223||jQuery.browser.safari&&xhr.status==undefined;}catch(e){}return false;},httpNotModified:function(xhr,url){try{var xhrRes=xhr.getResponseHeader("Last-Modified");return xhr.status==304||xhrRes==jQuery.lastModified[url]||jQuery.browser.safari&&xhr.status==undefined;}catch(e){}return false;},httpData:function(xhr,type,filter){var ct=xhr.getResponseHeader("content-type"),xml=type=="xml"||!type&&ct&&ct.indexOf("xml")>=0,data=xml?xhr.responseXML:xhr.responseText;if(xml&&data.documentElement.tagName=="parsererror")throw"parsererror";if(filter)data=filter(data,type);if(type=="script")jQuery.globalEval(data);if(type=="json")data=eval("("+data+")");return data;},param:function(a){var s=[];if(a.constructor==Array||a.jquery)jQuery.each(a,function(){s.push(encodeURIComponent(this.name)+"="+encodeURIComponent(this.value));});else
+for(var j in a)if(a[j]&&a[j].constructor==Array)jQuery.each(a[j],function(){s.push(encodeURIComponent(j)+"="+encodeURIComponent(this));});else
+s.push(encodeURIComponent(j)+"="+encodeURIComponent(jQuery.isFunction(a[j])?a[j]():a[j]));return s.join("&").replace(/%20/g,"+");}});jQuery.fn.extend({show:function(speed,callback){return speed?this.animate({height:"show",width:"show",opacity:"show"},speed,callback):this.filter(":hidden").each(function(){this.style.display=this.oldblock||"";if(jQuery.css(this,"display")=="none"){var elem=jQuery("<"+this.tagName+" />").appendTo("body");this.style.display=elem.css("display");if(this.style.display=="none")this.style.display="block";elem.remove();}}).end();},hide:function(speed,callback){return speed?this.animate({height:"hide",width:"hide",opacity:"hide"},speed,callback):this.filter(":visible").each(function(){this.oldblock=this.oldblock||jQuery.css(this,"display");this.style.display="none";}).end();},_toggle:jQuery.fn.toggle,toggle:function(fn,fn2){return jQuery.isFunction(fn)&&jQuery.isFunction(fn2)?this._toggle.apply(this,arguments):fn?this.animate({height:"toggle",width:"toggle",opacity:"toggle"},fn,fn2):this.each(function(){jQuery(this)[jQuery(this).is(":hidden")?"show":"hide"]();});},slideDown:function(speed,callback){return this.animate({height:"show"},speed,callback);},slideUp:function(speed,callback){return this.animate({height:"hide"},speed,callback);},slideToggle:function(speed,callback){return this.animate({height:"toggle"},speed,callback);},fadeIn:function(speed,callback){return this.animate({opacity:"show"},speed,callback);},fadeOut:function(speed,callback){return this.animate({opacity:"hide"},speed,callback);},fadeTo:function(speed,to,callback){return this.animate({opacity:to},speed,callback);},animate:function(prop,speed,easing,callback){var optall=jQuery.speed(speed,easing,callback);return this[optall.queue===false?"each":"queue"](function(){if(this.nodeType!=1)return false;var opt=jQuery.extend({},optall),p,hidden=jQuery(this).is(":hidden"),self=this;for(p in prop){if(prop[p]=="hide"&&hidden||prop[p]=="show"&&!hidden)return opt.complete.call(this);if(p=="height"||p=="width"){opt.display=jQuery.css(this,"display");opt.overflow=this.style.overflow;}}if(opt.overflow!=null)this.style.overflow="hidden";opt.curAnim=jQuery.extend({},prop);jQuery.each(prop,function(name,val){var e=new jQuery.fx(self,opt,name);if(/toggle|show|hide/.test(val))e[val=="toggle"?hidden?"show":"hide":val](prop);else{var parts=val.toString().match(/^([+-]=)?([\d+-.]+)(.*)$/),start=e.cur(true)||0;if(parts){var end=parseFloat(parts[2]),unit=parts[3]||"px";if(unit!="px"){self.style[name]=(end||1)+unit;start=((end||1)/e.cur(true))*start;self.style[name]=start+unit;}if(parts[1])end=((parts[1]=="-="?-1:1)*end)+start;e.custom(start,end,unit);}else
+e.custom(start,val,"");}});return true;});},queue:function(type,fn){if(jQuery.isFunction(type)||(type&&type.constructor==Array)){fn=type;type="fx";}if(!type||(typeof type=="string"&&!fn))return queue(this[0],type);return this.each(function(){if(fn.constructor==Array)queue(this,type,fn);else{queue(this,type).push(fn);if(queue(this,type).length==1)fn.call(this);}});},stop:function(clearQueue,gotoEnd){var timers=jQuery.timers;if(clearQueue)this.queue([]);this.each(function(){for(var i=timers.length-1;i>=0;i--)if(timers[i].elem==this){if(gotoEnd)timers[i](true);timers.splice(i,1);}});if(!gotoEnd)this.dequeue();return this;}});var queue=function(elem,type,array){if(elem){type=type||"fx";var q=jQuery.data(elem,type+"queue");if(!q||array)q=jQuery.data(elem,type+"queue",jQuery.makeArray(array));}return q;};jQuery.fn.dequeue=function(type){type=type||"fx";return this.each(function(){var q=queue(this,type);q.shift();if(q.length)q[0].call(this);});};jQuery.extend({speed:function(speed,easing,fn){var opt=speed&&speed.constructor==Object?speed:{complete:fn||!fn&&easing||jQuery.isFunction(speed)&&speed,duration:speed,easing:fn&&easing||easing&&easing.constructor!=Function&&easing};opt.duration=(opt.duration&&opt.duration.constructor==Number?opt.duration:jQuery.fx.speeds[opt.duration])||jQuery.fx.speeds.def;opt.old=opt.complete;opt.complete=function(){if(opt.queue!==false)jQuery(this).dequeue();if(jQuery.isFunction(opt.old))opt.old.call(this);};return opt;},easing:{linear:function(p,n,firstNum,diff){return firstNum+diff*p;},swing:function(p,n,firstNum,diff){return((-Math.cos(p*Math.PI)/2)+0.5)*diff+firstNum;}},timers:[],timerId:null,fx:function(elem,options,prop){this.options=options;this.elem=elem;this.prop=prop;if(!options.orig)options.orig={};}});jQuery.fx.prototype={update:function(){if(this.options.step)this.options.step.call(this.elem,this.now,this);(jQuery.fx.step[this.prop]||jQuery.fx.step._default)(this);if(this.prop=="height"||this.prop=="width")this.elem.style.display="block";},cur:function(force){if(this.elem[this.prop]!=null&&this.elem.style[this.prop]==null)return this.elem[this.prop];var r=parseFloat(jQuery.css(this.elem,this.prop,force));return r&&r>-10000?r:parseFloat(jQuery.curCSS(this.elem,this.prop))||0;},custom:function(from,to,unit){this.startTime=now();this.start=from;this.end=to;this.unit=unit||this.unit||"px";this.now=this.start;this.pos=this.state=0;this.update();var self=this;function t(gotoEnd){return self.step(gotoEnd);}t.elem=this.elem;jQuery.timers.push(t);if(jQuery.timerId==null){jQuery.timerId=setInterval(function(){var timers=jQuery.timers;for(var i=0;i<timers.length;i++)if(!timers[i]())timers.splice(i--,1);if(!timers.length){clearInterval(jQuery.timerId);jQuery.timerId=null;}},13);}},show:function(){this.options.orig[this.prop]=jQuery.attr(this.elem.style,this.prop);this.options.show=true;this.custom(0,this.cur());if(this.prop=="width"||this.prop=="height")this.elem.style[this.prop]="1px";jQuery(this.elem).show();},hide:function(){this.options.orig[this.prop]=jQuery.attr(this.elem.style,this.prop);this.options.hide=true;this.custom(this.cur(),0);},step:function(gotoEnd){var t=now();if(gotoEnd||t>this.options.duration+this.startTime){this.now=this.end;this.pos=this.state=1;this.update();this.options.curAnim[this.prop]=true;var done=true;for(var i in this.options.curAnim)if(this.options.curAnim[i]!==true)done=false;if(done){if(this.options.display!=null){this.elem.style.overflow=this.options.overflow;this.elem.style.display=this.options.display;if(jQuery.css(this.elem,"display")=="none")this.elem.style.display="block";}if(this.options.hide)this.elem.style.display="none";if(this.options.hide||this.options.show)for(var p in this.options.curAnim)jQuery.attr(this.elem.style,p,this.options.orig[p]);}if(done)this.options.complete.call(this.elem);return false;}else{var n=t-this.startTime;this.state=n/this.options.duration;this.pos=jQuery.easing[this.options.easing||(jQuery.easing.swing?"swing":"linear")](this.state,n,0,1,this.options.duration);this.now=this.start+((this.end-this.start)*this.pos);this.update();}return true;}};jQuery.extend(jQuery.fx,{speeds:{slow:600,fast:200,def:400},step:{scrollLeft:function(fx){fx.elem.scrollLeft=fx.now;},scrollTop:function(fx){fx.elem.scrollTop=fx.now;},opacity:function(fx){jQuery.attr(fx.elem.style,"opacity",fx.now);},_default:function(fx){fx.elem.style[fx.prop]=fx.now+fx.unit;}}});jQuery.fn.offset=function(){var left=0,top=0,elem=this[0],results;if(elem)with(jQuery.browser){var parent=elem.parentNode,offsetChild=elem,offsetParent=elem.offsetParent,doc=elem.ownerDocument,safari2=safari&&parseInt(version)<522&&!/adobeair/i.test(userAgent),css=jQuery.curCSS,fixed=css(elem,"position")=="fixed";if(elem.getBoundingClientRect){var box=elem.getBoundingClientRect();add(box.left+Math.max(doc.documentElement.scrollLeft,doc.body.scrollLeft),box.top+Math.max(doc.documentElement.scrollTop,doc.body.scrollTop));add(-doc.documentElement.clientLeft,-doc.documentElement.clientTop);}else{add(elem.offsetLeft,elem.offsetTop);while(offsetParent){add(offsetParent.offsetLeft,offsetParent.offsetTop);if(mozilla&&!/^t(able|d|h)$/i.test(offsetParent.tagName)||safari&&!safari2)border(offsetParent);if(!fixed&&css(offsetParent,"position")=="fixed")fixed=true;offsetChild=/^body$/i.test(offsetParent.tagName)?offsetChild:offsetParent;offsetParent=offsetParent.offsetParent;}while(parent&&parent.tagName&&!/^body|html$/i.test(parent.tagName)){if(!/^inline|table.*$/i.test(css(parent,"display")))add(-parent.scrollLeft,-parent.scrollTop);if(mozilla&&css(parent,"overflow")!="visible")border(parent);parent=parent.parentNode;}if((safari2&&(fixed||css(offsetChild,"position")=="absolute"))||(mozilla&&css(offsetChild,"position")!="absolute"))add(-doc.body.offsetLeft,-doc.body.offsetTop);if(fixed)add(Math.max(doc.documentElement.scrollLeft,doc.body.scrollLeft),Math.max(doc.documentElement.scrollTop,doc.body.scrollTop));}results={top:top,left:left};}function border(elem){add(jQuery.curCSS(elem,"borderLeftWidth",true),jQuery.curCSS(elem,"borderTopWidth",true));}function add(l,t){left+=parseInt(l,10)||0;top+=parseInt(t,10)||0;}return results;};jQuery.fn.extend({position:function(){var left=0,top=0,results;if(this[0]){var offsetParent=this.offsetParent(),offset=this.offset(),parentOffset=/^body|html$/i.test(offsetParent[0].tagName)?{top:0,left:0}:offsetParent.offset();offset.top-=num(this,'marginTop');offset.left-=num(this,'marginLeft');parentOffset.top+=num(offsetParent,'borderTopWidth');parentOffset.left+=num(offsetParent,'borderLeftWidth');results={top:offset.top-parentOffset.top,left:offset.left-parentOffset.left};}return results;},offsetParent:function(){var offsetParent=this[0].offsetParent;while(offsetParent&&(!/^body|html$/i.test(offsetParent.tagName)&&jQuery.css(offsetParent,'position')=='static'))offsetParent=offsetParent.offsetParent;return jQuery(offsetParent);}});jQuery.each(['Left','Top'],function(i,name){var method='scroll'+name;jQuery.fn[method]=function(val){if(!this[0])return;return val!=undefined?this.each(function(){this==window||this==document?window.scrollTo(!i?val:jQuery(window).scrollLeft(),i?val:jQuery(window).scrollTop()):this[method]=val;}):this[0]==window||this[0]==document?self[i?'pageYOffset':'pageXOffset']||jQuery.boxModel&&document.documentElement[method]||document.body[method]:this[0][method];};});jQuery.each(["Height","Width"],function(i,name){var tl=i?"Left":"Top",br=i?"Right":"Bottom";jQuery.fn["inner"+name]=function(){return this[name.toLowerCase()]()+num(this,"padding"+tl)+num(this,"padding"+br);};jQuery.fn["outer"+name]=function(margin){return this["inner"+name]()+num(this,"border"+tl+"Width")+num(this,"border"+br+"Width")+(margin?num(this,"margin"+tl)+num(this,"margin"+br):0);};});})();
\ No newline at end of file
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/js.js	Mon Jan 05 15:54:01 2009 -0800
@@ -0,0 +1,73 @@
+/* ***** BEGIN LICENSE BLOCK *****
+ * Version: MPL 1.1/GPL 2.0/LGPL 2.1
+ *
+ * The contents of this file are subject to the Mozilla Public License Version
+ * 1.1 (the "License"); you may not use this file except in compliance with
+ * the License. You may obtain a copy of the License at
+ * http://www.mozilla.org/MPL/
+ *
+ * Software distributed under the License is distributed on an "AS IS" basis,
+ * WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License
+ * for the specific language governing rights and limitations under the
+ * License.
+ *
+ * The Original Code is the Narcissus JavaScript engine.
+ *
+ * The Initial Developer of the Original Code is
+ * Brendan Eich <brendan@mozilla.org>.
+ * Portions created by the Initial Developer are Copyright (C) 2004
+ * the Initial Developer. All Rights Reserved.
+ *
+ * Contributor(s):
+ *
+ * Alternatively, the contents of this file may be used under the terms of
+ * either the GNU General Public License Version 2 or later (the "GPL"), or
+ * the GNU Lesser General Public License Version 2.1 or later (the "LGPL"),
+ * in which case the provisions of the GPL or the LGPL are applicable instead
+ * of those above. If you wish to allow use of your version of this file only
+ * under the terms of either the GPL or the LGPL, and not to allow others to
+ * use your version of this file under the terms of the MPL, indicate your
+ * decision by deleting the provisions above and replace them with the notice
+ * and other provisions required by the GPL or the LGPL. If you do not delete
+ * the provisions above, a recipient may use your version of this file under
+ * the terms of any one of the MPL, the GPL or the LGPL.
+ *
+ * ***** END LICENSE BLOCK ***** */
+
+/*
+ * Narcissus - JS implemented in JS.
+ *
+ * Native objects and classes implemented metacircularly:
+ *      the global object (singleton)
+ *      eval
+ *      function objects, Function
+ *
+ * SpiderMonkey extensions used:
+ *      catch guards
+ *      const declarations
+ *      get and set functions in object initialisers
+ *      Object.prototype.__defineGetter__
+ *      Object.prototype.__defineSetter__
+ *      Object.prototype.__defineProperty__
+ *      Object.prototype.__proto__
+ *      filename and line number arguments to *Error constructors
+ *      callable regular expression objects
+ *
+ * SpiderMonkey extensions supported metacircularly:
+ *      catch guards
+ *      const declarations
+ *      get and set functions in object initialisers
+ */
+
+/*
+ * Loads a file relative to the calling script's (our) source directory, and not
+ * the directory that the executing shell is being run out of.
+ */
+function my_load(filename) {
+    evaluate(snarf(filename), filename, 1);
+}
+
+my_load('jsdefs.js');
+my_load('jsparse.js');
+my_load('jsexec.js');
+
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/jsdefs.js	Mon Jan 05 15:54:01 2009 -0800
@@ -0,0 +1,169 @@
+/* ***** BEGIN LICENSE BLOCK *****
+ * Version: MPL 1.1/GPL 2.0/LGPL 2.1
+ *
+ * The contents of this file are subject to the Mozilla Public License Version
+ * 1.1 (the "License"); you may not use this file except in compliance with
+ * the License. You may obtain a copy of the License at
+ * http://www.mozilla.org/MPL/
+ *
+ * Software distributed under the License is distributed on an "AS IS" basis,
+ * WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License
+ * for the specific language governing rights and limitations under the
+ * License.
+ *
+ * The Original Code is the Narcissus JavaScript engine.
+ *
+ * The Initial Developer of the Original Code is
+ * Brendan Eich <brendan@mozilla.org>.
+ * Portions created by the Initial Developer are Copyright (C) 2004
+ * the Initial Developer. All Rights Reserved.
+ *
+ * Contributor(s):
+ *
+ * Alternatively, the contents of this file may be used under the terms of
+ * either the GNU General Public License Version 2 or later (the "GPL"), or
+ * the GNU Lesser General Public License Version 2.1 or later (the "LGPL"),
+ * in which case the provisions of the GPL or the LGPL are applicable instead
+ * of those above. If you wish to allow use of your version of this file only
+ * under the terms of either the GPL or the LGPL, and not to allow others to
+ * use your version of this file under the terms of the MPL, indicate your
+ * decision by deleting the provisions above and replace them with the notice
+ * and other provisions required by the GPL or the LGPL. If you do not delete
+ * the provisions above, a recipient may use your version of this file under
+ * the terms of any one of the MPL, the GPL or the LGPL.
+ *
+ * ***** END LICENSE BLOCK ***** */
+
+/*
+ * Narcissus - JS implemented in JS.
+ *
+ * Well-known constants and lookup tables.  Many consts are generated from the
+ * tokens table via eval to minimize redundancy, so consumers must be compiled
+ * separately to take advantage of the simple switch-case constant propagation
+ * done by SpiderMonkey.
+ */
+const GLOBAL = this;
+
+var tokens = [
+    // End of source.
+    "END",
+
+    // Operators and punctuators.  Some pair-wise order matters, e.g. (+, -)
+    // and (UNARY_PLUS, UNARY_MINUS).
+    "\n", ";",
+    ",",
+    "=",
+    "?", ":", "CONDITIONAL",
+    "||",
+    "&&",
+    "|",
+    "^",
+    "&",
+    "==", "!=", "===", "!==",
+    "<", "<=", ">=", ">",
+    "<<", ">>", ">>>",
+    "+", "-",
+    "*", "/", "%",
+    "!", "~", "UNARY_PLUS", "UNARY_MINUS",
+    "++", "--",
+    ".",
+    "[", "]",
+    "{", "}",
+    "(", ")",
+
+    // Nonterminal tree node type codes.
+    "SCRIPT", "BLOCK", "LABEL", "FOR_IN", "CALL", "NEW_WITH_ARGS", "INDEX",
+    "ARRAY_INIT", "OBJECT_INIT", "PROPERTY_INIT", "GETTER", "SETTER",
+    "GROUP", "LIST",
+
+    // Terminals.
+    "IDENTIFIER", "NUMBER", "STRING", "REGEXP",
+
+    // Keywords.
+    "break",
+    "case", "catch", "const", "continue",
+    "debugger", "default", "delete", "do",
+    "else", "enum",
+    "false", "finally", "for", "function",
+    "if", "in", "instanceof",
+    "new", "null",
+    "return",
+    "switch",
+    "this", "throw", "true", "try", "typeof",
+    "var", "void",
+    "while", "with",
+];
+
+// Operator and punctuator mapping from token to tree node type name.
+// NB: superstring tokens (e.g., ++) must come before their substring token
+// counterparts (+ in the example), so that the opRegExp regular expression
+// synthesized from this list makes the longest possible match.
+var opTypeNames = {
+    '\n':   "NEWLINE",
+    ';':    "SEMICOLON",
+    ',':    "COMMA",
+    '?':    "HOOK",
+    ':':    "COLON",
+    '||':   "OR",
+    '&&':   "AND",
+    '|':    "BITWISE_OR",
+    '^':    "BITWISE_XOR",
+    '&':    "BITWISE_AND",
+    '===':  "STRICT_EQ",
+    '==':   "EQ",
+    '=':    "ASSIGN",
+    '!==':  "STRICT_NE",
+    '!=':   "NE",
+    '<<':   "LSH",
+    '<=':   "LE",
+    '<':    "LT",
+    '>>>':  "URSH",
+    '>>':   "RSH",
+    '>=':   "GE",
+    '>':    "GT",
+    '++':   "INCREMENT",
+    '--':   "DECREMENT",
+    '+':    "PLUS",
+    '-':    "MINUS",
+    '*':    "MUL",
+    '/':    "DIV",
+    '%':    "MOD",
+    '!':    "NOT",
+    '~':    "BITWISE_NOT",
+    '.':    "DOT",
+    '[':    "LEFT_BRACKET",
+    ']':    "RIGHT_BRACKET",
+    '{':    "LEFT_CURLY",
+    '}':    "RIGHT_CURLY",
+    '(':    "LEFT_PAREN",
+    ')':    "RIGHT_PAREN"
+};
+
+// Hash of keyword identifier to tokens index.  NB: we must null __proto__ to
+// avoid toString, etc. namespace pollution.
+var keywords = {__proto__: null};
+
+// Define const END, etc., based on the token names.  Also map name to index.
+var consts = "const ";
+for (var i = 0, j = tokens.length; i < j; i++) {
+    if (i > 0)
+        consts += ", ";
+    var t = tokens[i];
+    if (/^[a-z]/.test(t)) {
+        consts += t.toUpperCase();
+        keywords[t] = i;
+    } else {
+        consts += (/^\W/.test(t) ? opTypeNames[t] : t);
+    }
+    consts += " = " + i;
+    tokens[t] = i;
+}
+eval(consts + ";");
+
+// Map assignment operators to their indexes in the tokens array.
+var assignOps = ['|', '^', '&', '<<', '>>', '>>>', '+', '-', '*', '/', '%'];
+
+for (i = 0, j = assignOps.length; i < j; i++) {
+    t = assignOps[i];
+    assignOps[t] = tokens[t];
+}
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/jsexec.js	Mon Jan 05 15:54:01 2009 -0800
@@ -0,0 +1,944 @@
+/* ***** BEGIN LICENSE BLOCK *****
+ * vim: set ts=4 sw=4 et tw=80:
+ *
+ * Version: MPL 1.1/GPL 2.0/LGPL 2.1
+ *
+ * The contents of this file are subject to the Mozilla Public License Version
+ * 1.1 (the "License"); you may not use this file except in compliance with
+ * the License. You may obtain a copy of the License at
+ * http://www.mozilla.org/MPL/
+ *
+ * Software distributed under the License is distributed on an "AS IS" basis,
+ * WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License
+ * for the specific language governing rights and limitations under the
+ * License.
+ *
+ * The Original Code is the Narcissus JavaScript engine.
+ *
+ * The Initial Developer of the Original Code is
+ * Brendan Eich <brendan@mozilla.org>.
+ * Portions created by the Initial Developer are Copyright (C) 2004
+ * the Initial Developer. All Rights Reserved.
+ *
+ * Contributor(s):
+ *
+ * Alternatively, the contents of this file may be used under the terms of
+ * either the GNU General Public License Version 2 or later (the "GPL"), or
+ * the GNU Lesser General Public License Version 2.1 or later (the "LGPL"),
+ * in which case the provisions of the GPL or the LGPL are applicable instead
+ * of those above. If you wish to allow use of your version of this file only
+ * under the terms of either the GPL or the LGPL, and not to allow others to
+ * use your version of this file under the terms of the MPL, indicate your
+ * decision by deleting the provisions above and replace them with the notice
+ * and other provisions required by the GPL or the LGPL. If you do not delete
+ * the provisions above, a recipient may use your version of this file under
+ * the terms of any one of the MPL, the GPL or the LGPL.
+ *
+ * ***** END LICENSE BLOCK ***** */
+
+/*
+ * Narcissus - JS implemented in JS.
+ *
+ * Execution of parse trees.
+ *
+ * Standard classes except for eval, Function, Array, and String are borrowed
+ * from the host JS environment.  Function is metacircular.  Array and String
+ * are reflected via wrapping the corresponding native constructor and adding
+ * an extra level of prototype-based delegation.
+ */
+
+const GLOBAL_CODE = 0, EVAL_CODE = 1, FUNCTION_CODE = 2;
+
+function ExecutionContext(type) {
+    this.type = type;
+}
+
+var global = {
+    // Value properties.
+    NaN: NaN, Infinity: Infinity, undefined: undefined,
+
+    // Function properties.
+    eval: function eval(s) {
+        if (typeof s != "string")
+            return s;
+
+        var x = ExecutionContext.current;
+        var x2 = new ExecutionContext(EVAL_CODE);
+        x2.thisObject = x.thisObject;
+        x2.caller = x.caller;
+        x2.callee = x.callee;
+        x2.scope = x.scope;
+        ExecutionContext.current = x2;
+        try {
+            execute(parse(s), x2);
+        } catch (e if e == THROW) {
+            x.result = x2.result;
+            throw e;
+        } finally {
+            ExecutionContext.current = x;
+        }
+        return x2.result;
+    },
+    parseInt: parseInt, parseFloat: parseFloat,
+    isNaN: isNaN, isFinite: isFinite,
+    decodeURI: decodeURI, encodeURI: encodeURI,
+    decodeURIComponent: decodeURIComponent,
+    encodeURIComponent: encodeURIComponent,
+
+    // Class constructors.  Where ECMA-262 requires C.length == 1, we declare
+    // a dummy formal parameter.
+    Object: Object,
+    Function: function Function(dummy) {
+        var p = "", b = "", n = arguments.length;
+        if (n) {
+            var m = n - 1;
+            if (m) {
+                p += arguments[0];
+                for (var k = 1; k < m; k++)
+                    p += "," + arguments[k];
+            }
+            b += arguments[m];
+        }
+
+        // XXX We want to pass a good file and line to the tokenizer.
+        // Note the anonymous name to maintain parity with Spidermonkey.
+        var t = new Tokenizer("anonymous(" + p + ") {" + b + "}");
+
+        // NB: Use the STATEMENT_FORM constant since we don't want to push this
+        // function onto the null compilation context.
+        var f = FunctionDefinition(t, null, false, STATEMENT_FORM);
+        var s = {object: global, parent: null};
+        return new FunctionObject(f, s);
+    },
+    Array: function Array(dummy) {
+        // Array when called as a function acts as a constructor.
+        return GLOBAL.Array.apply(this, arguments);
+    },
+    String: function String(s) {
+        // Called as function or constructor: convert argument to string type.
+        s = arguments.length ? "" + s : "";
+        if (this instanceof String) {
+            // Called as constructor: save the argument as the string value
+            // of this String object and return this object.
+            this.value = s;
+            return this;
+        }
+        return s;
+    },
+    Boolean: Boolean, Number: Number, Date: Date, RegExp: RegExp,
+    Error: Error, EvalError: EvalError, RangeError: RangeError,
+    ReferenceError: ReferenceError, SyntaxError: SyntaxError,
+    TypeError: TypeError, URIError: URIError,
+
+    // Other properties.
+    Math: Math,
+
+    // Extensions to ECMA.
+    snarf: snarf, evaluate: evaluate,
+    load: function load(s) {
+        if (typeof s != "string")
+            return s;
+
+        evaluate(snarf(s), s, 1)
+    },
+    print: print, version: null
+};
+
+// Helper to avoid Object.prototype.hasOwnProperty polluting scope objects.
+function hasDirectProperty(o, p) {
+    return Object.prototype.hasOwnProperty.call(o, p);
+}
+
+// Reflect a host class into the target global environment by delegation.
+function reflectClass(name, proto) {
+    var gctor = global[name];
+    gctor.__defineProperty__('prototype', proto, true, true, true);
+    proto.__defineProperty__('constructor', gctor, false, false, true);
+    return proto;
+}
+
+// Reflect Array -- note that all Array methods are generic.
+reflectClass('Array', new Array);
+
+// Reflect String, overriding non-generic methods.
+var gSp = reflectClass('String', new String);
+gSp.toSource = function () { return this.value.toSource(); };
+gSp.toString = function () { return this.value; };
+gSp.valueOf  = function () { return this.value; };
+global.String.fromCharCode = String.fromCharCode;
+
+var XCp = ExecutionContext.prototype;
+ExecutionContext.current = XCp.caller = XCp.callee = null;
+XCp.scope = {object: global, parent: null};
+XCp.thisObject = global;
+XCp.result = undefined;
+XCp.target = null;
+XCp.ecmaStrictMode = false;
+
+function Reference(base, propertyName, node) {
+    this.base = base;
+    this.propertyName = propertyName;
+    this.node = node;
+}
+
+Reference.prototype.toString = function () { return this.node.getSource(); }
+
+function getValue(v) {
+    if (v instanceof Reference) {
+        if (!v.base) {
+            throw new ReferenceError(v.propertyName + " is not defined",
+                                     v.node.filename, v.node.lineno);
+        }
+        return v.base[v.propertyName];
+    }
+    return v;
+}
+
+function putValue(v, w, vn) {
+    if (v instanceof Reference)
+        return (v.base || global)[v.propertyName] = w;
+    throw new ReferenceError("Invalid assignment left-hand side",
+                             vn.filename, vn.lineno);
+}
+
+function isPrimitive(v) {
+    var t = typeof v;
+    return (t == "object") ? v === null : t != "function";
+}
+
+function isObject(v) {
+    var t = typeof v;
+    return (t == "object") ? v !== null : t == "function";
+}
+
+// If r instanceof Reference, v == getValue(r); else v === r.  If passed, rn
+// is the node whose execute result was r.
+function toObject(v, r, rn) {
+    switch (typeof v) {
+      case "boolean":
+        return new global.Boolean(v);
+      case "number":
+        return new global.Number(v);
+      case "string":
+        return new global.String(v);
+      case "function":
+        return v;
+      case "object":
+        if (v !== null)
+            return v;
+    }
+    var message = r + " (type " + (typeof v) + ") has no properties";
+    throw rn ? new TypeError(message, rn.filename, rn.lineno)
+             : new TypeError(message);
+}
+
+function execute(n, x) {
+    var a, f, i, j, r, s, t, u, v;
+
+    switch (n.type) {
+      case FUNCTION:
+        if (n.functionForm != DECLARED_FORM) {
+            if (!n.name || n.functionForm == STATEMENT_FORM) {
+                v = new FunctionObject(n, x.scope);
+                if (n.functionForm == STATEMENT_FORM)
+                    x.scope.object.__defineProperty__(n.name, v, true);
+            } else {
+                t = new Object;
+                x.scope = {object: t, parent: x.scope};
+                try {
+                    v = new FunctionObject(n, x.scope);
+                    t.__defineProperty__(n.name, v, true, true);
+                } finally {
+                    x.scope = x.scope.parent;
+                }
+            }
+        }
+        break;
+
+      case SCRIPT:
+        t = x.scope.object;
+        a = n.funDecls;
+        for (i = 0, j = a.length; i < j; i++) {
+            s = a[i].name;
+            f = new FunctionObject(a[i], x.scope);
+            t.__defineProperty__(s, f, x.type != EVAL_CODE);
+        }
+        a = n.varDecls;
+        for (i = 0, j = a.length; i < j; i++) {
+            u = a[i];
+            s = u.name;
+            if (u.readOnly && hasDirectProperty(t, s)) {
+                throw new TypeError("Redeclaration of const " + s,
+                                    u.filename, u.lineno);
+            }
+            if (u.readOnly || !hasDirectProperty(t, s)) {
+                t.__defineProperty__(s, undefined, x.type != EVAL_CODE,
+                                     u.readOnly);
+            }
+        }
+        // FALL THROUGH
+
+      case BLOCK:
+        for (i = 0, j = n.length; i < j; i++)
+            execute(n[i], x);
+        break;
+
+      case IF:
+        if (getValue(execute(n.condition, x)))
+            execute(n.thenPart, x);
+        else if (n.elsePart)
+            execute(n.elsePart, x);
+        break;
+
+      case SWITCH:
+        s = getValue(execute(n.discriminant, x));
+        a = n.cases;
+        var matchDefault = false;
+      switch_loop:
+        for (i = 0, j = a.length; ; i++) {
+            if (i == j) {
+                if (n.defaultIndex >= 0) {
+                    i = n.defaultIndex - 1; // no case matched, do default
+                    matchDefault = true;
+                    continue;
+                }
+                break;                      // no default, exit switch_loop
+            }
+            t = a[i];                       // next case (might be default!)
+            if (t.type == CASE) {
+                u = getValue(execute(t.caseLabel, x));
+            } else {
+                if (!matchDefault)          // not defaulting, skip for now
+                    continue;
+                u = s;                      // force match to do default
+            }
+            if (u === s) {
+                for (;;) {                  // this loop exits switch_loop
+                    if (t.statements.length) {
+                        try {
+                            execute(t.statements, x);
+                        } catch (e if e == BREAK && x.target == n) {
+                            break switch_loop;
+                        }
+                    }
+                    if (++i == j)
+                        break switch_loop;
+                    t = a[i];
+                }
+                // NOT REACHED
+            }
+        }
+        break;
+
+      case FOR:
+        n.setup && getValue(execute(n.setup, x));
+        // FALL THROUGH
+      case WHILE:
+        while (!n.condition || getValue(execute(n.condition, x))) {
+            try {
+                execute(n.body, x);
+            } catch (e if e == BREAK && x.target == n) {
+                break;
+            } catch (e if e == CONTINUE && x.target == n) {
+                continue;
+            }
+            n.update && getValue(execute(n.update, x));
+        }
+        break;
+
+      case FOR_IN:
+        u = n.varDecl;
+        if (u)
+            execute(u, x);
+        r = n.iterator;
+        s = execute(n.object, x);
+        v = getValue(s);
+
+        // ECMA deviation to track extant browser JS implementation behavior.
+        t = (v == null && !x.ecmaStrictMode) ? v : toObject(v, s, n.object);
+        a = [];
+        for (i in t)
+            a.push(i);
+        for (i = 0, j = a.length; i < j; i++) {
+            putValue(execute(r, x), a[i], r);
+            try {
+                execute(n.body, x);
+            } catch (e if e == BREAK && x.target == n) {
+                break;
+            } catch (e if e == CONTINUE && x.target == n) {
+                continue;
+            }
+        }
+        break;
+
+      case DO:
+        do {
+            try {
+                execute(n.body, x);
+            } catch (e if e == BREAK && x.target == n) {
+                break;
+            } catch (e if e == CONTINUE && x.target == n) {
+                continue;
+            }
+        } while (getValue(execute(n.condition, x)));
+        break;
+
+      case BREAK:
+      case CONTINUE:
+        x.target = n.target;
+        throw n.type;
+
+      case TRY:
+        try {
+            execute(n.tryBlock, x);
+        } catch (e if e == THROW && (j = n.catchClauses.length)) {
+            e = x.result;
+            x.result = undefined;
+            for (i = 0; ; i++) {
+                if (i == j) {
+                    x.result = e;
+                    throw THROW;
+                }
+                t = n.catchClauses[i];
+                x.scope = {object: {}, parent: x.scope};
+                x.scope.object.__defineProperty__(t.varName, e, true);
+                try {
+                    if (t.guard && !getValue(execute(t.guard, x)))
+                        continue;
+                    execute(t.block, x);
+                    break;
+                } finally {
+                    x.scope = x.scope.parent;
+                }
+            }
+        } finally {
+            if (n.finallyBlock)
+                execute(n.finallyBlock, x);
+        }
+        break;
+
+      case THROW:
+        x.result = getValue(execute(n.exception, x));
+        throw THROW;
+
+      case RETURN:
+        x.result = getValue(execute(n.value, x));
+        throw RETURN;
+
+      case WITH:
+        r = execute(n.object, x);
+        t = toObject(getValue(r), r, n.object);
+        x.scope = {object: t, parent: x.scope};
+        try {
+            execute(n.body, x);
+        } finally {
+            x.scope = x.scope.parent;
+        }
+        break;
+
+      case VAR:
+      case CONST:
+        for (i = 0, j = n.length; i < j; i++) {
+            u = n[i].initializer;
+            if (!u)
+                continue;
+            t = n[i].name;
+            for (s = x.scope; s; s = s.parent) {
+                if (hasDirectProperty(s.object, t))
+                    break;
+            }
+            u = getValue(execute(u, x));
+            if (n.type == CONST)
+                s.object.__defineProperty__(t, u, x.type != EVAL_CODE, true);
+            else
+                s.object[t] = u;
+        }
+        break;
+
+      case DEBUGGER:
+        throw "NYI: " + tokens[n.type];
+
+      case SEMICOLON:
+        if (n.expression)
+            x.result = getValue(execute(n.expression, x));
+        break;
+
+      case LABEL:
+        try {
+            execute(n.statement, x);
+        } catch (e if e == BREAK && x.target == n) {
+        }
+        break;
+
+      case COMMA:
+        for (i = 0, j = n.length; i < j; i++)
+            v = getValue(execute(n[i], x));
+        break;
+
+      case ASSIGN:
+        r = execute(n[0], x);
+        t = n[0].assignOp;
+        if (t)
+            u = getValue(r);
+        v = getValue(execute(n[1], x));
+        if (t) {
+            switch (t) {
+              case BITWISE_OR:  v = u | v; break;
+              case BITWISE_XOR: v = u ^ v; break;
+              case BITWISE_AND: v = u & v; break;
+              case LSH:         v = u << v; break;
+              case RSH:         v = u >> v; break;
+              case URSH:        v = u >>> v; break;
+              case PLUS:        v = u + v; break;
+              case MINUS:       v = u - v; break;
+              case MUL:         v = u * v; break;
+              case DIV:         v = u / v; break;
+              case MOD:         v = u % v; break;
+            }
+        }
+        putValue(r, v, n[0]);
+        break;
+
+      case HOOK:
+        v = getValue(execute(n[0], x)) ? getValue(execute(n[1], x))
+                                       : getValue(execute(n[2], x));
+        break;
+
+      case OR:
+        v = getValue(execute(n[0], x)) || getValue(execute(n[1], x));
+        break;
+
+      case AND:
+        v = getValue(execute(n[0], x)) && getValue(execute(n[1], x));
+        break;
+
+      case BITWISE_OR:
+        v = getValue(execute(n[0], x)) | getValue(execute(n[1], x));
+        break;
+
+      case BITWISE_XOR:
+        v = getValue(execute(n[0], x)) ^ getValue(execute(n[1], x));
+        break;
+
+      case BITWISE_AND:
+        v = getValue(execute(n[0], x)) & getValue(execute(n[1], x));
+        break;
+
+      case EQ:
+        v = getValue(execute(n[0], x)) == getValue(execute(n[1], x));
+        break;
+
+      case NE:
+        v = getValue(execute(n[0], x)) != getValue(execute(n[1], x));
+        break;
+
+      case STRICT_EQ:
+        v = getValue(execute(n[0], x)) === getValue(execute(n[1], x));
+        break;
+
+      case STRICT_NE:
+        v = getValue(execute(n[0], x)) !== getValue(execute(n[1], x));
+        break;
+
+      case LT:
+        v = getValue(execute(n[0], x)) < getValue(execute(n[1], x));
+        break;
+
+      case LE:
+        v = getValue(execute(n[0], x)) <= getValue(execute(n[1], x));
+        break;
+
+      case GE:
+        v = getValue(execute(n[0], x)) >= getValue(execute(n[1], x));
+        break;
+
+      case GT:
+        v = getValue(execute(n[0], x)) > getValue(execute(n[1], x));
+        break;
+
+      case IN:
+        v = getValue(execute(n[0], x)) in getValue(execute(n[1], x));
+        break;
+
+      case INSTANCEOF:
+        t = getValue(execute(n[0], x));
+        u = getValue(execute(n[1], x));
+        if (isObject(u) && typeof u.__hasInstance__ == "function")
+            v = u.__hasInstance__(t);
+        else
+            v = t instanceof u;
+        break;
+
+      case LSH:
+        v = getValue(execute(n[0], x)) << getValue(execute(n[1], x));
+        break;
+
+      case RSH:
+        v = getValue(execute(n[0], x)) >> getValue(execute(n[1], x));
+        break;
+
+      case URSH:
+        v = getValue(execute(n[0], x)) >>> getValue(execute(n[1], x));
+        break;
+
+      case PLUS:
+        v = getValue(execute(n[0], x)) + getValue(execute(n[1], x));
+        break;
+
+      case MINUS:
+        v = getValue(execute(n[0], x)) - getValue(execute(n[1], x));
+        break;
+
+      case MUL:
+        v = getValue(execute(n[0], x)) * getValue(execute(n[1], x));
+        break;
+
+      case DIV:
+        v = getValue(execute(n[0], x)) / getValue(execute(n[1], x));
+        break;
+
+      case MOD:
+        v = getValue(execute(n[0], x)) % getValue(execute(n[1], x));
+        break;
+
+      case DELETE:
+        t = execute(n[0], x);
+        v = !(t instanceof Reference) || delete t.base[t.propertyName];
+        break;
+
+      case VOID:
+        getValue(execute(n[0], x));
+        break;
+
+      case TYPEOF:
+        t = execute(n[0], x);
+        if (t instanceof Reference)
+            t = t.base ? t.base[t.propertyName] : undefined;
+        v = typeof t;
+        break;
+
+      case NOT:
+        v = !getValue(execute(n[0], x));
+        break;
+
+      case BITWISE_NOT:
+        v = ~getValue(execute(n[0], x));
+        break;
+
+      case UNARY_PLUS:
+        v = +getValue(execute(n[0], x));
+        break;
+
+      case UNARY_MINUS:
+        v = -getValue(execute(n[0], x));
+        break;
+
+      case INCREMENT:
+      case DECREMENT:
+        t = execute(n[0], x);
+        u = Number(getValue(t));
+        if (n.postfix)
+            v = u;
+        putValue(t, (n.type == INCREMENT) ? ++u : --u, n[0]);
+        if (!n.postfix)
+            v = u;
+        break;
+
+      case DOT:
+        r = execute(n[0], x);
+        t = getValue(r);
+        u = n[1].value;
+        v = new Reference(toObject(t, r, n[0]), u, n);
+        break;
+
+      case INDEX:
+        r = execute(n[0], x);
+        t = getValue(r);
+        u = getValue(execute(n[1], x));
+        v = new Reference(toObject(t, r, n[0]), String(u), n);
+        break;
+
+      case LIST:
+        // Curse ECMA for specifying that arguments is not an Array object!
+        v = {};
+        for (i = 0, j = n.length; i < j; i++) {
+            u = getValue(execute(n[i], x));
+            v.__defineProperty__(i, u, false, false, true);
+        }
+        v.__defineProperty__('length', i, false, false, true);
+        break;
+
+      case CALL:
+        r = execute(n[0], x);
+        a = execute(n[1], x);
+        f = getValue(r);
+        if (isPrimitive(f) || typeof f.__call__ != "function") {
+            throw new TypeError(r + " is not callable",
+                                n[0].filename, n[0].lineno);
+        }
+        t = (r instanceof Reference) ? r.base : null;
+        if (t instanceof Activation)
+            t = null;
+        v = f.__call__(t, a, x);
+        break;
+
+      case NEW:
+      case NEW_WITH_ARGS:
+        r = execute(n[0], x);
+        f = getValue(r);
+        if (n.type == NEW) {
+            a = {};
+            a.__defineProperty__('length', 0, false, false, true);
+        } else {
+            a = execute(n[1], x);
+        }
+        if (isPrimitive(f) || typeof f.__construct__ != "function") {
+            throw new TypeError(r + " is not a constructor",
+                                n[0].filename, n[0].lineno);
+        }
+        v = f.__construct__(a, x);
+        break;
+
+      case ARRAY_INIT:
+        v = [];
+        for (i = 0, j = n.length; i < j; i++) {
+            if (n[i])
+                v[i] = getValue(execute(n[i], x));
+        }
+        v.length = j;
+        break;
+
+      case OBJECT_INIT:
+        v = {};
+        for (i = 0, j = n.length; i < j; i++) {
+            t = n[i];
+            if (t.type == PROPERTY_INIT) {
+                v[t[0].value] = getValue(execute(t[1], x));
+            } else {
+                f = new FunctionObject(t, x.scope);
+                u = (t.type == GETTER) ? '__defineGetter__'
+                                       : '__defineSetter__';
+                v[u](t.name, thunk(f, x));
+            }
+        }
+        break;
+
+      case NULL:
+        v = null;
+        break;
+
+      case THIS:
+        v = x.thisObject;
+        break;
+
+      case TRUE:
+        v = true;
+        break;
+
+      case FALSE:
+        v = false;
+        break;
+
+      case IDENTIFIER:
+        for (s = x.scope; s; s = s.parent) {
+            if (n.value in s.object)
+                break;
+        }
+        v = new Reference(s && s.object, n.value, n);
+        break;
+
+      case NUMBER:
+      case STRING:
+      case REGEXP:
+        v = n.value;
+        break;
+
+      case GROUP:
+        v = execute(n[0], x);
+        break;
+
+      default:
+        throw "PANIC: unknown operation " + n.type + ": " + uneval(n);
+    }
+
+    return v;
+}
+
+function Activation(f, a) {
+    for (var i = 0, j = f.params.length; i < j; i++)
+        this.__defineProperty__(f.params[i], a[i], true);
+    this.__defineProperty__('arguments', a, true);
+}
+
+// Null Activation.prototype's proto slot so that Object.prototype.* does not
+// pollute the scope of heavyweight functions.  Also delete its 'constructor'
+// property so that it doesn't pollute function scopes.  But first, we must
+// copy __defineProperty__ down from Object.prototype.
+
+Activation.prototype.__defineProperty__ = Object.prototype.__defineProperty__;
+Activation.prototype.__proto__ = null;
+delete Activation.prototype.constructor;
+
+function FunctionObject(node, scope) {
+    this.node = node;
+    this.scope = scope;
+    this.__defineProperty__('length', node.params.length, true, true, true);
+    var proto = {};
+    this.__defineProperty__('prototype', proto, true);
+    proto.__defineProperty__('constructor', this, false, false, true);
+}
+
+var FOp = FunctionObject.prototype = {
+    // Internal methods.
+    __call__: function (t, a, x) {
+        var x2 = new ExecutionContext(FUNCTION_CODE);
+        x2.thisObject = t || global;
+        x2.caller = x;
+        x2.callee = this;
+        a.__defineProperty__('callee', this, false, false, true);
+        var f = this.node;
+        x2.scope = {object: new Activation(f, a), parent: this.scope};
+
+        ExecutionContext.current = x2;
+        try {
+            execute(f.body, x2);
+        } catch (e if e == RETURN) {
+            return x2.result;
+        } catch (e if e == THROW) {
+            x.result = x2.result;
+            throw THROW;
+        } finally {
+            ExecutionContext.current = x;
+        }
+        return undefined;
+    },
+
+    __construct__: function (a, x) {
+        var o = new Object;
+        var p = this.prototype;
+        if (isObject(p))
+            o.__proto__ = p;
+        // else o.__proto__ defaulted to Object.prototype
+
+        var v = this.__call__(o, a, x);
+        if (isObject(v))
+            return v;
+        return o;
+    },
+
+    __hasInstance__: function (v) {
+        if (isPrimitive(v))
+            return false;
+        var p = this.prototype;
+        if (isPrimitive(p)) {
+            throw new TypeError("'prototype' property is not an object",
+                                this.node.filename, this.node.lineno);
+        }
+        var o;
+        while ((o = v.__proto__)) {
+            if (o == p)
+                return true;
+            v = o;
+        }
+        return false;
+    },
+
+    // Standard methods.
+    toString: function () {
+        return this.node.getSource();
+    },
+
+    apply: function (t, a) {
+        // Curse ECMA again!
+        if (typeof this.__call__ != "function") {
+            throw new TypeError("Function.prototype.apply called on" +
+                                " uncallable object");
+        }
+
+        if (t === undefined || t === null)
+            t = global;
+        else if (typeof t != "object")
+            t = toObject(t, t);
+
+        if (a === undefined || a === null) {
+            a = {};
+            a.__defineProperty__('length', 0, false, false, true);
+        } else if (a instanceof Array) {
+            var v = {};
+            for (var i = 0, j = a.length; i < j; i++)
+                v.__defineProperty__(i, a[i], false, false, true);
+            v.__defineProperty__('length', i, false, false, true);
+            a = v;
+        } else if (!(a instanceof Object)) {
+            // XXX check for a non-arguments object
+            throw new TypeError("Second argument to Function.prototype.apply" +
+                                " must be an array or arguments object",
+                                this.node.filename, this.node.lineno);
+        }
+
+        return this.__call__(t, a, ExecutionContext.current);
+    },
+
+    call: function (t) {
+        // Curse ECMA a third time!
+        var a = Array.prototype.splice.call(arguments, 1);
+        return this.apply(t, a);
+    }
+};
+
+// Connect Function.prototype and Function.prototype.constructor in global.
+reflectClass('Function', FOp);
+
+// Help native and host-scripted functions be like FunctionObjects.
+var Fp = Function.prototype;
+var REp = RegExp.prototype;
+
+if (!('__call__' in Fp)) {
+    Fp.__defineProperty__('__call__', function (t, a, x) {
+        // Curse ECMA yet again!
+        a = Array.prototype.splice.call(a, 0, a.length);
+        return this.apply(t, a);
+    }, true, true, true);
+
+    REp.__defineProperty__('__call__', function (t, a, x) {
+        a = Array.prototype.splice.call(a, 0, a.length);
+        return this.exec.apply(this, a);
+    }, true, true, true);
+
+    Fp.__defineProperty__('__construct__', function (a, x) {
+        a = Array.prototype.splice.call(a, 0, a.length);
+        return this.__applyConstructor__(a);
+    }, true, true, true);
+
+    // Since we use native functions such as Date along with host ones such
+    // as global.eval, we want both to be considered instances of the native
+    // Function constructor.
+    Fp.__defineProperty__('__hasInstance__', function (v) {
+        return v instanceof Function || v instanceof global.Function;
+    }, true, true, true);
+}
+
+function thunk(f, x) {
+    return function () { return f.__call__(this, arguments, x); };
+}
+
+function evaluate(s, f, l) {
+    if (typeof s != "string")
+        return s;
+
+    var x = ExecutionContext.current;
+    var x2 = new ExecutionContext(GLOBAL_CODE);
+    ExecutionContext.current = x2;
+    try {
+        execute(parse(s, f, l), x2);
+    } catch (e if e == THROW) {
+        if (x) {
+            x.result = x2.result;
+            throw THROW;
+        }
+        throw x2.result;
+    } finally {
+        ExecutionContext.current = x;
+    }
+    return x2.result;
+}
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/jsparse.js	Mon Jan 05 15:54:01 2009 -0800
@@ -0,0 +1,1019 @@
+/* vim: set sw=4 ts=8 et tw=78: */
+/* ***** BEGIN LICENSE BLOCK *****
+ * Version: MPL 1.1/GPL 2.0/LGPL 2.1
+ *
+ * The contents of this file are subject to the Mozilla Public License Version
+ * 1.1 (the "License"); you may not use this file except in compliance with
+ * the License. You may obtain a copy of the License at
+ * http://www.mozilla.org/MPL/
+ *
+ * Software distributed under the License is distributed on an "AS IS" basis,
+ * WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License
+ * for the specific language governing rights and limitations under the
+ * License.
+ *
+ * The Original Code is the Narcissus JavaScript engine.
+ *
+ * The Initial Developer of the Original Code is
+ * Brendan Eich <brendan@mozilla.org>.
+ * Portions created by the Initial Developer are Copyright (C) 2004
+ * the Initial Developer. All Rights Reserved.
+ *
+ * Contributor(s):
+ *
+ * Alternatively, the contents of this file may be used under the terms of
+ * either the GNU General Public License Version 2 or later (the "GPL"), or
+ * the GNU Lesser General Public License Version 2.1 or later (the "LGPL"),
+ * in which case the provisions of the GPL or the LGPL are applicable instead
+ * of those above. If you wish to allow use of your version of this file only
+ * under the terms of either the GPL or the LGPL, and not to allow others to
+ * use your version of this file under the terms of the MPL, indicate your
+ * decision by deleting the provisions above and replace them with the notice
+ * and other provisions required by the GPL or the LGPL. If you do not delete
+ * the provisions above, a recipient may use your version of this file under
+ * the terms of any one of the MPL, the GPL or the LGPL.
+ *
+ * ***** END LICENSE BLOCK ***** */
+
+/*
+ * Narcissus - JS implemented in JS.
+ *
+ * Lexical scanner and parser.
+ */
+
+// Build a regexp that recognizes operators and punctuators (except newline).
+var opRegExpSrc = "^";
+for (i in opTypeNames) {
+    if (i == '\n')
+        continue;
+    if (opRegExpSrc != "^")
+        opRegExpSrc += "|^";
+    opRegExpSrc += i.replace(/[?|^&(){}\[\]+\-*\/\.]/g, "\\$&");
+}
+var opRegExp = new RegExp(opRegExpSrc);
+
+// A regexp to match floating point literals (but not integer literals).
+var fpRegExp = /^\d+\.\d*(?:[eE][-+]?\d+)?|^\d+(?:\.\d*)?[eE][-+]?\d+|^\.\d+(?:[eE][-+]?\d+)?/;
+
+// A regexp to match regexp literals.
+var reRegExp = /^\/((?:\\.|\[(?:\\.|[^\]])*\]|[^\/])+)\/([gimy]*)/;
+
+function Tokenizer(s, f, l) {
+    this.cursor = 0;
+    this.source = String(s);
+    this.tokens = [];
+    this.tokenIndex = 0;
+    this.lookahead = 0;
+    this.scanNewlines = false;
+    this.scanOperand = true;
+    this.filename = f || "";
+    this.lineno = l || 1;
+    this.comments = [];
+}
+
+Tokenizer.prototype = {
+    get input() {
+        return this.source.substring(this.cursor);
+    },
+
+    get done() {
+        return this.peek() == END;
+    },
+
+    get token() {
+        return this.tokens[this.tokenIndex];
+    },
+
+    match: function (tt) {
+        return this.get() == tt || this.unget();
+    },
+
+    mustMatch: function (tt) {
+        if (!this.match(tt))
+            throw this.newSyntaxError("Missing " + tokens[tt].toLowerCase());
+        return this.token;
+    },
+
+    peek: function () {
+        var tt, next;
+        if (this.lookahead) {
+            next = this.tokens[(this.tokenIndex + this.lookahead) & 3];
+            if (this.scanNewlines && next.lineno != this.lineno)
+                tt = NEWLINE;
+            else
+                tt = next.type;
+        } else {
+            tt = this.get();
+            this.unget();
+        }
+        return tt;
+    },
+
+    peekOnSameLine: function () {
+        this.scanNewlines = true;
+        var tt = this.peek();
+        this.scanNewlines = false;
+        return tt;
+    },
+
+    get: function () {
+        var token;
+        while (this.lookahead) {
+            --this.lookahead;
+            this.tokenIndex = (this.tokenIndex + 1) & 3;
+            token = this.tokens[this.tokenIndex];
+            if (token.type != NEWLINE || this.scanNewlines)
+                return token.type;
+        }
+
+        for (;;) {
+            var input = this.input;
+            var match = (this.scanNewlines ? /^[ \t]+/ : /^\s+/)(input);
+            if (match) {
+                var spaces = match[0];
+                this.cursor += spaces.length;
+                var newlines = spaces.match(/\n/g);
+                if (newlines)
+                    this.lineno += newlines.length;
+                input = this.input;
+            }
+
+            if (!(match = /^\/(?:\*(?:.|\n)*?\*\/|\/.*)/(input)))
+                break;
+            var comment = match[0];
+            this.comments.push({lineno: this.lineno,
+                                cursor: this.cursor,
+                                text: comment});
+            this.cursor += comment.length;
+            newlines = comment.match(/\n/g);
+            if (newlines)
+                this.lineno += newlines.length
+        }
+
+        this.tokenIndex = (this.tokenIndex + 1) & 3;
+        token = this.tokens[this.tokenIndex];
+        if (!token)
+            this.tokens[this.tokenIndex] = token = {};
+
+        if (!input)
+            return token.type = END;
+
+        if ((match = fpRegExp(input))) {
+            token.type = NUMBER;
+            token.value = parseFloat(match[0]);
+        } else if ((match = /^0[xX][\da-fA-F]+|^0[0-7]*|^\d+/(input))) {
+            token.type = NUMBER;
+            token.value = parseInt(match[0]);
+        } else if ((match = /^[$_\w]+/(input))) {       // FIXME no ES3 unicode
+            var id = match[0];
+            token.type = keywords[id] || IDENTIFIER;
+            token.value = id;
+        } else if ((match = /^"(?:\\.|[^"])*"|^'(?:\\.|[^'])*'/(input))) { //"){
+            token.type = STRING;
+            token.value = eval(match[0]);
+        } else if (this.scanOperand && (match = reRegExp(input))) {
+            token.type = REGEXP;
+            token.value = new RegExp(match[1], match[2]);
+        } else if ((match = opRegExp(input))) {
+            var op = match[0];
+            if (assignOps[op] && input[op.length] == '=') {
+                token.type = ASSIGN;
+                token.assignOp = GLOBAL[opTypeNames[op]];
+                match[0] += '=';
+            } else {
+                token.type = GLOBAL[opTypeNames[op]];
+                if (this.scanOperand &&
+                    (token.type == PLUS || token.type == MINUS)) {
+                    token.type += UNARY_PLUS - PLUS;
+                }
+                token.assignOp = null;
+            }
+            token.value = op;
+        } else if (this.scanNewlines && (match = /^\n/(input))) {
+            token.type = NEWLINE;
+        } else {
+            throw this.newSyntaxError("Illegal token");
+        }
+
+        token.start = this.cursor;
+        this.cursor += match[0].length;
+        token.end = this.cursor;
+        token.lineno = this.lineno;
+        return token.type;
+    },
+
+    unget: function () {
+        if (++this.lookahead == 4) throw "PANIC: too much lookahead!";
+        this.tokenIndex = (this.tokenIndex - 1) & 3;
+    },
+
+    newSyntaxError: function (m) {
+        var e = new SyntaxError(m, this.filename, this.lineno);
+        e.source = this.source;
+        e.cursor = this.cursor;
+        return e;
+    }
+};
+
+function CompilerContext(inFunction) {
+    this.inFunction = inFunction;
+    this.stmtStack = [];
+    this.funDecls = [];
+    this.varDecls = [];
+}
+
+var CCp = CompilerContext.prototype;
+CCp.bracketLevel = CCp.curlyLevel = CCp.parenLevel = CCp.hookLevel = 0;
+CCp.ecmaStrictMode = CCp.inForLoopInit = false;
+
+function Script(t, x) {
+    var n = Statements(t, x);
+    n.type = SCRIPT;
+    n.funDecls = x.funDecls;
+    n.varDecls = x.varDecls;
+    return n;
+}
+
+// Node extends Array, which we extend slightly with a top-of-stack method.
+Array.prototype.__defineProperty__(
+    'top',
+    function () {
+        return this.length && this[this.length-1];
+    },
+    false, false, true
+);
+
+function Node(t, type) {
+    var token = t.token;
+    if (token) {
+        this.type = type || token.type;
+        this.value = token.value;
+        this.lineno = token.lineno;
+        this.start = token.start;
+        this.end = token.end;
+    } else {
+        this.type = type;
+        this.lineno = t.lineno;
+    }
+    this.tokenizer = t;
+
+    for (var i = 2; i < arguments.length; i++)
+        this.push(arguments[i]);
+}
+
+var Np = Node.prototype = new Array;
+Np.constructor = Node;
+Np.toSource = Object.prototype.toSource;
+
+// Always use push to add operands to an expression, to update start and end.
+Np.push = function (kid) {
+    if (kid.start < this.start)
+        this.start = kid.start;
+    if (this.end < kid.end)
+        this.end = kid.end;
+    return Array.prototype.push.call(this, kid);
+}
+
+Node.indentLevel = 0;
+
+function tokenstr(tt) {
+    var t = tokens[tt];
+    return /^\W/.test(t) ? opTypeNames[t] : t.toUpperCase();
+}
+
+Np.toString = function () {
+    var a = [];
+    for (var i in this) {
+        if (this.hasOwnProperty(i) && i != 'type' && i != 'target')
+            a.push({id: i, value: this[i]});
+    }
+    a.sort(function (a,b) { return (a.id < b.id) ? -1 : 1; });
+    const INDENTATION = "    ";
+    var n = ++Node.indentLevel;
+    var s = "{\n" + INDENTATION.repeat(n) + "type: " + tokenstr(this.type);
+    for (i = 0; i < a.length; i++)
+        s += ",\n" + INDENTATION.repeat(n) + a[i].id + ": " + a[i].value;
+    n = --Node.indentLevel;
+    s += "\n" + INDENTATION.repeat(n) + "}";
+    return s;
+}
+
+Np.getSource = function () {
+    return this.tokenizer.source.slice(this.start, this.end);
+};
+
+Np.__defineGetter__('filename',
+                    function () { return this.tokenizer.filename; });
+
+String.prototype.__defineProperty__(
+    'repeat',
+    function (n) {
+        var s = "", t = this + s;
+        while (--n >= 0)
+            s += t;
+        return s;
+    },
+    false, false, true
+);
+
+// Statement stack and nested statement handler.
+function nest(t, x, node, func, end) {
+    x.stmtStack.push(node);
+    var n = func(t, x);
+    x.stmtStack.pop();
+    end && t.mustMatch(end);
+    return n;
+}
+
+function Statements(t, x) {
+    var n = new Node(t, BLOCK);
+    x.stmtStack.push(n);
+    while (!t.done && t.peek() != RIGHT_CURLY)
+        n.push(Statement(t, x));
+    x.stmtStack.pop();
+    return n;
+}
+
+function Block(t, x) {
+    t.mustMatch(LEFT_CURLY);
+    var n = Statements(t, x);
+    t.mustMatch(RIGHT_CURLY);
+    return n;
+}
+
+const DECLARED_FORM = 0, EXPRESSED_FORM = 1, STATEMENT_FORM = 2;
+
+function Statement(t, x) {
+    var i, label, n, n2, ss, tt = t.get();
+
+    // Cases for statements ending in a right curly return early, avoiding the
+    // common semicolon insertion magic after this switch.
+    switch (tt) {
+      case FUNCTION:
+        return FunctionDefinition(t, x, true,
+                                  (x.stmtStack.length > 1)
+                                  ? STATEMENT_FORM
+                                  : DECLARED_FORM);
+
+      case LEFT_CURLY:
+        n = Statements(t, x);
+        t.mustMatch(RIGHT_CURLY);
+        return n;
+
+      case IF:
+        n = new Node(t);
+        n.condition = ParenExpression(t, x);
+        x.stmtStack.push(n);
+        n.thenPart = Statement(t, x);
+        n.elsePart = t.match(ELSE) ? Statement(t, x) : null;
+        x.stmtStack.pop();
+        return n;
+
+      case SWITCH:
+        n = new Node(t);
+        t.mustMatch(LEFT_PAREN);
+        n.discriminant = Expression(t, x);
+        t.mustMatch(RIGHT_PAREN);
+        n.cases = [];
+        n.defaultIndex = -1;
+        x.stmtStack.push(n);
+        t.mustMatch(LEFT_CURLY);
+        while ((tt = t.get()) != RIGHT_CURLY) {
+            switch (tt) {
+              case DEFAULT:
+                if (n.defaultIndex >= 0)
+                    throw t.newSyntaxError("More than one switch default");
+                // FALL THROUGH
+              case CASE:
+                n2 = new Node(t);
+                if (tt == DEFAULT)
+                    n.defaultIndex = n.cases.length;
+                else
+                    n2.caseLabel = Expression(t, x, COLON);
+                break;
+              default:
+                throw t.newSyntaxError("Invalid switch case");
+            }
+            t.mustMatch(COLON);
+            n2.statements = new Node(t, BLOCK);
+            while ((tt=t.peek()) != CASE && tt != DEFAULT && tt != RIGHT_CURLY)
+                n2.statements.push(Statement(t, x));
+            n.cases.push(n2);
+        }
+        x.stmtStack.pop();
+        return n;
+
+      case FOR:
+        n = new Node(t);
+        n.isLoop = true;
+        t.mustMatch(LEFT_PAREN);
+        if ((tt = t.peek()) != SEMICOLON) {
+            x.inForLoopInit = true;
+            if (tt == VAR || tt == CONST) {
+                t.get();
+                n2 = Variables(t, x);
+            } else {
+                n2 = Expression(t, x);
+            }
+            x.inForLoopInit = false;
+        }
+        if (n2 && t.match(IN)) {
+            n.type = FOR_IN;
+            if (n2.type == VAR) {
+                if (n2.length != 1) {
+                    throw new SyntaxError("Invalid for..in left-hand side",
+                                          t.filename, n2.lineno);
+                }
+
+                // NB: n2[0].type == IDENTIFIER and n2[0].value == n2[0].name.
+                n.iterator = n2[0];
+                n.varDecl = n2;
+            } else {
+                n.iterator = n2;
+                n.varDecl = null;
+            }
+            n.object = Expression(t, x);
+        } else {
+            n.setup = n2 || null;
+            t.mustMatch(SEMICOLON);
+            n.condition = (t.peek() == SEMICOLON) ? null : Expression(t, x);
+            t.mustMatch(SEMICOLON);
+            n.update = (t.peek() == RIGHT_PAREN) ? null : Expression(t, x);
+        }
+        t.mustMatch(RIGHT_PAREN);
+        n.body = nest(t, x, n, Statement);
+        return n;
+
+      case WHILE:
+        n = new Node(t);
+        n.isLoop = true;
+        n.condition = ParenExpression(t, x);
+        n.body = nest(t, x, n, Statement);
+        return n;
+
+      case DO:
+        n = new Node(t);
+        n.isLoop = true;
+        n.body = nest(t, x, n, Statement, WHILE);
+        n.condition = ParenExpression(t, x);
+        if (!x.ecmaStrictMode) {
+            // <script language="JavaScript"> (without version hints) may need
+            // automatic semicolon insertion without a newline after do-while.
+            // See http://bugzilla.mozilla.org/show_bug.cgi?id=238945.
+            t.match(SEMICOLON);
+            return n;
+        }
+        break;
+
+      case BREAK:
+      case CONTINUE:
+        n = new Node(t);
+        if (t.peekOnSameLine() == IDENTIFIER) {
+            t.get();
+            n.label = t.token.value;
+        }
+        ss = x.stmtStack;
+        i = ss.length;
+        label = n.label;
+        if (label) {
+            do {
+                if (--i < 0)
+                    throw t.newSyntaxError("Label not found");
+            } while (ss[i].label != label);
+        } else {
+            do {
+                if (--i < 0) {
+                    throw t.newSyntaxError("Invalid " + ((tt == BREAK)
+                                                         ? "break"
+                                                         : "continue"));
+                }
+            } while (!ss[i].isLoop && (tt != BREAK || ss[i].type != SWITCH));
+        }
+        n.target = ss[i];
+        break;
+
+      case TRY:
+        n = new Node(t);
+        n.tryBlock = Block(t, x);
+        n.catchClauses = [];
+        while (t.match(CATCH)) {
+            n2 = new Node(t);
+            t.mustMatch(LEFT_PAREN);
+            n2.varName = t.mustMatch(IDENTIFIER).value;
+            if (t.match(IF)) {
+                if (x.ecmaStrictMode)
+                    throw t.newSyntaxError("Illegal catch guard");
+                if (n.catchClauses.length && !n.catchClauses.top().guard)
+                    throw t.newSyntaxError("Guarded catch after unguarded");
+                n2.guard = Expression(t, x);
+            } else {
+                n2.guard = null;
+            }
+            t.mustMatch(RIGHT_PAREN);
+            n2.block = Block(t, x);
+            n.catchClauses.push(n2);
+        }
+        if (t.match(FINALLY))
+            n.finallyBlock = Block(t, x);
+        if (!n.catchClauses.length && !n.finallyBlock)
+            throw t.newSyntaxError("Invalid try statement");
+        return n;
+
+      case CATCH:
+      case FINALLY:
+        throw t.newSyntaxError(tokens[tt] + " without preceding try");
+
+      case THROW:
+        n = new Node(t);
+        n.exception = Expression(t, x);
+        break;
+
+      case RETURN:
+        if (!x.inFunction)
+            throw t.newSyntaxError("Invalid return");
+        n = new Node(t);
+        tt = t.peekOnSameLine();
+        if (tt != END && tt != NEWLINE && tt != SEMICOLON && tt != RIGHT_CURLY)
+            n.value = Expression(t, x);
+        break;
+
+      case WITH:
+        n = new Node(t);
+        n.object = ParenExpression(t, x);
+        n.body = nest(t, x, n, Statement);
+        return n;
+
+      case VAR:
+      case CONST:
+        n = Variables(t, x);
+        break;
+
+      case DEBUGGER:
+        n = new Node(t);
+        break;
+
+      case NEWLINE:
+      case SEMICOLON:
+        n = new Node(t, SEMICOLON);
+        n.expression = null;
+        return n;
+
+      default:
+        if (tt == IDENTIFIER) {
+            t.scanOperand = false;
+            tt = t.peek();
+            t.scanOperand = true;
+            if (tt == COLON) {
+                label = t.token.value;
+                ss = x.stmtStack;
+                for (i = ss.length-1; i >= 0; --i) {
+                    if (ss[i].label == label)
+                        throw t.newSyntaxError("Duplicate label");
+                }
+                t.get();
+                n = new Node(t, LABEL);
+                n.label = label;
+                n.statement = nest(t, x, n, Statement);
+                return n;
+            }
+        }
+
+        n = new Node(t, SEMICOLON);
+        t.unget();
+        n.expression = Expression(t, x);
+        n.end = n.expression.end;
+        break;
+    }
+
+    if (t.lineno == t.token.lineno) {
+        tt = t.peekOnSameLine();
+        if (tt != END && tt != NEWLINE && tt != SEMICOLON && tt != RIGHT_CURLY)
+            throw t.newSyntaxError("Missing ; before statement");
+    }
+    t.match(SEMICOLON);
+    return n;
+}
+
+function FunctionDefinition(t, x, requireName, functionForm) {
+    var f = new Node(t);
+    if (f.type != FUNCTION)
+        f.type = (f.value == "get") ? GETTER : SETTER;
+    if (t.match(IDENTIFIER))
+        f.name = t.token.value;
+    else if (requireName)
+        throw t.newSyntaxError("Missing function identifier");
+
+    t.mustMatch(LEFT_PAREN);
+    f.params = [];
+    var tt;
+    while ((tt = t.get()) != RIGHT_PAREN) {
+        if (tt != IDENTIFIER)
+            throw t.newSyntaxError("Missing formal parameter");
+        f.params.push(t.token.value);
+        if (t.peek() != RIGHT_PAREN)
+            t.mustMatch(COMMA);
+    }
+
+    t.mustMatch(LEFT_CURLY);
+    var x2 = new CompilerContext(true);
+    f.body = Script(t, x2);
+    t.mustMatch(RIGHT_CURLY);
+    f.end = t.token.end;
+
+    f.functionForm = functionForm;
+    if (functionForm == DECLARED_FORM)
+        x.funDecls.push(f);
+    return f;
+}
+
+function Variables(t, x) {
+    var n = new Node(t);
+    do {
+        t.mustMatch(IDENTIFIER);
+        var n2 = new Node(t);
+        n2.name = n2.value;
+        if (t.match(ASSIGN)) {
+            if (t.token.assignOp)
+                throw t.newSyntaxError("Invalid variable initialization");
+            n2.initializer = Expression(t, x, COMMA);
+        }
+        n2.readOnly = (n.type == CONST);
+        n.push(n2);
+        x.varDecls.push(n2);
+    } while (t.match(COMMA));
+    return n;
+}
+
+function ParenExpression(t, x) {
+    t.mustMatch(LEFT_PAREN);
+    var n = Expression(t, x);
+    t.mustMatch(RIGHT_PAREN);
+    return n;
+}
+
+var opPrecedence = {
+    SEMICOLON: 0,
+    COMMA: 1,
+    ASSIGN: 2, HOOK: 2, COLON: 2,
+    // The above all have to have the same precedence, see bug 330975.
+    OR: 4,
+    AND: 5,
+    BITWISE_OR: 6,
+    BITWISE_XOR: 7,
+    BITWISE_AND: 8,
+    EQ: 9, NE: 9, STRICT_EQ: 9, STRICT_NE: 9,
+    LT: 10, LE: 10, GE: 10, GT: 10, IN: 10, INSTANCEOF: 10,
+    LSH: 11, RSH: 11, URSH: 11,
+    PLUS: 12, MINUS: 12,
+    MUL: 13, DIV: 13, MOD: 13,
+    DELETE: 14, VOID: 14, TYPEOF: 14, // PRE_INCREMENT: 14, PRE_DECREMENT: 14,
+    NOT: 14, BITWISE_NOT: 14, UNARY_PLUS: 14, UNARY_MINUS: 14,
+    INCREMENT: 15, DECREMENT: 15,     // postfix
+    NEW: 16,
+    DOT: 17
+};
+
+// Map operator type code to precedence.
+for (i in opPrecedence)
+    opPrecedence[GLOBAL[i]] = opPrecedence[i];
+
+var opArity = {
+    COMMA: -2,
+    ASSIGN: 2,
+    HOOK: 3,
+    OR: 2,
+    AND: 2,
+    BITWISE_OR: 2,
+    BITWISE_XOR: 2,
+    BITWISE_AND: 2,
+    EQ: 2, NE: 2, STRICT_EQ: 2, STRICT_NE: 2,
+    LT: 2, LE: 2, GE: 2, GT: 2, IN: 2, INSTANCEOF: 2,
+    LSH: 2, RSH: 2, URSH: 2,
+    PLUS: 2, MINUS: 2,
+    MUL: 2, DIV: 2, MOD: 2,
+    DELETE: 1, VOID: 1, TYPEOF: 1,  // PRE_INCREMENT: 1, PRE_DECREMENT: 1,
+    NOT: 1, BITWISE_NOT: 1, UNARY_PLUS: 1, UNARY_MINUS: 1,
+    INCREMENT: 1, DECREMENT: 1,     // postfix
+    NEW: 1, NEW_WITH_ARGS: 2, DOT: 2, INDEX: 2, CALL: 2,
+    ARRAY_INIT: 1, OBJECT_INIT: 1, GROUP: 1
+};
+
+// Map operator type code to arity.
+for (i in opArity)
+    opArity[GLOBAL[i]] = opArity[i];
+
+function Expression(t, x, stop) {
+    var n, id, tt, operators = [], operands = [];
+    var bl = x.bracketLevel, cl = x.curlyLevel, pl = x.parenLevel,
+        hl = x.hookLevel;
+
+    function reduce() {
+        var n = operators.pop();
+        var op = n.type;
+        var arity = opArity[op];
+        if (arity == -2) {
+            // Flatten left-associative trees.
+            var left = operands.length >= 2 && operands[operands.length-2];
+            if (left.type == op) {
+                var right = operands.pop();
+                left.push(right);
+                return left;
+            }
+            arity = 2;
+        }
+
+        // Always use push to add operands to n, to update start and end.
+        var a = operands.splice(operands.length - arity);
+        for (var i = 0; i < arity; i++)
+            n.push(a[i]);
+
+        // Include closing bracket or postfix operator in [start,end).
+        if (n.end < t.token.end)
+            n.end = t.token.end;
+
+        operands.push(n);
+        return n;
+    }
+
+loop:
+    while ((tt = t.get()) != END) {
+        if (tt == stop &&
+            x.bracketLevel == bl && x.curlyLevel == cl && x.parenLevel == pl &&
+            x.hookLevel == hl) {
+            // Stop only if tt matches the optional stop parameter, and that
+            // token is not quoted by some kind of bracket.
+            break;
+        }
+        switch (tt) {
+          case SEMICOLON:
+            // NB: cannot be empty, Statement handled that.
+            break loop;
+
+          case ASSIGN:
+          case HOOK:
+          case COLON:
+            if (t.scanOperand)
+                break loop;
+            // Use >, not >=, for right-associative ASSIGN and HOOK/COLON.
+            while (opPrecedence[operators.top().type] > opPrecedence[tt] ||
+                   (tt == COLON && operators.top().type == ASSIGN)) {
+                reduce();
+            }
+            if (tt == COLON) {
+                n = operators.top();
+                if (n.type != HOOK)
+                    throw t.newSyntaxError("Invalid label");
+                --x.hookLevel;
+            } else {
+                operators.push(new Node(t));
+                if (tt == ASSIGN)
+                    operands.top().assignOp = t.token.assignOp;
+                else
+                    ++x.hookLevel;      // tt == HOOK
+            }
+            t.scanOperand = true;
+            break;
+
+          case IN:
+            // An in operator should not be parsed if we're parsing the head of
+            // a for (...) loop, unless it is in the then part of a conditional
+            // expression, or parenthesized somehow.
+            if (x.inForLoopInit && !x.hookLevel &&
+                !x.bracketLevel && !x.curlyLevel && !x.parenLevel) {
+                break loop;
+            }
+            // FALL THROUGH
+          case COMMA:
+            // Treat comma as left-associative so reduce can fold left-heavy
+            // COMMA trees into a single array.
+            // FALL THROUGH
+          case OR:
+          case AND:
+          case BITWISE_OR:
+          case BITWISE_XOR:
+          case BITWISE_AND:
+          case EQ: case NE: case STRICT_EQ: case STRICT_NE:
+          case LT: case LE: case GE: case GT:
+          case INSTANCEOF:
+          case LSH: case RSH: case URSH:
+          case PLUS: case MINUS:
+          case MUL: case DIV: case MOD:
+          case DOT:
+            if (t.scanOperand)
+                break loop;
+            while (opPrecedence[operators.top().type] >= opPrecedence[tt])
+                reduce();
+            if (tt == DOT) {
+                t.mustMatch(IDENTIFIER);
+                operands.push(new Node(t, DOT, operands.pop(), new Node(t)));
+            } else {
+                operators.push(new Node(t));
+                t.scanOperand = true;
+            }
+            break;
+
+          case DELETE: case VOID: case TYPEOF:
+          case NOT: case BITWISE_NOT: case UNARY_PLUS: case UNARY_MINUS:
+          case NEW:
+            if (!t.scanOperand)
+                break loop;
+            operators.push(new Node(t));
+            break;
+
+          case INCREMENT: case DECREMENT:
+            if (t.scanOperand) {
+                operators.push(new Node(t));  // prefix increment or decrement
+            } else {
+                // Don't cross a line boundary for postfix {in,de}crement.
+                if (t.tokens[(t.tokenIndex + t.lookahead - 1) & 3].lineno !=
+                    t.lineno) {
+                    break loop;
+                }
+
+                // Use >, not >=, so postfix has higher precedence than prefix.
+                while (opPrecedence[operators.top().type] > opPrecedence[tt])
+                    reduce();
+                n = new Node(t, tt, operands.pop());
+                n.postfix = true;
+                operands.push(n);
+            }
+            break;
+
+          case FUNCTION:
+            if (!t.scanOperand)
+                break loop;
+            operands.push(FunctionDefinition(t, x, false, EXPRESSED_FORM));
+            t.scanOperand = false;
+            break;
+
+          case NULL: case THIS: case TRUE: case FALSE:
+          case IDENTIFIER: case NUMBER: case STRING: case REGEXP:
+            if (!t.scanOperand)
+                break loop;
+            operands.push(new Node(t));
+            t.scanOperand = false;
+            break;
+
+          case LEFT_BRACKET:
+            if (t.scanOperand) {
+                // Array initialiser.  Parse using recursive descent, as the
+                // sub-grammar here is not an operator grammar.
+                n = new Node(t, ARRAY_INIT);
+                while ((tt = t.peek()) != RIGHT_BRACKET) {
+                    if (tt == COMMA) {
+                        t.get();
+                        n.push(null);
+                        continue;
+                    }
+                    n.push(Expression(t, x, COMMA));
+                    if (!t.match(COMMA))
+                        break;
+                }
+                t.mustMatch(RIGHT_BRACKET);
+                operands.push(n);
+                t.scanOperand = false;
+            } else {
+                // Property indexing operator.
+                operators.push(new Node(t, INDEX));
+                t.scanOperand = true;
+                ++x.bracketLevel;
+            }
+            break;
+
+          case RIGHT_BRACKET:
+            if (t.scanOperand || x.bracketLevel == bl)
+                break loop;
+            while (reduce().type != INDEX)
+                continue;
+            --x.bracketLevel;
+            break;
+
+          case LEFT_CURLY:
+            if (!t.scanOperand)
+                break loop;
+            // Object initialiser.  As for array initialisers (see above),
+            // parse using recursive descent.
+            ++x.curlyLevel;
+            n = new Node(t, OBJECT_INIT);
+          object_init:
+            if (!t.match(RIGHT_CURLY)) {
+                do {
+                    tt = t.get();
+                    if ((t.token.value == "get" || t.token.value == "set") &&
+                        t.peek() == IDENTIFIER) {
+                        if (x.ecmaStrictMode)
+                            throw t.newSyntaxError("Illegal property accessor");
+                        n.push(FunctionDefinition(t, x, true, EXPRESSED_FORM));
+                    } else {
+                        switch (tt) {
+                          case IDENTIFIER:
+                          case NUMBER:
+                          case STRING:
+                            id = new Node(t);
+                            break;
+                          case RIGHT_CURLY:
+                            if (x.ecmaStrictMode)
+                                throw t.newSyntaxError("Illegal trailing ,");
+                            break object_init;
+                          default:
+                            throw t.newSyntaxError("Invalid property name");
+                        }
+                        t.mustMatch(COLON);
+                        n.push(new Node(t, PROPERTY_INIT, id,
+                                        Expression(t, x, COMMA)));
+                    }
+                } while (t.match(COMMA));
+                t.mustMatch(RIGHT_CURLY);
+            }
+            operands.push(n);
+            t.scanOperand = false;
+            --x.curlyLevel;
+            break;
+
+          case RIGHT_CURLY:
+            if (!t.scanOperand && x.curlyLevel != cl)
+                throw "PANIC: right curly botch";
+            break loop;
+
+          case LEFT_PAREN:
+            if (t.scanOperand) {
+                operators.push(new Node(t, GROUP));
+            } else {
+                while (opPrecedence[operators.top().type] > opPrecedence[NEW])
+                    reduce();
+
+                // Handle () now, to regularize the n-ary case for n > 0.
+                // We must set scanOperand in case there are arguments and
+                // the first one is a regexp or unary+/-.
+                n = operators.top();
+                t.scanOperand = true;
+                if (t.match(RIGHT_PAREN)) {
+                    if (n.type == NEW) {
+                        --operators.length;
+                        n.push(operands.pop());
+                    } else {
+                        n = new Node(t, CALL, operands.pop(),
+                                     new Node(t, LIST));
+                    }
+                    operands.push(n);
+                    t.scanOperand = false;
+                    break;
+                }
+                if (n.type == NEW)
+                    n.type = NEW_WITH_ARGS;
+                else
+                    operators.push(new Node(t, CALL));
+            }
+            ++x.parenLevel;
+            break;
+
+          case RIGHT_PAREN:
+            if (t.scanOperand || x.parenLevel == pl)
+                break loop;
+            while ((tt = reduce().type) != GROUP && tt != CALL &&
+                   tt != NEW_WITH_ARGS) {
+                continue;
+            }
+            if (tt != GROUP) {
+                n = operands.top();
+                if (n[1].type != COMMA)
+                    n[1] = new Node(t, LIST, n[1]);
+                else
+                    n[1].type = LIST;
+            }
+            --x.parenLevel;
+            break;
+
+          // Automatic semicolon insertion means we may scan across a newline
+          // and into the beginning of another statement.  If so, break out of
+          // the while loop and let the t.scanOperand logic handle errors.
+          default:
+            break loop;
+        }
+    }
+
+    if (x.hookLevel != hl)
+        throw t.newSyntaxError("Missing : after ?");
+    if (x.parenLevel != pl)
+        throw t.newSyntaxError("Missing ) in parenthetical");
+    if (x.bracketLevel != bl)
+        throw t.newSyntaxError("Missing ] in index expression");
+    if (t.scanOperand)
+        throw t.newSyntaxError("Missing operand");
+
+    // Resume default mode, scanning for operands, not operators.
+    t.scanOperand = true;
+    t.unget();
+    while (operators.length)
+        reduce();
+    return operands.pop();
+}
+
+function parse(s, f, l) {
+    var t = new Tokenizer(s, f, l);
+    var x = new CompilerContext(false);
+    var n = Script(t, x);
+    if (!t.done)
+        throw t.newSyntaxError("Syntax error");
+    return n;
+}
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/samplecode.js	Mon Jan 05 15:54:01 2009 -0800
@@ -0,0 +1,20 @@
+// Hello, this is sample code.
+//
+// How do you feel about chutney.
+//
+// I don't //like// chutney, do you?
+//
+// No.  It's utter **hogwash**.
+//
+// * Hello.
+// * There.
+// * Dood.
+//
+// {{{
+//   function blarg() {
+//   }
+// }}}
+
+function blarg() {
+  return 1;
+}
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/server.py	Mon Jan 05 15:54:01 2009 -0800
@@ -0,0 +1,12 @@
+import CGIHTTPServer
+import BaseHTTPServer
+
+PORT = 8000
+
+Handler = CGIHTTPServer.CGIHTTPRequestHandler
+
+httpd = BaseHTTPServer.HTTPServer(("", PORT), Handler)
+
+print "Serving files at http://localhost:%d" % PORT
+
+httpd.serve_forever()
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/thingy.html	Mon Jan 05 15:54:01 2009 -0800
@@ -0,0 +1,28 @@
+<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN"
+          "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
+<html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en" lang="en">
+<head>
+  <meta http-equiv="Content-type" content="text/html; charset=utf-8" />
+  <title>Narcissus Thingy</title>
+</head>
+<body>
+<div id="content"></div>
+</body>
+<script>
+// Hack found at:
+// http://www.nabble.com/Re%3A-__defineProperty__-by-default-in-SpiderMonkey-p2836854.html
+
+Object.prototype.__defineProperty__ = function(property, value) {
+        this[property] = value;
+}
+</script>
+<script src="jquery-1.2.6.min.js"></script>
+<script type="application/javascript;version=1.7"
+        src="jsdefs.js"></script>
+<script type="application/javascript;version=1.7"
+        src="jsparse.js"></script>
+<script type="application/javascript;version=1.7"
+        src="wikicreole.js"></script>
+<script type="application/javascript;version=1.7"
+        src="thingy.js"></script>
+</html>
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/thingy.js	Mon Jan 05 15:54:01 2009 -0800
@@ -0,0 +1,42 @@
+var App = {
+  FILENAME: "samplecode.js"
+};
+
+App.trim = function trim(str) {
+  return str.replace(/^\s+|\s+$/g,"");
+};
+
+App.processCode = function processCode(code) {
+  var statements = parse(code, App.FILENAME, 1);
+  var block = "";
+
+  jQuery.each(
+    statements.tokenizer.comments,
+    function(i) {
+      var comment = this;
+      var startIndex = comment.text.indexOf("//");
+      if (startIndex == -1)
+        // This is a /* */-style comment, skip it.
+        return;
+      var text = comment.text.slice(startIndex + 3);
+      block += text + "\n";
+    });
+
+  var creole = new Parse.Simple.Creole(
+    {interwiki: {
+       WikiCreole: 'http://www.wikicreole.org/wiki/',
+       Wikipedia: 'http://en.wikipedia.org/wiki/'
+     },
+     linkFormat: ''
+    });
+
+  creole.parse($("#content").get(0), block);
+};
+
+$(window).ready(
+  function() {
+    jQuery.get(App.FILENAME,
+               {},
+               App.processCode,
+               "text");
+  });
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/wikicreole.js	Mon Jan 05 15:54:01 2009 -0800
@@ -0,0 +1,348 @@
+/*
+ * Copyright (c) 2008 Ivan Fomichev
+ *
+ * Portions Copyright (c) 2007 Chris Purcell
+ *
+ * Permission is hereby granted, free of charge, to any person obtaining a
+ * copy of this software and associated documentation files (the "Software"),
+ * to deal in the Software without restriction, including without limitation
+ * the rights to use, copy, modify, merge, publish, distribute, sublicense,
+ * and/or sell copies of the Software, and to permit persons to whom the
+ * Software is furnished to do so, subject to the following conditions:
+ *
+ * The above copyright notice and this permission notice shall be included
+ * in all copies or substantial portions of the Software.
+ *
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
+ * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+ * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL
+ * THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
+ * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
+ * FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
+ * DEALINGS IN THE SOFTWARE.
+ */
+
+if (!Parse) { var Parse = {}; }
+if (!Parse.Simple) { Parse.Simple = {}; }
+
+Parse.Simple.Base = function(root, options) {
+    if (!arguments.length) { return; }
+
+    this.root = new this.ruleConstructor(root);
+    this.options = options;
+};
+
+Parse.Simple.Base.prototype = {
+    ruleConstructor: null,
+    root: null,
+    options: null,
+
+    parse: function(node, data, options) {
+        if (options) {
+            for (i in this.options) {
+                if (typeof options[i] == 'undefined') { options[i] = this.options[i]; }
+            }
+        }
+        else {
+            options = this.options;
+        }
+        this.root.apply(node, data, options);
+    }
+};
+
+Parse.Simple.Base.prototype.constructor = Parse.Simple.Base;
+
+Parse.Simple.Base.Rule = function(params) {
+    if (!arguments.length) { return; }
+
+    for (var p in params) { this[p] = params[p]; }
+    if (!this.children) { this.children = []; }
+};
+
+Parse.Simple.Base.prototype.ruleConstructor = Parse.Simple.Base.Rule;
+
+Parse.Simple.Base.Rule.prototype = {
+    regex: null,
+    capture: null,
+    replaceRegex: null,
+    replaceString: null,
+    tag: null,
+    attrs: null,
+    children: null,
+
+    match: function(data, options) {
+        return data.match(this.regex);
+    },
+
+    build: function(node, r, options) {
+        var data;
+        if (this.capture !== null) {
+            data = r[this.capture];
+        }
+
+        var target;
+        if (this.tag) {
+            target = document.createElement(this.tag);
+            node.appendChild(target);
+        }
+        else { target = node; }
+
+        if (data) {
+            if (this.replaceRegex) {
+                data = data.replace(this.replaceRegex, this.replaceString);
+            }
+            this.apply(target, data, options);
+        }
+
+        if (this.attrs) {
+            for (var i in this.attrs) {
+                target.setAttribute(i, this.attrs[i]);
+                if (i == 'class') { target.className = this.attrs[i]; } // for IE
+            }
+        }
+        return this;
+    },
+
+    apply: function(node, data, options) {
+        var tail = '' + data;
+        var matches = [];
+
+        if (!this.fallback.apply) {
+            this.fallback = new this.constructor(this.fallback);
+        }
+
+        while (true) {
+            var best = false;
+            var rule  = false;
+            for (var i = 0; i < this.children.length; i++) {
+                if (typeof matches[i] == 'undefined') {
+                    if (!this.children[i].match) {
+                        this.children[i] = new this.constructor(this.children[i]);
+                    }
+                    matches[i] = this.children[i].match(tail, options);
+                }
+                if (matches[i] && (!best || best.index > matches[i].index)) {
+                    best = matches[i];
+                    rule = this.children[i];
+                    if (best.index == 0) { break; }
+                }
+            }
+
+            var pos = best ? best.index : tail.length;
+            if (pos > 0) {
+                this.fallback.apply(node, tail.substring(0, pos), options);
+            }
+
+            if (!best) { break; }
+
+            if (!rule.build) { rule = new this.constructor(rule); }
+            rule.build(node, best, options);
+
+            var chopped = best.index + best[0].length;
+            tail = tail.substring(chopped);
+            for (var i = 0; i < this.children.length; i++) {
+                if (matches[i]) {
+                    if (matches[i].index >= chopped) {
+                        matches[i].index -= chopped;
+                    }
+                    else {
+                        matches[i] = void 0;
+                    }
+                }
+            }
+        }
+
+        return this;
+    },
+
+    fallback: {
+        apply: function(node, data, options) {
+            node.appendChild(document.createTextNode(data));
+        }
+    }
+};
+
+Parse.Simple.Base.Rule.prototype.constructor = Parse.Simple.Base.Rule;
+
+Parse.Simple.Creole = function(options) {
+    var rx = {};
+    rx.link = '[^\\]|~\\n]*(?:(?:\\](?!\\])|~.)[^\\]|~\\n]*)*';
+    rx.linkText = '[^\\]~\\n]*(?:(?:\\](?!\\])|~.)[^\\]~\\n]*)*';
+    rx.uriPrefix = '\\b(?:(?:https?|ftp)://|mailto:)';
+    rx.uri = rx.uriPrefix + rx.link;
+    rx.rawUri = rx.uriPrefix + '\\S*[^\\s!"\',.:;?]';
+    rx.interwikiPrefix = '[\\w.]+:';
+    rx.interwikiLink = rx.interwikiPrefix + rx.link;
+
+    var formatLink = function(link, format) {
+        format = format instanceof Array ? format : [ format ];
+        if (typeof format[1] == 'undefined') { format[1] = ''; }
+        return format[0] + link + format[1];
+    };
+
+    var g = {
+        hr: { tag: 'hr', regex: /(^|\n)\s*----\s*(\n|$)/ },
+
+        br: { tag: 'br', regex: /\\\\/ },
+
+        preBlock: { tag: 'pre', capture: 2,
+            regex: /(^|\n)\{\{\{\n((.*\n)*?)\}\}\}(\n|$)/,
+            replaceRegex: /^ ([ \t]*\}\}\})/gm,
+            replaceString: '$1' },
+        tt: { tag: 'tt',
+            regex: /\{\{\{(.*?\}\}\}+)/, capture: 1,
+            replaceRegex: /\}\}\}$/, replaceString: '' },
+
+        ulist: { tag: 'ul', capture: 0,
+            regex: /(^|\n)([ \t]*\*[^*#].*(\n|$)([ \t]*[^\s*#].*(\n|$))*([ \t]*[*#]{2}.*(\n|$))*)+/ },
+        olist: { tag: 'ol', capture: 0,
+            regex: /(^|\n)([ \t]*#[^*#].*(\n|$)([ \t]*[^\s*#].*(\n|$))*([ \t]*[*#]{2}.*(\n|$))*)+/ },
+        li: { tag: 'li', capture: 0,
+            regex: /[ \t]*([*#]).+(\n[ \t]*[^*#\s].*)*(\n[ \t]*\1[*#].+)*/,
+            replaceRegex: /(^|\n)[ \t]*[*#]/g, replaceString: '$1' },
+
+        table: { tag: 'table', capture: 0,
+            regex: /(^|\n)(\|.*?[ \t]*(\n|$))+/ },
+        tr: { tag: 'tr', capture: 2, regex: /(^|\n)(\|.*?)\|?[ \t]*(\n|$)/ },
+        th: { tag: 'th', regex: /\|+=([^|]*)/, capture: 1 },
+        td: { tag: 'td', capture: 1,
+            regex: /\|+([^|~]*(~(.|(?=\n)|$)[^|~]*)*)/ },
+
+        singleLine: { regex: /.+/, capture: 0 },
+        paragraph: { tag: 'p', capture: 0,
+            regex: /(^|\n)([ \t]*\S.*(\n|$))+/ },
+        text: { capture: 0, regex: /(^|\n)([ \t]*[^\s].*(\n|$))+/ },
+
+        strong: { tag: 'strong', capture: 1,
+            regex: /\*\*([^*~]*((\*(?!\*)|~(.|(?=\n)|$))[^*~]*)*)(\*\*|\n|$)/ },
+        em: { tag: 'em', capture: 1,
+            regex: '\\/\\/(((?!' + rx.uriPrefix + ')[^\\/~])*' +
+                   '((' + rx.rawUri + '|\\/(?!\\/)|~(.|(?=\\n)|$))' +
+                   '((?!' + rx.uriPrefix + ')[^\\/~])*)*)(\\/\\/|\\n|$)' },
+
+        img: { regex: '\\{\\{((?!\\{)[^|}\\n]*(?:}(?!})[^|}\\n]*)*)\\|' +
+                      '([^}~\\n]*((}(?!})|~.)[^}~\\n]*)*)}}',
+            build: function(node, r, options) {
+                var img = document.createElement('img');
+                img.src = r[1];
+                img.alt = r[2].replace(/~(.)/g, '$1');
+                node.appendChild(img);
+            } },
+
+        namedUri: { regex: '\\[\\[(' + rx.uri + ')\\|(' + rx.linkText + ')\\]\\]',
+            build: function(node, r, options) {
+                var link = document.createElement('a');
+                link.href = r[1];
+                if (options && options.isPlainUri) {
+                    link.appendChild(document.createTextNode(r[2]));
+                }
+                else {
+                    this.apply(link, r[2], options);
+                }
+                node.appendChild(link);
+            } },
+
+        namedLink: { regex: '\\[\\[(' + rx.link + ')\\|(' + rx.linkText + ')\\]\\]',
+            build: function(node, r, options) {
+                var link = document.createElement('a');
+
+                link.href = options && options.linkFormat
+                    ? formatLink(r[1].replace(/~(.)/g, '$1'), options.linkFormat)
+                    : r[1].replace(/~(.)/g, '$1');
+                this.apply(link, r[2], options);
+
+                node.appendChild(link);
+            } },
+
+        unnamedUri: { regex: '\\[\\[(' + rx.uri + ')\\]\\]',
+            build: 'dummy' },
+        unnamedLink: { regex: '\\[\\[(' + rx.link + ')\\]\\]',
+            build: 'dummy' },
+        unnamedInterwikiLink: { regex: '\\[\\[(' + rx.interwikiLink + ')\\]\\]',
+            build: 'dummy' },
+
+        rawUri: { regex: '(' + rx.rawUri + ')',
+            build: 'dummy' },
+
+        escapedSequence: { regex: '~(' + rx.rawUri + '|.)', capture: 1,
+            tag: 'span', attrs: { 'class': 'escaped' } },
+        escapedSymbol: { regex: /~(.)/, capture: 1,
+            tag: 'span', attrs: { 'class': 'escaped' } }
+    };
+    g.unnamedUri.build = g.rawUri.build = function(node, r, options) {
+        if (!options) { options = {}; }
+        options.isPlainUri = true;
+        g.namedUri.build.call(this, node, Array(r[0], r[1], r[1]), options);
+    };
+    g.unnamedLink.build = function(node, r, options) {
+        g.namedLink.build.call(this, node, Array(r[0], r[1], r[1]), options);
+    };
+    g.namedInterwikiLink = { regex: '\\[\\[(' + rx.interwikiLink + ')\\|(' + rx.linkText + ')\\]\\]',
+        build: function(node, r, options) {
+                var link = document.createElement('a');
+
+                var m, f;
+                if (options && options.interwiki) {
+                m = r[1].match(/(.*?):(.*)/);
+                f = options.interwiki[m[1]];
+            }
+
+            if (typeof f == 'undefined') {
+                if (!g.namedLink.apply) {
+                    g.namedLink = new this.constructor(g.namedLink);
+                }
+                return g.namedLink.build.call(g.namedLink, node, r, options);
+            }
+
+            link.href = formatLink(m[2].replace(/~(.)/g, '$1'), f);
+
+            this.apply(link, r[2], options);
+
+            node.appendChild(link);
+        }
+    };
+    g.unnamedInterwikiLink.build = function(node, r, options) {
+        g.namedInterwikiLink.build.call(this, node, Array(r[0], r[1], r[1]), options);
+    };
+    g.namedUri.children = g.unnamedUri.children = g.rawUri.children =
+            g.namedLink.children = g.unnamedLink.children =
+            g.namedInterwikiLink.children = g.unnamedInterwikiLink.children =
+        [ g.escapedSymbol, g.img ];
+
+    for (var i = 1; i <= 6; i++) {
+        g['h' + i] = { tag: 'h' + i, capture: 2,
+            regex: '(^|\\n)[ \\t]*={' + i + '}[ \\t]' +
+                   '([^~]*?(~(.|(?=\\n)|$))*)[ \\t]*=*\\s*(\\n|$)'
+        };
+    }
+
+    g.ulist.children = g.olist.children = [ g.li ];
+    g.li.children = [ g.ulist, g.olist ];
+    g.li.fallback = g.text;
+
+    g.table.children = [ g.tr ];
+    g.tr.children = [ g.th, g.td ];
+    g.td.children = [ g.singleLine ];
+    g.th.children = [ g.singleLine ];
+
+    g.h1.children = g.h2.children = g.h3.children =
+            g.h4.children = g.h5.children = g.h6.children =
+            g.singleLine.children = g.paragraph.children =
+            g.text.children = g.strong.children = g.em.children =
+        [ g.escapedSequence, g.strong, g.em, g.br, g.rawUri,
+            g.namedUri, g.namedInterwikiLink, g.namedLink,
+            g.unnamedUri, g.unnamedInterwikiLink, g.unnamedLink,
+            g.tt, g.img ];
+
+    g.root = {
+        children: [ g.h1, g.h2, g.h3, g.h4, g.h5, g.h6,
+            g.hr, g.ulist, g.olist, g.preBlock, g.table ],
+        fallback: { children: [ g.paragraph ] }
+    };
+
+    Parse.Simple.Base.call(this, g.root, options);
+};
+
+Parse.Simple.Creole.prototype = new Parse.Simple.Base();
+
+Parse.Simple.Creole.prototype.constructor = Parse.Simple.Creole;