Getting Started¶
Welcome to osl. This guide will help you set up the environment and explore the key features of osl.
VSCode Extension: osl. Syntax Highlighting¶
Before you go ahead, enhance your coding experience with the osl-syntax-highlighting
VSCode extension:
- Open VSCode.
- Go to Extensions (
Ctrl+Shift+X
). - Search for
osl-syntax-highlighting
and install. - Open
.osl
files to enjoy syntax highlighting and basic autocompletion.
Download it from the VSCode Marketplace.
Quick Installation (C++ version)¶
The osl. compiler (cosl.) is under development written in C++ (current version supports typechecking). For now, use the following instructions:
- Clone the repository:
- Build the compiler (in progress):
Quick Installation (Python legacy version)¶
For the complete dummy osl. compiler (in Python) including bytecode and VM (in C++), use:
Requirements¶
- Python 3.10+
-
GCC compiler
-
Clone the repository:
- Install dependencies:
- Build the C VM:
Run the interpreter¶
or
Compile to bytecode¶
or
Execute bytecode with C VM¶
Additional flags¶
-t
or --time
: Display execution/compilation time
Generate coverage report¶
coverage run --include="src/codegen.py,src/visualizer.py,src/osl_lexer.py,src/osl_parser.py" run.py <codeFile.osl> -c
coverage html
Writing a simple program¶
Here's a simple program in osl:
To run this:
- Save it as
code.osl
. - Use the osl compiler (python version) to compile and execute:
Expected output:
Overview of Features¶
OSL is designed to be a modern, efficient scripting language. Here’s a quick look at its features (some implemented, others proposed):
- Unambiguity: Grammar designed to eliminate parsing ambiguities (see Grammar).
- Garbage Collection: Automatic memory management via a mark-and-sweep GC in the Stack VM (see GC).
- Escape Analysis: Planned optimization to reduce heap allocations.
- Bytecode-Generated Stack VM: Executes programs via an efficient stack-based virtual machine (see Bytecode).
- Strongly Typed: Enforces type safety with explicit declarations (e.g.,
i32
,bool
).
Let’s dive deeper in the User Documentation!