-
Notifications
You must be signed in to change notification settings - Fork 64
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Parse complete SPARQL queries using ANTLR (#790)
The ANTLR based parser now parses the complete query string into a `ParsedQuery`. The only thing that is till done via the old parser are FILTERs. Also add many checks for invariants of a valid SPARQL query into the `ParsedQuery` class and improve the unit tests for the parsing.
- Loading branch information
Showing
20 changed files
with
903 additions
and
956 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,30 @@ | ||
// Copyright 2022, University of Freiburg, | ||
// Chair of Algorithms and Data Structures. | ||
// Author: Julian Mundhahs (mundhahj@informatik.uni-freiburg.de) | ||
|
||
#pragma once | ||
|
||
#include "parser/SelectClause.h" | ||
#include "parser/data/Types.h" | ||
|
||
namespace parsedQuery { | ||
struct ConstructClause : ClauseBase { | ||
ad_utility::sparql_types::Triples triples_; | ||
|
||
ConstructClause() = default; | ||
explicit ConstructClause(ad_utility::sparql_types::Triples triples) | ||
: triples_(std::move(triples)) {} | ||
|
||
// Yields all variables that appear in this `ConstructClause`. Variables that | ||
// appear multiple times are also yielded multiple times. | ||
cppcoro::generator<const Variable> containedVariables() const { | ||
for (const auto& triple : triples_) { | ||
for (const auto& varOrTerm : triple) { | ||
if (auto variable = std::get_if<Variable>(&varOrTerm)) { | ||
co_yield *variable; | ||
} | ||
} | ||
} | ||
} | ||
}; | ||
} // namespace parsedQuery |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.