Giter Site home page Giter Site logo

senselogic / cibyl Goto Github PK

View Code? Open in Web Editor NEW
44.0 7.0 1.0 2.91 MB

Lightweight curly-bracket language which compiles to Ruby and Crystal.

License: GNU General Public License v3.0

Crystal 35.61% Shell 0.81% Ruby 12.62% D 42.70% HTML 8.26%
lightweight language c-like ruby crystal curly brackets braces

cibyl's Introduction

Cibyl

Lightweight curly-bracket language which compiles to Ruby and Crystal.

Description

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();

Syntax

Most of the Ruby/Crystal syntax is kept unchanged, except that :

  • .cb files contain Cibyl code
  • .ecb files contain embedded Cibyl code
  • blocks start by a { line and end by a } line
  • do blocks start their own lines
  • short comments start by //
  • long comments start by /* and end by */
  • <%~ %> blocks apply HTML.escape to their content

If 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.

Limitations

  • Blocks must be properly aligned.
  • Multi-line strings are not supported.
  • Curly bracket blocks can't be used in embedded code.

Installation

Install the DMD 2 compiler (using the MinGW setup option on Windows).

Build the executable with the following command line :

dmd -m64 cibyl.d

Command line

cibyl [options] INPUT_FOLDER/ OUTPUT_FOLDER/

Options

--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

Examples

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.

Version

1.3

Author

Eric Pelzer ([email protected]).

License

This project is licensed under the GNU General Public License version 3.

See the LICENSE.md file for details.

cibyl's People

Contributors

ecstaticcoder avatar senselogic avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar

Forkers

chipper1

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.