forked from syndicate-lang/preserves
Special cases for label[...] and label{...}
This commit is contained in:
parent
c02e790f71
commit
8dc6346c58
|
@ -283,8 +283,8 @@
|
||||||
(define (read-sequence terminator)
|
(define (read-sequence terminator)
|
||||||
(sequence-fold '() (lambda (acc) (cons (read-value) acc)) reverse terminator))
|
(sequence-fold '() (lambda (acc) (cons (read-value) acc)) reverse terminator))
|
||||||
|
|
||||||
(define (read-dictionary-or-set)
|
(define (read-dictionary-or-set seed)
|
||||||
(sequence-fold #f
|
(sequence-fold seed
|
||||||
(lambda (acc)
|
(lambda (acc)
|
||||||
(define k (read-value))
|
(define k (read-value))
|
||||||
(skip-whitespace)
|
(skip-whitespace)
|
||||||
|
@ -447,18 +447,20 @@
|
||||||
|
|
||||||
(define (collect-fields head)
|
(define (collect-fields head)
|
||||||
(match (peek-char i)
|
(match (peek-char i)
|
||||||
[#\(
|
[#\( (read-char i)
|
||||||
(read-char i)
|
(collect-fields (build-record head (read-sequence #\))))]
|
||||||
(collect-fields (build-record head (read-sequence #\))))]
|
[#\[ (read-char i)
|
||||||
[_
|
(collect-fields (build-record head (list (read-sequence #\]))))]
|
||||||
head]))
|
[#\{ (read-char i)
|
||||||
|
(collect-fields (build-record head (list (read-dictionary-or-set (hash)))))]
|
||||||
|
[_ head]))
|
||||||
|
|
||||||
(define (read-value)
|
(define (read-value)
|
||||||
(skip-whitespace)
|
(skip-whitespace)
|
||||||
(collect-fields
|
(collect-fields
|
||||||
(match (peek-char i)
|
(match (peek-char i)
|
||||||
[(? eof-object? o) o]
|
[(? eof-object? o) o]
|
||||||
[#\{ (read-char i) (read-dictionary-or-set)]
|
[#\{ (read-char i) (read-dictionary-or-set #f)]
|
||||||
[#\[ (read-char i) (read-sequence #\])]
|
[#\[ (read-char i) (read-sequence #\])]
|
||||||
[(or #\- #\0 #\1 #\2 #\3 #\4 #\5 #\6 #\7 #\8 #\9) (read-number)]
|
[(or #\- #\0 #\1 #\2 #\3 #\4 #\5 #\6 #\7 #\8 #\9) (read-number)]
|
||||||
[#\" (read-char i) (read-string #\")]
|
[#\" (read-char i) (read-string #\")]
|
||||||
|
|
|
@ -317,6 +317,12 @@ tokens `#set{` and `}`.[^printing-collections]
|
||||||
commas separating, and commas terminating elements or key/value
|
commas separating, and commas terminating elements or key/value
|
||||||
pairs within a collection.
|
pairs within a collection.
|
||||||
|
|
||||||
|
The special cases of records with a single field, which is in turn a
|
||||||
|
sequence or dictionary, may be written omitting the parentheses.
|
||||||
|
|
||||||
|
Record =/ Value Sequence
|
||||||
|
Record =/ Value Dictionary
|
||||||
|
|
||||||
`Boolean`s are the simple literal strings `#true` and `#false`.
|
`Boolean`s are the simple literal strings `#true` and `#false`.
|
||||||
|
|
||||||
Boolean = %s"#true" / %s"#false"
|
Boolean = %s"#true" / %s"#false"
|
||||||
|
|
Loading…
Reference in New Issue