https://github.com/sebbekarlsson/cola
component language (component-based programming language)
https://github.com/sebbekarlsson/cola
components interpreter programming-language wip
Last synced: 8 months ago
JSON representation
component language (component-based programming language)
- Host: GitHub
- URL: https://github.com/sebbekarlsson/cola
- Owner: sebbekarlsson
- Created: 2018-11-12T17:36:16.000Z (about 7 years ago)
- Default Branch: master
- Last Pushed: 2019-02-05T11:27:57.000Z (almost 7 years ago)
- Last Synced: 2025-01-30T18:04:37.244Z (10 months ago)
- Topics: components, interpreter, programming-language, wip
- Language: C
- Size: 259 KB
- Stars: 3
- Watchers: 2
- Forks: 0
- Open Issues: 1
-
Metadata Files:
- Readme: README.md
Awesome Lists containing this project
- AwesomeInterpreter - cola
README
## Cola
> _A component-based programming language._
## Snippet
> Here is what it looks like:
comp productlist use httplib, json {
function array get_products {
return json.parse(httplib.get('http://example.org/products'));
};
function array yields {
return get_products();
};
};
comp main use productlist {
function void run {
foreach (productlist as product) {
print(product);
};
};
};
## How to write a component
### The syntax
> The syntax for a component looks like this:
`comp [NAME] use [DEPENDENCY-LIST] [LBRACE] [RBRACE]`
comp mycomponent use somelibrary {
...
};
### The run-method
> The `run` method in a component can be executed through the `run` statement:
comp mycomponent {
function void run {
print("Hello World!")
};
};
comp main use mycomponent {
// run method of `mycomponent` is executed when mounted like this
};
### The yields-method
> The `yields` method in a component is used to make a component act as if
> it was another data-type. For example:
comp PI {
function float yields {
return 3.14;
};
};
comp main use PI {
function void run {
print(PI * 0.5);
};
};
> ... here, the `PI` component is treated as if it was a float.
### Interpreter instructions
> You can include other files using interpreter instructions, it looks
> very much like in `C`:
#include "somefile.cola"
comp main {
...
## Data-types
> The existing data-types are:
* int
* string
* array
* map
* struct
### Note
> The `array` data-type can hold any sort of type, but the type must
> be specified like: `array numbers;` or `array names;`
> The `map` data-type can also hold any sort of type and specified like:
> `map ages;` or `map> fav_numbers;`
## Built-in methods
> These are the built-in methods that currently exists:
* **print** - _print something to stdout_ (takes an infinite list of arguments)