diff --git a/IMPLEMENTATION_STATUS.md b/IMPLEMENTATION_STATUS.md new file mode 100644 index 0000000..68f4961 --- /dev/null +++ b/IMPLEMENTATION_STATUS.md @@ -0,0 +1,197 @@ +# F# Grammar Implementation Status + +This document tracks the implementation status of F# language features in the tree-sitter-fsharp grammar, mapped against the [F# Language Specification](https://fsharp.org/specs/language-spec/). + +## Status Legend +- โœ… **Implemented** - Feature is fully supported with tests +- ๐Ÿšง **Partial** - Basic support exists but missing some cases +- โŒ **Not Implemented** - Feature not yet supported +- ๐Ÿ”จ **In Progress** - Currently being worked on + +## Core Language Features + +### Expressions ([Spec ยง6](https://github.com/fsharp/fslang-spec/blob/main/spec/expressions.md)) + +| Feature | Status | Tests | Notes | +|---------|--------|-------|-------| +| Basic expressions (constants, identifiers) | โœ… | `expr.txt`, `constants.txt` | | +| Arithmetic/Boolean/String operations | โœ… | `expr.txt`, `operators.txt` | | +| Tuple expressions | โœ… | `expr.txt` | | +| List expressions `[1; 2; 3]` | โœ… | `expr.txt` | | +| Array expressions `[|1; 2; 3|]` | โœ… | `expr.txt` | | +| Record expressions `{ X = 1 }` | โœ… | `expr.txt` | | +| Anonymous records `{| X = 1 |}` | โœ… | `expr.txt` | | +| Sequence expressions `seq { ... }` | ๐Ÿšง | `expr.txt:847` | Only basic form, missing yield/for/while | +| List comprehensions `[ for x in 1..10 -> x ]` | โŒ | | | +| Array comprehensions | โŒ | | | +| Computation expressions (full) | ๐Ÿšง | `expr.txt:865` | Only async/task with let!/do!, missing custom builders | +| Query expressions `query { ... }` | โŒ | | LINQ-style queries | +| Object expressions `{ new IFoo with ... }` | โœ… | `expr.txt:2163` | | +| Lambda expressions `fun x -> x` | โœ… | `expr.txt:1443` | | +| Function expressions `function \| ... -> ...` | โœ… | `expr.txt:2856` | | +| Match expressions | โœ… | `expr.txt:2039` | | +| Try-with/Try-finally | โœ… | `expr.txt:1883` | | +| If-then-else expressions | โœ… | `expr.txt:1108` | | +| While loops | โœ… | `expr.txt:2661` | | +| For loops | โœ… | `expr.txt:1659` | | +| For-in loops | โœ… | `expr.txt:1659` | | +| Slice expressions `arr.[1..3]` | โœ… | `expr.txt:2309` | | +| Wildcard slice expressions `arr.[*]` | โœ… | `expr.txt:3785` | | +| Quotation expressions `<@ ... @>` | ๐Ÿšง | `expr.txt:3199` | Basic support only | +| Typed quotations `<@ expr : type @>` | โŒ | | | +| Untyped quotations `<@@ ... @@>` | โŒ | | | +| Splice expressions `%expr` and `%%expr` | โŒ | | | +| Lazy expressions `lazy expr` | โŒ | | | +| Assert expressions | โŒ | | | +| Address-of expressions `&expr` | ๐Ÿšง | `expr.txt:2897` | | +| Yield expressions `yield expr` | โŒ | | | +| Yield-bang expressions `yield! expr` | โŒ | | | +| Return expressions `return expr` | ๐Ÿšง | `expr.txt:867` | Only in CE context | +| Return-bang expressions `return! expr` | โŒ | | | +| Use expressions `use x = ...` | โŒ | | | +| Use-bang expressions `use! x = ...` | โŒ | | | + +### Patterns ([Spec ยง7](https://github.com/fsharp/fslang-spec/blob/main/spec/patterns.md)) + +| Feature | Status | Tests | Notes | +|---------|--------|-------|-------| +| Constant patterns | โœ… | `patterns.txt` | | +| Identifier patterns | โœ… | `patterns.txt` | | +| Wildcard pattern `_` | โœ… | `patterns.txt` | | +| As patterns `pat as ident` | โœ… | `patterns.txt:19` | | +| Or patterns `pat1 | pat2` | โœ… | `patterns.txt:275` | | +| And patterns `pat1 & pat2` | โœ… | `patterns.txt:443` | | +| Cons patterns `head :: tail` | โœ… | `patterns.txt:356` | | +| List patterns `[a; b]` | โœ… | `patterns.txt:107` | | +| Array patterns `[| a; b |]` | ๐Ÿšง | `patterns.txt:290` | Basic only | +| Record patterns | โœ… | `patterns.txt:163` | | +| Tuple patterns | โœ… | `patterns.txt:3` | | +| Type test patterns `:? Type` | ๐Ÿšง | `expr.txt:1950` | Basic support | +| Type annotated patterns | โœ… | `patterns.txt:392` | | +| Active patterns `(|Even|Odd|)` | ๐Ÿšง | `patterns.txt:496` | Basic only, no parameters | +| Parameterized active patterns | โŒ | | | +| Partial active patterns `(|Even|_|)` | ๐Ÿšง | | Basic support | +| Null patterns | โœ… | `patterns.txt:140` | | +| Optional patterns | โœ… | `patterns.txt:214` | | +| Attribute patterns | โœ… | `patterns.txt:327` | | + +### Type Definitions ([Spec ยง8](https://github.com/fsharp/fslang-spec/blob/main/spec/type-definitions.md)) + +| Feature | Status | Tests | Notes | +|---------|--------|-------|-------| +| Type abbreviations | โœ… | `type_defn.txt` | | +| Record types | โœ… | `type_defn.txt:140` | | +| Discriminated unions | โœ… | `type_defn.txt:356` | | +| Class types | โœ… | `type_defn.txt:951` | | +| Interface types | โœ… | `type_defn.txt:1759` | | +| Struct types | โœ… | `type_defn.txt:1913` | | +| Enum types | โœ… | `type_defn.txt:1969` | | +| Delegate types | โœ… | `type_defn.txt:2041` | | +| Exception types | โœ… | `type_defn.txt:2140` | | +| Type extensions | โœ… | `type_defn.txt:2210` | | +| Flexible types `#Type` | ๐Ÿšง | `expr.txt:2984` | | +| Static members | ๐Ÿšง | | Limited support | +| Properties (get/set) | ๐Ÿšง | | Basic support | +| Indexers | โŒ | | | +| Events | โŒ | | | +| Auto-properties | โŒ | | | +| Explicit constructors | โœ… | `type_defn.txt` | | +| Additional constructors | โœ… | `type_defn.txt` | | +| Generic type parameters | โœ… | `type_defn.txt` | | +| Type constraints | ๐Ÿšง | `type_defn.txt:1584` | Basic support | +| SRTP constraints | โŒ | | Statically resolved type parameters | + +### Type System Features ([Spec ยง5](https://github.com/fsharp/fslang-spec/blob/main/spec/types-and-type-constraints.md)) + +| Feature | Status | Tests | Notes | +|---------|--------|-------|-------| +| Basic types (int, string, etc.) | โœ… | Throughout | | +| Function types `'a -> 'b` | โœ… | `type_defn.txt` | | +| Tuple types `'a * 'b` | โœ… | `type_defn.txt` | | +| Array types `'a[]` | โœ… | `type_defn.txt` | | +| List types `'a list` | โœ… | `type_defn.txt` | | +| Option types | โœ… | `type_defn.txt` | | +| Generic types `List<'a>` | โœ… | `type_defn.txt` | | +| Anonymous record types | โœ… | `expr.txt:3336` | | +| Type abbreviations | โœ… | `type_defn.txt` | | +| Units of measure | โŒ | | `float`, `int` | +| Type providers | ๐Ÿšง | | Very basic support | +| Byref types | โŒ | | | +| Native pointer types | โŒ | | | + +### Modules and Namespaces ([Spec ยง10-11](https://github.com/fsharp/fslang-spec/blob/main/spec/namespaces-and-modules.md)) + +| Feature | Status | Tests | Notes | +|---------|--------|-------|-------| +| Namespaces | โœ… | `module.txt` | | +| Modules | โœ… | `module.txt` | | +| Nested modules | โœ… | `module.txt:75` | | +| Module abbreviations | โœ… | `module_abbrev.txt` | | +| Module signatures (.fsi) | ๐Ÿšง | `fsharp_signature/` | Minimal | +| Open declarations | โœ… | `import.txt` | | +| AutoOpen attribute | โœ… | `attributes.txt` | | +| RequireQualifiedAccess | โœ… | `attributes.txt` | | + +### Special Features + +| Feature | Status | Tests | Notes | +|---------|--------|-------|-------| +| Attributes | โœ… | `attributes.txt` | | +| Compiler directives | โœ… | `compiler_directive.txt` | | +| FSI directives | โœ… | `fsi_directives.txt` | | +| XML documentation | โœ… | `comments.txt` | | +| Preprocessor directives | โœ… | `compiler_directive.txt` | | +| Inline functions | ๐Ÿšง | | Basic parsing | +| Operator definitions | โœ… | `operators.txt` | | +| Extension methods | ๐Ÿšง | | Via type extensions | +| Partial application | โœ… | | Via currying | + +## Priority for Implementation + +### High Priority (Common Usage) +1. **Sequence/List/Array Comprehensions** - Very common in F# code +2. **Static Members and Properties** - Essential for OOP interop +3. **Full Computation Expression support** - Core F# feature +4. **Active Patterns with Parameters** - Common in domain modeling + +### Medium Priority (Important but Less Common) +5. **Units of Measure** - Scientific/financial domains +6. **Query Expressions** - LINQ compatibility +7. **Type Constraints (full)** - Advanced generics +8. **Quotations (full)** - Metaprogramming + +### Lower Priority (Specialized) +9. **Type Providers** - Data access scenarios +10. **Events and Delegates** - Mostly for C# interop +11. **Byref/Pointer types** - Low-level scenarios + +## Contributing + +When implementing a feature: +1. Update this document's status +2. Add tests to appropriate file in `test/corpus/` +3. Reference the F# spec section in commit messages +4. Ensure all tests pass with `npx tree-sitter test` + +## Test Coverage + +Current test corpus files: +- `attributes.txt` - 264 lines +- `comments.txt` - 383 lines +- `compiler_directive.txt` - 536 lines +- `constants.txt` - 735 lines +- `expr.txt` - 3855 lines +- `fsharp_signature/values.txt` - 26 lines +- `fsi_directives.txt` - 44 lines +- `function_defn.txt` - 252 lines +- `identifiers.txt` - 111 lines +- `import.txt` - 23 lines +- `module.txt` - 347 lines +- `module_abbrev.txt` - 13 lines +- `operators.txt` - 99 lines +- `patterns.txt` - 526 lines +- `scoping.txt` - 284 lines +- `source_file.txt` - 176 lines +- `type_defn.txt` - 2717 lines + +Total: ~10,400 lines of tests across 345+ test cases \ No newline at end of file