diff --git a/.gitignore b/.gitignore index 870c5b5..1acf416 100644 --- a/.gitignore +++ b/.gitignore @@ -1,91 +1,82 @@ # Compiled Object files *.slo *.lo *.o *.obj # Compiled Dynamic libraries *.so *.so.* *.dylib *.dll # Compiled Static libraries *.lai *.la *.a *.lib # Executables *.exe *.out *.app *.class # Mobile Tools for Java (J2ME) .mtj.tmp/ # Package Files # *.jar *.war *.ear # virtual machine crash logs, see http://www.java.com/en/download/help/error_hotspot.xml hs_err_pid* # Qt-es /.qmake.cache /.qmake.stash *.pro.user *.pro.user.* *.moc moc_*.cpp qrc_*.cpp ui_*.h Makefile* *-build-* # QtCreator *.autosave coco/*.old coco/*~ *~ cpp/build-*/* cpp/xreate-debug/* cpp/xreate-release/* cpp/.idea CMakeLists.txt.user cmake_install.cmake project/* nb*.xml .* target/* /tools/phabricator/xreate-frontend/nbproject/private/ documentation/trash4/ trash/ CMakeFiles/ gen-cpp/ generated-cpp/ gen-php/ generated-js/ books/ build/ coco/Parser.* coco/Scanner.* -cpp/src/compilation/latecontextcompiler.cpp -cpp/src/compilation/latecontextcompiler.h -cpp/src/pass/environmenttestspass.cpp -cpp/src/pass/environmenttestspass.h -cpp/src/query/ptrvalid.cpp -cpp/src/query/ptrvalid.h -cpp/tests/deferred/ -cpp/tests/vendorAPI/ - -scripts/metatests/ +scripts/ tools/phabricator/administration/ diff --git a/cpp/src/CMakeLists.txt b/cpp/src/CMakeLists.txt index 7f4a3bf..e0f83ad 100644 --- a/cpp/src/CMakeLists.txt +++ b/cpp/src/CMakeLists.txt @@ -1,222 +1,215 @@ cmake_minimum_required(VERSION 2.8.11) project(xreate) cmake_policy(SET CMP0022 NEW) message("MODULES" ${CMAKE_MODULE_PATH}) # LLVM #====================== FIND_PACKAGE (LLVM REQUIRED) set(LLVM_VERSION ${LLVM_VERSION_MAJOR}.${LLVM_VERSION_MINOR}) message(STATUS "Found LLVM ${LLVM_PACKAGE_VERSION}") message("LLVM LIB PATH:" ${LLVM_LIBRARY_DIRS}) message(STATUS "Using LLVMConfig.cmake in: ${LLVM_DIR}") INCLUDE_DIRECTORIES(${LLVM_INCLUDE_DIRS}) message(STATUS "INCLUDE DIR: ${LLVM_INCLUDE_DIRS}") add_definitions(${LLVM_DEFINITIONS}) message("LLVM DEFS: " ${LLVM_DEFINITIONS}) llvm_map_components_to_libnames(LLVM_LIBS core nativecodegen native executionengine mcjit support option) message("LLVM LIBS: " ${LLVM_LIBS}) # CLANG #====================== set(CLANG_LIBS clangCodeGen clangASTMatchers clangQuery clangTooling clangFrontend clangSerialization clangDriver clangParse clangSema clangAnalysis clangAST clangEdit clangLex clangBasic ) # POTASSCO #====================== set(POTASSCO_PATH "/opt/potassco/clingo" CACHE PATH "Path to potassco sources") set(POTASSCO_INCLUDE_PATH ${POTASSCO_PATH}/libgringo ${POTASSCO_PATH}/libclasp ${POTASSCO_PATH}/libclingo ${POTASSCO_PATH}/libprogram_opts ${POTASSCO_PATH}/liblp ) INCLUDE_DIRECTORIES(${POTASSCO_INCLUDE_PATH}) set(LIBCLASP_LIBS clingo clasp gringo program_opts reify lp ) message("CLASP LIBS: " ${LIBCLASP_LIBS}) # OTHER DEPENDENCIES #=========================== set(JEAYESON_INCLUDE_PATH ${CMAKE_HOME_DIRECTORY}/../vendors/jeayeson/include/ ) INCLUDE_DIRECTORIES(${JEAYESON_INCLUDE_PATH}) # COCO #=========================== set(COCO_EXECUTABLE "" CACHE PATH "Path to coco executable") set(COCO_FRAMES_PATH "" CACHE PATH "Path to coco frames") set(COCO_GRAMMAR_PATH ${CMAKE_HOME_DIRECTORY}/../coco/) set(COCO_SOURCE_FILES ${COCO_GRAMMAR_PATH}/Parser.cpp ${COCO_GRAMMAR_PATH}/Scanner.cpp) INCLUDE_DIRECTORIES(${COCO_GRAMMAR_PATH}) add_custom_command(OUTPUT ${COCO_SOURCE_FILES} COMMAND ${COCO_GRAMMAR_PATH}/gen-grammar ${COCO_EXECUTABLE} ${COCO_FRAMES_PATH} WORKING_DIRECTORY ${COCO_GRAMMAR_PATH} MAIN_DEPENDENCY ${COCO_GRAMMAR_PATH}/xreate.ATG ) message(STATUS "COCO GRAMMAR BUILD STATUS:" ${COCO_OUTPUT}) # XREATE #====================== set(SOURCE_FILES pass/dfapass.cpp analysis/dfagraph.cpp pass/versionspass.cpp compilation/targetinterpretation.cpp pass/compilepass.cpp attachments.cpp ast.cpp ExternLayer.cpp analysis/cfagraph.cpp analysis/aux.cpp compilation/containers.cpp compilation/advanced.cpp clasplayer.cpp compilation/latecontextcompiler2.cpp query/context.cpp llvmlayer.cpp utils.cpp passmanager-bare.cpp passmanager-full.cpp pass/abstractpass.cpp pass/cfapass.cpp pass/adhocpass.cpp contextrule.cpp query/containers.cpp pass/interpretationpass.cpp analysis/DominatorsTreeAnalysisProvider.cpp serialization/expressionserializer.cpp - - #serialization/expressionserializer2.cpp - #compilation/latecontextcompiler.cpp - #pass/loggerpass.cpp - #compilation/transformations.cpp - #query/ptrvalid.cpp - #pass/rulespass.cpp ) set(XREATE_INCLUDE_DIRS ${CMAKE_CURRENT_SOURCE_DIR}/ ) INCLUDE_DIRECTORIES(${XREATE_INCLUDE_DIRS}) set(XREATE_PRIVATE_INCLUDE_DIRS ${XREATE_INCLUDE_DIRS} ${COCO_GRAMMAR_PATH} ${JEAYESON_INCLUDE_PATH} ${LLVM_INCLUDE_DIRS} ${POTASSCO_INCLUDE_PATH} ) add_library(${PROJECT_NAME} SHARED ${SOURCE_FILES} ${COCO_SOURCE_FILES}) target_link_libraries(${PROJECT_NAME}) target_include_directories(${PROJECT_NAME} INTERFACE ${XREATE_INCLUDE_DIRS} ${COCO_GRAMMAR_PATH} ${JEAYESON_INCLUDE_PATH} ${LLVM_INCLUDE_DIRS} ${POTASSCO_INCLUDE_PATH} ) get_directory_property(DEFINITIONS_ALL DIRECTORY ${CMAKE_CURRENT_SOURCE_DIR} COMPILE_DEFINITIONS) message("definitions all: " ${DEFINITIONS_ALL}) target_compile_definitions(${PROJECT_NAME} INTERFACE ${DEFINITIONS_ALL}) get_directory_property(COMPILATION_OPTIONS_ALL DIRECTORY ${CMAKE_CURRENT_SOURCE_DIR} COMPILE_OPTIONS) message("compilations all: " ${COMPILATION_OPTIONS_ALL}) target_compile_options(${PROJECT_NAME} INTERFACE ${COMPILATION_OPTIONS_ALL}) SET_PROPERTY(TARGET ${PROJECT_NAME} PROPERTY INTERFACE_LINK_LIBRARIES ${LIBCLASP_LIBS} ${CLANG_LIBS} ${LLVM_LIBS} tbb ) #${CLANG_LIBS} #set (LINK_INTERFACE_LIBRARIES "") # FUNCTION(PREPEND var prefix) # SET(listVar "") # FOREACH(f ${ARGN}) # LIST(APPEND listVar "${prefix}/${f}") # ENDFOREACH(f) # SET(${var} "${listVar}" PARENT_SCOPE) # ENDFUNCTION(PREPEND) #set(COTIRE_UNITY_SOURCE_MAXIMUM_NUMBER_OF_INCLUDES "-j4") #cotire(xreate) # MACRO (ADD_PCH_RULE _header_filename _src_list) # SET(_gch_filename "${_header_filename}.gch") # LIST(APPEND ${_src_list} ${_gch_filename}) # SET (_args ${CMAKE_CXX_FLAGS}) # LIST(APPEND _args -c ${_header_filename} -o ${_gch_filename}) # GET_DIRECTORY_PROPERTY(DIRINC INCLUDE_DIRECTORIES) # foreach (_inc ${DIRINC}) # LIST(APPEND _args "-I" ${_inc}) # endforeach(_inc ${DIRINC}) # SEPARATE_ARGUMENTS(_args) # add_custom_command(OUTPUT ${_gch_filename} # COMMAND rm -f ${_gch_filename} # COMMAND ${CMAKE_CXX_COMPILER} ${CMAKE_CXX_COMPILER_ARG1} ${_args} # DEPENDS ${_header_filename}) # ENDMACRO(ADD_PCH_RULE _header_filename _src_list) # ADD_PCH_RULE (${CMAKE_HOME_DIRECTORY}/src/ast.h SOURCE_FILES) # ADD_PCH_RULE (${CMAKE_HOME_DIRECTORY}/src/llvmlayer.h SOURCE_FILES) # ADD_PCH_RULE (${CMAKE_HOME_DIRECTORY}/src/clasplayer.h SOURCE_FILES) # ADD_PCH_RULE (${CMAKE_HOME_DIRECTORY}/src/pass/abstractpass.h SOURCE_FILES) diff --git a/cpp/src/pass/rulespass.cpp b/cpp/src/pass/rulespass.cpp deleted file mode 100644 index a30c100..0000000 --- a/cpp/src/pass/rulespass.cpp +++ /dev/null @@ -1,16 +0,0 @@ -#include "rulespass.h" - -using namespace xreate; - -RulesPass::RulesPass(PassManager* manager) - : ASTPass(manager) -{ - man->registerFilter(this, PassFilter::RULE); -} - -void -RulesPass::process(MetaRuleAbstract* rule, PassContext context) -{ - rule->compile(*man->clasp); -} - diff --git a/cpp/src/pass/rulespass.h b/cpp/src/pass/rulespass.h deleted file mode 100644 index 4bf4b5e..0000000 --- a/cpp/src/pass/rulespass.h +++ /dev/null @@ -1,14 +0,0 @@ -#ifndef RULESPASS_H -#define RULESPASS_H -#include "passmanager.h" - -//DISABLEDFEATURE rulespass -namespace xreate { -class RulesPass : public ASTPass -{ -public: - void process(MetaRuleAbstract* rule, PassContext context); - RulesPass(PassManager* manager); -}; } - -#endif // RULESPASS_H diff --git a/cpp/src/serialization/expressionserializer2.cpp b/cpp/src/serialization/expressionserializer2.cpp deleted file mode 100644 index 5c63641..0000000 --- a/cpp/src/serialization/expressionserializer2.cpp +++ /dev/null @@ -1,98 +0,0 @@ -/* - * ExpressionSerializer2.cpp - * - * Created on: 9 февр. 2016 - * Author: pgess - */ - -#include "expressionserializer2.h" - -using namespace std; - -namespace xreate { - -typedef size_t ElementId; -struct Element{ - string name; - unsigned char degree; - ElementId terminal = 0; - std::list childs; - - bool operator< (const Element& other) { - int cmp = name.compare(other.name); - if (cmp !=0) return (cmp < 0); - return (degree < other.degree); - } - - bool operator== (const Element& other) { - int cmp = name.compare(other.name); - if (cmp != 0) return false; - return degree == other.degree; - } - - Element(string nameElement, unsigned int degreeElement) - : name(nameElement), degree(degreeElement) {} -}; - -const Element End{"", 0}; - -class ExpressionSerializerStrategyB { - vector __registry; - - ElementId push(const Element& e, ElementId rootId){ - typedef list::iterator ElementIt; - - list& elements = __registry[rootId].childs; - list::iterator pos = std::__lower_bound(elements.begin(), elements.end(), e, - [this](const ElementIt& testIt, const Element& value){return __registry[*testIt] < value;}); - - if (!(__registry[*pos] == e)) { - __registry.push_back(e); - ElementId result = __registry.size()-1; - elements.insert(pos, result); - return result; - } - - return *pos; - } - - ElementId registerExpression(const Expression& e, ElementId rootId) { - switch(e.op){ - case Operator::NONE: { - switch (e.__state) { - case Expression::STRING: - case Expression::IDENT: { - const string& name = e.getValueString(); - Element element(name, 0); - ElementId rootId = push(element, rootId); - return rootId; - } - - default: { - break; - } - } - break; - } - - case Operator::CALL: { - const string& name = e.getValueString(); - Element element(name, e.operands.size()); - ElementId rootId = push(element, rootId); - - for (const Expression& op: e.operands){ - Element element(op.getValueString(), op.operands.size()); - rootId = push(element, rootId); - } - - return rootId; - } - - default: break; - } - - assert(false && "Expression too complicate for serialization"); - } -}; - -} /* namespace xreate */ diff --git a/cpp/src/serialization/expressionserializer2.h b/cpp/src/serialization/expressionserializer2.h deleted file mode 100644 index 3b29756..0000000 --- a/cpp/src/serialization/expressionserializer2.h +++ /dev/null @@ -1,25 +0,0 @@ -/* - * ExpressionSerializer2.h - * - * Created on: 9 февр. 2016 - * Author: pgess - */ - -#ifndef EXPRESSIONSERIALIZER2_H_ -#define EXPRESSIONSERIALIZER2_H_ - -#include - -namespace xreate { - -class ExpressionSerializer2 { -public: - ExpressionSerializer2(); - virtual ~ExpressionSerializer2(); - - void registerExpression(const Expression& e); -}; - -} /* namespace xreate */ - -#endif /* EXPRESSIONSERIALIZER2_H_ */ diff --git a/scripts/dsl/regexps.xreate b/scripts/dsl/regexps.xreate deleted file mode 100644 index 684c99b..0000000 --- a/scripts/dsl/regexps.xreate +++ /dev/null @@ -1,76 +0,0 @@ -=========================== - DATA - - -patternAB = [Sequence, - [[ZeroOrMore, "a"], - [Text, "b"]]]. - -========================== - HANDLERS - -Matcher = type variant (Sequence, ZeroOrMore, Text) - -matchSequence = function(text::string, sequence::undef):: int{ - textLength = length(text):: int. - - loop fold(sequence-> matcher:: undef, 0->pos){ - n = match(mid(text, pos, textLength), matcher). - - if (n == pos_FAIL:: break){ - pos - - } else { - pos+n - } - } -} - -matchZeroOrMore= function(text::string, matcher::string):: int{ - textLength = length(text):: int. - - loop fold inf(0->pos, n==pos_FAIL){ //<--- infinite loop? - n = match(matcherChild, mid(text, pos, textLength)). - - if (n == pos_FAIL:: break){ - pos - - } else { - pos+n - } - } -} - -matchText = function(text::string, matcher::string):: int { - textLength = length(text):: int. - - if (length(matcher) <= textLength, mid(text, 0, length(matcher)) == matcher) - { - textLength; - - } else { - pos_FAIL; - } -} - -match = function(text::string, pattern::undef)::string{ - - n = switch (pattern[0]) :: int - case (Sequence) {matchSequence(text, pattern[1])} - case (ZeroOrMore) {matchZeroOrMore(text, pattern[1])} - case (Text) {matchText(text, pattern[1])} - case default {pos_FAIL} - - if (n != pos_FAIL) - {mid(text, 0, n)} - else - {text_FAIL} -} - -================================= - CLIENT - -test = function(){ - match(patternAB, "aaaaab"). - match(patternAB, "baaaaa"). -}