Skip to content

Instantly share code, notes, and snippets.

@nixpulvis nixpulvis/macro.rkt
Created Nov 30, 2014

Embed
What would you like to do?
;; A macro that defines a PDA language
(define-syntax pushdown
(syntax-rules (: ->)
[(pushdown init-state end-state
[state : (input-stream input-stack -> new-state new-stack) ...]
...)
(lambda (string)
(: state : (Listof Token) (Listof Token) -> Boolean)
...
(define (state stream stack)
(match (list stream stack)
[(list '() '()) (if (symbol=? 'state 'end-state) #t #f)]
; TODO: This match is a problem.
[(list (list-rest _ more-input)
(list-rest _ more-stack))
; TODO: not done.
(new-state more-input (append 'input-stack more-stack))]
...
[_ #f]))
...
(init-state (append (explode-string string) '(*)) '(*)))]))
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
You can’t perform that action at this time.