Skip to content
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
197 changes: 197 additions & 0 deletions IMPLEMENTATION_STATUS.md
Original file line number Diff line number Diff line change
@@ -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<kg>`, `int<m/s>` |
| 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
Loading