init: SDF3/Statix project as initialized by Spoofax

This commit is contained in:
Glen Whitney 2021-01-30 12:27:10 -08:00
commit 9ecfa63f58
20 changed files with 515 additions and 0 deletions

46
trans/analysis.str Normal file
View file

@ -0,0 +1,46 @@
module analysis
imports
statixruntime
statix/api
pp
injections/-
libspoofax/term/origin
rules // Analysis
// single-file analysis
editor-analyze = stx-editor-analyze(pre-analyze, post-analyze|"statics", "programOk")
// see README.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 = 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: (selected, _, _, path, project-path) -> (filename, result)
with filename := <guarantee-extension(|"aterm")> path
; result := selected
// Prints the pre-analyzed abstract syntax ATerm of a selection.
debug-show-pre-analyzed: (selected, _, _, path, project-path) -> (filename, result)
with filename := <guarantee-extension(|"pre-analyzed.aterm")> path
; result := <pre-analyze> selected
// Prints the analyzed annotated abstract syntax ATerm of a selection.
debug-show-analyzed: (selected, _, _, path, project-path) -> (filename, result)
with filename := <guarantee-extension(|"analyzed.aterm")> path
; result := selected

16
trans/fostr.str Normal file
View file

@ -0,0 +1,16 @@
module fostr
imports
completion/completion
pp
outline
analysis
rules // Debugging
debug-show-aterm:
(node, _, _, path, project-path) -> (filename, result)
with
filename := <guarantee-extension(|"aterm")> path
; result := node

15
trans/outline.str Normal file
View file

@ -0,0 +1,15 @@
module outline
imports
signatures/fostr-sig
libspoofax/editor/outline
rules
editor-outline:
(_, _, ast, path, project-path) -> outline
where
outline := <simple-label-outline(to-outline-label)> ast
to-outline-label = fail

49
trans/pp.str Normal file
View file

@ -0,0 +1,49 @@
module pp
imports
libstratego-gpp
libspoofax/sdf/pp
libspoofax/editor/refactoring/-
pp/fostr-parenthesize
pp/fostr-pp
rules
editor-format:
(node, _, ast, path, project-path) -> (filename, result)
with
ext := <get-extension> path
; filename := <guarantee-extension(|$[pp.[ext]])> path
; result := <pp-debug> node
rules
pp-fostr-string =
parenthesize-fostr
; prettyprint-fostr-start-symbols
; !V([], <id>)
; box2text-string(|120)
pp-partial-fostr-string =
parenthesize-fostr
; prettyprint-fostr
; !V([], <id>)
; box2text-string(|120)
pp-partial-fostr-string(|sort) =
parenthesize-fostr
; prettyprint-fostr(|sort)
; !V([], <id>)
; box2text-string(|120)
pp-debug :
ast -> result
with
result := <pp-fostr-string> ast
<+ <bottomup(try(not(is-string); not(is-list); not(pp-fostr-string); debug(!"cannot pp ")))> ast
; result := ""
rules
construct-textual-change = construct-textual-change(pp-partial-fostr-string, parenthesize, override-reconstruction, resugar)

24
trans/statics.stx Normal file
View file

@ -0,0 +1,24 @@
module statics
// see README.md for details on how to switch to multi-file analysis
rules // single-file entry point
programOk : Start
programOk(Empty()).
rules // multi-file entry point
projectOk : scope
projectOk(s).
fileOk : scope * Start
fileOk(s, Empty()).
signature
sorts Start constructors
Empty : Start