Local names and top-level names as the compiler binds them

- Scope: a run of body defs and defuns is one recursive group; pattern
  parameters; a let of plain names; with-open in sequence; :as; a named
  loop's name; def*, begin and :leave arms. A :view's step, a loop's =>
  call and a comprehension's head are not binders.
- Symbols: a pattern def or def* gives what it binds; :alias; a
  def/grammar's productions and cases; unit forms as constants.
- Completion: the special forms as the compiler has them now.

🤖 Generated with [ECA](https://eca.dev) (anthropic/claude-opus-5-5)

Co-Authored-By: eca-agent <git@eca.dev>
This commit is contained in:
Linus Björnstam 2026-11-09 15:02:46 +01:00
parent 78d18c9854
commit 9a365b260b
5 changed files with 474 additions and 44 deletions

View file

@ -8,13 +8,15 @@ open System
open Bjolang
open BjolangLsp.Symbols
/// The heads the parsers recognise themselves, which no module defines. A
/// copy of the REPL's list in `Repl.fs`, which is private to it.
/// The heads the parsers recognise themselves, which no module defines. The
/// REPL's list in `Repl.fs`, which is private to it, and the declaration heads
/// `def/loop-clause`, `def/dimension`, `def/unit` and `def/prefix`.
let private specialForms =
[ "->"; "and"; "begin"; "bjo"; "bjoroutine"; "by-colour"; "case"; "cast"; "def"; "def*"; "def/hash-extend"
"def/dimension"; "def/grammar"; "def/loop-clause"; "def/prefix"; "def/unit"
"def/macro"; "def/mutable"; "def/pattern"; "def/trait"; "defbjo"; "defbjouble"; "defun"; "dyn"
"export"; "fun"; "if"; "impl"; "impl/extern"; "import"; "import/class"; "import/extern"; "include"
"let"; "let/mono"; "letrec"; "loop"; "match"; "module"; "not"; "or"; "parameterize"; "re-export"
"let"; "let/mono"; "letrec"; "loop"; "match"; "module"; "or"; "parameterize"; "re-export"
"record"; "record-ref"; "record-set"; "record-set!"; "seq"; "seql"; "set!"; "spawn"; "spawn-evt"
"spawn/daemon"; "spawn/detached"; "struct"; "struct-ref"; "struct-set"; "struct-set!"; "task->event"
"try"; "type"; "type-rec"; "unless"; "when"; "with-open"; "with-return"; "yield"; "yield-from" ]
@ -30,6 +32,7 @@ type ItemKind =
| Keyword = 14
| EnumMember = 20
| Struct = 22
| Constant = 21
type Item =
{ Label: string
@ -47,6 +50,7 @@ let private itemKind (k: Kind) =
| Kind.Field -> ItemKind.Field
| Kind.EnumMember -> ItemKind.EnumMember
| Kind.Struct -> ItemKind.Struct
| Kind.Constant -> ItemKind.Constant
| _ -> ItemKind.Variable
/// The word the cursor ends, as the start column of it on its line. A word