|
| 1 | +# F# Grammar Implementation Status |
| 2 | + |
| 3 | +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/). |
| 4 | + |
| 5 | +## Status Legend |
| 6 | +- ✅ **Implemented** - Feature is fully supported with tests |
| 7 | +- 🚧 **Partial** - Basic support exists but missing some cases |
| 8 | +- ❌ **Not Implemented** - Feature not yet supported |
| 9 | +- 🔨 **In Progress** - Currently being worked on |
| 10 | + |
| 11 | +## Core Language Features |
| 12 | + |
| 13 | +### Expressions ([Spec §6](https://github.com/fsharp/fslang-spec/blob/main/spec/expressions.md)) |
| 14 | + |
| 15 | +| Feature | Status | Tests | Notes | |
| 16 | +|---------|--------|-------|-------| |
| 17 | +| Basic expressions (constants, identifiers) | ✅ | `expr.txt`, `constants.txt` | | |
| 18 | +| Arithmetic/Boolean/String operations | ✅ | `expr.txt`, `operators.txt` | | |
| 19 | +| Tuple expressions | ✅ | `expr.txt` | | |
| 20 | +| List expressions `[1; 2; 3]` | ✅ | `expr.txt` | | |
| 21 | +| Array expressions `[|1; 2; 3|]` | ✅ | `expr.txt` | | |
| 22 | +| Record expressions `{ X = 1 }` | ✅ | `expr.txt` | | |
| 23 | +| Anonymous records `{| X = 1 |}` | ✅ | `expr.txt` | | |
| 24 | +| Sequence expressions `seq { ... }` | 🚧 | `expr.txt:847` | Only basic form, missing yield/for/while | |
| 25 | +| List comprehensions `[ for x in 1..10 -> x ]` | ❌ | | | |
| 26 | +| Array comprehensions | ❌ | | | |
| 27 | +| Computation expressions (full) | 🚧 | `expr.txt:865` | Only async/task with let!/do!, missing custom builders | |
| 28 | +| Query expressions `query { ... }` | ❌ | | LINQ-style queries | |
| 29 | +| Object expressions `{ new IFoo with ... }` | ✅ | `expr.txt:2163` | | |
| 30 | +| Lambda expressions `fun x -> x` | ✅ | `expr.txt:1443` | | |
| 31 | +| Function expressions `function | ... -> ...` | ✅ | `expr.txt:2856` | | |
| 32 | +| Match expressions | ✅ | `expr.txt:2039` | | |
| 33 | +| Try-with/Try-finally | ✅ | `expr.txt:1883` | | |
| 34 | +| If-then-else expressions | ✅ | `expr.txt:1108` | | |
| 35 | +| While loops | ✅ | `expr.txt:2661` | | |
| 36 | +| For loops | ✅ | `expr.txt:1659` | | |
| 37 | +| For-in loops | ✅ | `expr.txt:1659` | | |
| 38 | +| Slice expressions `arr.[1..3]` | ✅ | `expr.txt:2309` | | |
| 39 | +| Wildcard slice expressions `arr.[*]` | ✅ | `expr.txt:3785` | | |
| 40 | +| Quotation expressions `<@ ... @>` | 🚧 | `expr.txt:3199` | Basic support only | |
| 41 | +| Typed quotations `<@ expr : type @>` | ❌ | | | |
| 42 | +| Untyped quotations `<@@ ... @@>` | ❌ | | | |
| 43 | +| Splice expressions `%expr` and `%%expr` | ❌ | | | |
| 44 | +| Lazy expressions `lazy expr` | ❌ | | | |
| 45 | +| Assert expressions | ❌ | | | |
| 46 | +| Address-of expressions `&expr` | 🚧 | `expr.txt:2897` | | |
| 47 | +| Yield expressions `yield expr` | ❌ | | | |
| 48 | +| Yield-bang expressions `yield! expr` | ❌ | | | |
| 49 | +| Return expressions `return expr` | 🚧 | `expr.txt:867` | Only in CE context | |
| 50 | +| Return-bang expressions `return! expr` | ❌ | | | |
| 51 | +| Use expressions `use x = ...` | ❌ | | | |
| 52 | +| Use-bang expressions `use! x = ...` | ❌ | | | |
| 53 | + |
| 54 | +### Patterns ([Spec §7](https://github.com/fsharp/fslang-spec/blob/main/spec/patterns.md)) |
| 55 | + |
| 56 | +| Feature | Status | Tests | Notes | |
| 57 | +|---------|--------|-------|-------| |
| 58 | +| Constant patterns | ✅ | `patterns.txt` | | |
| 59 | +| Identifier patterns | ✅ | `patterns.txt` | | |
| 60 | +| Wildcard pattern `_` | ✅ | `patterns.txt` | | |
| 61 | +| As patterns `pat as ident` | ✅ | `patterns.txt:19` | | |
| 62 | +| Or patterns `pat1 | pat2` | ✅ | `patterns.txt:275` | | |
| 63 | +| And patterns `pat1 & pat2` | ✅ | `patterns.txt:443` | | |
| 64 | +| Cons patterns `head :: tail` | ✅ | `patterns.txt:356` | | |
| 65 | +| List patterns `[a; b]` | ✅ | `patterns.txt:107` | | |
| 66 | +| Array patterns `[| a; b |]` | 🚧 | `patterns.txt:290` | Basic only | |
| 67 | +| Record patterns | ✅ | `patterns.txt:163` | | |
| 68 | +| Tuple patterns | ✅ | `patterns.txt:3` | | |
| 69 | +| Type test patterns `:? Type` | 🚧 | `expr.txt:1950` | Basic support | |
| 70 | +| Type annotated patterns | ✅ | `patterns.txt:392` | | |
| 71 | +| Active patterns `(|Even|Odd|)` | 🚧 | `patterns.txt:496` | Basic only, no parameters | |
| 72 | +| Parameterized active patterns | ❌ | | | |
| 73 | +| Partial active patterns `(|Even|_|)` | 🚧 | | Basic support | |
| 74 | +| Null patterns | ✅ | `patterns.txt:140` | | |
| 75 | +| Optional patterns | ✅ | `patterns.txt:214` | | |
| 76 | +| Attribute patterns | ✅ | `patterns.txt:327` | | |
| 77 | + |
| 78 | +### Type Definitions ([Spec §8](https://github.com/fsharp/fslang-spec/blob/main/spec/type-definitions.md)) |
| 79 | + |
| 80 | +| Feature | Status | Tests | Notes | |
| 81 | +|---------|--------|-------|-------| |
| 82 | +| Type abbreviations | ✅ | `type_defn.txt` | | |
| 83 | +| Record types | ✅ | `type_defn.txt:140` | | |
| 84 | +| Discriminated unions | ✅ | `type_defn.txt:356` | | |
| 85 | +| Class types | ✅ | `type_defn.txt:951` | | |
| 86 | +| Interface types | ✅ | `type_defn.txt:1759` | | |
| 87 | +| Struct types | ✅ | `type_defn.txt:1913` | | |
| 88 | +| Enum types | ✅ | `type_defn.txt:1969` | | |
| 89 | +| Delegate types | ✅ | `type_defn.txt:2041` | | |
| 90 | +| Exception types | ✅ | `type_defn.txt:2140` | | |
| 91 | +| Type extensions | ✅ | `type_defn.txt:2210` | | |
| 92 | +| Flexible types `#Type` | 🚧 | `expr.txt:2984` | | |
| 93 | +| Static members | 🚧 | | Limited support | |
| 94 | +| Properties (get/set) | 🚧 | | Basic support | |
| 95 | +| Indexers | ❌ | | | |
| 96 | +| Events | ❌ | | | |
| 97 | +| Auto-properties | ❌ | | | |
| 98 | +| Explicit constructors | ✅ | `type_defn.txt` | | |
| 99 | +| Additional constructors | ✅ | `type_defn.txt` | | |
| 100 | +| Generic type parameters | ✅ | `type_defn.txt` | | |
| 101 | +| Type constraints | 🚧 | `type_defn.txt:1584` | Basic support | |
| 102 | +| SRTP constraints | ❌ | | Statically resolved type parameters | |
| 103 | + |
| 104 | +### Type System Features ([Spec §5](https://github.com/fsharp/fslang-spec/blob/main/spec/types-and-type-constraints.md)) |
| 105 | + |
| 106 | +| Feature | Status | Tests | Notes | |
| 107 | +|---------|--------|-------|-------| |
| 108 | +| Basic types (int, string, etc.) | ✅ | Throughout | | |
| 109 | +| Function types `'a -> 'b` | ✅ | `type_defn.txt` | | |
| 110 | +| Tuple types `'a * 'b` | ✅ | `type_defn.txt` | | |
| 111 | +| Array types `'a[]` | ✅ | `type_defn.txt` | | |
| 112 | +| List types `'a list` | ✅ | `type_defn.txt` | | |
| 113 | +| Option types | ✅ | `type_defn.txt` | | |
| 114 | +| Generic types `List<'a>` | ✅ | `type_defn.txt` | | |
| 115 | +| Anonymous record types | ✅ | `expr.txt:3336` | | |
| 116 | +| Type abbreviations | ✅ | `type_defn.txt` | | |
| 117 | +| Units of measure | ❌ | | `float<kg>`, `int<m/s>` | |
| 118 | +| Type providers | 🚧 | | Very basic support | |
| 119 | +| Byref types | ❌ | | | |
| 120 | +| Native pointer types | ❌ | | | |
| 121 | + |
| 122 | +### Modules and Namespaces ([Spec §10-11](https://github.com/fsharp/fslang-spec/blob/main/spec/namespaces-and-modules.md)) |
| 123 | + |
| 124 | +| Feature | Status | Tests | Notes | |
| 125 | +|---------|--------|-------|-------| |
| 126 | +| Namespaces | ✅ | `module.txt` | | |
| 127 | +| Modules | ✅ | `module.txt` | | |
| 128 | +| Nested modules | ✅ | `module.txt:75` | | |
| 129 | +| Module abbreviations | ✅ | `module_abbrev.txt` | | |
| 130 | +| Module signatures (.fsi) | 🚧 | `fsharp_signature/` | Minimal | |
| 131 | +| Open declarations | ✅ | `import.txt` | | |
| 132 | +| AutoOpen attribute | ✅ | `attributes.txt` | | |
| 133 | +| RequireQualifiedAccess | ✅ | `attributes.txt` | | |
| 134 | + |
| 135 | +### Special Features |
| 136 | + |
| 137 | +| Feature | Status | Tests | Notes | |
| 138 | +|---------|--------|-------|-------| |
| 139 | +| Attributes | ✅ | `attributes.txt` | | |
| 140 | +| Compiler directives | ✅ | `compiler_directive.txt` | | |
| 141 | +| FSI directives | ✅ | `fsi_directives.txt` | | |
| 142 | +| XML documentation | ✅ | `comments.txt` | | |
| 143 | +| Preprocessor directives | ✅ | `compiler_directive.txt` | | |
| 144 | +| Inline functions | 🚧 | | Basic parsing | |
| 145 | +| Operator definitions | ✅ | `operators.txt` | | |
| 146 | +| Extension methods | 🚧 | | Via type extensions | |
| 147 | +| Partial application | ✅ | | Via currying | |
| 148 | + |
| 149 | +## Priority for Implementation |
| 150 | + |
| 151 | +### High Priority (Common Usage) |
| 152 | +1. **Sequence/List/Array Comprehensions** - Very common in F# code |
| 153 | +2. **Static Members and Properties** - Essential for OOP interop |
| 154 | +3. **Full Computation Expression support** - Core F# feature |
| 155 | +4. **Active Patterns with Parameters** - Common in domain modeling |
| 156 | + |
| 157 | +### Medium Priority (Important but Less Common) |
| 158 | +5. **Units of Measure** - Scientific/financial domains |
| 159 | +6. **Query Expressions** - LINQ compatibility |
| 160 | +7. **Type Constraints (full)** - Advanced generics |
| 161 | +8. **Quotations (full)** - Metaprogramming |
| 162 | + |
| 163 | +### Lower Priority (Specialized) |
| 164 | +9. **Type Providers** - Data access scenarios |
| 165 | +10. **Events and Delegates** - Mostly for C# interop |
| 166 | +11. **Byref/Pointer types** - Low-level scenarios |
| 167 | + |
| 168 | +## Contributing |
| 169 | + |
| 170 | +When implementing a feature: |
| 171 | +1. Update this document's status |
| 172 | +2. Add tests to appropriate file in `test/corpus/` |
| 173 | +3. Reference the F# spec section in commit messages |
| 174 | +4. Ensure all tests pass with `npx tree-sitter test` |
| 175 | + |
| 176 | +## Test Coverage |
| 177 | + |
| 178 | +Current test corpus files: |
| 179 | +- `attributes.txt` - 264 lines |
| 180 | +- `comments.txt` - 383 lines |
| 181 | +- `compiler_directive.txt` - 536 lines |
| 182 | +- `constants.txt` - 735 lines |
| 183 | +- `expr.txt` - 3855 lines |
| 184 | +- `fsharp_signature/values.txt` - 26 lines |
| 185 | +- `fsi_directives.txt` - 44 lines |
| 186 | +- `function_defn.txt` - 252 lines |
| 187 | +- `identifiers.txt` - 111 lines |
| 188 | +- `import.txt` - 23 lines |
| 189 | +- `module.txt` - 347 lines |
| 190 | +- `module_abbrev.txt` - 13 lines |
| 191 | +- `operators.txt` - 99 lines |
| 192 | +- `patterns.txt` - 526 lines |
| 193 | +- `scoping.txt` - 284 lines |
| 194 | +- `source_file.txt` - 176 lines |
| 195 | +- `type_defn.txt` - 2717 lines |
| 196 | + |
| 197 | +Total: ~10,400 lines of tests across 345+ test cases |
0 commit comments