aboutsummaryrefslogtreecommitdiffstats
path: root/src/servo/parser
diff options
context:
space:
mode:
authorMargaret Meyerhofer <mmeyerhofer@mozilla.com>2012-07-17 17:00:48 -0700
committerMargaret Meyerhofer <mmeyerhofer@mozilla.com>2012-07-18 13:27:23 -0700
commit6148309ce11aed879e8d88151c630bae6e8c617c (patch)
tree70a6f4b215c9d18ec2fa42ffda4d4fb899dd5176 /src/servo/parser
parentc25cb50d9d3f2ca709de855df9f6ccd9e9f60a70 (diff)
downloadservo-6148309ce11aed879e8d88151c630bae6e8c617c.tar.gz
servo-6148309ce11aed879e8d88151c630bae6e8c617c.zip
Fixed all strings in the old format
Diffstat (limited to 'src/servo/parser')
-rw-r--r--src/servo/parser/css_builder.rs28
-rw-r--r--src/servo/parser/css_lexer.rs30
-rw-r--r--src/servo/parser/html_builder.rs26
-rw-r--r--src/servo/parser/html_lexer.rs16
-rw-r--r--src/servo/parser/lexer_util.rs10
5 files changed, 55 insertions, 55 deletions
diff --git a/src/servo/parser/css_builder.rs b/src/servo/parser/css_builder.rs
index f96c34b5f8d..0c794ac1cd9 100644
--- a/src/servo/parser/css_builder.rs
+++ b/src/servo/parser/css_builder.rs
@@ -35,7 +35,7 @@ fn parse_element(reader : TokenReader) -> option<~style::Selector> {
let elmt_name = alt reader.get() {
Element(tag) { copy tag }
Eof { ret none; }
- _ { fail "Expected an element" }
+ _ { fail ~"Expected an element" }
};
let mut attr_list = ~[];
@@ -50,10 +50,10 @@ fn parse_element(reader : TokenReader) -> option<~style::Selector> {
break;
}
Eof { ret none; }
- Element(_) { fail "Unexpected second element without "
- + "relation to first element"; }
- EndDescription { fail "Unexpected '}'"; }
- Description(_, _) { fail "Unexpected description"; }
+ Element(_) { fail ~"Unexpected second element without "
+ + ~"relation to first element"; }
+ EndDescription { fail ~"Unexpected '}'"; }
+ Description(_, _) { fail ~"Unexpected description"; }
}
}
@@ -141,28 +141,28 @@ fn parse_rule(reader : TokenReader) -> option<~style::Rule> {
EndDescription { break; }
Description(prop, val) {
alt prop {
- "font-size" {
+ ~"font-size" {
// TODO, support more ways to declare a font size than # pt
- assert val.ends_with("pt");
+ assert val.ends_with(~"pt");
let num = val.substr(0u, val.len() - 2u);
alt uint::from_str(num) {
some(n) { push(desc_list, FontSize(n)); }
- none { fail "Nonnumber provided as font size"; }
+ none { fail ~"Nonnumber provided as font size"; }
}
}
- "display" {
+ ~"display" {
alt val {
- "inline" { push(desc_list, Display(DisInline)); }
- "block" { push(desc_list, Display(DisBlock)); }
- "none" { push(desc_list, Display(DisNone)); }
+ ~"inline" { push(desc_list, Display(DisInline)); }
+ ~"block" { push(desc_list, Display(DisBlock)); }
+ ~"none" { push(desc_list, Display(DisNone)); }
_ { #debug["Recieved unknown display value '%s'", val]; }
}
}
- "color" {
+ ~"color" {
push(desc_list, TextColor(parse_color(val)));
}
- "background-color" {
+ ~"background-color" {
push(desc_list, BackgroundColor(parse_color(val)));
}
_ { #debug["Recieved unknown style property '%s'", val]; }
diff --git a/src/servo/parser/css_lexer.rs b/src/servo/parser/css_lexer.rs
index 73022783f4a..9c09850ea9f 100644
--- a/src/servo/parser/css_lexer.rs
+++ b/src/servo/parser/css_lexer.rs
@@ -25,9 +25,9 @@ enum Token {
Child,
Sibling,
Comma,
- Element(str),
+ Element(~str),
Attr(style::Attr),
- Description(str, str),
+ Description(~str, ~str),
Eof
}
@@ -74,10 +74,10 @@ impl css_methods for CssLexer {
if c == '.' as u8 || c == '#' as u8 {
self.parser_state = CssAttribute;
self.input_state.unget(c);
- ret Element("*");
+ ret Element(~"*");
} else if c == '*' as u8 {
self.parser_state = CssAttribute;
- ret Element("*");
+ ret Element(~"*");
}
self.input_state.unget(c);
@@ -99,21 +99,21 @@ impl css_methods for CssLexer {
alt self.input_state.get() {
CoeChar(c) { ch = c }
- CoeEof { fail "File ended before description of style" }
+ CoeEof { fail ~"File ended before description of style" }
}
ret self.parse_css_relation(ch);
}
alt ch {
- '.' as u8 { ret Attr(style::Includes("class", self.input_state.parse_ident())); }
- '#' as u8 { ret Attr(style::Includes("id", self.input_state.parse_ident())); }
+ '.' as u8 { ret Attr(style::Includes(~"class", self.input_state.parse_ident())); }
+ '#' as u8 { ret Attr(style::Includes(~"id", self.input_state.parse_ident())); }
'[' as u8 {
let attr_name = self.input_state.parse_ident();
alt self.input_state.get() {
CoeChar(c) { ch = c; }
- CoeEof { fail "File ended before description finished"; }
+ CoeEof { fail ~"File ended before description finished"; }
}
if ch == ']' as u8 {
@@ -152,7 +152,7 @@ impl css_methods for CssLexer {
alt self.input_state.get() {
CoeChar(c) { ch = c }
- CoeEof { fail "Reached end of file in CSS description" }
+ CoeEof { fail ~"Reached end of file in CSS description" }
}
}
@@ -164,7 +164,7 @@ impl css_methods for CssLexer {
self.input_state.eat_whitespace();
} else if ch == ':' as u8 {
if desc_name.len() == 0u {
- fail "Expected descriptor name";
+ fail ~"Expected descriptor name";
} else {
break;
}
@@ -174,7 +174,7 @@ impl css_methods for CssLexer {
alt self.input_state.get() {
CoeChar(c) { ch = c }
- CoeEof { fail "Reached end of file in CSS description" }
+ CoeEof { fail ~"Reached end of file in CSS description" }
}
}
@@ -185,21 +185,21 @@ impl css_methods for CssLexer {
loop {
alt self.input_state.get() {
CoeChar(c) { ch = c }
- CoeEof { fail "Reached end of file in CSS description" }
+ CoeEof { fail ~"Reached end of file in CSS description" }
}
if ch.is_whitespace() {
self.input_state.eat_whitespace();
} else if ch == '}' as u8 {
if desc_val.len() == 0u {
- fail "Expected descriptor value";
+ fail ~"Expected descriptor value";
} else {
self.input_state.unget('}' as u8);
break;
}
} else if ch == ';' as u8 {
if desc_val.len() == 0u {
- fail "Expected descriptor value";
+ fail ~"Expected descriptor value";
} else {
break;
}
@@ -223,7 +223,7 @@ fn spawn_css_lexer_task(-filename: ~str) -> port<Token> {
let result_chan = chan(result_port);
task::spawn(|| {
- assert (copy filename).ends_with(".css");
+ assert (copy filename).ends_with(~".css");
let file_try = io::read_whole_file(filename);
// Check if the given css file existed, if it does, parse it,
diff --git a/src/servo/parser/html_builder.rs b/src/servo/parser/html_builder.rs
index 49a38959268..3dd7c48f21c 100644
--- a/src/servo/parser/html_builder.rs
+++ b/src/servo/parser/html_builder.rs
@@ -19,14 +19,14 @@ enum css_message {
}
#[warn(no_non_implicitly_copyable_typarams)]
-fn link_up_attribute(scope: NodeScope, node: Node, -key: str, -value: str) {
+fn link_up_attribute(scope: NodeScope, node: Node, -key: ~str, -value: ~str) {
// TODO: Implement atoms so that we don't always perform string comparisons.
scope.read(node, |node_contents| {
alt *node_contents.kind {
Element(element) {
element.attrs.push(~Attr(copy key, copy value));
alt *element.kind {
- HTMLImageElement(img) if key == "width" {
+ HTMLImageElement(img) if key == ~"width" {
alt int::from_str(value) {
none {
// Drop on the floor.
@@ -34,7 +34,7 @@ fn link_up_attribute(scope: NodeScope, node: Node, -key: str, -value: str) {
some(s) { img.size.width = geometry::px_to_au(s); }
}
}
- HTMLImageElement(img) if key == "height" {
+ HTMLImageElement(img) if key == ~"height" {
alt int::from_str(value) {
none {
// Drop on the floor.
@@ -51,22 +51,22 @@ fn link_up_attribute(scope: NodeScope, node: Node, -key: str, -value: str) {
}
Text(*) {
- fail "attempt to link up an attribute to a text node"
+ fail ~"attempt to link up an attribute to a text node"
}
}
})
}
-fn build_element_kind(tag_name: str) -> ~ElementKind {
+fn build_element_kind(tag_name: ~str) -> ~ElementKind {
alt tag_name {
- "div" { ~HTMLDivElement }
- "img" {
+ ~"div" { ~HTMLDivElement }
+ ~"img" {
~HTMLImageElement({
mut size: Size2D(geometry::px_to_au(100),
geometry::px_to_au(100))
})
}
- "head" { ~HTMLHeadElement }
+ ~"head" { ~HTMLHeadElement }
_ { ~UnknownElement }
}
}
@@ -117,7 +117,7 @@ fn css_link_listener(to_parent : chan<Stylesheet>, from_parent : port<css_messag
#[warn(no_non_implicitly_copyable_typarams)]
fn build_dom(scope: NodeScope, stream: port<Token>) -> (Node, port<Stylesheet>) {
// The current reference node.
- let mut cur_node = scope.new_node(Element(ElementData("html", ~HTMLDivElement)));
+ let mut cur_node = scope.new_node(Element(ElementData(~"html", ~HTMLDivElement)));
// We will spawn a separate task to parse any css that is
// encountered, each link to a stylesheet is sent to the waiting
// task. After the html sheet has been fully read, the spawned
@@ -153,10 +153,10 @@ fn build_dom(scope: NodeScope, stream: port<Token>) -> (Node, port<Stylesheet>)
//TODO: check for things other than the link tag
scope.read(cur_node, |n| {
alt *n.kind {
- Element(elmt) if elmt.tag_name == "link" {
- alt elmt.get_attr("rel") {
- some(r) if r == "stylesheet" {
- alt elmt.get_attr("href") {
+ Element(elmt) if elmt.tag_name == ~"link" {
+ alt elmt.get_attr(~"rel") {
+ some(r) if r == ~"stylesheet" {
+ alt elmt.get_attr(~"href") {
some(filename) {
#debug["Linking to a css sheet named: %s", filename];
style_chan.send(file(copy filename));
diff --git a/src/servo/parser/html_lexer.rs b/src/servo/parser/html_lexer.rs
index 7a8a0d50767..3c4fced71c4 100644
--- a/src/servo/parser/html_lexer.rs
+++ b/src/servo/parser/html_lexer.rs
@@ -6,12 +6,12 @@ import vec::push;
import lexer_util::*;
enum Token {
- StartOpeningTag(str),
+ StartOpeningTag(~str),
EndOpeningTag,
- EndTag(str),
+ EndTag(~str),
SelfCloseTag,
- Text(str),
- Attr(str, str),
+ Text(~str),
+ Attr(~str, ~str),
Doctype,
Eof
}
@@ -47,14 +47,14 @@ impl html_methods for HtmlLexer {
if ch == ('<' as u8) {
alt self.input_state.get() {
CoeChar(c) { ch = c; }
- CoeEof { self.input_state.parse_err("eof after '<'") }
+ CoeEof { self.input_state.parse_err(~"eof after '<'") }
}
if ch == ('!' as u8) {
self.input_state.eat_whitespace();
- self.input_state.expect_ident("DOCTYPE");
+ self.input_state.expect_ident(~"DOCTYPE");
self.input_state.eat_whitespace();
- self.input_state.expect_ident("html");
+ self.input_state.expect_ident(~"html");
self.input_state.eat_whitespace();
self.input_state.expect('>' as u8);
ret Doctype;
@@ -169,7 +169,7 @@ fn spawn_html_lexer_task(-filename: ~str) -> port<Token> {
task::spawn(|| {
let filename = copy html_file;
- assert (copy filename).ends_with(".html");
+ assert (copy filename).ends_with(~".html");
let file_data = io::read_whole_file(filename).get();
let reader = io::bytes_reader(file_data);
diff --git a/src/servo/parser/lexer_util.rs b/src/servo/parser/lexer_util.rs
index 6cd395f82a8..a2ee3c767b6 100644
--- a/src/servo/parser/lexer_util.rs
+++ b/src/servo/parser/lexer_util.rs
@@ -45,7 +45,7 @@ impl util_methods for InputState {
self.lookahead = some(CoeChar(ch));
}
- fn parse_err(err: str) -> ! {
+ fn parse_err(err: ~str) -> ! {
fail err
}
@@ -62,7 +62,7 @@ impl util_methods for InputState {
}
}
- fn parse_ident() -> str {
+ fn parse_ident() -> ~str {
let mut result: ~[u8] = ~[];
loop {
alt self.get() {
@@ -70,21 +70,21 @@ impl util_methods for InputState {
if (c.is_alpha()) {
push(result, c);
} else if result.len() == 0u {
- self.parse_err("expected ident");
+ self.parse_err(~"expected ident");
} else {
self.unget(c);
break;
}
}
CoeEof {
- self.parse_err("expected ident");
+ self.parse_err(~"expected ident");
}
}
}
ret str::from_bytes(result);
}
- fn expect_ident(expected: str) {
+ fn expect_ident(expected: ~str) {
let actual = self.parse_ident();
if expected != actual {
self.parse_err(#fmt("expected '%s' but found '%s'", expected, actual));