Package Exports
- ris-language
- ris-language/index.js
This package does not declare an exports field, so the exports above have been automatically detected and optimized by JSPM instead. If any package subpath is missing, it is recommended to post an issue to the original package (ris-language) to support the "exports" field. If that is not possible, create a JSPM override to customize the exports field for this package.
Readme
RIS-Language
A Node.js interpreter for the Reverse Instruction Set (RIS) language - a minimal assembly-like language designed for OS development.
Installation
# Install globally to use the CLI
npm install -g ris-language
# Or install locally in your project
npm install ris-languageCommand Line Usage
Once installed globally, you can run RIS programs from the command line:
ris path/to/program.risOptions:
--debug: Enable debug output showing execution details
Programmatic Usage
You can also use the RIS interpreter in your JavaScript code:
const ris = require('ris-language');
// Execute RIS code from a file
ris.executeFile('path/to/program.ris')
.then(() => console.log('Program completed'))
.catch(err => console.error('Error:', err));
// Or execute RIS code directly from a string
const code = `
PRN Hello from RIS!
VAR name = << What's your name?
PRN Nice to meet you, ${name}!
HLT
`;
ris.executeCode(code)
.then(() => console.log('Program completed'))
.catch(err => console.error('Error:', err));RIS Language Basics
RIS is a minimal assembly-like language with the following instruction set:
Instructions
PRN: Print a messagePRN Hello, World! PRN Message >> ; Output directionVAR: Declare a variableVAR name = value VAR input = << Enter value: ; Input direction with promptHLT: Halt execution (required at the end of every program)HLT
Data Flow Operators
>>: Output direction<<: Input direction
Variables
Reference variables using ${variable_name} syntax:
VAR name = John
PRN Hello, ${name}!Comments
Use semicolons for comments:
; This is a commentExamples
Hello World
; Simple Hello World program
PRN Hello, World from RIS!
HLTUser Input
; Program that asks for a name
PRN Welcome to RIS!
VAR username = << Please enter your name:
PRN Hello, ${username}! Nice to meet you!
HLTAPI Reference
executeFile(filePath, options)
Executes a RIS program from a file.
filePath: Path to the RIS fileoptions: Configuration optionsdebug: Enable debug mode (default: false)
- Returns: Promise that resolves when execution completes
executeCode(code, options)
Executes RIS code from a string.
code: RIS code to executeoptions: Configuration optionsdebug: Enable debug mode (default: false)
- Returns: Promise that resolves when execution completes
parseRIS(code)
Parses RIS code into an executable format.
code: RIS source code- Returns: Parsed code object
executeRIS(parsedCode, options)
Executes parsed RIS code.
parsedCode: Parsed RIS code fromparseRIS()options: Configuration optionsdebug: Enable debug mode (default: false)
- Returns: Promise that resolves when execution completes
License
MIT