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
4b71c93d
Commit
4b71c93d
authored
2 years ago
by
Putegnat Theo
Browse files
Options
Downloads
Patches
Plain Diff
Modifications lexeur suite au mail de conseil
parent
1ba848df
No related branches found
No related tags found
No related merge requests found
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
src/e_regexp.ml
+3
-3
3 additions, 3 deletions
src/e_regexp.ml
src/lexer_generator.ml
+10
-1
10 additions, 1 deletion
src/lexer_generator.ml
with
13 additions
and
4 deletions
src/e_regexp.ml
+
3
−
3
View file @
4b71c93d
...
...
@@ -69,7 +69,7 @@ let list_regexp : (regexp * (string -> token option)) list =
(
keyword_regexp
"while"
,
fun
_
->
Some
(
SYM_WHILE
));
(
keyword_regexp
"int"
,
fun
_
->
Some
(
SYM_INT
));
(* begin TODO *)
(
Eps
,
fun
_
->
Some
(
SYM_VOID
));
(
keyword_regexp
"void"
,
fun
_
->
Some
(
SYM_VOID
));
(
keyword_regexp
"char"
,
fun
_
->
Some
(
SYM_CHAR
));
(
keyword_regexp
"if"
,
fun
_
->
Some
(
SYM_IF
));
(
keyword_regexp
"else"
,
fun
_
->
Some
(
SYM_ELSE
));
...
...
@@ -88,7 +88,7 @@ let list_regexp : (regexp * (string -> token option)) list =
(
keyword_regexp
"]"
,
fun
_
->
Some
(
SYM_RBRACKET
));
(
keyword_regexp
"("
,
fun
_
->
Some
(
SYM_LPARENTHESIS
));
(
keyword_regexp
")"
,
fun
_
->
Some
(
SYM_RPARENTHESIS
));
(
keyword_regexp
"
|
"
,
fun
_
->
Some
(
SYM_SEMICOLON
));
(
keyword_regexp
"
;
"
,
fun
_
->
Some
(
SYM_SEMICOLON
));
(
keyword_regexp
","
,
fun
_
->
Some
(
SYM_COMMA
));
(
keyword_regexp
"="
,
fun
_
->
Some
(
SYM_ASSIGN
));
(
keyword_regexp
"=="
,
fun
_
->
Some
(
SYM_EQUALITY
));
...
...
@@ -97,7 +97,7 @@ let list_regexp : (regexp * (string -> token option)) list =
(
keyword_regexp
">"
,
fun
_
->
Some
(
SYM_GT
));
(
keyword_regexp
"<="
,
fun
_
->
Some
(
SYM_LEQ
));
(
keyword_regexp
">="
,
fun
_
->
Some
(
SYM_GEQ
));
(
identifier_material
,
fun
s
->
Some
(
SYM_IDENTIFIER
s
));
(
Cat
(
digit_regexp
,
plus
(
identifier_material
))
,
fun
s
->
Some
(
SYM_IDENTIFIER
s
));
(* end TODO *)
(
Cat
(
keyword_regexp
"//"
,
Cat
(
Star
(
char_range
(
List
.
filter
(
fun
c
->
c
<>
'\n'
)
alphabet
))
,
...
...
This diff is collapsed.
Click to expand it.
src/lexer_generator.ml
+
10
−
1
View file @
4b71c93d
...
...
@@ -382,7 +382,16 @@ let tokenize_one (d : dfa) (w: char list) : lexer_result * char list =
(
current_token
:
char
list
)
(
last_accepted
:
lexer_result
*
char
list
)
:
lexer_result
*
char
list
=
(* TODO *)
last_accepted
match
w
with
|
[]
->
LRtoken
SYM_EOF
,
[]
|
c
::
r
->
match
d
.
dfa_step
q
c
with
|
None
->
last_accepted
|
Some
qnext
->
match
List
.
assoc_opt
qnext
d
.
dfa_final
with
|
None
->
recognize
qnext
r
(
current_token
@
[
c
])
last_accepted
|
Some
t
->
recognize
qnext
r
(
current_token
@
[
c
])
(
LRtoken
(
Option
.
get
(
t
(
string_of_char_list
(
current_token
@
[
c
]))))
,
r
)
in
recognize
d
.
dfa_initial
w
[]
(
LRerror
,
w
)
...
...
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