(zilch lang rust): document
Change-Id: I6a6a6964c8aaff8d5f3e18bc5c7486746b5a2952
This commit is contained in:
parent
ae774da043
commit
0340f6e830
10 changed files with 597 additions and 82 deletions
|
|
@ -1,3 +1,5 @@
|
|||
;; Procedures to parse `cfg` attributes, as well as match them against
|
||||
;; conditionals found in crate definitions.
|
||||
(define-library (zilch lang rust cfg)
|
||||
(import
|
||||
(scheme base)
|
||||
|
|
@ -35,6 +37,12 @@
|
|||
(let ((end (or (string-skip strval is-ident-rest (+ index 1)) (string-length strval))))
|
||||
(tokenize-cfg strval end (cons (cons 'ident (string-copy strval index end)) tail)))
|
||||
(error "Unexpected character in cfg() string" strval))))))
|
||||
|
||||
;; Parses a configuration string or expression.
|
||||
;;
|
||||
;; - `key="value"` is represented as `('value . (key . value))`, where value can be `#f`.
|
||||
;; - `all` and `any` are represented as `('all/'any . items)`, where `items` is a list of sub-expressions.
|
||||
;; - `not(...)` is represented as `('not . value)`, where `value` is a sub-expression.
|
||||
(define (cfg-parse str)
|
||||
(define tokens (tokenize-cfg str 0 '()))
|
||||
(define (expect token)
|
||||
|
|
@ -100,6 +108,8 @@
|
|||
(cons 'value (cons left right))))))
|
||||
(parse-expr))
|
||||
|
||||
;; Checks whether the parsed expression `expr` matches against the list of
|
||||
;; config value pairs in `cfgs`.
|
||||
(define (cfg-matches expr cfgs)
|
||||
(define (parse-any tail)
|
||||
(cond
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue