Popularity
6.4
Growing
Activity
0.0
Stable
31
5
1
Programming language: Crystal
License: MIT License
Tags:
Implementations/Compilers
cppize alternatives and similar shards
Based on the "Implementations and Compilers" category.
Alternatively, view cppize alternatives based on common mentions on social networks and blogs.
-
mint-lang
:leaves: A refreshing programming language for the front-end web. -
myst-lang
A practical, dynamic language designed to be written and understood as easily and efficiently as possible
Deliver Cleaner and Safer Code - Right in Your IDE of Choice!
SonarLint is a free and open source IDE extension that identifies and catches bugs and vulnerabilities as you code, directly in the IDE. Install from your favorite IDE marketplace today.
Promo
www.sonarlint.org
Do you think we are missing an alternative of cppize or a related project?
README
cppize
Crystal-to-C++ transpiler [WIP]
Generated code can be compiled with c++14 compiler (tested with g++ 6.2.0)
List of supported AST nodes can be found [here](NODES.md)
You can try it here
CLI Usage
- Compile
src/cppize/transpiler.cr
(it may take some time as itrequire
s Crystal parser) - Launch compiled executable with
-h
flag to view all command line flags
Implemented -fFEATURE
s
Flag | Description |
---|---|
-funsafe-cast |
Tells transpiler to transpile casts to C-style casts instead of static_cast s |
-fprimitive-types |
Tells transpiler to use fundamental C++ types when possible |
-fauto-module-type |
Allows transpiler to detect if module is included :warning: This option can slow down transpilation |
-fimplicit-static |
Enables static module methods' calls |
Library Usage
# Initialize transpiler
transpiler = Cppize::Transpiler.new
# Set error and warning callbacks
transpiler.on_warning{|e| puts e.to_s}
transpiler.on_error{|e| puts e.to_s; exit 1}
# Transpile file
transpiled_code = transpiler.parse_and_transpile_file("./file.cpp.cr")
# Transpile code from IO
transpiled_code = transpiler.parse_and_transpile_file(File.open("./file.cpp.cr"),"./file.cpp.cr")
# Transpile code from string
transpiled_code = transpiler.parse_and_transpile_file("def foo; bar(true) end","<test>")
Things to improve in already supported AST nodes
- Improve automatic return
- Improve module type detection (namespace / includable)
Development
Implementing nodes
See [src/cppize/nodes/expressions.cr](src/cppize/nodes/expressions.cr) for example
Adding transpile-time macros
See [src/cppize/macros/__cpp__.cr](src/cppize/macros/cpp.cr) for example
Contributing
- Fork it ( https://github.com/unn4m3d/cppize/fork )
- Create your feature branch (git checkout -b my-new-feature)
- Commit your changes (git commit -am 'Add some feature')
- Push to the branch (git push origin my-new-feature)
- Create a new Pull Request
Contributors
- unn4m3d unn4m3d - creator, maintainer