-
Notifications
You must be signed in to change notification settings - Fork 12
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
064f285
commit c97eae8
Showing
5 changed files
with
74 additions
and
1 deletion.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
9 changes: 9 additions & 0 deletions
9
semantics/src/main/kotlin/com/strumenta/kolasu/semantics/newapproach/ASTRepository.kt
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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> | ||
} |
5 changes: 5 additions & 0 deletions
5
semantics/src/main/kotlin/com/strumenta/kolasu/semantics/newapproach/BuiltinsSymbolsIndex.kt
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,5 @@ | ||
package com.strumenta.kolasu.semantics.newapproach | ||
|
||
class BuiltinsSymbolsIndex { | ||
|
||
} |
44 changes: 44 additions & 0 deletions
44
...cs/src/main/kotlin/com/strumenta/kolasu/semantics/newapproach/SemanticEnrichmentFacade.kt
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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) | ||
} | ||
} | ||
} | ||
} | ||
} |
13 changes: 13 additions & 0 deletions
13
...ntics/src/main/kotlin/com/strumenta/kolasu/semantics/newapproach/SymbolResolutionIndex.kt
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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() | ||
} | ||
} |