Code Monkey home page Code Monkey logo

nigel's Introduction

Nigel

The Nigel programming language

What is it?

Nigel is a new programming language for the 8051 microcontroller, with a c-like syntax.

Goals

  • Complete compilation from source code to hex files.
  • Resolve complex expressions
  • Functions
  • Control flow (if, while, etc.)
  • Pointers
  • Intern/extern RAM
  • Preprocessor
  • Compile the compiler on linux (clang/gcc)
  • Interrupts
  • 8051-specific stuff (ports, timer, etc.)

Nice to have

  • arrays (can be emulated with a pointer)
  • string literals
  • structs
  • optimizing code

How does it work?

The Compiler is divided into these parts:

     Source code
          |
          v
+--------------------+
|    Preprocessor    |
+--------------------+
          |
          v
    Line textcode
          |
          v
+--------------------+
|       Lexer        |
+--------------------+
          |
          v
     Lexer code
          |
          v
+--------------------+
|     AST Parser     |
+--------------------+
          |
          v
         AST
          |
          v
+--------------------+
|    IM Generator    |
+--------------------+
          |
          v
         IMC
          |
          v
+--------------------+
|       Linker       |
+--------------------+
          |
          v
       HEX code

The resulting Hex code can be uploaded onto a 8051 microcontroller or be interpreted in a simulator.

Next development steps

  • new, delete (dynamic memory)

  • std-library

Getting started

Building

On Windows

Pre-generated solution:

  1. Install Visual Studio (tested with VC 2017).
  2. Install the boost library:
    1. Download the library from http://www.boost.org/ and add it to the project dependencies (make sure filesystem and system are compiled)
    2. or use vcpkg (https://github.com/Microsoft/vcpkg/) and install boost with <vcpkg_install_dir>\vcpkg install boost-filesystem boost-system. This might be the easier way.
  3. Clone this repository.
  4. Open Compiler\Nigel.sln, compile and hope for the best. The output binaries will be in Nigel\Compiler\Release\ or Nigel\Compiler\Debug\ depending on your configuration.

CMake (static build):

  1. Install cmake
  2. Install the boost library with vcpkg as above use <vcpkg_install_dir>\vcpkg install --triplet x86-windows-static boost-filesystem boost-system for static build
  3. Clone this repository.
  4. create the project
mkdir build && cd build
cmake .. -DCMAKE_TOOLCHAIN_FILE=<vcpkg_install_dir>/scripts/buildsystems/vcpkg.cmake -DVCPKG_TARGET_TRIPLET=x86-windows-static
  1. Open build\Nigel.sln and compile

On Linux

  1. Install cmake (https://cmake.org/ or just sudo apt-get install cmake).
  2. Install boost with sudo apt-get install libboost-all-dev.
  3. Clone this repository (git clone https://github.com/erikgoe/nigel).
    1. Use clang (recommanded): Install clang-4.0 (google it for your distribution). This should work for ubuntu 16.04 xenial: sudo apt-add-repository "deb http://llvm.org/apt/xenial/ llvm-toolchain-xenial-4.0 main" sudo apt-get update sudo apt-get install clang-4.0 lldb-4.0 Then just run 'build_clang.sh' script from this repository.
    2. or use gcc: mkdir build | cd cmake .. make The output binaries will be in Nigel/Compiler/build/Nigel/.

Usage

cd <binaries_output>,

then, with cmake nigel build --c ../../tests/code/functions.nig --o ../../tests/code/functions.hex or without (on Windows) nigel build --c ..\tests\code\functions.nig --o ..\tests\code\functions.hex to compile a test program

or nigel help to get further information on how to use nigel.

Alternatively you can add the binaries output directory to your PATH environment variable on windows.

Who uses Nigel?

Hmm... maybe you?

nigel's People

Contributors

erikgoe avatar

Stargazers

 avatar Jason Hsu avatar

Watchers

James Cloos avatar  avatar

Forkers

wxuefei

nigel's Issues

Fix Interrupts

If an interrupt gets called, the psw should be pushed to the stack and later restored

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.