Skip to content

Commit

Permalink
is-paired returns false if it reaches a parent
Browse files Browse the repository at this point in the history
  • Loading branch information
bel28kent committed Sep 1, 2024
1 parent f6ef9e0 commit dada847
Show file tree
Hide file tree
Showing 3 changed files with 31 additions and 2 deletions.
21 changes: 21 additions & 0 deletions tests/tools/autowedge.rkt
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@
"../../tools/autowedge/autowedge.rkt")

(define wedge-tree (hfile->ab-hgraph (path->hfile "data/wedge.krn") htree))
(define parent-tree (hfile->ab-hgraph (path->hfile "data/parent.krn") htree))

; autowedge
(check-expect (autowedge wedge-tree)
Expand Down Expand Up @@ -67,5 +68,25 @@
(leaf (token "[" SPINE-DATA 24))
(leaf (token "==" MEASURE 25))
(leaf (token "*-" SPINE-TERMINATOR 26)))))))
(check-expect (autowedge parent-tree)
(ab-hgraph (root (list (list (leaf (token "**kern" EXCLUSIVE-INTERPRETATION 0))
(parent (token "*^" SPINE-SPLIT 1)
(list (leaf (token "4a" SPINE-DATA 2))
(leaf (token "*" NULL-INTERPRETATION 3))
(leaf (token "*v" SPINE-JOIN 4)))
(list (leaf (token "4aa" SPINE-DATA 2))
(leaf (token "*" NULL-INTERPRETATION 3))
(leaf (token "*v" SPINE-JOIN 4))))
(leaf (token "==" MEASURE 5))
(leaf (token "*-" SPINE-TERMINATOR 6)))
(list (leaf (token "**dynam" EXCLUSIVE-INTERPRETATION 0))
(parent (token "*^" SPINE-SPLIT 1)
(list (leaf (token "p" SPINE-DATA 2))
(leaf (token "*v" SPINE-JOIN 3)))
(list (leaf (token "pp" SPINE-DATA 2))
(leaf (token "*v" SPINE-JOIN 3))))
(leaf (token "*" NULL-INTERPRETATION 4))
(leaf (token "==" MEASURE 5))
(leaf (token "*-" SPINE-TERMINATOR 6)))))))

(test)
7 changes: 7 additions & 0 deletions tests/tools/data/parent.krn
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
**kern **dynam
*^ *^
4a 4aa p pp
* * *v *v
*v *v *
== ==
*- *-
5 changes: 3 additions & 2 deletions tools/autowedge/autowedge.rkt
Original file line number Diff line number Diff line change
Expand Up @@ -60,6 +60,7 @@
(define (is-paired? f lon)
(local [(define (paired? lon)
(cond [(empty? lon) #f]
[(parent? (first lon)) #f]
[(not (regexp-match? #px"[\\[\\]\\.=\\*!]"
(token-token (leaf-token (first lon)))))
#f]
Expand Down Expand Up @@ -91,10 +92,10 @@
(define r (if (empty? branch)
empty
(rest branch)))
(define n? (if (and (leaf? f) (not (empty? f)))
(define n? (if (leaf? f)
(not-angle-or-null? f)
#f))
(define p? (if (and (leaf? f) (not (empty? f)))
(define p? (if (leaf? f)
(is-paired? f r)
#f))]
(cond [(empty? branch) empty]
Expand Down

0 comments on commit dada847

Please sign in to comment.