#include "builtins/builtins.h"
#include "precedence.h"
#include "builtins/helpers.h"

using namespace empathy;
using namespace empathy::ir;
using namespace empathy::parse;

namespace empathy::builtins
{
    void SetupCommaOp( Env& e )
    {
        RegisterLeftAssInfixOp( e, ","_sid, precedence::CommaOp,
            []( auto&& lhs, auto&& rhs )
            {
                if( IsOpenTuple( lhs ) )
                    return AppendToTuple( lhs, rhs );

                return AppendToTuple( AppendToTuple( EmptyTuple(), lhs ), rhs );
            } );
    }
}
