Glen Whitney
2772fd0c5c
All checks were successful
continuous-integration/drone/push Build is passing
In addition, for the sake of Haskell code generation, this PR adds static typing with Statix. Resolves #5. Co-authored-by: Glen Whitney <glen@studioinfinity.org> Reviewed-on: #19 Co-Authored-By: Glen Whitney <glen@nobody@nowhere.net> Co-Committed-By: Glen Whitney <glen@nobody@nowhere.net>
68 lines
2.4 KiB
Plaintext
68 lines
2.4 KiB
Plaintext
module analysis
|
|
imports
|
|
|
|
statixruntime
|
|
statix/api
|
|
|
|
pp
|
|
injections/-
|
|
|
|
libspoofax/term/origin
|
|
desugar
|
|
|
|
rules // Analysis
|
|
|
|
// single-file analysis
|
|
editor-analyze = stx-editor-analyze(pre-analyze, post-analyze|"statics", "programOk")
|
|
|
|
// see docs/implementation.md for details on how to switch to multi-file analysis
|
|
// multi-file analysis
|
|
// editor-analyze = stx-editor-analyze(pre-analyze, post-analyze|"statics", "projectOk", "fileOk")
|
|
|
|
pre-analyze = desugar-fostr
|
|
; origin-track-forced(explicate-injections-fostr-Start)
|
|
post-analyze = origin-track-forced(implicate-injections-fostr-Start)
|
|
|
|
rules // Editor Services
|
|
|
|
editor-resolve = stx-editor-resolve
|
|
|
|
editor-hover = stx-editor-hover
|
|
|
|
rules // Debugging
|
|
|
|
// Prints the abstract syntax ATerm of a selection.
|
|
debug-show-aterm: (sel, _, _, path, projp) -> (filename, result)
|
|
with filename := <guarantee-extension(|"aterm")> path
|
|
; result := sel
|
|
|
|
// Prints the desugared abstract syntax ATerm of a selection.
|
|
debug-desugar-fostr: (sel, _, _, path, projp) -> (filename, result)
|
|
with filename := <guarantee-extension(|"desugared.aterm")> path
|
|
; result := <desugar-fostr> sel
|
|
|
|
// Prints the pre-analyzed abstract syntax ATerm of a selection.
|
|
debug-show-pre-analyzed: (sel, _, _, path, projp) -> (filename, result)
|
|
with filename := <guarantee-extension(|"pre-analyzed.aterm")> path
|
|
; result := <pre-analyze> sel
|
|
|
|
// Prints the analyzed annotated abstract syntax ATerm of a selection.
|
|
debug-show-analyzed: (sel, _, _, path, projp) -> (filename, result)
|
|
with filename := <guarantee-extension(|"analyzed.aterm")> path
|
|
; result := sel
|
|
|
|
// Extract the type assigned to a node by Statix
|
|
get-type: node -> type
|
|
where
|
|
// Assigns variable a to be the result of the Statix analysis of the entire program (or throws an error)
|
|
a := <stx-get-ast-analysis <+ fail-msg(|$[no analysis on node [<strip-annos;write-to-string> node]])>;
|
|
// Gets the type of the given node (or throws an error)
|
|
type := <stx-get-ast-type(|a) <+ fail-msg(|$[no type on node [<strip-annos;write-to-string> node]])> node
|
|
|
|
fail-msg(|msg) = err-msg(|$[get-type: [msg]]); fail
|
|
|
|
// Prints the analyzed type of a selection.
|
|
debug-show-type: (sel, _, _, path, projp) -> (filename, result)
|
|
with filename := <guarantee-extension(|"type.aterm")> path
|
|
; result := <get-type> sel
|