Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
J
jsexplain
Manage
Activity
Members
Code
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Build
Pipelines
Jobs
Pipeline schedules
Artifacts
Deploy
Releases
Container Registry
Model registry
Operate
Environments
Analyze
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
Verified Software
jsexplain
Commits
bb1cccdc
Commit
bb1cccdc
authored
9 years ago
by
Cesar Roux Dit Buisson
Browse files
Options
Downloads
Patches
Plain Diff
Annotate and remove wrap
parent
b0340210
No related branches found
No related tags found
No related merge requests found
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
generator/log.ml
+7
-1
7 additions, 1 deletion
generator/log.ml
with
7 additions
and
1 deletion
generator/log.ml
+
7
−
1
View file @
bb1cccdc
...
...
@@ -101,6 +101,7 @@ struct
if
l
.
[
len
-
1
]
=
'
|
'
then
extract
(
len
-
2
)
0
else
None
(* Links list of tokens to string, and returns token annotated string. Stores token info. *)
let
log_line
str
ctxls
=
let
log_ctx
str
ctx
=
let
token
,
tokenized
=
bind_token
str
in
...
...
@@ -108,6 +109,7 @@ struct
tokenized
in
List
.
fold_left
log_ctx
str
ctxls
(* Removes all tokens from string *)
let
strip_log_info
s
=
global_replace
token_re
""
s
...
...
@@ -123,6 +125,7 @@ struct
let
nacc
=
(
Some
(
G
.
token_of_string
(
String
.
sub
m
1
(
m_len
-
2
))))
::
acc
in
line_token_extractor
nacc
npos
nl
(* Splits string by new lines and searches for all tokens in that line. Return list of tuples: [([<token_list>], <line>)] *)
let
lines
s
=
let
end_line_markers
s
=
let
rec
build
start
=
match
(
search_forward
endline_re
s
start
)
with
...
...
@@ -181,6 +184,7 @@ struct
Buffer
.
add_string
buf
(
"
\n
"
^
pad
^
"log("
^
string_of_int
(
i
+
1
)
^
", ctx,
\"
function
\"
);"
);
aux
i
((
tks
,
str
)
::
xs
)
|
ReturnStrip
->
(* Pull whatever is in a return call out to var returnres and modify the stored string to return returnres *)
let
strsplit
=
split
(
regexp
"return"
)
str
in
if
List
.
length
strsplit
>
1
then
let
nstr
=
(
List
.
nth
strsplit
0
)
^
"return returnres;"
in
...
...
@@ -189,9 +193,11 @@ struct
else
aux
i
((
tks
,
str
)
::
xs
)
|
Enter
->
(* Log an entry into a function *)
Buffer
.
add_string
buf
(
"
\n
"
^
pad
^
"log_custom({line:"
^
string_of_int
(
i
+
1
)
^
", type:
\"
enter
\"
});"
);
aux
(
i
+
1
)
xs
|
Exit
->
(* Log exit of a function *)
Buffer
.
add_string
buf
(
"
\n
"
^
pad
^
"log_custom({line:"
^
string_of_int
(
i
+
1
)
^
", type:
\"
exit
\"
});"
);
aux
i
((
tks
,
str
)
::
xs
)
in
aux
0
ls
;
Buffer
.
contents
buf
...
...
@@ -199,7 +205,7 @@ struct
let
logged_output
s
=
let
str_ppf
=
Format
.
str_formatter
in
Format
.
fprintf
str_ppf
(
Scanf
.
format_from_string
s
""
);
ppf_run_wrap
(
add_log_info
(
Format
.
flush_str_formatter
()
)
)
add_log_info
(
Format
.
flush_str_formatter
()
)
(* let bad_output = Format.flush_str_formatter () in *)
(* let pretty_output = global_replace lfs "\n" bad_output in *)
(* add_log_info pretty_output *)
...
...
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