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)
|
||||
(sequence-fold '() (lambda (acc) (cons (read-value) acc)) reverse terminator))
|
||||
|
||||
(define (read-dictionary-or-set)
|
||||
(sequence-fold #f
|
||||
(define (read-dictionary-or-set seed)
|
||||
(sequence-fold seed
|
||||
(lambda (acc)
|
||||
(define k (read-value))
|
||||
(skip-whitespace)
|
||||
|
@ -447,18 +447,20 @@
|
|||
|
||||
(define (collect-fields head)
|
||||
(match (peek-char i)
|
||||
[#\(
|
||||
(read-char i)
|
||||
(collect-fields (build-record head (read-sequence #\))))]
|
||||
[_
|
||||
head]))
|
||||
[#\( (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)
|
||||
(skip-whitespace)
|
||||
(collect-fields
|
||||
(match (peek-char i)
|
||||
[(? eof-object? o) o]
|
||||
[#\{ (read-char i) (read-dictionary-or-set)]
|
||||
[#\{ (read-char i) (read-dictionary-or-set #f)]
|
||||
[#\[ (read-char i) (read-sequence #\])]
|
||||
[(or #\- #\0 #\1 #\2 #\3 #\4 #\5 #\6 #\7 #\8 #\9) (read-number)]
|
||||
[#\" (read-char i) (read-string #\")]
|
||||
|
|
|
@ -317,6 +317,12 @@ tokens `#set{` and `}`.[^printing-collections]
|
|||
commas separating, and commas terminating elements or key/value
|
||||
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"#true" / %s"#false"
|
||||
|
|
Loading…
Reference in New Issue