Skip to content
This repository has been archived by the owner on Feb 3, 2018. It is now read-only.

Commit

Permalink
factor< and factor<= are no longer macros
Browse files Browse the repository at this point in the history
  • Loading branch information
joshua-choi committed May 28, 2009
1 parent ecf83f1 commit f76b6e8
Showing 1 changed file with 4 additions and 4 deletions.
8 changes: 4 additions & 4 deletions src/name/choi/joshua/fnparse.clj
Original file line number Diff line number Diff line change
Expand Up @@ -326,17 +326,17 @@
(with-monad parser-m
(m-seq (replicate factor subrule))))

(defmacro factor<
(defn factor<
"Same as the factor= function, except that the new rule eats up tokens only until the
given subrule is fulfilled one less times than the factor. The new rule would never fail.
(factor< 3 :a) would eat the first two tokens [:a :a :a :a :b] and return:
[[:a :a] (list :a :a :b)].
(factor< 3 :a) would eat the first three tokens [:b] and return:
[nil (list :b)]"
[factor subrule]
`(alt (factor= ~(dec factor) ~subrule) (rep< ~factor ~subrule)))
(alt (factor= (dec factor) subrule) (rep< factor subrule)))

(defmacro factor<=
(defn factor<=
"Same as the factor= function, except that the new rule always succeeds, consuming tokens
until the subrule is fulfilled the same amount of times as the given factor. The new rule
would never fail.
Expand All @@ -345,7 +345,7 @@
(factor<= 3 :a) would eat the first three tokens [:b] and return:
[nil (list :b)]"
[factor subrule]
`(alt (factor= ~factor ~subrule) (rep< ~factor ~subrule)))
(alt (factor= factor subrule) (rep< factor subrule)))

(defn failpoint
"Creates a rule that applies a failpoint to a subrule. When the subrule fails—i.e., it
Expand Down

0 comments on commit f76b6e8

Please sign in to comment.