cppsp是一個轉譯式語言(原始碼轉原始碼),可以把.cppsp檔案轉成.cpp並編譯、執行,是單人開發的實驗性語言,不適合大專案使用。此cppsp與c++ server pages無關。
curl -L -o cppsp_compiler.exe https://github.com/user19870/cppsp/raw/refs/heads/First/cppsp_compiler.exe
curl -L -o cppsp_compiler https://github.com/user19870/cppsp/raw/refs/heads/First/cppsp_compiler_linux.delete_linux
curl -L -o cppsp_compiler https://github.com/user19870/cppsp/raw/refs/heads/First/cppsp_compiler_mac.delete_mac
cppsp_compiler script.cppsp( 如果沒設定到環境改成.\cppsp_compiler.exe or c:\...\cppsp_compiler.exe)
include.ini:C:\...\include1,c:\...\include2
lib.ini:C:\...\lib1,c:\...\lib2
#useclang 或 #usegcc : 使用clang/gcc編譯@command("..."): 把參數加入編譯指令:-Os、-m64#overwrite:讓 @command() 覆蓋整個編譯指令: @command("g++ -Os -m64 -nostdlib -shared -o dll.dll dll.cpp") 並在 int main(){..}後分別自動加/和/#skipcompile :跳過編譯直接執行結果import :使用c++標頭(不需要<>、"") import iostream,cstdio,x,y,.....
@function<<...>>: 把原生c++程式碼注入到#include 後面 int main()前面@inject(...) : 把程式碼注入到int main(){...}print(): 把內容輸出到終端/控制台 print("12\n"," ",1," ",2.1,true,false," ")
input(): 輸入變數如 input(a,b,c)
var ....type 可以宣告變數,允許多變數宣告,且宣告必須為值不能是算式,但可以用<{....}>把c++程式碼當成值來宣告,type只允許int/float/char/string/boolif/else/else if(...){...} :跟c++的類似,但允許if(input(x)>1),可以在{...}裡面寫變數操作(=,+,-,*,/,++....)和cppsp關鍵字for(...){...}: 支持for( type i=0,i<10,i++)、for(type i=0,j=10;i<10&&j>0;i++,j++)、for(type i:x)等多種方式,可以在{...}裡面寫變數操作(=,+,-,*,/,++....)和cppsp關鍵字function f()...:function f() type {...return...}可以定義有型別函數、 function f(){...}定義void函數、function f()宣告void函數、function f(){...return...}定義函數並使用c++的auto型別function [std::pow,std::sort,abs,sqrt] // 註冊來自c++的函數但具有模板的函數依然需要<{...}>例如 std::sort(x,x+5,<{ std::greater<int>()}>)
struct S{...} :定義一個結構體,結構體名稱會成為型別,所以可以使用var ... S之類的用法//:註解y=e()
y=4.6; y++ ;y++
<{...}> :會把裡面的c++程式碼或所有東西當成cppsp關鍵字的元素例如: import math.h,iostream
print( <{pow(2,3)}>)
var...type:import string,iostream
var a,c,d = 1,
<{(2*2+6)/2}>
,4 int
var b = "hello world" string
var f1,f2,f3 float
var c1 char
var b1 = <{1+1==2}> bool
input(f1)
print(a," ",c," ",d," ",b," ",b1," ",f1)
import iostream
var x={1,2,3} int
@inject("x[0]=3;x[1]=2; x[2]=1;")
if(true) {
x[0]=4
}
for(int i=0,i<3,i++) {x[i]=0}
@command() 將不會支持跨行@command("-f1 -f2 ..... -f5")
@command("-f6 -f7 ....-f10")
配合 #overwrite 關鍵字
@command("g++ -Os -m64 -nostdlib -shared ")
@command(" -o dll.dll dll.cpp")
print("hello world")
@command("-mtune=native -fomit-frame-pointer -static-libgcc -ffunction-sections -fdata-sections -Wl,--gc-sections -Wl,--as-needed -s -Wl,--strip-all -Os -m64")
import iostream,vector
@function<<using namespace std;>>
print("12\n"," ",1," ",2.1,true,false," ")
print( "abc")
print(1,"\n") //abv
//print(1.1)
@inject(int x=1;int y=2;int z=3; auto is_bool = [](const std::string& s){ return s == "true" || s == "false";};)
input(x,y,z)
@function<<class cls{vector< string> cars = {"Volvo", "BMW", "Ford", "Mazda"};};>>
print(x+y+z)
#overwrite
@command("g++ -Os -m64 -nostdlib -shared -o dll.dll dll.cpp")
@function<<extern "C" __declspec(dllexport) int add(int a, int b) { return a * b;}>>
@function<</*>>