Skip to content

Lightweight Pascal/Oberon-like imperative programming language

License

Notifications You must be signed in to change notification settings

IVIosab/carbonic-c

Repository files navigation

Contributors Forks Stargazers Issues BSD License


Logo

Carbonic-C

Lightweight Pascal/Oberon-like imperative programming language
Explore the docs »

Table of Contents
  1. Getting Started
  2. Usage
  3. Contributing
  4. License

About The Project

Carbonic-C Logo

(back to top)

Carbonic-C is a lightweight imperative programming language with Pascal/Oberon-like syntax. The language supports a set of basic features you would find in any programming language, as well as some more complex ones. Below are some of the main characteristics of the language:

  • The langugae is static. Object types are fixed at object declarations and cannot change during program execution.
  • There are three predefined data types: integer, real, boolean.
  • There are two predefined data structures: records, arrays.
  • Full expression syntax with usual set of binary, logical, and comparison operators.
  • The language is compiled, LLVM bytecode being the target.
  • The structure of the program is a sequence of data and routine (function)declarations.
  • The language features a standard set of statements: Assignment, if, for, while, return, print.

Visual Studio Code Extension

(back to top)

Carbonic-C has a VS Code extension that offers syntax highlighting and auto-completion. You can check it out here

Built With

  • CPP
  • CMake
  • LLVM
  • Bison
  • Flex

(back to top)

Getting Started

Below are the instructions for setting up the project locally on a Linux machine.

Prerequisites

  • g++ 11.3.0

    sudo apt install g++=11.3.0
  • flex 2.6.4

    sudo apt install flex=2.6.4
  • bison 3.8.2

    sudo apt install bison=3.8.2
  • make 4.3

    sudo apt install make=4.3
  • cmake 3.26.0

    sudo apt install cmake=2.6.4
  • llvm 14.0.0

    sudo apt install llvm-14

Usage

The project uses CMake as a build tool and contains a Makefile to provide an interface to easily use it. Below is the list of commands and their corresponding functionalities. These commands are available directly in the source directory.

  • run : Runs the compiler in the terminal and expects input from stdin. Prints output to stdout. This can be used as the "default' command for running the compiler, and is the quickest way to do so.
  make run
  • run/file : Compiles the contents of the input.crbc file in the source directory and produces output to output.out also in the source directory.
  make run/file
  • test : Runs a large set of valid/invalid Unit and End-to-End tests that test the entire compiler as well as its individual components and features. The test suite is run using CTest and prints elaborate output and test stats to the terminal.
  make test
  • build : If not previously built, this command will build the compiler in all of its stages and produce a single executable file. All generated files can be found in carbonic-c/build. If previously built, this command will build partially (re-compiling only files that have been touched since last built). This should be used as the default command for building the project after any changes are made.
  make build
  • clean : Removes all previously generated build and output files. This command can be used to restore the project to its "default" state
  make clean
  • build/all : Runs clean, removing all previously generated files and resetting the project, after that it builds the project from scratch with all of its components.
  make build/all

(back to top)

Contributing

Contributions are what make the open source community such an amazing place to learn, inspire, and create. Any contributions you make are greatly appreciated.

If you have a suggestion that would make this better, please fork the repo and create a pull request. You can also simply open an issue with the tag "enhancement". Don't forget to give the project a star! Thanks again!

  1. Fork the Project
  2. Create your Feature Branch (git checkout -b feature/AmazingFeature)
  3. Commit your Changes (git commit -m 'Add some AmazingFeature')
  4. Push to the Branch (git push origin feature/AmazingFeature)
  5. Open a Pull Request

(back to top)

License

Distributed under the 3-Clause BSD License. See LICENSE.txt for more information.

(back to top)