mirror of
https://github.com/justinethier/cyclone.git
synced 2025-07-09 22:17:33 +02:00
Added (parse-literal-identifier)
This commit is contained in:
parent
dbf77ce999
commit
8b43a0d4ac
1 changed files with 27 additions and 0 deletions
|
@ -392,6 +392,8 @@
|
||||||
(in-port:get-cnum ptbl)))))
|
(in-port:get-cnum ptbl)))))
|
||||||
;; just another char...
|
;; just another char...
|
||||||
(parse fp (cons c tok) toks all? #f parens ptbl)))
|
(parse fp (cons c tok) toks all? #f parens ptbl)))
|
||||||
|
((eq? c #\|)
|
||||||
|
(parse-literal-identifier fp toks all? parens ptbl))
|
||||||
(else
|
(else
|
||||||
(parse fp (cons c tok) toks all? #f parens ptbl)))))
|
(parse fp (cons c tok) toks all? #f parens ptbl)))))
|
||||||
|
|
||||||
|
@ -518,6 +520,31 @@
|
||||||
((eq? #\| c) (read-block-terminator fp ptbl))
|
((eq? #\| c) (read-block-terminator fp ptbl))
|
||||||
(else (read-block-comment fp ptbl)))))
|
(else (read-block-comment fp ptbl)))))
|
||||||
|
|
||||||
|
;; Parse literal identifier encountered within pipes
|
||||||
|
(define (parse-literal-identifier fp toks all? parens ptbl)
|
||||||
|
(let ((sym (parse-li-rec fp '() ptbl)))
|
||||||
|
(if all?
|
||||||
|
(parse fp '() (cons sym toks) all? #f parens ptbl)
|
||||||
|
sym)))
|
||||||
|
|
||||||
|
;; Helper for parse-literal-identifier
|
||||||
|
(define (parse-li-rec fp tok ptbl)
|
||||||
|
(let ((c (get-next-char fp ptbl))
|
||||||
|
(next (lambda (c) (parse-li-rec fp (cons c tok) ptbl))))
|
||||||
|
(cond
|
||||||
|
((eq? #\| c)
|
||||||
|
(let ((str (if (null? tok)
|
||||||
|
"||"
|
||||||
|
(list->string
|
||||||
|
(reverse tok)))))
|
||||||
|
(string->symbol str)))
|
||||||
|
((eof-object? c)
|
||||||
|
(parse-error "EOF encountered parsing literal identifier"
|
||||||
|
(in-port:get-lnum ptbl)
|
||||||
|
(in-port:get-cnum ptbl)))
|
||||||
|
(else
|
||||||
|
(next c)))))
|
||||||
|
|
||||||
(define (parse-number fp toks all? parens ptbl base tok->num)
|
(define (parse-number fp toks all? parens ptbl base tok->num)
|
||||||
; (parse-number-rec base fp '() ptbl))
|
; (parse-number-rec base fp '() ptbl))
|
||||||
(let ((num (parse-number-rec base fp '() ptbl)))
|
(let ((num (parse-number-rec base fp '() ptbl)))
|
||||||
|
|
Loading…
Add table
Reference in a new issue