diff --git a/.gitignore b/.gitignore index 15a9d4ddd..8ec195372 100644 --- a/.gitignore +++ b/.gitignore @@ -1,3 +1,4 @@ .DS_Store .ycm_extra_conf.py .ycm_extra_conf.pyc +*.swp diff --git a/.gitmodules b/.gitmodules new file mode 100644 index 000000000..4ed522b98 --- /dev/null +++ b/.gitmodules @@ -0,0 +1,3 @@ +[submodule "cypher/lexertl"] + path = cypher/lexertl + url = https://github.com/BenHanson/lexertl.git diff --git a/cypher/.gitignore b/cypher/.gitignore index 12a485549..eb70c486b 100644 --- a/cypher/.gitignore +++ b/cypher/.gitignore @@ -1,4 +1,3 @@ -lexertl lemon *.o cypher.cpp diff --git a/cypher/Makefile b/cypher/Makefile index d274cb2cd..64df4cfd3 100644 --- a/cypher/Makefile +++ b/cypher/Makefile @@ -17,7 +17,7 @@ cypher.hpp: lemonfiles .PHONY: lemonfiles lemonfiles: cypher.y - lemon/lemon cypher.y -s + lemon cypher.y -s mv cypher.c cypher.cpp .PHONY: clean diff --git a/cypher/lexer.cpp b/cypher/lexer.cpp index 3343198eb..2bda65a18 100644 --- a/cypher/lexer.cpp +++ b/cypher/lexer.cpp @@ -1,6 +1,4 @@ -#include "lexertl/generator.hpp" #include -#include "lexertl/lookup.hpp" #include "cypher_lexer.hpp" diff --git a/cypher/lexer.hpp b/cypher/lexer.hpp index 6a0b15226..c130efc83 100644 --- a/cypher/lexer.hpp +++ b/cypher/lexer.hpp @@ -8,8 +8,8 @@ // auto_ptr > is deprecated #pragma GCC diagnostic push #pragma GCC diagnostic ignored "-Wdeprecated-declarations" -#include "lexertl/generator.hpp" -#include "lexertl/lookup.hpp" +#include "lexertl/lexertl/generator.hpp" +#include "lexertl/lexertl/lookup.hpp" #pragma GCC diagnostic pop #include "errors.hpp" diff --git a/cypher/lexertl b/cypher/lexertl new file mode 160000 index 000000000..5acf39fbe --- /dev/null +++ b/cypher/lexertl @@ -0,0 +1 @@ +Subproject commit 5acf39fbea01eb546edd140ce1334bd53f88928f diff --git a/server/.gitignore b/server/.gitignore new file mode 100644 index 000000000..f47cb2045 --- /dev/null +++ b/server/.gitignore @@ -0,0 +1 @@ +*.out diff --git a/server/README.md b/server/README.md index 8dc47dc28..bb526c2e7 100644 --- a/server/README.md +++ b/server/README.md @@ -2,7 +2,7 @@ * https://github.com/libuv/libuv -```{engine='bash'} +``` sh autogen.sh ./configure make @@ -12,14 +12,20 @@ make install * https://github.com/joyent/http-parser -```{engine='bash'} +``` make make install -stdlib=libstdc++ -lstdc++ (OSX) make install ``` +* https://github.com/c9s/r3 + +``` +brew install r3 (OSX) +``` + ## Test compile -```{engine='bash'} -clang++ -std=c++11 test.cpp -o test -luv -lhttp_parser -I../ -``` \ No newline at end of file +``` +clang++ -std=c++11 test.cpp -o test.out -luv -lhttp_parser -I../ +``` diff --git a/server/application/application.hpp b/server/application/application.hpp new file mode 100644 index 000000000..c14a362c3 --- /dev/null +++ b/server/application/application.hpp @@ -0,0 +1,3 @@ +#include "router.hpp" + +#include "router.inl" diff --git a/server/application/router.hpp b/server/application/router.hpp new file mode 100644 index 000000000..080720045 --- /dev/null +++ b/server/application/router.hpp @@ -0,0 +1,27 @@ +#ifndef MEMGRAPH_SERVER_APPLICATION_ROUTER_HPP +#define MEMGRAPH_SERVER_APPLICATION_ROUTER_HPP + +// TODO: find more appropriate way to include header files +#include "../uv/uv.hpp" +#include "../http/http.hpp" + +namespace application +{ + +// TODO: find out more appropriate name, like express +class Router +{ +private: + uv::UvLoop loop; + http::HttpServer server; + http::Ipv4 ip; +public: + Router(const http::Ipv4& ip); + void get(const std::string path, http::request_cb_t callback); + void listen(); + ~Router(); +}; + +} + +#endif diff --git a/server/application/router.inl b/server/application/router.inl new file mode 100644 index 000000000..1c75f8fb0 --- /dev/null +++ b/server/application/router.inl @@ -0,0 +1,34 @@ +#ifndef MEMGRAPH_SERVER_APPLICATION_ROUTER_INL +#define MEMGRAPH_SERVER_APPLICATION_ROUTER_INL + +#include "router.hpp" + +namespace application +{ + +Router::Router(const http::Ipv4& ip) : server(loop), ip(ip) +{ +} + +void Router::get(const std::string path, http::request_cb_t callback) +{ +} + +void Router::listen() +{ + server.listen(ip, [](http::Request& req, http::Response& res) { + res.send(req.url); + }); + + std::cout << "Server is UP" << std::endl; + + loop.run(uv::UvLoop::Mode::Default); +} + +Router::~Router() +{ +} + +} + +#endif diff --git a/server/test.cpp b/server/test.cpp index d37f236ad..74da0ec95 100644 --- a/server/test.cpp +++ b/server/test.cpp @@ -1,19 +1,13 @@ #include -#include "uvmachine.hpp" +#include "application/application.hpp" int main(void) { - uv::UvLoop loop; - http::HttpServer server(loop); - http::Ipv4 ip("0.0.0.0", 3400); - server.listen(ip, [](http::Request& req, http::Response& res) { - res.send(req.url); - }); - - loop.run(uv::UvLoop::Mode::Default); + application::Router router(ip); + router.listen(); return 0; } diff --git a/server/uvmachine.hpp b/server/uvmachine.hpp deleted file mode 100644 index 980ba1209..000000000 --- a/server/uvmachine.hpp +++ /dev/null @@ -1,2 +0,0 @@ -#include "uv/uv.hpp" -#include "http/http.hpp"