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
b5b607c8
Commit
b5b607c8
authored
9 years ago
by
Alan Schmitt
Committed by
Thomas Wood
9 years ago
Browse files
Options
Downloads
Patches
Plain Diff
trying for better indentation
parent
9d657861
No related branches found
Branches containing commit
No related tags found
No related merge requests found
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
generator/js_of_ast.ml
+10
-10
10 additions, 10 deletions
generator/js_of_ast.ml
generator/log.ml
+7
-5
7 additions, 5 deletions
generator/log.ml
with
17 additions
and
15 deletions
generator/js_of_ast.ml
+
10
−
10
View file @
b5b607c8
...
@@ -134,20 +134,20 @@ let is_infix f args = match args with
...
@@ -134,20 +134,20 @@ let is_infix f args = match args with
*)
*)
let
ppf_lambda_wrap
s
=
let
ppf_lambda_wrap
s
=
Printf
.
sprintf
"
@[<v 0>
function () {@
,%s
@,}()
@]
"
s
Printf
.
sprintf
"
(
function () {@
;<1 2>@[<v 0>%s@]
@,}()
)
"
s
let
ppf_branch
case
binders
expr
=
let
ppf_branch
case
binders
expr
=
Printf
.
sprintf
"
@[<v 1>
%s: @[<v
2
>%s@,return %s;@
,@]@,@,@
]"
Printf
.
sprintf
"%s: @[<v
0
>%s@,return %s;@]"
case
binders
expr
case
binders
expr
let
ppf_let_in
decl
exp
=
let
ppf_let_in
decl
exp
=
let
s
=
let
s
=
Printf
.
sprintf
"
@[<v 0>%s@,
@,return %s;
@]
"
Printf
.
sprintf
"
%s
@,return %s;"
decl
exp
decl
exp
in
ppf_lambda_wrap
s
in
ppf_lambda_wrap
s
let
ppf_function
args
body
=
let
ppf_function
args
body
=
Printf
.
sprintf
"
@[<v 0>
function (%s) {@
,
@[<v
2>@,
return %s;@
,@
]@,}
@]
"
Printf
.
sprintf
"function (%s) {@
;<1 2>
@[<v
0>
return %s;@]@,}"
args
body
args
body
let
ppf_apply
f
args
=
let
ppf_apply
f
args
=
...
@@ -160,7 +160,7 @@ let ppf_apply_infix f arg1 arg2 =
...
@@ -160,7 +160,7 @@ let ppf_apply_infix f arg1 arg2 =
let
ppf_match
value
cases
=
let
ppf_match
value
cases
=
let
s
=
let
s
=
Printf
.
sprintf
"
@[<v 0>
switch (%s.type) {@,@[<v
2>@,
%s@
,@
]@,}
@]
"
Printf
.
sprintf
"switch (%s.type) {@,@[<v
0>
%s@]@,}"
value
cases
value
cases
in
ppf_lambda_wrap
s
in
ppf_lambda_wrap
s
...
@@ -224,7 +224,7 @@ let ppf_record llde =
...
@@ -224,7 +224,7 @@ let ppf_record llde =
in
aux
""
llde
in
aux
""
llde
let
ppf_decl
id
expr
=
let
ppf_decl
id
expr
=
Printf
.
sprintf
"@[<v 0>var %s = %s;@
,@
]"
Printf
.
sprintf
"@[<v 0>var %s = %s;@]"
id
expr
id
expr
let
ppf_pat_array
id_list
array_expr
=
let
ppf_pat_array
id_list
array_expr
=
...
@@ -245,13 +245,13 @@ and show_value_binding old_env vb =
...
@@ -245,13 +245,13 @@ and show_value_binding old_env vb =
and
js_of_structure
old_env
s
=
and
js_of_structure
old_env
s
=
let
new_env
=
s
.
str_final_env
in
let
new_env
=
s
.
str_final_env
in
show_list_f
(
fun
strct
->
js_of_structure_item
new_env
strct
)
lin2
s
.
str_items
show_list_f
(
fun
strct
->
js_of_structure_item
new_env
strct
)
"@,@,"
s
.
str_items
and
js_of_structure_item
old_env
s
=
and
js_of_structure_item
old_env
s
=
let
new_env
=
s
.
str_env
in
let
new_env
=
s
.
str_env
in
match
s
.
str_desc
with
match
s
.
str_desc
with
|
Tstr_eval
(
e
,
_
)
->
Printf
.
sprintf
"%s"
@@
js_of_expression
new_env
e
|
Tstr_eval
(
e
,
_
)
->
Printf
.
sprintf
"%s"
@@
js_of_expression
new_env
e
|
Tstr_value
(
_
,
vb_l
)
->
String
.
concat
lin2
@@
List
.
map
(
fun
vb
->
show_value_binding
new_env
vb
)
@@
vb_l
|
Tstr_value
(
_
,
vb_l
)
->
String
.
concat
"@,@,"
@@
List
.
map
(
fun
vb
->
show_value_binding
new_env
vb
)
@@
vb_l
|
Tstr_type
tl
->
|
Tstr_type
tl
->
let
explore_type
=
function
let
explore_type
=
function
|
[]
->
()
|
[]
->
()
...
@@ -312,7 +312,7 @@ and js_of_expression old_env e =
...
@@ -312,7 +312,7 @@ and js_of_expression old_env e =
else
ppf_apply
se
(
String
.
concat
", "
sl
)
else
ppf_apply
se
(
String
.
concat
", "
sl
)
|
Texp_match
(
exp
,
l
,
[]
,
Total
)
->
|
Texp_match
(
exp
,
l
,
[]
,
Total
)
->
let
se
=
js_of_expression
new_env
exp
in
let
se
=
js_of_expression
new_env
exp
in
let
sb
=
List
.
fold_left
(
fun
acc
x
->
acc
^
js_of_branch
old_env
x
se
)
""
l
in
let
sb
=
String
.
concat
"@,"
(
List
.
map
(
fun
x
->
js_of_branch
old_env
x
se
)
l
)
in
ppf_match
se
sb
ppf_match
se
sb
|
Texp_tuple
(
tl
)
->
ppf_tuple
@@
show_list_f
(
fun
exp
->
js_of_expression
new_env
exp
)
", "
tl
|
Texp_tuple
(
tl
)
->
ppf_tuple
@@
show_list_f
(
fun
exp
->
js_of_expression
new_env
exp
)
", "
tl
|
Texp_construct
(
loc
,
cd
,
el
)
->
|
Texp_construct
(
loc
,
cd
,
el
)
->
...
@@ -411,7 +411,7 @@ and js_of_pattern old_env pat obj =
...
@@ -411,7 +411,7 @@ and js_of_pattern old_env pat obj =
let
params
=
Hashtbl
.
find
type_tbl
c
in
let
params
=
Hashtbl
.
find
type_tbl
c
in
let
binders
=
let
binders
=
if
List
.
length
el
=
0
then
""
if
List
.
length
el
=
0
then
""
else
Printf
.
sprintf
"@[<v 0>%s@
,@
]"
else
Printf
.
sprintf
"@[<v 0>%s@]"
(
"var "
^
show_list
", "
(
List
.
map2
(
fun
x
y
->
x
^
" = "
^
obj
^
"."
^
y
)
(
List
.
map
(
fun
x
->
fst
(
js_of_pattern
new_env
x
obj
))
el
)
params
)
^
";"
)
in
(
"var "
^
show_list
", "
(
List
.
map2
(
fun
x
y
->
x
^
" = "
^
obj
^
"."
^
y
)
(
List
.
map
(
fun
x
->
fst
(
js_of_pattern
new_env
x
obj
))
el
)
params
)
^
";"
)
in
spat
,
binders
spat
,
binders
|
Tpat_tuple
el
->
out_of_scope
"tuple matching"
|
Tpat_tuple
el
->
out_of_scope
"tuple matching"
...
...
This diff is collapsed.
Click to expand it.
generator/log.ml
+
7
−
5
View file @
b5b607c8
...
@@ -131,16 +131,18 @@ struct
...
@@ -131,16 +131,18 @@ struct
let
logged_output
s
=
let
logged_output
s
=
let
str_ppf
=
Format
.
str_formatter
in
let
str_ppf
=
Format
.
str_formatter
in
Format
.
fprintf
str_ppf
(
Scanf
.
format_from_string
s
""
);
Format
.
fprintf
str_ppf
(
Scanf
.
format_from_string
s
""
);
let
bad_output
=
Format
.
flush_str_formatter
()
in
add_log_info
(
Format
.
flush_str_formatter
()
)
let
pretty_output
=
global_replace
lfs
"
\n
"
bad_output
in
(* let bad_output = Format.flush_str_formatter () in *)
add_log_info
pretty_output
(* let pretty_output = global_replace lfs "\n" bad_output in *)
(* add_log_info pretty_output *)
let
unlogged_output
s
=
let
unlogged_output
s
=
let
str_ppf
=
Format
.
str_formatter
in
let
str_ppf
=
Format
.
str_formatter
in
let
unlogged_info
=
strip_log_info
s
in
let
unlogged_info
=
strip_log_info
s
in
Format
.
fprintf
str_ppf
(
Scanf
.
format_from_string
unlogged_info
""
);
Format
.
fprintf
str_ppf
(
Scanf
.
format_from_string
unlogged_info
""
);
let
bad_output
=
Format
.
flush_str_formatter
()
in
Format
.
flush_str_formatter
()
global_replace
lfs
"
\n
"
bad_output
(* let bad_output = Format.flush_str_formatter () in *)
(* global_replace lfs "\n" bad_output *)
end
end
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