I have the following test example to be able to use read, but encounters some problem:
#lang racket
(struct test (num) #:prefab)
(define s3 (read (open-input-string "((AK= #s(test .)) (AV))")))
(match s3
[`((AK= ,(struct test (val))) (AV)) (displayln val)])
It will give out read: unexpected)’`
I know it is because of the ., but my source will contain a lot of this kind of thing, then the question is that how can I read them in racket?
Thanks in advance…
You can disable reading dots with
read-accept-dotandread-accept-infix-dot, but that just makes it an error if there’s a dot. So it sounds like you’d want to use a custom readtable here (read the guide section too):Alternatively, you can make the dots get treated as comments: