Skip to content

covscript/covscript

Repository files navigation

Covariant Script Programming Language: The Interpreter

Build & Test CodeQL Advanced

Welcome to the Covariant Script programming language!
Covariant Script is an open source, cross-platform programming language.
This project is an officially maintained Covariant Script interpreter.

Sponsor This Project - Support development and contribute to the community's future

Switch language

Features

  • Cross-platform, supporting most mainstream Operating Systems
    • Apple macOS: Universal binary with x86_64 (Intel) and ARM64 (Apple Silicon)
    • Linux and Unix: x86, ARM, MIPS, LoongArch
    • Microsoft Windows: x86, ARM
    • [New!] Google Android: x86, ARM (The complete environment is available in Termux environment)
  • Powerful and bloat-free extension system
    • C/C++ Native Interface(CNI) System: translate invoking from both C/C++ and Covariant Script
    • Interpreter Bootstrap: A portable way to access the Covariant Script Runtime from C++
    • CNI Composer Macro: Combined the extension system and CNI system organically
    • CFFI Support: Directly calling functions from shared library written in C
  • Self-developed efficient compilation system
    • Dependency-free and efficient compiler front-end
    • Unicode support optimized for Chinese
    • Support compile-time optimization
    • Exportable compilation results
  • High-performance runtime environment
    • Stackful asymmetric coroutine
    • Hotspot optimization algorithm
    • Efficient memory management system
    • Reference count garbage collection system

Documents

Please visit Covariant Script Organization README

Codespace

You can try CovScript in GitHub Codespace directly.

Open in GitHub Codespaces

Installation

  • [Recommend] Download installation package from covscript.org.cn
  • Download the precompiled executable on the Latest Release
  • Directly compile source code with CMake toolchain

Run

Basic command

cs [options...] <FILE|STDIN> [arguments...]
cs [options...]

When replace FILE with STDIN, interpreter will directly reads inputs from standard input stream.

Options

Interpreter
Option Mnemonic Function
--compile-only -c Only compile
--dump-ast -d Export abstract syntax tree
--dependency -r Export module dependency
--csym <FILE> -g <FILE> Read cSYM from file
Interpreter REPL
Option Mnemonic Function
--silent -s Close the command prompt
--args <...> -a <...> Set the covscript arguments

Note that everything you set after option --args or its mnemonic -a will be regarded as arguments.

Common
Option Mnemonic Function
--no-optimize -o Disable optimizer
--help -h Show help information
--version -v Show version information
--wait-before-exit -w Wait before process exit
--stack-resize <SIZE> -S <SIZE> Reset the size of runtime stack
--log-path <PATH> -l <PATH> Set the log and AST exporting path
--import-path <PATH> -i <PATH> Set the import path

The default stack size is 64. This is the initial reserved size - the stack will grow automatically as needed, with the upper limit determined by system constraints. When the stack size is set to 1000 or larger, the stack size of the coroutine will be dynamically adjusted to one tenth of the set size; when the stack size is set smaller than 1000, the stack size of the coroutine will remain at 64.

Note that if you do not set the log path, it will be directly output to the standard output stream.

Debugger

cs_dbg [options...] <FILE>

Options

Option Mnemonic Function
--help -h Show help information
--version -v Show version information
--silent -s Close the command prompt
--wait-before-exit -w Wait before process exit
--csym <FILE> -g <FILE> Read cSYM from file
--stack-resize <SIZE> -S <SIZE> Reset the size of runtime stack
--log-path <PATH> -l <PATH> Set the log path
--import-path <PATH> -i <PATH> Set the import path

The stack size policy is the same as for the interpreter.

Note that if you do not set the log path, it will be directly output to the standard output stream.

Examples

The covscript-example repository contains several example programs written in Covariant Script.

Related Projects

Explore these official projects to enhance your Covariant Script experience:

  • Handbook - Comprehensive getting started guide, tutorials, and best practices for learning CovScript
  • VSCode Extension - Official VSCode extension with syntax highlighting, code completion, and debugging support
  • Package Manager (cspkg) - Official package manager for easy dependency management and package distribution
  • Examples - Collection of example programs and use cases

Tools & Resources

Development Tools

  • VSCode Extension - Recommended IDE integration with full language support
  • Package Manager - Manage dependencies with cspkg command-line tool
  • Handbook - Official documentation and learning resources

Community

Copyright

The author of the Covariant Script Programming Language is @mikecovlee, licensed under Apache 2.0
Copyright © 2017-2025 Michael Lee(李登淳)
This software is registered with the National Copyright Administration of the People's Republic of China(Registration Number: 2020SR0408026) and is protected by the Copyright Law of the People's Republic of China.

For Contributors

When contributing to Covariant Script:

  • Your contributions are always attributed to you
  • Your name/GitHub handle is preserved in project history
  • Significant contributors may be recognized in version release notes and documentation
  • You retain copyright to your contributions under the Apache 2.0 license
  • Active contributors may receive bonuses from sponsorship funds (distributed annually based on contribution metrics)

For a complete list of contributors, please visit our Contributors page. For sponsorship details, see Sponsoring page.

Citation

Please cite the repo if you use CovScript.

@misc{CovScript,
  author = {Li, Dengchun},
  title = {Covariant Script Programming Language},
  year = {2017},
  publisher = {GitHub},
  howpublished = {\url{https://github.com/covscript/covscript}}
}

Thanks

Sichuan University, KDDE Lab (Prof. Lei Duan), freeCodeCamp Chengdu Community

@imkiva, @ice1000, @MouriNaruto, Weicheng Shi