Giter Club home page Giter Club logo

cod's Introduction

Cod

The Cod Compiler

Cod is an opensource concatenative stack-based general purpose programming language that compiles to C

In the future, it is planned for the compiler to be bootstrapped meaning it will be written in Cod itself.


Contribution

To Cod is an opensource project and contributions are welcome. If you would like to contribute, please fork the repository, work using github issues, use the ticket notation style used in the issues, and submit a pull request.

Hacktoberfest pull requests are welcome including spelling mistakes and grammar fixes.


Installation

You can download the latest version from your operating system on The cod website

Once downloaded you can put the executable in your system PATH and then it should work


Usage

cod someScript.cod -o someScript.c for More help, run cod --help

Make sure to download the standard library in your project root


Useful links:

Language

Hello World:

"Hello World!" prints

Fizzbuzz:

-- Fizzbuzz example written in Cod
include "std/math.cod"
include "std/io.cod"
include "std/stack.cod"

alias max_loop_count 40

-- Subroutine to check if number is divisible by another number
subroutine divisible_by {
    % 0 ==
}

-- Counter
1

-- Start the loop
true

while {
    pop
    
    -- Check if divisible by 3
    dup 3 divisible_by if {
        "fizz" prints
    } pop

    -- Check if divisible by 5
    dup 5 divisible_by if {
        "buzz" prints
    } pop
    
    -- Check if divisible by neither
    dup 3 divisible_by ! swap dup cycle3 swap 5 divisible_by ! & if {
        swap printn swap
    } pop

    -- Print newline
    10 printc pop

    -- Increment count
    1 +

    -- Determain if loop again
    dup max_loop_count <=
}

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.