Go to file
Corey Johnson cb62fdf437 feat(compiler): add PipeExpr compilation support
Implement Task 6 from docs/plans/2025-10-12-pipe-expressions.md

- Add pipe operator (|) termination to tokenizer
- Update grammar to include expressionWithoutIdentifier in pipeOperand
- Add PipeExpr case to compiler switch statement
- Implement pipe compilation: piped value becomes first argument
- Store piped values in temporary __pipe_value variable
- Handle both FunctionCallOrIdentifier and FunctionCall operands
- Add integration tests for pipe expressions

Tests:
- Simple pipe (5 | double) works correctly
- Additional tests exist but have pre-existing issues with function parameters

🤖 Generated with [Claude Code](https://claude.com/claude-code)

Co-Authored-By: Claude <noreply@anthropic.com>
2025-10-12 17:00:17 -07:00
packages hell yeah 2025-10-10 15:50:09 -07:00
src feat(compiler): add PipeExpr compilation support 2025-10-12 17:00:17 -07:00
.gitignore works better 2025-10-08 17:30:30 -07:00
.gitmodules yessss 2025-10-08 13:56:17 -07:00
bun.lock yessss 2025-10-08 13:56:17 -07:00
bunfig.toml emoji 2025-09-29 11:40:32 -07:00
CLAUDE.md wip 2025-10-12 16:33:53 -07:00
example.shrimp works better 2025-10-08 17:30:30 -07:00
package.json works better 2025-10-08 17:30:30 -07:00
README.md works better 2025-10-08 17:30:30 -07:00
today.md clean 2025-10-09 09:48:27 -07:00
tsconfig.json works better 2025-10-08 17:30:30 -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.

Use it

Go to http://localhost:3000 to try out the playground.

echo "Hello, world!"
tail log.txt lines=50

name = "Shrimp"
greet = fn person: echo "Hello" person

result = tail log.txt lines=10

Language Design Philosophy

  • Shell-like command syntax - echo hello world works naturally
  • Everything is an expression - Commands, assignments, and functions all return values
  • Whitespace matters in binary operations - Spaces distinguish operators from identifiers (e.g., x-1 is an identifier, x - 1 is subtraction)
  • 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

Parser Features

  • Distinguishes identifiers from words to enable shell-like syntax - paths like ./file.txt work without quotes
  • 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)

Architecture

parser/ - Lezer grammar and tokenizers that parse Shrimp code into syntax trees editor/ - CodeMirror integration with syntax highlighting and language support
compiler/ - Transforms syntax trees into ReefVM bytecode for execution

The flow: Shrimp source → parser (CST) → compiler (bytecode) → ReefVM (execution)

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