dressipi usecase hardcoded
This commit is contained in:
@@ -674,6 +674,12 @@ void RecordStream<Stream>::write_meta(const std::string &type)
|
||||
HALF_CALL(write_meta(type));
|
||||
}
|
||||
|
||||
template <class Stream>
|
||||
void RecordStream<Stream>::write_failure(const std::map<std::string, std::string> &data)
|
||||
{
|
||||
HALF_CALL(write_failure(data));
|
||||
}
|
||||
|
||||
template <class Stream>
|
||||
void RecordStream<Stream>::send()
|
||||
{
|
||||
|
||||
@@ -19,3 +19,4 @@
|
||||
#include "set.hpp"
|
||||
#include "expr.hpp"
|
||||
#include "with.hpp"
|
||||
#include "functions.hpp"
|
||||
|
||||
@@ -36,6 +36,9 @@ struct Star;
|
||||
struct Slash;
|
||||
struct Rem;
|
||||
|
||||
// functions
|
||||
struct CountFunction;
|
||||
|
||||
struct RelationshipSpecs;
|
||||
struct RelationshipTypeList;
|
||||
struct Relationship;
|
||||
@@ -83,6 +86,7 @@ struct AstVisitor
|
||||
PatternList, Match, ReadQuery, Start, Where, WriteQuery, Create,
|
||||
Return, Distinct, Delete, DeleteQuery, UpdateQuery, Set, SetKey,
|
||||
ReadWriteQuery, IdentifierList, WithList, WithClause, WithQuery, Long,
|
||||
CountFunction,
|
||||
InternalIdExpr, SetValue, SetElement, SetList>
|
||||
{
|
||||
};
|
||||
|
||||
@@ -24,6 +24,16 @@ struct LeafExpr : public ValueExpr<Derived>
|
||||
T value;
|
||||
};
|
||||
|
||||
// T is argument type
|
||||
template <class T, class Derived>
|
||||
struct FunctionExpr : public ValueExpr<Derived>
|
||||
{
|
||||
FunctionExpr(const std::string& name, T argument) : name(name), argument(argument) {}
|
||||
|
||||
std::string name;
|
||||
T argument;
|
||||
};
|
||||
|
||||
template <class Derived>
|
||||
struct BinaryExpr : public ValueExpr<Derived>
|
||||
{
|
||||
@@ -43,4 +53,5 @@ struct PatternExpr : public Expr
|
||||
|
||||
Pattern *pattern;
|
||||
};
|
||||
|
||||
}
|
||||
|
||||
14
src/cypher/ast/functions.hpp
Normal file
14
src/cypher/ast/functions.hpp
Normal file
@@ -0,0 +1,14 @@
|
||||
#pragma once
|
||||
|
||||
#include "expr.hpp"
|
||||
|
||||
namespace ast
|
||||
{
|
||||
|
||||
struct CountFunction : public FunctionExpr<std::string, CountFunction>
|
||||
{
|
||||
CountFunction(const std::string &argument) : FunctionExpr("count", argument)
|
||||
{
|
||||
}
|
||||
};
|
||||
}
|
||||
@@ -495,6 +495,12 @@ pattern_expr(E) ::= pattern(P). {
|
||||
E = ast->create<ast::PatternExpr>(P);
|
||||
}
|
||||
|
||||
%type function_expr {ast::Expr*}
|
||||
|
||||
function_expr(E) ::= COUNT LP IDN(A) RP. {
|
||||
E = ast->create<ast::CountFunction>(A->value);
|
||||
}
|
||||
|
||||
%type expr {ast::Expr*}
|
||||
|
||||
expr(E) ::= value_expr(V). {
|
||||
@@ -505,6 +511,10 @@ expr(E) ::= pattern_expr(P). {
|
||||
E = P;
|
||||
}
|
||||
|
||||
expr(E) ::= function_expr(F). {
|
||||
E = F;
|
||||
}
|
||||
|
||||
//%type alias {ast::Alias*}
|
||||
//
|
||||
//alias(A) ::= IDN(X) AS IDN(Y). {
|
||||
|
||||
@@ -294,6 +294,12 @@ public:
|
||||
Traverser::visit(rem);
|
||||
}
|
||||
|
||||
void visit(ast::CountFunction& count) override
|
||||
{
|
||||
auto entry = printer.advance("Count ");
|
||||
entry << count.name << "(" << count.argument << ")";
|
||||
}
|
||||
|
||||
void visit(ast::PropertyList& prop_list) override
|
||||
{
|
||||
auto entry = printer.advance("Property List");
|
||||
|
||||
@@ -58,6 +58,9 @@ public:
|
||||
rule("(?i:AND)", TK_AND);
|
||||
rule("(?i:OR)", TK_OR);
|
||||
|
||||
// functions
|
||||
rule("(?i:COUNT)", TK_COUNT);
|
||||
|
||||
// string literal TODO single quote escape
|
||||
rule("'(.*?)'", TK_STR);
|
||||
|
||||
|
||||
@@ -154,6 +154,10 @@ public:
|
||||
accept(rem.right);
|
||||
}
|
||||
|
||||
void visit(ast::CountFunction& count) override
|
||||
{
|
||||
}
|
||||
|
||||
void visit(ast::PropertyList& prop_list) override
|
||||
{
|
||||
accept(prop_list.value);
|
||||
|
||||
Reference in New Issue
Block a user