Skip to content

Latest commit

 

History

History
99 lines (75 loc) · 2.48 KB

LANGUAGE.md

File metadata and controls

99 lines (75 loc) · 2.48 KB

Echode Language Specification

Main

The Echode language is a language that is designed to be simple. It compiles to Java (source, which compiles to bytecode). It is strongly static typed. Everything must be closed with an end statement. Statements are newline-based. Between keywords there must be at least one bit of whitespace, further whitespace is ignored. Program files have the extension .ecp

Program Syntax

The core of a program is written as

program programname

...

end program

Each program must have a block of code marked with a starthere block, for example

program name

starthere

...

end starthere

end program

The command line arguments are made available with the argv list

Comments

Comments are blocks of code that are ignored by the compiler.

... //commment is ignored

This style is maintained until the end of the line

Variables and Literals

Variables are declared with the let statement and the declare statement. The difference is that a let statement assigns a variable at the same time as it is declared, while a declare statement simply declares it's name

declare type name

or

let type name be expression

An exception is when a variable has already been declared, in which case the let statement is used without the type:

let name be expression

Variable Types

There are several variable types

  • Number: (Max value: 2240*10232) (Syntax: 3.1415)
  • String (syntax: "stringvalue")
  • Boolean (syntax: true or false)
  • List (syntax: {obj1, obj2, obj3}) (see later)

Functions

Functions are declared as

function name

...

end function

and called with

call name

A function with parameters are declared as

function name with (partype parname = default, par2type par2name = par2default)

...

end function

and called with

name (parname = parvalue, par2name = par2value)

Functions on objects are called as

obj->name(...)

Parameter names MUST be included, except if there is only one parameter. In addition, parameters can be in any order

##Lists List syntax is

declare list[type] name

or

let list[type] name be expr

The syntax to access an element in a list is

name[index]

An element is inserted into a list in two ways: An existing element is replaced like:

let name[index] be expr

While an element is added to the end as

name->push(obj) (asterisks not necessary)