export some readtable functions
and finish up the docs
This commit is contained in:
parent
6c95c7a142
commit
a350659906
|
@ -3,7 +3,10 @@
|
||||||
(define collection "2d")
|
(define collection "2d")
|
||||||
(define version "1.0")
|
(define version "1.0")
|
||||||
(define deps '("base" "2d-lib"))
|
(define deps '("base" "2d-lib"))
|
||||||
(define build-deps '("scribble-lib" "racket-doc"))
|
(define build-deps '("scribble-lib"
|
||||||
|
"racket-doc"
|
||||||
|
"syntax-color-doc"
|
||||||
|
"syntax-color-lib"))
|
||||||
(define pkg-desc "Documentation part of \"2d\"")
|
(define pkg-desc "Documentation part of \"2d\"")
|
||||||
(define pkg-authors '(robby))
|
(define pkg-authors '(robby))
|
||||||
|
|
||||||
|
|
|
@ -2,8 +2,10 @@
|
||||||
@(require scribble/base
|
@(require scribble/base
|
||||||
scribble/manual
|
scribble/manual
|
||||||
scribble/core
|
scribble/core
|
||||||
|
scribble/example
|
||||||
(for-label 2d/cond
|
(for-label 2d/cond
|
||||||
2d/match
|
2d/match
|
||||||
|
syntax-color/lexer-contract
|
||||||
racket/file
|
racket/file
|
||||||
racket/contract
|
racket/contract
|
||||||
racket/base))
|
racket/base))
|
||||||
|
@ -11,7 +13,9 @@
|
||||||
@title[#:tag "2d"]{2D Syntax}
|
@title[#:tag "2d"]{2D Syntax}
|
||||||
|
|
||||||
@defmodulelang[2d]{The @racketmodname[2d] language installs
|
@defmodulelang[2d]{The @racketmodname[2d] language installs
|
||||||
@litchar{#2d} reader support in the readtable, and then chains to the reader of
|
@litchar{#2d} reader support in the
|
||||||
|
@tech[#:doc '(lib "scribblings/reference/reference.scrbl")]{readtables},
|
||||||
|
and then chains to the reader of
|
||||||
another language that is specified immediately after
|
another language that is specified immediately after
|
||||||
@racketmodname[2d].}
|
@racketmodname[2d].}
|
||||||
|
|
||||||
|
@ -267,3 +271,79 @@ See @seclink["Keyboard Shortcuts" #:doc '(lib "scribblings/drracket/drracket.scr
|
||||||
columns (as @litchar{#2d} syntax requires that the first row contain
|
columns (as @litchar{#2d} syntax requires that the first row contain
|
||||||
a cell for each column that appears in the table).
|
a cell for each column that appears in the table).
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@section{2D Readtable}
|
||||||
|
|
||||||
|
@defmodule[2d/readtable]
|
||||||
|
|
||||||
|
@defproc[(make-readtable) readtable?]{
|
||||||
|
Builds a @racket[readtable?] that recognizes @litchar{#2d} and turns it into
|
||||||
|
a parenthesized form as discussed in @secref["2d"].
|
||||||
|
}
|
||||||
|
|
||||||
|
@defproc[(2d-readtable-dispatch-proc
|
||||||
|
[char char?]
|
||||||
|
[port input-port?]
|
||||||
|
[source any/c]
|
||||||
|
[line (or/c exact-positive-integer? #f)]
|
||||||
|
[column (or/c exact-nonnegative-integer? #f)]
|
||||||
|
[position (or/c exact-positive-integer? #f)]
|
||||||
|
[/recursive (-> input-port? any/c (or/c readtable? #f) any/c)]
|
||||||
|
[readtable (or/c #f readtable?)])
|
||||||
|
any/c]{
|
||||||
|
The function that implements @racket[make-readtable]'s functionality. The
|
||||||
|
@racket[/recursive] function is used to handle the content in the cells.
|
||||||
|
|
||||||
|
See the docs
|
||||||
|
on @tech[#:doc '(lib "scribblings/reference/reference.scrbl")]{readtables} for more information.
|
||||||
|
}
|
||||||
|
|
||||||
|
@section{2d Lexer}
|
||||||
|
|
||||||
|
@defmodule[2d/lexer]
|
||||||
|
|
||||||
|
@defproc[(2d-lexer [sub lexer/c]) lexer/c]{
|
||||||
|
Constructs a @racket[lexer/c] given one that handles
|
||||||
|
lexing inside the cells.
|
||||||
|
}
|
||||||
|
|
||||||
|
@section{2D Direction Chars}
|
||||||
|
|
||||||
|
@defmodule[2d/dir-chars]
|
||||||
|
|
||||||
|
@(define 2dchars-eval (make-base-eval '(require 2d/dir-chars)))
|
||||||
|
|
||||||
|
This library provides definitions of the characters that are looked for when
|
||||||
|
parsing 2d syntax.
|
||||||
|
|
||||||
|
@(define-syntax-rule
|
||||||
|
(doc-chars id . stuff)
|
||||||
|
(begin
|
||||||
|
@(defthing id (listof char?) . stuff)
|
||||||
|
@examples[#:label #f #:eval 2dchars-eval id]))
|
||||||
|
|
||||||
|
@doc-chars[adjustable-chars]{
|
||||||
|
These are the characters that are considered either to be part of 2d rectangle
|
||||||
|
or characters that could be part of one, possibly fixed by up a DrRacket keybinding.
|
||||||
|
}
|
||||||
|
|
||||||
|
@doc-chars[double-barred-chars]{
|
||||||
|
These are all of the @racket[adjustable-chars], except those that are regular ASCII.
|
||||||
|
}
|
||||||
|
|
||||||
|
@doc-chars[up-chars]{
|
||||||
|
All of the 2d chars that connect to the line above.
|
||||||
|
}
|
||||||
|
|
||||||
|
@doc-chars[dn-chars]{
|
||||||
|
All of the 2d chars that connect to the line below.
|
||||||
|
}
|
||||||
|
|
||||||
|
@doc-chars[lt-chars]{
|
||||||
|
All of the 2d chars that connect to the next char.
|
||||||
|
}
|
||||||
|
|
||||||
|
@doc-chars[rt-chars]{
|
||||||
|
All of the 2d chars that connect to the previous char.
|
||||||
|
}
|
||||||
|
|
||||||
|
|
|
@ -1,7 +1,7 @@
|
||||||
#lang info
|
#lang info
|
||||||
|
|
||||||
(define collection "2d")
|
(define collection "2d")
|
||||||
(define version "1.0")
|
(define version "1.1")
|
||||||
(define deps '("base"
|
(define deps '("base"
|
||||||
"scribble-lib"
|
"scribble-lib"
|
||||||
"syntax-color-lib"))
|
"syntax-color-lib"))
|
||||||
|
|
|
@ -20,7 +20,8 @@ example uses:
|
||||||
racket/port)
|
racket/port)
|
||||||
|
|
||||||
|
|
||||||
(provide make-2d-readtable)
|
(provide make-2d-readtable
|
||||||
|
2d-readtable-dispatch-proc)
|
||||||
|
|
||||||
(define (make-2d-readtable)
|
(define (make-2d-readtable)
|
||||||
(define previous-readtable (current-readtable))
|
(define previous-readtable (current-readtable))
|
||||||
|
@ -35,16 +36,16 @@ example uses:
|
||||||
;; the "-2"s here are because the initial line and column
|
;; the "-2"s here are because the initial line and column
|
||||||
;; are supposed be at the beginning of the thing read, not
|
;; are supposed be at the beginning of the thing read, not
|
||||||
;; after the "#2" has been consumed.
|
;; after the "#2" has been consumed.
|
||||||
(dispatch-proc char port #f line
|
(2d-readtable-dispatch-proc char port #f line
|
||||||
(and col (- col 2))
|
(and col (- col 2))
|
||||||
(and pos (- pos 2))
|
(and pos (- pos 2))
|
||||||
read/recursive previous-readtable)]
|
read/recursive previous-readtable)]
|
||||||
[(char port source _line _col _pos)
|
[(char port source _line _col _pos)
|
||||||
(dispatch-proc char port source _line _col _pos
|
(2d-readtable-dispatch-proc char port source _line _col _pos
|
||||||
(λ (a b c) (read-syntax/recursive source a b c))
|
(λ (a b c) (read-syntax/recursive source a b c))
|
||||||
previous-readtable)])))
|
previous-readtable)])))
|
||||||
|
|
||||||
(define (dispatch-proc char port source _line _col _pos /recursive previous-readtable)
|
(define (2d-readtable-dispatch-proc char port source _line _col _pos /recursive previous-readtable)
|
||||||
(define next-char (peek-char port))
|
(define next-char (peek-char port))
|
||||||
(cond
|
(cond
|
||||||
[(equal? next-char #\d)
|
[(equal? next-char #\d)
|
||||||
|
|
15
2d-lib/readtable.rkt
Normal file
15
2d-lib/readtable.rkt
Normal file
|
@ -0,0 +1,15 @@
|
||||||
|
#lang racket/base
|
||||||
|
|
||||||
|
(require "private/readtable.rkt"
|
||||||
|
racket/contract)
|
||||||
|
(provide
|
||||||
|
(contract-out
|
||||||
|
[2d-readtable-dispatch-proc
|
||||||
|
(-> char? input-port? any/c
|
||||||
|
(or/c exact-positive-integer? #f)
|
||||||
|
(or/c exact-nonnegative-integer? #f)
|
||||||
|
(or/c exact-positive-integer? #f)
|
||||||
|
(-> input-port? any/c (or/c readtable? #f) any/c)
|
||||||
|
(or/c #f readtable?)
|
||||||
|
any/c)])
|
||||||
|
make-readtable)
|
|
@ -2,7 +2,7 @@
|
||||||
|
|
||||||
(define collection "2d")
|
(define collection "2d")
|
||||||
(define version "1.0")
|
(define version "1.0")
|
||||||
(define deps '("base" "2d-lib"))
|
(define deps '("base" "2d-lib" "racket-index"))
|
||||||
(define build-deps '("rackunit-lib"
|
(define build-deps '("rackunit-lib"
|
||||||
"option-contract-lib"
|
"option-contract-lib"
|
||||||
"at-exp-lib"
|
"at-exp-lib"
|
||||||
|
|
8
2d-test/tests/docs-complete.rkt
Normal file
8
2d-test/tests/docs-complete.rkt
Normal file
|
@ -0,0 +1,8 @@
|
||||||
|
#lang racket/base
|
||||||
|
(require rackunit/docs-complete)
|
||||||
|
(check-docs '2d/cond)
|
||||||
|
(check-docs '2d/dir-chars)
|
||||||
|
(check-docs '2d/lexer)
|
||||||
|
(check-docs '2d/match)
|
||||||
|
(check-docs '2d/readtable)
|
||||||
|
(check-docs '2d/tabular)
|
Loading…
Reference in New Issue
Block a user