Skip to content

Latest commit

 

History

28 Commits

Folders and files

NameName
Last commit message
Last commit date
 
 
 
 

Repository files navigation

Program uses shunting yard algorithm to interpret C Preprocessor (#if, #elif) boolean expressions

Examples

  • c_eval function implements Parser(with Precedence of all operators such as defined ! | >> ...)
  • defined operator must take only an identifier
  • Below Expression will output a syntax error
expr = "!defined(456)"
c_eval(expr)
image
expr = "~ defined(TEST)"
c_eval(expr)

image
expr = "F > 12.3"
c_eval(expr)
image
expr = "!defined(AAA) && F > H +"
c_eval(expr)
image
  • If there is an identifier in this expression, it means it has not defined and treated as 0 in eval loop
  • For Example below, B will be treated as 0
expr = "!defined(B) && 123 > 1257"
c_eval(expr) # False
  • Also FOO and F Treated as 0
expr = "!defined(FOO) && 123678 > 1257 || F + 12"
c_eval(expr) # True

About

This is Python implementation of C Preprocessor (#if) conditional evaluator with Shunting-Yard algorithm.

Topics

Resources

Stars

0 stars

Watchers

0 watching

Forks

Releases

Packages

Contributors

Languages