Skip to content

Instantly share code, notes, and snippets.

View kmicinski's full-sized avatar

Kristopher Micinski kmicinski

View GitHub Profile
@kmicinski
kmicinski / 10-16.rkt
Created October 16, 2025 23:14
Project 3 -- partial solution from class
#lang racket
;; CIS531 Fall '25 Project 1
;; Compiling LVar -> x86-64
(require "irs.rkt") ;; Definition of each IR (please read)
(require "system.rkt") ;; System-specific details
(require "interpreters.rkt")
(provide
typecheck
@kmicinski
kmicinski / 10-07.rkt
Created October 7, 2025 23:21
Code from class: 10/07 (CPS, etc.)
#lang racket
(define (atom? a)
(match a
[(? integer? i) #t]
[(? symbol? x) #t]
[_ #f]))
(define (anf-transform e)
;; e is the expression to be converted
@kmicinski
kmicinski / cps-notes.rkt
Last active October 5, 2025 17:14
CIS531 Project 2 -- `anf-convert`, CPS and CPS Conversion
#lang racket
;; CIS531 -- Fall 2025
;; Kristopher Micinski
;;
;; Notes on CPS Conversion
#;(+ (* (read) 3) (+ 4 5))
;; When we translate constructs like +, *, and other
#lang racket
(require "system.rkt")
;;
;; This file provides detailed documentation of each of the IRs used
;; in the project.
;;
;; Please do not modify this code (doing so will not help you): your
;; passes must conform to these specifications for the autograder to
@kmicinski
kmicinski / left-assoc.rkt
Created September 19, 2025 18:18
Parsing left-associative operators in LL(k) grammars
#lang racket
;; When we say an operator "associates to the left,"
;; we mean that we interpret a construct like
;; 10 - 2 - 2 is interpreted as (10 - 2) - 2 rather
;; than the (incorrect) 10 - (2 - 2). Most typical
;; arithmetic operators like +, *, /, and - associate
;; to the left.
;; Unfortunately, LL parsers do not make this natural
#lang racket
;; Tuesday, April 8, 2025
;; CIS352
(define (λ-expr? e)
(match e
[(? symbol? x) #t]
[`(lambda (,(? symbol? x)) ,(? λ-expr? e-b)) #t]
[`(,(? λ-expr? e0) ,(? λ-expr? e1)) #t]
#lang racket
;; CIS352 -- P3 Builtins help
;;
;; I wrote up these notes based on some student meetings.
;; This project is intentionally a bit vague about how to
;; handle the builtins. That is because I want you to have
;; some ability to have the experience of figuring out how
;; you might want to engineer your own solution, considering
;; the various trade-offs.
@kmicinski
kmicinski / buffer1.rkt
Created March 20, 2025 19:32
Exercise 3 help
#lang racket
;; Consider the folllowing λ-calculus expression, write
;; a reduction sequence where each β reduction in the
;; sequence uses CBV evaluation order
((λ (x) x)
((λ (y) y) (λ (z) z)))
((λ (x) x)
((λ (z) (z z)) (λ (y) (y y))))
@kmicinski
kmicinski / 03-20.rkt
Created March 20, 2025 17:34
CIS352 'S25 -- 3/20/25
#lang racket
;; CIS352 -- March 20, 2025
;; For the past few lectures, we've talked about the idea of "in-context" β:
;; the idea that we can "just do all the βs." So for example:
((λ (b) b)
(((λ (x) x) (λ (a) a))
((λ (y) y) (λ (z) z))))
#lang racket
;; CIS 352 -- Spring '25
;; March 18, 2025
;; This week in class:
;; [ ] λ-calculus refresher
;; [ ] λ-calculus β reduction motivation
;; [ ] Extending the λ-calculus with numbers
;; [ ] Building an interpreter with closures