Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Contribute to GitLab
Sign in
Toggle navigation
C
cpdt
Project
Project
Details
Activity
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
research
cpdt
Commits
9864c6c0
Commit
9864c6c0
authored
Dec 09, 2010
by
Adam Chlipala
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
First cut at spellcheck filter
parent
d2f328ef
Changes
1
Show whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
79 additions
and
0 deletions
+79
-0
prepare_spellcheck.ml
tools/prepare_spellcheck.ml
+79
-0
No files found.
tools/prepare_spellcheck.ml
0 → 100644
View file @
9864c6c0
let
read_line
()
=
try
Some
(
read_line
()
)
with
End_of_file
->
None
let
strstr'
p
s
n
=
try
Some
(
Str
.
search_forward
(
Str
.
regexp_string
p
)
s
n
)
with
Not_found
->
None
let
strstr
p
s
=
strstr'
p
s
0
let
prefix
s1
s2
=
String
.
length
s2
>=
String
.
length
s1
&&
Str
.
string_before
s2
(
String
.
length
s1
)
=
s1
let
sanitize
s
=
let
rec
san
n
acc
=
try
let
pos
=
Str
.
search_forward
(
Str
.
regexp
"
\\
[
\\
|%
\\
|#"
)
s
n
in
let
ender
=
match
s
.
[
pos
]
with
|
'
[
'
->
'
]
'
|
_
->
s
.
[
pos
]
in
let
pos'
=
String
.
index_from
s
(
pos
+
1
)
ender
in
san
(
pos'
+
1
)
(
acc
^
String
.
sub
s
n
(
pos
-
n
))
with
Not_found
->
acc
^
Str
.
string_after
s
n
in
san
0
""
let
rec
initial
()
=
match
read_line
()
with
|
None
->
()
|
Some
line
->
match
strstr
"(**"
line
with
|
None
->
initial
()
|
Some
pos
->
match
strstr
"*)"
line
with
|
None
->
begin
match
strstr
"[["
line
with
|
None
->
print_endline
(
sanitize
(
Str
.
string_after
line
(
pos
+
3
)));
comment
()
|
Some
_
->
runTo
"]]"
end
|
Some
pos'
->
let
rest
=
Str
.
string_after
line
(
pos
+
3
)
in
if
not
(
prefix
" printing"
rest
||
prefix
" begin"
rest
||
prefix
" end"
rest
)
then
print_endline
(
sanitize
(
String
.
sub
line
(
pos
+
3
)
(
pos'
-
(
pos
+
3
))));
initial
()
and
comment
()
=
match
read_line
()
with
|
None
->
()
|
Some
line
->
match
strstr
"*)"
line
with
|
None
->
begin
match
strstr
"[["
line
with
|
None
->
begin
match
strstr
"<<"
line
with
|
None
->
print_endline
(
sanitize
line
);
comment
()
|
Some
_
->
runTo
">>"
end
|
Some
_
->
runTo
"]]"
end
|
Some
pos
->
print_endline
(
sanitize
(
Str
.
string_before
line
pos
));
initial
()
and
runTo
ender
=
match
read_line
()
with
|
None
->
()
|
Some
line
->
match
strstr
ender
line
with
|
None
->
runTo
ender
|
_
->
match
strstr
"*)"
line
with
|
None
->
comment
()
|
_
->
initial
()
let
()
=
initial
()
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