Go to file
2025-10-07 10:22:49 -07:00
src wip 2025-10-07 10:22:49 -07:00
.gitattributes Initial commit 2025-09-25 20:17:27 -07:00
.gitignore Initial commit 2025-09-25 20:17:27 -07:00
build.ts Initial commit 2025-09-25 20:17:27 -07:00
bun-env.d.ts Initial commit 2025-09-25 20:17:27 -07:00
bun.lock editor 2025-09-26 16:16:09 -07:00
bunfig.toml emoji 2025-09-29 11:40:32 -07:00
CLAUDE.md Initial commit 2025-09-25 20:17:27 -07:00
package.json emoji 2025-09-29 11:40:32 -07:00
README.md ok, cool 2025-10-06 16:37:07 -07:00
tsconfig.json OMG hairy 2025-10-02 14:05:17 -07:00

Shrimp Language

Overview

Shrimp is a shell-like scripting language that combines the simplicity of command-line interfaces with functional programming concepts. Built using Lezer (CodeMirror's parser system) with TypeScript.

Language Design Philosophy

  • Everything is an expression - Commands, assignments, and functions all return values
  • Whitespace matters - Spaces distinguish operators from identifiers (e.g., x-1 is an identifier, x - 1 is subtraction)
  • Shell-like command syntax - echo hello world works naturally
  • Named arguments without quotes - tail file.txt lines=30
  • Unbound symbols become strings - echo hello treats hello as a string if not defined
  • Simplicity over cleverness - Each feature should work one way, consistently. Two simple features that are easy to explain beat one complex feature that requires lots of explanation

Current Status & Goals

Today's Implementation Goals

  1. Interpreter Setup - Renamed evaluator to interpreter for clarity
  2. Command Execution - Support calling external commands and built-in functions
  3. Variable Assignment - Implement assignment with validation using Lezer context tracking

Parser Features

  • Distinguishes between identifiers (assignable) and words (non-assignable)
  • Smart tokenization for named args (lines=30 splits, but ./path=value stays together)
  • Handles ambiguous cases (bare identifier could be function call or variable reference)

Grammar Architecture

See src/parser/example.shrimp for language examples and src/parser/shrimp.grammar for the full grammar.

Key Token Types

  • Identifier - Lowercase/emoji start, can contain dashes/numbers (assignable)
  • Word - Any non-whitespace that isn't a valid identifier (paths, URLs, etc.)
  • FunctionCall - Identifier followed by arguments
  • FunctionCallOrIdentifier - Ambiguous case resolved at runtime