- Add Sprint 3 plan (37 steps, global 39-75) with canonical memory annotations, test quality requirements, global step numbering, and Sprint 2 overlap notes - Refactor all docs to use canonical annotation families (@Deallocate, @Lifetime, @Reclaim, @Owner, @Allocate) replacing simplified @deref 4-strategy system - Replace @perf with canonical @Hot/@Cold, @Inline, @Pure from annotations/6 optimization - Replace @memory-footprint, @execution-mode, @deref-explicit with canonical equivalents - Update REQUIREMENTS_OVERVIEW, SPRINT_1_REQUIREMENTS, SPRINT_2_PLAN, SPRINT_2_VISION, C++ Implementation Roadmap, example files, and progress report - Remove duplicate bonus steps 41-42, consolidate Phase 3h from 7 to 4 steps Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
8.8 KiB
Sprint 1 Progress Report
Session: 2025-02-05 — TargetLanguage Enum Fix + Status Assessment
What Was Fixed This Session
Bug: Module TextGen generated both Python AND C++ output regardless of the targetLanguage enum selection.
Root Causes (layered):
targetLanguageproperty was typed asstringinstead ofTargetLanguageenum — Fixed inSemAnno.structure.mps- TextGen used
NotEqualsExpression(!=) for string comparison — In Java,!=does reference comparison, not value comparison, so both conditions were alwaystrue - After fixing to
.equals(), MPS generatesgetEnum()for enum-typed properties, returning an enum object, not a String —"cpp".equals(enumObject)always returnsfalse
Final Fix: Used MPS's EnumMember_IsOperation (is operation) from jetbrains.mps.lang.smodel:
Python block condition: !(node.targetLanguage.is(cpp))
C++ block condition: !(node.targetLanguage.is(python))
This generates correct Java: SEnumOperations.isMember(SPropertyOperations.getEnum(...), memberID)
Files Changed:
languages/SemAnno/models/SemAnno.structure.mps—targetLanguageproperty type:string→TargetLanguageenumlanguages/SemAnno/models/SemAnno.textGen.mps— Module TextGen conditions useisoperation with enum member referenceslanguages/SemAnno/SemAnno.mpl— Added JDK dependency (may still be needed for future.equals()calls)languages/SemAnno/source_gen/SemAnno/textGen/Module_TextGen.java— Regenerated by MPS with correctSEnumOperations.isMember()calls
Key MPS Lessons Learned
- Enum property comparison: Use the
isoperation fromjetbrains.mps.lang.smodel, NOT==or.equals()on strings SPropertyAccesson enum properties generatesgetEnum()(returns enum literal), notgetString()(returns String)EnumMember_IsOperation(concept21noJN) withEnumMemberReference(concept21nZrQ) is the correct pattern- JDK module dependency must be in the
<dependencies>section of.mpl, not just<dependencyVersions> - InstanceMethodCallOperation concept ID is
1202948039474, indexliA8E(NOT1204053956946which isIMethodCallabstract interface)
Known Remaining Errors
Return_TextGen: "The reference value (link) is out of search scope" — Pre-existing, needs investigation- Some unused registry entries from debugging may remain in textGen.mps — Clean up on next session
Sprint 1 Status Assessment
Implementation Order from Requirements:
- Week 1-2: Core AST Structure — Phase: MOSTLY DONE
- Week 3-4: Python Projection & Generator — Phase: PARTIAL
- Week 5-6: C++ Projection & Generator — Phase: PARTIAL
- Week 7-8: Tree-sitter Import — Phase: NOT STARTED
- Week 9-10: Warning System & Annotations — Phase: NOT STARTED
Detailed Status by Area
1. Structure (SemAnno.structure.mps) — MOSTLY DONE
Fully Defined Concepts:
- Module (with targetLanguage enum: python/cpp/both)
- Function (name, parameters, body, returnType, annotations)
- Variable (name, type, initializer, annotations)
- Parameter (name, type)
- PrimitiveType (kind)
- Assignment, Return, ExpressionStatement, Block
- IfStatement, WhileLoop, ForLoop
- BinaryOperation, UnaryOperation
- FunctionCall, VariableReference
- All Literals: IntegerLiteral, FloatLiteral, StringLiteral, BooleanLiteral, NullLiteral, ListLiteral
- IndexAccess, MemberAccess
- Type nodes: ListType, SetType, MapType, TupleType, ArrayType, OptionalType, CustomType
- Annotations: Memory strategy (initially
DerefStrategy, canonical:DeallocateAnnotation/LifetimeAnnotation/ReclaimAnnotation/OwnerAnnotation/AllocateAnnotation), OptimizationLock, LangSpecific - TargetLanguage enum (python, cpp, both)
Status: All TR-1 core AST nodes are defined. Annotation structures (TR-2, TR-3, TR-4) exist but may need property refinement.
2. TextGen — PARTIAL (Core works, most nodes are stubs)
WORKING (read node properties, generate real output):
Module_TextGen— Conditional Python/C++ generation with enum check ✅Function_TextGen— Generatesdef name(params):with body (Python style only)Variable_TextGen— Generatesname: typeParameter_TextGen— Generates parameter namePrimitiveType_TextGen— Generates type kindAssignment_TextGen— Generatesname = valueReturn_TextGen— Generatesreturn value(has reference error)BinaryOperation_TextGen— Generatesleft op rightBlock_TextGen— Generates indented statementsExpressionStatement_TextGen— Generates expressionVariableReference_TextGen— Generates variable name
STUBS (output placeholder text, not reading node data):
IntegerLiteral_TextGen— outputs<int>instead of actual valueFloatLiteral_TextGen— outputs[value]StringLiteral_TextGen— outputs"[value]"BooleanLiteral_TextGen— outputs[value]NullLiteral_TextGen— outputsnull(may be correct)ListLiteral_TextGen— outputs[elements]IfStatement_TextGen— outputs placeholder textWhileLoop_TextGen— outputs placeholder textForLoop_TextGen— outputs placeholder textFunctionCall_TextGen— outputs[functionName]([arguments])UnaryOperation_TextGen— outputs[operator][operand]IndexAccess_TextGen— outputs[target][[index]]MemberAccess_TextGen— outputs[target].[memberName]- All Type TextGens (List, Set, Map, Tuple, Array, Optional, Custom) — placeholders
DerefStrategy_TextGen— outputs@deref([strategy])(to be updated to canonical annotation names like@Reclaim(Tracing),@Deallocate(Explicit), etc.)OptimizationLock_TextGen— outputs@lock([lockedBy], [lockReason])LangSpecific_TextGen— outputs@lang([language]:[idiomType])
MISSING:
- C++ mode generation for Function, Variable, etc. (only Module switches; child nodes always generate Python-style)
- Proper literal value output
- Control flow statement generation (if/while/for)
3. Editor (SemAnno.editor.mps) — EXISTS, NEEDS ASSESSMENT
- Editor definitions exist (~20KB)
- Likely has basic cell layouts for concepts
- Dual Python/C++ projection switching: UNKNOWN (needs investigation)
4. Behavior (SemAnno.behavior.mps) — MINIMAL
- File exists but likely minimal
5. Constraints (SemAnno.constraints.mps) — MINIMAL
- File exists but likely minimal
6. TypeSystem (SemAnno.typesystem.mps) — MINIMAL
- File exists but likely minimal
7. Tree-sitter Integration — NOT STARTED
- No tree-sitter files found in project
8. Warning System — NOT STARTED
- OptimizationLock concept exists in structure
- No warning UI or behavior implementation
9. Test Models — MINIMAL
Phase1Test.mps— Calculator example (Module with 2 functions, variables, assignments, returns, binary ops)- No other test models found
Recommended Next Steps (Priority Order)
Phase A: Fix Remaining TextGen Stubs (High Priority)
Make all TextGen implementations read actual node data instead of outputting placeholder text.
- Fix literal TextGens — IntegerLiteral, FloatLiteral, StringLiteral, BooleanLiteral should read their
valueproperty - Fix control flow TextGens — IfStatement, WhileLoop, ForLoop should read conditions and bodies
- Fix FunctionCall TextGen — Read function name and arguments
- Fix UnaryOperation TextGen — Read operator and operand
- Fix IndexAccess, MemberAccess TextGens — Read targets and members
- Fix type TextGens — Read inner types for composite types
- Fix annotation TextGens — Read annotation properties
Phase B: Dual Language Generation (High Priority)
Currently only Module switches between Python/C++. Child nodes need language-aware generation:
- Pass targetLanguage context to child TextGens (or have children read parent Module's targetLanguage)
- Function_TextGen — Python:
def name(params):/ C++:returnType name(params) {} - Variable_TextGen — Python:
name: type/ C++:type name; - Statement TextGens — Python uses
:and indentation / C++ uses{}and;
Phase C: Fix Return_TextGen Error
- Investigate "The reference value (link) is out of search scope" error
- May be a link ID mismatch in the structure
Phase D: Expand Phase1Test
- Add more test cases: control flow, function calls, literals, type variations
- Test both Python and C++ output for each case
Phase E: Editor Dual Projection (Medium Priority)
- Investigate current editor state
- Add projection switching (Python view vs C++ view)
Phase F: Tree-sitter Import (Lower Priority for Sprint 1)
- External tooling integration
- Can be deferred if core generation works
Phase G: Warning System (Lower Priority)
- OptimizationLock behavior
- Warning UI in editor