For more details and some pictures, take a look at the report I put together.
A scope graph is an approach for name resolution in a compiler front-end. With this approach, the parsed AST is extended with
- nodes representing scopes
- edges representing relationships between scopes (lexical parent/child relationships, imports, declarations within scopes)
This reduces name resolution to finding paths from identifiers to AST nodes, and provides a mechanism for formalizing scoping/shadowing rules. There are some papers on this here.
This project is a small compiler frontend that parses and builds a scope graph for FlixSG, a subset of the Flix programming language.
Use Main to compile and compileFile to run all phases.
See Examples for a view of the language. With the vsix extension installed and the language server running, you can ctrl/cmd + click on identifiers to see how they are resolved.
- ParsedAst contains the Parsed AST.
- ScopedAst contains the Scoped AST, as well as the scope nodes and edges.
- File reads files (
String). - Lexer tokenizes strings (
String -> Vector[Token]). - Parser parses tokens (
Vector[Token] -> ParsedAst.Scope). - Sanitizer sanitizes the parsed output (
ParsedAst.Scope -> Unit). - Scoper builds a scope graph from the parsed AST (
ParsedAst -> ScopeGraph).
- ScopeGraph contains functions for resolving names by searching for paths in the graph.
flix> :build
flix> :fatjar
install the .vsix extension
cd extension/flixsg
npm install
vsce package
and then copy the .vsix file down