Skip to content

ucsd-cse230/03-whilepp

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

13 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

whilepp

A Teeny Tiny Type checker and Interpreter for WHILE++ to get some practice with

  1. Parser combinators chumsky
  2. Error handling Result
  3. Type checking
  4. Error reporting ariadne
  5. Property based testing proptest

Part 1: Parse

Fill in the parse_todo!() inside parse.rs to parse expressions the WHILE++ language.

  1. First, complete the implementations of parse_rel_expr and parse_expr. When you are done cargo test relational should work.

  2. Next, define and use sub-parsers like if_only and try_ to parse one-armed if statements and try statements. When you are done cargo test statement should pass.

When you are done with both parts, cargo test parse should pass.

Part 2: Evaluate

Next, fill in the todo!() inside eval.rs to evaluate WHILE++ programs.

  1. First, fill in eval_op and eval_expr to evaluate expressions. When you are done, cargo test eval should pass

  2. Next, fill in eval_stmt to evaluate statements. When you are done, cargo test run should pass.

Part 3: Check

Finally, you will implement a small static checker for WHILE++ programs.

  1. First, implement check_expr which checks that an Expr is well-typed in a given Env. When you are done, cargo test check_expr should pass.

  2. Next, implement check_stmt which checks that a Stmt is well-typed in a given Env. When you are done, cargo test soundness should pass.

Specifically, the soundness tests check that if a program type-checks, then it will not produce a runtime type error when evaluated (divide by zero is ok).

When you are done with all the parts, cargo test check should pass.

Grading

Each test is worth 5 points; so you can run cargo test and figure out your score.

You can run python3 grade.py to do the tabulation automatically.

Submission

You can submit your assignment by running make turnin

About

Rust starter code for building a small interpreter and type checker for while++

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

 
 
 

Contributors