项目作者: titan-lang

项目描述 :
泰坦编程语言
高级语言: Lua
项目地址: git://github.com/titan-lang/titan.git
创建时间: 2017-09-11T14:09:52Z
项目社区:https://github.com/titan-lang/titan

开源协议:MIT License

下载


Titan

Build Status
Coverage Status

Titan is a new programming language, designed to be a statically-typed,
ahead-of-time compiled sister language to Lua. It is an
application programming language with a focus on performance.

Install

First you need to download, extract and build the sources to Lua 5.3.5
inside the folder where you cloned this repository. The Lua tarball will extract
to a lua-5.3.5 folder. Enter it and build Lua with make linux MYCFLAGS=-fPIC.

You can install the Titan compiler itself using LuaRocks
this will also install all dependencies automatically.

  1. $ [install luarocks]
  2. $ luarocks make titan-scm-1.rockspec

To install without sudo permissions.

  1. $ [cd into titan folder]
  2. $ luarocks build --local

You can also run the Titan compiler directly from the folder where you
cloned this repository if you install all the dependencies for the compiler.

Requirements for running the compiler

  1. LPegLabel >= 1.5.0
  2. inspect >= 3.1.0
  3. argparse >= 0.5.0
  4. luafilesystem >= 1.7.0

Usage

  1. $ titanc [--print-ast] [--lua <path>] [--tree <path>] <module> [<module>]

The compiler takes a list of module names that you want to compile. Modules
are looked up in the source tree (defaults to the current working directory,
but you can override this with the --tree option), as well as in the Titan
binary path, a semicolon-separated list of paths
(defaults to .;/usr/local/lib/titan/0.5, you can override with a TITAN_PATH_0_5
or TITAN_PATH environment variable).

If everything is all right with your modules, you will get the result of
your compilation as a native binary:

  • if one of your Titan modules has a main function, with signature
    function({string}):integer, then titanc will bundle all modules
    given in the command-line, along with all their dependencies where
    source code was available, as a stand-alone executable program.
  • Otherwise, it will compile each module into a shared library
    (in the same path as the module source) that you can import from
    Titan as well as require from Lua, and call any exported
    functions/access exported variables. For each generated module, any
    of its transitive imports is statically linked if source code was
    found; dependencies that were only available as a shared library
    will be dynamically loaded.

Running the test suite

The test suite es written using Busted, which can be installed using LuaRocks:

  1. $ luarocks install busted

Then, you need to bulid the local copy of Lua, and run busted from the root directory
of this repository:

  1. $ cd lua
  2. $ make linux
  3. $ cd ..
  4. $ busted

You may need to adapt the invocation of make above to your platform.

Compiler options

  1. --print-ast Print the AST.
  2. --lua <path> Path to the Lua sources (default 'lua-5.3.5/src')
  3. --tree <path> Path to the source tree for your Titan modules (default '.')
  4. -h, --help Show this help message and exit.

Tentative roadmap

This is a very preliminary roadmap towards Titan 1.0, where everything is
subject to change, with things more likely to change the further
they are in the roadmap:

Supported

  • control structures
  • integers
  • floats
  • booleans
  • strings
  • arrays
  • top-level functions
  • early-bound modules
  • multiple assignment/multiple returns
  • FFI with C (C pointers, call C functions)
  • records (structs) with methods
  • maps

In progress

  • first-class functions (still only in the top-level)

Next

  • FFI with C, continued (C arrays, C structs)
  • standard library that is a subset of Lua’s standard library, built using the C FFI
  • tagged variants (unions of structs with some syntax for switch/case on the tag)
  • polymorphic functions
  • for-in
  • self-hosted compiler
  • nested and anonymous first-class functions with proper lexical scoping (closures)
  • “:” syntax sugar for records of functions
  • classes with single inheritance, either Go/Java/C#/Swift-like interfaces/protocols or Haskell/Rust-like typeclasses/traits
  • “:” method calls (not syntax sugar)
  • operator overloading
  • …Titan 1.0!