Skip to content

ζ basic is a small interpreted programming language based on python. Its syntax is mainly inspired by the BASIC language.

License

Notifications You must be signed in to change notification settings

bennaaym/zeta-basic

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

8 Commits
 
 
 
 
 
 
 
 

Repository files navigation

ZETA BASIC

Table of Contents
  1. About The Project
  2. Getting Started
  3. License
  4. Links
  5. Acknowledgements
  6. Documentation
  7. Code Examples
  8. What is Next

About The Project

Product Name Screen Shot

ζ basic is a small interpreted programming language based on python. Its syntax is mainly inspired by the BASIC language.

Built With

Getting Started

Prerequisites

Installation

  1. Clone the repo

    git clone https://github.com/bennaaym/zeta-basic.git
  2. Install python packages

    pip install -r requirements.txt
  3. Install NPM packages

    npm install
  4. inside the ui directory create a .env.local file and past the line below

    REACT_APP_INTERPRETER_API=http://127.0.0.1:5000/api/input
    

License

MIT License
Distributed under the MIT License. See LICENSE for more information.

Links

Acknowledgements

Documentation

Data types

  • ζ basic has 4 data types .
    • Bool
    • Number (int, float)
    • String
    • List

Variables

Syntax :  LET var_name = datatype | expression ;

Arithmetic Operators

addition, subtraction, multiplication, division, modulo, floor division (//), and power(**) operators are available . operations on List are inspired by the NumPy library .

Syntax :
  (+)  : (Number + Number) or (List + List) or (String + String) or (List + Number)
  (-)  : (Number - Number) or (List - List) or (List + Number)
  (*)  : (Number * Number) or (List * List) or (String * Number) or(List + Number)
  (/)  : (Number / Number) or (List / List) or (List / Number)
  (%)  : (Number % Number)
  (//) : (Number // Number) or (List // List) or (List // Number)
  (**) : (Number * Number)

Comparison Operators

equal, not equal, less than, greater than, less than or equal, and greater than or equal operators are available .

Syntax :

(==) : (dataype == datatype)
(!=) : (datatype != datatype)
(<) : (Number < Number) or (String < String)
(>) : (Number > Number) or (String > String)
(<=) : (Number <= Number) or (String <= String)
(>=) : (Number >= Number) or (String >= String)

Logical Operators

not, and, or operetors are available .value 0 ,empty String ,empty List corresponds to "FALSE" any other value corresponds to "TRUE" .

Syntax :

(!) : (! datatype)
(&&) : (datatype && datatype)
(||) : (datatype || datatype)

Conditional Statements

if-statement returns a value thus it can be assigned to a variable .

Syntex :  IF condition THEN expression ELSE expression

For Loop

for-loop returns a List thus it can be assigned to a variable .

Syntax :

FOR var_counter = start_value TO end_value DO expression ;
FOR var_counter = start_value TO end_value STEP step_value DO expression ;

While Loop

while-loop returns a List thus it can be assigned to a variable .

Syntax : WHILE condition DO expression ;

Built-in Functions

PRINT ,SUM, and STRINGIFY functions are available . all built-in functions return a value thus they can be assigned to a variable .

Syntax:

PRINT expression ;
SUM List ;
STRINGIFY datatype ;

Code Examples

Hello World

PRINT "Hello world!";

Find The Area of a Triangle

LET first_side = 5;
LET second_side = 4;
LET third_side = 3;
LET s = (first_side+second_side+third_side)/2;
LET area = (s*(s-first_side)*(s-second_side)*(s-third_side)) ** 0.5 ;
PRINT "the area of the triangle is: "+ STRINGIFY area

Factorial n!

LET n = 9;
LET fact = 1;
FOR i = 1 TO n + 1 DO LET fact = fact * i;
PRINT STRINGIFY n +" factorial is : "+ STRINGIFY fact;

Check Prime Number

LET number = 97;
LET counter = 1;
LET upper_value = number //2 +1;
LET is_prime = TRUE;
LET i = 2;
FOR i = 2 TO upper_value DO IF number % i == 0 THEN LET is_prime = FALSE;
LET result = STRINGIFY number;
LET result = result + IF is_prime THEN " is prime" ELSE " is not prime";
PRINT result;

Print a triangle

LET n = 10;
LET triangle = FOR i =0 TO n DO PRINT "#" * i +" ";

What is Next

  • implementation of functions
  • implementation of multiline statements
  • multi-files support

About

ζ basic is a small interpreted programming language based on python. Its syntax is mainly inspired by the BASIC language.

Topics

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published