diff --git a/bracket/bracket-info.rkt b/bracket/bracket-info.rkt index 24843e605..9f85e05d2 100644 --- a/bracket/bracket-info.rkt +++ b/bracket/bracket-info.rkt @@ -1,29 +1,10 @@ #lang racket -(provide get-language-info get-info) +(provide get-language-info) (define (get-language-info data) (lambda (key default) - (displayln (list 'bracket-info/get-language-info key default)) (case key [(configure-runtime) '(#(bracket/runtime-config configure #f))] - [(color-lexer) - (dynamic-require 'syntax-color/default-lexer - 'default-lexer) - (displayln "HErE") - (dynamic-require "parser.rkt" - 'color-expression-lexer)] - [else default]))) - -(require racket/runtime-path) -(define-runtime-path color-lexer-path "parser.rkt") - -(define (get-info in mod line col pos) - (displayln (list 'bracket-info/get-info in mod line col pos)) - (lambda (key default) - (displayln (list 'reader/get-info key default)) - (case key - [(color-lexer) - (dynamic-require color-lexer-path 'color-expression-lexer)] [else default]))) diff --git a/bracket/bracket.rkt b/bracket/bracket.rkt index ae845b6eb..f086e1bca 100644 --- a/bracket/bracket.rkt +++ b/bracket/bracket.rkt @@ -1185,14 +1185,22 @@ (define (Plot f range [options '(List)]) ; TODO: Implement options - (displayln (list f range)) + ;(displayln (list f range)) (define y-min -5) (define y-max +5) (define excluded? #f) - (match range + ; TODO: plot2d needs to be extended to multiple functions + #;(define fs + (match functions + [(List: f ...) f] + [f (list f)] + [else (error 'Plot "TODO")])) + (define fs (list f)) + (match range [(List: var x-min x-max) + ; TODO: Declare var as a local variable ? (plot2d (if (procedure? f) - (λ (x) (displayln x) (f x)) + (λ (x) (f x)) (λ (x) (N (Substitute f (Equal var x))))) x-min x-max y-min y-max excluded?)] [else (error)])) diff --git a/bracket/lang/parser.rkt b/bracket/lang/parser.rkt index 57602649e..47e973975 100644 --- a/bracket/lang/parser.rkt +++ b/bracket/lang/parser.rkt @@ -71,7 +71,8 @@ [string (:: #\" (:* (:~ #\")) #\")] [identifier (:: letter (:* (:or letter digit #\_ #\?)))] [identifier:= (:: letter (:* (:or letter digit #\_ #\?)) ":=")] - [identifierOP (:: letter (:* (:or letter digit #\_ #\?)) "(")]) + [identifierOP (:: letter (:* (:or letter digit #\_ #\?)) "(")] + [comment (:: "%" (complement (:: any-string #\newline any-string)) #\newline)]) (define (string-drop-right n s) (substring s 0 (- (string-length s) n))) @@ -105,6 +106,8 @@ ["<>" 'NOT-EQUAL] ["≠" 'NOT-EQUAL] ["define" 'DEFINE] + [comment + (return-without-pos (expression-lexer input-port))] [string (token-STRING (substring lexeme 1 (- (string-length lexeme) 1)))] ; The parser can only look ahead 1 token, so we have 3 @@ -154,6 +157,8 @@ (syn-val lexeme 'no-color #f start-pos end-pos)] ["define" (syn-val lexeme 'constant #f start-pos end-pos)] + [comment + (syn-val lexeme 'comment #f start-pos end-pos)] [string (syn-val lexeme 'string #f start-pos end-pos)] ; The parser can only look ahead 1 token, so we have 3 @@ -165,7 +170,10 @@ [(:+ digit) (syn-val lexeme 'constant #f start-pos end-pos)] [(:: (:+ digit) #\. (:* digit)) - (syn-val lexeme 'constant #f start-pos end-pos)])) + (syn-val lexeme 'constant #f start-pos end-pos)] + ; catch anything else + [any-char + (syn-val lexeme 'error #f start-pos end-pos)])) ;; A macro to build the syntax object @@ -362,6 +370,7 @@ (define (parse-expression src stx ip) (port-count-lines! ip) + (define out ((expression-parser (if src src (object-name ip)) ; If you change any of these values, then @@ -395,3 +404,5 @@ (eq? (position-token-token peek1) 'EOF)) (begin0 peek1 (next)) (begin0 peek (next))))))) + (displayln out) + out) diff --git a/bracket/lang/reader.rkt b/bracket/lang/reader.rkt index b15dfc6cb..f0c7b8cb8 100644 --- a/bracket/lang/reader.rkt +++ b/bracket/lang/reader.rkt @@ -57,6 +57,10 @@ (define list-ref List-ref) (define-syntax (define stx) (syntax-case stx () [(_ . more) #'(Define . more)])) + (require bracket/lang/parser) + (current-read-interaction + (λ (_ in) + (parse-expression 'repl #'repl (open-input-string "1+2")))) body)) 'module-language '#(bracket/bracket-info get-language-info #f))))) diff --git a/bracket/main.rkt b/bracket/main.rkt index 810d0a26a..a9d34c014 100644 --- a/bracket/main.rkt +++ b/bracket/main.rkt @@ -16,4 +16,5 @@ [(_ sym ...) #'(begin (define sym 'sym) ...)])) - +(require bracket/lang/parser) +(provide (all-from-out bracket/lang/parser)) diff --git a/bracket/runtime-config.rkt b/bracket/runtime-config.rkt index 8016149a6..7a6234fb0 100644 --- a/bracket/runtime-config.rkt +++ b/bracket/runtime-config.rkt @@ -8,5 +8,49 @@ (display v))) (define (configure data) - (show-enabled #t)) + (show-enabled #t) + (current-read-interaction read0)) + +(require bracket/lang/reader) + +(define (without-lang-read src in) + (parameterize ([read-accept-reader #f] + [read-accept-lang #f]) + (read-one-line src in))) + +; XXX This is almost certainly wrong. +(define (read0 src ip) + (displayln (list 'read0 src ip)) + (begin0 + (without-lang-read src ip) + (current-read-interaction read1))) + +(define (read1 src ip) + (displayln (list 'read1 src ip)) + (current-read-interaction read0) + eof) + +(define (read2 src ip) + (displayln (list 'read2 src ip)) + (current-read-interaction read0) + eof) + +;; at the repl, honu will only read a single line at a time regardless +;; of how many expressions it contains +(define (read-one-line name input) + (define quit? #f) + (define one-line + (with-output-to-string + (lambda () + (let loop () + (define next (read-char input)) + (when (eof-object? next) + (set! quit? #t)) + (when (not (or (eof-object? next) + (char=? next #\newline))) + (display next) + (loop)))))) + (if quit? + eof + (read-syntax name (open-input-string one-line)))) diff --git a/plotting/adaptive-plotting.rkt b/plotting/adaptive-plotting.rkt index ea50735fd..04970b92c 100644 --- a/plotting/adaptive-plotting.rkt +++ b/plotting/adaptive-plotting.rkt @@ -21,7 +21,7 @@ ;;; http://scicomp.stackexchange.com/questions/2377/algorithms-for-adaptive-function-plotting ;;; for discussion on adaptive plotting. -(define *debug* #t) +(define *debug* #f) ; These count functions are used to measure the ; number of evaluations of the function to be drawn. @@ -262,4 +262,3 @@ (list (list 'angle: angle))))) angle])) - \ No newline at end of file