about summary refs log tree commit diff
path: root/src/comp
diff options
context:
space:
mode:
authorPatrick Walton <pcwalton@mimiga.net>2010-08-20 14:34:48 -0700
committerPatrick Walton <pcwalton@mimiga.net>2010-08-20 14:35:59 -0700
commitfc05ea0371a415bc5dca85010b9e9149039937a4 (patch)
treec45a35032616937a130361e9709ea9c43f2e8e7a /src/comp
parent8097a10c3681775cdc8d72029edc3faff152d598 (diff)
downloadrust-fc05ea0371a415bc5dca85010b9e9149039937a4.tar.gz
rust-fc05ea0371a415bc5dca85010b9e9149039937a4.zip
Use pattern matching for the one-byte structural symbols in the self-hosted compiler
Diffstat (limited to 'src/comp')
-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 d13b6f37512..bcc19d19d28 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;