Skip to content

Commit

Permalink
Merge pull request #79 from bennn/dr-repl
Browse files Browse the repository at this point in the history
Dr repl
  • Loading branch information
bennn committed Oct 30, 2015
2 parents 9a8d4f6 + a289168 commit 9fe69b7
Show file tree
Hide file tree
Showing 6 changed files with 35 additions and 22 deletions.
1 change: 1 addition & 0 deletions examples/english-sonnet/18.rkt
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
#lang ipoe/english-sonnet

#:poetic-license 3

Shall I compare thee to a summer's day?
Thou art more lovely and more temperate:
Expand Down
14 changes: 7 additions & 7 deletions ipoe/haiku/lang/reader.rkt
Original file line number Diff line number Diff line change
Expand Up @@ -2,11 +2,11 @@

#:name haiku
#:rhyme-scheme {[5 7 5]}
#:description
"1 stanza, 3 lines
No rhyme constraints
5 syllables in first line
7 in second
5 in last
;; 1 stanza, 3 lines
;; No rhyme constraints
;; 5 syllables in first line
;; 7 in second
;; 5 in last

;; Should be about #nature
Should be about #nature"
21 changes: 15 additions & 6 deletions ipoe/lang/reader.rkt
Original file line number Diff line number Diff line change
Expand Up @@ -37,11 +37,20 @@
(define (custom-read in)
(syntax->datum (custom-read-syntax #f in)))
(define (custom-read-syntax src-path in)
(with-syntax ([str (validate in)])
(strip-context #'(module anything racket
(provide text description)
(define description descr)
(define text 'str)))))))))
(with-syntax ([(P L O*) (validate in)]
[mod-id2 (gensym 'mod-id)])
(strip-context
#'(module mod-id2 racket
;; Set up a basic interactions environment
(require
(only-in ipoe/private/parameters parameterize-from-hash)
(only-in ipoe/private/command/dbshell dbshell))
(define (connect)
(parameterize-from-hash O* dbshell))
(define help
"Type '(connect)' to open a connection to the iPoe database")
(define description descr)
;; Print a message in Dr.Racket
(module+ test (displayln help))))))))))

;; =============================================================================

18 changes: 11 additions & 7 deletions ipoe/private/command/dbshell.rkt
Original file line number Diff line number Diff line change
Expand Up @@ -4,8 +4,9 @@

(provide
dbshell
;; (-> '() Void)
;; (->* [(Vectorof String)] Void)
;; Start a fresh REPL for the database
;; Argument should be command line arguments
)

;; -----------------------------------------------------------------------------
Expand All @@ -23,6 +24,7 @@
sequence-empty?
sequence-skip)
;; --
(only-in racket/format ~a)
(only-in racket/string string-join string-split)
(only-in racket/sequence
sequence->list)
Expand Down Expand Up @@ -238,11 +240,12 @@
(symbol->string (command-id cmd))))

(define HELP-STR
(string-join
(for/list ([c (in-list COMMAND*)])
(format " ~a : ~a" (command-id c) (command-descr c)))
"\n"
#:before-first "Available commands:\n"))
(let ([W (apply max (map (compose1 string-length symbol->string command-id) COMMAND*))])
(string-join
(for/list ([c (in-list COMMAND*)])
(format " ~a : ~a" (~a (command-id c)#:min-width W) (command-descr c)))
"\n"
#:before-first "Available commands:\n")))

;; -----------------------------------------------------------------------------
;; --- Parameters
Expand All @@ -261,7 +264,7 @@
;; -----------------------------------------------------------------------------
;; --- REPL

(define (dbshell arg*)
(define (dbshell [arg* '#()])
;; -- repl
(command-line
#:argv arg*
Expand All @@ -285,6 +288,7 @@
#:dbname d
(lambda ()
(printf "Connected to database '~a' as user '~a'.\n" d u)
(printf "Enter 'help' for information and 'quit' to quit.\n")
(if (*output-file*)
(call-with-output-file* (*output-file*) #:exists 'replace
init-repl)
Expand Down
2 changes: 1 addition & 1 deletion ipoe/private/scrape/scrape-words.rkt
Original file line number Diff line number Diff line change
Expand Up @@ -274,7 +274,7 @@
(define (check-syllables scraper w)
(word-result-num-syllables (scraper w)))

(check-apply* check-syllables
(check-apply* (lambda (scraper w) (word-result-num-syllables (scraper w)))
[dictionary.com "each" == 1]
[the-free-dictionary "each" == 1]
[merriam-webster "each" == 1]
Expand Down
1 change: 0 additions & 1 deletion ipoe/private/util/check-os.rkt
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,6 @@
(for-syntax
racket/base
syntax/parse
(only-in racket/list last)
))

;; =============================================================================
Expand Down

0 comments on commit 9fe69b7

Please sign in to comment.