From 83607705bc2f9cd7d7147c0c197be696f7de2b19 Mon Sep 17 00:00:00 2001 From: Avi Kivity Date: Thu, 19 Mar 2015 12:40:03 +0200 Subject: [PATCH] cql3: convert lists literal grammar to C++ --- cql3/Cql.g | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) diff --git a/cql3/Cql.g b/cql3/Cql.g index b8ec5c9ba7..68b1b63a4f 100644 --- a/cql3/Cql.g +++ b/cql3/Cql.g @@ -45,6 +45,7 @@ options { #include "cql3/cf_name.hh" #include "cql3/maps.hh" #include "cql3/sets.hh" +#include "cql3/lists.hh" #include "core/sstring.hh" #include "CqlLexer.hpp" @@ -1069,12 +1070,11 @@ setOrMapLiteral[shared_ptr t] returns [shared_ptr value] -#if 0 - : '[' { List l = new ArrayList(); } - ( t1=term { l.add(t1); } ( ',' tn=term { l.add(tn); } )* )? - ']' { $value = new Lists.Literal(l); } -#endif // turn ':' below to '|': - : '{' t=term v=setOrMapLiteral[t] { $value = v; } '}' + @init{ std::vector> l; } + : '[' + ( t1=term { l.push_back(t1); } ( ',' tn=term { l.push_back(tn); } )* )? + ']' { $value = ::make_shared(std::move(l)); } + | '{' 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). | '{' '}' { $value = make_shared(cql3::sets::literal({})); }