Allow parsing config lines without comments.
This commit is contained in:
parent
2674f08674
commit
ba2c753109
3 changed files with 6 additions and 5 deletions
|
|
@ -39,11 +39,12 @@ member file parsers. All functions are UTF-8 aware.")
|
|||
|
||||
(import scheme
|
||||
(chicken base)
|
||||
racket-kwargs
|
||||
testing)
|
||||
|
||||
;; Pass 0: Removes any comments and removes any leading and trailing
|
||||
;; whitespace.
|
||||
(define/doc (parser-preprocess-line line)
|
||||
(define*/doc (parser-preprocess-line line #:strip-comments? (strip-comments? #t))
|
||||
("* ```line``` - a string with contents of one source line
|
||||
|
||||
If the input ```line``` contains the ```#``` character, the rest of
|
||||
|
|
@ -62,7 +63,8 @@ Returns a string representing the preprocessed line.")
|
|||
(ploop (add1 pidx)))))
|
||||
(hpos (let hloop ((hidx ppos))
|
||||
(if (or (= hidx llen)
|
||||
(eq? (string-ref line hidx) #\#))
|
||||
(and strip-comments?
|
||||
(eq? (string-ref line hidx) #\#)))
|
||||
hidx
|
||||
(hloop (add1 hidx)))))
|
||||
(spos (let sloop ((sidx (sub1 hpos)))
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue