Skip to content
This repository has been archived by the owner on Aug 15, 2022. It is now read-only.

Commit

Permalink
Partial grammer parsing (#17)
Browse files Browse the repository at this point in the history
* replace tbb queue with boost spsc_queue

* add test

* add test

* implement collections partial parser

* add the grammers for vars

* implement collections partial parser

* change the parsers to accept sparqlQueries

* more changes to the parsers to accept sparqlQueries

* continue change the parsers to accept sparqlQueries

* continue change the parsers to accept sparqlQueries

* fix some bugs

* fix some bugs

* fix big bug

* continue developing the parser for sparql

* continue implementing the sparql triple blocks parser

* fix bugs

* fixed one bug with var storing

* delete unnessery class

* devlop the string parser to accept prefixes before start parsing

* changing the structure

* restructuring

* fix compiling issue on the new structure

* TriplesParser Iterator's field triplesParser was not initialized
additionally changed type to Derived

* use type alias for conditional type

* Fix a bug in grammer preventing multi-part triple blocks to be parsed

* make the pasrser templeting less complex

* solve some problems

* solve some problems

* fix one parsing bug

* Fix Major bug

* A

Co-authored-by: shaheen <[email protected]>
Co-authored-by: Fakhr shaheen <[email protected]>
Co-authored-by: Alexander Bigerl <[email protected]>
  • Loading branch information
4 people authored Dec 13, 2020
1 parent 5ba44dc commit d981920
Show file tree
Hide file tree
Showing 23 changed files with 651 additions and 338 deletions.
6 changes: 3 additions & 3 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
cmake_minimum_required(VERSION 3.12)
project(rdf_parser VERSION 0.9.0)
project(rdf_parser VERSION 0.11.0)
set(CMAKE_CXX_STANDARD 17)


Expand All @@ -14,7 +14,7 @@ set(rdf_parser_INSTALL_CMAKE_DIR "share/rdf_parser/cmake" CACHE STRING "The inst

# define a header-only library
add_library(rdf_parser INTERFACE)
add_library(Dice::rdf_parser ALIAS rdf_parser)
add_library(Dice::rdf_parser ALIAS rdf_parser )

target_include_directories(rdf_parser INTERFACE
$<BUILD_INTERFACE:${CMAKE_CURRENT_SOURCE_DIR}/include>
Expand All @@ -23,7 +23,7 @@ target_include_directories(rdf_parser INTERFACE
target_link_libraries(rdf_parser INTERFACE ${CONAN_LIBS})

# testing
option(rdf_parser_BUILD_TESTS "Build rdf_parser tests." OFF)
option(rdf_parser_BUILD_TESTS "Build rdf_parser tests." ON)
if(rdf_parser_BUILD_TESTS)
enable_testing()
add_subdirectory(tests)
Expand Down
5 changes: 3 additions & 2 deletions conanfile.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,20 +3,21 @@

class RDFParser(ConanFile):
name = "rdf-parser"
version = "0.9"
version = "0.11"
author = "DICE Group <[email protected]>"
description = "RDF parser used by [Tentris](https://github.com/dice-group/tentris). It uses [PEGTL](https://github.com/taocpp/PEGTL), Parsing Expression Grammar Library, to parse RDF files (currently supported: ntriple, turtle). "
homepage = "https://github.com/dice-group/rdf-parser"
url = homepage
license = "AGPL"
topics = ("dice-group", "RDF", "parser", "semantic web", "turtle", "ntriple")
settings = "build_type", "compiler", "os", "arch"
requires = "TBB/2019_U3@conan/stable", "pegtl/2.8.1@taocpp/stable", "gtest/1.8.1@bincrafters/stable", "fmt/6.0.0@bincrafters/stable", "abseil/20181200@bincrafters/stable"
requires = "boost/1.71.0@conan/stable", "pegtl/2.8.1@taocpp/stable", "gtest/1.8.1@bincrafters/stable", "fmt/6.0.0@bincrafters/stable", "abseil/20181200@bincrafters/stable"
generators = "cmake", "cmake_find_package", "cmake_paths"
exports = "LICENSE"
exports_sources = "include/*", "CMakeLists.txt", "cmake/dummy-config.cmake.in"
no_copy_source = True


def package(self):
cmake = CMake(self)
cmake.definitions["rdf_parser_BUILD_TESTS"] = "OFF"
Expand Down
75 changes: 39 additions & 36 deletions include/Dice/rdf_parser/Parser/Turtle/Actions/Actions.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -17,8 +17,8 @@ namespace rdf_parser::Turtle {

template<>
struct action<Grammer::statement> {
template<typename Input, typename Queue>
static void apply(const Input &in, States::State<Queue> &state) {
template<typename Input, typename Queue,bool SparqlQuery>
static void apply(const Input &in, States::State<SparqlQuery,Queue> &state) {

state.syncWithMainThread();

Expand All @@ -27,29 +27,29 @@ namespace rdf_parser::Turtle {



template<>
struct action<Grammer::triple> {
template<bool SparqlQuery>
struct action<Grammer::triple<SparqlQuery>> {
template<typename Input, typename Queue>
static void apply(const Input &in, States::State<Queue> &state) {
static void apply(const Input &in, States::State<SparqlQuery,Queue> &state) {
state.clearTripleParameters();

}
};

template<>
struct action<Grammer::tripleSeq1> {
template<bool SparqlQuery>
struct action<Grammer::tripleSeq1<SparqlQuery>> {
template<typename Input, typename Queue>
static void apply(const Input &in, States::State<Queue> &state) {
static void apply(const Input &in, States::State<SparqlQuery,Queue> &state) {

state.proccessTripleSeq();

}
};

template<>
struct action<Grammer::tripleSeq2> {
template<bool SparqlQuery>
struct action<Grammer::tripleSeq2<SparqlQuery>> {
template<typename Input, typename Queue>
static void apply(const Input &in, States::State<Queue> &state) {
static void apply(const Input &in, States::State<SparqlQuery,Queue> &state) {

//add the unlabeled blank node from BNPL as subject
state.setSubject(state.getFirst_BNPL());
Expand All @@ -60,83 +60,86 @@ namespace rdf_parser::Turtle {
};


template<>
struct action<Grammer::subject> {
template<bool SparqlQuery>
struct action<Grammer::subject<SparqlQuery>> {
template<typename Input, typename Queue>
static void apply(const Input &in, States::State<Queue> &state) {
state.setSubject(state.getTerm());
static void apply(const Input &in, States::State<SparqlQuery,Queue> &state) {
state.setSubject(state.getElement());
}
};

template<>
struct action<Grammer::verb> {
template<bool SparqlQuery>
struct action<Grammer::verb<SparqlQuery>> {
template<typename Input, typename Queue>
static void apply(const Input &in, States::State<Queue> &state) {
static void apply(const Input &in, States::State<SparqlQuery,Queue> &state) {
state.proccessVerb();
}
};

template<>
struct action<Grammer::object> {
template<bool SparqlQuery>
struct action<Grammer::object<SparqlQuery>> {
template<typename Input, typename Queue>
static void apply(const Input &in, States::State<Queue> &state) {
static void apply(const Input &in, States::State<SparqlQuery,Queue> &state) {
state.pushCurrentTermIntoBnpl_collection_list();
}
};


template<>
struct action<Grammer::collectionBegin> {
template<typename Input, typename Queue>
static void apply(const Input &in, States::State<Queue> &state) {
template<typename Input, typename Queue,bool SparqlQuery>
static void apply(const Input &in, States::State<SparqlQuery,Queue> &state) {
state.moveBnpl_collection_listIntoStack();
}
};

template<>
struct action<Grammer::collection> {
template<bool SparqlQuery>
struct action<Grammer::collection<SparqlQuery>> {
template<typename Input, typename Queue>
static void apply(const Input &in, States::State<Queue> &state) {
static void apply(const Input &in, States::State<SparqlQuery,Queue> &state) {
state.proccessCollection();
}
};

template<>
struct action<Grammer::blankNodePropertyListBegin> {
template<typename Input, typename Queue>
static void apply(const Input &in, States::State<Queue> &state) {
template<typename Input, typename Queue,bool SparqlQuery>
static void apply(const Input &in, States::State<SparqlQuery,Queue> &state) {
state.moveBnpl_collection_listIntoStack();
}
};

template<>
struct action<Grammer::blankNodePropertyList> {
template<bool SparqlQuery>
struct action<Grammer::blankNodePropertyList<SparqlQuery>> {
template<typename Input, typename Queue>
static void apply(const Input &in, States::State<Queue> &state) {
static void apply(const Input &in, States::State<SparqlQuery,Queue> &state) {
state.proccessBlankNodePropertyList();
}
};


template<>
struct action<Grammer::predicateObjectListInner> {
template<bool SparqlQuery>
struct action<Grammer::predicateObjectListInner<SparqlQuery> > {
template<typename Input, typename Queue>
static void apply(const Input &in, States::State<Queue> &state) {
static void apply(const Input &in, States::State<SparqlQuery,Queue> &state) {
state.proccessPredicateObjectListInner();
}
};


template<>
struct action<Grammer::turtleDoc> {
template<typename Input, typename Queue>
static void apply(const Input &in, States::State<Queue> &state) {
template<typename Input, typename Queue,bool SparqlQuery>
static void apply(const Input &in, States::State<SparqlQuery,Queue> &state) {
//Here parsingIsDone lock is set to true
state.setPasrsingIsDone();
}
};





}
}

Expand Down
Loading

0 comments on commit d981920

Please sign in to comment.