Skip to content

rywiese/scope-graphs

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

148 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

scope-graphs

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

  1. nodes representing scopes
  2. 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.

Asts

  • ParsedAst contains the Parsed AST.
  • ScopedAst contains the Scoped AST, as well as the scope nodes and edges.

Phases

  • 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).

Graph

  • ScopeGraph contains functions for resolving names by searching for paths in the graph.

Using the vsix extension

flix> :build
flix> :fatjar

install the .vsix extension

Build Extension

cd extension/flixsg
npm install
vsce package

and then copy the .vsix file down

About

No description, website, or topics provided.

Resources

License

Stars

Watchers

Forks

Packages

 
 
 

Contributors