aboutsummaryrefslogtreecommitdiffstats
path: root/src/servo/parser/lexer_util.rs
diff options
context:
space:
mode:
Diffstat (limited to 'src/servo/parser/lexer_util.rs')
-rw-r--r--src/servo/parser/lexer_util.rs20
1 files changed, 15 insertions, 5 deletions
diff --git a/src/servo/parser/lexer_util.rs b/src/servo/parser/lexer_util.rs
index 6532e944930..a95a5eb4611 100644
--- a/src/servo/parser/lexer_util.rs
+++ b/src/servo/parser/lexer_util.rs
@@ -11,8 +11,18 @@ enum CharOrEof {
CoeEof
}
+impl CharOrEof: cmp::Eq {
+ pure fn eq(&&other: CharOrEof) -> bool {
+ match (self, other) {
+ (CoeChar(a), CoeChar(b)) => a == b,
+ (CoeChar(*), _) | (_, CoeChar(*)) => false,
+ (CoeEof, CoeEof) => true,
+ }
+ }
+}
+
type InputState = {
- mut lookahead: option<CharOrEof>,
+ mut lookahead: Option<CharOrEof>,
mut buffer: ~[u8],
input_port: Port<ProgressMsg>,
mut eof: bool
@@ -47,12 +57,12 @@ trait InputStateUtil {
impl InputState : InputStateUtil {
fn get() -> CharOrEof {
match copy self.lookahead {
- some(coe) => {
+ Some(coe) => {
let rv = coe;
- self.lookahead = none;
+ self.lookahead = None;
return rv;
}
- none => {
+ None => {
/* fall through */
}
}
@@ -82,7 +92,7 @@ impl InputState : InputStateUtil {
fn unget(ch: u8) {
assert is_none(self.lookahead);
- self.lookahead = some(CoeChar(ch));
+ self.lookahead = Some(CoeChar(ch));
}
fn parse_err(err: ~str) -> ! {