DeveloperBreeze

Recursive-Descent Development Tutorials, Guides & Insights

Unlock 1+ expert-curated recursive-descent tutorials, real-world code snippets, and modern dev strategies. From fundamentals to advanced topics, boost your recursive-descent skills on DeveloperBreeze.

Implementing a Domain-Specific Language (DSL) with LLVM and C++

Tutorial February 12, 2025

Your CMakeLists.txt should find and link LLVM libraries. For example:

cmake_minimum_required(VERSION 3.15)
project(MyDSL)

find_package(LLVM REQUIRED CONFIG)
message(STATUS "Found LLVM ${LLVM_PACKAGE_VERSION}")
message(STATUS "Using LLVMConfig.cmake in: ${LLVM_DIR}")

include_directories(${LLVM_INCLUDE_DIRS})
add_definitions(${LLVM_DEFINITIONS})

set(SOURCE_FILES
    src/main.cpp
    src/Lexer.cpp
    src/Parser.cpp
    src/AST.cpp
    src/CodeGen.cpp
)

add_executable(mydsl ${SOURCE_FILES})
llvm_map_components_to_libnames(llvm_libs support core irreader nativecodegen)
target_link_libraries(mydsl ${llvm_libs})