Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
I
infosec-ecomp
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Wiki
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Snippets
Build
Pipelines
Jobs
Pipeline schedules
Artifacts
Deploy
Releases
Package Registry
Container Registry
Model registry
Operate
Environments
Terraform modules
Monitor
Incidents
Analyze
Value stream analytics
Contributor analytics
CI/CD analytics
Repository analytics
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
Community forum
Contribute to GitLab
Provide feedback
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
Putegnat Theo
infosec-ecomp
Commits
d04eb5e6
Commit
d04eb5e6
authored
5 years ago
by
alexandre dang
Browse files
Options
Downloads
Patches
Plain Diff
Ajout d'un appendice dans le sujet pour installer merlin avec VSCode
parent
8bd48bd5
No related branches found
No related tags found
No related merge requests found
Changes
5
Hide whitespace changes
Inline
Side-by-side
Showing
5 changed files
.gitignore
+1
-0
1 addition, 0 deletions
.gitignore
Sujet.pdf
+0
-0
0 additions, 0 deletions
Sujet.pdf
src/Makefile
+4
-0
4 additions, 0 deletions
src/Makefile
src/e_regexp.ml
+1
-1
1 addition, 1 deletion
src/e_regexp.ml
src/lexer_generator.ml
+42
-22
42 additions, 22 deletions
src/lexer_generator.ml
with
48 additions
and
23 deletions
.gitignore
+
1
−
0
View file @
d04eb5e6
...
...
@@ -19,6 +19,7 @@ src/_build
alpaga/_build
grammar.html
src/generated_parser.ml
src/config.ml
**/*.native
alpaga/ml_parser_generator
alpaga/alpaga
...
...
This diff is collapsed.
Click to expand it.
Sujet.pdf
+
0
−
0
View file @
d04eb5e6
No preview for this file type
This diff is collapsed.
Click to expand it.
src/Makefile
+
4
−
0
View file @
d04eb5e6
...
...
@@ -13,6 +13,10 @@ all: $(TG)
$(TG)
:
$(SRC)
ocamlbuild
-cflags
-warn-error
,
"+a-26"
-use-ocamlfind
$(
TG
)
test_lexer
:
$(SRC)
ocamlbuild
-use-ocamlfind
test_lexer.native
./test_lexer.native
clean
:
rm
-rf
_build
rm
-f
config.ml main.native
This diff is collapsed.
Click to expand it.
src/e_regexp.ml
+
1
−
1
View file @
d04eb5e6
...
...
@@ -46,7 +46,7 @@ let rec string_of_regexp r =
|
Charset
c
->
Printf
.
sprintf
"[%s]"
(
string_of_char_list
(
Set
.
to_list
c
))
|
Alt
(
r1
,
r2
)
->
Printf
.
sprintf
"(%s)|(%s)"
(
string_of_regexp
r1
)
(
string_of_regexp
r2
)
|
Cat
(
r1
,
r2
)
->
Printf
.
sprintf
"(%s)(%s)"
|
Cat
(
r1
,
r2
)
->
Printf
.
sprintf
"(%s)
.
(%s)"
(
string_of_regexp
r1
)
(
string_of_regexp
r2
)
|
Star
r
->
Printf
.
sprintf
"(%s)*"
(
string_of_regexp
r
)
...
...
This diff is collapsed.
Click to expand it.
src/lexer_generator.ml
+
42
−
22
View file @
d04eb5e6
...
...
@@ -332,6 +332,30 @@ let rec tokenize_all (d: dfa) (w: char list) : (token list * char list) =
(* Fonctions d'affichage - Utile pour déboguer *)
let
char_list_to_char_ranges
s
=
let
rec
recognize_range
(
cl
:
int
list
)
l
opt_c
n
=
match
cl
with
|
[]
->
(
match
opt_c
with
None
->
l
|
Some
c
->
l
@
[(
c
,
n
)]
)
|
c
::
r
->
(
match
opt_c
with
|
None
->
recognize_range
r
l
(
Some
c
)
0
|
Some
c'
->
if
c'
+
n
+
1
=
c
then
recognize_range
r
l
(
Some
c'
)
(
n
+
1
)
else
recognize_range
r
((
c'
,
n
)
::
l
)
(
Some
c
)
0
)
in
let
l
=
recognize_range
(
List
.
sort
Stdlib
.
compare
(
List
.
map
Char
.
code
s
))
[]
None
0
in
List
.
fold_left
(
fun
acc
(
c
,
n
)
->
if
n
=
0
then
Printf
.
sprintf
"%c%s"
(
Char
.
chr
c
)
acc
else
Printf
.
sprintf
"%c-%c%s"
(
Char
.
chr
c
)
(
Char
.
chr
(
c
+
n
))
acc
)
""
l
(* Affichage d'un NFA *)
let
nfa_to_string
(
n
:
nfa
)
:
string
=
Printf
.
sprintf
"===== NFA
\n
States : %s
\n
Initial states : %s
\n
Final states : %s
\n
%s"
...
...
@@ -348,6 +372,24 @@ let nfa_to_string (n : nfa) : string =
)
l
)
)
n
.
nfa_states
))
let
nfa_to_dot
oc
(
n
:
nfa
)
:
unit
=
Printf
.
fprintf
oc
"digraph {
\n
"
;
List
.
iter
(
fun
n
->
Printf
.
fprintf
oc
"N%d [shape=
\"
house
\"
color=
\"
red
\"
]
\n
"
n
)
(
n
.
nfa_initial
);
List
.
iter
(
fun
(
q
,
t
)
->
Printf
.
fprintf
oc
"N%d [shape=
\"
rectangle
\"
, label=
\"
%s
\"
]
\n
"
q
(
match
t
"0"
with
|
Some
s
->
string_of_symbol
s
|
None
->
""
))
n
.
nfa_final
;
List
.
iter
(
fun
q
->
List
.
iter
(
fun
(
cso
,
q'
)
->
match
cso
with
|
None
->
Printf
.
fprintf
oc
"N%d -> N%d [label=
\"
[epsilon]
\"
]
\n
"
q
q'
|
Some
cs
->
Printf
.
fprintf
oc
"N%d -> N%d [label=
\"
[%s]
\"
]
\n
"
q
q'
(
char_list_to_char_ranges
(
Set
.
to_list
cs
))
)
(
n
.
nfa_step
q
);
)
n
.
nfa_states
;
Printf
.
fprintf
oc
"}
\n
"
(* Affichage d'un DFA *)
let
dfa_to_string
(
n
:
dfa
)
(
alphabet
:
char
list
)
:
string
=
Printf
.
sprintf
"===== DFA
\n
States : %s
\n
Initial state : %s
\n
Final states : [%s]
\n
%s"
...
...
@@ -373,28 +415,6 @@ let dfa_to_string (n : dfa) (alphabet: char list): string =
bien en copiant le code DOT dans un convertisseur en ligne (par exemple :
http://proto.informatics.jax.org/prototypes/dot2svg/). *)
let
char_list_to_char_ranges
s
=
let
rec
recognize_range
(
cl
:
int
list
)
l
opt_c
n
=
match
cl
with
|
[]
->
(
match
opt_c
with
None
->
l
|
Some
c
->
l
@
[(
c
,
n
)]
)
|
c
::
r
->
(
match
opt_c
with
|
None
->
recognize_range
r
l
(
Some
c
)
0
|
Some
c'
->
if
c'
+
n
+
1
=
c
then
recognize_range
r
l
(
Some
c'
)
(
n
+
1
)
else
recognize_range
r
((
c'
,
n
)
::
l
)
(
Some
c
)
0
)
in
let
l
=
recognize_range
(
List
.
sort
Stdlib
.
compare
(
List
.
map
Char
.
code
s
))
[]
None
0
in
List
.
fold_left
(
fun
acc
(
c
,
n
)
->
if
n
=
0
then
Printf
.
sprintf
"%c%s"
(
Char
.
chr
c
)
acc
else
Printf
.
sprintf
"%c-%c%s"
(
Char
.
chr
c
)
(
Char
.
chr
(
c
+
n
))
acc
)
""
l
let
dfa_to_dot
oc
(
n
:
dfa
)
(
cl
:
char
list
)
:
unit
=
Printf
.
fprintf
oc
"digraph {
\n
"
;
Printf
.
fprintf
oc
"N%s [shape=
\"
house
\"
color=
\"
red
\"
]
\n
"
(
string_of_int_set
n
.
dfa_initial
);
...
...
This diff is collapsed.
Click to expand it.
Preview
0%
Loading
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Save comment
Cancel
Please
register
or
sign in
to comment