Skip to content

zfranke/Runic

Repository files navigation

Runic

Runic is a dynamically-typed, object-oriented programming language designed for speed, dynamic handling, and portability. Its main goal is to be used in web development, specifically for creating and sending strings using HTTP calls (GET, POST, etc.).

Syntax

In Runic, variables are called "runes" and have an identifier consisting of letters and numbers only. Statements are terminated using a semicolon (;).

The following data types are supported in Runic:

  • char
  • int
  • double
  • long
  • string
  • boolean
  • object

To declare a variable, use the rune keyword followed by the identifier and the data type:

rune myRune: int = 42; // 42 is an int

To declare a function, use the rune keyword followed by the identifier, the parameters, the return type, and the function body:

rune myFunction(a: int, b: int) -> int {
  return a + b;
}

To call a function, use the identifier followed by the arguments in parentheses:

myFunction(1, 2);

To print a value to the console, use the evoke keyword followed by the value in parentheses:

evoke(42);

Interpreter

The Runic interpreter is written in JavaScript and uses the PEG.js library to generate a parser based on a grammar written in the PEG.js syntax. It reads the source code from a file, parses it using the generated parser, and then interprets the AST generated by the parser to execute the source code.

To run a Runic program using the interpreter, use the following command:

node main.js path/to/file.runic

This command will execute the main.js script, passing the path/to/file.runic file as an argument. The script will read the source code from the file, pass it to the interpreter to execute it, and then print the result of any evoke statements to the console.

Example

Here is a simple example of a Runic program that declares a variable, defines a function, and prints the result of calling the function:

rune myRune: int = 42;

rune add(a: int, b: int) -> int {
  return a + b;
}


evoke(add(myRune, myRune));

This program will print 84 to the console, as it declares a variable myRune with the value 42, defines a function add that takes two int arguments and returns their sum, and then calls the add function with myRune as both arguments, resulting in the sum 42 + 42 = 84.

About

No description, website, or topics provided.

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published