Skip to content

Instantly share code, notes, and snippets.

View danking's full-sized avatar

Dan King danking

View GitHub Profile
Group is
tiger.lex
errormsg.sml
parsetest.sml
tiger.grm
smlnj-lib.cm
ml-yacc-lib.cm
signature ERRORMSG =
sig
val anyErrors : bool ref
val fileName : string ref
val lineNum : int ref
val linePos : int list ref
val sourceStream : TextIO.instream ref
val error : int -> string -> unit
exception Error
val impossible : string -> 'a (* raises Error *)
(define-syntax (define-ustruct stx)
(define (make-updater-name struct-name field-name)
(symbol-append struct-name '-update- field-name))
(define (make-updater-proc name-stx field-stx)
(let* ((field-name (syntax->datum field-stx))
(struct-name (syntax->datum name-stx))
(update-proc (datum->syntax name-stx
(make-updater-name struct-name
field-name))))
#`(define (#,update-proc s val)
(define-syntax symbol-append
(syntax-rules ()
[(_ sym ...)
(string->symbol (string-append (symbol->string sym) ...))]))
(define-syntax (define-ustruct stx)
(define (make-updater-name struct-name field-name)
;; How do I get symbol-append to be defined here?
(symbol-append struct-name '-update- field-name))
(define (make-updater-proc name-stx field-stx)
--- Data stack:
1
2
3
4
5
( scratchpad ) [| :> a | a ] call
--- Data stack:
1
danking@danking-desktop:~ 18:31 $ racket
Welcome to Racket v5.1.
> (require ffi/unsafe)
> ((get-ffi-obj "execv" #f (_fun _path (_list i _string) -> _int)) "/bin/ls" '("/bin/ls"))
-1
> "test"
"test"
>
danking@danking-desktop:~ 18:32 $
{-# LANGUAGE GADTs, FlexibleInstances #-}
data Stack a where
Empty :: () -> Stack ()
Push :: b -> Stack a -> Stack (b,Stack a)
instance Show (Stack ()) where
show (Empty ()) = "()"
instance (Show a, Show b) => Show (Stack (a,b)) where
deref ::= id LBRACK num RBRACK
| id DOT id
| id DOT foo
id . LBRACK num RBRACK
id . DOT id
id . DOT foo
id DOT . id
Grammar
0 $accept: foo $end
1 foo: foo A
2 | A
Terminals, with rules where they appear
Grammar
0 $accept: foo $end
1 foo: foo A
2 | A
Terminals, with rules where they appear