This commit is contained in:
1 parent
78f5f94adc
commit
738121c18a
2 files changed
+22
-3
No files matched your search
+12
-2
@@ -5,11 +5,17 @@ boolean = #"#(t(rue)?|f(alse)?)" <intertoken-space>
|
||||
semicolon = ';'
|
||||
left-paren = '(' <intertoken-space>
|
||||
right-paren = ')' <intertoken-space>
|
||||
dot = '.' <intertoken-space>
|
||||
|
||||
(* datum *)
|
||||
<datum> = simple-datum
|
||||
<datum> = simple-datum | compound-datum
|
||||
<simple-datum> = boolean | symbol | number | string
|
||||
<compound-datum> = any-list
|
||||
|
||||
<simple-datum> = boolean | symbol | number
|
||||
(* list *)
|
||||
<any-list> = proper-list | improper-list
|
||||
proper-list = <left-paren> datum* <right-paren>
|
||||
improper-list = <left-paren> datum+ <dot> datum <right-paren>
|
||||
|
||||
(* symbol *)
|
||||
symbol = ordinary-symbol <intertoken-space>
|
||||
@@ -23,6 +29,10 @@ num-10 = sign #"[0-9]+"
|
||||
sign = ('+' | '-')?
|
||||
exactness = ('#i' | '#e')?
|
||||
|
||||
(* string *)
|
||||
string = <'"'> string-element* <'"'> <intertoken-space>
|
||||
<string-element> = #'[^"\\]' | '\\"' | '\\\\'
|
||||
|
||||
(* atmosphere *)
|
||||
atmosphere = whitespace | comment | directive
|
||||
whitespace = intraline-whitespace | line-ending
|
||||
|
||||
+10
-1
@@ -1,7 +1,8 @@
|
||||
(ns scm
|
||||
(:require [instaparse.core :as insta]
|
||||
[clojure.java.io :as io]
|
||||
[clojure.core.match :refer [match]])
|
||||
[clojure.core.match :refer [match]]
|
||||
[clojure.string :as str])
|
||||
(:refer-clojure :exclude [read]))
|
||||
|
||||
|
||||
@@ -60,6 +61,14 @@
|
||||
(match x
|
||||
(:or "#t" "#true") true
|
||||
(:or "#f" "#false") false)])
|
||||
:string (fn [& els]
|
||||
(apply str
|
||||
(for [e els]
|
||||
(match e
|
||||
"\\\\" "\\"
|
||||
"\\\"" "\""
|
||||
"\\n" "\n"
|
||||
_ e))))
|
||||
:sign (fn
|
||||
([] identity)
|
||||
([x] (match x "-" - "+" identity)))
|
||||
|
||||
Reference in new issue
Block a user