Created
August 17, 2012 13:25
-
-
Save Idorobots/3378676 to your computer and use it in GitHub Desktop.
Simple Lisp grammar
This file contains hidden or 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
(grammar ((Expression < (/ String List Atom))) | |
((String <- (:"\"") "[^\"]*" (: "\""))) | |
((List < (: "\\(") (* Expression) (: "\\)")) | |
`($(car List) | |
$(cdr List))) | |
((Atom <- (/ Number Symbol))) | |
((Number <- "[+\\-]?[0-9]+(\\.[0-9]*)?") | |
`($(car Number) | |
($(str->num (caadr Number))))) | |
((Symbol <- (! Number) "[^\\(\\)\"';\\s]+") | |
`($(car Symbol) | |
($(str->symbol (caadr Symbol))))) | |
((Spacing <- (* (/ Comment "[\\s]+")))) | |
((Comment <- (: ";" "[^\n]*\n")))) | |
(Expression "(define (compose f g) | |
(lambda (arg) (f (g arg))))") |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment