Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
51 changes: 51 additions & 0 deletions .github/workflows/jekyll-gh-pages.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,51 @@
# Sample workflow for building and deploying a Jekyll site to GitHub Pages
name: Deploy Jekyll with GitHub Pages dependencies preinstalled

on:
# Runs on pushes targeting the default branch
push:
branches: ["main"]

# Allows you to run this workflow manually from the Actions tab
workflow_dispatch:

# Sets permissions of the GITHUB_TOKEN to allow deployment to GitHub Pages
permissions:
contents: read
pages: write
id-token: write

# Allow only one concurrent deployment, skipping runs queued between the run in-progress and latest queued.
# However, do NOT cancel in-progress runs as we want to allow these production deployments to complete.
concurrency:
group: "pages"
cancel-in-progress: false

jobs:
# Build job
build:
runs-on: ubuntu-latest
steps:
- name: Checkout
uses: actions/checkout@v4
- name: Setup Pages
uses: actions/configure-pages@v5
- name: Build with Jekyll
uses: actions/jekyll-build-pages@v1
with:
source: ./
destination: ./_site
- name: Upload artifact
uses: actions/upload-pages-artifact@v3

# Deployment job
deploy:
environment:
name: github-pages
url: ${{ steps.deployment.outputs.page_url }}
runs-on: ubuntu-latest
needs: build
steps:
- name: Deploy to GitHub Pages
id: deployment
uses: actions/deploy-pages@v4
4 changes: 2 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
# Status

[![.github/workflows/ci.yml](https://github.com/clause/471c/actions/workflows/ci.yml/badge.svg)](https://github.com/clause/471c/actions/workflows/ci.yml)
[![Coverage](https://codecov.io/gh/clause/471c/branch/main/graph/badge.svg)](https://codecov.io/gh/clause/471c)
[![.github/workflows/ci.yml](https://github.com/clause/471c/actions/workflows/ci.yml/badge.svg)](https://github.com/Amena2026/471c/actions/workflows/ci.yml)
[![Coverage](https://codecov.io/gh/clause/471c/branch/main/graph/badge.svg)](https://app.codecov.io/gh/Amena2026/471c)

# Contributing

Expand Down
33 changes: 33 additions & 0 deletions packages/L0/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,33 @@
#copy
duplicate the value from a source identifier and insert it into a destination identifer

#immediate
A constant value like an integer that doesnt need to be loaded or stored

#primitave
a math operation containing one or more operands

#Branch
A sequence of instructions that you want to run only if a certain condition is met

#Allocate
give a certain amount of memory to a variable or data structure

#Load
get a value from memory or a data structure

#store
insert a value into memory or a data structure

#Address
a location of memory that can be used to store and retrieve data from

#Call
a sequence of instructions to be run, given an identifier

#halt
stop execution, return from a function

# difference between L2 & L1
Abstract has been removed, Address and call have been introducted. Address is an identifier to store and retrieve data from
, while a call allows for a sequence of instructions to be run given an identifier.
32 changes: 32 additions & 0 deletions packages/L1/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,32 @@
#copy
duplicate the value from a source identifier and insert it into a destination identifer

#Abstract
assigns the value of a sequence into an identifier

#Apply
perform a squence of instructions

#immediate
A constant value like an integer that doesnt need to be loaded or stored

#primitave
a math operation containing one or more operands

#Branch
A sequence of instructions that you want to run only if a certain condition is met

#Allocate
give a certain amount of memory to a variable or data structure

#Load
get a value from memory or a data structure

#store
insert a value into memory or a data structure

#halt
stop execution, return from a function

# difference between L2 & L1
terms have been removed and are now replaced by statements. Let and reference have both been removed and is now replaced by copy, which allows for the duplication of data from one identifer to another. Halt is introduced to let you return from a function
36 changes: 36 additions & 0 deletions packages/L2/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,36 @@
#Let
Assign a value to a identifier

#Reference
points to a memory location that contains a value

#Abstract
assigns the value of a sequence into an identifier

#Apply
perform a squence of instructions

#immediate
A constant value like an integer that doesnt need to be loaded or stored

#primitave
a math operation containing one or more operands

#Branch
A sequence of instructions that you want to run only if a certain condition is met

#Allocate
give a certain amount of memory to a variable or data structure

#Load
get a value from memory or a data structure

#store
insert a value into memory or a data structure

#begin
start a sequence of instructions


# difference between L3 & L2
no new features have been added. Letrec has been removed
118 changes: 107 additions & 11 deletions packages/L2/src/L2/cps_convert.py
Original file line number Diff line number Diff line change
Expand Up @@ -16,37 +16,133 @@ def cps_convert_term(

match term:
case L2.Let(bindings=bindings, body=body):
pass

def sequence_bindings(bs):
if not bs:
return _term(body, k)
(name, term_), *rest = bs
return _term(
term_,
lambda v, n=name, r=rest: L1.Copy(
destination=n,
source=v,
then=sequence_bindings(r),
),
)

return sequence_bindings(bindings)

case L2.Reference(name=name):
pass
return k(name)

case L2.Abstract(parameters=parameters, body=body):
pass
t = fresh("t")
kp = fresh("k")
return L1.Abstract(
destination=t,
parameters=[*parameters, kp],
body=_term(body, lambda v, kp=kp: L1.Apply(target=kp, arguments=[v])),
then=k(t),
)

case L2.Apply(target=target, arguments=arguments):
pass
kp = fresh("k")
t = fresh("t")

def after_target(tgt, kp=kp, t=t):
def after_args(args, kp=kp, t=t, tgt=tgt):
return L1.Abstract(
destination=kp,
parameters=[t],
body=k(t),
then=L1.Apply(target=tgt, arguments=[*args, kp]),
)

return _terms(arguments, after_args)

return _term(target, after_target)

case L2.Immediate(value=value):
pass
t = fresh("t")
return L1.Immediate(destination=t, value=value, then=k(t))

case L2.Primitive(operator=operator, left=left, right=right):
pass

def after_left(l, op=operator, r=right):
def after_right(rv, op=op, l=l):
t = fresh("t")
return L1.Primitive(destination=t, operator=op, left=l, right=rv, then=k(t))

return _term(r, after_right)

return _term(left, after_left)

case L2.Branch(operator=operator, left=left, right=right, consequent=consequent, otherwise=otherwise):
pass
j = fresh("j")
t = fresh("t")

def after_left(l, op=operator, r=right, cons=consequent, other=otherwise, j=j, t=t):
def after_right(rv, op=op, l=l, cons=cons, other=other, j=j, t=t):
def after_cons(c, op=op, l=l, rv=rv, other=other, j=j, t=t):
def after_other(o, op=op, l=l, rv=rv, c=c, j=j, t=t):
return L1.Abstract(
destination=j,
parameters=[t],
body=k(t),
then=L1.Branch(
operator=op,
left=l,
right=rv,
then=L1.Apply(target=j, arguments=[c]),
otherwise=L1.Apply(target=j, arguments=[o]),
),
)

return _term(other, after_other)

return _term(cons, after_cons)

return _term(r, after_right)

return _term(left, after_left)

case L2.Allocate(count=count):
pass
t = fresh("t")
return L1.Allocate(destination=t, count=count, then=k(t))

case L2.Load(base=base, index=index):
pass

def after_base(b, idx=index):
t = fresh("t")
return L1.Load(destination=t, base=b, index=idx, then=k(t))

return _term(base, after_base)

case L2.Store(base=base, index=index, value=value):
pass

def after_base(b, idx=index, val=value):
def after_value(v, b=b, idx=idx):
t = fresh("t")
return L1.Store(
base=b,
index=idx,
value=v,
then=L1.Immediate(destination=t, value=0, then=k(t)),
)

return _term(val, after_value)

return _term(base, after_base)

case L2.Begin(effects=effects, value=value): # pragma: no branch
pass

def sequence_effects(effs):
if not effs:
return _term(value, k)
first, *rest = effs
return _term(first, lambda _, r=rest: sequence_effects(r))

return sequence_effects(effects)


def cps_convert_terms(
Expand Down
Loading