Skip to content

Instantly share code, notes, and snippets.

@tokiwoousaka
Last active December 16, 2015 18:49
Show Gist options
  • Save tokiwoousaka/5480615 to your computer and use it in GitHub Desktop.
Save tokiwoousaka/5480615 to your computer and use it in GitHub Desktop.
egisonのmatcherの定義。 見様見真似で書いてみたけどどうしてこーなるのか解らんw
(define $hoge
(matcher {
;; <primitive-pp>
[,$val [] {[$tgt
(match [val tgt] [hoge hoge] {
[[<aaa> <aaa>] {[]}]
[[<bbb> <bbb>] {[]}]
[[<ccc> <ccc>] {[]}]
[_ {}]})]}]
;; <primitive-dp>
[<aaa> [] {[<AAA> {[]}] [_ {}]}]
[<bbb> [] {[<BBB> {[]}] [_ {}]}]
[<ccc> [] {[<CCC> {[]}] [_ {}]}]}))
;; <OK> patterns
(test "------------")
(test (match <AAA> hoge {[<aaa> <OK>] [_ <KO>]}))
(test (match <AAA> hoge {[,<AAA> <OK>] [_ <KO>]}))
(test (match <BBB> hoge {[<bbb> <OK>] [_ <KO>]}))
(test (match <BBB> hoge {[,<BBB> <OK>] [_ <KO>]}))
(test (match <CCC> hoge {[<ccc> <OK>] [_ <KO>]}))
(test (match <CCC> hoge {[,<CCC> <OK>] [_ <KO>]}))
;; <KO> patterns
(test "------------")
(test (match <AAA> hoge {[<bbb> <OK>] [_ <KO>]}))
(test (match <AAA> hoge {[,<BBB> <OK>] [_ <KO>]}))
(test (match <AAA> hoge {[<ccc> <OK>] [_ <KO>]}))
(test (match <AAA> hoge {[,<CCC> <OK>] [_ <KO>]}))
(test (match <BBB> hoge {[<aaa> <OK>] [_ <KO>]}))
(test (match <BBB> hoge {[,<AAA> <OK>] [_ <KO>]}))
(test (match <BBB> hoge {[<ccc> <OK>] [_ <KO>]}))
(test (match <BBB> hoge {[,<CCC> <OK>] [_ <KO>]}))
(test (match <CCC> hoge {[<aaa> <OK>] [_ <KO>]}))
(test (match <CCC> hoge {[,<AAA> <OK>] [_ <KO>]}))
(test (match <CCC> hoge {[<bbb> <OK>] [_ <KO>]}))
(test (match <CCC> hoge {[,<BBB> <OK>] [_ <KO>]}))
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment