mirror of
https://github.com/justinethier/cyclone.git
synced 2025-05-23 20:15:05 +02:00
Limited support for #e
This commit is contained in:
parent
af40c7cd8d
commit
3a3610f93d
1 changed files with 22 additions and 0 deletions
|
@ -8,6 +8,7 @@
|
||||||
;;;;
|
;;;;
|
||||||
(define-library (scheme read)
|
(define-library (scheme read)
|
||||||
(import (scheme base)
|
(import (scheme base)
|
||||||
|
;(scheme write)
|
||||||
(scheme char))
|
(scheme char))
|
||||||
(export
|
(export
|
||||||
read
|
read
|
||||||
|
@ -311,6 +312,27 @@
|
||||||
(if all?
|
(if all?
|
||||||
(parse fp '() (cons #f toks) all? #f parens ptbl)
|
(parse fp '() (cons #f toks) all? #f parens ptbl)
|
||||||
#f))
|
#f))
|
||||||
|
;; Numbers
|
||||||
|
;; TODO: technically broken for #e because allows whitespace between "#e" and the number itself
|
||||||
|
;; TODO: #b (binary), #o (octal), #d (decimal), and #x (hexadecimal) also #i for inexact
|
||||||
|
;; TODO: cleanup code to support above. hex may be tricky and require
|
||||||
|
;; a specialized parsing pass. actually, bin and oct do too because
|
||||||
|
;; otherwise they would be parsed as decimal numbers
|
||||||
|
((eq? #\e next-c)
|
||||||
|
;(write `(DEBUG ,next-c ,toks))
|
||||||
|
(let ((sub (parse fp '() '() #f #f parens ptbl)))
|
||||||
|
;(write `(DEBUG2 ,sub ,(string? sub)))
|
||||||
|
(cond
|
||||||
|
((number? sub)
|
||||||
|
(let ((result (exact sub)))
|
||||||
|
(if all?
|
||||||
|
(parse fp '() (cons result toks) all? #f parens ptbl)
|
||||||
|
result)))
|
||||||
|
(else
|
||||||
|
(parse-error
|
||||||
|
"Illegal number syntax"
|
||||||
|
(in-port:get-lnum ptbl)
|
||||||
|
(in-port:get-cnum ptbl))))))
|
||||||
;; Vector
|
;; Vector
|
||||||
((eq? #\( next-c)
|
((eq? #\( next-c)
|
||||||
(let ((sub (parse fp '() '() #t #f (+ parens 1) ptbl))
|
(let ((sub (parse fp '() '() #t #f (+ parens 1) ptbl))
|
||||||
|
|
Loading…
Add table
Reference in a new issue