New Research: Supply Chain Attack on Axios Pulls Malicious Dependency from npm.Details →
Socket
Book a DemoSign in
Socket

dinoscript

Package Overview
Dependencies
Maintainers
1
Versions
1
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

dinoscript

A TypeScript-based language where Okie! replaces true, Hey! replaces false, and Yeah? randomly evaluates to true or false

latest
npmnpm
Version
0.1.0
Version published
Weekly downloads
1
Maintainers
1
Weekly downloads
 
Created
Source

Dinoscript Compiler

Dinoscript is a TypeScript-based language with a fun twist: Okie! replaces true, Hey! replaces false, and Yeah? randomly evaluates to either true or false at compile time.

Architecture

This compiler follows the principles from "Crafting Interpreters" - Representing Code and implements a standard compiler pipeline:

  • Scanning (Lexical Analysis) - Identifies tokens, specifically Okie!, Hey!, and Yeah?
  • Transformation - Converts Okie!true, Hey!false, and Yeah? → randomly chosen true or false
  • TypeScript Compilation - Delegates to TypeScript's compiler for parsing, type checking, and code generation

Installation

npm Package

# Global installation (CLI tool)
npm install -g dinoscript

# Or as a project dependency
npm install dinoscript

VS Code Extension

  • Open VS Code
  • Go to Extensions (Cmd+Shift+X / Ctrl+Shift+X)
  • Search for "Dinoscript"
  • Click Install

Or install via command line:

code --install-extension publisher-id.dinoscript

From Source

git clone https://github.com/yourusername/dinoscript.git
cd dinoscript
pnpm install
pnpm run build

Usage

CLI Compiler

# Transform a file (show output without writing)
pnpm dev transform examples/example.ds

# Compile a .ds file to .ts
pnpm dev compile examples/example.ds examples/example.ts

Programmatic API

import { DinoscriptCompiler } from './src';

const compiler = new DinoscriptCompiler();

// Compile a file
const result = compiler.compile({
  sourceFile: 'example.ds',
  outputFile: 'example.ts',
  verbose: true
});

// Transform source code in memory
const transformed = compiler.transformSource('if (Okie!) { console.log("Hello"); }');
// Result: 'if (true) { console.log("Hello"); }'

Using with TypeScript Compiler

For direct tsc integration, you can use the custom file system host:

import * as ts from 'typescript';
import { createDinoscriptFileSystemHost } from './src';

const options: ts.CompilerOptions = {
  target: ts.ScriptTarget.ES2017,
  module: ts.ModuleKind.ESNext,
};

const host = createDinoscriptFileSystemHost();
const program = ts.createProgram(['example.ds'], options, host);
const emitResult = program.emit();

Example

Dinoscript (example.ds):

function isAwesome(): boolean {
  return Okie!;
}

if (Okie!) {
  console.log("Dinosaurs are awesome!");
}

const flag: boolean = Hey!;

Transformed TypeScript:

function isAwesome(): boolean {
  return true;
}

if (true) {
  console.log("Dinosaurs are awesome!");
}

const flag: boolean = false;

Design Decisions

  • Source-level transformation: We transform the source code before TypeScript's parser sees it. This is simpler than extending TypeScript's scanner/parser.

  • Word boundary detection: The scanner ensures Okie!, Hey!, and Yeah? are only matched when they're standalone tokens, not part of larger identifiers.

  • Case-insensitive matching: Both Okie!/okie!, Hey!/hey!, and Yeah?/yeah? are recognized.

  • Random evaluation: Yeah? randomly evaluates to either true or false at compile time. Each occurrence is independently randomized.

  • Type preservation: The transformed code maintains TypeScript's type system - Okie!, Hey!, and Yeah? become true or false which are typed as boolean.

Testing

Run the test suite:

pnpm test

Project Structure

dinoscript/
├── src/              # Source code
│   ├── types.ts      # Type definitions
│   ├── scanner.ts    # Lexical analysis
│   ├── transformer.ts # Source transformation
│   ├── compiler.ts   # Main compiler
│   ├── ts-transformer.ts # TypeScript integration
│   ├── tsc-integration.ts # tsc integration
│   └── index.ts      # Public API
├── bin/              # CLI scripts
│   └── dinoscript.ts
├── examples/         # Example files
│   ├── example.ds
│   └── test-compilation.ts
├── package.json
├── tsconfig.json
└── README.md

Future Enhancements

  • AST-based transformation (extending TypeScript's scanner)
  • VS Code extension for syntax highlighting
  • Direct browser support via bundler plugins
  • More language features inspired by dinosaurs 🦕

Documentation

See src/ARCHITECTURE.md for detailed architecture documentation.

Keywords

dinoscript

FAQs

Package last updated on 20 Dec 2025

Did you know?

Socket

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Install

Related posts