Skip to content
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,10 @@ public class NameCompatible4Isabelle implements SysMLStatesASTStateDefCoCo,
SysMLPartsASTSysMLPackageCoCo {
//check for name
private void LogsCompatible4Isabelle(String name, SourcePosition start, SourcePosition end) {
if(!name.matches("^(?!0-9)[a-zA-Z0-9_]+$") && !name.isEmpty()) {
// Names must start with a letter or underscore.
// Subsequent characters may also include digits, spaces, dots, and hyphens.
// Names like 'Roger B. Chaffee' , 'F-1', 'SA-500F' can be accepted.

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Image

Siehe auch https://git.rwth-aachen.de/monticore/languages/sysml2/sysml2official/-/work_items/52

Ich denke die korrekte Lösung ein Encoding der Namen im Transformer ist. Vorschlag:

<ASCII letters/digits> --> identisch

_ (Underscore)             --> __ (double Underscore)

Unicode U+XXXX        --> _uXXXX_

Dieser PR kann nicht gemerged werden, bitte mit anderen CoCos weitermachen.
Danach hier: https://git.rwth-aachen.de/montibelle/frontend/transformer/sysmltransformer/-/work_items/320

if (!name.isEmpty() && !name.matches("^[a-zA-Z_][a-zA-Z0-9_ .-]*$")) {
Log.error("0xFF005 This name is not Isabelle compatible", start, end);
}
}
Expand Down
Original file line number Diff line number Diff line change
@@ -1,18 +1,23 @@
package parser;
package cocos;

import de.monticore.lang.sysmlv2.SysMLv2Mill;
import de.monticore.lang.sysmlv2.SysMLv2Tool;
import de.monticore.lang.sysmlv2._ast.ASTSysMLModel;
import de.se_rwth.commons.logging.Log;
import de.se_rwth.commons.logging.LogStub;
import org.junit.jupiter.api.BeforeAll;
import org.junit.jupiter.api.BeforeEach;
import org.junit.jupiter.api.Test;
import java.io.IOException;
import java.nio.file.Files;
import java.nio.file.Path;
import java.util.ArrayList;
import java.util.stream.Collectors;
import static org.assertj.core.api.Assertions.assertThat;
import de.se_rwth.commons.logging.Finding;

/**
* Checks that the Apollo_11 can be parsed
* Checks that the Apollo 11 models can be parsed and pass all CoCo checks.
* https://github.com/airbus/apollo-11-sysml-v2/tree/main
*/
public class ApolloTest {
Expand All @@ -28,7 +33,7 @@ public static void setup() {
@BeforeEach
public void init() {
tool.init();
Log.init();
LogStub.init();
}

@Test
Expand All @@ -42,9 +47,13 @@ public void testParseApollo11Models() throws IOException {
var lines = 0;

Log.enableFailQuick(false);
var asts = new ArrayList<ASTSysMLModel>();

for(var model: models) {
try {
var ast = tool.parse(model.toString());
var ast = SysMLv2Mill.parser().parse(model.toString());
assertThat(ast).as("Could not parse " + model).isPresent();
asts.add(ast.get());
if(Log.getFindings().isEmpty()) {
successful++;
}
Expand All @@ -56,9 +65,17 @@ public void testParseApollo11Models() throws IOException {
Log.clearFindings();
}
}
asts.forEach(ast -> tool.createSymbolTable(ast));
asts.forEach(ast -> tool.completeSymbolTable(ast));
asts.forEach(ast -> tool.finalizeSymbolTable(ast));

//casts.forEach(ast -> tool.runDefaultCoCos(ast));
asts.forEach(ast -> tool.runAdditionalCoCos(ast));

assertThat(successful).isEqualTo(27);
assertThat(Log.getFindings()).isEmpty();

var errors = Log.getFindings().stream().filter(Finding::isError).collect(Collectors.toList());
assertThat(errors).as(errors::toString).isEmpty();
}

}
Loading