Change from bool to tag ast.mutability.
This commit is contained in:
parent
38846e39c4
commit
386f363cfe
5 changed files with 65 additions and 49 deletions
|
|
@ -48,6 +48,11 @@ tag pat_ {
|
|||
pat_tag(ident, vec[@pat], ann);
|
||||
}
|
||||
|
||||
tag mutability {
|
||||
mut;
|
||||
imm;
|
||||
}
|
||||
|
||||
tag binop {
|
||||
add;
|
||||
sub;
|
||||
|
|
@ -105,7 +110,7 @@ type arm = rec(@pat pat, block block);
|
|||
type expr = spanned[expr_];
|
||||
tag expr_ {
|
||||
expr_vec(vec[@expr], ann);
|
||||
expr_tup(vec[tup(bool /* mutability */, @expr)], ann);
|
||||
expr_tup(vec[tup(mutability, @expr)], ann);
|
||||
expr_rec(vec[tup(ident,@expr)], ann);
|
||||
expr_call(@expr, vec[@expr], ann);
|
||||
expr_binary(binop, @expr, @expr, ann);
|
||||
|
|
@ -147,7 +152,7 @@ tag ty_ {
|
|||
ty_str;
|
||||
ty_box(@ty);
|
||||
ty_vec(@ty);
|
||||
ty_tup(vec[tup(bool /* mutability */, @ty)]);
|
||||
ty_tup(vec[tup(mutability, @ty)]);
|
||||
ty_fn(vec[rec(mode mode, @ty ty)], @ty); // TODO: effect
|
||||
ty_path(path, option.t[def]);
|
||||
ty_mutable(@ty);
|
||||
|
|
|
|||
|
|
@ -96,13 +96,14 @@ impure fn parse_ident(parser p) -> ast.ident {
|
|||
}
|
||||
}
|
||||
|
||||
impure fn parse_possibly_mutable_ty(parser p) -> tup(bool, @ast.ty) {
|
||||
impure fn parse_possibly_mutable_ty(parser p)
|
||||
-> tup(ast.mutability, @ast.ty) {
|
||||
auto mut;
|
||||
if (p.peek() == token.MUTABLE) {
|
||||
p.bump();
|
||||
mut = true;
|
||||
mut = ast.mut;
|
||||
} else {
|
||||
mut = false;
|
||||
mut = ast.imm;
|
||||
}
|
||||
|
||||
ret tup(mut, parse_ty(p));
|
||||
|
|
@ -192,8 +193,10 @@ impure fn parse_ty(parser p) -> @ast.ty {
|
|||
case (token.TUP) {
|
||||
p.bump();
|
||||
auto f = parse_possibly_mutable_ty; // FIXME: trans_const_lval bug
|
||||
auto elems = parse_seq[tup(bool, @ast.ty)](token.LPAREN,
|
||||
token.RPAREN, some(token.COMMA), f, p);
|
||||
auto elems =
|
||||
parse_seq[tup(ast.mutability, @ast.ty)]
|
||||
(token.LPAREN,
|
||||
token.RPAREN, some(token.COMMA), f, p);
|
||||
hi = p.get_span();
|
||||
t = ast.ty_tup(elems.node);
|
||||
}
|
||||
|
|
@ -346,13 +349,14 @@ impure fn parse_name(parser p, ast.ident id) -> ast.name {
|
|||
ret spanned(lo, tys.span, rec(ident=id, types=tys.node));
|
||||
}
|
||||
|
||||
impure fn parse_possibly_mutable_expr(parser p) -> tup(bool, @ast.expr) {
|
||||
impure fn parse_possibly_mutable_expr(parser p)
|
||||
-> tup(ast.mutability, @ast.expr) {
|
||||
auto mut;
|
||||
if (p.peek() == token.MUTABLE) {
|
||||
p.bump();
|
||||
mut = true;
|
||||
mut = ast.mut;
|
||||
} else {
|
||||
mut = false;
|
||||
mut = ast.imm;
|
||||
}
|
||||
|
||||
ret tup(mut, parse_expr(p));
|
||||
|
|
@ -409,10 +413,12 @@ impure fn parse_bottom_expr(parser p) -> @ast.expr {
|
|||
case (token.TUP) {
|
||||
p.bump();
|
||||
auto pf = parse_possibly_mutable_expr;
|
||||
auto es = parse_seq[tup(bool, @ast.expr)](token.LPAREN,
|
||||
token.RPAREN,
|
||||
some(token.COMMA),
|
||||
pf, p);
|
||||
auto es =
|
||||
parse_seq[tup(ast.mutability, @ast.expr)]
|
||||
(token.LPAREN,
|
||||
token.RPAREN,
|
||||
some(token.COMMA),
|
||||
pf, p);
|
||||
hi = es.span;
|
||||
ex = ast.expr_tup(es.node, ast.ann_none);
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue