Interface ScriptLoader
- All Known Implementing Classes:
InMemoryScriptLoader
- Functional Interface:
- This is a functional interface and can therefore be used as the assignment target for a lambda expression or method reference.
Strategy for resolving a path to a
Script — the engine's pluggable
"where does a Script come from" seam.
This abstraction decouples the semantic analyser from both the file system
and any concrete syntax: an implementation may parse .relix text, read
a serialized query, or serve pre-built ASTs from a map. The engine only ever
sees the resulting Script, which is why a failure to produce one is
reported as the core-level ScriptParseException rather than any one
frontend's own exception type.
Implementations must be thread-safe if the analyser is used concurrently.
Example — a text frontend's file-system loader (it parses .relix,
so it lives in relix-console, not here):
ScriptLoader loader = new FileSystemScriptLoader(Paths.get("/project/scripts"));
SemanticAnalyzer analyzer = new SemanticAnalyzer(loader);
Example — serving an AST held in memory:
Script script = ...; // parsed, or built programmatically ScriptLoader loader = path -> script; SemanticAnalyzer analyzer = new SemanticAnalyzer(loader);
-
Method Summary
-
Method Details
-
load
Loads the script at the given path.- Parameters:
path- the file path as written in theimportor root-file argument; interpretation (absolute, relative, logical) is implementation-defined- Returns:
- the loaded script; never null
- Throws:
IOException- if the source cannot be readScriptParseException- if the source cannot be turned into aScript(for a text frontend: a syntax error)
-