Giter VIP home page Giter VIP logo

pycsl's Introduction

pycsl - Python Implementation of Computation Script Language

Introduction

Computation Script Language (CSL)

Computation Script Language (CSL) is a language for computation scripts and simple arithmetics. It supports:

  • Arithmetic calculation (+, -, *, /, %, ^[power]);
  • Boolean calculation (and, or, not) same as Python;
  • Controls (if, else, for, while) same as C;
  • Variables and declarations;
  • Types (int, float, char, string);
  • Functions (Pre-defined functions and self-definition);
  • Modules (Include other files by 'import')

Similar to Python, a CSL program can run directly by line or by block. If input is a block, the CSL interpreter detects main() function as the entry point.

Type System and Generic Types

CSL is static type. However, a function may not specify the variable type and the type check will be performed on interpretion. Type are required in compiling.

Examples

By line:

> 1+2*(3+4)
15
> abs(-5)
5

By block:

sum.csl:

import std;

def plus(x:int, y:int):int{
    return x + y;
}

def main():int{
    int a;
    int i;
    a = 0;

    for (i=0;i<5;i++){
        a = plus(a, i);
        printi(a);
    }
}

Execution:

Direct interpretion:

$csli sum.csl
1
3
6
10
15

Compile and run:

$cslc sum.csl
$./sum
1
3
6
10
15

pycsl's People

Contributors

yanzewu avatar

Watchers

James Cloos 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.