OwnLang provides a comprehensive set of development tools to support interactive programming, project management, and code quality maintenance. This document covers the interactive REPL system, the package manager, and various command-line utilities that facilitate OwnLang development workflows.
For information about the build system and distribution, see Build and Distribution. For details on the module system that these tools interact with, see Module System.
The OwnLang REPL (Read-Eval-Print Loop) provides an interactive development environment for testing code, exploring the language, and debugging. The REPL implementation is built on top of JLine for enhanced console interaction and command completion.
Sources: ownlang-utils/src/main/java/com/annimon/ownlang/utils/Repl.java1-186
The REPL provides several built-in commands accessible through the :command
syntax:
Command | Purpose | Implementation |
---|---|---|
:help | Display available commands | printHelp() method |
:vars | List variables and constants | printVariables() using ScopeHandler |
:funcs | List user and library functions | printFunctions() with categorization |
:source | Show accumulated source code | Uses PrintVisitor on history |
:reset | Clear input buffer | Buffer reset operation |
:exit | Exit REPL session | Loop termination |
The REPL maintains a BlockStatement
history of successfully parsed statements and can automatically attempt to wrap expressions in println
statements for immediate evaluation display.
Sources: ownlang-utils/src/main/java/com/annimon/ownlang/utils/Repl.java27-33 ownlang-utils/src/main/java/com/annimon/ownlang/utils/Repl.java114-185
The REPL supports multiple console backends with graceful fallback:
Sources: ownlang-utils/src/main/java/com/annimon/ownlang/utils/Repl.java101-112
The OwnLang package manager is implemented as an OwnLang script that provides dependency management, project initialization, and script execution capabilities. The package manager operates through the own
command and is built using a modular class-based architecture.
Sources: ownlang-desktop/src/main/resources/scripts/own.own1-41
The package manager consists of several key classes that handle different aspects of project and dependency management:
Manages package registry operations including caching and HTTP retrieval:
Sources: ownlang-desktop/src/main/resources/scripts/own/Registry.own1-58
Handles project configuration through own-package.json
:
Sources: ownlang-desktop/src/main/resources/scripts/own/Config.own1-76
Manages dependency installation and package operations:
own-modules
directory structure.usage.own
filesSources: ownlang-desktop/src/main/resources/scripts/own/Packages.own1-145
Sources: ownlang-desktop/src/main/resources/scripts/own.own31-40 ownlang-desktop/src/main/resources/scripts/own/Own.own1-81
The package manager uses own-package.json
for project configuration with the following structure:
Field | Purpose | Default Value |
---|---|---|
name | Project identifier | Derived from directory name |
version | Project version | "1.0.0" |
author | Project author | System username |
program | Main program file | "main.own" |
scripts | Executable commands | {"default": ["$ownlang$", "-f", "$program$"]} |
dependencies | Package dependencies | {} |
Sources: ownlang-desktop/src/main/resources/scripts/own/Config.own42-57
The OwnLang development environment includes various command-line utilities for code processing and quality maintenance. These tools operate on OwnLang source code and provide features like beautification, linting, and optimization.
The CLI tools utilize a structured error handling system for parse and runtime errors:
Sources: ownlang-parser/src/main/java/com/annimon/ownlang/exceptions/ParseException.java1-21 ownlang-parser/src/main/java/com/annimon/ownlang/exceptions/OwnLangParserException.java1-27 ownlang-parser/src/main/java/com/annimon/ownlang/parser/error/ParseErrors.java1-54
The development tools integrate with the core language processing pipeline to provide:
The tools maintain compatibility with the module system and can process code that uses both standard library and external package dependencies.
Sources: ownlang-utils/src/main/java/com/annimon/ownlang/utils/Repl.java86-92
Refresh this wiki