Skip to content

Commit

Permalink
[gzb2gzbc] Apply workaround for metaborg/nabl#94
Browse files Browse the repository at this point in the history
  • Loading branch information
jochembroekhoff committed Apr 11, 2022
1 parent 05260dc commit 80893b5
Show file tree
Hide file tree
Showing 2 changed files with 19 additions and 3 deletions.
15 changes: 15 additions & 0 deletions ext/ext.gzb2gzbc/trans/common.str
Original file line number Diff line number Diff line change
Expand Up @@ -76,3 +76,18 @@ strategies // is-simple-type :: Type -> id
+ ?TypeBool()
+ ?TypeInt()
+ ?TypeFloat()

strategies // stx-get-scopegraph-data-ext(|Analysis, relation:string) :: Scope -> List(any)

// Workaround for metaborg/nabl#94, see: https://slde.slack.com/archives/C7254SF60/p1649660409194699
stx-get-scopegraph-data-ext(|a, rel) = ?s
; stx-get-scopegraph-data(|a, rel)
; try(
?[]; !s
// extract the resource identifier from the scope and drop the "/./" prefix
; where(Scope(string-as-chars(drop(|3)) => resource, id))
// attempt to retrieve the analysis state from the extenal scope
; where(a' := <stx-get-ast-analysis> (){TermIndex(resource, -1)})
// execute in the external context
; stx-get-scopegraph-data(|a', rel)
)
7 changes: 4 additions & 3 deletions ext/ext.gzb2gzbc/trans/transform-type.str
Original file line number Diff line number Diff line change
Expand Up @@ -70,7 +70,7 @@ rules // type-convert(|Analysis) :: TYPE -> Type-C
type-convert-(|a): ENUM(s, t@INT()) -> TypeEnumInt-C(members)
with
members := <
stx-get-scopegraph-data(|a, "statics/common!memb")
stx-get-scopegraph-data-ext(|a, "statics/common!memb")
; filter(?(_, ENUM_V_INT(_)) + ?(_, ENUM_V_STR(_)))
; map(
\((name, _, _), ENUM_V_INT(v)) -> EnumMembInt-C(name, <int-to-string> v)\
Expand All @@ -80,7 +80,7 @@ rules // type-convert(|Analysis) :: TYPE -> Type-C
type-convert-(|a): ENUM(s, t@STRING()) -> TypeEnumString-C(members)
with
members := <
stx-get-scopegraph-data(|a, "statics/common!memb")
stx-get-scopegraph-data-ext(|a, "statics/common!memb")
; filter(?(_, ENUM_V_STR(_)))
; map(
\((name, _, _), ENUM_V_STR(v)) -> EnumMembString-C(name, v)\
Expand Down Expand Up @@ -146,7 +146,8 @@ strategies // AUX
*/
tt-scope-query-fields-recursive(|a): s -> <concat> [fields, edges'*]
with
fields := <stx-get-scopegraph-data(|a, "statics/common!field")> s
fields := <stx-get-scopegraph-data-ext(|a, "statics/common!field")> s
// TODO: maybe edges need a patched version like stx-get-scopegraph-data
; edges := <stx-get-scopegraph-edges(|a, "statics/common!B")> s
; edges'* := <map(tt-scope-query-fields-recursive(|a))> edges

Expand Down

0 comments on commit 80893b5

Please sign in to comment.