package Data::Query::ExprHelpers;

use strictures 1;
use Data::Query::Constants qw(DQ_VALUE DQ_OPERATOR DQ_IDENTIFIER);

use base qw(Exporter);

our @EXPORT_OK = qw(perl_scalar_value perl_operator identifier);

sub perl_scalar_value {
  +{
    type => DQ_VALUE,
    subtype => { Perl => 'Scalar' },
    value => $_[0],
    $_[1] ? (value_meta => $_[1]) : ()
  }
}

sub perl_operator {
  my ($op, @args) = @_;
  +{
    type => DQ_OPERATOR,
    operator => { Perl => $op },
    args => \@args
  }
}

sub identifier {
  +{
    type => DQ_IDENTIFIER,
    elements => [ @_ ]
  }
}

1;
