Skip to content
Snippets Groups Projects
Commit 73b9ba37 authored by marco's avatar marco
Browse files

extend query grammar to handle several points in within statement

git-svn-id: https://dng.biozentrum.unibas.ch/svn/openstructure/trunk@2657 5a81b35b-ba03-0410-adc8-b2c5c5119f08
parent 4ac959df
Branches
Tags
No related merge requests found
...@@ -378,7 +378,6 @@ QueryImpl::QueryImpl(const String& query_string) ...@@ -378,7 +378,6 @@ QueryImpl::QueryImpl(const String& query_string)
sel_values_.push_back(sel_value); sel_values_.push_back(sel_value);
Node* ast_root = this->BuildAST(); Node* ast_root = this->BuildAST();
if (ast_root) { if (ast_root) {
// ast_root->Dump();
// Get all selection statements // Get all selection statements
this->ExtractSelStmts(ast_root); this->ExtractSelStmts(ast_root);
this->ASTToSelStack(ast_root,Prop::CHAIN, this->ASTToSelStack(ast_root,Prop::CHAIN,
...@@ -389,6 +388,7 @@ QueryImpl::QueryImpl(const String& query_string) ...@@ -389,6 +388,7 @@ QueryImpl::QueryImpl(const String& query_string)
sel_stacks_[(int)Prop::ATOM]); sel_stacks_[(int)Prop::ATOM]);
delete ast_root; delete ast_root;
empty_optimize_=false; empty_optimize_=false;
has_error_=false;
} else { } else {
has_error_=true; has_error_=true;
} }
...@@ -773,8 +773,9 @@ Node* QueryImpl::ParseSubExpr(QueryLexer& lexer, bool paren) { ...@@ -773,8 +773,9 @@ Node* QueryImpl::ParseSubExpr(QueryLexer& lexer, bool paren) {
error_desc_.range=t.GetRange(); error_desc_.range=t.GetRange();
return NULL; return NULL;
} }
if (t.IsEOF()) if (t.IsEOF()) {
continue; return root_node.release();
}
if (!this->ExpectLogicalOperator(t)) if (!this->ExpectLogicalOperator(t))
return NULL; return NULL;
switch(t.GetType()) { switch(t.GetType()) {
...@@ -958,19 +959,35 @@ Node* QueryImpl::ParseWithinExpr(QueryLexer& lexer) { ...@@ -958,19 +959,35 @@ Node* QueryImpl::ParseWithinExpr(QueryLexer& lexer) {
return NULL; return NULL;
QueryToken ct=lexer.CurrentToken(); QueryToken ct=lexer.CurrentToken();
if (ct.GetType()==tok::LeftCurlyBrace) { if (ct.GetType()==tok::LeftCurlyBrace) {
geom::Vec3 point; Node* points=NULL;
if (this->ParsePoint(lexer, point)) { while (true) {
lexer.NextToken(); geom::Vec3 point;
ParamType pt(WithinParam(point, rv*rv)); if (this->ParsePoint(lexer, point)) {
CompOP comp_op= COP_LE; ParamType pt(WithinParam(point, rv*rv));
if (inversion_stack_.back()) CompOP comp_op= COP_LE;
comp_op=COP_GE; if (inversion_stack_.back())
SelNode* within_node=new SelNode(Prop(Prop::WITHIN, Prop::VEC_DIST, comp_op=COP_GE;
Prop::ATOM), SelNode* within_node=new SelNode(Prop(Prop::WITHIN, Prop::VEC_DIST,
comp_op, pt); Prop::ATOM),
return within_node; comp_op, pt);
} else { if (points) {
return NULL; points=this->Concatenate(points, within_node, LOP_OR);
} else {
points=within_node;
}
QueryToken nt=lexer.NextToken();
if (nt.GetType()==tok::Coma) {
nt=lexer.NextToken();
if (!this->Expect(tok::LeftCurlyBrace, "'{'", nt)) {
delete points;
return NULL;
}
continue;
}
return points;
} else {
return NULL;
}
} }
} else if (ct.GetType()==tok::LeftBracket) { } else if (ct.GetType()==tok::LeftBracket) {
// push false onto inversion stack to make sure we have a proper start for // push false onto inversion stack to make sure we have a proper start for
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment