Created
January 7, 2012 20:51
-
-
Save jlongster/1576001 to your computer and use it in GitHub Desktop.
Beginning of Outlet compiler in Outlet (compiles to js and lua)
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
(require (reader "./ext/Parser") | |
(util "util") | |
(ast "./ast") | |
(grammar "./grammar")) | |
;; util | |
(define (assert v msg) | |
(if (not v) | |
(throw msg))) | |
(define (assert_type node type msg) | |
(assert (= (node-type node) type) | |
(string-append "invalid type, expected " | |
type | |
": " | |
(inspect node)))) | |
;; main functions | |
(define (read src) | |
(reader grammar src)) | |
(define (parse node generator) | |
(let ((parser (vector-ref parsers (node-type node)))) | |
(assert parser (string-append "No parser for node type:" | |
(node-type node))) | |
(parser node | |
(lambda (node) (parse node generator)) | |
generator))) | |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment