Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Bringing AlphaRegexPublic up-to-date with dune #5

Closed
wants to merge 3 commits into from
Closed
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 3 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
_build
dune-project
*~
4 changes: 4 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
@@ -20,6 +20,10 @@ After you clone this project, follow the steps below.
- Activate the build script: ```chmod +x build```.
- Complie the whole files using the script: ```./build```.

## How to build with dune:
Simply run ```dune build main.exe```.


## How to use
To use AlphaRegex, you need to provide:
- Positive examples
7 changes: 7 additions & 0 deletions dune
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
(executable
(name main)
(libraries base batteries))

(env
(dev
(flags (:standard -warn-error -A))))
9 changes: 5 additions & 4 deletions main.ml
Original file line number Diff line number Diff line change
@@ -12,11 +12,11 @@ let onestep_xto01 : string -> string list
then [str]
else
let idx = String.index str 'X' in
let str1 = str in
let str2 = Bytes.copy str in
let str1 = Bytes.of_string str in
let str2 = Bytes.copy (Bytes.of_string str) in
let _ = Bytes.set str1 idx '0' in
let _ = Bytes.set str2 idx '1' in
[str1]@[str2]
[Bytes.to_string str1]@[Bytes.to_string str2]

(* onestep for all strings *)
let onestep_strlst : string list -> string list
@@ -83,7 +83,8 @@ let main () =
(match pgm with
| None -> print_endline "Fail to synthesize"
| Some pgm ->
let _ = pp pgm in
let _ = pp pgm in
print_endline ("Size = " ^ string_of_int( cost(pgm)) );
print_endline ("Level: " ^ string_of_int (level pgm));
sanity_check pgm pos_examples neg_examples;
print_endline "============ REPORT =============";
14 changes: 14 additions & 0 deletions runall
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
#!/bin/bash

EXEC=_build/default/main.exe
DIR=benchmarks

for e in ${DIR}/*
do
echo ----------- ${e} -----------
${EXEC} -input ${e}
done