From cd9ade64f097ca6e62b1f2e9797ba0190dc3ff8e Mon Sep 17 00:00:00 2001 From: Robin Voetter Date: Tue, 9 Nov 2021 16:30:38 +0100 Subject: [PATCH] Remove some old tools --- src/compiler/bridge.fut | 18 +++----- src/tools/gen_futhark_dataset.py | 16 -------- src/tools/test_parser.cpp | 70 -------------------------------- src/tools/test_parser_input.py | 33 --------------- 4 files changed, 5 insertions(+), 132 deletions(-) delete mode 100755 src/tools/gen_futhark_dataset.py delete mode 100644 src/tools/test_parser.cpp delete mode 100755 src/tools/test_parser_input.py diff --git a/src/compiler/bridge.fut b/src/compiler/bridge.fut index 3a351ba..2a50095 100644 --- a/src/compiler/bridge.fut +++ b/src/compiler/bridge.fut @@ -78,29 +78,21 @@ let convert_node_type (node_type: front_node_type) = let convert_data_type (data_type: front_data_type) = DATA_TYPE_LOOKUP[i32.u8 data_type] -let convert_node_idx (idx: front_node_idx_type) = - idx - -let convert_child_idx (child_idx: front_child_idx_type) = - child_idx - -let convert_node_data (node_data: front_node_data_type) = - node_data - let backend_convert_node ( node_type: front_node_type, data_type: front_data_type, parent: front_node_idx_type, depth: front_depth_type, child_idx: front_child_idx_type, - data: front_node_data_type) : Node = + data: front_node_data_type + ): Node = { node_type = convert_node_type node_type, resulting_type = convert_data_type data_type, - parent = convert_node_idx parent, + parent = parent, depth = depth, - child_idx = convert_child_idx child_idx, - node_data = convert_node_data data + child_idx = child_idx, + node_data = data } let zip6 [n] 'a 'b 'c 'd 'e 'f diff --git a/src/tools/gen_futhark_dataset.py b/src/tools/gen_futhark_dataset.py deleted file mode 100755 index 55a80d3..0000000 --- a/src/tools/gen_futhark_dataset.py +++ /dev/null @@ -1,16 +0,0 @@ -#!/usr/bin/env python3 -import sys - -def write_binary(word, size=1): - sys.stdout.buffer.write(word.to_bytes(size, byteorder='little')) - -data = sys.stdin.buffer.read() -if data[-1] == '\n': - data = data[:-1] - -write_binary(ord('b')) -write_binary(2) # Version -write_binary(1) # Dimension -sys.stdout.buffer.write(" u8".encode()) # Type -write_binary(len(data), 8) # Size -sys.stdout.buffer.write(data) # Data diff --git a/src/tools/test_parser.cpp b/src/tools/test_parser.cpp deleted file mode 100644 index 4ad6ce6..0000000 --- a/src/tools/test_parser.cpp +++ /dev/null @@ -1,70 +0,0 @@ -#include -#include -#include -#include - -struct Parser { - std::string input; - size_t offset; - - int current() const { - return this->offset >= this->input.size() ? -1 : this->input[this->offset]; - } - - void advance() { - ++this->offset; - } - - bool eat(char c) { - if (this->current() == c) { - this->advance(); - return true; - } - - return false; - } -}; - -bool expr(Parser& p); - -bool atom(Parser& p) { - return p.eat('a') || (p.eat('[') && expr(p) && p.eat(']')); -} - -bool sum(Parser& p) { - if (p.eat('+')) - return atom(p) && sum(p); - - return true; -} - -bool expr(Parser& p) { - return atom(p) && sum(p); -} - -bool program(Parser& p) { - return p.eat('(') && expr(p) && p.eat(')'); -} - -bool futhark_program(Parser& p) { - if (!p.eat('b')) - return false; - p.offset += 1 + 1 + 4 + 8; - return program(p); -} - -int main() { - auto p = Parser{ - .input = std::string( - std::istreambuf_iterator(std::cin), - std::istreambuf_iterator() - ), - .offset = 0 - }; - - auto start = std::chrono::high_resolution_clock::now(); - bool matches = futhark_program(p); - auto end = std::chrono::high_resolution_clock::now(); - - std::cout << (matches ? "true" : "false") << " (matched in " << std::chrono::duration_cast(end - start).count() << "us)" << std::endl; -} diff --git a/src/tools/test_parser_input.py b/src/tools/test_parser_input.py deleted file mode 100755 index 156348f..0000000 --- a/src/tools/test_parser_input.py +++ /dev/null @@ -1,33 +0,0 @@ -#!/usr/bin/env python3 -import random -import sys - -def write_binary(word, size=1): - sys.stdout.buffer.write(word.to_bytes(size, byteorder='little')) - -data = bytearray() - -def gen(depth): - action = random.randint(0, 5) - - if depth >= 20 or (depth >= 10 and action == 0): # a - data.append(ord('a')) - elif action <= 3: # plus - gen(depth + 1) - data.append(ord('+')) - gen(depth + 1) - else: # parens - data.append(ord('[')) - gen(depth + 1) - data.append(ord(']')) - -gen(0) - -print(f'Input size: {len(data)} elements', file=sys.stderr) - -write_binary(ord('b')) -write_binary(2) # Version -write_binary(1) # Dimension -sys.stdout.buffer.write(" u8".encode()) # Type -write_binary(len(data), 8) # Size -sys.stdout.buffer.write(data) # Data