Skip to content

Instantly share code, notes, and snippets.

@soegaard
Created January 23, 2013 00:15
Show Gist options
  • Save soegaard/4600286 to your computer and use it in GitHub Desktop.
Save soegaard/4600286 to your computer and use it in GitHub Desktop.
#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