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 :
.cbfiles contain Cibyl code.ecbfiles contain embedded Cibyl code- blocks start by a
{line and end by a}line doblocks start their own lines- short comments start by
// - long comments start by
/*and end by*/ <%~%>blocks applyHTML.escapeto their content
If the --convert option is used :
$prefixes are converted to@@PascalCaseidentifiers are converted tosnake_caseUPPER_CASEidentifiers are converted toPascalCasePascalCaseidentifiers prefixed with#are converted toUPPER_CASEsnake_caseidentifiers prefixed with#are converted toPascalCase
Characters and identifiers prefixed with \ are kept unchanged.
- Blocks must be properly aligned.
- Multi-line strings are not supported.
- Curly bracket blocks can't be used in embedded code.
Install the DMD 2 compiler (using the MinGW setup option on Windows).
Build the executable with the following command line :
dmd -m64 cibyl.dcibyl [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 (ecstatic.coder@gmail.com).
This project is licensed under the GNU General Public License version 3.
See the LICENSE.md file for details.
