diff --git a/.gitignore b/.gitignore index 740a6eb..f8e80f2 100644 --- a/.gitignore +++ b/.gitignore @@ -1,6 +1,8 @@ # Created by https://www.toptal.com/developers/gitignore/api/haskell # Edit at https://www.toptal.com/developers/gitignore?templates=haskell +parsed_rtlil/ + ### Haskell ### dist dist-* diff --git a/.gitmodules b/.gitmodules new file mode 100644 index 0000000..dce9fd3 --- /dev/null +++ b/.gitmodules @@ -0,0 +1,3 @@ +[submodule "rtlil-corpus"] + path = rtlil-corpus + url = git@github.com:JoyOfHardware/rtlil-corpus.git diff --git a/README.md b/README.md index 1ec2597..29c4733 100644 --- a/README.md +++ b/README.md @@ -45,6 +45,7 @@ The following will allow you to see a pretty printed AST for the given input `il` file. ```bash +git clone --recursive git@github.com:JoyOfHardware/Haskellator.git $ nix-shell $ rtlil-parse ``` diff --git a/rtlil-corpus b/rtlil-corpus new file mode 160000 index 0000000..d60615b --- /dev/null +++ b/rtlil-corpus @@ -0,0 +1 @@ +Subproject commit d60615be78cd1fc7173bff956d2b1a53f8235bb0 diff --git a/test.py b/test.py new file mode 100644 index 0000000..d7f89a4 --- /dev/null +++ b/test.py @@ -0,0 +1,25 @@ +import os +import subprocess + +# Define the directories +corpus_dir = './rtlil-corpus/corpus/' +parsed_dir = './parsed_rtlil' + +# Create the parsed_rtlil directory if it doesn't exist +os.makedirs(parsed_dir, exist_ok=True) + +# Iterate over all .rtlil files in the corpus directory +for file_name in os.listdir(corpus_dir): + if file_name.endswith('.il'): + input_path = os.path.join(corpus_dir, file_name) + output_file = os.path.splitext(file_name)[0] + '.hs' + output_path = os.path.join(parsed_dir, output_file) + + # Construct and run the command + command = f"cabal run rtlil-parse -- {input_path} {output_path}" + try: + subprocess.run(command, shell=True, check=True) + print(f"Processed: {input_path} -> {output_path}") + except subprocess.CalledProcessError as e: + print(f"Error processing {input_path}: {e}") + break