From 983749787ee0dc1beb1107873e8a13ebdaeba576 Mon Sep 17 00:00:00 2001 From: Derick Huth Date: Mon, 18 Jan 2016 15:43:52 -0700 Subject: restore test suite --- test-chill/testchill/cpp_validate/grammar.txt | 124 +++++++++++++++++++++ test-chill/testchill/cpp_validate/src/validate.cpp | 29 +++++ 2 files changed, 153 insertions(+) create mode 100644 test-chill/testchill/cpp_validate/grammar.txt create mode 100644 test-chill/testchill/cpp_validate/src/validate.cpp (limited to 'test-chill/testchill/cpp_validate') diff --git a/test-chill/testchill/cpp_validate/grammar.txt b/test-chill/testchill/cpp_validate/grammar.txt new file mode 100644 index 0000000..fdb8c00 --- /dev/null +++ b/test-chill/testchill/cpp_validate/grammar.txt @@ -0,0 +1,124 @@ +terminals: + Identifier '[a-zA-Z_][a-zA-Z_0-9]*' + NumericLiteral '[0-9]+(\.[0-9]+)?' + Comment '\#([^\x0a])*' + WS '\s+' +ignore: WS, , Comment +rules: + ::= + :w => w + :p => p + ::= + 'with' '{' :decls '}' :p => addbindings(p, dict(decls)) + ::= + eps => [] + :l => l + ::= + :l ',' :decl => l + [decl] + :decl => [decl] + ::= + Identifier:name ':' :e => (name, (None, e)) + :ctype Identifier:name ':' :e => (name, (ctype, e)) + + ::= + 'procedure' :rtype Identifier:name '(' :plist ')' + => Procedure(name, rtype, plist) + ::= + :bt '*' => CppPointerType(bt) + :bt :dims => CppArrayType(bt, dims) + 'void' => CppVoidType() + 'char' => CppPrimitiveType.get_from_cppname('char') + 'signed' 'char' => CppPrimitiveType.get_from_cppname('signed char') + 'unsigned' 'char' => CppPrimitiveType.get_from_cppname('unsigned char') + 'short' => CppPrimitiveType.get_from_cppname('short') + 'unsigned' 'short' => CppPrimitiveType.get_from_cppname('unsigned short') + 'int' => CppPrimitiveType.get_from_cppname('int') + 'unsigned' 'int' => CppPrimitiveType.get_from_cppname('unsigned int') + 'long' => CppPrimitiveType.get_from_cppname('long') + 'unsigned' 'long' => CppPrimitiveType.get_from_cppname('unsigned long') + 'long' 'long' => CppPrimitiveType.get_from_cppname('long long') + 'unsigned' 'long' 'long' => CppPrimitiveType.get_from_cppname('unsigned long long') + 'float' => CppPrimitiveType.get_from_cppname('float') + 'double' => CppPrimitiveType.get_from_cppname('double') + ::= + :dlist '[' :e ']' => dlist + [e] + :dlist '[' ']' => dlist + [None] + '[' ']' => [None] + '[' :e ']' => [e] + ::= + eps => [] + :l => l + ::= + :l ',' :p => l + [p] + :p => [p] + ::= + :d :t Identifier:name '=' :e => Parameter(name, t, d, e) + :d :t Identifier:name => Parameter(name, t, d, None) + ::= + 'in' => 'in' + 'out' => 'out' + 'in' 'out' => 'inout' + 'out' 'in' => 'inout' + eps => 'inout' + + + ::= + :e => e + 'lambda' :params ':' :e => LambdaExpr(params, e) + 'matrix' '(' :d ',' :e ')' => MatrixGenerator(d, e) + 'matrix' :dims :e => MatrixGenerator([d[1] for d in dims], LambdaExpr([d[0] for d in dims], e)) + ::= + :l '+' :r => BinExpr(l, '+', r) + :l '-' :r => BinExpr(l, '-', r) + :e => e + ::= + :l '*' :r => BinExpr(l, '*', r) + :l '/' :r => BinExpr(l, '/', r) + :e => e + ::= + '-' :e => UnaryExpr('-', e) + :e => e + ::= + :e => e + ::= + :l '**' :r => BinExpr(l, '**', r) + :e => e + ::= + '(' :e ')' => e + '[' :l ']' => l + Identifier:name => NameExpr(name) + NumericLiteral:num => ConstantExpr(num) + 'random' '(' :mn ',' :mx ')' => RandomExpr(mn, mx) + :f '(' :l ')' => InvokeExpr(f, l) + :n '.' Identifier:attr => AttributeExpr(n, attr) + ::= + eps => [] + :l => l + ::= + :l ',' :e => l + [e] + :e => [e] + ::= + '[' :l ']' => l + ::= + :l ',' :e => l + [e] + :e => [e] + ::= + eps => None + '*' => None + :e => e + ::= + eps => [] + :l => l + ::= + :l ',' Identifier:ident => l + [ident] + Identifier:ident => [ident] + ::= + '[' :l ']' => l + ::= + :l ',' :e => l + [e] + :e => [e] + ::= + Identifier:name => (name, None) + Identifier:name ':' :e => (name, e) + + diff --git a/test-chill/testchill/cpp_validate/src/validate.cpp b/test-chill/testchill/cpp_validate/src/validate.cpp new file mode 100644 index 0000000..f09009d --- /dev/null +++ b/test-chill/testchill/cpp_validate/src/validate.cpp @@ -0,0 +1,29 @@ +#include +#include +#include + +//# defines +//# test-proc + +int main(int argc, char** argv) { + //# declarations + timespec start_time; + timespec end_time; + + std::ifstream datafile_initialize(argv[1]); + //# read-in + //# read-out + datafile_initialize.close(); + + clock_gettime(CLOCK_REALTIME, &start_time); + //# run + clock_gettime(CLOCK_REALTIME, &end_time); + + std::ofstream datafile_out(argv[2]); + //# write-out + datafile_out.close(); + + double time_diff = (end_time.tv_sec - start_time.tv_sec) + (end_time.tv_nsec - start_time.tv_nsec)/1000000000.0; + std::printf("(%f,)", time_diff); + return 0; +} -- cgit v1.2.3-70-g09d2