1. llibra
  2. aly

Commits

llibra  committed 953b627

Supported the latest version of fivepm.

Fivepm is now called optima.

  • Participants
  • Parent commits 4f88cc3
  • Branches default

Comments (0)

Files changed (5)

File README.markdown

View file
  • Ignore whitespace
 
 * [Alexandria](http://common-lisp.net/project/alexandria/)
 * [Anaphora](http://common-lisp.net/project/anaphora/)
-* [fivepm](https://github.com/m2ym/fivepm)
+* [optima](https://github.com/m2ym/optima)
 
 Install
 -------

File aly.asd

View file
  • Ignore whitespace
   :version "0.1"
   :author "Manabu Takayama <learn.libra@gmail.com>"
   :licence "MIT License"
-  :depends-on (:alexandria :anaphora :fivepm)
+  :depends-on (:alexandria :anaphora :optima)
   :components ((:module "src"
                         :serial t
                         :components ((:file "packages")

File src/char.lisp

View file
  • Ignore whitespace
   (labels ((rec (stream1 index)
              (if (= index (length string))
                  (success nil stream1)
-                 (ematch-values
+                 (multiple-value-ematch
                      (funcall (specific-char (aref string index)) stream1)
                    ((t _ stream2 _ _)
                     (rec stream2 (1+ index)))
                    ((nil pos msgs)
                     (failure pos msgs))))))
     (lambda (stream)
-      (ematch-values (rec stream 0)
+      (multiple-value-ematch (rec stream 0)
         ((t _ stream pos msgs)
          (success string stream pos msgs))
         ((nil pos msgs)

File src/core.lisp

View file
  • Ignore whitespace
 
 (defun bind (parser fn)
   (lambda (stream)
-    (ematch-values (funcall parser stream)
+    (multiple-value-ematch (funcall parser stream)
       ((t value1 stream1 _ msgs1)
-       (ematch-values (funcall (funcall fn value1) stream1)
+       (multiple-value-ematch (funcall (funcall fn value1) stream1)
          ((t value2 stream2 pos2 msgs2)
           (let ((msgs (if (eq stream1 stream2) (cons msgs1 msgs2) msgs2)))
             (success value2 stream2 pos2 msgs)))
 
 (defun choice2 (parser1 parser2)
   (lambda (stream)
-    (ematch-values (funcall parser1 stream)
+    (multiple-value-ematch (funcall parser1 stream)
       ((t value stream pos msgs)
        (success value stream pos msgs))
       ((nil pos1 msgs1)
        (if (eq stream pos1)
-           (ematch-values (funcall parser2 pos1)
+           (multiple-value-ematch (funcall parser2 pos1)
              ((t value2 stream2 pos2 msgs2)
               (let ((msgs (if (eq pos1 stream2) (cons msgs1 msgs2) msgs2)))
                 (success value2 stream2 pos2 msgs)))
 
 (defun try (parser)
   (lambda (stream)
-    (ematch-values (funcall parser stream)
+    (multiple-value-ematch (funcall parser stream)
       ((t value stream pos msgs)
        (success value stream pos msgs))
       ((nil pos msgs)
 
 (defun expect (parser x)
   (lambda (stream0)
-    (ematch-values (funcall parser stream0)
+    (multiple-value-ematch (funcall parser stream0)
       ((t value stream pos msgs)
        (let ((msgs (if (eq stream0 stream) (list x) msgs)))
          (success value stream pos msgs)))
 ;; TODO: Treating a parser that accepts an empty string properly
 (defun many-common (accum-fn parser stream)
   (labels ((rec (stream0 accum)
-             (ematch-values (funcall parser stream0)
+             (multiple-value-ematch (funcall parser stream0)
                ((t value stream)
                 (rec stream (funcall accum-fn value accum)))
                ((nil pos msgs)
 
 (defun many (parser)
   (lambda (stream)
-    (ematch-values (many-common #'cons parser stream)
+    (multiple-value-ematch (many-common #'cons parser stream)
       ((t value stream pos msgs)
        (success (nreverse value) stream pos msgs))
       ((nil pos msgs)
 
 (defun parse (parser input &key (parser-error-p t))
   (let ((stream (parser-stream input)))
-    (ematch-values (funcall parser stream)
+    (multiple-value-ematch (funcall parser stream)
       ((t value)
        (values value t))
       ((nil pos msgs)

File src/packages.lisp

View file
  • Ignore whitespace
 (defpackage :aly.core
   (:use :cl :aly.util :aly.stream :aly.condition)
   (:import-from :alexandria :with-gensyms :flatten)
-  (:import-from :5pm :match :ematch :ematch-values :guard)
+  (:import-from :optima :match :ematch :multiple-value-ematch :guard)
   (:export :success :failure :satisfy :unit :fail :bind :mlet1 :mlet* :seq :seq1
            :seqn :seq/bind :choice :try :expect :many :skip-many :eoi :parse))
 
 (defpackage :aly.char
   (:use :cl :aly.util :aly.core :aly.combinator)
   (:import-from :alexandria :curry :rcurry)
-  (:import-from :5pm :ematch-values)
+  (:import-from :optima :multiple-value-ematch)
   (:export :specific-char :specific-string :one-of :none-of :any-char :upper
            :lower :letter :alpha-num :digit :decimal-digit :hex-digit :oct-digit
            :newline :tab :whitespace :whitespaces))