Skip to content

Parser and evaluator of trivaluated logical expressions

Notifications You must be signed in to change notification settings

faculerena/logical-parser

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

5 Commits
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Trivaluated logic expression parser

Note: This DOES NOT apply the "NOT" operator. If someone has an idea on how to implement it and wants to do it, please do!

Simple logical expression parser and evaluator. It accepts this format:

"(...) operation (...)"

Examples

exp1 = "(a&b)|c"
exp2 = "(a>b)|(c&d)"

Given an expression, it'll ask for the values of each variable. Enter T, F or U as needed. It'll then evaluate the expression and print the result.

Here's more info and another examples of the parser (the latest 3 doesn't evaluate the expression). I took inspiration and got helped by the authors!

parser by iglosiggio (javascript)

parser by nsanmartin (Haskell)

parser by fsan (Python)

And a few more. In the next days I will make a post talking about the similarities in the parsers. (e.g. only one implemented the "not" operator, why?)

About

Parser and evaluator of trivaluated logical expressions

Topics

Resources

Stars

Watchers

Forks

Languages