Use pattern matching for the one-byte structural symbols in the self-hosted compiler

This commit is contained in:
Patrick Walton 2010-08-20 14:34:48 -07:00
parent 8097a10c36
commit fc05ea0371
1 changed files with 12 additions and 10 deletions

View File

@ -60,16 +60,18 @@ fn next_token(stdio_reader rdr) -> token.token {
} }
// One-byte structural symbols. // One-byte structural symbols.
if (c == ';') { ret token.SEMI(); } alt (c) {
if (c == '.') { ret token.DOT(); } case (';') { ret token.SEMI(); }
if (c == '(') { ret token.LPAREN(); } case ('.') { ret token.DOT(); }
if (c == ')') { ret token.RPAREN(); } case ('(') { ret token.LPAREN(); }
if (c == '{') { ret token.LBRACE(); } case (')') { ret token.RPAREN(); }
if (c == '}') { ret token.RBRACE(); } case ('{') { ret token.LBRACE(); }
if (c == '[') { ret token.LBRACKET(); } case ('}') { ret token.RBRACE(); }
if (c == ']') { ret token.RBRACKET(); } case ('[') { ret token.LBRACKET(); }
if (c == '@') { ret token.AT(); } case (']') { ret token.RBRACKET(); }
if (c == '#') { ret token.POUND(); } case ('@') { ret token.AT(); }
case ('#') { ret token.POUND(); }
}
log "lexer stopping at "; log "lexer stopping at ";
log c; log c;