This file provides guidance to Claude Code (claude.ai/code) when working with code in this repository.
Online AlpLogo is a browser-based educational programming environment for teaching turtle graphics programming. It features a custom Logo-like language interpreter with multi-language support (English, Azerbaijani, and Russian) and provides a complete IDE with code editor, canvas visualization, and debugging tools.
- Framework: Vue 3 with Composition API and
<script setup>syntax - Language: TypeScript with strict mode enabled
- Build Tool: Vite 7.x
- State Management: Pinia 3.x
- Code Editor: CodeMirror 6 (via
vue-codemirror6) - Styling: Scoped CSS in Single File Components
# Start development server (runs on port 3000)
npm run dev
# Type-check and build for production
npm run build
# Preview production build
npm run preview
# Run parser tests
npm testThe AlpLogo language is processed through a traditional interpreter architecture:
- Lexer (
src/core/parser/Lexer.ts): Tokenizes source code - Parser (
src/core/parser/Parser.ts): Recursive descent parser generating an AST - Interpreter (
src/core/interpreter/Interpreter.ts): Executes AST nodes with turtle graphics output
Key files:
- Token definitions and multi-language mappings:
src/core/parser/tokens.ts - AST node types:
src/core/ast/types.ts - Built-in command implementations:
src/core/interpreter/builtins.ts
The language supports three locales with keyword/command mappings:
- English:
forward,repeat,if,variable, etc. - Azerbaijani:
ileri,tekrar,eger,deyisen, etc. - Russian:
вперед,повтори,если,переменная, etc.
All commands normalize to English internally via COMMAND_MAP and KEYWORD_MAP in src/core/parser/tokens.ts.
| Store | File | Purpose |
|---|---|---|
| Editor Store | src/stores/editor.ts |
Code content, errors, line tracking |
| Turtle Store | src/stores/turtle.ts |
Canvas state, draw commands, turtle position |
| Execution Store | src/stores/execution.ts |
Execution mode, pause/resume, step debugging |
| Modal Store | src/stores/modal.ts |
Modal visibility management |
The interpreter supports three execution modes controlled via src/stores/execution.ts:
- Immediate: Fast execution without delays
- Animated: Step-by-step visualization with configurable speed (1-100)
- Step: Debug mode - pauses after each statement, waits for user step
Turtle graphics use a hybrid approach in src/components/canvas/TurtleCanvas.vue:
- Canvas API: High-performance rendering of lines, text, and dots
- SVG Overlay: Turtle sprite with rotation and visibility states
src/
├── components/ # Vue SFCs (organized by feature)
│ ├── editor/ # CodeEditor, EditorToolbar, ErrorDisplay
│ ├── canvas/ # TurtleCanvas
│ ├── ui/ # AppHeader, Sidebar, SplitPane, StatusBar
│ └── modals/ # ModalContainer, HelpModal, ExamplesModal, LanguageReferenceModal
├── core/ # Interpreter & Parser
│ ├── ast/ # AST type definitions
│ ├── parser/ # Lexer, Parser, tokens, Parser.test.ts
│ └── interpreter/ # Interpreter, builtins, Environment
├── stores/ # Pinia stores (editor, turtle, execution, modal)
└── languages/ # Syntax highlighters (CodeMirror 6, Monaco legacy)
| File | Purpose |
|---|---|
src/languages/alplogo.ts |
Monaco Editor language definition (legacy) |
src/languages/alplogo-codemirror.ts |
CodeMirror 6 syntax highlighter - Active syntax highlighting for multi-language commands |
| Purpose | File Path |
|---|---|
| HTML Entry | index.html |
| App Bootstrap | src/main.ts |
| Root Component | src/App.vue |
| CodeMirror Language | src/languages/alplogo-codemirror.ts |
The project includes a custom test runner for parser validation:
- Test File:
src/core/parser/Parser.test.ts - Test Runner:
tsx(TypeScript execute) - Coverage: Tests for all three languages (EN, AZ, RU), control flow keywords, system values, nested structures, comparison operators, and subroutine syntax
Run tests with npm test.
-
Store-to-Store Communication: Components often use multiple stores (e.g., EditorToolbar uses editor, turtle, and execution stores)
-
Interpreter Callbacks: The Interpreter class uses callback options for UI updates (
onDrawCommand,onTurtleUpdate,onLineChange) -
Error Handling: Parse and interpreter errors include line/column information for editor highlighting
-
Multi-language AST: The parser normalizes all commands to English internally while preserving original command names for error messages
-
CodeMirror Integration: The editor uses CodeMirror 6 with a custom StreamLanguage definition in
src/languages/alplogo-codemirror.tsfor syntax highlighting across all three supported languages -
Custom Test Runner: Parser tests use a lightweight custom test framework (not Jest/Vitest) executed via
tsxfor fast TypeScript testing without bundling