Move the option type to its own module

This commit is contained in:
Patrick Walton 2010-11-03 17:10:37 -07:00
parent e399926776
commit adb1754e4d
14 changed files with 115 additions and 93 deletions

View file

@ -1,7 +1,6 @@
import util.common.option;
import std.map.hashmap;
import std.util.option;
import std.option;
import util.common.span;
import util.common.spanned;
@ -71,16 +70,16 @@ tag unop {
type stmt = spanned[stmt_];
tag stmt_ {
stmt_decl(@decl);
stmt_ret(option[@expr]);
stmt_ret(option.t[@expr]);
stmt_log(@expr);
stmt_check_expr(@expr);
stmt_expr(@expr);
}
type local = rec(option[@ty] ty,
type local = rec(option.t[@ty] ty,
bool infer,
ident ident,
option[@expr] init,
option.t[@expr] init,
def_id id);
type decl = spanned[decl_];
@ -99,14 +98,14 @@ tag expr_ {
expr_unary(unop, @expr, ann);
expr_lit(@lit, ann);
expr_cast(@expr, @ty, ann);
expr_if(@expr, block, option[block], ann);
expr_if(@expr, block, option.t[block], ann);
expr_while(@expr, block, ann);
expr_do_while(block, @expr, ann);
expr_block(block, ann);
expr_assign(@expr /* TODO: @expr|is_lval */, @expr, ann);
expr_field(@expr, ident, ann);
expr_index(@expr, @expr, ann);
expr_name(name, option[def], ann);
expr_name(name, option.t[def], ann);
}
type lit = spanned[lit_];
@ -131,7 +130,7 @@ tag ty_ {
ty_box(@ty);
ty_vec(@ty);
ty_tup(vec[tup(bool /* mutability */, @ty)]);
ty_path(path, option[def]);
ty_path(path, option.t[def]);
}
tag mode {

View file

@ -1,7 +1,7 @@
import std._io;
import std.util.option;
import std.util.some;
import std.util.none;
import std.option;
import std.option.some;
import std.option.none;
import std.map.hashmap;
import driver.session;
@ -157,7 +157,7 @@ impure fn parse_arg(parser p) -> ast.arg {
impure fn parse_seq[T](token.token bra,
token.token ket,
option[token.token] sep,
option.t[token.token] sep,
(impure fn(parser) -> T) f,
parser p) -> util.common.spanned[vec[T]] {
let bool first = true;
@ -185,7 +185,7 @@ impure fn parse_seq[T](token.token bra,
ret spanned(lo, hi, v);
}
impure fn parse_lit(parser p) -> option[ast.lit] {
impure fn parse_lit(parser p) -> option.t[ast.lit] {
auto lo = p.get_span();
let ast.lit_ lit;
alt (p.peek()) {
@ -600,7 +600,7 @@ impure fn parse_if_expr(parser p) -> @ast.expr {
auto cond = parse_expr(p);
expect(p, token.RPAREN);
auto thn = parse_block(p);
let option[ast.block] els = none[ast.block];
let option.t[ast.block] els = none[ast.block];
hi = thn.span;
alt (p.peek()) {
case (token.ELSE) {
@ -664,7 +664,7 @@ impure fn parse_expr(parser p) -> @ast.expr {
}
}
impure fn parse_initializer(parser p) -> option[@ast.expr] {
impure fn parse_initializer(parser p) -> option.t[@ast.expr] {
if (p.peek() == token.EQ) {
p.bump();
ret some(parse_expr(p));