项目作者: ThakeeNathees

项目描述 :
An object-oriented programming language
高级语言: C++
项目地址: git://github.com/ThakeeNathees/carbon.git
创建时间: 2019-12-03T17:53:38Z
项目社区:https://github.com/ThakeeNathees/carbon

开源协议:MIT License

下载



Carbon Programming Language

Carbon is a simple embeddable, object-oriented, dynamic-typed, bytecode-interpreted, scripting language written in C++11 with smart pointers for safe memory deallocation. Carbon is syntactically similar to C/C++, it’s analyzer and backend written using GDScript as a reference.

What Carbon looks like

  1. class Vector {
  2. // non-static members
  3. var x = 0, y = 0;
  4. // constructor
  5. func Vector (x = 0, y = 0) {
  6. this.x = x;
  7. this.y = y;
  8. }
  9. // built-in operator overriding
  10. func __add(v) {
  11. return Vector(x + v.x, y + v.y);
  12. }
  13. // built-in String conversion overriding
  14. func to_string() {
  15. return "Vector(%s, %s)" % [x, y];
  16. }
  17. }
  18. func main() {
  19. // construct a new vector object
  20. var v1 = Vector(1,2);
  21. // construct a new vector object
  22. var v2 = Vector(3,4);
  23. // call '__add' function in the vector object
  24. var v3 = v1 + v2;
  25. // prints "Vector(4, 6)"
  26. println(v3);
  27. }

Features

  • Minimal setup
  • Embeddable
  • Dynamic typing
  • Reference counting
  • Object-oriented
  • Enums and switch statements
  • Reference, default argument
  • Static, non-static members
  • Operator overriding
  • First class types, functions
  • Callables and Iterables

Building from source

For a non-development install/embedding with a single header use carbon.h header, you only need a C++11 compiler. For more details. read usage in carbon.h.

Requirenment

Install scons

  1. python -m pip install scons

In Linux if scons using python2 instead of 3 you’ll have to edit /usr/local/bin/scons or ~/.local/bin/scons to ensure that it points to /usr/bin/env python3 and not python

Clone & Build

  1. git clone https://github.com/ThakeeNathees/carbon.git
  2. cd carbon
  3. scons

You can specify the number of jobs scons to use to speed up the building process using the -j flag (-j6, -j8). To generate Visual Studio project files add vsproj=true argument when building. To compile using mingw in windows use use_mingw=true argument. If your build failed feel free to open an issue. Once a successful compile the bytecode-interpreter and unit-test binaries are found in bin/ directory of the carbon root directory.