制約と validator 自動生成ツール
$ make test-gen-dsl
c++ -fsanitize=undefined -O2 test-gen-dsl.cpp -o test-gen-dsl
$ ./test-gen-dsl doc
- $n$ は整数である.
- $m$ は整数である.
$ ./test-gen-dsl validator
long long int n = readLong();
long long int m = readLong();
#include <iostream> | |
using namespace std; | |
#define IS_INTEGER(varname) gen_integer(varname, mode); | |
void gen_integer(string varname, string mode) { | |
if (mode == "doc") { | |
cout << "- $" << varname << "$ は整数である." << endl; | |
} | |
if (mode == "validator") { | |
cout << "long long int " << varname << " = readLong();" << endl; | |
} | |
} | |
void gen_code(string mode) { | |
IS_INTEGER("n"); | |
IS_INTEGER("m"); | |
} | |
int main(int argc, char **argv) { | |
if (argc != 2) { | |
cerr << "ushitapunichiakunw" << endl; | |
return 1; | |
} | |
// doc か validator のどちらか | |
string mode = argv[1]; | |
gen_code(mode); | |
} |
long long int n = readLong(); | |
long long int m = readLong(); |