Skip to content

Commit

Permalink
fix: correct scope for tensor dim reference in tensor body and lookup
Browse files Browse the repository at this point in the history
  • Loading branch information
Mangern committed Oct 4, 2024
1 parent f116bcd commit 6c4a97e
Show file tree
Hide file tree
Showing 4 changed files with 6 additions and 4 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -210,6 +210,7 @@ public List<Symbol> findSymbols(Symbol symbol) {
public List<Symbol> findSymbols(Symbol scope, SymbolType type, String shortIdentifier) {
// First candidates are all symbols with correct type and correct short identifier

// Special case for schema and document because a schema can sometimes refer to a document and vice versa
if (type == SymbolType.SCHEMA || type == SymbolType.DOCUMENT) {
SymbolType firstCheck = (type == SymbolType.SCHEMA ? SymbolType.SCHEMA : SymbolType.DOCUMENT);
List<Symbol> schemaDefinitions =
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -110,9 +110,9 @@ public void updateFileContent(String content) {
this.CST = parsingResult.CST().get();
lexer.setCST(CST);

logger.info("======== CST for file: " + fileURI + " ========");
//logger.info("======== CST for file: " + fileURI + " ========");

CSTUtils.printTree(logger, CST);
//CSTUtils.printTree(logger, CST);
}


Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -350,8 +350,6 @@ private void handleTensorTypeDefinitions(SchemaNode identifierNode, SchemaNode t
Optional<Symbol> existingSymbolMapped = context.schemaIndex().findSymbolInScope(scope, SymbolType.TENSOR_DIMENSION_MAPPED, identifierNode.getText());
Optional<Symbol> existingSymbolIndexed = context.schemaIndex().findSymbolInScope(scope, SymbolType.TENSOR_DIMENSION_INDEXED, identifierNode.getText());

// I want to keep this check here to give a message,
// but we have to change some stuff in the CongoCC parser for it to take effect.
if (existingSymbolMapped.isPresent() || existingSymbolIndexed.isPresent()) {
identifierNode.setSymbolStatus(SymbolStatus.INVALID);
diagnostics.add(new SchemaDiagnostic.Builder()
Expand All @@ -363,6 +361,7 @@ private void handleTensorTypeDefinitions(SchemaNode identifierNode, SchemaNode t
}

identifierNode.setSymbolStatus(SymbolStatus.DEFINITION);
context.schemaIndex().insertSymbolDefinition(identifierNode.getSymbol());
}

private static final Set<String> reservedFunctionNames = ReservedFunctionNames.getReservedNames();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -144,6 +144,8 @@ private static void findBuiltInFunction(RankNode node, ParseContext context, Lis
// add(SymbolType.PARAMETER); // This is a special case
add(SymbolType.FUNCTION);
add(SymbolType.RANK_CONSTANT);
add(SymbolType.TENSOR_DIMENSION_MAPPED);
add(SymbolType.TENSOR_DIMENSION_INDEXED);
}};

private static void resolveReference(RankNode referenceNode, ParseContext context, List<Diagnostic> diagnostics) {
Expand Down

0 comments on commit 6c4a97e

Please sign in to comment.