Read angle-bracket delimited records in the Racket implementation
This commit is contained in:
parent
c9a624839f
commit
9974002cad
|
@ -332,7 +332,7 @@
|
|||
(define (read-raw-symbol acc)
|
||||
(match (peek-char i)
|
||||
[(or (? eof-object?)
|
||||
(? char? (or #\( #\) #\{ #\} #\[ #\]
|
||||
(? char? (or #\( #\) #\{ #\} #\[ #\] #\< #\>
|
||||
#\" #\; #\, #\# #\: (== PIPE)
|
||||
(? char-whitespace?))))
|
||||
(if (null? acc)
|
||||
|
@ -479,16 +479,6 @@
|
|||
(push-child-annotation! (compute-key acc next) next-anns)
|
||||
(loop new-acc)])))
|
||||
|
||||
(define (collect-fields head)
|
||||
(match (peek-char i)
|
||||
[#\( (read-char i)
|
||||
(collect-fields (build-record head (read-sequence #\))))]
|
||||
[#\[ (read-char i)
|
||||
(collect-fields (build-record head (list (read-sequence #\]))))]
|
||||
[#\{ (read-char i)
|
||||
(collect-fields (build-record head (list (read-dictionary-or-set (hash)))))]
|
||||
[_ head]))
|
||||
|
||||
(define (read-value/annotations)
|
||||
(if skip-annotations
|
||||
(values (eof-guard (read-value)) empty-annotations)
|
||||
|
@ -512,11 +502,14 @@
|
|||
|
||||
(define (read-value)
|
||||
(skip-whitespace)
|
||||
(collect-fields
|
||||
(match (peek-char i)
|
||||
[(? eof-object? o) o]
|
||||
[#\{ (read-char i) (read-dictionary-or-set #f)]
|
||||
[#\[ (read-char i) (read-sequence #\])]
|
||||
[#\< (read-char i)
|
||||
(match (read-sequence #\>)
|
||||
['() (parse-error "Missing record label")]
|
||||
[(cons head fields) (build-record head fields)])]
|
||||
[(or #\- #\0 #\1 #\2 #\3 #\4 #\5 #\6 #\7 #\8 #\9) (read-number)]
|
||||
[#\" (read-char i) (read-string #\")]
|
||||
[(== PIPE) (read-char i) (string->symbol (read-string PIPE))]
|
||||
|
@ -547,7 +540,7 @@
|
|||
(read-char i)
|
||||
(parse-error "Invalid preserve value")])]
|
||||
[#\: (read-char i) (parse-error "Unexpected key/value separator between items")]
|
||||
[_ (read-raw-symbol '())])))
|
||||
[_ (read-raw-symbol '())]))
|
||||
|
||||
(read-value/annotations))
|
||||
|
||||
|
|
Loading…
Reference in New Issue