Skip to content

A simple parser that take a logic proposition and pretty print its truth table

License

Notifications You must be signed in to change notification settings

BuzzYbis/parsing-logic

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

3 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Parsing logic

What is this project

This project goal is to parse some logic proposition and return is truth table.

Build

dune build

Run

dune exec -- truth_table "(p -> q) & (!r | q)"

dune exec -- truth_table  # then type an expression interactively

For the first type of execution, directly passing the proposition as an arg, you will may have to type (p -> q) & (\!r | q) to avoid your terminal to use ! as a shortcut. If you do not want to be bothered by that, use the interactive mode.

Grammar

The grammar of the logic proposition we want to parse is fairly simple, we have:

  • Variable:
  • Constants: true | false
  • Prefix functions:
    • Not: !
  • Infix functions:
    • And: &
    • Or: |
    • Implies: -> (right associative)
    • If and only if: <=> (right associative)
  • Parenthesis: ( | )

Precedence (high → low): NOT > AND > OR > IMPLIES > IFF.

Overview

See OVERVIEW.md

About

A simple parser that take a logic proposition and pretty print its truth table

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published