compile_expression2(value(Val),_,Val) --> !.
compile_expression2(boolean_true,_,bool_true) --> !.
compile_expression2(boolean_false,_,bool_false) --> !.
compile_expression2(integer_set(SET),_,global_set(SET)) --> !.
compile_expression2(bool_set,_,[bool_true,bool_false]) --> !.
compile_expression2(empty_set,_,E) --> !, {empty_set(E)}.
compile_expression2(integer(Val),_,int(Val)) --> !.
compile_expression2(identifier(Id),Env,Value) --> !,
{ lookup_pre_identifier(Id,Env,V) ->
Value=V
; lookup_global_constant(Id,V) ->
Value=V
; b_global_set(Id) ->
Value=global_set(Id)
}.
compile_expression2(add(L,R),Env,Value) --> !,
compile_expression(L,Env,LValue),
compile_expression(R,Env,RValue),
emit(add(LValue,RValue,Value)).
compile_expression2(minus(L,R),Env,Value) --> !,
compile_expression(L,Env,LValue),
compile_expression(R,Env,RValue),
emit(sub(LValue,RValue,Value)).
compile_expression2(function(Function,Arg),Env,Value) --> !,
compile_expression(Function,Env,FValue),
compile_expression(Arg,Env,AValue),
emit(apply(FValue,AValue,Value)).
compile_expression2(set_subtraction(L,R),Env,Value) --> !,
compile_expression(L,Env,LValue),
compile_expression(R,Env,RValue),
emit(set_minus(LValue,RValue,Value)).
compile_expression2(set_extension(List),Env,Value) --> !,
compile_expression_l(List,Env,Values),
( {ground(Values)} ->
{custom_explicit_sets:construct_avl(Values,Value)}
; {otherwise} ->
{empty_set(Empty)},
add_values_to_set(Values,Empty,Value)).
compile_expression2(empty_set,_Env,Value) --> !,
{empty_set(Empty)},emit(Value=Empty).
compile_expression2(empty_sequence,Env,Value) --> !,
compile_expression2(empty_set,Env,Value).
compile_expression2(comprehension_set(Params,Condition),Env,Value) --> !,
{term_variables(Env,EnvVariables),
compile_set_comprehension(Params,Condition,Env,ElementValue,Body,[]),
term_variables(Body,UsedVariables),
intersect_variables(UsedVariables,EnvVariables,WaitVariables)},
emit(set_comprehension(Body,ElementValue,WaitVariables,Value)).
compile_expression2(first(Seq),Env,Value) --> !,
compile_expression(Seq,Env,SeqValue),
emit(first_of_sequence(SeqValue,Value)).
compile_expression2(tail(Seq),Env,Value) --> !,
compile_expression(Seq,Env,SeqValue),
emit(tail_of_sequence(SeqValue,Value)).
compile_expression2(overwrite(Rel,New),Env,Value) --> !,
compile_expression(Rel,Env,RelValue),
compile_expression(New,Env,NewValue),
emit(override_relation(RelValue,NewValue,Value)).
compile_expression2(insert_front(Front,Seq),Env,Value) --> !,
compile_expression(Front,Env,FrontValue),
compile_expression(Seq,Env,SeqValue),
emit(insert_at_front_of_sequence(SeqValue,FrontValue,Value)).
compile_expression2(couple(A,B),Env,Value) --> !,
{Value = (AV,BV)},
compile_expression(A,Env,AV), compile_expression(B,Env,BV).