Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
F
frama-c
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Wiki
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Deploy
Releases
Container Registry
Model registry
Monitor
Incidents
Analyze
Value stream analytics
Contributor 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
pub
frama-c
Commits
989018d8
Commit
989018d8
authored
4 years ago
by
Virgile Prevosto
Committed by
David Bühler
4 years ago
Browse files
Options
Downloads
Patches
Plain Diff
[lexer] Accept UCN characters as well as corresponding UTF-8 encoding
parent
92419510
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/kernel_internals/parsing/logic_lexer.mll
+36
-12
36 additions, 12 deletions
src/kernel_internals/parsing/logic_lexer.mll
src/libraries/utils/utf8_logic.mli
+3
-0
3 additions, 0 deletions
src/libraries/utils/utf8_logic.mli
with
39 additions
and
12 deletions
src/kernel_internals/parsing/logic_lexer.mll
+
36
−
12
View file @
989018d8
...
@@ -71,6 +71,37 @@
...
@@ -71,6 +71,37 @@
fun
s
->
try
Hashtbl
.
find
h
s
fun
s
->
try
Hashtbl
.
find
h
s
with
Not_found
->
IDENTIFIER
s
with
Not_found
->
IDENTIFIER
s
let
all_digits
s
=
let
is_digit
=
function
|
'
0
'
..
'
9
'
|
'
a'
..
'
f'
|
'
A'
..
'
F'
->
()
|
_
->
raise
Exit
in
try
String
.
iter
is_digit
s
;
true
with
Exit
->
false
let
is_ucn
s
=
if
String
.
length
s
<=
2
||
s
.
[
0
]
<>
'\\'
then
false
else
begin
match
s
.
[
1
]
with
|
'
U'
->
String
.
length
s
=
10
&&
all_digits
(
String
.
sub
s
2
8
)
|
'
u'
->
String
.
length
s
=
6
&&
all_digits
(
String
.
sub
s
2
4
)
|
_
->
false
end
let
int_of_digit
chr
=
match
chr
with
|
'
0
'
..
'
9
'
->
(
Char
.
code
chr
)
-
(
Char
.
code
'
0
'
)
|
'
a'
..
'
f'
->
(
Char
.
code
chr
)
-
(
Char
.
code
'
a'
)
+
10
|
'
A'
..
'
F'
->
(
Char
.
code
chr
)
-
(
Char
.
code
'
A'
)
+
10
|
_
->
assert
false
(* assumes is_ucn s *)
let
unicode_char
s
=
let
code
=
ref
0
in
let
add_digit
c
=
code
:=
16
*
!
code
+
int_of_digit
c
in
String
.
iter
add_digit
(
String
.
sub
s
2
(
String
.
length
s
-
2
));
let
c
=
Utf8_logic
.
from_unichar
!
code
in
find_utf8
c
let
identifier
,
is_acsl_keyword
=
let
identifier
,
is_acsl_keyword
=
let
all_kw
=
Hashtbl
.
create
37
in
let
all_kw
=
Hashtbl
.
create
37
in
let
c_kw
=
Hashtbl
.
create
37
in
let
c_kw
=
Hashtbl
.
create
37
in
...
@@ -242,18 +273,11 @@
...
@@ -242,18 +273,11 @@
];
];
fun
lexbuf
->
fun
lexbuf
->
let
s
=
lexeme
lexbuf
in
let
s
=
lexeme
lexbuf
in
try
Hashtbl
.
find
h
s
with
Not_found
->
if
is_ucn
s
then
unicode_char
s
else
begin
if
Logic_env
.
typename_status
s
then
TYPENAME
s
try
Hashtbl
.
find
h
s
with
Not_found
->
else
if
Logic_env
.
typename_status
s
then
TYPENAME
s
IDENTIFIER
s
else
IDENTIFIER
s
end
let
int_of_digit
chr
=
match
chr
with
'
0
'
..
'
9
'
->
(
Char
.
code
chr
)
-
(
Char
.
code
'
0
'
)
|
'
a'
..
'
f'
->
(
Char
.
code
chr
)
-
(
Char
.
code
'
a'
)
+
10
|
'
A'
..
'
F'
->
(
Char
.
code
chr
)
-
(
Char
.
code
'
A'
)
+
10
|
_
->
assert
false
(* Update lexer buffer. *)
(* Update lexer buffer. *)
let
update_line_loc
lexbuf
line
=
let
update_line_loc
lexbuf
line
=
...
...
This diff is collapsed.
Click to expand it.
src/libraries/utils/utf8_logic.mli
+
3
−
0
View file @
989018d8
...
@@ -24,6 +24,9 @@
...
@@ -24,6 +24,9 @@
(** UTF-8 string for logic symbols. *)
(** UTF-8 string for logic symbols. *)
(** given an unicode code point, returns the corresponding utf-8 encoding. *)
val
from_unichar
:
int
->
string
val
forall
:
string
val
forall
:
string
val
exists
:
string
val
exists
:
string
val
eq
:
string
val
eq
:
string
...
...
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