{"id":36953050,"url":"https://github.com/user19870/cppsp","last_synced_at":"2026-04-01T23:14:50.130Z","repository":{"id":329439993,"uuid":"1111269478","full_name":"user19870/cppsp","owner":"user19870","description":"cppsp --a transpiled script-like language base on c++","archived":false,"fork":false,"pushed_at":"2026-03-22T15:10:43.000Z","size":14647,"stargazers_count":5,"open_issues_count":1,"forks_count":1,"subscribers_count":1,"default_branch":"First","last_synced_at":"2026-03-23T00:28:59.899Z","etag":null,"topics":["compile-language","cpp","cppsp","linux","mac","open-source","script-like","transpiled-language","windows"],"latest_commit_sha":null,"homepage":"","language":"C++","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"gpl-3.0","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/user19870.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null,"zenodo":null,"notice":null,"maintainers":null,"copyright":null,"agents":null,"dco":null,"cla":null}},"created_at":"2025-12-06T16:00:19.000Z","updated_at":"2026-03-22T15:07:24.000Z","dependencies_parsed_at":null,"dependency_job_id":null,"html_url":"https://github.com/user19870/cppsp","commit_stats":null,"previous_names":["user19870/cppsp"],"tags_count":21,"template":false,"template_full_name":null,"purl":"pkg:github/user19870/cppsp","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/user19870%2Fcppsp","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/user19870%2Fcppsp/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/user19870%2Fcppsp/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/user19870%2Fcppsp/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/user19870","download_url":"https://codeload.github.com/user19870/cppsp/tar.gz/refs/heads/First","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/user19870%2Fcppsp/sbom","scorecard":null,"host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":286080680,"owners_count":31292846,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2026-04-01T21:15:39.731Z","status":"ssl_error","status_checked_at":"2026-04-01T21:15:34.046Z","response_time":53,"last_error":"SSL_read: unexpected eof while reading","robots_txt_status":"success","robots_txt_updated_at":"2025-07-24T06:49:26.215Z","robots_txt_url":"https://github.com/robots.txt","online":false,"can_crawl_api":true,"host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["compile-language","cpp","cppsp","linux","mac","open-source","script-like","transpiled-language","windows"],"created_at":"2026-01-13T12:32:35.597Z","updated_at":"2026-04-01T23:14:50.114Z","avatar_url":"https://github.com/user19870.png","language":"C++","readme":"# cppsp\u003cimg src=\"cppsp.png\" width=\"5%\" alt=\"cppsp logo\"/\u003e\ncppsp -a transpiled script-like language base on c++\n* [English](https://github.com/user19870/cppsp)\n* [中文](.github/workflows/README_tw.md)\n## Install\nDownload the cppsp_compiler.exe or compiler the sourcecode by yourself\n* Requirement:prepare your own c++ compiler and set it's folder to environment path(environment variable)\n* Requirement:a 64bits c++ compiler to make sure exe can be open\n* Optional: put the folder path of exe/elf/mach-o to environment\n* remember delete _mac/_linux to make cppsp_compiler works\n* (Optional) rename cppsp_compiler.exe(or cppsp_compiler) to any name you like to change compile command like:cppsp、abcdef....\n* Install from cmd/console:\n#### Windows:\n```\n  curl -L -o cppsp_compiler.exe https://github.com/user19870/cppsp/raw/refs/heads/First/cppsp_compiler.exe\n```\n#### Linux:\n```\n  curl -L -o cppsp_compiler https://github.com/user19870/cppsp/raw/refs/heads/First/cppsp_compiler_linux.delete_linux\n```\n#### Mac:\n```\n  curl -L -o cppsp_compiler https://github.com/user19870/cppsp/raw/refs/heads/First/cppsp_compiler_mac.delete_mac\n```\n## Usage\n* Use cmd or other console to compiler .cppsp file:\n`cppsp_compiler(if not in environment path:.\\cppsp_compiler.exe or c:\\...\\cppsp_compiler.exe) script.cppsp`\n* **`cppsp_compiler mod.cppsp -header`** will generate .h file and turn int main(){...} a comment\n* **`cppsp_compiler new project`**  : create new project with empty include.ini、lib.ini、module.ini、project.cppsp and setting current path in the three .ini\n* Setting c++ include/lib/cppsp_mod folder by .ini file\n```\ninclude.ini:C:\\...\\include1,c:\\...\\include2\nlib.ini:C:\\...\\lib1,c:\\...\\lib2\nmodule.ini:C:\\...\\modfolder1,c:\\...\\modfolder2\n```\n## Feature\n* can compile when there is only print(\"hello world\") in .cppsp\n* can use almost c++ header by import\n- can use .cppsp mod by import\n  - deepermod.cppsp still can use c++ header and .cppsp mod by import \n* user-custom syntaxs by pattern-driven, nested, namespace-scoped templates \n* can use c++ code  by @inject and @function\n* enable indentation and multi-line after v1.3\n* declare multi variables with `var`.....`type`\n* control variables inside keyword or globle\n* Can use utf8 encoding bytes as alternative of filename: `cppsp_compiler \\xe9\\x80\\x99\\xe6\\x98\\xaf\\x20\\xe4\\xb8\\xad\\xe6\\x96\\x87\\x68\\x75\\x20\\x6b\\x6f\\x6c\\x20\\x20\\x70\\xe6\\xaa\\x94\\xe6\\xa1\\x88\\x2e\\x63\\x70\\x70\\x73\\x70`\n* Enable compile filename encoded by utf8(I try my best but some devices may not work.)\n## Keyword\n* `#useclang` or `#usegcc` : use clang++ or g++ compile command\n* `@command(\"...\")`: add command when compile like:-Os、-m64\n* `#overwrite`:make `@command()` overwrite g++ .... or clang++ compile command like `@command(\"g++ -Os -m64 -nostdlib  -shared   -o dll.dll dll.cpp\")` and add \"*/\"  after int main(){..} also add \"/\\*\" in front of int main(){..} \n*  `#skipcompile` : skip g++/clang++ compile and directly run output\n- `import` :import header in c++ and accept import iostream,cstdio,x,y,.....\n  - import can also import .cppsp mods like`import a.b.mod`|  **a.b.mod represent the path a/b/mod.cppsp and path will be searched from parent path in module.ini** |  a.b.mod also generate namespace a{ namespace b{ namespace mod{...}}}\n* `package` : it is written in .cppsp, `package d.e.f` will replace namespace generated by import a.b.c\n* `@function\u003c\u003c...\u003e\u003e`: inject everything(void()、int()、bool()、even #define and using namespace) in \u003c\u003c...\u003e\u003e to the space under #include above int main().**Better not put any word, symbol or blanks but enalbe \"enter\" or nothing after \"\u003e\u003e\" to make difference between operation like `a\u003e\u003eb` and \u003c\u003c....\u003e\u003e**\n*  `@inject(...)` :inject everything in (...) to int main(){...}  ----`＠inject(....)`and `＠inject(\"....\")` are both legal. ＠inject(....) belonging to line ast and ＠inject(\"....\") belonging to token ast  but ＠inject(....) will be transpiled before ＠inject(\"....\") and any keyword belonging to token ast.)\n* `print()`: print content to console like print(\"12\\n\",\" \",1,\" \",2.1,true,false,\" \")\n* `input()`: input data to variables\n* `var`.....`type`: declare variables with/without values. Support multi variables and type can be written as `int/float/char/string/bool`. \u003c{1+1}\u003e is a value but 1+1 not(it's expression)\n* `if/else/else if/while(...){...}`:similar to \"if/else/else if\" in c++ but enable syntax: `if(input(x)\u003e1)`. Can write cppsp keywords and operation( =,+,-,*,/,++....) in {...}\n* `for(...){...}`:similae to \"for\" in c++ like for( type i=0,i\u003c10,i++), for(type i=0,j=10;i\u003c10\u0026\u0026j\u003e0;i++,j++) or for(type i:x) . Can write cppsp keywords and operation( =,+,-,*,/,++....) in {...}\n* `function f()...`:`function f() type {...return...}` will define a function with type, `function f(){...}` will define a void function,`function f()` will declare a void function, `function f(){...return...}`  will define a function with auto in c++. [Usages](example/functionTest.cppsp)\n```\nfunction [std::pow,std::sort,abs,sqrt] // will regist functions from c++\n// but template function still need \u003c{...}\u003e like  std::sort(x,x+5,\u003c{ std::greater\u003cint\u003e()}\u003e) \n```\n[Usecppfunction](example/Usecppfunction.cppsp)\n* [`struct S{...}`](example/structtest.cppsp) : define a structure and the name of structure will become a type ,so can use something like var....S. If write `struct a b c`without `{}` a ,b, and c will become type but won't generate any c++ code\n- [`@custom xxx(\"...\",\u003c{...}\u003e,...)`](https://github.com/user19870/cppsp/blob/First/example/customSyntax.cppsp) : ＠custom can let users write own syntaxs. it is a transpile-time pattern-driven code generator with nested templates, namespace-scoped features **\"...\" can generate code, \u003c{...}\u003e is similar to it but will become a placeholder and replaced by parameter when the custom syntax is called.** Code will generate in global and the inner of some cppsp keywords. ` namespace n{ @custom.... }`\n  -  If there is any \"＠\" is in ＠custom like `＠custom vec＠mn(\"std::vector\u003c\",\u003c{type}\u003e,\"\u003e\") `  vec＠mn(...) will generate code in main(){....}\n```\n@custom subs(\u003c{T}\u003e,\" sub(\",\u003c{T a}\u003e,\",\",\u003c{T b}\u003e,\")\",\" {return a-b;}\")\nsubs(int ,int a,int b)\n```\n- `use` :  use namespaces like :`use a.b.c`. \"xxx\" from @custom xxx(...) also affected by `use`\n   - `use a.b.c-\u003ed` can use function/struct/other in namespace a.b.c but not use the whole namespace  \n* `//`:comment\n## Syntax\n* control variables in cppsp once a line or separate by `;`\n```\ny=e()\ny=4.6; y++ ;y++\n```\n* `\u003c{...}\u003e` : c++ code or everything in \u003c{...}\u003e will become an element of cppsp keyowds like  :\n```\n  import math.h,iostream\nprint( \u003c{pow(2,3)}\u003e)\n```\n* `var`......`type`:\n```\nimport  string,iostream\nvar a,c,d =  1,\n\u003c{(2*2+6)/2}\u003e\n,4 int\nvar b = \"hello world\" string\nvar f1,f2,f3 float\nvar c1 char\nvar b1 = \u003c{1+1==2}\u003e bool\ninput(f1)\nprint(a,\" \",c,\" \",d,\" \",b,\" \",b1,\" \",f1)\n```\n* array and operation:\n```\nimport iostream\nvar x={1,2,3} int\n@inject(\"x[0]=3;x[1]=2; x[2]=1;\")\nif(true) {\n  x[0]=4\n}\nfor(int i=0,i\u003c3,i++) {x[i]=0}\n```\n## OOP\n* Inheritance : enable single and multi inheritance, use `public: a, b,c` inheritance in c++\n```\nstruct local{\n    extension_slot(\"local\")\n}\nstruct der derive(cppsp.test.mytype,local,\u003c{std::vector\u003cint\u003e}\u003e){\n\n}\n```\n* Extension : used to extend a struct. extension_slot(\"id\") can provide a slot to expand(id is decided by mod writter)\n```\nimport cppsp.cpp17.base, test\n\nstruct local{\n    private:\n    function f1(){}\n    var v int\n    public:\n    function f2(){}\n    var outv int\n    extension_slot(\"local\")\n}\nstruct extension(\"local\"){\n    function m1()\n    function m2()\n}\nstruct extension(\"cppsp.test.mytype\"){\n    function n1(){\n        print(\"test1\\n\")\n    }\n}\nstruct extension(\"local\"){\n    function m3(){\n        print(\"test2\\n\")\n    }\n}\nlocal o\no.m3()\ncppsp.test.mytype oo\noo.n1()\n```\n### Warning ⚠️\n* Cannot accept any space/blank before keyword before v1.2! \n* No multi-line before v1.3!\n* `＠command()` will never be multi-line but you can use following as an alternative\n```\n＠command(\"-f1 -f2 ..... -f5\") \n＠command(\"-f6 -f7 ....-f10\") \n```\nwith `＃overwrite` command\n```\n＠command(\"g++ -Os -m64 -nostdlib  -shared \") \n＠command(\" -o dll.dll dll.cpp\") \n ```\n## Example\n```cpp\n print(\"hello world\")\n```\n* another exmaple:\n```cpp\n@command(\"-mtune=native   -fomit-frame-pointer -static-libgcc   -ffunction-sections -fdata-sections -Wl,--gc-sections  -Wl,--as-needed  -s  -Wl,--strip-all  -Os -m64\")\nimport iostream,vector\n@function\u003c\u003cusing namespace std;\u003e\u003e\nprint(\"12\\n\",\" \",1,\" \",2.1,true,false,\" \")\nprint( \"abc\")\nprint(1,\"\\n\") //abv\n//print(1.1)\n@inject(int x=1;int y=2;int z=3; auto is_bool = [](const std::string\u0026 s){ return s == \"true\" || s == \"false\";};)\ninput(x,y,z)\n@function\u003c\u003cclass cls{vector\u003c string\u003e cars = {\"Volvo\", \"BMW\", \"Ford\", \"Mazda\"};};\u003e\u003e\nprint(x+y+z)\n```\n* simple dll\n```cpp\n#overwrite\n@command(\"g++ -Os -m64 -nostdlib  -shared   -o dll.dll dll.cpp\")\n@function\u003c\u003cextern \"C\" __declspec(dllexport) int add(int a, int b) { return a * b;}\u003e\u003e\n```\n* [swap](example/swap.cppsp)\n","funding_links":[],"categories":[],"sub_categories":[],"project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fuser19870%2Fcppsp","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fuser19870%2Fcppsp","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fuser19870%2Fcppsp/lists"}