Skip to content

Commit

Permalink
bumped version to 0.5
Browse files Browse the repository at this point in the history
  • Loading branch information
aoh committed Jul 20, 2016
1 parent b340be5 commit 5626916
Show file tree
Hide file tree
Showing 2 changed files with 22 additions and 4 deletions.
2 changes: 1 addition & 1 deletion rad/main.scm
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@
#false)))
(else #f)))

(define version-str "Radamsa 0.4") ;; aka lazy list
(define version-str "Radamsa 0.5")

(define usage-text "Usage: radamsa [arguments] [file ...]")

Expand Down
24 changes: 21 additions & 3 deletions rad/output.scm
Original file line number Diff line number Diff line change
Expand Up @@ -50,10 +50,27 @@
(else ;; no more numbers
(values (cons x ll) n))))))

(define default-path ".rad")
(define default-suffix (cdr (string->list default-path)))

(define (suffix-char? x)
(not (has? '(#\. #\/ #\\) x)))

(define (path-suffix path default)
(lets ((hd tl (take-while suffix-char? (reverse (string->list path)))))
(if (and (pair? tl) (eq? (car tl) #\.))
(reverse hd)
default-suffix)))

(define (source-path meta def)
(or (get meta 'source #false) ;; file generator
(get meta 'head #false) ;; jump generator (head -> tail)
def))

(define (file-writer pat suf)
(define (gen meta)
(lets
((path ;; <- could also just regex it there
((path
(runes->string
(str-foldr
(λ (char tl)
Expand All @@ -63,7 +80,8 @@
((and (eq? char #\%) (pair? tl))
(case (car tl)
((#\n) (render (get meta 'nth 0) (cdr tl)))
((#\s) (append suf (cdr tl)))
((#\s) (append (path-suffix (source-path meta default-path) default-path) (cdr tl)))
((#\p) (append suf (cdr tl)))
((#\0) ;; %0[0-9]+n -> testcase number with padding
(lets
((tlp pad (get-natural tl))
Expand All @@ -86,7 +104,7 @@
(print*-to stderr
(list "Warning: unknown pattern in output path: '"
(list->string (list char (car tl)))
"'. Did you mean '%n'?"))
"'. Did you mean '%n, %s or %p'?"))
(cons char tl))))
(else (cons char tl))))
null pat)))
Expand Down

0 comments on commit 5626916

Please sign in to comment.