Iniital checkin

This commit is contained in:
2017-09-12 12:48:21 +02:00
commit fd1e04fb62
270 changed files with 87560 additions and 0 deletions

View File

@ -0,0 +1,43 @@
/**
* generated by Xtext 2.12.0
*/
package com.minres.rdl;
import com.google.inject.Binder;
import com.google.inject.name.Names;
import com.minres.rdl.AbstractRDLRuntimeModule;
import com.minres.rdl.converter.RdlTerminalConverters;
import org.eclipse.xtext.conversion.IValueConverterService;
import org.eclipse.xtext.naming.IQualifiedNameProvider;
import org.eclipse.xtext.naming.SimpleNameProvider;
import org.eclipse.xtext.scoping.IGlobalScopeProvider;
import org.eclipse.xtext.scoping.IScopeProvider;
import org.eclipse.xtext.scoping.impl.AbstractDeclarativeScopeProvider;
import org.eclipse.xtext.scoping.impl.ImportUriGlobalScopeProvider;
import org.eclipse.xtext.scoping.impl.SimpleLocalScopeProvider;
/**
* Use this class to register components to be used at runtime / without the Equinox extension registry.
*/
@SuppressWarnings("all")
public class RDLRuntimeModule extends AbstractRDLRuntimeModule {
@Override
public Class<? extends IValueConverterService> bindIValueConverterService() {
return RdlTerminalConverters.class;
}
@Override
public void configureIScopeProviderDelegate(final Binder binder) {
binder.<IScopeProvider>bind(IScopeProvider.class).annotatedWith(Names.named(AbstractDeclarativeScopeProvider.NAMED_DELEGATE)).to(SimpleLocalScopeProvider.class);
}
@Override
public Class<? extends IGlobalScopeProvider> bindIGlobalScopeProvider() {
return ImportUriGlobalScopeProvider.class;
}
@Override
public Class<? extends IQualifiedNameProvider> bindIQualifiedNameProvider() {
return SimpleNameProvider.class;
}
}

View File

@ -0,0 +1,16 @@
/**
* generated by Xtext 2.12.0
*/
package com.minres.rdl;
import com.minres.rdl.RDLStandaloneSetupGenerated;
/**
* Initialization support for running Xtext languages without Equinox extension registry.
*/
@SuppressWarnings("all")
public class RDLStandaloneSetup extends RDLStandaloneSetupGenerated {
public static void doSetup() {
new RDLStandaloneSetup().createInjectorAndDoEMFRegistration();
}
}

View File

@ -0,0 +1,22 @@
package com.minres.rdl.converter;
import org.eclipse.xtext.conversion.impl.AbstractLexerBasedConverter;
import org.eclipse.xtext.nodemodel.INode;
@SuppressWarnings("all")
public class IDValueConverter extends AbstractLexerBasedConverter<String> {
@Override
protected String toEscapedString(final String value) {
return value;
}
@Override
public String toValue(final String string, final INode node) {
boolean _startsWith = string.startsWith("\\");
if (_startsWith) {
return string.substring(1);
} else {
return string;
}
}
}

View File

@ -0,0 +1,45 @@
package com.minres.rdl.converter;
import com.minres.rdl.IntegerWithRadix;
import org.eclipse.xtend2.lib.StringConcatenation;
import org.eclipse.xtext.conversion.ValueConverterException;
import org.eclipse.xtext.conversion.impl.AbstractLexerBasedConverter;
import org.eclipse.xtext.nodemodel.INode;
import org.eclipse.xtext.util.Strings;
import org.eclipse.xtext.xbase.lib.Exceptions;
@SuppressWarnings("all")
class NUMValueConverter extends AbstractLexerBasedConverter<IntegerWithRadix> {
@Override
protected String toEscapedString(final IntegerWithRadix value) {
return value.toString();
}
@Override
protected void assertValidValue(final IntegerWithRadix value) {
super.assertValidValue(value);
}
@Override
public IntegerWithRadix toValue(final String string, final INode node) throws ValueConverterException {
boolean _isEmpty = Strings.isEmpty(string);
if (_isEmpty) {
throw new ValueConverterException(
"Couldn\'t convert empty string to an integer value.", node, null);
}
try {
return new IntegerWithRadix(string);
} catch (final Throwable _t) {
if (_t instanceof NumberFormatException) {
final NumberFormatException e = (NumberFormatException)_t;
StringConcatenation _builder = new StringConcatenation();
_builder.append("Couldn\'t convert \'");
_builder.append(string);
_builder.append("\' to an integer value.");
throw new ValueConverterException(_builder.toString(), node, e);
} else {
throw Exceptions.sneakyThrow(_t);
}
}
}
}

View File

@ -0,0 +1,37 @@
package com.minres.rdl.converter;
import com.google.inject.Inject;
import com.minres.rdl.IntegerWithRadix;
import com.minres.rdl.converter.IDValueConverter;
import com.minres.rdl.converter.NUMValueConverter;
import com.minres.rdl.converter.STRValueConverter;
import org.eclipse.xtext.common.services.DefaultTerminalConverters;
import org.eclipse.xtext.conversion.IValueConverter;
import org.eclipse.xtext.conversion.ValueConverter;
@SuppressWarnings("all")
public class RdlTerminalConverters extends DefaultTerminalConverters {
@Inject
private NUMValueConverter numValueConverter;
@Inject
private STRValueConverter stringConverter;
@Inject
private IDValueConverter idConverter;
@ValueConverter(rule = "NUM")
public IValueConverter<IntegerWithRadix> getNumValueConverter() {
return this.numValueConverter;
}
@ValueConverter(rule = "STR")
public IValueConverter<String> getStrValueConverter() {
return this.stringConverter;
}
@ValueConverter(rule = "ID")
public IValueConverter<String> getIdValueConverter() {
return this.idConverter;
}
}

View File

@ -0,0 +1,19 @@
package com.minres.rdl.converter;
import org.eclipse.xtext.conversion.impl.AbstractLexerBasedConverter;
import org.eclipse.xtext.nodemodel.INode;
@SuppressWarnings("all")
public class STRValueConverter extends AbstractLexerBasedConverter<String> {
@Override
protected String toEscapedString(final String value) {
return (("\"" + value) + "\"");
}
@Override
public String toValue(final String string, final INode node) {
int _length = string.length();
int _minus = (_length - 1);
return string.substring(1, _minus);
}
}

View File

@ -0,0 +1,32 @@
/**
* generated by Xtext
*/
package com.minres.rdl.formatting;
import com.google.inject.Inject;
import com.minres.rdl.services.RDLGrammarAccess;
import org.eclipse.xtext.formatting.impl.AbstractDeclarativeFormatter;
import org.eclipse.xtext.formatting.impl.FormattingConfig;
import org.eclipse.xtext.xbase.lib.Extension;
/**
* This class contains custom formatting description.
*
* see : http://www.eclipse.org/Xtext/documentation.html#formatting
* on how and when to use it
*
* Also see {@link org.eclipse.xtext.xtext.XtextFormattingTokenSerializer} as an example
*/
@SuppressWarnings("all")
public class RDLFormatter extends AbstractDeclarativeFormatter {
@Inject
@Extension
private RDLGrammarAccess _rDLGrammarAccess;
@Override
protected void configureFormatting(final FormattingConfig c) {
c.setLinewrap(0, 1, 2).before(this._rDLGrammarAccess.getSL_COMMENTRule());
c.setLinewrap(0, 1, 2).before(this._rDLGrammarAccess.getML_COMMENTRule());
c.setLinewrap(0, 1, 1).after(this._rDLGrammarAccess.getML_COMMENTRule());
}
}

View File

@ -0,0 +1,21 @@
/**
* generated by Xtext 2.12.0
*/
package com.minres.rdl.generator;
import org.eclipse.emf.ecore.resource.Resource;
import org.eclipse.xtext.generator.AbstractGenerator;
import org.eclipse.xtext.generator.IFileSystemAccess2;
import org.eclipse.xtext.generator.IGeneratorContext;
/**
* Generates code from your model files on save.
*
* See https://www.eclipse.org/Xtext/documentation/303_runtime_concepts.html#code-generation
*/
@SuppressWarnings("all")
public class RDLGenerator extends AbstractGenerator {
@Override
public void doGenerate(final Resource resource, final IFileSystemAccess2 fsa, final IGeneratorContext context) {
}
}

View File

@ -0,0 +1,67 @@
package com.minres.rdl.messages;
import com.google.inject.Inject;
import org.antlr.runtime.RecognitionException;
import org.antlr.runtime.Token;
import org.eclipse.xtend2.lib.StringConcatenation;
import org.eclipse.xtext.GrammarUtil;
import org.eclipse.xtext.IGrammarAccess;
import org.eclipse.xtext.nodemodel.SyntaxErrorMessage;
import org.eclipse.xtext.parser.antlr.ISyntaxErrorMessageProvider;
import org.eclipse.xtext.parser.antlr.SyntaxErrorMessageProvider;
import org.eclipse.xtext.xbase.lib.InputOutput;
@SuppressWarnings("all")
public class RDLSyntaxErrorMessageProvider extends SyntaxErrorMessageProvider {
public final static String USED_RESERVED_KEYWORD = "USED_RESERVED_KEYWORD";
@Inject
private IGrammarAccess grammarAccess;
/**
* Customized error message for reserved keywords
*/
@Override
public SyntaxErrorMessage getSyntaxErrorMessage(final ISyntaxErrorMessageProvider.IParserErrorContext context) {
SyntaxErrorMessage _xblockexpression = null;
{
InputOutput.println();
RecognitionException _recognitionException = null;
if (context!=null) {
_recognitionException=context.getRecognitionException();
}
if (_recognitionException!=null) {
_recognitionException.getClass();
}
RecognitionException _recognitionException_1 = null;
if (context!=null) {
_recognitionException_1=context.getRecognitionException();
}
Token _ken = null;
if (_recognitionException_1!=null) {
_ken=_recognitionException_1.token;
}
String _text = null;
if (_ken!=null) {
_text=_ken.getText();
}
final String unexpectedText = _text;
boolean _contains = GrammarUtil.getAllKeywords(this.grammarAccess.getGrammar()).contains(unexpectedText);
if (_contains) {
InputOutput.<String>println(context.getDefaultMessage());
StringConcatenation _builder = new StringConcatenation();
_builder.append("\"");
_builder.append(unexpectedText);
_builder.append("\" is a reserved keyword which is not allowed as Identifier.");
_builder.newLineIfNotEmpty();
_builder.append("Please choose another word or alternatively confuse your co-workers by escaping it with the caret (^) character like this: \"^");
_builder.append(unexpectedText);
_builder.append("\".");
return new SyntaxErrorMessage(_builder.toString(),
RDLSyntaxErrorMessageProvider.USED_RESERVED_KEYWORD);
}
_xblockexpression = super.getSyntaxErrorMessage(context);
}
return _xblockexpression;
}
}

View File

@ -0,0 +1,151 @@
/**
* generated by Xtext 2.12.0
*/
package com.minres.rdl.scoping;
import com.google.common.collect.Iterables;
import com.minres.rdl.rdl.ComponentDefinition;
import com.minres.rdl.rdl.ComponentInstance;
import com.minres.rdl.rdl.Entity;
import com.minres.rdl.rdl.EnumDefinition;
import com.minres.rdl.rdl.Include;
import com.minres.rdl.rdl.NamedInstantiation;
import com.minres.rdl.rdl.Root;
import com.minres.rdl.scoping.AbstractRDLScopeProvider;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.List;
import org.eclipse.emf.common.util.EList;
import org.eclipse.emf.ecore.EObject;
import org.eclipse.emf.ecore.resource.Resource;
import org.eclipse.xtext.EcoreUtil2;
import org.eclipse.xtext.scoping.IScope;
import org.eclipse.xtext.scoping.Scopes;
import org.eclipse.xtext.xbase.lib.IterableExtensions;
/**
* This class contains custom scoping description.
*
* see : http://www.eclipse.org/Xtext/documentation.html#scoping
* on how and when to use it
* See https://www.eclipse.org/Xtext/documentation/303_runtime_concepts.html#scoping
* on how and when to use it.
*/
@SuppressWarnings("all")
public class RDLScopeProvider extends AbstractRDLScopeProvider {
protected IScope _getScopeWithComponentDefinition(final ComponentDefinition componentDef) {
return Scopes.scopeFor(componentDef.getComponentDefinitions(), this.getScopeWithComponentDefinition(componentDef.eContainer()));
}
protected IScope _getScopeWithComponentDefinition(final Root root) {
EList<ComponentDefinition> compDefs = root.getComponentDefinitions();
EList<Include> _includes = root.getIncludes();
for (final Include incl : _includes) {
{
Resource resource = EcoreUtil2.getResource(root.eResource(), incl.getImportURI());
EObject _head = IterableExtensions.<EObject>head(resource.getContents());
final Root r = ((Root) _head);
EList<ComponentDefinition> _componentDefinitions = r.getComponentDefinitions();
Iterables.<ComponentDefinition>addAll(compDefs, _componentDefinitions);
}
}
return Scopes.scopeFor(compDefs);
}
protected IScope _getScopeWithInstancesAndEnums(final ComponentDefinition componentDef) {
ArrayList<ComponentInstance> res = new ArrayList<ComponentInstance>();
EList<NamedInstantiation> _namedInstantiations = componentDef.getNamedInstantiations();
for (final NamedInstantiation inst : _namedInstantiations) {
int _size = inst.getComponentInstances().size();
boolean _greaterThan = (_size > 0);
if (_greaterThan) {
res.addAll(inst.getComponentInstances());
}
}
EList<ComponentDefinition> _componentDefinitions = componentDef.getComponentDefinitions();
for (final ComponentDefinition definition : _componentDefinitions) {
if (((definition.getImmediateInstantiation() != null) && (definition.getImmediateInstantiation().getComponentInstances().size() > 0))) {
res.addAll(definition.getImmediateInstantiation().getComponentInstances());
}
}
EList<EnumDefinition> _enumDefinitions = componentDef.getEnumDefinitions();
Iterable<Entity> _plus = Iterables.<Entity>concat(res, _enumDefinitions);
return Scopes.scopeFor(_plus, this.getScopeWithInstancesAndEnums(componentDef.eContainer()));
}
protected IScope _getScopeWithInstancesAndEnums(final Root root) {
ArrayList<ComponentInstance> res = new ArrayList<ComponentInstance>();
EList<NamedInstantiation> _namedInstantiations = root.getNamedInstantiations();
for (final NamedInstantiation instantiation : _namedInstantiations) {
int _size = instantiation.getComponentInstances().size();
boolean _greaterThan = (_size > 0);
if (_greaterThan) {
res.addAll(instantiation.getComponentInstances());
}
}
EList<ComponentDefinition> _componentDefinitions = root.getComponentDefinitions();
for (final ComponentDefinition definition : _componentDefinitions) {
if (((definition.getImmediateInstantiation() != null) && (definition.getImmediateInstantiation().getComponentInstances().size() > 0))) {
res.addAll(definition.getImmediateInstantiation().getComponentInstances());
}
}
List<EnumDefinition> enums = EcoreUtil2.<EnumDefinition>getAllContentsOfType(root, EnumDefinition.class);
EList<Include> _includes = root.getIncludes();
for (final Include incl : _includes) {
{
final Resource resource = EcoreUtil2.getResource(root.eResource(), incl.getImportURI());
EObject _head = IterableExtensions.<EObject>head(resource.getContents());
List<EnumDefinition> _allContentsOfType = EcoreUtil2.<EnumDefinition>getAllContentsOfType(((Root) _head), EnumDefinition.class);
Iterables.<EnumDefinition>addAll(enums, _allContentsOfType);
}
}
Iterable<Entity> _plus = Iterables.<Entity>concat(res, enums);
return Scopes.scopeFor(_plus);
}
private Root root(final EObject definition) {
EObject container = definition.eContainer();
while ((!(container instanceof Root))) {
container = container.eContainer();
}
return ((Root) container);
}
private ComponentDefinition componentDefinition(final EObject obj) {
EObject container = obj.eContainer();
while ((!(container instanceof Root))) {
{
if ((container instanceof NamedInstantiation)) {
return ((NamedInstantiation)container).getComponent();
}
if ((container instanceof ComponentDefinition)) {
return ((ComponentDefinition)container);
}
container = container.eContainer();
}
}
return null;
}
public IScope getScopeWithComponentDefinition(final EObject componentDef) {
if (componentDef instanceof ComponentDefinition) {
return _getScopeWithComponentDefinition((ComponentDefinition)componentDef);
} else if (componentDef instanceof Root) {
return _getScopeWithComponentDefinition((Root)componentDef);
} else {
throw new IllegalArgumentException("Unhandled parameter types: " +
Arrays.<Object>asList(componentDef).toString());
}
}
public IScope getScopeWithInstancesAndEnums(final EObject componentDef) {
if (componentDef instanceof ComponentDefinition) {
return _getScopeWithInstancesAndEnums((ComponentDefinition)componentDef);
} else if (componentDef instanceof Root) {
return _getScopeWithInstancesAndEnums((Root)componentDef);
} else {
throw new IllegalArgumentException("Unhandled parameter types: " +
Arrays.<Object>asList(componentDef).toString());
}
}
}

View File

@ -0,0 +1,15 @@
/**
* generated by Xtext 2.12.0
*/
package com.minres.rdl.validation;
import com.minres.rdl.validation.AbstractRDLValidator;
/**
* This class contains custom validation rules.
*
* See https://www.eclipse.org/Xtext/documentation/303_runtime_concepts.html#validation
*/
@SuppressWarnings("all")
public class RDLValidator extends AbstractRDLValidator {
}