Skip to content

quartztz/boolalg-rs

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

13 Commits
 
 
 
 
 
 
 
 
 
 

Repository files navigation

boolalg-rs a boolean algebra library to practice language parsing

mostly defines an Expr enumeration and an evaluate function. There's also the ability to define a context as a HashMap and substitute variables with their value.

to be potentially turned into a wasm project.

The interface

a veeeeeery crudely implemented shell is given in main.rs to work with the given definitions and see if they are properly implemented. its functioning is described here. First, an example:

> $: a = p v q
added => a = (p v q)
> !: p -> T
=> setting p to T
> ?: (p v F) ^ p
parsed => ((p v F) ^ p)
evaluated => T
> ?: $a
using prev def => (p v q)
evaluated => T

On prompt > , multiple options are available:

  • !: { char } -> { T | F | - }: update the evaluation context giving variable { char } the value T or F depending on input.
  • $: { char } = { expr }: define a new macro giving identifier { char } value { expr }. This is confusing. I know. At least the evaluation is unambiguous.
  • ?: { expr | $iden }: evaluate an expression, either typed out in as { expr } or addressed using a previously defined identifier and a dollar sign.
  • close: closes the shell
  • status: prints the variable hashmap
  • help: show help (not implemented yet)

TODO

  • make it easier to use and test => add an interface
  • restructure the code into a more Model View Controller format => make it a library?
  • refactor/rewrite to make the shell code more readable and concise. right now it sucks.
  • figure out wasm

Inspirations/Credits

This project was motivated by my hate of my CS101 class. What a learning experience that was.

The parsing is heavily inspired by this resource right here: Parser In Rust. It's very detailed and only needed a little coaxing to work with my integration.

About

No description, website, or topics provided.

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages