Created
January 23, 2013 00:15
-
-
Save soegaard/4600286 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
#lang racket/base | |
(require ragg/examples/simple-line-drawing/lexer | |
ragg/examples/simple-line-drawing/grammar | |
syntax/parse | |
(for-syntax syntax/parse) | |
(for-syntax racket/base)) | |
(define-syntax (define-datums stx) | |
(syntax-parse stx | |
[(_ name ...) | |
#'(begin | |
(define-syntax-class name (pattern (~datum name))) | |
...)])) | |
(define-datums drawing row repeat chunk) | |
(define an-stx | |
(parse (tokenize (open-input-string "3 9 X; | |
6 3 b 3 X 3 b; | |
3 9 X;")))) | |
(syntax-parse an-stx | |
[(_:drawing row ...) | |
(printf "I see: ~s\n" #'(row ...))]) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment