Skip to content

Commit

Permalink
Wip
Browse files Browse the repository at this point in the history
  • Loading branch information
ftomassetti committed Aug 30, 2024
1 parent 064f285 commit c97eae8
Show file tree
Hide file tree
Showing 5 changed files with 74 additions and 1 deletion.
Original file line number Diff line number Diff line change
Expand Up @@ -473,7 +473,9 @@ class KolasuClient(
containmentName: String,
containmentIndex: Int,
): LWNode {
require(kNode.javaClass.annotations.any { it is ASTRoot })
require(kNode.javaClass.annotations.any { it is ASTRoot }) {
"Cannot convert to LionWeb a node which class is not marked with annotation ASTRoot. Class: ${kNode.javaClass.canonicalName}"
}
nodeConverter.clearNodesMapping()
return nodeConverter.exportModelToLionWeb(
kNode,
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
package com.strumenta.kolasu.semantics.newapproach

import com.strumenta.kolasu.model.Node

interface ASTRepository {
fun<N: Node> getFullNode(nodeId:String) : N
fun<N: Node> getShallowNode(nodeId:String) : N
fun getNodeIDsByNodeType(nodeType: String) : List<String>
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
package com.strumenta.kolasu.semantics.newapproach

class BuiltinsSymbolsIndex {

}
Original file line number Diff line number Diff line change
@@ -0,0 +1,44 @@
package com.strumenta.kolasu.semantics.newapproach

import com.strumenta.kolasu.model.Node

interface SemanticEnrichmentLanguageSpecificLogic {
val builtinsSymbolsIndex: BuiltinsSymbolsIndex
val rootNodeTypes: List<String>
fun populateSRI(sri: SymbolResolutionIndex, ast: Node)
fun performSemanticEnrichment(sri: SymbolResolutionIndex, ast: Node)
}


class SemanticEnrichmentFacade(
val astRepository: ASTRepository,
val sri: SymbolResolutionIndex,
val languageSpecificLogics: List<SemanticEnrichmentLanguageSpecificLogic>
) {

/**
* This method is not responsible for loading or storing the SRI
*/
fun populateSymbolResolutionIndex() {
performOperationOnAST { semanticEnrichmentLanguageSpecificLogic, ast ->
semanticEnrichmentLanguageSpecificLogic.populateSRI(sri, ast)
}
}

fun performEnrichment() {
performOperationOnAST { semanticEnrichmentLanguageSpecificLogic, ast ->
semanticEnrichmentLanguageSpecificLogic.performSemanticEnrichment(sri, ast)
}
}

private fun performOperationOnAST(operation: (semanticEnrichmentLanguageSpecificLogic: SemanticEnrichmentLanguageSpecificLogic, ast: Node)->Unit) {
languageSpecificLogics.forEach { semanticEnrichmentLanguageSpecificLogic ->
semanticEnrichmentLanguageSpecificLogic.rootNodeTypes.forEach { rootNodeType ->
astRepository.getNodeIDsByNodeType(rootNodeType).forEach { rootNodeID ->
val ast = astRepository.getFullNode<Node>(rootNodeID)
operation.invoke(semanticEnrichmentLanguageSpecificLogic, ast)
}
}
}
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
package com.strumenta.kolasu.semantics.newapproach

import com.strumenta.kolasu.model.Source

class Symbol {
val source: Source = TODO()
}

class SymbolResolutionIndex {
fun store(symbol: Symbol) {
TODO()
}
}

0 comments on commit c97eae8

Please sign in to comment.