Permalink
Browse files

Adding js2

  • Loading branch information...
1 parent dff6d86 commit 1f8ebff0c9114fa78b0b4b6eb98e530eaeb177db @jeffsu committed Apr 3, 2011
Showing with 235 additions and 277 deletions.
  1. +30 −35 dist/browser/js2-full.js
  2. +4 −5 dist/gem/CHANGELOG
  3. +30 −35 dist/gem/lib/js2/js2.js
  4. +4 −5 dist/npm/CHANGELOG
  5. +30 −35 dist/npm/lib/js2.js
  6. +30 −35 flavors/browser-full.js
  7. +30 −35 flavors/node.js
  8. +30 −35 flavors/ringo-full.js
  9. +30 −35 flavors/ruby.js
  10. +16 −21 src/Common/JSML.js2
  11. +1 −1 tests/src/jsml.js2
View
@@ -1550,7 +1550,7 @@ JS2.Class.extend('JSML', function(KLASS, OO){
JS2.Class.extend('JSMLElement', function(KLASS, OO){
OO.addMember("SCOPE_REGEX",/^(\s*)(.*)$/);
- OO.addMember("SPLIT_REGEX",/^([^=-\s]*)(=|-)?(?:\s*)(.*)$/);
+ OO.addMember("SPLIT_REGEX",/^([^=-\s\{]*)(\{.*\})?(=|-)?(?:\s*)(.*)$/);
OO.addMember("TOKEN_REGEX",/(\%|\#|\.)([\w-]+)/g);
OO.addMember("JS_REGEX",/^(-|=)(.*)$/g);
OO.addMember("SCOPE_OFFSET",1);
@@ -1580,13 +1580,14 @@ JS2.Class.extend('JSMLElement', function(KLASS, OO){
this.attributes = {};
this.line = line;
var self = this;
-<<<<<<< HEAD
+
var splitted = line.match(this.SPLIT_REGEX);
+ var tokens = splitted[1];
+ var attrs = splitted[2];
+ var jsType = splitted[3];
+ var content = splitted[4];
- splitted[1].replace(this.TOKEN_REGEX, function(match, type, name){
-=======
- line = line.replace(this.TOKEN_REGEX, function(match, type, name){
->>>>>>> bed239574b501453ee0f22330c71562aff44ce0b
+ tokens.replace(this.TOKEN_REGEX, function(match, type, name){
switch(type) {
case '%': self.nodeType = name; break;
case '.': self.classes.push(name); break;
@@ -1595,35 +1596,32 @@ JS2.Class.extend('JSMLElement', function(KLASS, OO){
return '';
});
-<<<<<<< HEAD
- if (splitted[2] == '=') {
- this.jsEQ = splitted[3];
- } else if (splitted[2] == '-') {
- this.jsExec = splitted[3];
+ if (jsType == '=') {
+ this.jsEQ = content;
+ } else if (jsType == '-') {
+ this.jsExec = content;
} else {
- this.content = splitted[3];
+ this.content = content;
+ }
+
+ if (attrs) {
+ eval('this.attributes = ' + attrs + ';');
}
if (!this.nodeType && (this.classes.length || this.nodeID)) {
this.nodeType = 'div';
}
- };
+ });
- function flatten() {
+ OO.addMember("flatten",function () {
var out = [];
for(var _i1=0,_c1=this.children,_l1=_c1.length,c;(c=_c1[_i1])||(_i1<_l1);_i1++){
var arr = c.flatten();
for(var _i2=0,_c2=arr,_l2=_c2.length,item;(item=_c2[_i2])||(_i2<_l2);_i2++){
out.push(item);
-=======
- line = line.replace(this.JS_OUT_REGEX, function(match, type, content){
- switch(type) {
- case '=': this.jsEQ = content; break;
- case '-': this.jsExec = content; break;
->>>>>>> bed239574b501453ee0f22330c71562aff44ce0b
}
- };
+ }
if (this.nodeType) {
this.handleJsEQ(out);
@@ -1637,33 +1635,32 @@ JS2.Class.extend('JSMLElement', function(KLASS, OO){
}
return out;
- }
+ });
- function handleJsEQ(out) {
+ OO.addMember("handleJsEQ",function (out) {
if (this.jsEQ) {
this.jsEQ = this.jsEQ.replace(/;\s*$/, '');
out.unshift('out.push(' + this.jsEQ + ');\n');
}
- }
+ });
- function handleContent(out) {
+ OO.addMember("handleContent",function (out) {
if (this.content != null && this.content.length > 0) {
out.unshift('out.push(' + JSON.stringify(this.content) + ');\n');
}
- }
+ });
- function handleJsExec(out) {
+ OO.addMember("handleJsExec",function (out) {
if (this.jsExec) {
out.unshift(this.jsExec);
if (this.jsExec.match(/\{\s*$/)) {
out.push("}\n");
}
}
- }
-<<<<<<< HEAD
+ });
- function getAttributes() {
+ OO.addMember("getAttributes",function () {
if (!this.attributes) return '';
var out = [];
@@ -1679,11 +1676,9 @@ JS2.Class.extend('JSMLElement', function(KLASS, OO){
}
return (out.length ? ' ' : '') + out.join(' ');
- }
-=======
->>>>>>> bed239574b501453ee0f22330c71562aff44ce0b
-}
-););
+ });
+});
+
JS2.TEMPLATES = { jsml: JS2.JSML };
(function (undefined, JS2) {
View
@@ -1,11 +1,10 @@
-<<<<<<< Updated upstream
0.3.13
* fixed problem that doesn't allow toString methods
-=======
+ * JSML POC
+
0.3.12
* fixed parse error in JSMLElement
* Yanking 0.3.11
->>>>>>> Stashed changes
0.3.11
* fixed minor issue finding Rails.root in rack
@@ -24,7 +23,7 @@
0.3.8
* fied "render"
* fixed comment block bug
- * using target-dir instead of out-dir
+ * using target-dir instead of out-dir
0.3.7
* fixed foreach counter
@@ -36,7 +35,7 @@
0.3.5
* Added scope and binding support to shorthand functions
- * Added support for modules
+ * Added support for modules
0.3.4
* coded reduce to clojure spec
View
@@ -1546,7 +1546,7 @@ JS2.Class.extend('JSML', function(KLASS, OO){
JS2.Class.extend('JSMLElement', function(KLASS, OO){
OO.addMember("SCOPE_REGEX",/^(\s*)(.*)$/);
- OO.addMember("SPLIT_REGEX",/^([^=-\s]*)(=|-)?(?:\s*)(.*)$/);
+ OO.addMember("SPLIT_REGEX",/^([^=-\s\{]*)(\{.*\})?(=|-)?(?:\s*)(.*)$/);
OO.addMember("TOKEN_REGEX",/(\%|\#|\.)([\w-]+)/g);
OO.addMember("JS_REGEX",/^(-|=)(.*)$/g);
OO.addMember("SCOPE_OFFSET",1);
@@ -1576,13 +1576,14 @@ JS2.Class.extend('JSMLElement', function(KLASS, OO){
this.attributes = {};
this.line = line;
var self = this;
-<<<<<<< HEAD
+
var splitted = line.match(this.SPLIT_REGEX);
+ var tokens = splitted[1];
+ var attrs = splitted[2];
+ var jsType = splitted[3];
+ var content = splitted[4];
- splitted[1].replace(this.TOKEN_REGEX, function(match, type, name){
-=======
- line = line.replace(this.TOKEN_REGEX, function(match, type, name){
->>>>>>> bed239574b501453ee0f22330c71562aff44ce0b
+ tokens.replace(this.TOKEN_REGEX, function(match, type, name){
switch(type) {
case '%': self.nodeType = name; break;
case '.': self.classes.push(name); break;
@@ -1591,35 +1592,32 @@ JS2.Class.extend('JSMLElement', function(KLASS, OO){
return '';
});
-<<<<<<< HEAD
- if (splitted[2] == '=') {
- this.jsEQ = splitted[3];
- } else if (splitted[2] == '-') {
- this.jsExec = splitted[3];
+ if (jsType == '=') {
+ this.jsEQ = content;
+ } else if (jsType == '-') {
+ this.jsExec = content;
} else {
- this.content = splitted[3];
+ this.content = content;
+ }
+
+ if (attrs) {
+ eval('this.attributes = ' + attrs + ';');
}
if (!this.nodeType && (this.classes.length || this.nodeID)) {
this.nodeType = 'div';
}
- };
+ });
- function flatten() {
+ OO.addMember("flatten",function () {
var out = [];
for(var _i1=0,_c1=this.children,_l1=_c1.length,c;(c=_c1[_i1])||(_i1<_l1);_i1++){
var arr = c.flatten();
for(var _i2=0,_c2=arr,_l2=_c2.length,item;(item=_c2[_i2])||(_i2<_l2);_i2++){
out.push(item);
-=======
- line = line.replace(this.JS_OUT_REGEX, function(match, type, content){
- switch(type) {
- case '=': this.jsEQ = content; break;
- case '-': this.jsExec = content; break;
->>>>>>> bed239574b501453ee0f22330c71562aff44ce0b
}
- };
+ }
if (this.nodeType) {
this.handleJsEQ(out);
@@ -1633,33 +1631,32 @@ JS2.Class.extend('JSMLElement', function(KLASS, OO){
}
return out;
- }
+ });
- function handleJsEQ(out) {
+ OO.addMember("handleJsEQ",function (out) {
if (this.jsEQ) {
this.jsEQ = this.jsEQ.replace(/;\s*$/, '');
out.unshift('out.push(' + this.jsEQ + ');\n');
}
- }
+ });
- function handleContent(out) {
+ OO.addMember("handleContent",function (out) {
if (this.content != null && this.content.length > 0) {
out.unshift('out.push(' + JSON.stringify(this.content) + ');\n');
}
- }
+ });
- function handleJsExec(out) {
+ OO.addMember("handleJsExec",function (out) {
if (this.jsExec) {
out.unshift(this.jsExec);
if (this.jsExec.match(/\{\s*$/)) {
out.push("}\n");
}
}
- }
-<<<<<<< HEAD
+ });
- function getAttributes() {
+ OO.addMember("getAttributes",function () {
if (!this.attributes) return '';
var out = [];
@@ -1675,11 +1672,9 @@ JS2.Class.extend('JSMLElement', function(KLASS, OO){
}
return (out.length ? ' ' : '') + out.join(' ');
- }
-=======
->>>>>>> bed239574b501453ee0f22330c71562aff44ce0b
-}
-););
+ });
+});
+
JS2.TEMPLATES = { jsml: JS2.JSML };
View
@@ -1,11 +1,10 @@
-<<<<<<< Updated upstream
0.3.13
* fixed problem that doesn't allow toString methods
-=======
+ * JSML POC
+
0.3.12
* fixed parse error in JSMLElement
* Yanking 0.3.11
->>>>>>> Stashed changes
0.3.11
* fixed minor issue finding Rails.root in rack
@@ -24,7 +23,7 @@
0.3.8
* fied "render"
* fixed comment block bug
- * using target-dir instead of out-dir
+ * using target-dir instead of out-dir
0.3.7
* fixed foreach counter
@@ -36,7 +35,7 @@
0.3.5
* Added scope and binding support to shorthand functions
- * Added support for modules
+ * Added support for modules
0.3.4
* coded reduce to clojure spec
Oops, something went wrong.

0 comments on commit 1f8ebff

Please sign in to comment.