Skip to content

satyajitghana/ProjektBarium

Repository files navigation

Projekt Barium - A Basic Compiler for Barium Programming Language

This is the compiler i built for my programming lanugage barium, a fun little project to understand compilers.

Tech Stack : Flex, Bison, LLVM

Build Status

ubuntu-build

Status

language-count top-language repo-size loc-count

release-date release license maintainer

The Compiler Recipe

Lexical Analyzer (Lex) -> Semantic Parsing (Bison) -> Assembly (LLVM) -> Executable

Task List

  • Add Data Types (decimal, fraction)
  • Operators, Symbols, Reserved Keywords
  • Add Looping Statements - ongoing (parse done)
  • Add Control Statements - ongoing (parse done)
  • Add Output Statements - uses vprintf
  • Add Input Statements
  • Add Arrays Support - ongoing (parse done)
  • Create a CI/CD Pipeline
  • Output executables instead of obj files (partial support)
  • locations (YYLTYPE, and @$)

Far-fetched task list

  • Make it a Library
  • Add Boost Math Support
  • Containerize the Compiler using Docker

Dependencies

  • LLVM 9.0.1
  • Bison 3.5.2
  • Flex 2.6.4

Known Issues

  • Spacing is required between operators to remove ambiguity

Build Barium (Installs Deps)

$ sudo sh build.sh

Run Tests

$ sh run_tests.sh

Example Run

Normal Run

$ ./barium test_files/test_all_ir.bar -v OFF

Debug Verbose Run

$ ./barium test_files/test_all_ir.bar -v INFO

Screenshot

help

Compiler Recipe

compiler-recipe

Example AST

Run binary-op-test

AST binary-op-test-ast