programming language compiler
Go to file
Sven Vogel edefc717c8 added windows CI based on MSYS2 2024-06-05 11:37:57 +02:00
.github/workflows added windows CI based on MSYS2 2024-06-05 11:37:57 +02:00
dep added git submodule tomlc99 2024-05-31 12:05:22 +02:00
sdk transioned to glib 2024-05-18 12:25:13 +02:00
src Merge pull request #114 from Servostar/76-add-rules-for-references 2024-06-03 20:04:42 +02:00
tests Merge pull request #114 from Servostar/76-add-rules-for-references 2024-06-03 20:04:42 +02:00
.env added klib as external library 2024-05-17 15:39:07 +02:00
.gitignore lexer unknown token passthrough 2024-05-14 12:27:21 +02:00
.gitmodules added git submodule tomlc99 2024-05-31 12:05:22 +02:00
CMakeLists.txt fixed devkit not cloning submodules 2024-06-01 14:52:59 +02:00
Dockerfile fixed devkit not cloning submodules 2024-06-01 14:52:59 +02:00
LICENSE added GPLv2.0 license 2024-04-10 13:44:50 +02:00
README.md added section about writing tests to README 2024-05-02 09:59:42 +02:00
ci-build.sh added windows CI based on MSYS2 2024-06-05 11:37:57 +02:00
run-check-test.sh transioned to glib 2024-05-18 12:25:13 +02:00
run-docker-build.sh fixed docker builld script 2024-05-18 12:52:00 +02:00

README.md

Gemstone

Gemstone is a programming language compiler written in C with lex and yacc.

Dependencies (build)

Windows 11

For setup instruction see issue #30

Requires:

  • Microsoft Build Tools 2022 (includes: CMake, MSVC)
  • WinFlexBison find it here (needs to be in PATH)

GNU/Linux

Requires:

  • GCC
  • CMake
  • Make
  • bison
  • flex

Writing Tests

Since the project is build and configured through CMake it makes sense to rely for tests on CTest. All tests are located in the subfolder tests. In this directory is a CMakeLists.txt which specifies which tests are to be run. Actual tests are located in folders within tests and contain a final CMakeLists.txt which specifies what to run for a single test.

tests
  └─ test_group1
      └─ CMakeLists.txt  # specify tests in this group
      └─ ...             # test files of group 1
      
  └─ test_group2
      └─ CMakeLists.txt  # specify tests in this group
      └─ ...             # test files of group 2
      
  └─ CMakeLists.txt      # specify test groups to run
  
CMakeLists.txt           # build configuration

Development with VSCode/Codium

Recommended extensions for getting a decent experience are the following:

In order to remove false error messages from clangd CMake has to be run once in order generate compile_commands.json.

Build

The build pipeline is configured with CMake in the file CMakeLists.txt. In order to avoid dependency and configuration issues the recommended way to build is by using the provided docker containers. All tools required for building (cmake, make, gcc, lex, yacc) are installed inside the SDK container (see Dockerfile sdk/Dockerfile). For creating the build pipeline build the Dockerfile in the root folder of this repository. This takes the current SDK and copies the source files into the home of the build user. Then the make targets are generated. Running make release will build gemstone from source in release mode. The generated binaries can be found either in bin/release/gsc or bin/debug/gsc depending on the chosen target. The following graph visualizes the build pipeline:

                 SDK (environment)
                  │
                  │ configure build environment
                  │  cmake, make, gcc, yacc, lex
                  │
                  ▼
                 Devkit (pipeline)
                  │
                  │ create build pipeline
                  │  create make targets
                  ▼
                 Pipeline
     

yacc (generate files)    GCC (compile)   Extra Source Files (src/*.c)
│                             │                     │
├─ parser.tab.h ─────────────►│◄────────────────────┘
│                             │
└─ parser.tab.c ─────────────►│
                              │
lex (generate file)           │
│                             │
└─ lexer.ll.c  ──────────────►│
                              │
                              ▼
                             gsc

Docker images

Currently, the SDK is based on Almalinux 9.3, an open source distro binary compatible to RHEL 9.3.

The following images can be found in the offical repository at Docker Hub:

  • SDK
  • Devkit