Lightweight curly-bracket language which compiles to Ruby and Crystal.
Lightweight curly-bracket language which compiles to Ruby and Crystal.
Cibyl allows to develop Ruby and Crystal applications with a C-like syntax :
// Recursive Fibonacci function
def fibonacci(
n : Int32
)
{
if ( n <= 1 )
{
return n;
}
else
{
return fibonacci( n - 1 ) + fibonacci( n - 2 );
}
}
puts fibonacci( 8 );
Optionally, Cibyl allows to use other case conventions :
require "http/server";
server = HTTP::SERVER.New
do | context |
{
context.Response.ContentType = "text/plain";
context.Response.Print( "Hello world! The time is #{TIME.Now}" );
}
address = server.BindTcp( 8080 );
Puts( "Listening on http://#{address}" );
server.Listen();
Most of the Ruby/Crystal syntax is kept unchanged, except that :
.cb
files contain Cibyl code.ecb
files contain embedded Cibyl code{
line and end by a }
linedo
blocks start their own lines//
/*
and end by */
<%~
%>
blocks apply HTML.escape
to their contentIf the --convert
option is used :
$
prefixes are converted to @@
PascalCase
identifiers are converted to snake_case
UPPER_CASE
identifiers are converted to PascalCase
PascalCase
identifiers prefixed with #
are converted to UPPER_CASE
snake_case
identifiers prefixed with #
are converted to PascalCase
Characters and identifiers prefixed with \
are kept unchanged.
Install the DMD 2 compiler (using the MinGW setup option on Windows).
Build the executable with the following command line :
dmd -m64 cibyl.d
cibyl [options] INPUT_FOLDER/ OUTPUT_FOLDER/
--ruby : generate Ruby files
--crystal : generate Crystal files
--replace dictionary.txt : replace identifiers defined in this dictionary
--convert : convert the identifier case
--join : join split statements
--compact : remove unused lines
--create : create the output folders if needed
--watch : watch the Cibyl files for modifications
--pause 500 : time to wait before checking the Cibyl files again
--tabulation 4 : set the tabulation space count
cibyl --ruby --compact CB/ RB/
Converts the Cibyl files of the input folder into matching Ruby files in the output folder.
cibyl --crystal --create --watch CB/ CR/
Converts the Cibyl files of the input folder into matching Crystal files in the output folder (creating the Crystal folders if needed), then watches the Cibyl files for modifications.
cibyl --crystal --replace dictionary.txt --convert --join --create --watch CB/ CR/
Converts the Cibyl files of the input folder into matching Crystal files in the output folder (replacing the identifiers defined in the dictionary, converting the identifier case, joining split statements and creating the Crystal folders if needed), then watches the Cibyl files for modifications.
1.3
Eric Pelzer ([email protected]).
This project is licensed under the GNU General Public License version 3.
See the LICENSE.md file for details.