Coder Social home page Coder Social logo

hasanbly's Introduction

hasanbly

hasanbly basic scripting language

current version 1.5
[version 0.0, made on 05.10.2022]

if you want developing this project you can compile like this:

g++ main.cpp -o hsnc -static-libgcc -static-libstdc++ -Wl,-Bstatic -lstdc++ -lpthread


Get Started


You can get it with the command
git clone https://github.com/HasanEfeAksoy/hasanbly.git

Or get it as zip. Download hsnc.exe and create your .hsn file. (main.hsn)

Run with
hsnc main.hsn
command.
(note: Example main.hsn file may be do not run on MacOS and Linux. Please delete file and create again.)

Hasanbly is open source, not used parser basic scripting language.
Created with C++.

It is just interprete and run your codes easily.



Usage


Hello, World!


First, you may want to print Hello, World! to the console 🙃


<<Hello, World!;
EXIT;



------------------------------------------------------

Commands


  • //


    Comment line. The // operator only makes one line completely uninterpretable. So it cannot be used on a used line.

      
      // This is comment line
      
    // These lines will be ignored by the interpreter.
    EXIT;


    output: 


  • EXIT


    Ends the program. At the end of the program, you have to put EXIT command otherwise the program does not run.

      
      <Bye;
      
    EXIT;
    <Bye;
    EXIT;


    output: Bye


  • DEF


    Create a new variable and assign the entered value to the value of the variable. You have to define int or string or double (int-str-dbl).
    [Camel case variables are preferred]

      
      DEF:str:name=empty;
      
    <<$:str:name_;
    DEF:int:number=15;
    <<$:int:number_;
    DEF:dbl:myDouble=4.5;
    <<$:dbl:myDouble_;
    EXIT;


    output: empty
    15
    4.500000


  • <


    Prints the written values to the console.

      
      <Hello;
      
    EXIT;


    output: Hello


  • <<


    Prints the written values to the console with next line.

      
      <<Hello;
      
    EXIT;


      output: Hello
      


  • >


    Assigns the entered value to the value of the written variable.

      
      DEF:str:text=noname;
      
    // entered 'hasanbly'
    >$:str:text_;
    <<$:str:text_;
    EXIT;


    output: hasanbly


  • M


    You can using math operators like = + - * / %, trigonometric processes ex.(M.SIN $:dbl:myNum1_ $:dbl:myNum2_;) [note : just for radians double variables], M.ABS, M.POW, M.SQRT, M.ROUND, etc.
    But you have to using variables. You can convert type of variables with use M= command.

      
      DEF:int:first=0;
      
    DEF:int:second=1;
    // $:int:first_ = $:int:second_
    M= $:int:first_ $:int:second_;
    <<$:int:first_;
    EXIT;


    output: 1


  • GOTO


    Going to line. You can using with line number or line number variable value.

      
      <Hi; 
      
    GOTO 1;

    // or

    //DEF:int:line:2;
    //<Hi;
    //GOTO $:int:line_;
    EXIT;


    output: HiHiHiHiHiHiHiHiHiHiHiHiHiHiHiHiHiHi........



  • IF


    Like box office checkpoint. If true: can pass, else: go to a line.
    You have to use == != << >> <= >= and must use variable (not pure values) and use ELSE:<pure number>
    IMPORTANT: you have to string-string or int-int or double-double when using == or !=. but if using << >> <= >= you have to input parameters just int-int/double or double-double/int.

      
      DEF:int:num1=0;
      
    DEF:int:num2=0;
    // if 0 == 0
    // it returns true. so the interpreter does not go to line 8. it does not anything right now.
    // but if you put != the interpreter goes to line 8.
    IF== $:int:num1_ $:int:num2_ ELSE:8;
        <<Hello everyone;
    EXIT;


    output: Hello everyone


  • INC


    Increase the variable. You can use for int and double.

      
      DEF:int:number=0;
      
    <<$:int:number_;
    INC $:int:number_;
    <<$:int:number_;
    EXIT;


    output: 0
    1


  • DEC


    Decrease the variable. You can use for int and double.

      
      DEF:int:number=1;
      
    <<$:int:number_;
    DEC $:int:number_;
    <<$:int:number_;
    EXIT;


    output: 1
    0


  • NULL


    Set value of null to variable.
    if variable is string, new value is ''. (nothing)
    if variable is int, new value is 0.
    if variable is double, new value is 0.0.

      
      DEF:int:number=1;
      
    <<$:int:number_;
    NULL $:int:number_;
    <<$:int:number_;
    EXIT;


    output: 1
    0


  • FREE


    Delete the variable and set value of memory to null.

      
      DEF:int:myAwasomeNumber=5;
      
    <<$:int:myAwesomeNumber_;
    FREE $:int:myAwesomeNumber_;
    <<$:int:myAwesomeNumber_;
    EXIT;


    output: 5
    ERROR


  • INDEX


    Copy n'th index of first parameter and set value to second parameter. Just using with strings

      
      DEF:str:name=hasanbly;
      
    DEF:str:myIndex=nullForNow;
    <<$:str:myIndex_;
    INDEX[2] $:str:name_ $:str:myIndex;
    <<$:str:myIndex_;
    EXIT;


    output: nullForNow
    s


  • SLEEP


    Sleep main process. Just one parameter and it can be pure integer number or integer variable. Time type is millisecond.

      
      DEF:str:name=hasanbly;
      
    SLEEP 1000;
    // sleeping 1000 millisecond (1 second)
    <<$:str:name_;
    EXIT;


    output: hasanbly


  • RAND


    Random integer number generator. Have to using integer variables. 3 parameter (destination, min, max)

      
      DEF:int:dest=0;
      
    DEF:int:min=3;
    DEF:int:max=8;
    // random int number between 3-8 (3,4,5,6,7,8)
    RAND $:int:dest_ $:int:min_ $:int:max_;
    <<$:int:dest_;
    EXIT;


    output: 6


  • STRLEN


    Returns string's length. Have to using 2 (str, int) variables. 2 parameters are (source, destination)

      
      DEF:str:text=hello;
      
    DEF:int:length=0;
    STRLEN $:str:text_ $:int:length_;
    <<$:int:length_;
    EXIT;


    output: 5


  • CLEAR


    Takes no parameters and clears the console.

      
      <<^$^$Hello World!^$^$;
      
    CLEAR;
    <<^$^$Hello World!^$^$;
    EXIT;


    output: $$Hello World!$$


  • OSNAME


    Assigns your current OS name to a string variable.

      
      DEF:str:myOSname=;
      
    OSNAME $:str:myOSname_;
    <<$:str:myOSname_;
    EXIT;


    output: Windows


  • REPLACE


    Copy all of second parameter and change n'th index of first parameter. Just using with strings

      
      DEF:str:name=hasanbly;
      
    DEF:str:newWord=HAHAHA;
    <<$:str:name_;
    REPLACE[3] $:str:name_ $:str:newWord_;
    <<$:str:name_;
    EXIT;


    output: hasanbly
    hasHAHAHAnbly


  • TERMINAL


    Runs bash and batch codes. Just one parameter and it can be string variable. But be carefull because you may get some errors and program will stop if you write wrong command.

      
      // example for Windows
      
    DEF:str:myAwesomeCommand=dir;
    // example for UNIX types
    // DEF:str:myAwesomeCommand=ls;
    TERMINAL $:str:myAwesomeCommand_;
    EXIT;


    output: [< your current folder contents >]


  • TIME


    Returns current time. Just one parameter and it can be integer variable. There is 3 commands of TIME (.SECONDS .MINUTES .HOURS).

      
      DEF:int:time=0;
      
    TIME.MINUTES $:int:time_;
    <<$:int:time_;
    EXIT;


    output: 26


  • CLAMP


    Clamp value from first and second parameters to last 2 parameters range. Need 5 parameters and have to be double variables. 1) value 2) first min range 3) first max range 4) second min range 5) second max range.

      
      DEF:dbl:value=2;
      
    DEF:dbl:a=0;
    DEF:dbl:b=10;
    DEF:dbl:c=0;
    DEF:dbl:d=100;

    CLAMP $:dbl:value_ $:dbl:a_ $:dbl:b_ $:dbl:c_ $:dbl:d_;
    <<$:dbl:value_;
    EXIT;


    output: 20




UNDER DEVOLOPMENT

hasanbly's People

Contributors

hasanefeaksoy avatar

Stargazers

Levent Emre PAÇAL avatar

Watchers

 avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.