Skip to content
/ arrow Public

Arrow-Lang or Arrow is a fun and experimental interpreted programing language with it's interpretor made with JavaScript

License

Notifications You must be signed in to change notification settings

OMouta/arrow

Folders and files

NameName
Last commit message
Last commit date

Latest commit

Β 

History

29 Commits
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 

Repository files navigation

Arrow Language

Setup | Syntax Reference

Warning

Arrow-Lang is not and will never be production ready! We are currently re-writing the syntax and the interpreter!

Arrow-Logo Arrow-Logo Arrow-Logo

Description

Arrow is a fun, experimental interpreted programming language that uses arrows and special syntax elements to make programming visually intuitive and compact. Developed using JavaScript in the Deno 2 ecosystem, Arrow is intended for programmers who enjoy minimalist and symbolic syntax, allowing for efficient expressions and type-checked assignments. This language is especially suited for developers interested in learning about language design, parsing, and interpreter construction.

Purpose

Arrow aims to create an intuitive programming experience focused on simplicity and a unique syntax that is both visually distinct and easy to read. With features like variable type-checking, flexible function definitions, and arrow-based operators, Arrow provides an alternative way to experiment with programming fundamentals, control structures, and I/O. It’s designed as a sandbox for learning and expanding language development skills in a modular, extensible way.

Note

Most features here will eventualy be added, features are not listed by order, list can change over time.

Feature Table

Feature Description Status
Variable Declaration Declares and assigns values to variables. 🟨 Semi-Working
Basic Operators Supports addition, subtraction, multiplication, and division. πŸ”² Not Implemented
Logical Operators And, Or, Not operators for conditional logic. πŸ”² Not Implemented
Comparation Operators Equals, is bigger then, is smaller then for comparation logic. πŸ”² Not Implemented
Function Definition Defines functions with arguments and optional return types. 🟨 Semi-Working
Function Invocation Calls functions with arguments. πŸ”² Not Implemented
If-Else Conditionals Branches code based on conditions. πŸ”² Not Implemented
While Loop Executes code while a condition is true. πŸ”² Not Implemented
For Loop Executes code a fixed number of times. πŸ”² Not Implemented
Array Declaration Declares arrays for storing ordered data. πŸ”² Not Implemented
Array Access Accesses elements within an array by index. πŸ”² Not Implemented
Object Declaration Declares objects with key-value pairs. πŸ”² Not Implemented
Object Property Access Accesses properties of an object by key. πŸ”² Not Implemented
Built-In Functions Includes print for output and input for user input. πŸ”² Not Implemented
Comments Allows single and multi line comments for documentation. βœ… Implemented

Setup

To get started with the Arrow language, follow these steps:

1. Install Deno 2

First, you need to install Deno 2. You can download and install it from the official Deno website.

2. Clone the Repository

Clone this repository to your local machine using the following command:

git clone https://github.com/OMouta/arrow.git
cd arrow-lang

3. Run the Scripts

You can use the scripts defined in the deno.jsonc file to run and test the Arrow language.

Run the Arrow Interpreter

To run the Arrow interpreter, use the following command:

deno task arrow path/to/your/code.arrow

Run the Tests

To run the tests with debug information, use the following command:

deno task test

This will execute the Arrow code in the test/default.arrow file and output debug information.

Syntax Reference

1. Assignment

Basic Assignment:

<type> variableName <- value

Examples:

<str> message <- "Hello Arrow"

2. Function Definition and Invocation

Function Definition:

<fn bool> functionName(<const int> arg1, <const float> arg2 ) {
    // function body
    -> returnValue
}
  • <fn bool>: Denotes the start of a function and its return type.
  • ->: Return keyword, followed by value.

Function Invocation:

functionName(arg1, arg2, ...)

Examples:

<fn str> greetUser(<const str> name) {
    -> "Hello, " + name
}

message <- greetUser("ArrowUser")

3. Operators and Expressions

Arithmetic Operators:

  • Addition: x + y
  • Subtraction: x - y
  • Multiplication: x * y
  • Division: x / y

Logical Operators:

  • And: x && y
  • Or: x || y
  • Not: !! x

Comparison Operators:

  • Equal to: x == y
  • Not equal to: x != y
  • Greater than: x > y
  • Less than: x < y
  • Greater than or equal to: x >= y
  • Less than or equal to: x <= y

Examples:

<int> result <- x + y
<bool> isActive <- flag && condition
<bool> isEqual <- x == y
<bool> isNotEqual <- x != y
<bool> isGreater <- x > y
<bool> isLesser <- x < y
<bool> isGreaterOrEqual <- x >= y
<bool> isLesserOrEqual <- x <= y

4. Control Flow Statements

If-Else Conditionals:

if -> condition {
    // if block
} elif -> condition {
    // else block
} else {
    // else block
}

While Loop:

while -> condition {
    // loop body
}

For Loop:

for -> init ; condition ; increment {
    // loop body
}

Examples:

if -> score >= 50 {
    result <- "Pass"
} else {
    result <- "Fail"
}

i <== 0
while -> i < 5 {
    i <- i + 1
}

5. Arrays and Objects

Array Declaration:

<any> arrayName <- [item1, item2, ...]

Access Array Elements:

<any> item <- arrayName[index]

Object Declaration:

<obj> objectName <- { key1: value1, key2: value2, ... }

Access Object Properties:

<any> propertyValue <- objectName.key

Examples:

<int> items <- [10, 20, 30]
<int> firstItem <- items[0]

<obj> settings <- { volume: 75, theme: "dark" }
<str> currentTheme <- settings.theme

6. Built-In Functions

Print (Output to console):

print(message)

Input (User input):

<str> inputValue <- input("Prompt message")
  • print: Outputs the provided message to the console or display.
  • input: Displays a prompt and waits for user input.

Examples:

print("Hello, Arrow!")
<str> userName <- input("Enter your name: ")

7. Comments

Single-Line Comment:

:: This is a comment

Multi-Line Comment:

::> This
is
a
comment <::

8. Full Example Code

:: Declare variables
<const int> age <- 25
<const str> name <- "ArrowLang"

:: Function definition with return type
<fn bool> isValidAge(<const int> userAge) {
    if -> userAge >= 18 {
        -> true
    } else {
        -> false
    }
}

<fn null> main() {
    :: Function call
    <const bool> canVote <- isValidAge(age)

    :: Using a loop with an array
    <const int> values <- [10, 20, 30]
    <var int> sum <- 0

    for -> i <- 0 ; i < values.length ; i <- i + 1 {
        sum <- sum + values[i]
    }

    :: Output the sum
    print("Total Sum: " + sum)
}

About

Arrow-Lang or Arrow is a fun and experimental interpreted programing language with it's interpretor made with JavaScript

Topics

Resources

License

Stars

Watchers

Forks

Releases

No releases published