From d7023d54b8bcd0e3e4e90bd3038d710f123243da Mon Sep 17 00:00:00 2001 From: Avi Kivity Date: Fri, 13 Mar 2015 09:51:27 +0200 Subject: [PATCH] cql: enable grammar for set literals --- cql3/Cql.g | 17 ++++++++--------- 1 file changed, 8 insertions(+), 9 deletions(-) diff --git a/cql3/Cql.g b/cql3/Cql.g index 46fbc9d1bc..f78ace0137 100644 --- a/cql3/Cql.g +++ b/cql3/Cql.g @@ -44,6 +44,7 @@ options { #include "cql3/cql3_type.hh" #include "cql3/cf_name.hh" #include "cql3/maps.hh" +#include "cql3/sets.hh" #include "core/sstring.hh" #include "CqlLexer.hpp" @@ -1054,15 +1055,15 @@ mapLiteral returns [shared_ptr map] ; setOrMapLiteral[shared_ptr t] returns [shared_ptr value] - @init{ std::vector, shared_ptr>> m; } + @init{ std::vector, shared_ptr>> m; + std::vector> s; + } : ':' v=term { m.push_back({t, v}); } ( ',' kn=term ':' vn=term { m.push_back({kn, vn}); } )* { $value = ::make_shared(std::move(m)); } -#if 0 - | { List s = new ArrayList(); s.add(t); } - ( ',' tn=term { s.add(tn); } )* - { $value = new Sets.Literal(s); } -#endif + | { s.push_back(t); } + ( ',' tn=term { s.push_back(tn); } )* + { $value = make_shared(cql3::sets::literal(std::move(s))); } ; collectionLiteral returns [shared_ptr value] @@ -1074,9 +1075,7 @@ collectionLiteral returns [shared_ptr value] : '{' t=term v=setOrMapLiteral[t] { $value = v; } '}' // Note that we have an ambiguity between maps and set for "{}". So we force it to a set literal, // and deal with it later based on the type of the column (SetLiteral.java). -#if 0 - | '{' '}' { $value = new Sets.Literal(Collections.emptyList()); } -#endif + | '{' '}' { $value = make_shared(cql3::sets::literal({})); } ; #if 0