FE 0.5.0
A header-only C++ library for writing frontends
Loading...
Searching...
No Matches
FE

docs linux macos windows

A header-only C++ library for writing compiler/interpreter frontends.

What is FE?

FE provides a set of utilities that helps you writing your own compiler or interpreter frontend. FE is not a lexer or parser generator. Instead, it will give you the blueprint to easily hand-write your own lexer and parser.

Get Started Now!

Based on the toy language Let, either

Features

  • Arena allocator for efficient memory management.
  • Efficient symbol pool that internalizes C and C++ strings into symbols. Checking for equality/inequality is only a pointer comparisons!
  • Keep track of source code locations.
  • Blueprint for a lexer with UTF-8 support.
  • Blueprint for a parser.
  • Optional Abseil support.
  • You need at least C++-20.

Building

FE optionally supports Abseil's excellent hash containers. In order to enable Abseil support, you have to define FE_ABSL. Otherwise, FE will fall back to the hash containers of the C++ standard library.

Option #1: Include FE as Submodule (Recommended)

  1. Add FE as external submodule to your compiler project:
    • If your compiler project is already on GitHub, do this:
      git submodule add ../../leissa/fe external/fe
    • Otherwise:
      git submodule add git@github.com:leissa/fe.git external/fe
  2. Integrate into your build system:
    • If you use CMake, add something like this to your CMakeLists.txt:
      set(FE_ABSL ON) # remove this line, if you don't want to use Abseil
      add_subdirectory(external/fe)
      target_link_libraries(my_compiler PUBLIC fe)
    • Otherwise:
      • Add external/fe/include as include directory.
      • Furthermore, add -DFE_ABSL to your CXXFLAGS, if you want to use Abseil.

Option #2: Directly include FE in your Source Tree

  1. Copy over the headers from FE to your compiler project:
    git clone git@github.com:leissa/fe.git
    mkdir -p my_compiler/include/fe
    cp -r fe/include/fe/*.h my_compiler/include/fe
  2. Integrate into your build system:

    Since your build system most likely already has my_compiler/include/ as an include directory, nothing more needs to be done. In addition, add -DFE_ABSL to your CXXFLAGS, if you want to use Abseil. In the case of CMake, add something like this to your CMakeLists.txt:

    target_compile_definitions(my_compiler PUBLIC FE_ABSL)

Other Projects using FE

  • Let: A simple demo language that builds upon FE
  • GraphTool: A small tool that reads a subset from Graphviz' DOT language and calculates several dominance-related properties
  • SQL: Small and simple SQL parser
  • Thorin2: The Higher-ORder INtermediate representation