Movatterモバイル変換


[0]ホーム

URL:


Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings
This repository was archived by the owner on Jan 8, 2023. It is now read-only.

A new statically typed programming language, syntactically like TypeScript.

License

NotificationsYou must be signed in to change notification settings

StaticScript/StaticScript

Repository files navigation

StaticScript is a statically typed programming language, syntactically like TypeScript.

Github Workflow StatusPlatformLicense

GitHub Repo starsGitHub forksGitHub issuesGitHub pull requests

GitHub Repository SizeGitHub code size in bytesGitHub top language

English |简体中文

Install

Install on Ubuntu

/bin/bash -c"$(curl -fsSL https://raw.githubusercontent.com/StaticScript/StaticScript/master/install-ubuntu.sh)"

Or

wget https://raw.githubusercontent.com/StaticScript/StaticScript/master/install-ubuntu.shsudo chmod +x install-ubuntu.shsudo /bin/bash install-ubuntu.sh

For other linux distributions, you may need to modify the installation script to install properly.

The installation script may request administrator privileges.

Install on macOS

/bin/bash -c"$(curl -fsSL https://raw.githubusercontent.com/StaticScript/StaticScript/master/install-macos.sh)"

Or

wget https://raw.githubusercontent.com/StaticScript/StaticScript/master/install-macos.shsudo chmod +x install-macos.shsudo /bin/bash install-macos.sh

The installation script may request administrator privileges.

Install on Windows

Temporarily not supported

Usage

First you need to write a legal StaticScript code file as following.

// test.ssletcontent:string="Hello World";ss_println_string(content);

Then execute the following command from the command line.

staticscript test.ss -otest./test

Language Features Summary

Variable and Constant Declaration

Here are some variable declarations.

letflag:boolean=true;letcount:number=20;letcontent:string="Hello World";

Thanks to the type inference feature of StaticScript, we can write the above variable declaration as follows. They are exactly equivalent.

letflag=true;letcount=20;letcontent="Hello World";

The compiler of StaticScript cleverly deduced the type of the variable from the initial value.

In addition to usinglet to declare variables, you can also useconst to declare constants.

constname="StaticScript";constage=1;constdeveloping=true;

The difference betweenlet andconst is that constants declared withconst cannot be modified.

Variable Evaluation

You can use a wealth of operators to perform operations on variables, including arithmetic operations, bitwise operations, logical operations, relational operations, assignments, and string concatenation.

leta=1;letb=2;// add, subtract, multiply and divideletsum=a+b;letdiff=a-b;letproduct=a*b;letquotient=a/b;a=a<<1;// equivalent to `a <<= 1`b=b>>1;// equivalent to `b >>= 1`letyear="2020",month="08",day="06";letbirthday=year+"/"+month+"/"+day;

Control Flow

leta=1;letb=100;if(a<b){ss_println_string("b is bigger");}else{ss_println_string("b is not bigger");}letmax=a;if(a<b){max=b;}

Loops

StaticScript supports usingwhile statement andfor statement to do some repetitive things.

// Calculate the sum of all even numbers between [1, 100]letsum1=0;leti=1;while(i<=100){if(i%2==0){sum1+=i;}}// Calculate the sum of all integers between [1, 100]letsum2=0;for(leti=1;i<=100;i++){sum2+=i;}

Function

StaticScript supports defining functions in the top level scope and using function in any scope.

functionadd(a:number,b:number):number{returna+b;}

The above function can omit the return type because StaticScript can deduce the return type through the expression of the return statement.

It is important to note that the parameter types of functions must be explicitly declared.


[8]ページ先頭

©2009-2025 Movatter.jp