aboutsummaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorPatrick Walton <[email protected]>2010-08-20 14:34:48 -0700
committerPatrick Walton <[email protected]>2010-08-20 14:35:59 -0700
commitfc05ea0371a415bc5dca85010b9e9149039937a4 (patch)
treec45a35032616937a130361e9709ea9c43f2e8e7a /src
parentXFAIL _io test because darwin and winnt are burning. (diff)
downloadrust-fc05ea0371a415bc5dca85010b9e9149039937a4.tar.xz
rust-fc05ea0371a415bc5dca85010b9e9149039937a4.zip
Use pattern matching for the one-byte structural symbols in the self-hosted compiler
Diffstat (limited to 'src')
-rw-r--r--src/comp/fe/lexer.rs22
1 files changed, 12 insertions, 10 deletions
diff --git a/src/comp/fe/lexer.rs b/src/comp/fe/lexer.rs
index d13b6f37..bcc19d19 100644
--- a/src/comp/fe/lexer.rs
+++ b/src/comp/fe/lexer.rs
@@ -60,16 +60,18 @@ fn next_token(stdio_reader rdr) -> token.token {
}
// One-byte structural symbols.
- if (c == ';') { ret token.SEMI(); }
- if (c == '.') { ret token.DOT(); }
- if (c == '(') { ret token.LPAREN(); }
- if (c == ')') { ret token.RPAREN(); }
- if (c == '{') { ret token.LBRACE(); }
- if (c == '}') { ret token.RBRACE(); }
- if (c == '[') { ret token.LBRACKET(); }
- if (c == ']') { ret token.RBRACKET(); }
- if (c == '@') { ret token.AT(); }
- if (c == '#') { ret token.POUND(); }
+ alt (c) {
+ case (';') { ret token.SEMI(); }
+ case ('.') { ret token.DOT(); }
+ case ('(') { ret token.LPAREN(); }
+ case (')') { ret token.RPAREN(); }
+ case ('{') { ret token.LBRACE(); }
+ case ('}') { ret token.RBRACE(); }
+ case ('[') { ret token.LBRACKET(); }
+ case (']') { ret token.RBRACKET(); }
+ case ('@') { ret token.AT(); }
+ case ('#') { ret token.POUND(); }
+ }
log "lexer stopping at ";
log c;