A parser to calculate AND-OR string expression
Branch: master
Clone or download
Fetching latest commit…
Cannot retrieve the latest commit at this time.
Permalink
Type Name Latest commit message Commit time
Failed to load latest commit information.
.gitignore
LICENSE
Makefile
README.md
expr_parser.c
expression.c
expression.h
lexer.l
parser.y

README.md

expr_parser


What is this

A parser to calculate AND-OR string expression.

For example,

./expr_parser "abc == abc && ab ^^ a"

means abc equals abc AND ab contains a, which is True.

This program's output is

Expression: ((((abc) == (abc))) && (((ab) ^^ (a))))
Result: 1

expr_parser supports below four Operators and (,)

Operator Description
A && B A AND B
A || B A OR B
A == B string A equals to string B
A ^^ B string A contains string B

What this can do

Many applications need to support filtering input or output.

They can simply extend this code for their programs for supporting more operators.

To use this code, you need replace the RIGHT string with your own data.