The Nigel programming language
Nigel is a new programming language for the 8051 microcontroller, with a c-like syntax.
- 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.)
- arrays (can be emulated with a pointer)
- string literals
- structs
- optimizing code
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.
-
new, delete (dynamic memory)
-
std-library
Pre-generated solution:
- Install Visual Studio (tested with VC 2017).
- Install the boost library:
- Download the library from http://www.boost.org/ and add it to the project dependencies (make sure filesystem and system are compiled)
- 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.
- Clone this repository.
- 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):
- Install cmake
- 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 - Clone this repository.
- create the project
mkdir build && cd build
cmake .. -DCMAKE_TOOLCHAIN_FILE=<vcpkg_install_dir>/scripts/buildsystems/vcpkg.cmake -DVCPKG_TARGET_TRIPLET=x86-windows-static
- Open build\Nigel.sln and compile
- Install cmake (https://cmake.org/ or just
sudo apt-get install cmake
). - Install boost with
sudo apt-get install libboost-all-dev
. - Clone this repository (
git clone https://github.com/erikgoe/nigel
).- 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. - or use gcc:
mkdir build | cd
cmake ..
make
The output binaries will be in Nigel/Compiler/build/Nigel/.
- Use clang (recommanded):
Install clang-4.0 (google it for your distribution). This should work for ubuntu 16.04 xenial:
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.
Hmm... maybe you?