grammar refactoring: build_visitor fixed & visitors tested

This commit is contained in:
ProgramSnail 2023-04-11 13:49:22 +03:00
parent 3c2d496a85
commit e4802896bd
35 changed files with 118128 additions and 91770 deletions

File diff suppressed because it is too large Load diff

View file

@ -0,0 +1,781 @@
{
"inputs" :
[
{
"path" : "CMakeLists.txt"
},
{
"isCMake" : true,
"isExternal" : true,
"path" : "/home/snaillum/Applications/clion-2023.1/bin/cmake/linux/x64/share/cmake-3.25/Modules/CMakeDetermineSystem.cmake"
},
{
"isCMake" : true,
"isExternal" : true,
"path" : "/home/snaillum/Applications/clion-2023.1/bin/cmake/linux/x64/share/cmake-3.25/Modules/CMakeSystem.cmake.in"
},
{
"isGenerated" : true,
"path" : "cmake-build-debug/CMakeFiles/3.25.2/CMakeSystem.cmake"
},
{
"isCMake" : true,
"isExternal" : true,
"path" : "/home/snaillum/Applications/clion-2023.1/bin/cmake/linux/x64/share/cmake-3.25/Modules/CMakeSystemSpecificInitialize.cmake"
},
{
"isCMake" : true,
"isExternal" : true,
"path" : "/home/snaillum/Applications/clion-2023.1/bin/cmake/linux/x64/share/cmake-3.25/Modules/CMakeDetermineCCompiler.cmake"
},
{
"isCMake" : true,
"isExternal" : true,
"path" : "/home/snaillum/Applications/clion-2023.1/bin/cmake/linux/x64/share/cmake-3.25/Modules/CMakeDetermineCompiler.cmake"
},
{
"isCMake" : true,
"isExternal" : true,
"path" : "/home/snaillum/Applications/clion-2023.1/bin/cmake/linux/x64/share/cmake-3.25/Modules/CMakeDetermineCompilerId.cmake"
},
{
"isCMake" : true,
"isExternal" : true,
"path" : "/home/snaillum/Applications/clion-2023.1/bin/cmake/linux/x64/share/cmake-3.25/Modules/CMakeCompilerIdDetection.cmake"
},
{
"isCMake" : true,
"isExternal" : true,
"path" : "/home/snaillum/Applications/clion-2023.1/bin/cmake/linux/x64/share/cmake-3.25/Modules/Compiler/ADSP-DetermineCompiler.cmake"
},
{
"isCMake" : true,
"isExternal" : true,
"path" : "/home/snaillum/Applications/clion-2023.1/bin/cmake/linux/x64/share/cmake-3.25/Modules/Compiler/ARMCC-DetermineCompiler.cmake"
},
{
"isCMake" : true,
"isExternal" : true,
"path" : "/home/snaillum/Applications/clion-2023.1/bin/cmake/linux/x64/share/cmake-3.25/Modules/Compiler/ARMClang-DetermineCompiler.cmake"
},
{
"isCMake" : true,
"isExternal" : true,
"path" : "/home/snaillum/Applications/clion-2023.1/bin/cmake/linux/x64/share/cmake-3.25/Modules/Compiler/AppleClang-DetermineCompiler.cmake"
},
{
"isCMake" : true,
"isExternal" : true,
"path" : "/home/snaillum/Applications/clion-2023.1/bin/cmake/linux/x64/share/cmake-3.25/Modules/Compiler/Clang-DetermineCompilerInternal.cmake"
},
{
"isCMake" : true,
"isExternal" : true,
"path" : "/home/snaillum/Applications/clion-2023.1/bin/cmake/linux/x64/share/cmake-3.25/Modules/Compiler/Borland-DetermineCompiler.cmake"
},
{
"isCMake" : true,
"isExternal" : true,
"path" : "/home/snaillum/Applications/clion-2023.1/bin/cmake/linux/x64/share/cmake-3.25/Modules/Compiler/Bruce-C-DetermineCompiler.cmake"
},
{
"isCMake" : true,
"isExternal" : true,
"path" : "/home/snaillum/Applications/clion-2023.1/bin/cmake/linux/x64/share/cmake-3.25/Modules/Compiler/Clang-DetermineCompiler.cmake"
},
{
"isCMake" : true,
"isExternal" : true,
"path" : "/home/snaillum/Applications/clion-2023.1/bin/cmake/linux/x64/share/cmake-3.25/Modules/Compiler/Clang-DetermineCompilerInternal.cmake"
},
{
"isCMake" : true,
"isExternal" : true,
"path" : "/home/snaillum/Applications/clion-2023.1/bin/cmake/linux/x64/share/cmake-3.25/Modules/Compiler/Compaq-C-DetermineCompiler.cmake"
},
{
"isCMake" : true,
"isExternal" : true,
"path" : "/home/snaillum/Applications/clion-2023.1/bin/cmake/linux/x64/share/cmake-3.25/Modules/Compiler/Cray-DetermineCompiler.cmake"
},
{
"isCMake" : true,
"isExternal" : true,
"path" : "/home/snaillum/Applications/clion-2023.1/bin/cmake/linux/x64/share/cmake-3.25/Modules/Compiler/Embarcadero-DetermineCompiler.cmake"
},
{
"isCMake" : true,
"isExternal" : true,
"path" : "/home/snaillum/Applications/clion-2023.1/bin/cmake/linux/x64/share/cmake-3.25/Modules/Compiler/Fujitsu-DetermineCompiler.cmake"
},
{
"isCMake" : true,
"isExternal" : true,
"path" : "/home/snaillum/Applications/clion-2023.1/bin/cmake/linux/x64/share/cmake-3.25/Modules/Compiler/FujitsuClang-DetermineCompiler.cmake"
},
{
"isCMake" : true,
"isExternal" : true,
"path" : "/home/snaillum/Applications/clion-2023.1/bin/cmake/linux/x64/share/cmake-3.25/Modules/Compiler/GHS-DetermineCompiler.cmake"
},
{
"isCMake" : true,
"isExternal" : true,
"path" : "/home/snaillum/Applications/clion-2023.1/bin/cmake/linux/x64/share/cmake-3.25/Modules/Compiler/GNU-C-DetermineCompiler.cmake"
},
{
"isCMake" : true,
"isExternal" : true,
"path" : "/home/snaillum/Applications/clion-2023.1/bin/cmake/linux/x64/share/cmake-3.25/Modules/Compiler/HP-C-DetermineCompiler.cmake"
},
{
"isCMake" : true,
"isExternal" : true,
"path" : "/home/snaillum/Applications/clion-2023.1/bin/cmake/linux/x64/share/cmake-3.25/Modules/Compiler/IAR-DetermineCompiler.cmake"
},
{
"isCMake" : true,
"isExternal" : true,
"path" : "/home/snaillum/Applications/clion-2023.1/bin/cmake/linux/x64/share/cmake-3.25/Modules/Compiler/IBMClang-C-DetermineCompiler.cmake"
},
{
"isCMake" : true,
"isExternal" : true,
"path" : "/home/snaillum/Applications/clion-2023.1/bin/cmake/linux/x64/share/cmake-3.25/Modules/Compiler/Intel-DetermineCompiler.cmake"
},
{
"isCMake" : true,
"isExternal" : true,
"path" : "/home/snaillum/Applications/clion-2023.1/bin/cmake/linux/x64/share/cmake-3.25/Modules/Compiler/IntelLLVM-DetermineCompiler.cmake"
},
{
"isCMake" : true,
"isExternal" : true,
"path" : "/home/snaillum/Applications/clion-2023.1/bin/cmake/linux/x64/share/cmake-3.25/Modules/Compiler/LCC-C-DetermineCompiler.cmake"
},
{
"isCMake" : true,
"isExternal" : true,
"path" : "/home/snaillum/Applications/clion-2023.1/bin/cmake/linux/x64/share/cmake-3.25/Modules/Compiler/MSVC-DetermineCompiler.cmake"
},
{
"isCMake" : true,
"isExternal" : true,
"path" : "/home/snaillum/Applications/clion-2023.1/bin/cmake/linux/x64/share/cmake-3.25/Modules/Compiler/NVHPC-DetermineCompiler.cmake"
},
{
"isCMake" : true,
"isExternal" : true,
"path" : "/home/snaillum/Applications/clion-2023.1/bin/cmake/linux/x64/share/cmake-3.25/Modules/Compiler/NVIDIA-DetermineCompiler.cmake"
},
{
"isCMake" : true,
"isExternal" : true,
"path" : "/home/snaillum/Applications/clion-2023.1/bin/cmake/linux/x64/share/cmake-3.25/Modules/Compiler/OpenWatcom-DetermineCompiler.cmake"
},
{
"isCMake" : true,
"isExternal" : true,
"path" : "/home/snaillum/Applications/clion-2023.1/bin/cmake/linux/x64/share/cmake-3.25/Modules/Compiler/PGI-DetermineCompiler.cmake"
},
{
"isCMake" : true,
"isExternal" : true,
"path" : "/home/snaillum/Applications/clion-2023.1/bin/cmake/linux/x64/share/cmake-3.25/Modules/Compiler/PathScale-DetermineCompiler.cmake"
},
{
"isCMake" : true,
"isExternal" : true,
"path" : "/home/snaillum/Applications/clion-2023.1/bin/cmake/linux/x64/share/cmake-3.25/Modules/Compiler/SCO-DetermineCompiler.cmake"
},
{
"isCMake" : true,
"isExternal" : true,
"path" : "/home/snaillum/Applications/clion-2023.1/bin/cmake/linux/x64/share/cmake-3.25/Modules/Compiler/SDCC-C-DetermineCompiler.cmake"
},
{
"isCMake" : true,
"isExternal" : true,
"path" : "/home/snaillum/Applications/clion-2023.1/bin/cmake/linux/x64/share/cmake-3.25/Modules/Compiler/SunPro-C-DetermineCompiler.cmake"
},
{
"isCMake" : true,
"isExternal" : true,
"path" : "/home/snaillum/Applications/clion-2023.1/bin/cmake/linux/x64/share/cmake-3.25/Modules/Compiler/TI-DetermineCompiler.cmake"
},
{
"isCMake" : true,
"isExternal" : true,
"path" : "/home/snaillum/Applications/clion-2023.1/bin/cmake/linux/x64/share/cmake-3.25/Modules/Compiler/Tasking-DetermineCompiler.cmake"
},
{
"isCMake" : true,
"isExternal" : true,
"path" : "/home/snaillum/Applications/clion-2023.1/bin/cmake/linux/x64/share/cmake-3.25/Modules/Compiler/TinyCC-C-DetermineCompiler.cmake"
},
{
"isCMake" : true,
"isExternal" : true,
"path" : "/home/snaillum/Applications/clion-2023.1/bin/cmake/linux/x64/share/cmake-3.25/Modules/Compiler/VisualAge-C-DetermineCompiler.cmake"
},
{
"isCMake" : true,
"isExternal" : true,
"path" : "/home/snaillum/Applications/clion-2023.1/bin/cmake/linux/x64/share/cmake-3.25/Modules/Compiler/IBMCPP-C-DetermineVersionInternal.cmake"
},
{
"isCMake" : true,
"isExternal" : true,
"path" : "/home/snaillum/Applications/clion-2023.1/bin/cmake/linux/x64/share/cmake-3.25/Modules/Compiler/Watcom-DetermineCompiler.cmake"
},
{
"isCMake" : true,
"isExternal" : true,
"path" : "/home/snaillum/Applications/clion-2023.1/bin/cmake/linux/x64/share/cmake-3.25/Modules/Compiler/XL-C-DetermineCompiler.cmake"
},
{
"isCMake" : true,
"isExternal" : true,
"path" : "/home/snaillum/Applications/clion-2023.1/bin/cmake/linux/x64/share/cmake-3.25/Modules/Compiler/IBMCPP-C-DetermineVersionInternal.cmake"
},
{
"isCMake" : true,
"isExternal" : true,
"path" : "/home/snaillum/Applications/clion-2023.1/bin/cmake/linux/x64/share/cmake-3.25/Modules/Compiler/XLClang-C-DetermineCompiler.cmake"
},
{
"isCMake" : true,
"isExternal" : true,
"path" : "/home/snaillum/Applications/clion-2023.1/bin/cmake/linux/x64/share/cmake-3.25/Modules/Compiler/zOS-C-DetermineCompiler.cmake"
},
{
"isCMake" : true,
"isExternal" : true,
"path" : "/home/snaillum/Applications/clion-2023.1/bin/cmake/linux/x64/share/cmake-3.25/Modules/Compiler/IBMCPP-C-DetermineVersionInternal.cmake"
},
{
"isCMake" : true,
"isExternal" : true,
"path" : "/home/snaillum/Applications/clion-2023.1/bin/cmake/linux/x64/share/cmake-3.25/Modules/CMakeFindBinUtils.cmake"
},
{
"isCMake" : true,
"isExternal" : true,
"path" : "/home/snaillum/Applications/clion-2023.1/bin/cmake/linux/x64/share/cmake-3.25/Modules/Compiler/Clang-FindBinUtils.cmake"
},
{
"isCMake" : true,
"isExternal" : true,
"path" : "/home/snaillum/Applications/clion-2023.1/bin/cmake/linux/x64/share/cmake-3.25/Modules/CMakeCCompiler.cmake.in"
},
{
"isGenerated" : true,
"path" : "cmake-build-debug/CMakeFiles/3.25.2/CMakeCCompiler.cmake"
},
{
"isCMake" : true,
"isExternal" : true,
"path" : "/home/snaillum/Applications/clion-2023.1/bin/cmake/linux/x64/share/cmake-3.25/Modules/CMakeDetermineCXXCompiler.cmake"
},
{
"isCMake" : true,
"isExternal" : true,
"path" : "/home/snaillum/Applications/clion-2023.1/bin/cmake/linux/x64/share/cmake-3.25/Modules/CMakeDetermineCompiler.cmake"
},
{
"isCMake" : true,
"isExternal" : true,
"path" : "/home/snaillum/Applications/clion-2023.1/bin/cmake/linux/x64/share/cmake-3.25/Modules/Platform/Linux-Determine-CXX.cmake"
},
{
"isCMake" : true,
"isExternal" : true,
"path" : "/home/snaillum/Applications/clion-2023.1/bin/cmake/linux/x64/share/cmake-3.25/Modules/CMakeDetermineCompilerId.cmake"
},
{
"isCMake" : true,
"isExternal" : true,
"path" : "/home/snaillum/Applications/clion-2023.1/bin/cmake/linux/x64/share/cmake-3.25/Modules/CMakeCompilerIdDetection.cmake"
},
{
"isCMake" : true,
"isExternal" : true,
"path" : "/home/snaillum/Applications/clion-2023.1/bin/cmake/linux/x64/share/cmake-3.25/Modules/Compiler/ADSP-DetermineCompiler.cmake"
},
{
"isCMake" : true,
"isExternal" : true,
"path" : "/home/snaillum/Applications/clion-2023.1/bin/cmake/linux/x64/share/cmake-3.25/Modules/Compiler/ARMCC-DetermineCompiler.cmake"
},
{
"isCMake" : true,
"isExternal" : true,
"path" : "/home/snaillum/Applications/clion-2023.1/bin/cmake/linux/x64/share/cmake-3.25/Modules/Compiler/ARMClang-DetermineCompiler.cmake"
},
{
"isCMake" : true,
"isExternal" : true,
"path" : "/home/snaillum/Applications/clion-2023.1/bin/cmake/linux/x64/share/cmake-3.25/Modules/Compiler/AppleClang-DetermineCompiler.cmake"
},
{
"isCMake" : true,
"isExternal" : true,
"path" : "/home/snaillum/Applications/clion-2023.1/bin/cmake/linux/x64/share/cmake-3.25/Modules/Compiler/Clang-DetermineCompilerInternal.cmake"
},
{
"isCMake" : true,
"isExternal" : true,
"path" : "/home/snaillum/Applications/clion-2023.1/bin/cmake/linux/x64/share/cmake-3.25/Modules/Compiler/Borland-DetermineCompiler.cmake"
},
{
"isCMake" : true,
"isExternal" : true,
"path" : "/home/snaillum/Applications/clion-2023.1/bin/cmake/linux/x64/share/cmake-3.25/Modules/Compiler/Clang-DetermineCompiler.cmake"
},
{
"isCMake" : true,
"isExternal" : true,
"path" : "/home/snaillum/Applications/clion-2023.1/bin/cmake/linux/x64/share/cmake-3.25/Modules/Compiler/Clang-DetermineCompilerInternal.cmake"
},
{
"isCMake" : true,
"isExternal" : true,
"path" : "/home/snaillum/Applications/clion-2023.1/bin/cmake/linux/x64/share/cmake-3.25/Modules/Compiler/Comeau-CXX-DetermineCompiler.cmake"
},
{
"isCMake" : true,
"isExternal" : true,
"path" : "/home/snaillum/Applications/clion-2023.1/bin/cmake/linux/x64/share/cmake-3.25/Modules/Compiler/Compaq-CXX-DetermineCompiler.cmake"
},
{
"isCMake" : true,
"isExternal" : true,
"path" : "/home/snaillum/Applications/clion-2023.1/bin/cmake/linux/x64/share/cmake-3.25/Modules/Compiler/Cray-DetermineCompiler.cmake"
},
{
"isCMake" : true,
"isExternal" : true,
"path" : "/home/snaillum/Applications/clion-2023.1/bin/cmake/linux/x64/share/cmake-3.25/Modules/Compiler/Embarcadero-DetermineCompiler.cmake"
},
{
"isCMake" : true,
"isExternal" : true,
"path" : "/home/snaillum/Applications/clion-2023.1/bin/cmake/linux/x64/share/cmake-3.25/Modules/Compiler/Fujitsu-DetermineCompiler.cmake"
},
{
"isCMake" : true,
"isExternal" : true,
"path" : "/home/snaillum/Applications/clion-2023.1/bin/cmake/linux/x64/share/cmake-3.25/Modules/Compiler/FujitsuClang-DetermineCompiler.cmake"
},
{
"isCMake" : true,
"isExternal" : true,
"path" : "/home/snaillum/Applications/clion-2023.1/bin/cmake/linux/x64/share/cmake-3.25/Modules/Compiler/GHS-DetermineCompiler.cmake"
},
{
"isCMake" : true,
"isExternal" : true,
"path" : "/home/snaillum/Applications/clion-2023.1/bin/cmake/linux/x64/share/cmake-3.25/Modules/Compiler/GNU-CXX-DetermineCompiler.cmake"
},
{
"isCMake" : true,
"isExternal" : true,
"path" : "/home/snaillum/Applications/clion-2023.1/bin/cmake/linux/x64/share/cmake-3.25/Modules/Compiler/HP-CXX-DetermineCompiler.cmake"
},
{
"isCMake" : true,
"isExternal" : true,
"path" : "/home/snaillum/Applications/clion-2023.1/bin/cmake/linux/x64/share/cmake-3.25/Modules/Compiler/IAR-DetermineCompiler.cmake"
},
{
"isCMake" : true,
"isExternal" : true,
"path" : "/home/snaillum/Applications/clion-2023.1/bin/cmake/linux/x64/share/cmake-3.25/Modules/Compiler/IBMClang-CXX-DetermineCompiler.cmake"
},
{
"isCMake" : true,
"isExternal" : true,
"path" : "/home/snaillum/Applications/clion-2023.1/bin/cmake/linux/x64/share/cmake-3.25/Modules/Compiler/Intel-DetermineCompiler.cmake"
},
{
"isCMake" : true,
"isExternal" : true,
"path" : "/home/snaillum/Applications/clion-2023.1/bin/cmake/linux/x64/share/cmake-3.25/Modules/Compiler/IntelLLVM-DetermineCompiler.cmake"
},
{
"isCMake" : true,
"isExternal" : true,
"path" : "/home/snaillum/Applications/clion-2023.1/bin/cmake/linux/x64/share/cmake-3.25/Modules/Compiler/LCC-CXX-DetermineCompiler.cmake"
},
{
"isCMake" : true,
"isExternal" : true,
"path" : "/home/snaillum/Applications/clion-2023.1/bin/cmake/linux/x64/share/cmake-3.25/Modules/Compiler/MSVC-DetermineCompiler.cmake"
},
{
"isCMake" : true,
"isExternal" : true,
"path" : "/home/snaillum/Applications/clion-2023.1/bin/cmake/linux/x64/share/cmake-3.25/Modules/Compiler/NVHPC-DetermineCompiler.cmake"
},
{
"isCMake" : true,
"isExternal" : true,
"path" : "/home/snaillum/Applications/clion-2023.1/bin/cmake/linux/x64/share/cmake-3.25/Modules/Compiler/NVIDIA-DetermineCompiler.cmake"
},
{
"isCMake" : true,
"isExternal" : true,
"path" : "/home/snaillum/Applications/clion-2023.1/bin/cmake/linux/x64/share/cmake-3.25/Modules/Compiler/OpenWatcom-DetermineCompiler.cmake"
},
{
"isCMake" : true,
"isExternal" : true,
"path" : "/home/snaillum/Applications/clion-2023.1/bin/cmake/linux/x64/share/cmake-3.25/Modules/Compiler/PGI-DetermineCompiler.cmake"
},
{
"isCMake" : true,
"isExternal" : true,
"path" : "/home/snaillum/Applications/clion-2023.1/bin/cmake/linux/x64/share/cmake-3.25/Modules/Compiler/PathScale-DetermineCompiler.cmake"
},
{
"isCMake" : true,
"isExternal" : true,
"path" : "/home/snaillum/Applications/clion-2023.1/bin/cmake/linux/x64/share/cmake-3.25/Modules/Compiler/SCO-DetermineCompiler.cmake"
},
{
"isCMake" : true,
"isExternal" : true,
"path" : "/home/snaillum/Applications/clion-2023.1/bin/cmake/linux/x64/share/cmake-3.25/Modules/Compiler/SunPro-CXX-DetermineCompiler.cmake"
},
{
"isCMake" : true,
"isExternal" : true,
"path" : "/home/snaillum/Applications/clion-2023.1/bin/cmake/linux/x64/share/cmake-3.25/Modules/Compiler/TI-DetermineCompiler.cmake"
},
{
"isCMake" : true,
"isExternal" : true,
"path" : "/home/snaillum/Applications/clion-2023.1/bin/cmake/linux/x64/share/cmake-3.25/Modules/Compiler/Tasking-DetermineCompiler.cmake"
},
{
"isCMake" : true,
"isExternal" : true,
"path" : "/home/snaillum/Applications/clion-2023.1/bin/cmake/linux/x64/share/cmake-3.25/Modules/Compiler/VisualAge-CXX-DetermineCompiler.cmake"
},
{
"isCMake" : true,
"isExternal" : true,
"path" : "/home/snaillum/Applications/clion-2023.1/bin/cmake/linux/x64/share/cmake-3.25/Modules/Compiler/IBMCPP-CXX-DetermineVersionInternal.cmake"
},
{
"isCMake" : true,
"isExternal" : true,
"path" : "/home/snaillum/Applications/clion-2023.1/bin/cmake/linux/x64/share/cmake-3.25/Modules/Compiler/Watcom-DetermineCompiler.cmake"
},
{
"isCMake" : true,
"isExternal" : true,
"path" : "/home/snaillum/Applications/clion-2023.1/bin/cmake/linux/x64/share/cmake-3.25/Modules/Compiler/XL-CXX-DetermineCompiler.cmake"
},
{
"isCMake" : true,
"isExternal" : true,
"path" : "/home/snaillum/Applications/clion-2023.1/bin/cmake/linux/x64/share/cmake-3.25/Modules/Compiler/IBMCPP-CXX-DetermineVersionInternal.cmake"
},
{
"isCMake" : true,
"isExternal" : true,
"path" : "/home/snaillum/Applications/clion-2023.1/bin/cmake/linux/x64/share/cmake-3.25/Modules/Compiler/XLClang-CXX-DetermineCompiler.cmake"
},
{
"isCMake" : true,
"isExternal" : true,
"path" : "/home/snaillum/Applications/clion-2023.1/bin/cmake/linux/x64/share/cmake-3.25/Modules/Compiler/zOS-CXX-DetermineCompiler.cmake"
},
{
"isCMake" : true,
"isExternal" : true,
"path" : "/home/snaillum/Applications/clion-2023.1/bin/cmake/linux/x64/share/cmake-3.25/Modules/Compiler/IBMCPP-CXX-DetermineVersionInternal.cmake"
},
{
"isCMake" : true,
"isExternal" : true,
"path" : "/home/snaillum/Applications/clion-2023.1/bin/cmake/linux/x64/share/cmake-3.25/Modules/CMakeFindBinUtils.cmake"
},
{
"isCMake" : true,
"isExternal" : true,
"path" : "/home/snaillum/Applications/clion-2023.1/bin/cmake/linux/x64/share/cmake-3.25/Modules/Compiler/Clang-FindBinUtils.cmake"
},
{
"isCMake" : true,
"isExternal" : true,
"path" : "/home/snaillum/Applications/clion-2023.1/bin/cmake/linux/x64/share/cmake-3.25/Modules/CMakeCXXCompiler.cmake.in"
},
{
"isGenerated" : true,
"path" : "cmake-build-debug/CMakeFiles/3.25.2/CMakeCXXCompiler.cmake"
},
{
"isCMake" : true,
"isExternal" : true,
"path" : "/home/snaillum/Applications/clion-2023.1/bin/cmake/linux/x64/share/cmake-3.25/Modules/CMakeSystemSpecificInformation.cmake"
},
{
"isCMake" : true,
"isExternal" : true,
"path" : "/home/snaillum/Applications/clion-2023.1/bin/cmake/linux/x64/share/cmake-3.25/Modules/CMakeGenericSystem.cmake"
},
{
"isCMake" : true,
"isExternal" : true,
"path" : "/home/snaillum/Applications/clion-2023.1/bin/cmake/linux/x64/share/cmake-3.25/Modules/CMakeInitializeConfigs.cmake"
},
{
"isCMake" : true,
"isExternal" : true,
"path" : "/home/snaillum/Applications/clion-2023.1/bin/cmake/linux/x64/share/cmake-3.25/Modules/Platform/Linux.cmake"
},
{
"isCMake" : true,
"isExternal" : true,
"path" : "/home/snaillum/Applications/clion-2023.1/bin/cmake/linux/x64/share/cmake-3.25/Modules/Platform/UnixPaths.cmake"
},
{
"isCMake" : true,
"isExternal" : true,
"path" : "/home/snaillum/Applications/clion-2023.1/bin/cmake/linux/x64/share/cmake-3.25/Modules/CMakeCInformation.cmake"
},
{
"isCMake" : true,
"isExternal" : true,
"path" : "/home/snaillum/Applications/clion-2023.1/bin/cmake/linux/x64/share/cmake-3.25/Modules/CMakeLanguageInformation.cmake"
},
{
"isCMake" : true,
"isExternal" : true,
"path" : "/home/snaillum/Applications/clion-2023.1/bin/cmake/linux/x64/share/cmake-3.25/Modules/Compiler/Clang-C.cmake"
},
{
"isCMake" : true,
"isExternal" : true,
"path" : "/home/snaillum/Applications/clion-2023.1/bin/cmake/linux/x64/share/cmake-3.25/Modules/Compiler/Clang.cmake"
},
{
"isCMake" : true,
"isExternal" : true,
"path" : "/home/snaillum/Applications/clion-2023.1/bin/cmake/linux/x64/share/cmake-3.25/Modules/Compiler/CMakeCommonCompilerMacros.cmake"
},
{
"isCMake" : true,
"isExternal" : true,
"path" : "/home/snaillum/Applications/clion-2023.1/bin/cmake/linux/x64/share/cmake-3.25/Modules/Compiler/GNU.cmake"
},
{
"isCMake" : true,
"isExternal" : true,
"path" : "/home/snaillum/Applications/clion-2023.1/bin/cmake/linux/x64/share/cmake-3.25/Modules/Compiler/CMakeCommonCompilerMacros.cmake"
},
{
"isCMake" : true,
"isExternal" : true,
"path" : "/home/snaillum/Applications/clion-2023.1/bin/cmake/linux/x64/share/cmake-3.25/Modules/Platform/Linux-Clang-C.cmake"
},
{
"isCMake" : true,
"isExternal" : true,
"path" : "/home/snaillum/Applications/clion-2023.1/bin/cmake/linux/x64/share/cmake-3.25/Modules/Platform/Linux-GNU-C.cmake"
},
{
"isCMake" : true,
"isExternal" : true,
"path" : "/home/snaillum/Applications/clion-2023.1/bin/cmake/linux/x64/share/cmake-3.25/Modules/Platform/Linux-GNU.cmake"
},
{
"isCMake" : true,
"isExternal" : true,
"path" : "/home/snaillum/Applications/clion-2023.1/bin/cmake/linux/x64/share/cmake-3.25/Modules/CMakeCommonLanguageInclude.cmake"
},
{
"isCMake" : true,
"isExternal" : true,
"path" : "/home/snaillum/Applications/clion-2023.1/bin/cmake/linux/x64/share/cmake-3.25/Modules/CMakeTestCCompiler.cmake"
},
{
"isCMake" : true,
"isExternal" : true,
"path" : "/home/snaillum/Applications/clion-2023.1/bin/cmake/linux/x64/share/cmake-3.25/Modules/CMakeTestCompilerCommon.cmake"
},
{
"isCMake" : true,
"isExternal" : true,
"path" : "/home/snaillum/Applications/clion-2023.1/bin/cmake/linux/x64/share/cmake-3.25/Modules/CMakeDetermineCompilerABI.cmake"
},
{
"isCMake" : true,
"isExternal" : true,
"path" : "/home/snaillum/Applications/clion-2023.1/bin/cmake/linux/x64/share/cmake-3.25/Modules/CMakeParseImplicitIncludeInfo.cmake"
},
{
"isCMake" : true,
"isExternal" : true,
"path" : "/home/snaillum/Applications/clion-2023.1/bin/cmake/linux/x64/share/cmake-3.25/Modules/CMakeParseImplicitLinkInfo.cmake"
},
{
"isCMake" : true,
"isExternal" : true,
"path" : "/home/snaillum/Applications/clion-2023.1/bin/cmake/linux/x64/share/cmake-3.25/Modules/CMakeParseLibraryArchitecture.cmake"
},
{
"isCMake" : true,
"isExternal" : true,
"path" : "/home/snaillum/Applications/clion-2023.1/bin/cmake/linux/x64/share/cmake-3.25/Modules/CMakeTestCompilerCommon.cmake"
},
{
"isCMake" : true,
"isExternal" : true,
"path" : "/home/snaillum/Applications/clion-2023.1/bin/cmake/linux/x64/share/cmake-3.25/Modules/CMakeCCompilerABI.c"
},
{
"isCMake" : true,
"isExternal" : true,
"path" : "/home/snaillum/Applications/clion-2023.1/bin/cmake/linux/x64/share/cmake-3.25/Modules/CMakeDetermineCompileFeatures.cmake"
},
{
"isCMake" : true,
"isExternal" : true,
"path" : "/home/snaillum/Applications/clion-2023.1/bin/cmake/linux/x64/share/cmake-3.25/Modules/Internal/FeatureTesting.cmake"
},
{
"isCMake" : true,
"isExternal" : true,
"path" : "/home/snaillum/Applications/clion-2023.1/bin/cmake/linux/x64/share/cmake-3.25/Modules/CMakeCCompiler.cmake.in"
},
{
"isGenerated" : true,
"path" : "cmake-build-debug/CMakeFiles/3.25.2/CMakeCCompiler.cmake"
},
{
"isCMake" : true,
"isExternal" : true,
"path" : "/home/snaillum/Applications/clion-2023.1/bin/cmake/linux/x64/share/cmake-3.25/Modules/CMakeCXXInformation.cmake"
},
{
"isCMake" : true,
"isExternal" : true,
"path" : "/home/snaillum/Applications/clion-2023.1/bin/cmake/linux/x64/share/cmake-3.25/Modules/CMakeLanguageInformation.cmake"
},
{
"isCMake" : true,
"isExternal" : true,
"path" : "/home/snaillum/Applications/clion-2023.1/bin/cmake/linux/x64/share/cmake-3.25/Modules/Compiler/Clang-CXX.cmake"
},
{
"isCMake" : true,
"isExternal" : true,
"path" : "/home/snaillum/Applications/clion-2023.1/bin/cmake/linux/x64/share/cmake-3.25/Modules/Compiler/Clang.cmake"
},
{
"isCMake" : true,
"isExternal" : true,
"path" : "/home/snaillum/Applications/clion-2023.1/bin/cmake/linux/x64/share/cmake-3.25/Modules/Platform/Linux-Clang-CXX.cmake"
},
{
"isCMake" : true,
"isExternal" : true,
"path" : "/home/snaillum/Applications/clion-2023.1/bin/cmake/linux/x64/share/cmake-3.25/Modules/Platform/Linux-GNU-CXX.cmake"
},
{
"isCMake" : true,
"isExternal" : true,
"path" : "/home/snaillum/Applications/clion-2023.1/bin/cmake/linux/x64/share/cmake-3.25/Modules/Platform/Linux-GNU.cmake"
},
{
"isCMake" : true,
"isExternal" : true,
"path" : "/home/snaillum/Applications/clion-2023.1/bin/cmake/linux/x64/share/cmake-3.25/Modules/CMakeCommonLanguageInclude.cmake"
},
{
"isCMake" : true,
"isExternal" : true,
"path" : "/home/snaillum/Applications/clion-2023.1/bin/cmake/linux/x64/share/cmake-3.25/Modules/CMakeTestCXXCompiler.cmake"
},
{
"isCMake" : true,
"isExternal" : true,
"path" : "/home/snaillum/Applications/clion-2023.1/bin/cmake/linux/x64/share/cmake-3.25/Modules/CMakeTestCompilerCommon.cmake"
},
{
"isCMake" : true,
"isExternal" : true,
"path" : "/home/snaillum/Applications/clion-2023.1/bin/cmake/linux/x64/share/cmake-3.25/Modules/CMakeDetermineCompilerABI.cmake"
},
{
"isCMake" : true,
"isExternal" : true,
"path" : "/home/snaillum/Applications/clion-2023.1/bin/cmake/linux/x64/share/cmake-3.25/Modules/CMakeParseImplicitIncludeInfo.cmake"
},
{
"isCMake" : true,
"isExternal" : true,
"path" : "/home/snaillum/Applications/clion-2023.1/bin/cmake/linux/x64/share/cmake-3.25/Modules/CMakeParseImplicitLinkInfo.cmake"
},
{
"isCMake" : true,
"isExternal" : true,
"path" : "/home/snaillum/Applications/clion-2023.1/bin/cmake/linux/x64/share/cmake-3.25/Modules/CMakeParseLibraryArchitecture.cmake"
},
{
"isCMake" : true,
"isExternal" : true,
"path" : "/home/snaillum/Applications/clion-2023.1/bin/cmake/linux/x64/share/cmake-3.25/Modules/CMakeTestCompilerCommon.cmake"
},
{
"isCMake" : true,
"isExternal" : true,
"path" : "/home/snaillum/Applications/clion-2023.1/bin/cmake/linux/x64/share/cmake-3.25/Modules/CMakeCXXCompilerABI.cpp"
},
{
"isCMake" : true,
"isExternal" : true,
"path" : "/home/snaillum/Applications/clion-2023.1/bin/cmake/linux/x64/share/cmake-3.25/Modules/CMakeDetermineCompileFeatures.cmake"
},
{
"isCMake" : true,
"isExternal" : true,
"path" : "/home/snaillum/Applications/clion-2023.1/bin/cmake/linux/x64/share/cmake-3.25/Modules/Internal/FeatureTesting.cmake"
},
{
"isCMake" : true,
"isExternal" : true,
"path" : "/home/snaillum/Applications/clion-2023.1/bin/cmake/linux/x64/share/cmake-3.25/Modules/CMakeCXXCompiler.cmake.in"
},
{
"isGenerated" : true,
"path" : "cmake-build-debug/CMakeFiles/3.25.2/CMakeCXXCompiler.cmake"
},
{
"isExternal" : true,
"path" : "/usr/lib/cmake/Catch2/Catch2ConfigVersion.cmake"
},
{
"isExternal" : true,
"path" : "/usr/lib/cmake/Catch2/Catch2Config.cmake"
},
{
"isExternal" : true,
"path" : "/usr/lib/cmake/Catch2/Catch2Targets.cmake"
}
],
"kind" : "cmakeFiles",
"paths" :
{
"build" : "/home/snaillum/Code/3rd_year/project/interpreter/lang-interpreter/cmake-build-debug",
"source" : "/home/snaillum/Code/3rd_year/project/interpreter/lang-interpreter"
},
"version" :
{
"major" : 1,
"minor" : 0
}
}

View file

@ -0,0 +1,60 @@
{
"configurations" :
[
{
"directories" :
[
{
"build" : ".",
"jsonFile" : "directory-.-Debug-f5ebdc15457944623624.json",
"minimumCMakeVersion" :
{
"string" : "3.10"
},
"projectIndex" : 0,
"source" : ".",
"targetIndexes" :
[
0
]
}
],
"name" : "Debug",
"projects" :
[
{
"directoryIndexes" :
[
0
],
"name" : "LangInterpreter",
"targetIndexes" :
[
0
]
}
],
"targets" :
[
{
"directoryIndex" : 0,
"id" : "lang_interpreter::@6890427a1f51a3e7e1df",
"jsonFile" : "target-lang_interpreter-Debug-2572dccb12c281db093b.json",
"name" : "lang_interpreter",
"projectIndex" : 0
}
]
}
],
"kind" : "codemodel",
"paths" :
{
"build" : "/home/snaillum/Code/3rd_year/project/interpreter/lang-interpreter/cmake-build-debug",
"source" : "/home/snaillum/Code/3rd_year/project/interpreter/lang-interpreter"
},
"version" :
{
"major" : 2,
"minor" : 4
}
}

View file

@ -0,0 +1,14 @@
{
"backtraceGraph" :
{
"commands" : [],
"files" : [],
"nodes" : []
},
"installers" : [],
"paths" :
{
"build" : ".",
"source" : "."
}
}

View file

@ -0,0 +1,108 @@
{
"cmake" :
{
"generator" :
{
"multiConfig" : false,
"name" : "Ninja"
},
"paths" :
{
"cmake" : "/home/snaillum/Applications/clion-2023.1/bin/cmake/linux/x64/bin/cmake",
"cpack" : "/home/snaillum/Applications/clion-2023.1/bin/cmake/linux/x64/bin/cpack",
"ctest" : "/home/snaillum/Applications/clion-2023.1/bin/cmake/linux/x64/bin/ctest",
"root" : "/home/snaillum/Applications/clion-2023.1/bin/cmake/linux/x64/share/cmake-3.25"
},
"version" :
{
"isDirty" : false,
"major" : 3,
"minor" : 25,
"patch" : 2,
"string" : "3.25.2",
"suffix" : ""
}
},
"objects" :
[
{
"jsonFile" : "codemodel-v2-2a9d70ea75d656abc00d.json",
"kind" : "codemodel",
"version" :
{
"major" : 2,
"minor" : 4
}
},
{
"jsonFile" : "cache-v2-5a7c1d2b066689bf1144.json",
"kind" : "cache",
"version" :
{
"major" : 2,
"minor" : 0
}
},
{
"jsonFile" : "cmakeFiles-v1-2e515ef32a8cb12b793d.json",
"kind" : "cmakeFiles",
"version" :
{
"major" : 1,
"minor" : 0
}
},
{
"jsonFile" : "toolchains-v1-7a002b0e342416a4f4e9.json",
"kind" : "toolchains",
"version" :
{
"major" : 1,
"minor" : 0
}
}
],
"reply" :
{
"cache-v2" :
{
"jsonFile" : "cache-v2-5a7c1d2b066689bf1144.json",
"kind" : "cache",
"version" :
{
"major" : 2,
"minor" : 0
}
},
"cmakeFiles-v1" :
{
"jsonFile" : "cmakeFiles-v1-2e515ef32a8cb12b793d.json",
"kind" : "cmakeFiles",
"version" :
{
"major" : 1,
"minor" : 0
}
},
"codemodel-v2" :
{
"jsonFile" : "codemodel-v2-2a9d70ea75d656abc00d.json",
"kind" : "codemodel",
"version" :
{
"major" : 2,
"minor" : 4
}
},
"toolchains-v1" :
{
"jsonFile" : "toolchains-v1-7a002b0e342416a4f4e9.json",
"kind" : "toolchains",
"version" :
{
"major" : 1,
"minor" : 0
}
}
}
}

View file

@ -0,0 +1,203 @@
{
"artifacts" :
[
{
"path" : "lang_interpreter"
}
],
"backtrace" : 1,
"backtraceGraph" :
{
"commands" :
[
"add_executable",
"include_directories"
],
"files" :
[
"CMakeLists.txt"
],
"nodes" :
[
{
"file" : 0
},
{
"command" : 0,
"file" : 0,
"line" : 19,
"parent" : 0
},
{
"command" : 1,
"file" : 0,
"line" : 11,
"parent" : 0
}
]
},
"compileGroups" :
[
{
"compileCommandFragments" :
[
{
"fragment" : " -Wall -g -fcolor-diagnostics"
},
{
"fragment" : "-std=gnu++17"
}
],
"includes" :
[
{
"backtrace" : 2,
"path" : "/home/snaillum/Code/3rd_year/project/interpreter/lang-interpreter/include"
},
{
"backtrace" : 2,
"path" : "/home/snaillum/Code/3rd_year/project/interpreter/lang-interpreter/tree-sitter/lib/src"
},
{
"backtrace" : 2,
"path" : "/home/snaillum/Code/3rd_year/project/interpreter/lang-interpreter/tree-sitter/lib/include"
}
],
"language" : "CXX",
"languageStandard" :
{
"backtraces" :
[
1
],
"standard" : "17"
},
"sourceIndexes" :
[
0,
1,
2,
3
]
},
{
"compileCommandFragments" :
[
{
"fragment" : "-g -fcolor-diagnostics"
}
],
"includes" :
[
{
"backtrace" : 2,
"path" : "/home/snaillum/Code/3rd_year/project/interpreter/lang-interpreter/include"
},
{
"backtrace" : 2,
"path" : "/home/snaillum/Code/3rd_year/project/interpreter/lang-interpreter/tree-sitter/lib/src"
},
{
"backtrace" : 2,
"path" : "/home/snaillum/Code/3rd_year/project/interpreter/lang-interpreter/tree-sitter/lib/include"
}
],
"language" : "C",
"sourceIndexes" :
[
4,
6
]
}
],
"id" : "lang_interpreter::@6890427a1f51a3e7e1df",
"link" :
{
"commandFragments" :
[
{
"fragment" : "-Wall -g",
"role" : "flags"
},
{
"fragment" : "",
"role" : "flags"
}
],
"language" : "CXX"
},
"name" : "lang_interpreter",
"nameOnDisk" : "lang_interpreter",
"paths" :
{
"build" : ".",
"source" : "."
},
"sourceGroups" :
[
{
"name" : "Source Files",
"sourceIndexes" :
[
0,
1,
2,
3,
4,
6
]
},
{
"name" : "Header Files",
"sourceIndexes" :
[
5
]
}
],
"sources" :
[
{
"backtrace" : 1,
"compileGroupIndex" : 0,
"path" : "src/main.cpp",
"sourceGroupIndex" : 0
},
{
"backtrace" : 1,
"compileGroupIndex" : 0,
"path" : "src/visitor.cpp",
"sourceGroupIndex" : 0
},
{
"backtrace" : 1,
"compileGroupIndex" : 0,
"path" : "src/build_visitor.cpp",
"sourceGroupIndex" : 0
},
{
"backtrace" : 1,
"compileGroupIndex" : 0,
"path" : "src/print_visitor.cpp",
"sourceGroupIndex" : 0
},
{
"backtrace" : 1,
"compileGroupIndex" : 1,
"path" : "src/parser.c",
"sourceGroupIndex" : 0
},
{
"backtrace" : 1,
"path" : "include/parser.h",
"sourceGroupIndex" : 1
},
{
"backtrace" : 1,
"compileGroupIndex" : 1,
"path" : "tree-sitter/lib/src/lib.c",
"sourceGroupIndex" : 0
}
],
"type" : "EXECUTABLE"
}

View file

@ -0,0 +1,105 @@
{
"kind" : "toolchains",
"toolchains" :
[
{
"compiler" :
{
"id" : "Clang",
"implicit" :
{
"includeDirectories" :
[
"/usr/lib/clang/15.0.7/include",
"/usr/local/include",
"/usr/include"
],
"linkDirectories" :
[
"/usr/lib64/gcc/x86_64-pc-linux-gnu/12.2.1",
"/usr/lib64",
"/lib64",
"/usr/lib",
"/lib"
],
"linkFrameworkDirectories" : [],
"linkLibraries" :
[
"gcc",
"gcc_s",
"c",
"gcc",
"gcc_s"
]
},
"path" : "/usr/bin/clang",
"version" : "15.0.7"
},
"language" : "C",
"sourceFileExtensions" :
[
"c",
"m"
]
},
{
"compiler" :
{
"id" : "Clang",
"implicit" :
{
"includeDirectories" :
[
"/usr/include/c++/12.2.1",
"/usr/include/c++/12.2.1/x86_64-pc-linux-gnu",
"/usr/include/c++/12.2.1/backward",
"/usr/lib/clang/15.0.7/include",
"/usr/local/include",
"/usr/include"
],
"linkDirectories" :
[
"/usr/lib64/gcc/x86_64-pc-linux-gnu/12.2.1",
"/usr/lib64",
"/lib64",
"/usr/lib",
"/lib"
],
"linkFrameworkDirectories" : [],
"linkLibraries" :
[
"stdc++",
"m",
"gcc_s",
"gcc",
"c",
"gcc_s",
"gcc"
]
},
"path" : "/usr/bin/clang++",
"version" : "15.0.7"
},
"language" : "CXX",
"sourceFileExtensions" :
[
"C",
"M",
"c++",
"cc",
"cpp",
"cxx",
"mm",
"mpp",
"CPP",
"ixx",
"cppm"
]
}
],
"version" :
{
"major" : 1,
"minor" : 0
}
}

File diff suppressed because one or more lines are too long

View file

@ -139,13 +139,6 @@ struct ReferenceExpression;
struct FunctionCallExpression;
//
struct TypeExpression;
using FunctionArgument = std::variant<
SubExpressionToken,
std::unique_ptr<TypeExpression>>;
//
struct TupleExpression;
struct VariantExpression;
struct ReturnExpression;
@ -212,6 +205,12 @@ using TypeSubExpression = std::variant<
std::unique_ptr<AnyTypeIdentifier>,
std::unique_ptr<ParametrizedType>>;
//
using FunctionArgument = std::variant<
SubExpressionToken,
TypeSubExpression>;
// Comments [IGNORE] -----------------
// Identifiers, constants, etc. -----------------
@ -233,7 +232,7 @@ using Literal = std::variant<
//
using NameSubExpression = std::variant<
std::unique_ptr<NameIdentifier>,
std::unique_ptr<ExtendedName>,
std::unique_ptr<Literal>,
std::unique_ptr<SuperExpression>>;
@ -295,6 +294,7 @@ struct AliasDefinitionStatement {
struct VariableDefinitionStatement {
enum { Var, Const } modifier;
enum { Move, Assign } assignment_modifier;
AnyName name;
SuperExpression value;
};
@ -306,6 +306,7 @@ struct FunctionDeclaration {
};
struct FunctionDefinitionStatement {
bool is_inline;
std::unique_ptr<FunctionDefinition> definition;
SuperExpression value;
};
@ -437,8 +438,9 @@ struct ReturnExpression {
};
struct TypeConstructor {
enum AssignmentModifier { Move, Assign };
std::unique_ptr<ParametrizedType> type;
std::vector<std::pair<ExtendedName, SubExpression>> parameters;
std::vector<std::tuple<ExtendedName, AssignmentModifier, SubExpression>> parameters;
};
struct LambdaFunction {
@ -502,7 +504,7 @@ struct ParametrizedType {
struct TypeExpression {
std::vector<TypeSubExpression> namespaces;
AnyTypeIdentifier type;
std::optional<size_t> ArraySize; // if array; 0 - dynamic size
std::optional<size_t> array_size; // if array; 0 - dynamic size
};
struct ExtendedScopedAnyType {

View file

@ -45,7 +45,7 @@ public:
std::string GetValue() { // from source
size_t start = ts_node_start_byte(node_);
size_t end = ts_node_end_byte(node_);
return source_->substr(start, end - start); // TODO check
return source_->substr(start, end - start);
}
bool IsNull() {
@ -86,28 +86,18 @@ public:
return Node(ts_node_child_by_field_name(node_, name.c_str(), name.size()), source_);
}
// ?? use field id instaed of name ??
// ?? node equality check needed ??
Node NextSibling() {
return Node(ts_node_next_sibling(node_), source_);
}
Node NextNamedSibling() {
return Node(ts_node_next_named_sibling(node_), source_);
}
private:
bool uninitialized_;
TSNode node_;
const std::string* source_;
};
class Cursor { // ?? needed ??
public:
Cursor(const Node& node);
void ResetTo(const Node& node);
Node GetCurrentNode();
std::string GetCurrentNodeName();
bool GoToParent();
bool GoToNextSibling();
bool GoToFirstChild();
private:
TSTreeCursor cursor_;
};
ParseTree(const std::string& source) : source_(source) {
TSParser* parser = ts_parser_new();

View file

@ -103,7 +103,7 @@ private:
void Visit(ExtendedName* node) override;
void Visit(AnyIdentifier* node) override; // std::string
void Visit(std::string* node) override; // std::string
void Visit(FloatNumberLiteral* node) override;
void Visit(NumberLiteral* node) override;

View file

@ -1,7 +1,6 @@
#include <iostream>
#include <memory>
#include <sched.h>
// for clangd
#include "../include/build_visitor.hpp"
@ -115,8 +114,10 @@ void BuildVisitor::Visit(ImportStatement* node) {
++excluded_child_count;
}
auto module_name_node = parse_node.ChildByFieldName("module_name");
node->module_name = module_name_node.NthChild(1).GetValue();
StringLiteral module_name;
current_node_ = parse_node.ChildByFieldName("module_name");
Visit(&module_name);
node->module_name = module_name.value;
++excluded_child_count;
size_t child_count = parse_node.NamedChildCount();
@ -180,6 +181,13 @@ void BuildVisitor::Visit(VariableDefinitionStatement* node) {
current_node_ = parse_node.ChildByFieldName("value");
Visit(node->value);
std::string assignment_modifier = parse_node.NthChild(2).GetValue();
if (assignment_modifier == "=") {
node->assignment_modifier = VariableDefinitionStatement::Assign;
} else if (assignment_modifier == "<-") {
node->assignment_modifier = VariableDefinitionStatement::Move;
}
current_node_ = parse_node;
}
@ -197,6 +205,7 @@ void BuildVisitor::Visit(FunctionDeclaration* node) {
}
current_node_ = parse_node.ChildByFieldName("type");
node->type = std::make_unique<FunctionType>();
Visit(node->type.get());
current_node_ = parse_node;
@ -205,6 +214,8 @@ void BuildVisitor::Visit(FunctionDeclaration* node) {
void BuildVisitor::Visit(FunctionDefinitionStatement* node) {
auto parse_node = current_node_;
node->is_inline = (parse_node.NthChild(1).GetValue() == "inline");
current_node_ = parse_node.ChildByFieldName("definition");
node->definition = std::make_unique<FunctionDefinition>();
Visit(node->definition.get());
@ -319,7 +330,7 @@ void BuildVisitor::Visit(SourceStatement& node) {
void BuildVisitor::Visit(FunctionDefinition* node) {
auto parse_node = current_node_;
node->name = parse_node.ChildByFieldName("name").GetValue(); // TODO: check on operator
node->name = parse_node.ChildByFieldName("name").GetValue();
if (parse_node.NthChild(0).GetValue() == "(") {
node->modifier = FunctionDefinition::Operator;
@ -431,7 +442,7 @@ void BuildVisitor::Visit(Match* node) {
// if (child_count > 1) { // always true (repeat1)
node->matches.resize(child_count - 1);
for (size_t i = 0; i < child_count - 1; ++i) {
for (size_t i = 0; i + 1 < child_count; ++i) {
current_node_ = parse_node.NthNamedChild(i + 1);
Visit(&node->matches[i]);
}
@ -589,7 +600,7 @@ void BuildVisitor::Visit(SubExpressionToken& node) {
std::string current_node_type = current_node_.GetType();
if (current_node_type == parser::tokens::NameExpression) { // optimize ??
if (current_node_type == parser::tokens::NameExpression) {
node = std::make_unique<NameExpression>();
Visit(std::get<std::unique_ptr<NameExpression>>(node).get());
} else if (current_node_type == parser::tokens::ScopedStatement) {
@ -620,10 +631,10 @@ void BuildVisitor::Visit(SubExpression& node) {
Visit(*std::get<std::unique_ptr<SubExpressionToken>>(node));
} else if (current_node_type == parser::tokens::ArrayExpression) {
node = std::make_unique<ArrayExpression>();
Visit(std::get<std::unique_ptr<ArrayExpression>>(node));
Visit(std::get<std::unique_ptr<ArrayExpression>>(node).get());
} else if (current_node_type == parser::tokens::ReferenceExpression) {
node = std::make_unique<ReferenceExpression>();
Visit(std::get<std::unique_ptr<ReferenceExpression>>(node));
Visit(std::get<std::unique_ptr<ReferenceExpression>>(node).get());
} else {
// error
}
@ -763,15 +774,34 @@ void BuildVisitor::Visit(ReferenceExpression* node) {
}
current_node_ = parse_node.ChildByFieldName("expression");
node->expression = std::make_unique<ScopedStatement>();
Visit(node->expression.get());
current_node_ = parse_node;
}
// TODO <-- current place
// Other expressions
void BuildVisitor::Visit(FunctionArgument& node) {
auto parse_node = current_node_;
current_node_ = parse_node.NthNamedChild(0);
std::string current_node_type = current_node_.GetType();
if (current_node_type == parser::tokens::SubExpressionToken) {
node = SubExpressionToken();
Visit(std::get<SubExpressionToken>(node));
} else if (current_node_type == parser::tokens::TypeSubExpression) {
node = TypeSubExpression();
Visit(std::get<TypeSubExpression>(node));
} else {
// error
}
current_node_ = parse_node;
}
void BuildVisitor::Visit(FunctionCallExpression* node) {
auto parse_node = current_node_;
@ -784,9 +814,9 @@ void BuildVisitor::Visit(FunctionCallExpression* node) {
// if (child_count > 1) { // always true (repeat1)
node->arguments.resize(child_count - 1);
for (size_t i = 0; i < child_count - 1; ++i) {
current_node_ = parse_node.NthNamedChild(i + 1);
Visit(node->arguments[i]);
for (size_t i = 0; i + 1 < child_count; ++i) {
current_node_ = parse_node.NthNamedChild(i + 1);
Visit(node->arguments[i]);
}
// }
@ -801,8 +831,8 @@ void BuildVisitor::Visit(TupleExpression* node) {
node->expressions.resize(expressions_count);
for (size_t i = 0; i < expressions_count; ++i) {
current_node_ = parse_node.NthNamedChild(i);
Visit(node->expressions[i]);
current_node_ = parse_node.NthNamedChild(i);
Visit(node->expressions[i]);
}
current_node_ = parse_node;
@ -816,8 +846,8 @@ void BuildVisitor::Visit(VariantExpression* node) {
node->expressions.resize(expressions_count);
for (size_t i = 0; i < expressions_count; ++i) {
current_node_ = parse_node.NthNamedChild(i);
Visit(node->expressions[i]);
current_node_ = parse_node.NthNamedChild(i);
Visit(node->expressions[i]);
}
current_node_ = parse_node;
@ -832,6 +862,83 @@ void BuildVisitor::Visit(ReturnExpression* node) {
current_node_ = parse_node;
}
void BuildVisitor::Visit(TypeConstructor* node) {
auto parse_node = current_node_;
current_node_ = parse_node.ChildByFieldName("type");
node->type = std::make_unique<ParametrizedType>();
Visit(node->type.get());
size_t parameter_count = (parse_node.NamedChildCount() - 1) / 2;
node->parameters.resize(parameter_count);
for (size_t i = 0; i < parameter_count * 2; ++i) {
current_node_ = parse_node.NthNamedChild(i + 1);
if (i % 2 == 0) {
Visit(&std::get<0>(node->parameters[i / 2]));
std::string assignment_modifier = current_node_.NextSibling().GetValue();
if (assignment_modifier == "=") {
std::get<1>(node->parameters[i / 2]) = TypeConstructor::Assign;
} else if (assignment_modifier == "<-") {
std::get<1>(node->parameters[i / 2]) = TypeConstructor::Move;
}
} else {
Visit(std::get<2>(node->parameters[i / 2]));
}
}
current_node_ = parse_node;
}
void BuildVisitor::Visit(LambdaFunction* node) {
auto parse_node = current_node_;
size_t child_count = parse_node.NamedChildCount();
if (child_count > 1) {
bool parameters_ended = false;
for (size_t i = 0; i + 1 < child_count; ++i) {
current_node_ = parse_node.NthNamedChild(i);
if (current_node_.GetType() != parser::tokens::DefinitionParameter) {
parameters_ended = true;
}
if (!parameters_ended) {
node->parameters.push_back(std::make_unique<DefinitionParameter>());
Visit(node->parameters.back().get());
} else {
node->arguments.emplace_back();
Visit(&node->arguments.back());
}
}
}
current_node_ = parse_node.ChildByFieldName("expression");
Visit(node->expression);
current_node_ = parse_node;
}
void BuildVisitor::Visit(ArrayExpression* node) {
auto parse_node = current_node_;
size_t elements_count = parse_node.NamedChildCount();
node->elements.resize(elements_count);
for (size_t i = 0; i < elements_count; ++i) {
current_node_ = parse_node.NthNamedChild(i);
Visit(node->elements[i]);
}
current_node_ = parse_node;
}
void BuildVisitor::Visit(LoopControlExpression& node) {
std::string value = current_node_.NthChild(0).GetValue();
@ -844,61 +951,6 @@ void BuildVisitor::Visit(LoopControlExpression& node) {
}
}
//
void BuildVisitor::Visit(FunctionArgument& node) {
auto parse_node = current_node_;
current_node_ = parse_node.NthNamedChild(0);
std::string current_node_type = current_node_.GetType();
if (current_node_type == parser::tokens::SubExpressionToken) { // optimize ??
node = std::make_unique<SubExpressionToken>();
Visit(*std::get<std::unique_ptr<SubExpressionToken>>(node));
} else if (current_node_type == parser::tokens::TypeSubExpression) {
node = std::make_unique<TypeSubExpression>();
Visit(*std::get<std::unique_ptr<TypeSubExpression>>(node));
} else {
// error
}
current_node_ = parse_node;
}
// Lambda
void BuildVisitor::Visit(LambdaFunction* node) {
auto parse_node = current_node_;
size_t child_count = parse_node.NamedChildCount();
if (child_count > 1) {
bool parameters_ended = false;
for (size_t i = 0; i < child_count - 1; ++i) {
current_node_ = parse_node.NthNamedChild(i);
if (current_node_.GetType() != parser::tokens::DefinitionParameter) {
parameters_ended = true;
}
if (!parameters_ended) {
node->parameters.push_back(std::make_unique<DefinitionParameter>());
Visit(node->parameters.back().get());
} else {
node->arguments.push_back(std::make_unique<DefinitionArgument>());
Visit(node->arguments.back().get());
}
}
}
current_node_ = parse_node.ChildByFieldName("expression");
Visit(node->expression);
current_node_ = parse_node;
}
// Name
void BuildVisitor::Visit(NameExpression* node) {
@ -918,8 +970,9 @@ void BuildVisitor::Visit(NameExpression* node) {
if (i + 1 == child_count) {
node->expressions.emplace_back();
if (current_node_type == parser::tokens::NameIdentifier) { // optimize ??
node->expressions.back() = std::make_unique<NameIdentifier>(current_node_.GetValue());
if (current_node_type == parser::tokens::ExtendedName) {
node->expressions.back() = std::make_unique<ExtendedName>();
Visit(node->expressions.back());
} else if (current_node_type == parser::tokens::Literal) {
node->expressions.back() = std::make_unique<Literal>();
Visit(*std::get<std::unique_ptr<Literal>>(node->expressions.back()));
@ -954,7 +1007,7 @@ void BuildVisitor::Visit(TupleName* node) {
for (size_t i = 0; i < names_count; ++i) {
current_node_ = parse_node.NthNamedChild(i);
node->names[i] = std::make_unique<AnnotatedName>();
Visit(node->names[i].get());
Visit(node->names[i]);
}
current_node_ = parse_node;
@ -970,7 +1023,7 @@ void BuildVisitor::Visit(VariantName* node) {
for (size_t i = 0; i < names_count; ++i) {
current_node_ = parse_node.NthNamedChild(i);
node->names[i] =std::make_unique<AnnotatedName>();
Visit(node->names[i].get());
Visit(node->names[i]);
}
current_node_ = parse_node;
@ -984,7 +1037,7 @@ void BuildVisitor::Visit(AnnotatedName* node) {
if (parse_node.NamedChildCount() > 1) {
current_node_ = parse_node.ChildByFieldName("type");
node->type = std::make_unique<ParametrizedType>();
Visit(node->type.value().get());
Visit(node->type.value());
current_node_ = parse_node;
}
@ -997,7 +1050,7 @@ void BuildVisitor::Visit(AnyName& node) {
std::string current_node_type = current_node_.GetType();
if (current_node_type == parser::tokens::AnnotatedName) { // optimize ??
if (current_node_type == parser::tokens::AnnotatedName) {
node = std::make_unique<AnnotatedName>();
Visit(std::get<std::unique_ptr<AnnotatedName>>(node).get());
} else if (current_node_type == parser::tokens::TupleName) {
@ -1013,27 +1066,20 @@ void BuildVisitor::Visit(AnyName& node) {
current_node_ = parse_node;
}
// Type, typeclass, etc. -----------------
// Type
void BuildVisitor::Visit(TypeConstructor* node) {
void BuildVisitor::Visit(FunctionType* node) {
auto parse_node = current_node_;
current_node_ = parse_node.ChildByFieldName("type");
node->type = std::make_unique<ParametrizedType>();
Visit(node->type.get());
size_t types_count = parse_node.NamedChildCount();
size_t parameter_count = (parse_node.NamedChildCount() - 1) / 2;
node->types.resize(types_count);
node->parameters.resize(parameter_count);
for (size_t i = 0; i < parameter_count * 2; ++i) {
current_node_ = parse_node.NthNamedChild(i + 1);
if (i % 2 == 0) {
node->parameters[i / 2].first = current_node_.GetValue();
} else {
Visit(node->parameters[i / 2].second);
}
for (size_t i = 0; i < types_count; ++i) {
current_node_ = parse_node.NthNamedChild(i);
Visit(node->types[i]);
}
current_node_ = parse_node;
@ -1047,7 +1093,7 @@ void BuildVisitor::Visit(TupleType* node) {
current_node_ = parse_node.NthNamedChild(current_node_n);
if (current_node_.GetType() == parser::tokens::Constructor) {
node->type = current_node_.GetValue(); // TODO check
node->type = current_node_.GetValue();
++current_node_n;
current_node_ = parse_node.NthNamedChild(current_node_n);
@ -1056,14 +1102,16 @@ void BuildVisitor::Visit(TupleType* node) {
while (current_node_n < parse_node.NamedChildCount()) {
node->entities.emplace_back();
if (current_node_.GetType() == parser::tokens::NameIdentifier) {
node->entities.back().first = current_node_.GetValue();
if (current_node_.GetType() == parser::tokens::ExtendedName) {
node->entities.back().first.emplace();
Visit(&node->entities.back().first.value());
++current_node_n;
current_node_ = parse_node.NthNamedChild(current_node_n);
}
Visit(node->entities.back().second);
node->entities.back().second = std::make_unique<ExtendedScopedAnyType>();
Visit(node->entities.back().second.get());
++current_node_n;
current_node_ = parse_node.NthNamedChild(current_node_n);
@ -1080,7 +1128,7 @@ void BuildVisitor::Visit(VariantType* node) {
current_node_ = parse_node.NthNamedChild(current_node_n);
if (current_node_.GetType() == parser::tokens::Constructor) {
node->type = current_node_.GetValue(); // TODO check
node->type = current_node_.GetValue();
++current_node_n;
current_node_ = parse_node.NthNamedChild(current_node_n);
@ -1091,8 +1139,8 @@ void BuildVisitor::Visit(VariantType* node) {
node->constructors.emplace_back();
if (current_node_type == parser::tokens::TypeIdentifierDefinition) { // optimize ??
node->constructors.back() = current_node_.GetValue(); // TODO check
if (current_node_type == parser::tokens::Constructor) {
node->constructors.back() = current_node_.GetValue();
} else if (current_node_type == parser::tokens::TupleType) {
node->constructors.back() = std::make_unique<TupleType>();
Visit(std::get<std::unique_ptr<TupleType>>(node->constructors.back()).get());
@ -1119,21 +1167,9 @@ void BuildVisitor::Visit(AnnotatedType* node) {
if (child_count > 1) {
node->annotations.resize(child_count - 1);
for (size_t i = 0; i < child_count - 1; ++i) {
for (size_t i = 0; i + 1 < child_count; ++i) {
current_node_ = parse_node.NthNamedChild(i + 1);
std::string current_node_type = current_node_.GetType();
node->annotations[i] = std::make_unique<ParametrizedTypeclass>();
if (current_node_type == parser::tokens::TypeclassExpression) { // optimize ??
node->annotations[i]->typeclass_expression = std::make_unique<TypeclassExpression>();
Visit(node->annotations[i]->typeclass_expression.get());
} else if (current_node_type == parser::tokens::ParametrizedTypeclass) {
Visit(node->annotations[i].get());
} else {
// error
}
Visit(node->annotations[i]);
}
}
@ -1152,9 +1188,9 @@ void BuildVisitor::Visit(ParametrizedType* node) {
if (child_count > 1) {
node->parameters.resize(child_count - 1);
for (size_t i = 0; i < child_count - 1; ++i) {
current_node_ = parse_node.NthNamedChild(i + 1);
Visit(node->parameters[i]);
for (size_t i = 0; i + 1 < child_count; ++i) {
current_node_ = parse_node.NthNamedChild(i + 1);
Visit(node->parameters[i]);
}
}
@ -1164,30 +1200,48 @@ void BuildVisitor::Visit(ParametrizedType* node) {
void BuildVisitor::Visit(TypeExpression* node) {
auto parse_node = current_node_;
size_t excluded_child_count = 0;
size_t child_count = parse_node.NamedChildCount();
if (child_count > 1) {
node->namespaces.resize(child_count - 1);
current_node_ = parse_node.ChildByFieldName("type");
node->type = current_node_.GetValue();
++excluded_child_count;
for (size_t i = 0; i < child_count - 1; ++i) {
current_node_ = current_node_.NextSibling();
if (!current_node_.IsNull()) {
current_node_ = current_node_.NextSibling();
if (!current_node_.IsNull()) {
NumberLiteral literal;
Visit(&literal);
node->array_size = literal.value;
++excluded_child_count;
} else {
node->array_size = 0;
}
}
if (child_count > excluded_child_count) {
node->namespaces.resize(child_count - excluded_child_count);
for (size_t i = 0; i + excluded_child_count < child_count; ++i) {
current_node_ = parse_node.NthNamedChild(i);
Visit(node->namespaces[i]);
}
}
node->type = parse_node.ChildByFieldName("type").GetValue();
current_node_ = parse_node;
}
void BuildVisitor::Visit(AnyType& node) { // Or ScopedAnyType
void BuildVisitor::Visit(AnyType& node) {
auto parse_node = current_node_;
current_node_ = parse_node.NthNamedChild(0);
std::string current_node_type = current_node_.GetType();
if (current_node_type == parser::tokens::ParametrizedType) { // optimize ??
if (current_node_type == parser::tokens::ParametrizedType) {
node = std::make_unique<ParametrizedType>();
Visit(std::get<std::unique_ptr<ParametrizedType>>(node).get());
} else if (current_node_type == parser::tokens::TupleType) {
@ -1196,6 +1250,9 @@ void BuildVisitor::Visit(AnyType& node) { // Or ScopedAnyType
} else if (current_node_type == parser::tokens::VariantType) {
node = std::make_unique<VariantType>();
Visit(std::get<std::unique_ptr<VariantType>>(node).get());
} else if (current_node_type == parser::tokens::FunctionType) {
node = std::make_unique<FunctionType>();
Visit(std::get<std::unique_ptr<FunctionType>>(node).get());
} else {
// error
}
@ -1203,82 +1260,46 @@ void BuildVisitor::Visit(AnyType& node) { // Or ScopedAnyType
current_node_ = parse_node;
}
void BuildVisitor::Visit(TypeSubExpression& node) {
void BuildVisitor::Visit(ExtendedScopedAnyType* node) {
auto parse_node = current_node_;
current_node_ = parse_node.NthNamedChild(0);
size_t child_count = parse_node.ChildCount();
std::string current_node_type = current_node_.GetType();
if (current_node_type == parser::tokens::TypeIdentifier) { // optimize ??
node = std::make_unique<TypeIdentifier>();
Visit(std::get<std::unique_ptr<TypeIdentifier>>(node).get());
} else if (current_node_type == parser::tokens::AbstractTypeIdentifier) {
node = std::make_unique<AbstractTypeIdentifier>();
Visit(std::get<std::unique_ptr<AbstractTypeIdentifier>>(node).get());
} else if (current_node_type == parser::tokens::ParametrizedType) {
node = std::make_unique<ParametrizedType>();
Visit(std::get<std::unique_ptr<ParametrizedType>>(node).get());
} else {
// error
if (child_count > 1) {
node->references.resize(child_count - 1);
for (size_t i = 0; i + 1 < child_count; ++i) {
std::string reference = parse_node.NthChild(i).GetValue();
if (reference == "~") {
node->references[i] = ReferenceType::Reference;
} else if (reference == "@") {
node->references[i] = ReferenceType::UniqueReference;
}
}
}
current_node_ = parse_node;
}
void BuildVisitor::Visit(TypeParameter& node) {
auto parse_node = current_node_;
current_node_ = parse_node.NthNamedChild(0);
std::string current_node_type = current_node_.GetType();
if (current_node_type == parser::tokens::TypeExpression) { // optimize ??
node = std::make_unique<TypeExpression>();
Visit(std::get<std::unique_ptr<TypeExpression>>(node).get());
} else if (current_node_type == parser::tokens::ParametrizedType) {
node = std::make_unique<ParametrizedType>();
Visit(std::get<std::unique_ptr<ParametrizedType>>(node).get());
} else if (current_node_type == parser::tokens::Expression) {
node = std::make_unique<Expression>();
Visit(*std::get<std::unique_ptr<Expression>>(node));
} else {
// error
}
current_node_ = parse_node.ChildByFieldName("type");
Visit(node->type);
current_node_ = parse_node;
}
// Typeclass
void BuildVisitor::Visit(AnnotatedTypeclass* node) {
void BuildVisitor::Visit(TypeclassUsage& node) {
auto parse_node = current_node_;
current_node_ = parse_node.ChildByFieldName("typeclass_expression");
node->typeclass_expression = std::make_unique<TypeclassExpression>();
Visit(node->typeclass_expression.get());
current_node_ = parse_node.NthNamedChild(0);
size_t child_count = parse_node.NamedChildCount();
std::string current_node_type = current_node_.GetType();
if (child_count > 1) {
node->annotations.resize(child_count - 1);
for (size_t i = 0; i < child_count - 1; ++i) {
current_node_ = parse_node.NthNamedChild(i + 1);
std::string current_node_type = current_node_.GetType();
node->annotations[i] = std::make_unique<ParametrizedTypeclass>();
if (current_node_type == parser::tokens::TypeclassExpression) { // optimize ??
node->annotations[i]->typeclass_expression = std::make_unique<TypeclassExpression>();
Visit(node->annotations[i]->typeclass_expression.get());
} else if (current_node_type == parser::tokens::ParametrizedTypeclass) {
Visit(node->annotations[i].get());
} else {
// error
}
}
if (current_node_type == parser::tokens::TypeclassExpression) {
node = std::make_unique<TypeclassExpression>();
Visit(std::get<std::unique_ptr<TypeclassExpression>>(node).get());
} else if (current_node_type == parser::tokens::ParametrizedTypeclass) {
node = std::make_unique<ParametrizedTypeclass>();
Visit(std::get<std::unique_ptr<ParametrizedTypeclass>>(node).get());
} else {
// error
}
current_node_ = parse_node;
@ -1296,7 +1317,7 @@ void BuildVisitor::Visit(ParametrizedTypeclass* node) {
if (child_count > 1) {
node->parameters.resize(child_count - 1);
for (size_t i = 0; i < child_count - 1; ++i) {
for (size_t i = 0; i + 1 < child_count; ++i) {
current_node_ = parse_node.NthNamedChild(i + 1);
Visit(node->parameters[i]);
}
@ -1313,7 +1334,7 @@ void BuildVisitor::Visit(TypeclassExpression* node) {
if (child_count > 1) {
node->namespaces.resize(child_count - 1);
for (size_t i = 0; i < child_count - 1; ++i) {
for (size_t i = 0; i + 1 < child_count; ++i) {
current_node_ = parse_node.NthNamedChild(i);
Visit(node->namespaces[i]);
}
@ -1324,9 +1345,54 @@ void BuildVisitor::Visit(TypeclassExpression* node) {
current_node_ = parse_node;
}
// Typeclass & Type -----------------
void BuildVisitor::Visit(TypeParameter& node) {
auto parse_node = current_node_;
current_node_ = parse_node.NthNamedChild(0);
std::string current_node_type = current_node_.GetType();
if (current_node_type == parser::tokens::TypeExpression) {
node = std::make_unique<TypeExpression>();
Visit(std::get<std::unique_ptr<TypeExpression>>(node).get());
} else if (current_node_type == parser::tokens::ParametrizedType) {
node = std::make_unique<ParametrizedType>();
Visit(std::get<std::unique_ptr<ParametrizedType>>(node).get());
} else {
// error
}
current_node_ = parse_node;
}
void BuildVisitor::Visit(TypeSubExpression& node) {
auto parse_node = current_node_;
current_node_ = parse_node.NthNamedChild(0);
std::string current_node_type = current_node_.GetType();
if (current_node_type == parser::tokens::TypeIdentifier) {
node = std::make_unique<TypeIdentifier>();
Visit(std::get<std::unique_ptr<TypeIdentifier>>(node).get());
} else if (current_node_type == parser::tokens::AbstractTypeIdentifier) {
node = std::make_unique<AbstractTypeIdentifier>();
Visit(std::get<std::unique_ptr<AbstractTypeIdentifier>>(node).get());
} else if (current_node_type == parser::tokens::ParametrizedType) {
node = std::make_unique<ParametrizedType>();
Visit(std::get<std::unique_ptr<ParametrizedType>>(node).get());
} else {
// error
}
current_node_ = parse_node;
}
// Identifiers, constants, etc. -----------------
void BuildVisitor::Visit(ExtendedName* node) { // TODO: check
void BuildVisitor::Visit(ExtendedName* node) {
size_t child_count = current_node_.NamedChildCount();
if (child_count > 1) {
node->name = current_node_.GetValue();
@ -1348,11 +1414,13 @@ void BuildVisitor::Visit(NumberLiteral* node) {
}
void BuildVisitor::Visit(StringLiteral* node) {
node->value = current_node_.NthChild(1).GetValue();
std::string literal = current_node_.GetValue();
node->value = literal.substr(1, literal.size() - 2);
}
void BuildVisitor::Visit(CharLiteral* node) {
node->value = current_node_.NthChild(1).GetValue()[0];
std::string literal = current_node_.GetValue();
node->value = literal.substr(1, literal.size() - 2).back(); // TODO: special symbols, etc.
}
void BuildVisitor::Visit(Literal& node) {
@ -1362,7 +1430,7 @@ void BuildVisitor::Visit(Literal& node) {
std::string current_node_type = current_node_.GetType();
if (current_node_type == parser::tokens::FloatNumberLiteral) { // optimize ??
if (current_node_type == parser::tokens::FloatNumberLiteral) {
node = std::make_unique<FloatNumberLiteral>();
Visit(std::get<std::unique_ptr<FloatNumberLiteral>>(node).get());
} else if (current_node_type == parser::tokens::NumberLiteral) {
@ -1381,16 +1449,16 @@ void BuildVisitor::Visit(Literal& node) {
current_node_ = parse_node;
}
void BuildVisitor::Visit(NameSubSuperExpression& node) {
void BuildVisitor::Visit(NameSubExpression& node) {
auto parse_node = current_node_;
current_node_ = parse_node.NthNamedChild(0);
std::string current_node_type = current_node_.GetType();
if (current_node_type == parser::tokens::NameIdentifier) { // optimize ??
node = std::make_unique<NameIdentifier>(current_node_.GetValue());
//Visit(std::get<std::unique_ptr<NameIdentifier>>(node).get());
if (current_node_type == parser::tokens::ExtendedName) {
node = std::make_unique<ExtendedName>();
Visit(std::get<std::unique_ptr<ExtendedName>>(node).get());
} else if (current_node_type == parser::tokens::Literal) {
node = std::make_unique<Literal>();
Visit(*std::get<std::unique_ptr<Literal>>(node));

206449
src/parser.c

File diff suppressed because it is too large Load diff

View file

@ -90,7 +90,7 @@ void PrintVisitor::Visit(ImportStatement* node) {
if (!node->symbols.empty()) {
out_ << " (\n";
for (auto& symbol : node->symbols) {
Visitor::Visit(&symbol);
Visit(&symbol);
out_ << '\n';
}
out_ << ')';
@ -183,7 +183,7 @@ void PrintVisitor::Visit(AbstractTypeDefinitionStatement* node) {
break;
}
out_ << "] (";
Visit(node->definition.get());
Visit(node->type.get());
out_ << ")\n";
}
@ -413,7 +413,7 @@ void PrintVisitor::Visit(FunctionCallExpression* node) {
Visitor::Visit(argument);
out_ << ", ";
}
out_ << ")\n";
out_ << ")";
}
void PrintVisitor::Visit(TupleExpression* node) {
@ -444,11 +444,24 @@ void PrintVisitor::Visit(TypeConstructor* node) {
out_ << "[TypeConstructor ";
Visit(node->type.get());
out_ << "]\n(";
bool is_first = true;
for (auto& parameter : node->parameters) {
Visit(&parameter.first);
out_ << " = ";
Visitor::Visit(parameter.second);
out_ << ")\n(";
if (!is_first) {
out_ << ")\n";
is_first = false;
}
out_ << '(';
Visit(&std::get<0>(parameter));
switch (std::get<1>(parameter)) {
case TypeConstructor::Assign:
out_ << " = ";
break;
case TypeConstructor::Move:
out_ << " <- ";
break;
}
Visitor::Visit(std::get<2>(parameter));
}
out_ << ")\n";
}
@ -530,12 +543,12 @@ void PrintVisitor::Visit(AnnotatedName* node) {
void PrintVisitor::Visit(FunctionType* node) {
out_ << "[FunctionType] (";
bool first = true;
bool is_first = true;
for (auto& type : node->types) {
if (!first) {
if (!is_first) {
out_ << " -> ";
}
first = false;
is_first = false;
Visitor::Visit(type);
}
out_ << ')';
@ -601,7 +614,13 @@ void PrintVisitor::Visit(ParametrizedType* node) {
}
void PrintVisitor::Visit(TypeExpression* node) {
out_ << "[TypeExpression] (";
out_ << "[TypeExpression ";
if (node->array_size.has_value()) {
out_ << "[array size: " << node->array_size.value() << ']';
}
out_ << "] (";
for (auto& type_namespace : node->namespaces) {
Visitor::Visit(type_namespace);
out_ << '.';
@ -655,7 +674,7 @@ void PrintVisitor::Visit(ExtendedName* node) {
out_ << "[ExtendedName " << node->name << "] ";
}
void PrintVisitor::Visit(AnyIdentifier* node) { // std::string
void PrintVisitor::Visit(std::string* node) { // std::string
out_ << "[Identifier " << *node << "] ";
}

View file

@ -191,10 +191,10 @@ void Visitor::Visit(SuperExpression& node) {
void Visitor::Visit(FunctionArgument& node) {
switch (node.index()) {
case 0:
Visit(*std::get<std::unique_ptr<SubExpressionToken>>(node));
Visit(std::get<SubExpressionToken>(node));
break;
case 1:
Visit(*std::get<std::unique_ptr<TypeSubExpression>>(node));
Visit(std::get<TypeSubExpression>(node));
break;
default:
// error
@ -225,7 +225,7 @@ void Visitor::Visit(AnyName& node) {
// Type
void Visitor::Visit(AnyType& node) { // Or ScopedAnyType
void Visitor::Visit(AnyType& node) {
switch (node.index()) {
case 0:
Visit(std::get<std::unique_ptr<ParametrizedType>>(node).get());
@ -318,7 +318,7 @@ void Visitor::Visit(Literal& node) {
void Visitor::Visit(NameSubExpression& node) {
switch (node.index()) {
case 0:
Visit(std::get<std::unique_ptr<NameIdentifier>>(node).get());
Visit(std::get<std::unique_ptr<ExtendedName>>(node).get());
break;
case 1:
Visit(*std::get<std::unique_ptr<Literal>>(node));

View file

@ -1,29 +1,21 @@
decl test_arrays : Unit -> Unit
def test_arrays = {
var arr1 = [1, 2, 3]
const arr2 = [] // empty array ??
var arr3 = [] : Int.5 // TODO: decide ??
const arr4= ['a'..'z']
const n = 100;
var @arr5 = @[] : @Int.n // unique pointer (??)
var arr1 = [1; 2; 3]
const arr2 = []
var arr3 = []
const arr4 = 'a'..'z'
const n = 100
var @arr5 = @$Int_n
var @@arr6 = @@[] : @@Int.n // shared pointer (??)
var @@arr6_pointer = @@arr6
var @arr6 = @$Int_n
var @arr6_pointer = @arr6
const elem1 = arr1.1
var elem2 = arr1.1
const *ref1 = *arr1.1 // reference <-> unmanaged pointer (??)
var *ref2 = *arr1.1
; *arr1.1 = 123
const ~ref1 = ~arr1.1
var ~ref2 = ~arr1.1
; ~arr1.1 = 123
; ref1 = arr1.2 // set value
; *ref1 = *ref2 // set reference
// ?? references, that can't change ??
// ?? array access, array mutable access, array get reference to elem ??
// ?? arrays as basic type ??
// ?? custom allocators ??
; ~ref1 = ~ref2 // set reference
}
// ????????????????????

View file

@ -1,12 +1,3 @@
// ?? value - parametric classes ??
// struct fields/etc. accessible from everywere
// class fields/etc. accessible only from namespace of class or class instance (from "methods")
// points at the beginning of constructor name - amount of needed constructor prefixes ?
// ?? how to make class compositons ??
struct Fruit =
| Apple
| Orange
@ -20,13 +11,13 @@ struct (Result : #Move) 'A 'B =
| & 'A
| Error & 'B
// struct (Complex : #Value) =
// & Float(0.0)
// & Float(0.0)
//
// struct Task =
// & name("Task") : String
// & duration(0.0) : Float
struct (Complex : #Value) =
& Float
& Float
struct Task =
& name : String
& duration : Float
class Employee =
& name : String

View file

@ -12,6 +12,7 @@ namespace Employee {
& duration = 10.3
& sleep_on_work = ($Productivity.SleepOnWork.No))
& salary = 123)
}
}

View file

@ -1,22 +1,14 @@
decl flow_control_test : Unit -> Unit
def flow_control_test = {
// if && || a < b
// || a == b
// && b < c
// && c > 10
if ((a < b) || (a == b)) && (b < c)
then IO.print x
elif x < 0
then {
if ((a < b) || (a == b)) && (b < c) then IO.print x
elif x < 0 then {
; ++x
; IO.print y
} else {
return {}
}
while (a > 0) && (!array.is_empty)
do {
while (a > 0) && (!array.is_empty) do {
; --a
; array.pop
}
@ -28,9 +20,7 @@ def flow_control_test = {
; IO.print i
}
for & i & j
in (& 0..y & 0..k)
do { // TODO: decide ??? does it work (like auto zip) ???
for & i & j in (& 0..y & 0..k) do {
; IO.print 1
; IO.print 2
; IO.print 128

View file

@ -1,7 +1,5 @@
// "decl" is not required, but useful in module interface
decl sum ('A : #Add) : 'A -> 'A -> 'A
def sum : a b = a + b
def sum 'A : a b = a + b
decl fib : Int -> Int
def fib : n =
@ -16,25 +14,22 @@ def fact : n =
| n -> n * fact (n - 1)
decl find_prefix_hashes ('H : (#AccHash Char)) : String -> Array 'H
def find_prefix_hashes ('H : (#AccHash Char)) : str = {
def find_prefix_hashes 'H : str = {
var hashes = (Array 'H).new (str.size + 1)
; hashes.0 = 'H.of str.0
for i in 1..hashes.size do {
; hashes.i = hashes.(i - 1).clone
; hashes.i.append str.i
}
return hashes
; hashes.0 = 'H.of str.0
for i in 1..hashes.size do {
; hashes.i = hashes.(i - 1).clone
; hashes.i.append str.i
}
return hashes
}
// ?? other default constructor symbol (instead of placeholder _), etc. ??
// seporate first and last iteration of loop ?
// previous and next iterations ?
alias Hash = AccHash Char
decl find_substring : String -> String -> Array Index
def find_substring : str substr = {
alias Hash = AccHash Char
var result = (Array Index).empty
@ -64,7 +59,4 @@ decl mul : Int -> Int -> Int
def mul : x y = x * y
decl mul_10 : Int -> Int
def mul_10 = mul 10 // or argument can be used
// ?? is partial application feature needed ??
def mul_10 = mul 10

View file

@ -1,11 +1,11 @@
import "module"
import "module" : func
import "module" :
Type1
func1
func2
func3
func4
func5
use ModuleNamespace = import "module"
@ -14,5 +14,3 @@ use PartOfModuleNamespace =
func1
func2
func3
// ?? use ":" once again ??

View file

@ -1,12 +1,9 @@
decl test_lambdas : Unit -> Unit
def test_lambdas = {
const lambda1 = \x -> x * x
// const lambda2 = \(x : #Hash) -> x.hash // ??
const lambda2 = \x -> x.hash
const lambda3 = \x y -> x + y
// TODO: type LambdaType = Int -> Int // ?? type keyword ??
// const typed_lambda = \x -> x + 1
const lambda4 = \x -> {
; IO.print x
const y = x + x

View file

@ -1,9 +1,8 @@
struct StructWithRef =
& @Int._ // unique pointer to any-sized array (default size is zero ??)
& @Int_
decl test_memory : Unit -> Unit
def test_memory = {
const @unique_ref1 <- @5 // move unique reference
const @unique_ref1 <- @(5)
var @unique_ref2 <- @(Array.of 1 2 3)
// ?? reference to constant value ??
}

View file

@ -1,20 +1,15 @@
namespace Namespace {
decl something : Unit
decl something : Unit -> Unit
}
namespace Array 'A {
decl something : Unit
// "static methods" of Array 'a class
namespace Array {
decl something : Unit -> Unit
}
namespace Array ('A : #Copy) {
decl something : Unit
// "static methods" of Array 'a with "copyable" 'a
namespace Array {
decl something : Unit -> Unit
}
namespace var a : Array ('A : #Copy) {
decl something : Unit
// "methods" of Array 'a (a as array instance) with "copyable" 'a
namespace var a : Array {
decl something : Unit -> Unit
}
// ?? what to do with const/public/... methods ??

View file

@ -1,5 +0,0 @@
class (FixedArray : #Ord) 'A : (a : Int) =
& size(a) : Int // ?? const ??
& @[] : @'A.a
// ?? not shure about array definition ??

View file

@ -1,38 +1,23 @@
// partition DOC { // or .doc.lang filename
// // ...
// }
// ?? separated doc ??
partition TEST { // or .test.lang filename
decl something : Unit
decl something : Unit -> Unit
}
partition INTERFACE { // or .interface.lang filename
decl something : Unit
decl something : Unit -> Unit
}
partition CORE { // or .core.lang filename
decl something : Unit
decl something : Unit -> Unit
}
partition LIB { // or .lib.lang filename
decl something : Unit
decl something : Unit -> Unit
}
partition MODULE { // or .module.lang filename
decl something : Unit
decl something : Unit -> Unit
}
// maybe another name for partition
partition EXE { // or .exe.lang filename
decl something : Unit
decl something : Unit -> Unit
}
// partition CONFIG { // or .config.lang filename
// decl something : Unit
// }
// ?? config is one of the partitions ??
// ?? maybe more ??

View file

@ -7,6 +7,4 @@ def test_tuples = {
}
// ??????????????????????????

View file

@ -3,5 +3,3 @@ def test_type_casting = {
var x = y.as Int
var k = (f y x).as Float
}
// type casting is can be done by generic method "as"

View file

@ -1,36 +1,20 @@
typeclass #Copy =
& copy : #Copy -> #Copy
typeclass Copy =
& copy : Copy -> Copy
typeclass (#Ord : #Eq) =
& ( < ) : #Ord -> #Ord -> Bool
& ( > ) : #Ord -> #Ord -> Bool
& ( <= ) : #Ord -> #Ord -> Bool
& ( >= ) : #Ord -> #Ord -> Bool
typeclass (Ord : #Eq) =
& ( < ) : Ord -> Ord -> Bool
& ( > ) : Ord -> Ord -> Bool
& ( <= ) : Ord -> Ord -> Bool
& ( >= ) : Ord -> Ord -> Bool
typeclass (#D : #A #B #C) 'A 'B =
typeclass (D : #A #B #C) 'A 'B =
& do_something : Unit -> (& 'A & 'B)
typeclass #E 'A =
typeclass E 'A =
& do_something : Unit -> 'A
namespace const ord : #Ord {
namespace const ord : Ord {
def ( <= ) : a b = (a < b) || (a == b)
def ( > ) : a b = !(a <= b)
def ( >= ) : a b = !(a < b)
}
// === ?? dependent types ?? ===
//
// typeclass #F : (a : Int) (b : Int) =
// & do_something Int -> Int
//
// namespace (f : #F a b c) {
// require do_sometihng a = b
// }
//
// ===
// ?? operators over functions (without arguments, like "def <= = < || ==;") ??
// ?? define operators like OCaml ??
// ?? denote moved type ??
// ?? "trait" VS "typeclass" ??

View file

@ -1,14 +1,8 @@
alias T1 = Int;
alias T1 = Int
type (T2 : #A #B #C);
abstract (T2 : #A #B #C)
// Define file level abstract type
T2 =
| Int
| Float
| Complex;
// Compile module (functions, types, ...) for T2 = Int, Float, Complex
// ?? file level <-> module level ??
// Used to pre-compile module for some types
let T2 = Int
let T2 = Float
let T2 = Complex

View file

@ -1,14 +1,12 @@
decl test_variants : Unit -> Unit
def test_variants = {
var variant1 = | 'a' | 2 | "hello"
var | val | err = f x // optional types for each
var | val | err = f x
; val -> "something" // open variant as value in expr
; val -!> "nothing" // open variant as None in expr
; ?err // open variant as value, or return None (if possible), operator
match variant1 with
| 'a' -> "something"
| 2 -> "something"
@ -18,5 +16,3 @@ def test_variants = {
| Int.of i -> "someting"
| 11 -> "nothing"
}
// ???????????????????????