Changeset trunk,10 for trunk/parse3.lisp


Ignore:
Timestamp:
06/18/2007 04:17:50 PM (19 years ago)
Author:
dsowen
revision id:
svn-v3-trunk0:2948df59-2b31-0410-8e06-c40c0b09d5b6:trunk:10
Message:

Finished re-indenting.
Simplified the sequence matcher.
Finished changing tree-building (except the required and forbidden parsers).
Fixed: The maximum count on a count-matcher wasn't being used properly.

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/parse3.lisp

    r9 r10  
    55
    66(defmacro if-matcher-parser (input parser (next match)
    7                                    &body (&optional (then t) else))
     7                             &body (&optional (then t) else))
    88  (declare (symbol parser next match))
    99  (with-gensyms (ok)
     
    1212
    1313(defmacro if-matches-char (input char (next match)
    14                                 &body (&optional (then t) else))
     14                          &body (&optional (then t) else))
    1515  (declare (symbol next match)
    1616           (character char))
     
    3434
    3535(defmacro if-matches-regex (input regex (next match)
    36                                   &body (&optional (then t) else))
     36                            &body (&optional (then t) else))
    3737  (declare (string regex)
    3838           (symbol next match))
     
    4848
    4949(defmacro if-matches-choice (input alts (next match)
    50                                    &body (&optional (then t) else))
     50                             &body (&optional (then t) else))
    5151  (declare (symbol next match)
    5252           (list alts))
     
    6666          `(if-matches ,input ,head (,head-next ,head-match)
    6767            (if-matches-sequence ,head-next ,tail (,next ,tail-match)
    68               (let ((,match (append ,head-match ,tail-match)))
     68              (let ((,match (cons ,head-match (list ,tail-match))))
    6969                ,then)
    7070              ,else)
    7171            ,else))
    72         (with-gensyms (head-match)
    73           `(if-matches ,input ,head (,next ,head-match)
    74             (let ((,match ,head-match))
    75               ,then)
    76             ,else)))))
     72        `(if-matches ,input ,head (,next ,match) ,then ,else))))
    7773
    7874(defmacro if-matches-eqcount (input count rule (next match)
    79                                     &body (&optional (then t) else))
     75                              &body (&optional (then t) else))
    8076  "WARNING: ELSE code executes in an anonymous block!"
    8177  (declare ((or null (integer 0)) count)
     
    8884          (if-matches ,next ,rule (,next2 ,match2)
    8985            (setf ,next ,next2
    90                   ,match (nconc ,match (list ,match2)))
     86                  ,match (cons ,match2 ,match))
    9187            (return-from ,r ,else)))
     88        (setf ,match (nreverse ,match))
    9289        ,then))))
    9390
    9491(defmacro if-matches-maxcount (input count rule (next match)
    95                                      &body (&optional (then t) else))
     92                               &body (&optional (then t) else))
    9693  (declare ((or null (integer 0)) count)
    9794           (symbol next match)
     
    105102                      (progn
    106103                        (psetf ,next ,next2
    107                                ,match (nconc ,match (list ,match2))
     104                               ,match (cons ,match2 ,match)
    108105                               ,i (1+ ,i))
    109106                        t)))))
     107      (setf ,match (nreverse ,match))
    110108      ,then)))
    111109
    112110(defmacro if-matches-count (input mincount maxcount rule (next match)
    113                                   &body (&optional (then t) else))
     111                            &body (&optional (then t) else))
     112  (when (and maxcount mincount) (setf maxcount (- maxcount mincount)))
    114113  (with-gensyms (next2 match2)
    115114    `(if-matches-eqcount ,input ,mincount ,rule (,next2 ,match2)
Note: See TracChangeset for help on using the changeset viewer.