eelco-visser-compiler-const.../lab/0a.html

1020 lines
15 KiB
HTML

<!doctype html>
<html lang="en">
<head>
<meta charset="utf-8">
<meta name="viewport" content="width=device-width, initial-scale=1, shrink-to-fit=no">
<meta name="description" content="">
<meta name="author" content="Eelco Visser">
<meta name="generator" content="Jekyll v3.8.5">
<title>Lab 0(a): The ChocoPy Language</title>
<!-- <base href="/2021"> -->
<!--link rel="canonical" href="https://getbootstrap.com/docs/4.3/examples/starter-template/"-->
<link rel="icon" href="../img/logo/pl_ico2_2B3_icon.ico" type="image/x-icon">
<!-- Bootstrap core CSS -->
<!--link href="https://getbootstrap.com/docs/4.3/dist/css/bootstrap.min.css" rel="stylesheet" integrity="sha384-ggOyR0iXCbMQv3Xipma34MD+dH/1fQ784/j6cY/iJTQUOhcWr7x9JvoRxT2MZw1T" crossorigin="anonymous"-->
<link rel="stylesheet" href="https://stackpath.bootstrapcdn.com/bootstrap/4.3.1/css/bootstrap.min.css" integrity="sha384-ggOyR0iXCbMQv3Xipma34MD+dH/1fQ784/j6cY/iJTQUOhcWr7x9JvoRxT2MZw1T" crossorigin="anonymous">
<style>
.bd-placeholder-img {
font-size: 1.125rem;
text-anchor: middle;
-webkit-user-select: none;
-moz-user-select: none;
-ms-user-select: none;
user-select: none;
}
@media (min-width: 768px) {
.bd-placeholder-img-lg {
font-size: 3.5rem;
}
}
</style>
<!-- Custom styles for this template -->
<link href="../css/main.css" rel="stylesheet">
<link href="../css/borders-responsive.css" rel="stylesheet">
<link rel="stylesheet" href="../css/pl.css">
</head>
<body>
<nav class="navbar navbar-expand-md navbar-dark bg-dark fixed-top">
<a class="navbar-brand" href="../index.html">
TU Delft | CS4200
</a>
<button class="navbar-toggler" type="button" data-toggle="collapse" data-target="#navbarsExampleDefault" aria-controls="navbarsExampleDefault" aria-expanded="false" aria-label="Toggle navigation">
<span class="navbar-toggler-icon"></span>
</button>
<div class="collapse navbar-collapse" id="navbarsExampleDefault">
<ul class="navbar-nav mr-auto">
<li class="nav-item active">
<a class="nav-link" href="../lectures/index.html" tabindex="-1" aria-disabled="true">Lectures</a>
</li>
<li class="nav-item active">
<a class="nav-link" href="../homework/index.html" tabindex="-1" aria-disabled="true">Homework</a>
</li>
<li class="nav-item active">
<a class="nav-link" href="../project/index.html" tabindex="-1" aria-disabled="true">Project</a>
</li>
<li class="nav-item active">
<a class="nav-link" href="../news/index.html" tabindex="-1" aria-disabled="true">News</a>
</li>
<li class="nav-item active">
<a class="nav-link" href="../blog/index.html" tabindex="-1" aria-disabled="true">Blog</a>
</li>
</ul>
</div>
</nav>
<div class="container">
<div class="row">
<div class="col-sm-12 col-md-12 col-lg-12 col-xl-12">
<a href="https://tudelft-cs4200.github.io/2021https://chocopy.org/chocopy_language_reference.pdf">
<img class="border border-dark" width="100%" src="../project/2021/00-lab0a/chocopy-refman.png"/>
</a>
<div class="mt-3 mb-3 pt-3 pb-3 text-dark border-top border-bottom border-grey">
<div class="text-dark font-weight-bold">
<h1>
<a class="text-dark" href="https://chocopy.org/chocopy_language_reference.pdf">
Lab 0(a): The ChocoPy Language
</a>
</h1>
</div>
<div>
</div>
<div>
<a class="text-primary" href="https://chocopy.org/chocopy_language_reference.pdf">
Project Language Documentation
</a>
| <a class="text-primary" href="https://tudelft-cs4200.github.io/2021https://chocopy.org/chocopy_language_reference.pdf">PDF</a>
</div>
<div>
September 03, 2021
</div>
</div>
</div>
</div>
<div class="row">
<div class="col-sm-12 col-md-12 col-lg-9 border-lg-right border-grey">
<h3 id="project-language">Project Language</h3>
<p>In the course project you will build a compiler and IDE for the ChocoPy language. Quoting from the ChocoPy <a href="http://chocopy.org">website</a>:</p>
<blockquote>
<p>ChocoPy is a programming language designed for classroom use in undergraduate compilers courses. ChocoPy is a restricted subset of Python 3, which can easily be compiled to a target such as RISC-V. The language is fully specified using formal grammar, typing rules, and operational semantics. ChocoPy is used to teach CS 164 at UC Berkeley. ChocoPy has been designed by Rohan Padhye and Koushik Sen, with substantial contributions from Paul Hilfinger.</p>
<p>At a glance, ChocoPy is:</p>
<p><strong>Familiar</strong>: ChocoPy programs can be executed directly in a Python (3.6+) interpreter. ChocoPy programs can also be edited using standard Python syntax highlighting.</p>
<p><strong>Safe</strong>: ChocoPy uses Python 3.6 type annotations to enforce static type checking. The type system supports nominal subtyping.</p>
<p><strong>Concise</strong>: A full compiler for ChocoPy be implemented in about 12 weeks by undergraduate students of computer science. This can be a hugely rewarding exercise for students.</p>
<p><strong>Expressive</strong>: One can write non-trivial ChocoPy programs using lists, classes, and nested functions. Such language features also lead to interesting implications for compiler design.</p>
<p>Bonus: Due to static type safety and ahead-of-time compilation, most student implementations outperform the reference Python implementation on non-trivial benchmarks.</p>
</blockquote>
<h3 id="the-chocopy-reference-manual">The ChocoPy Reference Manual</h3>
<p>The ChocoPy reference manual is the authority on the definition of the syntax and semantics of ChocoPy.
Start reading the document to understand the language design.</p>
<h3 id="chocopy-example-programs">ChocoPy Example Programs</h3>
<p>You can find examples of ChocoPy programs at <a href="https://github.com/cs164berkeley">https://github.com/cs164berkeley</a>.</p>
<h3 id="references">References</h3>
<ul class="list-group list-group-flush pb-3">
<li class="list-group-item pl-lg-0 border-0 pb-0">
<div class="bd-callout border-success pl-3">
<div>
<a name="PadhyeSH19"></a>
<a class="font-weight-bold text-dark" target="_blank" href="https://chocopy.org/chocopy_language_reference.pdf">ChocoPy v2.2: Language Manual and Reference</a>
</div>
<div class="font-weight-light text-secondary" style="font-size:90%;">
<a class="text-secondary" href="https://researchr.org/alias/rohan-padhye">Rohan Padhye</a>, <a class="text-secondary" href="https://researchr.org/alias/koushik-sen">Koushik Sen</a>, <a class="text-secondary" href="https://researchr.org/alias/paul-hilfnger"> Paul Hilfnger</a>, <a class="text-secondary" href="https://researchr.org/alias/rohan-padhye">Rohan Padhye</a>, <a class="text-secondary" href="https://researchr.org/alias/koushik-sen">Koushik Sen</a>, <a class="text-secondary" href="https://researchr.org/alias/paul-hilfnger"> Paul Hilfnger</a>.
</div>
<div class="font-weight-light text-secondary" style="font-size:90%;">
[<a href="https://tudelft-cs4200.github.io/2021https://chocopy.org/chocopy_language_reference.pdf" class="text-secondary" target="_blank">pdf</a>, <a class="text-secondary" target="_blank" href="https://researchr.org/publication/PadhyeSH19/bibtex">bib</a>, <a href="https://researchr.org/publication/PadhyeSH19" class="text-secondary" target="_blank">researchr</a>]
<!-- -->
</div>
</div>
</li>
<li class="list-group-item pl-lg-0 border-0 pb-0">
<div class="bd-callout border-primary pl-3">
<div>
<a name="PhadyeSH19-SPLASHE"></a>
<a class="font-weight-bold text-dark" target="_blank" href="https://tudelft-cs4200.github.io/2021/lab/10.1145/3358711.3361627">ChocoPy: A Programming Language for Compilers Courses</a>
</div>
<div class="font-weight-light text-secondary" style="font-size:90%;">
<a class="text-secondary" href="https://researchr.org/alias/padhye%2C-rohan">Padhye, Rohan</a>, <a class="text-secondary" href="https://researchr.org/alias/sen%2C-koushik">Sen, Koushik</a>, <a class="text-secondary" href="https://researchr.org/alias/hilfinger%2C-paul-n.">Hilfinger, Paul N.</a>.
</div>
<div class="font-weight-light text-secondary" style="font-size:90%;">
Proceedings of the 2019 ACM SIGPLAN Symposium on SPLASH-E 2019
[<a href="https://tudelft-cs4200.github.io/2021https://chocopy.org/chocopy-splashe19.pdf" class="text-secondary" target="_blank">pdf</a>, <a class="text-secondary" href="https://tudelft-cs4200.github.io/2021/lab/10.1145/3358711.3361627" target="_blank">doi</a>, <a class="text-secondary" target="_blank" href="https://researchr.org/publication/PhadyeSH19-SPLASHE/bibtex">bib</a>, <a href="https://researchr.org/publication/PhadyeSH19-SPLASHE" class="text-secondary" target="_blank">researchr</a>, <a class="text-secondary" data-toggle="collapse" href="0a.html#AbstractPhadyeSH19-SPLASHE" role="button" aria-expanded="false" aria-controls="AbstractPhadyeSH19-SPLASHE"">abstract</a>]
<!-- -->
</div>
<div class="collapse mt-1 mb-2" id="AbstractPhadyeSH19-SPLASHE">
<div class="">
ChocoPy is a programming language designed for teaching an undergraduate course on programming languages and compilers. ChocoPy is a restricted subset of Python 3.6, using static type annotations to enforce compile-time type safety. ChocoPy is fully specified using formal grammar, typing rules, and operational semantics. Valid ChocoPy programs can be executed in a standard Python interpreter, producing results consistent with ChocoPy semantics. A major component of CS164 at UC Berkeley is the project: students develop a full compiler for ChocoPy, targeting RISC-V, in about twelve weeks. In other exercises, students extend the syntax, type system, and formal semantics to support additional features of Python. In this paper, we outline (1) the motivations for creating the ChocoPy project, (2) salient features of the language, (3) the resources provided to students to develop their compiler, (4) some insights gained from teaching two semesters of ChocoPy-based courses by different instructors. Our assignment resources are available for re-use by other instructors and institutions.
</div>
</div>
</div>
</li>
<li class="list-group-item pl-lg-0 border-0 pb-0">
<div class="bd-callout border-success pl-3">
<div>
<a name="ChocoPyOrg19"></a>
<a class="font-weight-bold text-dark" target="_blank" href="http://chocopy.org">The ChocoPy website</a>
</div>
<div class="font-weight-light" style="font-size:90%;">
(editor).
</div>
<div class="font-weight-light text-secondary" style="font-size:90%;">
https://chocopy.org/ 2019
[<a class="text-secondary" target="_blank" href="https://researchr.org/publication/ChocoPyOrg19/bibtex">bib</a>, <a href="https://researchr.org/publication/ChocoPyOrg19" class="text-secondary" target="_blank">researchr</a>]
<!-- ChocoPyOrg19 -->
</div>
</div>
</li>
</ul>
</div>
<div class="col-sm-12 col-md-12 col-lg-3 col-xl-3 " >
<div class="sticky-top top70 d-none d-lg-block d-xl-block">
<div class="pb4 mb3 border-bottom border-grey ">
<nav>
<ul class="pagination justify-content-left">
<li class="page-item">
<a class="page-link" href="0.html">
&laquo;
</a>
</li>
<li class="page-item">
<a class="page-link" href="../project/index.html">
^
</a>
</li>
<li class="page-item">
<a class="page-link" href="0b.html">&raquo;</a>
</li>
</ul>
</nav>
</div>
<ul id="my_toc" class="toc list-group list-group-flush d-none d-lg-block d-xl-block p-0 ml-0 mt-3">
<li class="list-group-item pl-0 ml-0 border-0 pl-0 pt-0 pb-1 pr-0 m-0 mr-3"><a href="0a.html#project-language">Project Language</a></li>
<li class="list-group-item pl-0 ml-0 border-0 pl-0 pt-0 pb-1 pr-0 m-0 mr-3"><a href="0a.html#the-chocopy-reference-manual">The ChocoPy Reference Manual</a></li>
<li class="list-group-item pl-0 ml-0 border-0 pl-0 pt-0 pb-1 pr-0 m-0 mr-3"><a href="0a.html#chocopy-example-programs">ChocoPy Example Programs</a></li>
<li class="list-group-item pl-0 ml-0 border-0 pl-0 pt-0 pb-1 pr-0 m-0 mr-3"><a href="0a.html#references">References</a></li>
</ul>
</div>
</div>
</div>
<div class="row">
<div class="col-12">
<div class="border-top border-bottom border-grey mt-3 pt-3">
<nav>
<ul class="pagination justify-content-center">
<li class="page-item">
<a class="page-link" href="0.html">
Previous
</a>
</li>
<li class="page-item">
<a class="page-link" href="0b.html">Next</a>
</li>
<li class="page-item">
<a class="page-link" href="../project/index.html">
Index
</a>
</li>
</ul>
</nav>
</div>
</div>
</div>
</div>
<!-- Optional JavaScript -->
<!-- jQuery first, then Popper.js, then Bootstrap JS -->
<script src="https://code.jquery.com/jquery-3.3.1.slim.min.js" integrity="sha384-q8i/X+965DzO0rT7abK41JStQIAqVgRVzpbzo5smXKp4YfRvH+8abtTE1Pi6jizo" crossorigin="anonymous"></script>
<script src="https://cdnjs.cloudflare.com/ajax/libs/popper.js/1.14.7/umd/popper.min.js" integrity="sha384-UO2eT0CpHqdSJQ6hJty5KVphtPhzWj9WO1clHTMGa3JDZwrnQq4sF86dIHNDz0W1" crossorigin="anonymous"></script>
<script src="https://stackpath.bootstrapcdn.com/bootstrap/4.3.1/js/bootstrap.min.js" integrity="sha384-JjSmVgyd0p3pXB1rRibZUAYoIIy6OrQ6VrjIEaFf/nJGzIxFDsf4x0xIM+B07jRM" crossorigin="anonymous"></script>
</body>
</html>