Created
March 14, 2019 17:24
-
-
Save shekohex/a26e95fdbdde6392950eba69baba5ac7 to your computer and use it in GitHub Desktop.
Simple boolean expression parser Roles using pest.rs https://pest.rs
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
AND = { "." } | |
NOT = { "`" } | |
OR = { "+" } | |
SEP = _{ (NEWLINE | WHITE_SPACE) } | |
VAR_NAME = { (ASCII_ALPHA ~ ASCII_DIGIT*) } | |
VAR = { VAR_NAME ~ SEP* ~ NOT? ~ SEP* } | |
EXP = { VAR ~ SEP* ~ ((OR | AND) ~ SEP* ~ VAR ~ SEP*)* } | |
FUNC = { VAR ~ SEP* ~ "=" ~ SEP* ~ EXP+ } | |
ROOT = _{ SOI ~ NEWLINE* ~ (FUNC | ANY) ~ NEWLINE* ~ EOI } |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment