Browse files

Merged alex's commit 1737db9 [ moved all rules from Parser to OMeta -…

…- Parser is now deprecated. also added def. of fromTo rule to OMeta grammar. ]
  • Loading branch information...
1 parent f2626c9 commit 13c67ddd59178dfaef8105a593c096c30d4fa915 @tristanls committed Jul 2, 2011
View
30 node_modules/ometajsnode/lib/ometa-base.js
@@ -464,6 +464,36 @@ OMeta = {
this._lookahead(function() { return this._apply(rule); });
return r;
},
+ listOf: function() {
+ var rule = this._apply("anything"),
+ delim = this._apply("anything");
+ return this._or(function() {
+ var r = this._apply(rule);
+ return this._many(function() {
+ this._applyWithArgs("token", delim);
+ return this._apply(rule);
+ },
+ r);
+ },
+ function() { return []; });
+ },
+ token: function() {
+ var cs = this._apply("anything");
+ this._apply("spaces");
+ return this._applyWithArgs("seq", cs);
+ },
+ fromTo: function () {
+ var x = this._apply("anything"),
+ y = this._apply("anything");
+ return this._consumedBy(function() {
+ this._applyWithArgs("seq", x);
+ this._many(function() {
+ this._not(function() { this._applyWithArgs("seq", y); });
+ this._apply("char");
+ });
+ this._applyWithArgs("seq", y);
+ });
+ },
initialize: function() { },
// match and matchAll are a grammar's "public interface"
View
18 node_modules/ometajsnode/lib/parser.js
@@ -24,22 +24,4 @@
*/
Parser = objectThatDelegatesTo(OMeta, {
- listOf: function() {
- var rule = this._apply("anything"),
- delim = this._apply("anything");
- return this._or(function() {
- var r = this._apply(rule);
- return this._many(function() {
- this._applyWithArgs("token", delim);
- return this._apply(rule);
- },
- r);
- },
- function() { return []; });
- },
- token: function() {
- var cs = this._apply("anything");
- this._apply("spaces");
- return this._applyWithArgs("seq", cs);
- }
});
View
62 node_modules/ometajsnode/ometajs/ometajs.js
@@ -1,4 +1,4 @@
-// lib.js
+// TODO: lib.js
/*
Copyright (c) 2007-2010 Alessandro Warth <awarth@cs.ucla.edu>
@@ -179,7 +179,7 @@ getTag = (function() {
};
})();
-// ometa-base.js
+// TODO: ometa-base.js
/*
Copyright (c) 2007-2010 Alessandro Warth <awarth@cs.ucla.edu>
@@ -647,6 +647,36 @@ notLast: function() {
this._lookahead(function() { return this._apply(rule); });
return r;
},
+listOf: function() {
+ var rule = this._apply("anything"),
+ delim = this._apply("anything");
+ return this._or(function() {
+ var r = this._apply(rule);
+ return this._many(function() {
+ this._applyWithArgs("token", delim);
+ return this._apply(rule);
+ },
+ r);
+ },
+ function() { return []; });
+},
+token: function() {
+ var cs = this._apply("anything");
+ this._apply("spaces");
+ return this._applyWithArgs("seq", cs);
+},
+fromTo: function () {
+ var x = this._apply("anything"),
+ y = this._apply("anything");
+ return this._consumedBy(function() {
+ this._applyWithArgs("seq", x);
+ this._many(function() {
+ this._not(function() { this._applyWithArgs("seq", y); });
+ this._apply("char");
+ });
+ this._applyWithArgs("seq", y);
+ });
+},
initialize: function() { },
// match and matchAll are a grammar's "public interface"
@@ -689,7 +719,7 @@ createInstance: function() {
}
};
-// parser.js
+// TODO: parser.js
/*
Copyright (c) 2007, 2008 Alessandro Warth <awarth@cs.ucla.edu>
@@ -717,27 +747,9 @@ OTHER DEALINGS IN THE SOFTWARE.
*/
Parser = objectThatDelegatesTo(OMeta, {
-listOf: function() {
- var rule = this._apply("anything"),
- delim = this._apply("anything");
- return this._or(function() {
- var r = this._apply(rule);
- return this._many(function() {
- this._applyWithArgs("token", delim);
- return this._apply(rule);
- },
- r);
- },
- function() { return []; });
-},
-token: function() {
- var cs = this._apply("anything");
- this._apply("spaces");
- return this._applyWithArgs("seq", cs);
-}
});
-// bs-js-compiler.js
+// TODO: bs-js-compiler.js
{BSJSParser=objectThatDelegatesTo(Parser,{
"fromTo":function(){var $elf=this,_fromIdx=this.input.idx,x,y;return (function(){x=this._apply("anything");y=this._apply("anything");this._applyWithArgs("seq",x);this._many((function(){return (function(){this._not((function(){return this._applyWithArgs("seq",y)}));return this._apply("char")}).call(this)}));return this._applyWithArgs("seq",y)}).call(this)},
@@ -821,7 +833,7 @@ token: function() {
"case":function(){var $elf=this,_fromIdx=this.input.idx,x,y;return (function(){x=this._apply("trans");y=this._apply("trans");return ((("case " + x) + ": ") + y)}).call(this)},
"default":function(){var $elf=this,_fromIdx=this.input.idx,y;return (function(){y=this._apply("trans");return ("default: " + y)}).call(this)}})}
-// bs-ometa-compiler.js
+// TODO: bs-ometa-compiler.js
{BSOMetaParser=objectThatDelegatesTo(Parser,{
"fromTo":function(){var $elf=this,_fromIdx=this.input.idx,x,y;return (function(){x=this._apply("anything");y=this._apply("anything");this._applyWithArgs("seq",x);this._many((function(){return (function(){this._not((function(){return this._applyWithArgs("seq",y)}));return this._apply("char")}).call(this)}));return this._applyWithArgs("seq",y)}).call(this)},
@@ -885,13 +897,13 @@ token: function() {
"trans":function(){var $elf=this,_fromIdx=this.input.idx,t,ans;return (function(){this._form((function(){return (function(){t=this._apply("anything");return ans=this._applyWithArgs("apply",t)}).call(this)}));return ans}).call(this)},
"transFn":function(){var $elf=this,_fromIdx=this.input.idx,x;return (function(){x=this._apply("trans");return ["(function(){return ",x,"})"].join("")}).call(this)}});(BSOMetaTranslator["jumpTableCode"]=(function (cases){var buf=new StringBuffer();buf.nextPutAll("(function(){switch(this._apply(\'anything\')){");for(var i=(0);(i < cases["length"]);(i+=(1))){buf.nextPutAll((((("case " + cases[i][(0)]) + ":return ") + cases[i][(1)]) + ";"))};buf.nextPutAll("default: throw fail}}).call(this)");return buf.contents()}))}
-// bs-ometa-js-compiler.js
+// TODO: bs-ometa-js-compiler.js
{var BSOMetaJSParser=exports.BSOMetaJSParser=objectThatDelegatesTo(BSJSParser,{
"srcElem":function(){var $elf=this,_fromIdx=this.input.idx,r;return this._or((function(){return (function(){this._apply("spaces");r=this._applyWithArgs("foreign",BSOMetaParser,'grammar');this._apply("sc");return r}).call(this)}),(function(){return BSJSParser._superApplyWithArgs(this,'srcElem')}))}});var BSOMetaJSTranslator=exports.BSOMetaJSTranslator=objectThatDelegatesTo(BSJSTranslator,{
"Grammar":function(){var $elf=this,_fromIdx=this.input.idx;return this._applyWithArgs("foreign",BSOMetaTranslator,'Grammar')}})}
-// bs-ometa-optimizer.js
+// TODO: bs-ometa-optimizer.js
{BSNullOptimization=objectThatDelegatesTo(OMeta,{
"setHelped":function(){var $elf=this,_fromIdx=this.input.idx;return (this["_didSomething"]=true)},

0 comments on commit 13c67dd

Please sign in to comment.