diff options
| author | Patrick Walton <[email protected]> | 2010-08-20 14:34:48 -0700 |
|---|---|---|
| committer | Patrick Walton <[email protected]> | 2010-08-20 14:35:59 -0700 |
| commit | fc05ea0371a415bc5dca85010b9e9149039937a4 (patch) | |
| tree | c45a35032616937a130361e9709ea9c43f2e8e7a /src/comp/fe | |
| parent | XFAIL _io test because darwin and winnt are burning. (diff) | |
| download | rust-fc05ea0371a415bc5dca85010b9e9149039937a4.tar.xz rust-fc05ea0371a415bc5dca85010b9e9149039937a4.zip | |
Use pattern matching for the one-byte structural symbols in the self-hosted compiler
Diffstat (limited to 'src/comp/fe')
| -rw-r--r-- | src/comp/fe/lexer.rs | 22 |
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; |