All Projects → Florian3k → fayrant-lang

Florian3k / fayrant-lang

Licence: MIT license
Simple, interpreted, dynamically-typed programming language

Programming Languages

crystal
512 projects

Projects that are alternatives of or similar to fayrant-lang

aria
Expressive, noiseless, interpreted, toy programming language
Stars: ✭ 40 (+33.33%)
Mutual labels:  interpreter, lexer
Rs Monkey Lang
Monkey Programming Language written in Rust.
Stars: ✭ 80 (+166.67%)
Mutual labels:  interpreter, lexer
pascal-interpreter
A simple interpreter for a large subset of Pascal language written for educational purposes
Stars: ✭ 21 (-30%)
Mutual labels:  interpreter, lexer
Swiftpascalinterpreter
Simple Swift interpreter for the Pascal language inspired by the Let’s Build A Simple Interpreter article series.
Stars: ✭ 270 (+800%)
Mutual labels:  interpreter, lexer
types-and-programming-languages
C++ Implementations of programming languages and type systems studied in "Types and Programming Languages" by Benjamin C. Pierce..
Stars: ✭ 32 (+6.67%)
Mutual labels:  interpreter, lexer
MonkeyLang.jl
"Writing an Interpreter in GO" and "Writing a Compiler in GO" in Julia.
Stars: ✭ 30 (+0%)
Mutual labels:  interpreter, lexer
Mico
Mico ("Monkey" in catalan). Monkey language implementation done with C++. https://interpreterbook.com/
Stars: ✭ 19 (-36.67%)
Mutual labels:  interpreter, lexer
malluscript
A simple,gentle,humble scripting language for mallus, based on malayalam memes.
Stars: ✭ 112 (+273.33%)
Mutual labels:  interpreter, lexer
Cub
The Cub Programming Language
Stars: ✭ 198 (+560%)
Mutual labels:  interpreter, lexer
Monkey Rust
An interpreter for the Monkey programming language written in Rust
Stars: ✭ 174 (+480%)
Mutual labels:  interpreter, lexer
Lioness
The Lioness Programming Language
Stars: ✭ 155 (+416.67%)
Mutual labels:  interpreter, lexer
core.horse64.org
THIS IS A MIRROR, CHECK https://codeberg.org/Horse64/core.horse64.org
Stars: ✭ 3 (-90%)
Mutual labels:  dynamic-typing, lexer
monkey
The Monkey Programming Language & Interpreter written in PHP.
Stars: ✭ 21 (-30%)
Mutual labels:  interpreter, lexer
Own-Programming-Language-Tutorial
Репозиторий курса "Как создать свой язык программирования"
Stars: ✭ 95 (+216.67%)
Mutual labels:  interpreter, lexer
pawn-3.2-plus
Pawn scripting language with runtime fixes and improvements
Stars: ✭ 14 (-53.33%)
Mutual labels:  interpreter
nj
NJ is a simple script engine in golang with Lua-like syntax.
Stars: ✭ 19 (-36.67%)
Mutual labels:  interpreter
RSqueak
A Squeak/Smalltalk VM written in RPython.
Stars: ✭ 78 (+160%)
Mutual labels:  interpreter
xin
Xin (신/心) is a flexible functional programming language with a tiny core, inspired by Lisp and CSP
Stars: ✭ 20 (-33.33%)
Mutual labels:  interpreter
bshift
Compiler for a language called bshift
Stars: ✭ 15 (-50%)
Mutual labels:  lexer
LambdaCore
An interpreted language written in Rust inspired by the Lisp family of languages.
Stars: ✭ 56 (+86.67%)
Mutual labels:  interpreter

🎩 Fayrant-lang

Simple, interpreted, dynamically-typed programming language

Authors:

Basic syntax

~ this is comment

~ variable declaration
var something;
var something2 = 123;

~ simple types
something = null;

something = true;
something = false;

something = 1234;           ~ all numbers are 64-bit floating point (double)
something = 3.14159;
something = 0b100001011001; ~ binary literal
something = 0xDeadC0de;     ~ hexadecimal literal

something = "simple string";
something = "string with \n \t \\ \" \{ \} escapes";
something = "string with unicode escapes \u{65} \u{0x41}";
something = "string with interpolation { 2 + 3 + something2 }";
something = "string { "with { "nested" } interpolation" }";

~ unary and binary operators
something = !something;
something = -something;
something = @1234;    ~ conversion to string
something = #"1234";  ~ conversion to number

~ arithmetic
something = 1 + 2 - 3;
something = 1 * 2 + 3 / 4;
something = 4 \ 3;      ~ same as 3 / 4;
something = 2 ^ 3 ^ 4;  ~ exponentiation
something = 5 % 3;

~ comparison
something = 2 < 3;
something = 2 > 3;
something = 2 <= 3;
something = 2 >= 3;

something = 2 == 3;
something = 2 != 3;
something = "asd" == "def";
something = "asd" == 3;
something = "asd" == null;

something = "Hello " ++ "world!";  ~ string concatenation

~ logical
something = true & false;
something = true | false;

~ assignment operators
something = 1;
something += 2;
something -= 3;
something *= 4;
something /= 5;
something \= 6;
something %= 7;
something ^= 8;
something &= true;
something |= false;
something ++= "asdf";

~ basic io
something = input();  ~ returns string
print(something);     ~ prints anything

~ control flow

if (something > 5) {
  print("hello");
}

if (something == 7) {
  print("seven");
} else {
  print("not seven");
}

while (something > 0) {
  something -= 1;
}

for (var i = 0; i < 3; i += 1) {
  print(i);
}

while (true) {
  if (true) {
    break;
  }
}

for (var i = 0; i < 3; i += 1) {
  if (i == 2) {
    continue;
  }
  print(i);
}

Functions example

func factorial_iter(x) {
  if (x < 1) {
    return 1;
  }
  var res = 1;
  while (x > 1) {
    res *= x;
    x -= 1;
  }
  return res;
}

func factorial_rec(x) {
  if (x < 1) {
    return 1;
  }
  return x * factorial_rec(x - 1);
}

var x = #input();
if (x == null | x < 1) {
  print("Invalid number");
  return;
}
print("Iter: {factorial_iter(x)}");
print("Rec: {factorial_rec(x)}");

Class example

class Vec2d {
  constructor(x, y) {
    this.x = x;
    this.y = y;
  }

  func plus(other) {
    return Vec2d(this.x + other.x, this.y + other.y);
  }
  
  func norm() {
    return (this.x ^ 2 + this.y ^ 2) ^ 0.5;
  }
  
  func str() {
    return "Vec[{this.x},{this.y}]";
  } 
}

var v1 = Vec2d(3, 4);
var v2 = Vec2d(4, 5);
var v3 = v1.plus(v2);

print("{v1.str()} + {v2.str()} = {v2.str()}")

FAQ:

Why Fayrant name?

It's a tribute to this outstanding beverage

Note that the project description data, including the texts, logos, images, and/or trademarks, for each open source project belongs to its rightful owner. If you wish to add or remove any projects, please contact us at [email protected].