当前位置: 首页 > 软件库 > 开发工具 > 编译器 >

c2compiler

the c2 programming language
授权协议 Apache-2.0 License
开发语言 C/C++
所属分类 开发工具、 编译器
软件类型 开源软件
地区 不详
投 递 者 姜楷
操作系统 跨平台
开源组织
适用人群 未知
 软件概览

C2Compiler

Please see C2Lang.org for more info about C2!

The C2 project attempts to create a new language, strongly based on C.In a nutshell, the main differences with C are:

  • no more header files (too much typing)
  • no includes
  • packages (needed if we can't have includes)
  • compiled per target (not per file)
  • more logical keywords (public/local replaces static)
  • integrated build system

Below are the instructions for building and using the C2Compiler.

Have fun! (and code..)

Generic

C2 is based on LLVM 7.0 and some parts of Clang 7.0. The design of C2C'sParser and ASTBuilder classes are heavily based on clang's Parser and Sema class,so hereby my thanks to the Clang folks!

What needs to be done

A short list of open items (the full list would probably fill-up GitHub) withtheir priority:

  • [high] c2c: parse full syntax into AST (ALMOST DONE)
  • [high] c2c: generate IR code for more AST elements
  • [medium] tool: create graphical refactor tool (c2reto) (IN PROGRESS)
  • [medium] c2c: tab completion on targets in recipe / cmdline args
  • [medium] tool: create c-parser for parsing C headers.
  • [medium] tool: create c2format - astyle for C2.
  • [low] tool: c2grep - grep only files in recipe

Installation

Read the installation document for installation on Linux or OSX. ForWindows installation, see windows installation document.

Using the C2 compiler

By default, c2c will only parse and analyse the targets. Generating C-codeshould work on all examples, but generating LLVM's IR code is work inprogress. In the examples directory: (or add -d examples/)

c2c multi
c2c hello
c2c puzzle
c2c -I working_ir

It's also possible to manually compile a single .c2 file without a recipefile with:

c2c -f <file.c2>

To generate ANSI-C code, use:

c2c -C <target>

The C2 compiler is able to generate a package dependency file in dot format. Thisfile can be converted into a png as follows:

c2c --deps <target>
dot -T png output/target/deps.dot > image.png

To see all available options, run:

c2c -h

c2tags

c2tags is C2's version of ctags. This tool is used by vim (e.a.) to "jump todefinition". See the installation document on how to install.

How it works is as follows:

  • use --refs or add $refs in recipe.txt to generate refs file during compilation.
  • c2c generates a refs file per target. This file contains all referencesand their respective destinations.
  • c2tags currently doesn't have a full-blown vim-plugin yet, but a smallcode-fragment in your .vimrc should suffice.
  • Pressing ctrl-h (configurable) with your cursor on any symbolwill jump to its definition. Pressing ctrl-o (default) will jump back.

Just like c2c itself, c2tags can be called from any (sub)directory in theproject tree.

相关阅读

相关文章

相关问答

相关文档