unwrap begin expression if it contains 1 or 0 expressions inside
This commit is contained in:
parent
6de7d610ee
commit
64038fae02
|
@ -367,17 +367,23 @@ analyze_node(analyze_state *state, pic_value obj, bool tailpos)
|
||||||
pic_value seq;
|
pic_value seq;
|
||||||
bool tail;
|
bool tail;
|
||||||
|
|
||||||
/* TODO: unwrap if the number of objects is 1 or 0 */
|
switch (pic_length(pic, obj)) {
|
||||||
seq = pic_list(pic, 1, pic_symbol_value(pic->sBEGIN));
|
case 1:
|
||||||
for (obj = pic_cdr(pic, obj); ! pic_nil_p(obj); obj = pic_cdr(pic, obj)) {
|
return pic_none_value();
|
||||||
if (pic_nil_p(pic_cdr(pic, obj))) {
|
case 2:
|
||||||
tail = tailpos;
|
return analyze(state, pic_list_ref(pic, obj, 1), tailpos);
|
||||||
} else {
|
default:
|
||||||
tail = false;
|
seq = pic_list(pic, 1, pic_symbol_value(pic->sBEGIN));
|
||||||
|
for (obj = pic_cdr(pic, obj); ! pic_nil_p(obj); obj = pic_cdr(pic, obj)) {
|
||||||
|
if (pic_nil_p(pic_cdr(pic, obj))) {
|
||||||
|
tail = tailpos;
|
||||||
|
} else {
|
||||||
|
tail = false;
|
||||||
|
}
|
||||||
|
seq = pic_cons(pic, analyze(state, pic_car(pic, obj), tail), seq);
|
||||||
}
|
}
|
||||||
seq = pic_cons(pic, analyze(state, pic_car(pic, obj), tail), seq);
|
return pic_reverse(pic, seq);
|
||||||
}
|
}
|
||||||
return pic_reverse(pic, seq);
|
|
||||||
}
|
}
|
||||||
else if (sym == pic->sSETBANG) {
|
else if (sym == pic->sSETBANG) {
|
||||||
pic_value var, val;
|
pic_value var, val;
|
||||||
|
|
Loading…
Reference in New Issue