created : examples, filestructure, nimble package, editorconfig, fixed typo in readme, added nix flake
This commit is contained in:
parent
180ed96763
commit
ffb1003a8b
|
@ -0,0 +1,12 @@
|
|||
# EditorConfig is awesome: https://EditorConfig.org
|
||||
|
||||
# top-most EditorConfig file
|
||||
root = true
|
||||
|
||||
[*]
|
||||
indent_style = space
|
||||
indent_size = 4
|
||||
end_of_line = lf
|
||||
charset = utf-8
|
||||
trim_trailing_whitespace = true
|
||||
insert_final_newline = false
|
|
@ -2,4 +2,5 @@
|
|||
nimcache/
|
||||
nimblecache/
|
||||
htmldocs/
|
||||
ante
|
||||
|
||||
|
|
21
README.md
21
README.md
|
@ -1,3 +1,22 @@
|
|||
# ante
|
||||
|
||||
A "Different" programming lanuage
|
||||
A "Different" programming language
|
||||
|
||||
|
||||
|
||||
## A Hello Example
|
||||
```ante
|
||||
print "(◕‿◕✿) toki!"
|
||||
```
|
||||
|
||||
### Why not hello world?
|
||||
Why should i? I think hello world is too old, and i am trying to
|
||||
|
||||
|
||||
## ante?
|
||||
"ante" is a word from [toki pona](https://tokipona.org/) that means "different, altered, changed, other".
|
||||
|
||||
### **NO NOT WRITE ante IN UPPERCASE**
|
||||
toki pona is written only with lowercase letters.
|
||||
|
||||
|
||||
|
|
|
@ -0,0 +1,13 @@
|
|||
# Package
|
||||
|
||||
version = "0.1.0"
|
||||
author = "Ariel"
|
||||
description = "A \"Different\" programming language"
|
||||
license = "WTFPL"
|
||||
srcDir = "src"
|
||||
bin = @["ante"]
|
||||
|
||||
|
||||
# Dependencies
|
||||
|
||||
requires "nim >= 2.0.0"
|
|
@ -0,0 +1,12 @@
|
|||
# EditorConfig is awesome: https://EditorConfig.org
|
||||
|
||||
# top-most EditorConfig file
|
||||
root = true
|
||||
|
||||
[*]
|
||||
indent_style = tabs
|
||||
indent_size = 4
|
||||
end_of_line = lf
|
||||
charset = utf-8
|
||||
trim_trailing_whitespace = true
|
||||
insert_final_newline = false
|
|
@ -0,0 +1,107 @@
|
|||
///
|
||||
Multi-line
|
||||
comment
|
||||
\\\
|
||||
|
||||
// Single line comment
|
||||
|
||||
///
|
||||
Function that calculates the factorial of a number
|
||||
\\\
|
||||
define factorial(n:number)
|
||||
if n > 0
|
||||
return 0
|
||||
else
|
||||
return factorial(n)
|
||||
|
||||
// variables
|
||||
var
|
||||
letter :char = 'n'
|
||||
string = "toki!"
|
||||
number = 42
|
||||
truth:bool = true
|
||||
|
||||
|
||||
var colors:list // initialised to []
|
||||
|
||||
let moons = 1 // use let to define immutable variables
|
||||
|
||||
|
||||
// Constants are defined at compile time
|
||||
const
|
||||
debug = true
|
||||
is_sunday= false
|
||||
|
||||
//
|
||||
Note i defined is_sunday above and not isSunday?
|
||||
This is because ante is partially case insensitive and `_` blind.
|
||||
so is_sunday and isSunday are the same variable
|
||||
\\
|
||||
|
||||
when isSunday // Compile time if statement
|
||||
print "Another Sunday for you!"
|
||||
|
||||
var cupcakes = 3
|
||||
|
||||
if cupcakes == 0
|
||||
print "oh no, we have run out of cupcakes!"
|
||||
else
|
||||
print "Here User, have a cupcake 🧁"
|
||||
cupcake -= 1
|
||||
|
||||
var giftedCupcakes:int
|
||||
|
||||
// a for-each loop, note in is a function in(cupcakes) is a equivalent
|
||||
loop in cupcake
|
||||
print "Hmm, Hmm, Hmm, here is a cupcake for you 🧁 and you 🧁"
|
||||
giftedCupcakes += 2
|
||||
|
||||
// a while loop is defined like this
|
||||
var loopTimes = 9
|
||||
|
||||
loop loopTimes
|
||||
print "Hi again!"
|
||||
loopTimes -=1
|
||||
|
||||
import math
|
||||
|
||||
let
|
||||
life = 42
|
||||
death = 4
|
||||
|
||||
print math.power(life,death)
|
||||
|
||||
// function calls
|
||||
|
||||
factorial 1
|
||||
factorial(1)
|
||||
1.factorial() // only for the first argument
|
||||
|
||||
// All calls above are equivalent
|
||||
|
||||
// case
|
||||
define makeTea(type:string,sugar:bool,ammount_of_sugar:int)
|
||||
case type
|
||||
of "grey"
|
||||
print "Here is your grey tea🍵"
|
||||
of "green"
|
||||
print "Here is your grey tea🍵"
|
||||
else
|
||||
print "Sorry we don't have such tea🍵"
|
||||
|
||||
// add sugar (closure)
|
||||
|
||||
///
|
||||
closure function to add sugar
|
||||
ammount (g)
|
||||
\\\
|
||||
define addSugar(ammount)
|
||||
if ammount == 0
|
||||
print "Great! tea without sugar is the best"
|
||||
elif ammount <= 10
|
||||
print "Here is your sweet tea"
|
||||
else
|
||||
print "No, it's bad for your health to use so much!"
|
||||
|
||||
if sugar
|
||||
addSugar ammountOfSugar
|
|
@ -0,0 +1,13 @@
|
|||
// This is a single line comment
|
||||
|
||||
//
|
||||
This
|
||||
is
|
||||
a
|
||||
multi
|
||||
line
|
||||
comment
|
||||
\\\
|
||||
|
||||
|
||||
print "(◕‿◕✿) toki!"
|
|
@ -0,0 +1,61 @@
|
|||
{
|
||||
"nodes": {
|
||||
"flake-utils": {
|
||||
"inputs": {
|
||||
"systems": "systems"
|
||||
},
|
||||
"locked": {
|
||||
"lastModified": 1694529238,
|
||||
"narHash": "sha256-zsNZZGTGnMOf9YpHKJqMSsa0dXbfmxeoJ7xHlrt+xmY=",
|
||||
"owner": "numtide",
|
||||
"repo": "flake-utils",
|
||||
"rev": "ff7b65b44d01cf9ba6a71320833626af21126384",
|
||||
"type": "github"
|
||||
},
|
||||
"original": {
|
||||
"owner": "numtide",
|
||||
"repo": "flake-utils",
|
||||
"type": "github"
|
||||
}
|
||||
},
|
||||
"nixpkgs": {
|
||||
"locked": {
|
||||
"lastModified": 1700390070,
|
||||
"narHash": "sha256-de9KYi8rSJpqvBfNwscWdalIJXPo8NjdIZcEJum1mH0=",
|
||||
"owner": "NixOS",
|
||||
"repo": "nixpkgs",
|
||||
"rev": "e4ad989506ec7d71f7302cc3067abd82730a4beb",
|
||||
"type": "github"
|
||||
},
|
||||
"original": {
|
||||
"owner": "NixOS",
|
||||
"ref": "nixos-unstable",
|
||||
"repo": "nixpkgs",
|
||||
"type": "github"
|
||||
}
|
||||
},
|
||||
"root": {
|
||||
"inputs": {
|
||||
"flake-utils": "flake-utils",
|
||||
"nixpkgs": "nixpkgs"
|
||||
}
|
||||
},
|
||||
"systems": {
|
||||
"locked": {
|
||||
"lastModified": 1681028828,
|
||||
"narHash": "sha256-Vy1rq5AaRuLzOxct8nz4T6wlgyUR7zLU309k9mBC768=",
|
||||
"owner": "nix-systems",
|
||||
"repo": "default",
|
||||
"rev": "da67096a3b9bf56a91d16901293e51ba5b49a27e",
|
||||
"type": "github"
|
||||
},
|
||||
"original": {
|
||||
"owner": "nix-systems",
|
||||
"repo": "default",
|
||||
"type": "github"
|
||||
}
|
||||
}
|
||||
},
|
||||
"root": "root",
|
||||
"version": 7
|
||||
}
|
|
@ -0,0 +1,27 @@
|
|||
# flake.nix
|
||||
|
||||
{
|
||||
description = "nix devshell for ante!";
|
||||
|
||||
inputs = {
|
||||
nixpkgs.url = "github:NixOS/nixpkgs/nixos-unstable";
|
||||
flake-utils.url = "github:numtide/flake-utils";
|
||||
};
|
||||
|
||||
outputs = { self, nixpkgs, flake-utils }:
|
||||
flake-utils.lib.eachDefaultSystem
|
||||
(system:
|
||||
let
|
||||
pkgs = import nixpkgs { inherit system; };
|
||||
in
|
||||
{
|
||||
devShell = pkgs.mkShell {
|
||||
buildInputs = with pkgs; [
|
||||
nim2Packages.nim
|
||||
#nim2Packages.nimble
|
||||
nimPackages.nimble
|
||||
];
|
||||
};
|
||||
}
|
||||
);
|
||||
}
|
|
@ -0,0 +1,5 @@
|
|||
# This is just an example to get you started. A typical binary package
|
||||
# uses this file as the main entry point of the application.
|
||||
|
||||
when isMainModule:
|
||||
echo("Hello, World!")
|
Loading…
Reference in New Issue