Last active
March 22, 2016 00:19
-
-
Save vitaut/0aae222c71f24c287dc6 to your computer and use it in GitHub Desktop.
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
#include "mp/nl-reader.h" | |
enum Expr {OTHER, CONST}; | |
struct ExprCounter : mp::NullNLHandler<Expr> { | |
int num_divs; | |
ExprCounter() : num_divs(0) {} | |
Expr OnBinary(mp::expr::Kind kind, Expr lhs, Expr rhs) { | |
if (kind == mp::expr::DIV && rhs != CONST) | |
++num_divs; | |
} | |
Expr OnNumericConstant(double value) { return CONST; } | |
}; | |
int main(int argc, char **argv) { | |
for (int i = 1; i < argc; ++i) { | |
ExprCounter counter; | |
mp::ReadNLFile(argv[i], counter); | |
if (counter.num_divs != 0) | |
fmt::print("{}: {} divisions\n", argv[i], counter.num_divs); | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment