Last active
August 29, 2015 14:15
-
-
Save cmoore/30d894187a08fcff1382 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
(defvar *previous-readtables* nil) | |
(defmacro enable-toml-syntax () | |
'(eval-when (:compile-toplevel :load-toplevel :execute) | |
(push *readtable* *previous-readtables*) | |
(setq *readtable* (copy-readtable)) | |
(set-macro-character #\[ 'read-left-bracket) | |
; more calls to (set-macro-character) | |
...)) | |
(defmacro disable-toml-syntax () | |
'(eval-when (:compile-toplevel :load-toplevel :execute) | |
(setq *readtable* (pop *previous-readtables*)))) | |
(defun parse (contents) | |
(let ((result nil)) | |
(with-input-from-string (in contents) | |
(enable-toml-syntax) | |
(setq result (read in)) | |
(disable-toml-syntax)) | |
result)) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment