めんどうでテストしとらんが。
/* selector{property:value;}selector{property:value;} [[selector,[[property,value],[property,value]]],[selector,[[property,value],[property,value]]]] */ var CSS = function(css){ var temps = css.split("}").map(function(elm){ return elm.split("{"); }).map(function(elm){ return elm.split(";"); }).map(function(elm){ return split(":"); ]}); temps = temps.clean(); return temps; }; Object.prototype.class = "Object"; Array.prototype.class = "Array"; Array.prototype.clone = function(){ var a = []; for(var i=0; i<this.length; i++){ if(this[i].class == "Array") a[i] = this[i].clone(); else a[i] = this[i]; } return a; }; Array.prototype.map = function(f){ var a = this.clone(); for(var i=0; i<a.length; i++) a[i] = f(a[i]); return a; }; Array.prototype.clean = function(){ var a = this.clone(); var b = []; for(var i=0; i<a.length; i++){ if(a[i].class == "Array") b.push(a[i].clean()); else if(a[i] != []) b.push(a[i]); } return b; };
動くのかね?