adjust source

dev-srcloc
Matthew Butterick 8 years ago
parent 522057f692
commit 640c716758

@ -1,8 +1,8 @@
#lang br #lang br
(require racket/draw) (require racket/draw)
(provide make-jsonic-buttons) (provide make-buttons)
(define make-jsonic-buttons (define make-buttons
(list (let ([label "Insert expression"] (list (let ([label "Insert expression"]
[bitmap (make-object bitmap% 16 16)] [bitmap (make-object bitmap% 16 16)]
[callback (λ (drr-frame) [callback (λ (drr-frame)

@ -1,34 +1,26 @@
#lang br #lang br
(require parser-tools/lex (require brag/support
syntax-color/racket-lexer syntax-color/racket-lexer)
parser-tools/lex-sre)
(provide color-jsonic)
(define in-racket-expr? #f) (define in-racket-expr? #f)
(define (at-racket-boundary? input-port) (define (color-jsonic port)
(equal? (peek-string 2 0 input-port) "$@"))
(module+ test
(require rackunit)
(check-true (at-racket-boundary? (open-input-string "$@foo")))
(check-false (at-racket-boundary? (open-input-string "foo$@"))))
(define (color-jsonic input-port)
(define jsonic-lexer (define jsonic-lexer
(lexer (lexer
[(eof) (values lexeme 'eof #f #f #f)] [(eof) (values lexeme 'eof #f #f #f)]
["@$" (begin ["@$" (begin
(set! in-racket-expr? #t) (set! in-racket-expr? #t)
(values lexeme 'parenthesis '|(| (position-offset start-pos) (position-offset end-pos)))] (values lexeme 'parenthesis '|(|
(pos lexeme-start) (pos lexeme-end)))]
["$@" (begin ["$@" (begin
(set! in-racket-expr? #f) (set! in-racket-expr? #f)
(values lexeme 'parenthesis '|)| (position-offset start-pos) (position-offset end-pos)))] (values lexeme 'parenthesis '|)|
[(seq "//" (* (char-complement #\newline))) (pos lexeme-start) (pos lexeme-end)))]
(values lexeme 'comment #f (position-offset start-pos) (position-offset end-pos))] [(from/to "//" "\n")
(values lexeme 'comment #f (pos lexeme-start) (pos lexeme-end))]
[any-char [any-char
(values lexeme 'string #f (position-offset start-pos) (position-offset end-pos))])) (values lexeme 'string #f (pos lexeme-start) (pos lexeme-end))]))
(if (and in-racket-expr? (not (at-racket-boundary? input-port))) (if (and in-racket-expr? (not (equal? (peek-string 2 0 port) "$@")))
(racket-lexer input-port) (racket-lexer port)
(jsonic-lexer input-port))) (jsonic-lexer port)))
(provide color-jsonic)

@ -1,14 +1,16 @@
#lang br/quicklang #lang br/quicklang
(module reader br (module reader br
(require "reader.rkt" "colorer.rkt" (require "reader.rkt")
"indenter.rkt" "buttons.rkt")
(provide read-syntax get-info) (provide read-syntax get-info)
(define (get-info port mod line col pos) (define (get-info port mod line col pos)
(define (handle-query key default) (define (handle-query key default)
(case key (case key
[(color-lexer) color-jsonic] [(color-lexer)
[(drracket:indentation) indent-jsonic] (dynamic-require 'br/demo/jsonic-2/colorer 'color-jsonic)]
[(drracket:toolbar-buttons) make-jsonic-buttons] [(drracket:indentation)
(dynamic-require 'br/demo/jsonic-2/indenter 'indent-jsonic)]
[(drracket:toolbar-buttons)
(dynamic-require 'br/demo/jsonic-2/buttons 'make-buttons)]
[else default])) [else default]))
handle-query)) handle-query))

Loading…
Cancel
Save