Giter VIP home page Giter VIP logo

csq3's Introduction

Csq-Version3

This is one more version of Csq programming language which's syntax looks much similar to Python and much faster than Csq Version-2.

Requirement

You should have g++ compiler

How does it works in backend?

It's processes are similar to the in the programming language Nim but here what it does it that a Intermediate code converter converts .csq to .csqm and later .csqm is converted to .cpp and it uses a prebuilt C++ compiler such as in this it uses clang++ to produce output.

What is new?

  • Speed is made faster than Csq version-2.
  • Functions can be used in main file.
  • Syntax for for loop is enhanced.
  • Speed of imported module is faster.
  • Code of CsqV2 couldn't be used in this.
  • You could add new tokens to it by changing base/token.h.
  • How to build Csq?

  • git clone https://github.com/CsqLang/Csq3
  • cd Csq-Version3 && bash build.sh
  • Some examples:

    Hello World

    print("Hello World")

    Creating Variables

    var i = 48
    //int i = 48 //But if you want to define a str so don't write like var v = "hello" because in this case it's considered as const char* use var v = str("hello")

    if else if and else

    if condition so ..... ends else if condition so ..... ends else go ..... ends

    For loop

    for var i : range(11)
     print(i,",")
    ends

    Functions

    def fizz()
     return str("BUZZ")
    fizz ends

    Functions with arguments

    def fizz(str name)
     return name + " BUZZ"
    fizz ends
    fizz("Aniket")

    Language used in backend

    Csq uses C++ at backend to compiler IR codes to generate machine code.

    New keywords::

    ["priv","pub","ends","meth"]

    To comment

    to comment you could use //

    What's inside base directory?

    In base directory all necessary header are present such as for code analysis, strings, arrays ...

    How to change add or remove operators:

    Go to base/token.h and there you will see a dictionary in which operators with their meaning in C++ are there. After changes compile csq.cpp and mcsq.cpp so that the changes can be applied.

    How it will provide memory safety if garbage collector isn't there?

    Well to provide memory safety there is one class which applies the concept of Smart Pointers using this it will free the memory by it self.

    csq3's People

    Contributors

    aniketkumar2500 avatar withsj avatar

    Stargazers

     avatar Krobix avatar  avatar  avatar

    Watchers

     avatar  avatar

    Forkers

    aniketkumar2500

    csq3's Issues

    println not working properly

    when I write code

    for var i : range(5) so 
    println("Hello world ", 100," | ",200)
    ends
    
    

    Output

    Hello world
    100 | 200Hello world
    100 | 200Hello world
    100 | 200Hello world
    100 | 200Hello world
    100 | 200

    The output should be like this
    Hello world 100 | 200
    Hello world 100 | 200
    Hello world 100 | 200
    Hello world 100 | 200
    Hello world 100 | 200

    it put \n after first arg "Hello world"

    Error when Function Define

    This code works and give output correctly

    def fizz(){
        return str("Hello World")
    }
    
    print(fizz())
    

    but when I put Curley braces in the new line

    def fizz()
    {
        return str("Hello World")
    }
    
    print(fizz())
    

    it gives me an error

    /home/jadam/Desktop/GITHUB/hello.cpp:3:1: error: expected unqualified-id before ‘{’ token
        3 | {;
          | ^
    /home/jadam/Desktop/GITHUB/hello.cpp: In function ‘int main()’:
    /home/jadam/Desktop/GITHUB/hello.cpp:8:11: error: use of ‘auto fizz()’ before deduction of ‘auto’
        8 | print(fizz());
          |       ~~~~^~
    sh: 1: ./hello: not found
    jadam@jadam-pc:~/Desktop/GITH
    

    IN hello.cpp File semi-colen at the end of def fizz()
    I think problem is here

    
    #include "/home/jadam/Desktop/GITHUB/Csq3/Modules/builtins.csqm"
    def fizz();
    {;
        return str("Hello World");
    };
    
    int main(){
    print(fizz());
    return 0;}
    
    

    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.