Skip to content
GitLab
Menu
Projects
Groups
Snippets
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
Menu
Open sidebar
cduce
cduce
Commits
ce7ff52a
Commit
ce7ff52a
authored
Apr 03, 2021
by
Kim Nguyễn
Browse files
Add HTML parser to the JSOO backend.
parent
deb43e17
Changes
2
Hide whitespace changes
Inline
Side-by-side
backend/jsoo/jsoo.ml
View file @
ce7ff52a
open
Js_of_ocaml
open
Cduce_core
let
load_xml
open_cb
close_cb
text_cb
txt
=
let
load_xml
_html
mimetype
open_cb
close_cb
text_cb
txt
=
let
_DOMParser
:
(
unit
->
<
..
>
Js
.
t
)
Js
.
constr
Js
.
optdef
=
Js
.
Unsafe
.(
get
global
(
Js
.
string
"DOMParser"
))
in
...
...
@@ -11,7 +11,7 @@ let load_xml open_cb close_cb text_cb txt =
in
let
parser
=
new
%
js
_DOMParser
()
in
let
txt
=
Js
.
string
txt
in
let
mime_type
=
Js
.
string
"text/xml"
in
let
mime_type
=
Js
.
string
mimetype
in
let
dom
:
Dom
.
element
Dom
.
document
Js
.
t
=
Js
.
Unsafe
.(
meth_call
parser
"parseFromString"
[
|
inject
txt
;
inject
mime_type
|
])
...
...
@@ -86,9 +86,15 @@ let use () =
!
content
);
Load_xml
.
xml_parser
:=
fun
url
->
load_xml
Load_xml
.
start_element_handler
Load_xml
.
end_element_handler
load_xml
_html
"application/xml"
Load_xml
.
start_element_handler
Load_xml
.
end_element_handler
Load_xml
.
text_handler
(
Url
.
load_url
url
);
Load_xml
.
html_loader
:=
Load_xml
.
mk_load_xml
(
fun
url
->
(
load_xml_html
"text/html"
Load_xml
.
start_element_handler
Load_xml
.
end_element_handler
Load_xml
.
text_handler
(
Url
.
load_url
url
)));
let
open
Cduce_types
in
let
tstr
=
Builtin_defs
.
string
in
...
...
lang/parser/parser.mly
View file @
ce7ff52a
...
...
@@ -473,8 +473,6 @@ ident_or_keyword:
|
k
=
keyword
{
k
}
;
int_or_star
:
|
i
=
INT
{
Some
i
}
|
"*"
{
None
}
...
...
@@ -530,7 +528,6 @@ field_pat:
;
regexp
:
|
x
=
regexp
"|"
y
=
regexp_concat
{
match
x
,
y
with
...
...
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