GithubHelp home page GithubHelp logo

justlucdewit / cod Goto Github PK

View Code? Open in Web Editor NEW
23.0 2.0 1.0 609 KB

cod programming language

Home Page: https://www.codlang.com

Python 99.36% Batchfile 0.64%
cod compiler concatenative language programming-language stack-based transpiler codlang hacktoberfest

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

cod's People

Contributors

justlucdewit avatar tombarten 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

Watchers

 avatar  avatar

Forkers

tombarten

cod's Issues

COD-9

strings

Strings can be pushed to the stack just like numbers, but in reality it will just simply put the string somewhere in memory and then push

  • the length of the string
  • the pointer to the string

These strings can be written like "" and '', can \ can be used as escape charachters just like in other programming languages like python and javascript.

COD-18

new operators

  • &
  • |
  • ^
  • <<
  • >>
  • !
  • %
  • random
  • cyclen
  • parseInt

COD-22

99 beers on the wall example

COD-24

Variables

// Creating value
<value> set::test

// Changing the value

get::test 5 + set::test

COD-7

heap memory management

Some words that can interface with the malloc() free() and realloc() functions of C, this will include the following new words:

malloc

pops the top value of the stack and reserves that many bytes, and pushes back a pointer to that memory

free

pops the top value of the stack and uses that as a pointer to free

realloc

pops the top value of the stack and uses that as a pointer to realloc, and then pops another value of the stack and uses that as the new buffer size

COD-19

rawc blocks

Either

raw "// c code goes here"

COD-1

While loops

Kinda like if statements, but it will repeat the block until the top value of the stack is no longer true
Example

10

while {
    printn
    1 -
}

COD-20

Support for other number systems

we already have decimal, but i also want

  • 0x Hexadecimal
  • 0b Binary
  • 0o Octal

COD-6

booleans & equality checking

First there needs to be some concepts of true and false, true and false will be built in aliases for 1 and 0

alias true 1
alias false 0

The we also need some sort of equality checking operators, which will be:

  • ==
  • !=
  • <
  • <=
  • =

COD-25

Setup py installer to compile to both windows and linux

COD-8

subroutines

Subroutines are like macros, except they dont simply get replaced, but rather they are compiled to C functions which can then be called. Making the executable more efficient

COD-2

Basic math operators

- + / *

COD-16

Console arguments

  • argc word will push argc
  • argv word will push argv pointer

COD-13

File IO

  • File Read
  • File Append
  • File Write

COD-4

alias

Aliases are words that are aliases for some other word or number, they are notated using alias x y meaning there will be a new word named x, which is the same as the already existing word y.

COD-26

Update readme and remove language.md since we have stuff on the website now

COD-5

macros

Macros are kinda like aliases, except they can be an alias for multiple words including if statements and loops. they are written like.

macro x {
	a b c
}

Where there will be a new word created named 'x' which will be an alias for the words a, b and then c.

COD-11

Better CLI

Make the CLI support flags and options like --watch --version --verbose --time etc

COD-3

Comments

Comments should be removed in some sort of pre-processor, and ignored, comments will be notated using -- this a comment and will then be ignored

COD-10

includes

Includes another .cod file based on a relative path, this will just copy paste the contents in the pre processor

Includes will be writte like include "some/path/to/a/library.cod"

COD-27

Update the repo to announce it will be bootstrapped, and add a contribution section where hacktoberfest members are welcomed

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.