ifzz / Wsp_language

基于golang开发的解释型语言 使用wsp虚拟机,效率极高

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

Logo

WSP

一门解释型语言

MIT License

安装WSP

vi /ect/profile
export WSPPATH=WSP所在目录
ln -s WSP所在目录/wsp /usr/bin

介绍

基于golang开发的解释型语言 使用wsp虚拟机,效率极高,有PHP的简单 Python的实用 Golang的效率

开发

wsp [命令行形式]
wsp ./xxxx.wsp

语法

自定义函数

function 函数名(参数){
    //代码块
}

自定义变量

$xx=xx;

循环

xx;xx;xx形式
for(条件){
    //代码块
}
while形式
for(条件){
    //代码块
}
do_while形式
for{
    //代码块
}(条件)
死循环
for{
    //代码块
}

判断

if(条件){
    //代码块
}else if(条件){
    //代码块
}else{
    //代码块
}

Switch语句

$a = "3";
switch($a){
    case 1:
        print(1);
    case 2:
        print(2);
    case 3:
        print(3);
    default:
        print(4);
}

wgo协程

wgo func();//堆栈均共享(可选)

class类

class Test{
    function PrintClass($a){
        print($a);
    }
    function _init_($c){
         $this->Var=$c;
         print($this->Var);
    }
    function TestPrint(){
        $this->PrintClass($this->Var);
    }
    $Var = 110;
}
$TestClass = new Test(001);
$TestClassB = new Test(002);
$TestClass->Var = "测试";
$TestClassB->Var = "测试2";
$TestClass->TestPrint();
$TestClassB->TestPrint();

Class继承

class Test{
    function TestPrinta(){
        print($this->Vara);
    }
    $Var = 0;
    $Vara = 0;
}
class TestB{
    function TestPrintb(){
        print($this->Var);
    }
    $Var = 1;
}
class TestC extends Test,TestB{
    function _init_(){
        print($this->Var)
    }
    function Test(){
        print("extends");
        print($this->Var);
    }
}
$a = new TestC();
$a->Var=10086;
$a->TestPrinta();
$a->Test();

面向容器编程 (暂定)

CurEnv->this->5555->31; //公开的容器 ID 31  //端口5555
        $TestArray[0]=10086;
        $All = 0;
CurEnv->this->0->Main;  //不公开的容器 主容器  
        $Pinter = Raflect.OpenCont(31);
        $All = Raflect.ReadCont($Pinter,"All")+1;
        $TestArray = Raflect.ReadCont($Pinter,"TestArray");
        Sys.Println($All);
        Sys.Println($TestArray[0]);

扩展开发 (未来会进行修改 [待定])

可以查看 Ext/Test 测试插件作为实例

package main

import(
  "fmt"
)
func Func_Info()(map[int]string){  //系统核心
    info := make(map[int]string)  //函数列表
    info[0] = "Testb"
    info[1] = "Tests"
    return info
}
func Package_Info()(string){  //系统核心
    info := "Test"   //包名设置
    return info
}


func Testb(Value map[int]string)(string){    //Testb扩展函数 wsp调用 Test.Testb()
    fmt.Println("b")
    return "TRUE"
}

func Tests(Value map[int]string)(string){    //Tests扩展函数 wsp调用 Test.Tests()
    fmt.Println("s")
    return "TRUE"
}
//扩展编译指令
//go build -buildmode=plugin -o test.so Test.go

License

MIT

About

基于golang开发的解释型语言 使用wsp虚拟机,效率极高

License:MIT License


Languages

Language:Go 100.0%