Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
separate into tasks that actually parse
- Loading branch information
1 parent
480d361
commit 275185a
Showing
10 changed files
with
166 additions
and
104 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,38 @@ | ||
// Constructs a DOM tree from an incoming token stream. | ||
|
||
import dom::rcu::writer_methods; | ||
import dom::base::{methods, rd_tree_ops, wr_tree_ops}; | ||
import dom = dom::base; | ||
import parser = parser::html; | ||
import html::token; | ||
|
||
fn build_dom(scope: dom::node_scope, | ||
stream: port<token>) -> dom::node { | ||
// The current reference node. | ||
let mut cur = scope.new_node(dom::nk_div); | ||
loop { | ||
let token = stream.recv(); | ||
#debug["token=%?", token]; | ||
alt token { | ||
parser::to_eof { break; } | ||
parser::to_start_tag(_) { | ||
let new_node = scope.new_node(dom::nk_div); | ||
scope.add_child(cur, new_node); | ||
cur = new_node; | ||
} | ||
parser::to_end_tag(_) { | ||
// TODO: Assert that the closing tag has the right name. | ||
// TODO: Fail more gracefully (i.e. according to the HTML5 | ||
// spec) if we close more tags than we open. | ||
cur = scope.get_parent(cur).get(); | ||
} | ||
parser::to_text(_) { | ||
// TODO | ||
} | ||
parser::to_doctype { | ||
// TODO: Do something here... | ||
} | ||
} | ||
} | ||
ret cur; | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -35,6 +35,7 @@ mod layout { | |
|
||
mod parser { | ||
mod html; | ||
mod html_builder; | ||
} | ||
|
||
mod platform { | ||
|
Oops, something went wrong.