init commit again
This commit is contained in:
34
IBAF-Editor/trans/analysis.str
Normal file
34
IBAF-Editor/trans/analysis.str
Normal file
@@ -0,0 +1,34 @@
|
||||
module analysis
|
||||
|
||||
imports
|
||||
libstratego-lib
|
||||
|
||||
imports
|
||||
|
||||
nabl2/api
|
||||
nabl2/runtime
|
||||
|
||||
statics
|
||||
|
||||
pp
|
||||
|
||||
rules // Analysis
|
||||
|
||||
editor-analyze = nabl2-analyze(id)
|
||||
|
||||
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 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
|
||||
|
||||
rules // Rename refactoring
|
||||
|
||||
// change last strategy argument to id if multi-file analysis is enabled
|
||||
rename-menu-action = nabl2-rename-action(construct-textual-change, editor-analyze, fail)
|
||||
1
IBAF-Editor/trans/cbs-gen/IBAF-Start.meta
Normal file
1
IBAF-Editor/trans/cbs-gen/IBAF-Start.meta
Normal file
@@ -0,0 +1 @@
|
||||
Meta([Syntax("Stratego-IBAF")])
|
||||
53
IBAF-Editor/trans/cbs-gen/IBAF-Start.str
Normal file
53
IBAF-Editor/trans/cbs-gen/IBAF-Start.str
Normal file
@@ -0,0 +1,53 @@
|
||||
module IBAF-Start
|
||||
|
||||
imports
|
||||
libstratego-gpp
|
||||
signatures/-
|
||||
pp/IBAF-parenthesize
|
||||
pp/IBAF-pp
|
||||
|
||||
imports
|
||||
|
||||
|
||||
// Language "IBAFlang"
|
||||
|
||||
rules
|
||||
to-funcons:
|
||||
|[ start[: (:E:) :] ]| ->
|
||||
|[ initialise-binding finalise-failing eval[: (:E:) :] ]|
|
||||
to-funcons:
|
||||
|[ eval[: (:N:) :] ]| ->
|
||||
|[ int[: (:N:) :] ]|
|
||||
to-funcons:
|
||||
|[ eval[: (:X:) :] ]| ->
|
||||
|[ bound id[: (:X:) :] ]|
|
||||
to-funcons:
|
||||
|[ eval[: lambda(:X:).(:E:) :] ]| ->
|
||||
|[ function closure scope (bind (id[: (:X:) :],
|
||||
given),
|
||||
eval[: (:E:) :]) ]|
|
||||
to-funcons:
|
||||
|[ eval[: (:E1:)((:E2:)) :] ]| ->
|
||||
|[ apply (eval[: (:E1:) :],
|
||||
eval[: (:E2:) :]) ]|
|
||||
to-funcons:
|
||||
|[ eval[: let(:X:)=(:E1:)in(:E2:) :] ]| ->
|
||||
|[ scope (bind (id[: (:X:) :],
|
||||
eval[: (:E1:) :]),
|
||||
eval[: (:E2:) :]) ]|
|
||||
to-funcons:
|
||||
|[ eval[: ((:E:)) :] ]| ->
|
||||
|[ eval[: (:E:) :] ]|
|
||||
to-funcons-lex:
|
||||
FCTDoubleQuoted(L-int(LEX-int(str))) ->
|
||||
FCTString(<double-quote> str)
|
||||
to-funcons:
|
||||
|[ int[: (:N:) :] ]| ->
|
||||
|[ decimal \"(:N:)\" ]|
|
||||
to-funcons-lex:
|
||||
FCTDoubleQuoted(L-id(LEX-id(str))) ->
|
||||
FCTString(<double-quote> str)
|
||||
to-funcons:
|
||||
|[ id[: (:X:) :] ]| ->
|
||||
|[ \"(:X:)\" ]|
|
||||
|
||||
1
IBAF-Editor/trans/generate.meta
Normal file
1
IBAF-Editor/trans/generate.meta
Normal file
@@ -0,0 +1 @@
|
||||
Meta([Syntax("Stratego-IBAF")])
|
||||
118
IBAF-Editor/trans/generate.str
Normal file
118
IBAF-Editor/trans/generate.str
Normal file
@@ -0,0 +1,118 @@
|
||||
module generate
|
||||
|
||||
imports
|
||||
libstratego-gpp
|
||||
signatures/-
|
||||
pp/IBAF-parenthesize
|
||||
pp/IBAF-pp
|
||||
pp/Funcons-pp-pp
|
||||
cbs-gen/IBAF-Start
|
||||
|
||||
rules // Builder
|
||||
|
||||
// Generates a funcon term for selected AST.
|
||||
generate-fct:
|
||||
(selected, position, ast, path, project-path) -> (filename, result)
|
||||
where <not(has-extension(|"fct"))> <debug> path
|
||||
with
|
||||
filename := <guarantee-extension(|"fct")> path;
|
||||
funcons := <to-funcons-top> selected;
|
||||
result := <prettyprint-IBAF-string> funcons
|
||||
|
||||
generate-fct:
|
||||
(selected, position, ast, path, project-path) -> None()
|
||||
where <has-extension(|"fct")> path
|
||||
|
||||
prettyprint-IBAF-string =
|
||||
parenthesize-IBAF
|
||||
; prettyprint-IBAF-Start
|
||||
; !V([], <id>)
|
||||
; box2text-string(|80)
|
||||
|
||||
to-funcons-start: START -> |[ start[: START :] ]|
|
||||
|
||||
to-funcons-top =
|
||||
to-funcons-start;
|
||||
innermost(to-desugared <+ to-funcons <+ to-funcons-default);
|
||||
bottomup(try(to-funcons-lex));
|
||||
innermost(to-funcons-sequences <+ to-funcons-groups);
|
||||
innermost(to-funcons-apps)
|
||||
|
||||
to-funcons = fail
|
||||
|
||||
to-funcons-default = fail
|
||||
|
||||
to-desugared = fail
|
||||
|
||||
// Funcons involved in simplification rules:
|
||||
|
||||
rules
|
||||
|
||||
to-funcons-sequences:
|
||||
FCTSequence(FCTEmpty(),seq) -> seq
|
||||
|
||||
to-funcons-sequences:
|
||||
FCTSequence(seq,FCTEmpty()) -> seq
|
||||
|
||||
to-funcons-sequences:
|
||||
FCTApp("sequential",FCTGroup(FCTSequence(fct,FCTApp("sequential",FCTGroup(seq))))) ->
|
||||
FCTApp("sequential",FCTGroup(FCTSequence(fct,seq)))
|
||||
|
||||
to-funcons-groups:
|
||||
FCTGroup(FCTGroup(seq)) -> FCTGroup(seq)
|
||||
|
||||
to-funcons-apps:
|
||||
FCTApp(f1,FCTApp(f2,fct)) -> FCTAppComp([f1,f2],fct)
|
||||
|
||||
to-funcons-apps:
|
||||
FCTApp(f,FCTAppComp(fs,fct)) -> FCTAppComp([f|fs],fct)
|
||||
|
||||
to-funcons-apps:
|
||||
FCTApp(f,FCTGroup(seq)) -> FCTAppComp([f],FCTGroup(seq))
|
||||
|
||||
rules
|
||||
|
||||
to-funcons-lex:
|
||||
FCTString(str) -> FCTString(<double-quote> str)
|
||||
|
||||
to-funcons-lex = ?FCTInt(_)
|
||||
|
||||
to-funcons-lex = ?FCTChar(_)
|
||||
|
||||
to-funcons-lex: FCTApp("integer-add",FCTGroup(FCTSequence(FCTInt(s),FCTInt(t)))) ->
|
||||
FCTInt(<addi;int-to-string>(<string-to-int> s, <string-to-int> t))
|
||||
|
||||
to-funcons-lex: FCTApp("string-append",FCTGroup(FCTSequence(FCTString(str1),FCTString(str2)))) ->
|
||||
FCTString(<concat-strings;double-quote> [<un-double-quote> str1, <un-double-quote> str2])
|
||||
|
||||
to-funcons-lex: FCTApp("string-append",FCTGroup(FCTSequence(FCTString(str1),FCTSequence(FCTString(str2),FCTString(str3))))) ->
|
||||
FCTString(<concat-strings;double-quote>
|
||||
[<un-double-quote> str1, <un-double-quote> str2, <un-double-quote> str3])
|
||||
// generalise to nested sequences
|
||||
|
||||
to-funcons-lex: FCTList(seq) ->
|
||||
FCTString(<concat-strings;double-quote> l)
|
||||
where
|
||||
<not(?FCTEmpty())> seq;
|
||||
l := <to-funcons-string-list>(seq, [])
|
||||
|
||||
|
||||
// l accumulates a list of strings, initially []:
|
||||
to-funcons-string-list: (FCTSequence(seq1, seq2), l) ->
|
||||
<to-funcons-string-list>(seq1, <to-funcons-string-list>(seq2, l))
|
||||
|
||||
to-funcons-string-list: (FCTEmpty(), l) -> l
|
||||
|
||||
// 'C':
|
||||
to-funcons-string-list: (FCTString(str), l) ->
|
||||
[<un-single-quote>str | l]
|
||||
|
||||
// ascii-character("C"):
|
||||
to-funcons-string-list:
|
||||
(FCTApp("ascii-character", FCTGroup(FCTString(str))), l) ->
|
||||
[<un-double-quote>str | l]
|
||||
|
||||
// ascii-character("\C"):
|
||||
to-funcons-string-list:
|
||||
(FCTApp("ascii-character", FCTApp("list-to-string", FCTList(seq))), l) ->
|
||||
<to-funcons-string-list>(seq, l)
|
||||
21
IBAF-Editor/trans/ibaf.str
Normal file
21
IBAF-Editor/trans/ibaf.str
Normal file
@@ -0,0 +1,21 @@
|
||||
module ibaf
|
||||
|
||||
imports
|
||||
libstratego-lib
|
||||
|
||||
imports
|
||||
completion/completion
|
||||
pp
|
||||
outline
|
||||
analysis
|
||||
|
||||
imports
|
||||
generate
|
||||
|
||||
rules // Debugging
|
||||
|
||||
debug-show-aterm:
|
||||
(node, _, _, path, project-path) -> (filename, result)
|
||||
with
|
||||
filename := <guarantee-extension(|"aterm")> path
|
||||
; result := node
|
||||
18
IBAF-Editor/trans/outline.str
Normal file
18
IBAF-Editor/trans/outline.str
Normal file
@@ -0,0 +1,18 @@
|
||||
module outline
|
||||
|
||||
imports
|
||||
libstratego-lib
|
||||
|
||||
imports
|
||||
|
||||
signatures/IBAF-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
|
||||
52
IBAF-Editor/trans/pp.str
Normal file
52
IBAF-Editor/trans/pp.str
Normal file
@@ -0,0 +1,52 @@
|
||||
module pp
|
||||
|
||||
imports
|
||||
libstratego-lib
|
||||
|
||||
imports
|
||||
|
||||
libstratego-gpp
|
||||
libspoofax/sdf/pp
|
||||
libspoofax/editor/refactoring/-
|
||||
pp/IBAF-parenthesize
|
||||
pp/IBAF-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-IBAF-string =
|
||||
parenthesize-IBAF
|
||||
; prettyprint-IBAF-start-symbols
|
||||
; !V([], <id>)
|
||||
; box2text-string(|120)
|
||||
|
||||
pp-partial-IBAF-string =
|
||||
parenthesize-IBAF
|
||||
; prettyprint-IBAF
|
||||
; !V([], <id>)
|
||||
; box2text-string(|120)
|
||||
|
||||
pp-partial-IBAF-string(|sort) =
|
||||
parenthesize-IBAF
|
||||
; prettyprint-IBAF(|sort)
|
||||
; !V([], <id>)
|
||||
; box2text-string(|120)
|
||||
|
||||
pp-debug :
|
||||
ast -> result
|
||||
with
|
||||
result := <pp-IBAF-string> ast
|
||||
<+ <bottomup(try(not(is-string); not(is-list); not(pp-IBAF-string); debug(!"cannot pp ")))> ast
|
||||
; result := ""
|
||||
|
||||
rules
|
||||
|
||||
construct-textual-change = construct-textual-change(pp-partial-IBAF-string, parenthesize, override-reconstruction, resugar)
|
||||
12
IBAF-Editor/trans/statics.nabl2
Normal file
12
IBAF-Editor/trans/statics.nabl2
Normal file
@@ -0,0 +1,12 @@
|
||||
module statics
|
||||
|
||||
imports
|
||||
|
||||
signatures/-
|
||||
|
||||
rules
|
||||
|
||||
init ^ (s) := new s.
|
||||
|
||||
[[ _ ^ (s) ]].
|
||||
|
||||
Reference in New Issue
Block a user