Giter Club home page Giter Club logo

danskdiego's Introduction

Note, as the language goal is to provide a danish programming language, everything is subject to change.

DanskDiego

DanskDiego is an imperative, procedural language, providing the world with a way to program in danish.

Overview

DanskDiego provides a small, and simple language, writeable in the mother tongue of Hans Christian Andersen. Coincidentally, the software was written in the birth city of the famed writer.

Data types

The primitive data types available in DanskDiego consists are int, bool, and char. Defining a variable is done using the var keyword, e.g.:

var a: int;

As seen above, a statement is terminated with a ;.

Multiple variables can be instantiated on the same line, by separating using a comma, as follows:

var a: int, b: bool, c: char;

Collections

DanskDiego supports arrays, and records. To define an array, prefix the type with array of, e.g.

var a: array of int, b: array of bool, c: array of array of char;

Where c is a two-dimensional array.

As the code reads, no size is defined for the arrays. This is done by using the allocate keyword. Using the allocate keyword requires use of a size, given as an integer, e.g.:

allocate b of length 5;

Which in conjunction with the previous snippet allocate b as an array of booleans of size 5.

Accessing values in an array are done using brackets. Accessing the 0th index in an array would be written as arr[0].

A record is similar to a C-struct, and uses the keywords record of to define. An example:

var rec: record of { a: int, b: bool };

Which creates a structure with the children being accessible through ., e.g. rec.a or rec.b.

Like arrays, records will need to be allocated, which is done similarly to arrays, but without the size:

var rec: record of { a: int, b: bool };
allocate rec;

Functions

Defining a function is done using the func keyword. A function must have a name and a return type, and be terminated by end followed by the function name.

A function returning an integer would be defined like this:

func returnInteger(a: int): int
    return a;
end returnInteger

which defines the function returnMe which takes a single argument, an integer.

Calling the function is done like most C-like programming languages:

returnMe(5);

Array length and absolute value

To retrieve the length of an array, the pipe operator can be used:

var length: int, arr: array of int;
allocate arr of length 5;
length = |arr|;
write length; // 5

Additionally, the pipe operator can also be used on an integer to get the absolute value, e.g:

var a: int;
a = 0-5;
write |a|; // 5

Hello World

The Hello World-program in DanskDiego is done using the primitive write, and can be done at the top level:

write "Hello, World!";

TODO - GRAMMAR

danskdiego's People

Contributors

danthrane avatar ezbob avatar tiggles avatar

Watchers

 avatar  avatar

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.