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
d2ea8627
Commit
d2ea8627
authored
Nov 27, 2018
by
POTTIER Francois
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Updated tests.
parent
627b3ec7
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
19 additions
and
17 deletions
+19
-17
demos/brz/Main.ml
demos/brz/Main.ml
+19
-17
No files found.
demos/brz/Main.ml
View file @
d2ea8627
...
...
@@ -4,14 +4,14 @@ let map = List.map
(* -------------------------------------------------------------------------- *)
(* Instantiate Brzozowski with an alphabet restricted to 'a'-'
z', ' ',
'$'. *)
(* Instantiate Brzozowski with an alphabet restricted to 'a'-'
e' and
'$'. *)
module
B
=
Brzozowski
.
Make
(
struct
include
Char
let
hash
=
Hashtbl
.
hash
let
foreach
f
=
for
i
=
Char
.
code
'
a'
to
Char
.
code
'
z
'
do
f
(
Char
.
chr
i
)
done
;
List
.
iter
f
[
'
'
;
'
$
'
]
for
i
=
Char
.
code
'
a'
to
Char
.
code
'
e
'
do
f
(
Char
.
chr
i
)
done
;
List
.
iter
f
[
'
$
'
]
let
print
c
=
Printf
.
sprintf
"%c"
c
end
)
...
...
@@ -133,31 +133,33 @@ let _ =
rejected
=
[
"ca$"
;
"ac$"
;
"abcb$"
;
];
}
(* A
keyword recognizer
. *)
(* A
n automaton that tests whether a word belongs in a dictionary
. *)
let
keywords
=
[
"
if"
;
"then"
;
"else"
;
"begin"
;
"end"
;
"do"
;
"done
"
;
]
[
"
cab"
;
"bed"
;
"ace"
;
"add"
;
"dead"
;
"dad
"
;
]
let
k
=
one
@@
(
keywords
|>
map
word
|>
disjunction
)
let
dict
=
keywords
|>
map
word
|>
disjunction
let
_
=
register
{
basename
=
"
k
"
;
regexp
=
k
;
accepted
=
[
"
if"
;
"we are not done eating"
;
"until the end of time
"
;
];
rejected
=
[
"
never shall he come back
"
;
];
basename
=
"
dict
"
;
regexp
=
dict
;
accepted
=
[
"
cab"
;
"added"
;
"dead
"
;
];
rejected
=
[
"
deed
"
;
];
}
let
kd
=
k
@@
eof
(* An automaton that searches for a word that belongs in a dictionary. *)
let
k
=
one
@@
(
keywords
|>
map
word
|>
disjunction
)
let
_
=
register
{
basename
=
"k
d
"
;
regexp
=
k
d
;
accepted
=
[
"
if$
"
;
];
rejected
=
[
"
iff"
;
"if"
;
"toto
"
;
];
basename
=
"k"
;
regexp
=
k
;
accepted
=
[
"
abed"
;
"bace
"
;
];
rejected
=
[
"
beca
"
;
];
}
(* Main. *)
...
...
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