Commit 647d9b1f authored by Hatim Djelassi's avatar Hatim Djelassi
Browse files

Release version v0.2

Add capabilities for set tensors
Add intrinsic functions
Fix precedence bug in parser
parent b740b085
cmake_minimum_required(VERSION 3.8)
cmake_minimum_required(VERSION 3.8 FATAL_ERROR)
set(CMAKE_DISABLE_IN_SOURCE_BUILD ON)
......
......@@ -12,6 +12,7 @@
#pragma once
#define LIBALE_MAX_DIM 3
#define LIBALE_MAX_SET_DIM 1
#if (LIBALE_MAX_DIM < 1 || LIBALE_MAX_DIM > 10)
#error LIBALE_MAX_DIM must be between 1 and 10
......
......@@ -79,6 +79,18 @@ struct value_node<boolean<LIBALE_MAX_DIM>> {
virtual value_node<boolean<LIBALE_MAX_DIM>>* clone() = 0;
};
template <typename TElement>
struct value_node<set<TElement, LIBALE_MAX_SET_DIM>> {
virtual ~value_node() {};
using basic_type = typename set<TElement, LIBALE_MAX_SET_DIM>::basic_type;
using var = std::variant<
constant_node<set<TElement, LIBALE_MAX_SET_DIM>>*,
parameter_node<set<TElement, LIBALE_MAX_SET_DIM>>*
>;
virtual var get_variant() = 0;
virtual value_node<set<TElement, LIBALE_MAX_SET_DIM>>* clone() = 0;
};
// value_node specializations for tensor-types of dimension 0
struct minus_node;
struct inverse_node;
......@@ -144,6 +156,12 @@ struct dippr106_dhvap_node;
struct schroeder_ethanol_p_node;
struct schroeder_ethanol_rhovap_node;
struct schroeder_ethanol_rholiq_node;
struct covar_matern_1_node;
struct covar_matern_3_node;
struct covar_matern_5_node;
struct covar_sqrexp_node;
struct gpdf_node;
struct regnormal_node;
struct squash_node;
template <typename TType> struct sum_node;
......@@ -219,7 +237,13 @@ using real_node_types = typename combined_pack<
squash_node*,
schroeder_ethanol_p_node*,
schroeder_ethanol_rhovap_node*,
schroeder_ethanol_rholiq_node*
schroeder_ethanol_rholiq_node*,
covar_matern_1_node*,
covar_matern_3_node*,
covar_matern_5_node*,
covar_sqrexp_node*,
gpdf_node*,
regnormal_node*
>,
pointer_pack_from_pack<sum_node, real_types>::type,
pointer_pack_from_pack<sum_node, index_types>::type,
......@@ -308,29 +332,17 @@ template <typename TType>
struct indicator_set_node;
template <typename TType>
struct value_node<set<TType>> {
struct value_node<set<TType, 0>> {
virtual ~value_node() {};
using basic_type = typename set<TType>::basic_type;
using basic_type = typename set<TType, 0>::basic_type;
using var = std::variant<
constant_node<set<TType>>*,
parameter_node<set<TType>>*,
constant_node<set<TType, 0>>*,
parameter_node<set<TType, 0>>*,
entry_node<set<TType, 0>>*,
indicator_set_node<TType>*
>;
virtual var get_variant() = 0;
virtual value_node<set<TType>>* clone() = 0;
};
template <unsigned IDim>
struct value_node<set<real<IDim>>> {
virtual ~value_node() {};
using basic_type = typename set<real<IDim>>::basic_type;
using var = std::variant<
constant_node<set<real<IDim>>>*,
parameter_node<set<real<IDim>>>*,
indicator_set_node<real<IDim>>*
>;
virtual var get_variant() = 0;
virtual value_node<set<real<IDim>>>* clone() = 0;
virtual value_node<set<TType, 0>>* clone() = 0;
};
// copyable specialization of unique_ptr for storing value_node
......@@ -442,6 +454,11 @@ struct neg_node : derived_value_node<neg_node, real<0>>, unary_node<real<0>> {us
struct schroeder_ethanol_p_node : derived_value_node<schroeder_ethanol_p_node, real<0>>, unary_node<real<0>> {using kary_node::kary_node;};
struct schroeder_ethanol_rhovap_node : derived_value_node<schroeder_ethanol_rhovap_node, real<0>>, unary_node<real<0>> {using kary_node::kary_node;};
struct schroeder_ethanol_rholiq_node : derived_value_node<schroeder_ethanol_rholiq_node, real<0>>, unary_node<real<0>> {using kary_node::kary_node;};
struct covar_matern_1_node : derived_value_node<covar_matern_1_node, real<0>>, unary_node<real<0>> {using kary_node::kary_node;};
struct covar_matern_3_node : derived_value_node<covar_matern_3_node, real<0>>, unary_node<real<0>> {using kary_node::kary_node;};
struct covar_matern_5_node : derived_value_node<covar_matern_5_node, real<0>>, unary_node<real<0>> {using kary_node::kary_node;};
struct covar_sqrexp_node : derived_value_node<covar_sqrexp_node, real<0>>, unary_node<real<0>> {using kary_node::kary_node;};
struct gpdf_node : derived_value_node<gpdf_node, real<0>>, unary_node<real<0>> {using kary_node::kary_node;};
// binary nodes
template <typename TType, typename UType>
......@@ -469,45 +486,45 @@ struct greater_node : derived_value_node<greater_node<TType>, boolean<0>>, binar
template <typename TType>
struct greater_equal_node : derived_value_node<greater_equal_node<TType>, boolean<0>>, binary_node<TType, TType> {using kary_node<TType, TType>::kary_node;};
struct element_node : derived_value_node<element_node, boolean<0>>, binary_node<real<0>, set<real<0>>> {using kary_node::kary_node;};
struct element_node : derived_value_node<element_node, boolean<0>>, binary_node<real<0>, set<real<0>, 0>> {using kary_node::kary_node;};
template <typename TType>
struct sum_node : derived_value_node<sum_node<TType>, real<0>>, binary_node<set<TType>, real<0>> {
using kary_node<set<TType>, real<0>>::kary_node;
sum_node(std::string name, value_node<set<TType>>* first, value_node<real<0>>* second) :
binary_node<set<TType>, real<0>>::kary_node(first, second), name(name) {};
struct sum_node : derived_value_node<sum_node<TType>, real<0>>, binary_node<set<TType, 0>, real<0>> {
using kary_node<set<TType, 0>, real<0>>::kary_node;
sum_node(std::string name, value_node<set<TType, 0>>* first, value_node<real<0>>* second) :
binary_node<set<TType, 0>, real<0>>::kary_node(first, second), name(name) {};
std::string name;
};
template <typename TType>
struct set_min_node : derived_value_node<set_min_node<TType>, real<0>>, binary_node<set<TType>, real<0>> {
using kary_node<set<TType>, real<0>>::kary_node;
set_min_node(std::string name, value_node<set<TType>>* first, value_node<real<0>>* second) :
binary_node<set<TType>, real<0>>::kary_node(first, second), name(name) {};
struct set_min_node : derived_value_node<set_min_node<TType>, real<0>>, binary_node<set<TType, 0>, real<0>> {
using kary_node<set<TType, 0>, real<0>>::kary_node;
set_min_node(std::string name, value_node<set<TType, 0>>* first, value_node<real<0>>* second) :
binary_node<set<TType, 0>, real<0>>::kary_node(first, second), name(name) {};
std::string name;
};
template <typename TType>
struct set_max_node : derived_value_node<set_max_node<TType>, real<0>>, binary_node<set<TType>, real<0>> {
using kary_node<set<TType>, real<0>>::kary_node;
set_max_node(std::string name, value_node<set<TType>>* first, value_node<real<0>>* second) :
binary_node<set<TType>, real<0>>::kary_node(first, second), name(name) {};
struct set_max_node : derived_value_node<set_max_node<TType>, real<0>>, binary_node<set<TType, 0>, real<0>> {
using kary_node<set<TType, 0>, real<0>>::kary_node;
set_max_node(std::string name, value_node<set<TType, 0>>* first, value_node<real<0>>* second) :
binary_node<set<TType, 0>, real<0>>::kary_node(first, second), name(name) {};
std::string name;
};
template <typename TType>
struct forall_node : derived_value_node<forall_node<TType>, boolean<0>>, binary_node<set<TType>, boolean<0>> {
using kary_node<set<TType>, boolean<0>>::kary_node;
forall_node(std::string name, value_node<set<TType>>* first, value_node<boolean<0>>* second) :
binary_node<set<TType>, boolean<0>>::kary_node(first, second), name(name) {};
struct forall_node : derived_value_node<forall_node<TType>, boolean<0>>, binary_node<set<TType, 0>, boolean<0>> {
using kary_node<set<TType, 0>, boolean<0>>::kary_node;
forall_node(std::string name, value_node<set<TType, 0>>* first, value_node<boolean<0>>* second) :
binary_node<set<TType, 0>, boolean<0>>::kary_node(first, second), name(name) {};
std::string name;
};
template <typename TType>
struct indicator_set_node : derived_value_node<indicator_set_node<TType>, set<TType>>, binary_node<set<TType>, boolean<0>> {
using kary_node<set<TType>, boolean<0>>::kary_node;
indicator_set_node(std::string name, value_node<set<TType>>* first, value_node<boolean<0>>* second) :
binary_node<set<TType>, boolean<0>>::kary_node(first, second), name(name) {};
struct indicator_set_node : derived_value_node<indicator_set_node<TType>, set<TType, 0>>, binary_node<set<TType, 0>, boolean<0>> {
using kary_node<set<TType, 0>, boolean<0>>::kary_node;
indicator_set_node(std::string name, value_node<set<TType, 0>>* first, value_node<boolean<0>>* second) :
binary_node<set<TType, 0>, boolean<0>>::kary_node(first, second), name(name) {};
std::string name;
};
......@@ -518,6 +535,7 @@ using ternary_node = kary_node<TType, UType, VType>;
struct mid_node : derived_value_node<mid_node, real<0>>, ternary_node<real<0>, real<0>, real<0>> {using kary_node::kary_node;};
struct bounding_func_node : derived_value_node<bounding_func_node, real<0>>, ternary_node<real<0>, real<0>, real<0>> {using kary_node::kary_node;};
struct squash_node : derived_value_node<squash_node, real<0>>, ternary_node<real<0>, real<0>, real<0>> {using kary_node::kary_node;};
struct regnormal_node : derived_value_node<regnormal_node, real<0>>, ternary_node<real<0>, real<0>, real<0>> {using kary_node::kary_node;};
// quaternary nodes
template <typename TType, typename UType, typename VType, typename WType>
......
......@@ -35,8 +35,9 @@ parser::parser(std::istream& input, symbol_table& symbols)
// special functions
"arh", "xexpy", "xexpax", "xlogx", "xabsx",
"erf", "erfc", "norm2", "sum_div", "xlog_sum",
"pos", "neg", "lb_func", "ub_func", "bounding_func", "squash",
"pos", "neg", "lb_func", "ub_func", "bounding_func", "squash", "regnormal",
"lmtd", "rlmtd", "cost_turton",
"covar_matern_1", "covar_matern_3", "covar_matern_5", "covar_sqrexp", "gpdf",
"nrtl_tau", "nrtl_dtau", "nrtl_g", "nrtl_gtau", "nrtl_gdtau", "nrtl_dgtau",
"antoine_psat", "ext_antoine_psat", "wagner_psat", "ik_cape_psat",
"antoine_tsat",
......@@ -139,7 +140,14 @@ bool parser::match_value(std::unique_ptr<value_node<real<0>>>& result) {
bool parser::match_addition(std::unique_ptr<value_node<real<0>>>& result) {
init();
std::unique_ptr<value_node<real<0>>> child;
if (!match_multiplication(child)) {
if (match(token::MINUS)) {
std::unique_ptr<value_node<real<0>>> mult;
if (!match_multiplication(mult)) {
return reject();
}
child.reset(new minus_node(mult.release()));
}
else if (!match_multiplication(child)) {
return reject();
}
if (!check_any(token::PLUS, token::MINUS)) {
......@@ -222,28 +230,12 @@ bool parser::match_exponentiation(std::unique_ptr<value_node<real<0>>>& result)
bool parser::match_unary(std::unique_ptr<value_node<real<0>>>& result) {
init();
if (match_minus(result)) {
return accept();
}
if (match_primary(result)) {
return accept();
}
return reject();
}
bool parser::match_minus(std::unique_ptr<value_node<real<0>>>& result) {
init();
if (!match(token::MINUS)) {
return reject();
}
std::unique_ptr<value_node<real<0>>> child;
if (!match_unary(child)) {
return reject();
}
result.reset(new minus_node(child.release()));
return accept();
}
bool parser::match_primary(std::unique_ptr<value_node<real<0>>>& result) {
init();
if (match_constant(result)) {
......@@ -309,7 +301,7 @@ bool parser::match_unary_function(std::unique_ptr<value_node<real<0>>>& result)
"tan", "atan", "xlogx", "sqr", "abs", "xabsx", "cosh", "sinh",
"tanh", "coth", "asinh", "acosh", "atanh", "acoth", "inv", "erf", "erfc",
"pos", "neg", "schroeder_ethanol_p", "schroeder_ethanol_rhovap",
"schroeder_ethanol_rholiq"))
"schroeder_ethanol_rholiq", "covar_matern_1", "covar_matern_3", "covar_matern_5", "covar_sqrexp", "gpdf"))
{
return reject();
}
......@@ -438,6 +430,26 @@ bool parser::match_unary_function(std::unique_ptr<value_node<real<0>>>& result)
result.reset(new schroeder_ethanol_rholiq_node(child.release()));
return accept();
}
if (type == "covar_matern_1") {
result.reset(new covar_matern_1_node(child.release()));
return accept();
}
if (type == "covar_matern_3") {
result.reset(new covar_matern_3_node(child.release()));
return accept();
}
if (type == "covar_matern_5") {
result.reset(new covar_matern_5_node(child.release()));
return accept();
}
if (type == "covar_sqrexp") {
result.reset(new covar_sqrexp_node(child.release()));
return accept();
}
if (type == "gpdf") {
result.reset(new gpdf_node(child.release()));
return accept();
}
return reject();
}
......@@ -519,7 +531,7 @@ bool parser::match_binary_function(std::unique_ptr<value_node<real<0>>>& result)
bool parser::match_ternary_function(std::unique_ptr<value_node<real<0>>>& result) {
init();
if (!check_any_keyword("mid", "bounding_func", "squash")) {
if (!check_any_keyword("mid", "bounding_func", "squash", "regnormal")) {
return reject();
}
std::string type = current().lexeme;
......@@ -566,6 +578,12 @@ bool parser::match_ternary_function(std::unique_ptr<value_node<real<0>>>& result
third_child.release()));
return accept();
}
if (type == "regnormal") {
result.reset(new regnormal_node(
first_child.release(), second_child.release(),
third_child.release()));
return accept();
}
return reject();
}
......@@ -1300,7 +1318,14 @@ bool parser::match_value(std::unique_ptr<value_node<index<0>>>& result) {
bool parser::match_addition(std::unique_ptr<value_node<index<0>>>& result) {
init();
std::unique_ptr<value_node<index<0>>> child;
if (!match_multiplication(child)) {
if (match(token::MINUS)) {
std::unique_ptr<value_node<index<0>>> mult;
if (!match_multiplication(mult)) {
return reject();
}
child.reset(new index_minus_node(mult.release()));
}
else if (!match_multiplication(child)) {
return reject();
}
if (!check_any(token::PLUS, token::MINUS)) {
......@@ -1352,28 +1377,12 @@ bool parser::match_multiplication(std::unique_ptr<value_node<index<0>>>& result)
bool parser::match_unary(std::unique_ptr<value_node<index<0>>>& result) {
init();
if (match_minus(result)) {
return accept();
}
if (match_primary(result)) {
return accept();
}
return reject();
}
bool parser::match_minus(std::unique_ptr<value_node<index<0>>>& result) {
init();
if (!match(token::MINUS)) {
return reject();
}
std::unique_ptr<value_node<index<0>>> child;
if (!match_unary(child)) {
return reject();
}
result.reset(new index_minus_node(child.release()));
return accept();
}
bool parser::match_primary(std::unique_ptr<value_node<index<0>>>& result) {
init();
if (match_constant(result)) {
......@@ -1504,7 +1513,7 @@ bool parser::match_element(std::unique_ptr<value_node<boolean<0>>>& result) {
if (!match_keyword("in")) {
return reject();
}
std::unique_ptr<value_node<set<real<0>>>> second_child;
std::unique_ptr<value_node<set<real<0>, 0>>> second_child;
if (!match_value(second_child)) {
return reject();
}
......@@ -1512,7 +1521,7 @@ bool parser::match_element(std::unique_ptr<value_node<boolean<0>>>& result) {
return accept();
}
bool parser::match_primary(std::unique_ptr<value_node<set<real<0>>>>& result) {
bool parser::match_primary(std::unique_ptr<value_node<set<real<0>, 0>>>& result) {
init();
if (match_constant(result)) {
return accept();
......@@ -1520,6 +1529,9 @@ bool parser::match_primary(std::unique_ptr<value_node<set<real<0>>>>& result) {
if (match_parameter(result)) {
return accept();
}
if (match_entry(result)) {
return accept();
}
if (match_indicator_set(result)) {
return accept();
}
......@@ -1527,7 +1539,7 @@ bool parser::match_primary(std::unique_ptr<value_node<set<real<0>>>>& result) {
}
bool parser::match_primary(std::unique_ptr<value_node<set<index<0>>>>& result) {
bool parser::match_primary(std::unique_ptr<value_node<set<index<0>, 0>>>& result) {
init();
if (match_constant(result)) {
return accept();
......@@ -1535,6 +1547,9 @@ bool parser::match_primary(std::unique_ptr<value_node<set<index<0>>>>& result) {
if (match_parameter(result)) {
return accept();
}
if (match_entry(result)) {
return accept();
}
if (match_indicator_set(result)) {
return accept();
}
......
......@@ -67,7 +67,7 @@ class parser {
// generic primary tensor
template <typename TType> bool match_primary(std::unique_ptr<value_node<TType>>&);
// generic primary set
template <typename TType> bool match_primary(std::unique_ptr<value_node<set<TType>>>&);
template <typename TType> bool match_primary(std::unique_ptr<value_node<set<TType, 0>>>&);
// generic primary alternatives
template <typename TType> bool match_constant(std::unique_ptr<value_node<TType>>&);
......@@ -75,14 +75,16 @@ class parser {
template <typename TType> bool match_grouping(std::unique_ptr<value_node<TType>>&);
template <typename TType> bool match_partial_entry(std::unique_ptr<value_node<TType>>&);
template <typename TAtom> bool match_partial_entry(std::unique_ptr<value_node<tensor_type<TAtom, LIBALE_MAX_DIM - 1>>>&);
template <typename TAtom> bool match_partial_entry(std::unique_ptr<value_node<set<TAtom, LIBALE_MAX_SET_DIM - 1>>>&);
template <typename TType> bool match_entry(std::unique_ptr<value_node<TType>>&);
template <typename TAtom> bool match_entry(std::unique_ptr<value_node<tensor_type<TAtom, LIBALE_MAX_DIM - 1>>>&);
template <typename TAtom> bool match_entry(std::unique_ptr<value_node<set<TAtom, LIBALE_MAX_SET_DIM - 1>>>&);
// generic basics
template <typename TAtom, unsigned IDim> bool match_tensor(typename tensor_type<TAtom, IDim>::basic_type&);
template <typename TAtom> bool match_vector(typename tensor_type<TAtom, 1>::basic_type&);
template <typename TAtom> bool match_set(typename set<TAtom>::basic_type&);
template <typename TAtom> bool match_sequence(typename set<TAtom>::basic_type&);
template <typename TAtom> bool match_set(typename set<TAtom, 0>::basic_type&);
template <typename TAtom> bool match_sequence(typename set<TAtom, 0>::basic_type&);
// tag dispatch overloads for match_basic
template <typename TType> struct basic_tag {};
......@@ -91,7 +93,7 @@ class parser {
template <typename TAtom>
bool match_basic(typename tensor_type<TAtom, 1>::basic_type&, basic_tag<tensor_type<TAtom, 1>>);
template <typename TAtom>
bool match_basic(typename set<TAtom>::basic_type&, basic_tag<set<TAtom>>);
bool match_basic(typename set<TAtom, 0>::basic_type&, basic_tag<set<TAtom, 0>>);
inline bool match_basic(typename real<0>::basic_type&, basic_tag<real<0>>);
inline bool match_basic(typename index<0>::basic_type&, basic_tag<index<0>>);
inline bool match_basic(typename boolean<0>::basic_type&, basic_tag<boolean<0>>);
......@@ -110,7 +112,7 @@ class parser {
template <typename TType> bool match_comparison(std::unique_ptr<value_node<boolean<0>>>&);
// sets
template <typename TType> bool match_indicator_set(std::unique_ptr<value_node<set<TType>>>&);
template <typename TType> bool match_indicator_set(std::unique_ptr<value_node<set<TType, 0>>>&);
// quantifiers
template <unsigned IDim> bool match_any_quantifier(std::unique_ptr<value_node<boolean<0>>>&);
......@@ -137,7 +139,6 @@ class parser {
bool match_multiplication(std::unique_ptr<value_node<real<0>>>&);
bool match_exponentiation(std::unique_ptr<value_node<real<0>>>&);
bool match_unary(std::unique_ptr<value_node<real<0>>>&);
bool match_minus(std::unique_ptr<value_node<real<0>>>&);
bool match_primary(std::unique_ptr<value_node<real<0>>>&);
bool match_unary_function(std::unique_ptr<value_node<real<0>>>&);
bool match_binary_function(std::unique_ptr<value_node<real<0>>>&);
......@@ -161,7 +162,6 @@ class parser {
bool match_multiplication(std::unique_ptr<value_node<index<0>>>&);
bool match_unary(std::unique_ptr<value_node<index<0>>>&);
bool match_primary(std::unique_ptr<value_node<index<0>>>&);
bool match_minus(std::unique_ptr<value_node<index<0>>>&);
bool match_value(std::unique_ptr<value_node<boolean<0>>>&);
bool match_disjunction(std::unique_ptr<value_node<boolean<0>>>&);
......@@ -171,9 +171,9 @@ class parser {
bool match_primary(std::unique_ptr<value_node<boolean<0>>>&);
bool match_element(std::unique_ptr<value_node<boolean<0>>>&);
bool match_primary(std::unique_ptr<value_node<set<real<0>>>>&);
bool match_primary(std::unique_ptr<value_node<set<real<0>, 0>>>&);
bool match_primary(std::unique_ptr<value_node<set<index<0>>>>&);
bool match_primary(std::unique_ptr<value_node<set<index<0>, 0>>>&);
// token handling
lexer lex;
......@@ -193,7 +193,6 @@ class parser {
std::ostream& error_stream;
// unexpected token
std::set<std::string> expected;
// std::set<token::token_type> expected;
token unexpected_token;
// unexpected symbol
token unexpected_symbol;
......
......@@ -126,7 +126,7 @@ bool parser::match_primary(std::unique_ptr<value_node<TType>>& result) {
// generic primary set
template <typename TType>
bool parser::match_primary(std::unique_ptr<value_node<set<TType>>>& result) {
bool parser::match_primary(std::unique_ptr<value_node<set<TType, 0>>>& result) {
init();
if (match_constant(result)) {
return accept();
......@@ -134,6 +134,9 @@ bool parser::match_primary(std::unique_ptr<value_node<set<TType>>>& result) {
if (match_parameter(result)) {
return accept();
}
if (match_entry(result)) {
return accept();
}
return reject();
}
......@@ -222,6 +225,28 @@ bool parser::match_partial_entry(std::unique_ptr<value_node<tensor_type<TAtom, L
return reject();
}
template <typename TAtom>
bool parser::match_partial_entry(std::unique_ptr<value_node<set<TAtom, LIBALE_MAX_SET_DIM - 1>>>& result) {
using TType = set<TAtom, LIBALE_MAX_SET_DIM - 1>;
init();
std::unique_ptr<value_node<vector_of<TType>>> first_child;
if (match_value(first_child)) {
if (!match(token::LBRACK)) {
return reject();
}
std::unique_ptr<value_node<index<0>>> second_child;
if (!match_value(second_child)) {
return reject();
}
if (!match(token::COMMA)) {
return reject();
}
result.reset(new entry_node<TType>(first_child.release(), second_child.release()));
return accept();
}
return reject();
}
template <typename TType>
bool parser::match_entry(std::unique_ptr<value_node<TType>>& result) {
init();
......@@ -276,6 +301,28 @@ bool parser::match_entry(std::unique_ptr<value_node<tensor_type<TAtom, LIBALE_MA
return reject();
}
template <typename TAtom>
bool parser::match_entry(std::unique_ptr<value_node<set<TAtom, LIBALE_MAX_SET_DIM - 1>>>& result) {
using TType = set<TAtom, LIBALE_MAX_SET_DIM - 1>;
init();
std::unique_ptr<value_node<vector_of<TType>>> first_child;
if (match_value(first_child)) {
if (!match(token::LBRACK)) {
return reject();
}
std::unique_ptr<value_node<index<0>>> second_child;
if (!match_value(second_child)) {
return reject();
}
if (!match(token::RBRACK)) {
return reject();
}
result.reset(new entry_node<TType>(first_child.release(), second_child.release()));
return accept();
}
return reject();
}
template <typename TType>
bool parser::match_grouping(std::unique_ptr<value_node<TType>>& result) {
init();
......@@ -364,13 +411,13 @@ bool parser::match_vector(typename tensor_type<TAtom, 1>::basic_type& value) {
}
template <typename TAtom>
bool parser::match_set(typename set<TAtom>::basic_type& value) {
bool parser::match_set(typename set<TAtom, 0>::basic_type& value) {
init();
if (!match(token::LBRACE)) {
return reject();
}
typename TAtom::basic_type elem;
typename set<TAtom>::basic_type elements;
typename set<TAtom, 0>::basic_type elements;
if (match_basic<TAtom>(elem)) {
elements.push_back(elem);
while(match(token::COMMA)) {
......@@ -389,12 +436,12 @@ bool parser::match_set(typename set<TAtom>::basic_type& value) {
template <typename TAtom>
bool parser::match_sequence(typename set<TAtom>::basic_type&) {
bool parser::match_sequence(typename set<TAtom, 0>::basic_type&) {
return false;
}
template <>
inline bool parser::match_sequence<index<0>>(typename set<index<0>>::basic_type& value) {
inline bool parser::match_sequence<index<0>>(typename set<index<0>, 0>::basic_type& value) {
init();
if (!match(token::LBRACE)) {
return reject();
......@@ -436,12 +483,12 @@ bool parser::match_basic(typename tensor_type<TAtom, 1>::basic_type& value, basi
}
template <typename TAtom>
bool parser::match_basic(typename set<TAtom>::basic_type& value, basic_tag<set<TAtom>>) {
bool parser::match_basic(typename set<TAtom, 0>::basic_type& value, basic_tag<set<TAtom, 0>>) {
return match_set<TAtom>(value);
}
template <>
inline bool parser::match_basic<index<0>>(typename set<index<0>>::basic_type& value, basic_tag<set<index<0>>>) {
inline bool parser::match_basic<index<0>>(typename set<index<0>, 0>::basic_type& value, basic_tag<set<index<0>, 0>>) {
init();
if (match_set<index<0>>(value)) {
return accept();
......@@ -548,7 +595,7 @@ bool parser::match_sum(std::unique_ptr<value_node<real<0>>>& result) {
if (!match_keyword("in")) {
return reject();
}
std::unique_ptr<value_node<set<TType>>> first_child;
std::unique_ptr<value_node<set<TType, 0>>> first_child;
if (!match_value(first_child)) {