Skip to content
GitLab
Projects
Groups
Snippets
Help
Loading...
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
F
fix
Project overview
Project overview
Details
Activity
Releases
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Issues
0
Issues
0
List
Boards
Labels
Service Desk
Milestones
Merge Requests
0
Merge Requests
0
Operations
Operations
Incidents
Analytics
Analytics
Repository
Value Stream
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Create a new issue
Commits
Issue Boards
Open sidebar
POTTIER Francois
fix
Commits
fd089217
Commit
fd089217
authored
Dec 10, 2018
by
POTTIER Francois
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Integrate Gabriel Radanne's stress test. Fix [make test] in the demos.
parent
cf88cfd2
Changes
13
Hide whitespace changes
Inline
Side-by-side
Showing
13 changed files
with
147 additions
and
11 deletions
+147
-11
demos/brz/Makefile
demos/brz/Makefile
+8
-1
demos/brz/TestGen.ml
demos/brz/TestGen.ml
+98
-0
demos/brz/dune
demos/brz/dune
+17
-2
demos/cfg/Makefile
demos/cfg/Makefile
+4
-0
demos/cyk/Makefile
demos/cyk/Makefile
+3
-1
demos/cyk/dune
demos/cyk/dune
+1
-1
demos/fib/Makefile
demos/fib/Makefile
+3
-1
demos/fib/dune
demos/fib/dune
+1
-1
demos/hco/Makefile
demos/hco/Makefile
+3
-1
demos/hco/dune
demos/hco/dune
+1
-1
demos/tst/Makefile
demos/tst/Makefile
+3
-1
demos/tst/dune
demos/tst/dune
+1
-1
misc/post.md
misc/post.md
+4
-0
No files found.
demos/brz/Makefile
View file @
fd089217
SHELL
:=
bash
BUILD
:=
../../_build/default/demos/brz
.PHONY
:
all
all
:
...
...
@@ -6,7 +7,7 @@ all:
.PHONY
:
test
test
:
all
_build/default
/Main.exe
$(BUILD)
/Main.exe
@
if
command
-v
dot
>
/dev/null
;
then
\
for
f
in
*
.dot
;
do
\
dot
-Tpng
$$
f
-O
;
\
...
...
@@ -15,6 +16,12 @@ test: all
echo
"The program dot is required to visualize DFAs. Please install graphviz."
;
\
fi
# This stress test, contributed by Gabriel Radanne, takes about 5 minutes.
.PHONY
:
testgen
testgen
:
dune build TestGen.exe
$(BUILD)
/TestGen.exe
.PHONY
:
clean
clean
:
rm
-f
*
~
*
.dot.png
...
...
demos/brz/TestGen.ml
0 → 100644
View file @
fd089217
(* This testing infrastructure has been contributed by Gabriel Radanne.
It is based on regenerate: https://github.com/regex-generate/regenerate *)
let
bos
=
'
^
'
let
eos
=
'
$
'
let
alphabet
=
[
'
a'
;
'
b'
;
'
c'
]
module
Char
=
struct
include
Char
let
hash
=
Hashtbl
.
hash
let
foreach
f
=
List
.
iter
f
(
bos
::
eos
::
alphabet
)
let
print
c
=
Printf
.
sprintf
"%c"
c
let
pp
=
Format
.
pp_print_char
end
module
B
=
Brzozowski
.
Make
(
Char
)
open
B
let
compl
l
=
List
.
fold_left
(
fun
l
x
->
CCList
.
remove
~
eq
:
Char
.
equal
~
x
l
)
alphabet
l
let
set
b
l
=
disjunction
(
List
.
map
char
(
if
b
then
l
else
compl
l
))
(* Turn a regular expression from Regenerate into a [B] expression. *)
let
rec
to_re
=
let
open
Regenerate
.
Regex
in
function
|
One
->
B
.
epsilon
|
Set
(
b
,
l
)
->
set
b
l
|
Seq
(
re
,
re'
)
->
to_re
re
@@
to_re
re'
|
Or
(
re
,
re'
)
->
to_re
re
|||
to_re
re'
|
And
(
re
,
re'
)
->
to_re
re
&&&
to_re
re'
|
Not
re
->
B
.
neg
(
to_re
re
)
|
Rep
(
0
,
None
,
re
)
->
B
.
star
(
to_re
re
)
|
Rep
(
_
,_,_
re
)
->
assert
false
let
is_match
re
input
=
match
B
.
exec
re
input
with
None
->
false
|
Some
_
->
true
(* Check positive and negative samples. *)
let
check
(
re
,
pos
,
neg
)
=
(* 1. Compile the regular expression. *)
let
cre
=
try
B
.
dfa
(
to_re
re
)
with
_
->
(* Discard regular expressions that we do not handle. *)
QCheck
.
assume_fail
()
in
(* 2. Test! *)
List
.
for_all
(
fun
s
->
is_match
cre
s
)
pos
&&
List
.
for_all
(
fun
s
->
not
(
is_match
cre
s
))
neg
module
WordSeq
(
C
:
sig
include
Set
.
OrderedType
val
pp
:
t
Fmt
.
t
end
)
=
struct
type
char
=
C
.
t
type
t
=
C
.
t
Seq
.
t
let
empty
=
Seq
.
empty
let
singleton
=
OSeq
.
return
let
length
=
OSeq
.
length
let
append
=
OSeq
.
append
let
cons
=
OSeq
.
cons
let
pp
fmt
w
=
Seq
.
iter
(
C
.
pp
fmt
)
w
let
compare
=
OSeq
.
compare
~
cmp
:
C
.
compare
end
(* Ensure that the whole word is matched *)
let
add_boundaries
=
let
bounds
s
=
let
(
@
)
=
OSeq
.
append
in
OSeq
.(
return
bos
@
s
@
return
eos
)
in
let
whole_string
re
=
Regenerate
.
Regex
.(
seq
[
char
bos
;
re
;
char
eos
])
in
QCheck
.
map_same_type
(
fun
(
re
,
pos
,
neg
)
->
whole_string
re
,
List
.
map
bounds
pos
,
List
.
map
bounds
neg
)
let
test
=
let
module
Word
=
WordSeq
(
Char
)
in
let
module
Stream
=
Segments
.
ThunkList
(
Word
)
in
let
generator
=
Regenerate
.
arbitrary
(
module
Word
)
(* Datastructure for words *)
(
module
Stream
)
(* Datastructure for streams of words *)
~
compl
:
false
(* Should we generate complement operations? *)
~
pp
:
Fmt
.
char
(* Printer for characters *)
~
samples
:
100
(* Average number of samples for each regular expression *)
alphabet
(* Alphabet *)
in
let
generator
=
add_boundaries
generator
in
QCheck
.
Test
.
make
generator
check
let
()
=
QCheck_runner
.
run_tests_main
[
test
]
demos/brz/dune
View file @
fd089217
(executable
(library
(name Brzozowski)
(modules Brzozowski ListAux)
(libraries fix seq)
(flags "-w" "A-4-44")
)
(test
(name Main)
(libraries fix)
(modules Main)
(libraries Brzozowski)
(flags "-w" "A-4-44")
)
(test
(name TestGen)
(modules TestGen)
(libraries Brzozowski regenerate)
(flags "-w" "A-4-44")
)
demos/cfg/Makefile
View file @
fd089217
...
...
@@ -6,3 +6,7 @@ all:
clean
:
rm
-f
*
~
dune clean
.PHONY
:
test
test
:
@
echo
"No test here."
demos/cyk/Makefile
View file @
fd089217
BUILD
:=
../../_build/default/demos/cyk
.PHONY
:
all
all
:
dune build Bench.exe
.PHONY
:
test
test
:
all
_build/default
/Bench.exe
$(BUILD)
/Bench.exe
.PHONY
:
clean
clean
:
...
...
demos/cyk/dune
View file @
fd089217
(
executable
(
test
(name Bench)
(libraries fix)
(flags "-w" "A")
...
...
demos/fib/Makefile
View file @
fd089217
BUILD
:=
../../_build/default/demos/fib
.PHONY
:
all
all
:
dune build Fib.exe
.PHONY
:
test
test
:
all
_build/default
/Fib.exe
$(BUILD)
/Fib.exe
.PHONY
:
clean
clean
:
...
...
demos/fib/dune
View file @
fd089217
(
executable
(
test
(name Fib)
(libraries unix fix)
(flags "-w" "A")
...
...
demos/hco/Makefile
View file @
fd089217
BUILD
:=
../../_build/default/demos/hco
.PHONY
:
all
all
:
dune build HashConsDemo.exe
.PHONY
:
test
test
:
all
_build/default
/HashConsDemo.exe
$(BUILD)
/HashConsDemo.exe
.PHONY
:
clean
clean
:
...
...
demos/hco/dune
View file @
fd089217
(
executable
(
test
(name HashConsDemo)
(libraries fix)
(flags "-w" "A")
...
...
demos/tst/Makefile
View file @
fd089217
BUILD
:=
../../_build/default/demos/tst
.PHONY
:
all
all
:
dune build Test.exe
.PHONY
:
test
test
:
all
_build/default
/Test.exe
$(BUILD)
/Test.exe
.PHONY
:
clean
clean
:
...
...
demos/tst/dune
View file @
fd089217
(
executable
(
test
(name Test)
(libraries fix)
(flags "-w" "A")
...
...
misc/post.md
View file @
fd089217
...
...
@@ -524,3 +524,7 @@ automata by Brzozowski's method is a good illustration of their application.
For more details,
please look at the
[
full source code for this demo
](
https://gitlab.inria.fr/fpottier/fix/blob/master/demos/brz/
)
.
As a bonus, Gabriel Radanne contributed a
[
stress test
](
https://gitlab.inria.fr/fpottier/fix/blob/master/demos/brz/TestGen.ml
)
based on
[
regenerate
](
https://github.com/regex-generate/regenerate
)
.
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
.
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment