forked from glen/fostr
Glen Whitney
f93499acfd
Also move the signature of the semantic sort TYPE into its own file to facilitate sharing between Statix and Stratego. (Currently it is shared via symbolic link, but that may cause problems down the line; if/when it does, will have to look at physically copying the file into src-gen via an "Additional build step" using either Stratego or Ant. Also documents using Statix types from Stratego.
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
|