Skip to content

Commit 6e97f73

Browse files
committed
First version of the DSL grammar with yaml format
1 parent 94269e6 commit 6e97f73

File tree

71 files changed

+16764
-0
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

71 files changed

+16764
-0
lines changed
Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,9 @@
1+
<?xml version="1.0" encoding="UTF-8"?>
2+
<classpath>
3+
<classpathentry kind="src" path="src"/>
4+
<classpathentry kind="src" path="src-gen"/>
5+
<classpathentry kind="src" path="xtend-gen"/>
6+
<classpathentry kind="con" path="org.eclipse.jdt.launching.JRE_CONTAINER/org.eclipse.jdt.internal.debug.ui.launcher.StandardVMType/JavaSE-11"/>
7+
<classpathentry kind="con" path="org.eclipse.pde.core.requiredPlugins"/>
8+
<classpathentry kind="output" path="bin"/>
9+
</classpath>
Lines changed: 34 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,34 @@
1+
<?xml version="1.0" encoding="UTF-8"?>
2+
<projectDescription>
3+
<name>de.fraunhofer.ipa.ros1.xtext.ide</name>
4+
<comment></comment>
5+
<projects>
6+
</projects>
7+
<buildSpec>
8+
<buildCommand>
9+
<name>org.eclipse.xtext.ui.shared.xtextBuilder</name>
10+
<arguments>
11+
</arguments>
12+
</buildCommand>
13+
<buildCommand>
14+
<name>org.eclipse.jdt.core.javabuilder</name>
15+
<arguments>
16+
</arguments>
17+
</buildCommand>
18+
<buildCommand>
19+
<name>org.eclipse.pde.ManifestBuilder</name>
20+
<arguments>
21+
</arguments>
22+
</buildCommand>
23+
<buildCommand>
24+
<name>org.eclipse.pde.SchemaBuilder</name>
25+
<arguments>
26+
</arguments>
27+
</buildCommand>
28+
</buildSpec>
29+
<natures>
30+
<nature>org.eclipse.xtext.ui.shared.xtextNature</nature>
31+
<nature>org.eclipse.jdt.core.javanature</nature>
32+
<nature>org.eclipse.pde.PluginNature</nature>
33+
</natures>
34+
</projectDescription>
Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,2 @@
1+
eclipse.preferences.version=1
2+
encoding/<project>=UTF-8
Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,10 @@
1+
eclipse.preferences.version=1
2+
org.eclipse.jdt.core.compiler.codegen.inlineJsrBytecode=enabled
3+
org.eclipse.jdt.core.compiler.codegen.targetPlatform=11
4+
org.eclipse.jdt.core.compiler.compliance=11
5+
org.eclipse.jdt.core.compiler.problem.assertIdentifier=error
6+
org.eclipse.jdt.core.compiler.problem.enablePreviewFeatures=disabled
7+
org.eclipse.jdt.core.compiler.problem.enumIdentifier=error
8+
org.eclipse.jdt.core.compiler.problem.reportPreviewFeatures=warning
9+
org.eclipse.jdt.core.compiler.release=enabled
10+
org.eclipse.jdt.core.compiler.source=11
Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,17 @@
1+
Manifest-Version: 1.0
2+
Automatic-Module-Name: de.fraunhofer.ipa.ros1.xtext.ide
3+
Bundle-ManifestVersion: 2
4+
Bundle-Name: de.fraunhofer.ipa.ros1.xtext.ide
5+
Bundle-Vendor: My Company
6+
Bundle-Version: 1.0.0.qualifier
7+
Bundle-SymbolicName: de.fraunhofer.ipa.ros1.xtext.ide; singleton:=true
8+
Bundle-ActivationPolicy: lazy
9+
Require-Bundle: de.fraunhofer.ipa.ros1.xtext,
10+
de.fraunhofer.ipa.ros,
11+
org.eclipse.xtext.ide,
12+
org.eclipse.xtext.xbase.ide,
13+
org.antlr.runtime;bundle-version="[3.2.0,3.2.1)"
14+
Bundle-RequiredExecutionEnvironment: JavaSE-11
15+
Export-Package: de.fraunhofer.ipa.ros1.ide.contentassist.antlr.internal,
16+
de.fraunhofer.ipa.ros1.ide.contentassist.antlr.lexer,
17+
de.fraunhofer.ipa.ros1.ide.contentassist.antlr
Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
source.. = src/,\
2+
src-gen/,\
3+
xtend-gen/
4+
bin.includes = .,\
5+
META-INF/
6+
bin.excludes = **/*.xtend
Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
de.fraunhofer.ipa.ros1.ide.Ros1IdeSetup
Lines changed: 67 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,67 @@
1+
/*
2+
* generated by Xtext 2.25.0
3+
*/
4+
package de.fraunhofer.ipa.ros1.ide;
5+
6+
import com.google.inject.Binder;
7+
import com.google.inject.name.Names;
8+
import de.fraunhofer.ipa.ros1.ide.contentassist.antlr.Ros1Parser;
9+
import de.fraunhofer.ipa.ros1.ide.contentassist.antlr.lexer.InternalRos1Lexer;
10+
import org.eclipse.xtext.ide.DefaultIdeModule;
11+
import org.eclipse.xtext.ide.LexerIdeBindings;
12+
import org.eclipse.xtext.ide.editor.contentassist.CompletionPrefixProvider;
13+
import org.eclipse.xtext.ide.editor.contentassist.FQNPrefixMatcher;
14+
import org.eclipse.xtext.ide.editor.contentassist.IPrefixMatcher;
15+
import org.eclipse.xtext.ide.editor.contentassist.IProposalConflictHelper;
16+
import org.eclipse.xtext.ide.editor.contentassist.IndentationAwareCompletionPrefixProvider;
17+
import org.eclipse.xtext.ide.editor.contentassist.antlr.AntlrProposalConflictHelper;
18+
import org.eclipse.xtext.ide.editor.contentassist.antlr.IContentAssistParser;
19+
import org.eclipse.xtext.ide.editor.contentassist.antlr.internal.Lexer;
20+
import org.eclipse.xtext.ide.refactoring.IRenameStrategy2;
21+
import org.eclipse.xtext.ide.server.rename.IRenameService2;
22+
import org.eclipse.xtext.ide.server.rename.RenameService2;
23+
24+
/**
25+
* Manual modifications go to {@link Ros1IdeModule}.
26+
*/
27+
@SuppressWarnings("all")
28+
public abstract class AbstractRos1IdeModule extends DefaultIdeModule {
29+
30+
// contributed by org.eclipse.xtext.xtext.generator.parser.antlr.XtextAntlrGeneratorFragment2
31+
public void configureContentAssistLexer(Binder binder) {
32+
binder.bind(Lexer.class)
33+
.annotatedWith(Names.named(LexerIdeBindings.CONTENT_ASSIST))
34+
.to(InternalRos1Lexer.class);
35+
}
36+
37+
// contributed by org.eclipse.xtext.xtext.generator.parser.antlr.XtextAntlrGeneratorFragment2
38+
public Class<? extends IContentAssistParser> bindIContentAssistParser() {
39+
return Ros1Parser.class;
40+
}
41+
42+
// contributed by org.eclipse.xtext.xtext.generator.parser.antlr.XtextAntlrGeneratorFragment2
43+
public Class<? extends IProposalConflictHelper> bindIProposalConflictHelper() {
44+
return AntlrProposalConflictHelper.class;
45+
}
46+
47+
// contributed by org.eclipse.xtext.xtext.generator.parser.antlr.XtextAntlrGeneratorFragment2
48+
public Class<? extends CompletionPrefixProvider> bindCompletionPrefixProvider() {
49+
return IndentationAwareCompletionPrefixProvider.class;
50+
}
51+
52+
// contributed by org.eclipse.xtext.xtext.generator.exporting.QualifiedNamesFragment2
53+
public Class<? extends IPrefixMatcher> bindIPrefixMatcher() {
54+
return FQNPrefixMatcher.class;
55+
}
56+
57+
// contributed by org.eclipse.xtext.xtext.generator.ui.refactoring.RefactorElementNameFragment2
58+
public Class<? extends IRenameService2> bindIRenameService2() {
59+
return RenameService2.class;
60+
}
61+
62+
// contributed by org.eclipse.xtext.xtext.generator.ui.refactoring.RefactorElementNameFragment2
63+
public Class<? extends IRenameStrategy2> bindIRenameStrategy2() {
64+
return IRenameStrategy2.DefaultImpl.class;
65+
}
66+
67+
}
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,33 @@
1+
/*
2+
* generated by Xtext 2.25.0
3+
*/
4+
package de.fraunhofer.ipa.ros1.ide.contentassist.antlr;
5+
6+
import java.util.Collection;
7+
import java.util.Collections;
8+
import org.eclipse.xtext.AbstractRule;
9+
import org.eclipse.xtext.ide.editor.contentassist.antlr.FollowElement;
10+
import org.eclipse.xtext.ide.editor.contentassist.antlr.internal.AbstractInternalContentAssistParser;
11+
import org.eclipse.xtext.util.PolymorphicDispatcher;
12+
13+
public class PartialRos1ContentAssistParser extends Ros1Parser {
14+
15+
private AbstractRule rule;
16+
17+
@Override
18+
public void initializeFor(AbstractRule rule) {
19+
this.rule = rule;
20+
}
21+
22+
@Override
23+
protected Collection<FollowElement> getFollowElements(AbstractInternalContentAssistParser parser) {
24+
if (rule == null || rule.eIsProxy())
25+
return Collections.emptyList();
26+
String methodName = "entryRule" + rule.getName();
27+
PolymorphicDispatcher<Collection<FollowElement>> dispatcher =
28+
new PolymorphicDispatcher<Collection<FollowElement>>(methodName, 0, 0, Collections.singletonList(parser));
29+
dispatcher.invoke();
30+
return parser.getFollowElements();
31+
}
32+
33+
}
Lines changed: 113 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,113 @@
1+
/*
2+
* generated by Xtext 2.25.0
3+
*/
4+
package de.fraunhofer.ipa.ros1.ide.contentassist.antlr;
5+
6+
import com.google.common.collect.ImmutableMap;
7+
import com.google.inject.Inject;
8+
import com.google.inject.Singleton;
9+
import de.fraunhofer.ipa.ros1.ide.contentassist.antlr.internal.InternalRos1Parser;
10+
import de.fraunhofer.ipa.ros1.services.Ros1GrammarAccess;
11+
import java.util.Map;
12+
import org.antlr.runtime.CharStream;
13+
import org.antlr.runtime.TokenSource;
14+
import org.eclipse.xtext.AbstractElement;
15+
import org.eclipse.xtext.ide.editor.contentassist.antlr.AbstractContentAssistParser;
16+
17+
public class Ros1Parser extends AbstractContentAssistParser {
18+
19+
@Singleton
20+
public static final class NameMappings {
21+
22+
private final Map<AbstractElement, String> mappings;
23+
24+
@Inject
25+
public NameMappings(Ros1GrammarAccess grammarAccess) {
26+
ImmutableMap.Builder<AbstractElement, String> builder = ImmutableMap.builder();
27+
init(builder, grammarAccess);
28+
this.mappings = builder.build();
29+
}
30+
31+
public String getRuleName(AbstractElement element) {
32+
return mappings.get(element);
33+
}
34+
35+
private static void init(ImmutableMap.Builder<AbstractElement, String> builder, Ros1GrammarAccess grammarAccess) {
36+
builder.put(grammarAccess.getDependencyAccess().getAlternatives(), "rule__Dependency__Alternatives");
37+
builder.put(grammarAccess.getRosNamesAccess().getAlternatives(), "rule__RosNames__Alternatives");
38+
builder.put(grammarAccess.getEStringAccess().getAlternatives(), "rule__EString__Alternatives");
39+
builder.put(grammarAccess.getRosParamNamesAccess().getAlternatives(), "rule__RosParamNames__Alternatives");
40+
builder.put(grammarAccess.getCatkinPackageAccess().getGroup(), "rule__CatkinPackage__Group__0");
41+
builder.put(grammarAccess.getCatkinPackageAccess().getGroup_4(), "rule__CatkinPackage__Group_4__0");
42+
builder.put(grammarAccess.getCatkinPackageAccess().getGroup_5(), "rule__CatkinPackage__Group_5__0");
43+
builder.put(grammarAccess.getCatkinPackageAccess().getGroup_5_2(), "rule__CatkinPackage__Group_5_2__0");
44+
builder.put(grammarAccess.getCatkinPackageAccess().getGroup_6(), "rule__CatkinPackage__Group_6__0");
45+
builder.put(grammarAccess.getCatkinPackageAccess().getGroup_6_3(), "rule__CatkinPackage__Group_6_3__0");
46+
builder.put(grammarAccess.getArtifactAccess().getGroup(), "rule__Artifact__Group__0");
47+
builder.put(grammarAccess.getNodeAccess().getGroup(), "rule__Node__Group__0");
48+
builder.put(grammarAccess.getNodeAccess().getGroup_3(), "rule__Node__Group_3__0");
49+
builder.put(grammarAccess.getNodeAccess().getGroup_3_2(), "rule__Node__Group_3_2__0");
50+
builder.put(grammarAccess.getPublisherAccess().getGroup(), "rule__Publisher__Group__0");
51+
builder.put(grammarAccess.getExternalDependencyAccess().getGroup(), "rule__ExternalDependency__Group__0");
52+
builder.put(grammarAccess.getCatkinPackageAccess().getNameAssignment_1(), "rule__CatkinPackage__NameAssignment_1");
53+
builder.put(grammarAccess.getCatkinPackageAccess().getFromGitRepoAssignment_4_1(), "rule__CatkinPackage__FromGitRepoAssignment_4_1");
54+
builder.put(grammarAccess.getCatkinPackageAccess().getArtifactAssignment_5_1(), "rule__CatkinPackage__ArtifactAssignment_5_1");
55+
builder.put(grammarAccess.getCatkinPackageAccess().getArtifactAssignment_5_2_1(), "rule__CatkinPackage__ArtifactAssignment_5_2_1");
56+
builder.put(grammarAccess.getCatkinPackageAccess().getDependencyAssignment_6_2(), "rule__CatkinPackage__DependencyAssignment_6_2");
57+
builder.put(grammarAccess.getCatkinPackageAccess().getDependencyAssignment_6_3_1(), "rule__CatkinPackage__DependencyAssignment_6_3_1");
58+
builder.put(grammarAccess.getArtifactAccess().getNameAssignment_2(), "rule__Artifact__NameAssignment_2");
59+
builder.put(grammarAccess.getArtifactAccess().getNodeAssignment_5(), "rule__Artifact__NodeAssignment_5");
60+
builder.put(grammarAccess.getNodeAccess().getNameAssignment_1(), "rule__Node__NameAssignment_1");
61+
builder.put(grammarAccess.getNodeAccess().getPublisherAssignment_3_1(), "rule__Node__PublisherAssignment_3_1");
62+
builder.put(grammarAccess.getNodeAccess().getPublisherAssignment_3_2_1(), "rule__Node__PublisherAssignment_3_2_1");
63+
builder.put(grammarAccess.getPublisherAccess().getNameAssignment_2(), "rule__Publisher__NameAssignment_2");
64+
builder.put(grammarAccess.getPublisherAccess().getMessageAssignment_6(), "rule__Publisher__MessageAssignment_6");
65+
builder.put(grammarAccess.getPackageDependencyAccess().getPackageAssignment(), "rule__PackageDependency__PackageAssignment");
66+
builder.put(grammarAccess.getExternalDependencyAccess().getNameAssignment_2(), "rule__ExternalDependency__NameAssignment_2");
67+
}
68+
}
69+
70+
@Inject
71+
private NameMappings nameMappings;
72+
73+
@Inject
74+
private Ros1GrammarAccess grammarAccess;
75+
76+
@Override
77+
protected InternalRos1Parser createParser() {
78+
InternalRos1Parser result = new InternalRos1Parser(null);
79+
result.setGrammarAccess(grammarAccess);
80+
return result;
81+
}
82+
83+
@Override
84+
protected TokenSource createLexer(CharStream stream) {
85+
return new Ros1TokenSource(super.createLexer(stream));
86+
}
87+
88+
@Override
89+
protected String getRuleName(AbstractElement element) {
90+
return nameMappings.getRuleName(element);
91+
}
92+
93+
@Override
94+
protected String[] getInitialHiddenTokens() {
95+
return new String[] { "RULE_WS", "RULE_ML_COMMENT", "RULE_SL_COMMENT" };
96+
}
97+
98+
public Ros1GrammarAccess getGrammarAccess() {
99+
return this.grammarAccess;
100+
}
101+
102+
public void setGrammarAccess(Ros1GrammarAccess grammarAccess) {
103+
this.grammarAccess = grammarAccess;
104+
}
105+
106+
public NameMappings getNameMappings() {
107+
return nameMappings;
108+
}
109+
110+
public void setNameMappings(NameMappings nameMappings) {
111+
this.nameMappings = nameMappings;
112+
}
113+
}

0 commit comments

Comments
 (0)