Skip to content

Language Syntax

Maximilian Winter edited this page Apr 7, 2022 · 1 revision

Modules

Modules are the basic foundation of a program in Bite. Each program consists of at least one module.

The code on the module level can contain functions, classes, objects and other variables. It can also create objects from classes, call functions and access objects.

Modules are defined like this:

module ModuleName;

You can import other modules through the "import" keyword, like this:

import ModuleName;

You can use imported functions and variables, like this:

ModuleName.FunctioName();
ModuleName.VariableName;

Through the use of the "using" keyword, you can omit the module names, like this:

import ModuleName;
using ModuleName;

FunctioName();       // ModuleName Function
VariableName;        // ModuleName Variable

Variables

Variables in Bite are there to hold data. Supported data types: numeric string object boolean array

Variables are defined like this:

var a = 42; // numeric data
a = "Hello World!"; // now 'a' is a variable that holds string data
a = new TestClass(); // now 'a' is a variable that holds object data from type TestClass

var b = new TestClass() // created a new variable of type TestClass

Functions

Functions in Bite can create objects from classes, call functions, access objects and return values.

They are defined, like that:

function FunctionName()
{

}

You can add parameters and return values, like that:

function FunctionName(parameterOne, parameterTwo)
{
  return parameterOne * parameterTwo;
}

Classes

Classes in Bite are an object-oriented way to separate Code into blueprints for objects and data structures. Classes can contain objects, other variables and functions. Classes can inherit members of other classes through inheritance. Functions in classes and functions in general can also create objects from classes, call functions and access objects.

Classes are defined like this:

class ClassName
{

}

You can inherit the members of other classes, like this:

class ClassName : OtherClassOne, OtherClassTwo
{

}

You can add members like variables and functions to a class, like this:

class ClassName
{
  var MemberOne = 5;
  function MethodOne(t)
  {
     return MemberOne * t;
  }
}
Clone this wiki locally