Skip to content

pierwill/bbrs

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

40 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Rust

bbrs

bbrs implements a simple language from Pierce's TAPL in Rust using pest.

Based on 𝔹 in Benjamin Pierce, Types and Programming Languages (U of Pennsylvania Press, 2002), page 34.

Currently working on implementing this grammar:

value = { "true" | "false" }
conditional = { "if" ~ term ~ "then" ~ term ~  "else" ~ term  }
term = { value | conditional }

The idea is a working, extensible interprer that'll do something like this:

>> true
true
>> false
false
>> if true then true else false
true
>> if false then true else false
false
>> funny
Error!

Eventually I'd like to add named variables and assignments. Things would look something like this:

WHITESPACE = _{ " " }
value = { "true" | "false" }
conditional = { "if" ~ term ~ "then" ~ term ~ "else" ~ term  }
name = @{ !("let"|"if"|"then"|"else"|value) ~ "_"? ~ ASCII_ALPHA+ ~ ANY? }
assignment = { "let" ~ name ~ "=" ~ value }
term = { name | assignment | value | conditional }

N.B.: These are parsing expression grammars as used by pest, not Extended Backus–Naur form.

References

About

Playing with a type system from B. Pierce's TAPL book

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

 
 
 

Contributors

Languages