Skip to content

Commit

Permalink
starting jsml
Browse files Browse the repository at this point in the history
  • Loading branch information
jeffsu committed Mar 28, 2011
1 parent 50f7b94 commit e7d03a6
Show file tree
Hide file tree
Showing 8 changed files with 135 additions and 127 deletions.
33 changes: 17 additions & 16 deletions dist/browser/js2-full.js
Original file line number Diff line number Diff line change
Expand Up @@ -1484,26 +1484,31 @@ JS2.Class.extend('JSML', function(KLASS, OO){

OO.addMember("initialize",function (txt) {
var lines = txt.split(/\n/);
this.root = new JSMLElement;
this.root = new JS2.JSMLElement('');
this.current = this.root;
this.stack = [ this.root ];

for(var _i1=0,_c1=lines,_l1=_c1.length,l;l=_c1[_i1]||_i1<_l1;_i1++){
if (l.match(/^\s*$/)) continue;
this.processLine(l);
}
});

OO.addMember("processLine",function (line) {
var ele = new JSMLElement(line);
console.log(line);
var ele = new JS2.JSMLElement(line);
var scope = this.getScope();

if (ele.scope == scope) {
console.log('same');
this.stack.pop();
this.getLast().push(ele);
} else if (ele.scope == scope+1) {
console.log('greater');
this.getLast().push(ele);
this.stack.push(ele);
} else if (ele.scope < scope) {
console.log('less');
var diff = ele.scope - scope;
while(diff-- != 0) {
this.stack.pop();
Expand All @@ -1514,31 +1519,25 @@ JS2.Class.extend('JSML', function(KLASS, OO){


OO.addMember("getScope",function () {
return this.stack.length-1;
return this.stack.length;
});

OO.addMember("getLast",function () {
return this.root[this.root.length-1];
});

OO.addMember("processClasses",function (ele, str) {
var self = this;
str.replace(this.CLASSES_AND_IDS, function(match, type, name){
if (type == '.') {
ele.addClass(name);
} else if (type == '#') {
ele.setID(name);
}
});
});
});

JS2.Class.extend('JSMLElement', function(KLASS, OO){
OO.addMember("FIRST_PASS",/^((?:\s{2})+)(if|foreach|\.|#|\w+)(.*)/);
OO.addMember("CLASSES_AND_IDS",/(#|\.)([\-w]+)/g);

OO.addMember("initialize",function (line) {
this.parse(line);
this.scope = 0;
if (line) {
this.parse(line);
}

this.children = [];
});

Expand All @@ -1547,8 +1546,10 @@ JS2.Class.extend('JSMLElement', function(KLASS, OO){
});

OO.addMember("parse",function (line) {
var m = line.match(FIRST_PASS);
this.scope = m[1].length / 2;
var m = line.match(this.FIRST_PASS);
if (m) {
this.scope = m[1].length / 2;
}
});
});

Expand Down
33 changes: 17 additions & 16 deletions dist/gem/lib/js2/js2.js
Original file line number Diff line number Diff line change
Expand Up @@ -1480,26 +1480,31 @@ JS2.Class.extend('JSML', function(KLASS, OO){

OO.addMember("initialize",function (txt) {
var lines = txt.split(/\n/);
this.root = new JSMLElement;
this.root = new JS2.JSMLElement('');
this.current = this.root;
this.stack = [ this.root ];

for(var _i1=0,_c1=lines,_l1=_c1.length,l;l=_c1[_i1]||_i1<_l1;_i1++){
if (l.match(/^\s*$/)) continue;
this.processLine(l);
}
});

OO.addMember("processLine",function (line) {
var ele = new JSMLElement(line);
console.log(line);
var ele = new JS2.JSMLElement(line);
var scope = this.getScope();

if (ele.scope == scope) {
console.log('same');
this.stack.pop();
this.getLast().push(ele);
} else if (ele.scope == scope+1) {
console.log('greater');
this.getLast().push(ele);
this.stack.push(ele);
} else if (ele.scope < scope) {
console.log('less');
var diff = ele.scope - scope;
while(diff-- != 0) {
this.stack.pop();
Expand All @@ -1510,31 +1515,25 @@ JS2.Class.extend('JSML', function(KLASS, OO){


OO.addMember("getScope",function () {
return this.stack.length-1;
return this.stack.length;
});

OO.addMember("getLast",function () {
return this.root[this.root.length-1];
});

OO.addMember("processClasses",function (ele, str) {
var self = this;
str.replace(this.CLASSES_AND_IDS, function(match, type, name){
if (type == '.') {
ele.addClass(name);
} else if (type == '#') {
ele.setID(name);
}
});
});
});

JS2.Class.extend('JSMLElement', function(KLASS, OO){
OO.addMember("FIRST_PASS",/^((?:\s{2})+)(if|foreach|\.|#|\w+)(.*)/);
OO.addMember("CLASSES_AND_IDS",/(#|\.)([\-w]+)/g);

OO.addMember("initialize",function (line) {
this.parse(line);
this.scope = 0;
if (line) {
this.parse(line);
}

this.children = [];
});

Expand All @@ -1543,8 +1542,10 @@ JS2.Class.extend('JSMLElement', function(KLASS, OO){
});

OO.addMember("parse",function (line) {
var m = line.match(FIRST_PASS);
this.scope = m[1].length / 2;
var m = line.match(this.FIRST_PASS);
if (m) {
this.scope = m[1].length / 2;
}
});
});

Expand Down
33 changes: 17 additions & 16 deletions dist/npm/lib/js2.js
Original file line number Diff line number Diff line change
Expand Up @@ -1480,26 +1480,31 @@ JS2.Class.extend('JSML', function(KLASS, OO){

OO.addMember("initialize",function (txt) {
var lines = txt.split(/\n/);
this.root = new JSMLElement;
this.root = new JS2.JSMLElement('');
this.current = this.root;
this.stack = [ this.root ];

for(var _i1=0,_c1=lines,_l1=_c1.length,l;l=_c1[_i1]||_i1<_l1;_i1++){
if (l.match(/^\s*$/)) continue;
this.processLine(l);
}
});

OO.addMember("processLine",function (line) {
var ele = new JSMLElement(line);
console.log(line);
var ele = new JS2.JSMLElement(line);
var scope = this.getScope();

if (ele.scope == scope) {
console.log('same');
this.stack.pop();
this.getLast().push(ele);
} else if (ele.scope == scope+1) {
console.log('greater');
this.getLast().push(ele);
this.stack.push(ele);
} else if (ele.scope < scope) {
console.log('less');
var diff = ele.scope - scope;
while(diff-- != 0) {
this.stack.pop();
Expand All @@ -1510,31 +1515,25 @@ JS2.Class.extend('JSML', function(KLASS, OO){


OO.addMember("getScope",function () {
return this.stack.length-1;
return this.stack.length;
});

OO.addMember("getLast",function () {
return this.root[this.root.length-1];
});

OO.addMember("processClasses",function (ele, str) {
var self = this;
str.replace(this.CLASSES_AND_IDS, function(match, type, name){
if (type == '.') {
ele.addClass(name);
} else if (type == '#') {
ele.setID(name);
}
});
});
});

JS2.Class.extend('JSMLElement', function(KLASS, OO){
OO.addMember("FIRST_PASS",/^((?:\s{2})+)(if|foreach|\.|#|\w+)(.*)/);
OO.addMember("CLASSES_AND_IDS",/(#|\.)([\-w]+)/g);

OO.addMember("initialize",function (line) {
this.parse(line);
this.scope = 0;
if (line) {
this.parse(line);
}

this.children = [];
});

Expand All @@ -1543,8 +1542,10 @@ JS2.Class.extend('JSMLElement', function(KLASS, OO){
});

OO.addMember("parse",function (line) {
var m = line.match(FIRST_PASS);
this.scope = m[1].length / 2;
var m = line.match(this.FIRST_PASS);
if (m) {
this.scope = m[1].length / 2;
}
});
});

Expand Down
33 changes: 17 additions & 16 deletions flavors/browser-full.js
Original file line number Diff line number Diff line change
Expand Up @@ -1484,26 +1484,31 @@ JS2.Class.extend('JSML', function(KLASS, OO){

OO.addMember("initialize",function (txt) {
var lines = txt.split(/\n/);
this.root = new JSMLElement;
this.root = new JS2.JSMLElement('');
this.current = this.root;
this.stack = [ this.root ];

for(var _i1=0,_c1=lines,_l1=_c1.length,l;l=_c1[_i1]||_i1<_l1;_i1++){
if (l.match(/^\s*$/)) continue;
this.processLine(l);
}
});

OO.addMember("processLine",function (line) {
var ele = new JSMLElement(line);
console.log(line);
var ele = new JS2.JSMLElement(line);
var scope = this.getScope();

if (ele.scope == scope) {
console.log('same');
this.stack.pop();
this.getLast().push(ele);
} else if (ele.scope == scope+1) {
console.log('greater');
this.getLast().push(ele);
this.stack.push(ele);
} else if (ele.scope < scope) {
console.log('less');
var diff = ele.scope - scope;
while(diff-- != 0) {
this.stack.pop();
Expand All @@ -1514,31 +1519,25 @@ JS2.Class.extend('JSML', function(KLASS, OO){


OO.addMember("getScope",function () {
return this.stack.length-1;
return this.stack.length;
});

OO.addMember("getLast",function () {
return this.root[this.root.length-1];
});

OO.addMember("processClasses",function (ele, str) {
var self = this;
str.replace(this.CLASSES_AND_IDS, function(match, type, name){
if (type == '.') {
ele.addClass(name);
} else if (type == '#') {
ele.setID(name);
}
});
});
});

JS2.Class.extend('JSMLElement', function(KLASS, OO){
OO.addMember("FIRST_PASS",/^((?:\s{2})+)(if|foreach|\.|#|\w+)(.*)/);
OO.addMember("CLASSES_AND_IDS",/(#|\.)([\-w]+)/g);

OO.addMember("initialize",function (line) {
this.parse(line);
this.scope = 0;
if (line) {
this.parse(line);
}

this.children = [];
});

Expand All @@ -1547,8 +1546,10 @@ JS2.Class.extend('JSMLElement', function(KLASS, OO){
});

OO.addMember("parse",function (line) {
var m = line.match(FIRST_PASS);
this.scope = m[1].length / 2;
var m = line.match(this.FIRST_PASS);
if (m) {
this.scope = m[1].length / 2;
}
});
});

Expand Down
Loading

0 comments on commit e7d03a6

Please sign in to comment.