rudimentary jsonic lexer
parent
9e8135ee05
commit
9e02db875f
@ -1 +1,12 @@
|
||||
#lang racket/base
|
||||
#lang br
|
||||
(require racket/class)
|
||||
(provide drracket-indenter)
|
||||
|
||||
(define (drracket-indenter t pos)
|
||||
#;(with-handlers ([exn:fail? (λ(exn) #f)]) ; this function won't work until gui-lib 1.26
|
||||
(send t compute-racket-amount-to-indent pos (λ(x)
|
||||
(case x
|
||||
[("with-pattern" "with-shared-id") 'lambda]
|
||||
[("define-macro") 'define]
|
||||
[else #f]))))
|
||||
#f)
|
@ -1,14 +1,24 @@
|
||||
#lang racket/base
|
||||
#lang br
|
||||
|
||||
(require parser-tools/lex
|
||||
syntax-color/racket-lexer
|
||||
(prefix-in : parser-tools/lex-sre))
|
||||
|
||||
(provide default-lexer)
|
||||
(provide drracket-lexer)
|
||||
|
||||
|
||||
(define default-lexer
|
||||
(define drracket-lexer
|
||||
(let ([in-racket-expr? #f])
|
||||
(lexer
|
||||
[(eof) (values lexeme 'eof #f #f #f)]
|
||||
[(:seq "//" (:* (char-complement "\n")))
|
||||
["@$" (begin
|
||||
(set! in-racket-expr? #t)
|
||||
(values lexeme 'parenthesis '|(| (position-offset start-pos) (position-offset end-pos)))]
|
||||
["$@" (begin
|
||||
(set! in-racket-expr? #f)
|
||||
(values lexeme 'parenthesis '|)| (position-offset start-pos) (position-offset end-pos)))]
|
||||
[(:seq "//" (:* (char-complement #\newline)))
|
||||
(values lexeme 'comment #f (position-offset start-pos) (position-offset end-pos))]
|
||||
[any-char (values lexeme 'no-color #f (position-offset start-pos) (position-offset end-pos))]))
|
||||
[any-char
|
||||
(if in-racket-expr?
|
||||
(racket-lexer (transplant-input-port (open-input-string lexeme) #f (position-offset start-pos)))
|
||||
(values lexeme 'string #f (position-offset start-pos) (position-offset end-pos)))])))
|
Loading…
Reference in New Issue