|
| 1 | +# FScript Assemblies, Roles, and Usage |
| 2 | + |
| 3 | +## Purpose |
| 4 | +This document describes how FScript is split into assemblies and how they are used together in applications. |
| 5 | + |
| 6 | +## Assembly overview |
| 7 | + |
| 8 | +### `FScript` |
| 9 | +Role: |
| 10 | +- Command-line tool (`fscript`) to execute `.fss` files. |
| 11 | + |
| 12 | +Responsibilities: |
| 13 | +- Parse CLI arguments. |
| 14 | +- Resolve script path and sandbox root. |
| 15 | +- Build runtime context and extern registry. |
| 16 | +- Execute parse -> type inference -> evaluation pipeline. |
| 17 | +- Print final result and report parse/type/eval errors. |
| 18 | + |
| 19 | +Use this when: |
| 20 | +- You want to run scripts directly from terminal/CI. |
| 21 | +- You want a ready-to-use executable without writing host integration code. |
| 22 | + |
| 23 | +### `FScript.Language` |
| 24 | +Role: |
| 25 | +- Embeddable language engine. |
| 26 | + |
| 27 | +Responsibilities: |
| 28 | +- Core language model and AST. |
| 29 | +- Lexer and parser. |
| 30 | +- Type system and Hindley-Milner inference. |
| 31 | +- Evaluator and value model. |
| 32 | +- Pretty-printing of evaluation results. |
| 33 | + |
| 34 | +Use this when: |
| 35 | +- You want to embed the language in another .NET application. |
| 36 | +- You need language processing independently from default runtime extern catalog. |
| 37 | + |
| 38 | +### `FScript.Runtime` |
| 39 | +Role: |
| 40 | +- Runtime integration layer and extern catalog. |
| 41 | + |
| 42 | +Responsibilities: |
| 43 | +- Host context model (`RootDirectory` and related host constraints). |
| 44 | +- Built-in external function modules (`List.*`, `Map.*`, `Option.*`, filesystem, JSON/XML, regex, hash, GUID, print). |
| 45 | +- Extern registry composition. |
| 46 | +- Host-oriented decoding helpers and sandbox-aware path checks. |
| 47 | + |
| 48 | +Use this when: |
| 49 | +- You want the built-in extern ecosystem ready to use. |
| 50 | +- You want a baseline runtime integration layer to extend with custom externs. |
| 51 | + |
| 52 | +## Typical composition |
| 53 | + |
| 54 | +### CLI execution path |
| 55 | +1. `FScript` reads CLI args and script text. |
| 56 | +2. `FScript` asks `FScript.Runtime` for externs (`Registry.all`). |
| 57 | +3. `FScript` invokes `FScript.Language` parse/infer/eval pipeline. |
| 58 | +4. `FScript` prints result. |
| 59 | + |
| 60 | +### Embedded host path |
| 61 | +1. Host app references `FScript.Language` and (optionally) `FScript.Runtime`. |
| 62 | +2. Host builds `HostContext` and extern list. |
| 63 | +3. Host runs parse/infer/eval programmatically. |
| 64 | +4. Host decides output, logging, and error handling behavior. |
| 65 | + |
| 66 | +## Dependency direction |
| 67 | +- `FScript.Language` has no dependency on `FScript.Runtime`. |
| 68 | +- `FScript.Runtime` depends on `FScript.Language` types. |
| 69 | +- `FScript` depends on both `FScript.Language` and `FScript.Runtime`. |
| 70 | + |
| 71 | +This keeps the language engine reusable while runtime capabilities remain host-configurable. |
0 commit comments