Pattern Matcher Compatible with Optima
Common Lisp
Latest commit adf38c7 Jan 4, 2017 @guicho271828 committed on GitHub Merge branch 'master' into master
Permalink
Failed to load latest commit information.
bench stylistic changes in benchmark Mar 27, 2015
level0 assert on level0 May 21, 2016
level1 shorter trace message May 22, 2016
level2 Make `defun-` and `lambda-` sugar macros handle docstrings and declar… Jan 3, 2017
ppcre SPLIT pattern Jul 21, 2016
quasiquote implemented Apr 1, 2016
test added test to ensure lambda-list signals error with nc pattern Oct 29, 2016
.gitignore cleanup Mar 1, 2015
.travis.yml allow failures in clisp Jan 4, 2017
LICENSE Add license file Jul 20, 2016
README.org [ci skip] added notes on incompatibility Jul 31, 2016
circle.yml change the order of implementations May 21, 2016
testscr.ros print some info at the beginning of tests May 21, 2016
trivia.asd include :mailto only under asdf3 May 21, 2016
trivia.benchmark.asd include :mailto only under asdf3 May 21, 2016
trivia.level0.asd include :mailto only under asdf3 May 21, 2016
trivia.level0.test.asd include :mailto only under asdf3 May 21, 2016
trivia.level1.asd include :mailto only under asdf3 May 21, 2016
trivia.level1.test.asd include :mailto only under asdf3 May 21, 2016
trivia.level2.asd new array patterns May 22, 2016
trivia.level2.docparser.asd include :mailto only under asdf3 May 21, 2016
trivia.level2.test.asd include :mailto only under asdf3 May 21, 2016
trivia.ppcre.asd include :mailto only under asdf3 May 21, 2016
trivia.ppcre.test.asd include :mailto only under asdf3 May 21, 2016
trivia.quasiquote.asd include :mailto only under asdf3 May 21, 2016
trivia.quasiquote.test.asd include :mailto only under asdf3 May 21, 2016

README.org

https://travis-ci.org/guicho271828/trivia.svg?branch=master

  • news! new pattern: lambda-list pattern. Contributed by akssri
  • news! new pattern: number-related patterns, e.g. >, <, =, <= …
  • news! Inline pattern implemented ! : @, @@ …
  • news!(04/02/2016) Support for fare-quasiquote is now available. See test/quasiquote for the usage
  • news!(04/22/2016) Added metabang-bind like macros if-match, when-match, unless-match, let-match, let*-match, let-match1
  • news!(05/21/2016) Added support for minor implementations: CMU, ECL, CLISP, ABCL.
  • news!(05/22/2016) Implemented ARRAY, SIMPLE-ARRAY, ARRAY-ROW-MAJOR, ARRAY-ROW-MAJOR* patterns! Multi-dimentional arrays are now more handy!
  • news!(07/21/2016) Added READ, LAST, SPLIT, SPLIT* patterns! Parsing the string is more conveninent.

Trivia : Trivial Pattern Matching Compiler

Trivia is a pattern matching compiler that is compatible with Optima. It shares the same testing code with Optima and acts as a drop-in replacement for 99% usage. For the basic usage, consult our wiki. Known differences between Optima and Trivia, which are bug, are described here (7/31/2016)

(defpackage :playwithit
  (:use :cl 
-       :optima))
+       :trivia))
(in-package :playwithit)

(match '(something #(0 1 2))
  ((list a (vector 0 _ b))
   (values a b)))
;; --> SOMETHING, 2

Patterns compiled with Trivia runs faster than Optima.

runtime [sec]fibonaccigomokustring-match
optima11.539.882.5
trivia [1]9.6837.41.57

[1]: trivia is using :balland2006 optimiizer

… and Trivia is more extensible. In fact, Trivia’s defpattern is able to implement all of unmodifiable, core pattern language in Optima within itself.

(defpattern cons (a b)
  (with-gensyms (it)
    `(guard1 (,it :type cons) (consp ,it) (car ,it) ,a (cdr ,it) ,b)))

Detailed documentation is in github wiki.

Dependency & Testing

  • Level 0,1 : Alexandria only.
  • Level 2 : Additionally, lisp-namespace and closer-mop.

To run the tests with trivial optimizer, (asdf:test-system :trivia) .

In order to run the same test with :balland2006 optimizer activated, run follows:

;; $ git clone https://github.com/guicho271828/trivia.balland2006
;; $ git clone https://github.com/guicho271828/type-i

(asdf:test-system :trivia.balland2006.enabled)

To run the benchmark:

(asdf:test-system :trivia.benchmark)