Permalink
Browse files

moved all rules from Parser to OMeta -- Parser is now deprecated. als…

…o added def. of fromTo rule to OMeta grammar.
  • Loading branch information...
1 parent 2c9fb6a commit 1737db906a59c717b2ede3ee4c81258c4fde015d @alexwarth alexwarth committed Jun 28, 2011
Showing with 30 additions and 18 deletions.
  1. +30 −0 ometa-base.js
  2. +0 −18 parser.js
View
@@ -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
@@ -24,23 +24,5 @@
*/
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)
- }
})

0 comments on commit 1737db9

Please sign in to comment.