diff --git a/org.eclipse.xtext.tests/src-gen/org/eclipse/xtext/parser/antlr/AbstractBug406914TestLanguageRuntimeModule.java b/org.eclipse.xtext.tests/src-gen/org/eclipse/xtext/parser/antlr/AbstractBug406914TestLanguageRuntimeModule.java new file mode 100644 index 000000000..5552a62b3 --- /dev/null +++ b/org.eclipse.xtext.tests/src-gen/org/eclipse/xtext/parser/antlr/AbstractBug406914TestLanguageRuntimeModule.java @@ -0,0 +1,111 @@ +/* + * generated by Xtext + */ +package org.eclipse.xtext.parser.antlr; + +import com.google.inject.Binder; +import com.google.inject.Provider; +import com.google.inject.name.Names; +import java.util.Properties; +import org.eclipse.xtext.Constants; +import org.eclipse.xtext.IGrammarAccess; +import org.eclipse.xtext.parser.IParser; +import org.eclipse.xtext.parser.ITokenToStringConverter; +import org.eclipse.xtext.parser.antlr.parser.antlr.Bug406914TestLanguageAntlrTokenFileProvider; +import org.eclipse.xtext.parser.antlr.parser.antlr.Bug406914TestLanguageParser; +import org.eclipse.xtext.parser.antlr.parser.antlr.internal.InternalBug406914TestLanguageLexer; +import org.eclipse.xtext.parser.antlr.serializer.Bug406914TestLanguageSemanticSequencer; +import org.eclipse.xtext.parser.antlr.serializer.Bug406914TestLanguageSyntacticSequencer; +import org.eclipse.xtext.parser.antlr.services.Bug406914TestLanguageGrammarAccess; +import org.eclipse.xtext.serializer.ISerializer; +import org.eclipse.xtext.serializer.impl.Serializer; +import org.eclipse.xtext.serializer.sequencer.ISemanticSequencer; +import org.eclipse.xtext.serializer.sequencer.ISyntacticSequencer; +import org.eclipse.xtext.service.DefaultRuntimeModule; + +/** + * Manual modifications go to {@link Bug406914TestLanguageRuntimeModule}. + */ +@SuppressWarnings("all") +public abstract class AbstractBug406914TestLanguageRuntimeModule extends DefaultRuntimeModule { + + protected Properties properties = null; + + @Override + public void configure(Binder binder) { + properties = tryBindProperties(binder, "org/eclipse/xtext/parser/antlr/Bug406914TestLanguage.properties"); + super.configure(binder); + } + + public void configureLanguageName(Binder binder) { + binder.bind(String.class).annotatedWith(Names.named(Constants.LANGUAGE_NAME)).toInstance("org.eclipse.xtext.parser.antlr.Bug406914TestLanguage"); + } + + public void configureFileExtensions(Binder binder) { + if (properties == null || properties.getProperty(Constants.FILE_EXTENSIONS) == null) + binder.bind(String.class).annotatedWith(Names.named(Constants.FILE_EXTENSIONS)).toInstance("bug406914testlanguage"); + } + + // contributed by org.eclipse.xtext.xtext.generator.parser.antlr.XtextAntlrGeneratorFragment2 + public Class bindIParser() { + return Bug406914TestLanguageParser.class; + } + + // contributed by org.eclipse.xtext.xtext.generator.parser.antlr.XtextAntlrGeneratorFragment2 + public Class bindITokenToStringConverter() { + return AntlrTokenToStringConverter.class; + } + + // contributed by org.eclipse.xtext.xtext.generator.parser.antlr.XtextAntlrGeneratorFragment2 + public Class bindIAntlrTokenFileProvider() { + return Bug406914TestLanguageAntlrTokenFileProvider.class; + } + + // contributed by org.eclipse.xtext.xtext.generator.parser.antlr.XtextAntlrGeneratorFragment2 + public Class bindLexer() { + return InternalBug406914TestLanguageLexer.class; + } + + // contributed by org.eclipse.xtext.xtext.generator.parser.antlr.XtextAntlrGeneratorFragment2 + public Class bindITokenDefProvider() { + return AntlrTokenDefProvider.class; + } + + // contributed by org.eclipse.xtext.xtext.generator.parser.antlr.XtextAntlrGeneratorFragment2 + public Provider provideInternalBug406914TestLanguageLexer() { + return LexerProvider.create(InternalBug406914TestLanguageLexer.class); + } + + // contributed by org.eclipse.xtext.xtext.generator.parser.antlr.XtextAntlrGeneratorFragment2 + public void configureRuntimeLexer(Binder binder) { + binder.bind(Lexer.class) + .annotatedWith(Names.named(LexerBindings.RUNTIME)) + .to(InternalBug406914TestLanguageLexer.class); + } + + // contributed by org.eclipse.xtext.xtext.generator.grammarAccess.GrammarAccessFragment2 + public ClassLoader bindClassLoaderToInstance() { + return getClass().getClassLoader(); + } + + // contributed by org.eclipse.xtext.xtext.generator.grammarAccess.GrammarAccessFragment2 + public Class bindIGrammarAccess() { + return Bug406914TestLanguageGrammarAccess.class; + } + + // contributed by org.eclipse.xtext.xtext.generator.serializer.SerializerFragment2 + public Class bindISemanticSequencer() { + return Bug406914TestLanguageSemanticSequencer.class; + } + + // contributed by org.eclipse.xtext.xtext.generator.serializer.SerializerFragment2 + public Class bindISyntacticSequencer() { + return Bug406914TestLanguageSyntacticSequencer.class; + } + + // contributed by org.eclipse.xtext.xtext.generator.serializer.SerializerFragment2 + public Class bindISerializer() { + return Serializer.class; + } + +} diff --git a/org.eclipse.xtext.tests/src-gen/org/eclipse/xtext/parser/antlr/Bug301935TestLanguage.ecore b/org.eclipse.xtext.tests/src-gen/org/eclipse/xtext/parser/antlr/Bug301935TestLanguage.ecore index 7c8bf0ac1..0a3df5edf 100644 --- a/org.eclipse.xtext.tests/src-gen/org/eclipse/xtext/parser/antlr/Bug301935TestLanguage.ecore +++ b/org.eclipse.xtext.tests/src-gen/org/eclipse/xtext/parser/antlr/Bug301935TestLanguage.ecore @@ -3,8 +3,8 @@ xmlns:ecore="http://www.eclipse.org/emf/2002/Ecore" name="bug301935Test" nsURI="http://eclipse.org/xtext/Bug301935TestLanguage" nsPrefix="bug301935Test"> - - - + + + diff --git a/org.eclipse.xtext.tests/src-gen/org/eclipse/xtext/parser/antlr/Bug301935TestLanguage.genmodel b/org.eclipse.xtext.tests/src-gen/org/eclipse/xtext/parser/antlr/Bug301935TestLanguage.genmodel index 16f8c8127..d9b265cd6 100644 --- a/org.eclipse.xtext.tests/src-gen/org/eclipse/xtext/parser/antlr/Bug301935TestLanguage.genmodel +++ b/org.eclipse.xtext.tests/src-gen/org/eclipse/xtext/parser/antlr/Bug301935TestLanguage.genmodel @@ -3,7 +3,7 @@ xmlns:genmodel="http://www.eclipse.org/emf/2002/GenModel" copyrightText="generated by Xtext" modelDirectory="/org.eclipse.xtext.tests/src-gen" modelPluginID="org.eclipse.xtext.tests" forceOverwrite="true" modelName="Bug301935TestLanguage" updateClasspath="false" rootExtendsClass="org.eclipse.emf.ecore.impl.MinimalEObjectImpl$Container" - complianceLevel="6.0" copyrightFields="false" runtimeVersion="2.9" usedGenPackages="platform:/resource/org.eclipse.emf.ecore/model/Ecore.genmodel#//ecore"> + complianceLevel="6.0" copyrightFields="false" runtimeVersion="2.9"> diff --git a/org.eclipse.xtext.tests/src-gen/org/eclipse/xtext/parser/antlr/Bug406914TestLanguage.ecore b/org.eclipse.xtext.tests/src-gen/org/eclipse/xtext/parser/antlr/Bug406914TestLanguage.ecore new file mode 100644 index 000000000..e10d7bc00 --- /dev/null +++ b/org.eclipse.xtext.tests/src-gen/org/eclipse/xtext/parser/antlr/Bug406914TestLanguage.ecore @@ -0,0 +1,8 @@ + + + + + + diff --git a/org.eclipse.xtext.tests/src-gen/org/eclipse/xtext/parser/antlr/Bug406914TestLanguage.genmodel b/org.eclipse.xtext.tests/src-gen/org/eclipse/xtext/parser/antlr/Bug406914TestLanguage.genmodel new file mode 100644 index 000000000..d29f6c765 --- /dev/null +++ b/org.eclipse.xtext.tests/src-gen/org/eclipse/xtext/parser/antlr/Bug406914TestLanguage.genmodel @@ -0,0 +1,13 @@ + + + + + + + + diff --git a/org.eclipse.xtext.tests/src-gen/org/eclipse/xtext/parser/antlr/Bug406914TestLanguage.xtextbin b/org.eclipse.xtext.tests/src-gen/org/eclipse/xtext/parser/antlr/Bug406914TestLanguage.xtextbin new file mode 100644 index 000000000..06d29d6c6 Binary files /dev/null and b/org.eclipse.xtext.tests/src-gen/org/eclipse/xtext/parser/antlr/Bug406914TestLanguage.xtextbin differ diff --git a/org.eclipse.xtext.tests/src-gen/org/eclipse/xtext/parser/antlr/Bug406914TestLanguageStandaloneSetupGenerated.java b/org.eclipse.xtext.tests/src-gen/org/eclipse/xtext/parser/antlr/Bug406914TestLanguageStandaloneSetupGenerated.java new file mode 100644 index 000000000..c2057ba2c --- /dev/null +++ b/org.eclipse.xtext.tests/src-gen/org/eclipse/xtext/parser/antlr/Bug406914TestLanguageStandaloneSetupGenerated.java @@ -0,0 +1,56 @@ +/* + * generated by Xtext + */ +package org.eclipse.xtext.parser.antlr; + +import com.google.inject.Guice; +import com.google.inject.Injector; +import org.eclipse.emf.ecore.EPackage; +import org.eclipse.emf.ecore.resource.Resource; +import org.eclipse.emf.ecore.xmi.impl.EcoreResourceFactoryImpl; +import org.eclipse.emf.ecore.xmi.impl.XMIResourceFactoryImpl; +import org.eclipse.xtext.ISetup; +import org.eclipse.xtext.XtextPackage; +import org.eclipse.xtext.parser.antlr.bug406914Test.Bug406914TestPackage; +import org.eclipse.xtext.resource.IResourceFactory; +import org.eclipse.xtext.resource.IResourceServiceProvider; +import org.eclipse.xtext.resource.impl.BinaryGrammarResourceFactoryImpl; + +@SuppressWarnings("all") +public class Bug406914TestLanguageStandaloneSetupGenerated implements ISetup { + + @Override + public Injector createInjectorAndDoEMFRegistration() { + // register default ePackages + if (!Resource.Factory.Registry.INSTANCE.getExtensionToFactoryMap().containsKey("ecore")) + Resource.Factory.Registry.INSTANCE.getExtensionToFactoryMap().put( + "ecore", new EcoreResourceFactoryImpl()); + if (!Resource.Factory.Registry.INSTANCE.getExtensionToFactoryMap().containsKey("xmi")) + Resource.Factory.Registry.INSTANCE.getExtensionToFactoryMap().put( + "xmi", new XMIResourceFactoryImpl()); + if (!Resource.Factory.Registry.INSTANCE.getExtensionToFactoryMap().containsKey("xtextbin")) + Resource.Factory.Registry.INSTANCE.getExtensionToFactoryMap().put( + "xtextbin", new BinaryGrammarResourceFactoryImpl()); + if (!EPackage.Registry.INSTANCE.containsKey(XtextPackage.eNS_URI)) + EPackage.Registry.INSTANCE.put(XtextPackage.eNS_URI, XtextPackage.eINSTANCE); + + Injector injector = createInjector(); + register(injector); + return injector; + } + + public Injector createInjector() { + return Guice.createInjector(new Bug406914TestLanguageRuntimeModule()); + } + + public void register(Injector injector) { + IResourceFactory resourceFactory = injector.getInstance(IResourceFactory.class); + IResourceServiceProvider serviceProvider = injector.getInstance(IResourceServiceProvider.class); + + Resource.Factory.Registry.INSTANCE.getExtensionToFactoryMap().put("bug406914testlanguage", resourceFactory); + IResourceServiceProvider.Registry.INSTANCE.getExtensionToFactoryMap().put("bug406914testlanguage", serviceProvider); + if (!EPackage.Registry.INSTANCE.containsKey("http://eclipse.org/xtext/Bug406914TestLanguage")) { + EPackage.Registry.INSTANCE.put("http://eclipse.org/xtext/Bug406914TestLanguage", Bug406914TestPackage.eINSTANCE); + } + } +} diff --git a/org.eclipse.xtext.tests/src-gen/org/eclipse/xtext/parser/antlr/bug301935Test/impl/Bug301935TestPackageImpl.java b/org.eclipse.xtext.tests/src-gen/org/eclipse/xtext/parser/antlr/bug301935Test/impl/Bug301935TestPackageImpl.java index fa8149ffe..b4f962069 100644 --- a/org.eclipse.xtext.tests/src-gen/org/eclipse/xtext/parser/antlr/bug301935Test/impl/Bug301935TestPackageImpl.java +++ b/org.eclipse.xtext.tests/src-gen/org/eclipse/xtext/parser/antlr/bug301935Test/impl/Bug301935TestPackageImpl.java @@ -6,7 +6,6 @@ package org.eclipse.xtext.parser.antlr.bug301935Test.impl; import org.eclipse.emf.ecore.EAttribute; import org.eclipse.emf.ecore.EClass; import org.eclipse.emf.ecore.EPackage; -import org.eclipse.emf.ecore.EcorePackage; import org.eclipse.emf.ecore.impl.EPackageImpl; @@ -77,9 +76,6 @@ public class Bug301935TestPackageImpl extends EPackageImpl implements Bug301935T isInited = true; - // Initialize simple dependencies - EcorePackage.eINSTANCE.eClass(); - // Create package meta-data objects theBug301935TestPackage.createPackageContents(); @@ -195,9 +191,6 @@ public class Bug301935TestPackageImpl extends EPackageImpl implements Bug301935T setNsPrefix(eNS_PREFIX); setNsURI(eNS_URI); - // Obtain other dependent packages - EcorePackage theEcorePackage = (EcorePackage)EPackage.Registry.INSTANCE.getEPackage(EcorePackage.eNS_URI); - // Create type parameters // Set bounds for type parameters @@ -206,9 +199,9 @@ public class Bug301935TestPackageImpl extends EPackageImpl implements Bug301935T // Initialize classes and features; add operations and parameters initEClass(modelEClass, Model.class, "Model", !IS_ABSTRACT, !IS_INTERFACE, IS_GENERATED_INSTANCE_CLASS); - initEAttribute(getModel_Name(), theEcorePackage.getEString(), "name", null, 0, 1, Model.class, !IS_TRANSIENT, !IS_VOLATILE, IS_CHANGEABLE, !IS_UNSETTABLE, !IS_ID, IS_UNIQUE, !IS_DERIVED, IS_ORDERED); - initEAttribute(getModel_Value(), theEcorePackage.getEString(), "value", null, 0, 1, Model.class, !IS_TRANSIENT, !IS_VOLATILE, IS_CHANGEABLE, !IS_UNSETTABLE, !IS_ID, IS_UNIQUE, !IS_DERIVED, IS_ORDERED); - initEAttribute(getModel_Value2(), theEcorePackage.getEString(), "value2", null, 0, 1, Model.class, !IS_TRANSIENT, !IS_VOLATILE, IS_CHANGEABLE, !IS_UNSETTABLE, !IS_ID, IS_UNIQUE, !IS_DERIVED, IS_ORDERED); + initEAttribute(getModel_Name(), ecorePackage.getEString(), "name", null, 0, 1, Model.class, !IS_TRANSIENT, !IS_VOLATILE, IS_CHANGEABLE, !IS_UNSETTABLE, !IS_ID, IS_UNIQUE, !IS_DERIVED, IS_ORDERED); + initEAttribute(getModel_Value(), ecorePackage.getEString(), "value", null, 0, 1, Model.class, !IS_TRANSIENT, !IS_VOLATILE, IS_CHANGEABLE, !IS_UNSETTABLE, !IS_ID, IS_UNIQUE, !IS_DERIVED, IS_ORDERED); + initEAttribute(getModel_Value2(), ecorePackage.getEString(), "value2", null, 0, 1, Model.class, !IS_TRANSIENT, !IS_VOLATILE, IS_CHANGEABLE, !IS_UNSETTABLE, !IS_ID, IS_UNIQUE, !IS_DERIVED, IS_ORDERED); // Create resource createResource(eNS_URI); diff --git a/org.eclipse.xtext.tests/src-gen/org/eclipse/xtext/parser/antlr/bug406914Test/Bug406914TestFactory.java b/org.eclipse.xtext.tests/src-gen/org/eclipse/xtext/parser/antlr/bug406914Test/Bug406914TestFactory.java new file mode 100644 index 000000000..e402f266d --- /dev/null +++ b/org.eclipse.xtext.tests/src-gen/org/eclipse/xtext/parser/antlr/bug406914Test/Bug406914TestFactory.java @@ -0,0 +1,44 @@ +/** + * generated by Xtext + */ +package org.eclipse.xtext.parser.antlr.bug406914Test; + +import org.eclipse.emf.ecore.EFactory; + +/** + * + * The Factory for the model. + * It provides a create method for each non-abstract class of the model. + * + * @see org.eclipse.xtext.parser.antlr.bug406914Test.Bug406914TestPackage + * @generated + */ +public interface Bug406914TestFactory extends EFactory +{ + /** + * The singleton instance of the factory. + * + * + * @generated + */ + Bug406914TestFactory eINSTANCE = org.eclipse.xtext.parser.antlr.bug406914Test.impl.Bug406914TestFactoryImpl.init(); + + /** + * Returns a new object of class 'Model'. + * + * + * @return a new object of class 'Model'. + * @generated + */ + Model createModel(); + + /** + * Returns the package supported by this factory. + * + * + * @return the package supported by this factory. + * @generated + */ + Bug406914TestPackage getBug406914TestPackage(); + +} //Bug406914TestFactory diff --git a/org.eclipse.xtext.tests/src-gen/org/eclipse/xtext/parser/antlr/bug406914Test/Bug406914TestPackage.java b/org.eclipse.xtext.tests/src-gen/org/eclipse/xtext/parser/antlr/bug406914Test/Bug406914TestPackage.java new file mode 100644 index 000000000..15099d179 --- /dev/null +++ b/org.eclipse.xtext.tests/src-gen/org/eclipse/xtext/parser/antlr/bug406914Test/Bug406914TestPackage.java @@ -0,0 +1,152 @@ +/** + * generated by Xtext + */ +package org.eclipse.xtext.parser.antlr.bug406914Test; + +import org.eclipse.emf.ecore.EAttribute; +import org.eclipse.emf.ecore.EClass; +import org.eclipse.emf.ecore.EPackage; + +/** + * + * The Package for the model. + * It contains accessors for the meta objects to represent + * + * + * @see org.eclipse.xtext.parser.antlr.bug406914Test.Bug406914TestFactory + * @model kind="package" + * @generated + */ +public interface Bug406914TestPackage extends EPackage +{ + /** + * The package name. + * + * + * @generated + */ + String eNAME = "bug406914Test"; + + /** + * The package namespace URI. + * + * + * @generated + */ + String eNS_URI = "http://eclipse.org/xtext/Bug406914TestLanguage"; + + /** + * The package namespace name. + * + * + * @generated + */ + String eNS_PREFIX = "bug406914Test"; + + /** + * The singleton instance of the package. + * + * + * @generated + */ + Bug406914TestPackage eINSTANCE = org.eclipse.xtext.parser.antlr.bug406914Test.impl.Bug406914TestPackageImpl.init(); + + /** + * The meta object id for the '{@link org.eclipse.xtext.parser.antlr.bug406914Test.impl.ModelImpl Model}' class. + * + * + * @see org.eclipse.xtext.parser.antlr.bug406914Test.impl.ModelImpl + * @see org.eclipse.xtext.parser.antlr.bug406914Test.impl.Bug406914TestPackageImpl#getModel() + * @generated + */ + int MODEL = 0; + + /** + * The feature id for the 'Name' attribute. + * + * + * @generated + * @ordered + */ + int MODEL__NAME = 0; + + /** + * The number of structural features of the 'Model' class. + * + * + * @generated + * @ordered + */ + int MODEL_FEATURE_COUNT = 1; + + + /** + * Returns the meta object for class '{@link org.eclipse.xtext.parser.antlr.bug406914Test.Model Model}'. + * + * + * @return the meta object for class 'Model'. + * @see org.eclipse.xtext.parser.antlr.bug406914Test.Model + * @generated + */ + EClass getModel(); + + /** + * Returns the meta object for the attribute '{@link org.eclipse.xtext.parser.antlr.bug406914Test.Model#getName Name}'. + * + * + * @return the meta object for the attribute 'Name'. + * @see org.eclipse.xtext.parser.antlr.bug406914Test.Model#getName() + * @see #getModel() + * @generated + */ + EAttribute getModel_Name(); + + /** + * Returns the factory that creates the instances of the model. + * + * + * @return the factory that creates the instances of the model. + * @generated + */ + Bug406914TestFactory getBug406914TestFactory(); + + /** + * + * Defines literals for the meta objects that represent + * + * + * @generated + */ + interface Literals + { + /** + * The meta object literal for the '{@link org.eclipse.xtext.parser.antlr.bug406914Test.impl.ModelImpl Model}' class. + * + * + * @see org.eclipse.xtext.parser.antlr.bug406914Test.impl.ModelImpl + * @see org.eclipse.xtext.parser.antlr.bug406914Test.impl.Bug406914TestPackageImpl#getModel() + * @generated + */ + EClass MODEL = eINSTANCE.getModel(); + + /** + * The meta object literal for the 'Name' attribute feature. + * + * + * @generated + */ + EAttribute MODEL__NAME = eINSTANCE.getModel_Name(); + + } + +} //Bug406914TestPackage diff --git a/org.eclipse.xtext.tests/src-gen/org/eclipse/xtext/parser/antlr/bug406914Test/Model.java b/org.eclipse.xtext.tests/src-gen/org/eclipse/xtext/parser/antlr/bug406914Test/Model.java new file mode 100644 index 000000000..dfc23025a --- /dev/null +++ b/org.eclipse.xtext.tests/src-gen/org/eclipse/xtext/parser/antlr/bug406914Test/Model.java @@ -0,0 +1,52 @@ +/** + * generated by Xtext + */ +package org.eclipse.xtext.parser.antlr.bug406914Test; + +import org.eclipse.emf.ecore.EObject; + +/** + * + * A representation of the model object 'Model'. + * + * + *

+ * The following features are supported: + *

+ * + * + * @see org.eclipse.xtext.parser.antlr.bug406914Test.Bug406914TestPackage#getModel() + * @model + * @generated + */ +public interface Model extends EObject +{ + /** + * Returns the value of the 'Name' attribute. + * + *

+ * If the meaning of the 'Name' attribute isn't clear, + * there really should be more of a description here... + *

+ * + * @return the value of the 'Name' attribute. + * @see #setName(String) + * @see org.eclipse.xtext.parser.antlr.bug406914Test.Bug406914TestPackage#getModel_Name() + * @model + * @generated + */ + String getName(); + + /** + * Sets the value of the '{@link org.eclipse.xtext.parser.antlr.bug406914Test.Model#getName Name}' attribute. + * + * + * @param value the new value of the 'Name' attribute. + * @see #getName() + * @generated + */ + void setName(String value); + +} // Model diff --git a/org.eclipse.xtext.tests/src-gen/org/eclipse/xtext/parser/antlr/bug406914Test/impl/Bug406914TestFactoryImpl.java b/org.eclipse.xtext.tests/src-gen/org/eclipse/xtext/parser/antlr/bug406914Test/impl/Bug406914TestFactoryImpl.java new file mode 100644 index 000000000..086543aec --- /dev/null +++ b/org.eclipse.xtext.tests/src-gen/org/eclipse/xtext/parser/antlr/bug406914Test/impl/Bug406914TestFactoryImpl.java @@ -0,0 +1,107 @@ +/** + * generated by Xtext + */ +package org.eclipse.xtext.parser.antlr.bug406914Test.impl; + +import org.eclipse.emf.ecore.EClass; +import org.eclipse.emf.ecore.EObject; +import org.eclipse.emf.ecore.EPackage; + +import org.eclipse.emf.ecore.impl.EFactoryImpl; + +import org.eclipse.emf.ecore.plugin.EcorePlugin; + +import org.eclipse.xtext.parser.antlr.bug406914Test.*; + +/** + * + * An implementation of the model Factory. + * + * @generated + */ +public class Bug406914TestFactoryImpl extends EFactoryImpl implements Bug406914TestFactory +{ + /** + * Creates the default factory implementation. + * + * + * @generated + */ + public static Bug406914TestFactory init() + { + try + { + Bug406914TestFactory theBug406914TestFactory = (Bug406914TestFactory)EPackage.Registry.INSTANCE.getEFactory(Bug406914TestPackage.eNS_URI); + if (theBug406914TestFactory != null) + { + return theBug406914TestFactory; + } + } + catch (Exception exception) + { + EcorePlugin.INSTANCE.log(exception); + } + return new Bug406914TestFactoryImpl(); + } + + /** + * Creates an instance of the factory. + * + * + * @generated + */ + public Bug406914TestFactoryImpl() + { + super(); + } + + /** + * + * + * @generated + */ + @Override + public EObject create(EClass eClass) + { + switch (eClass.getClassifierID()) + { + case Bug406914TestPackage.MODEL: return createModel(); + default: + throw new IllegalArgumentException("The class '" + eClass.getName() + "' is not a valid classifier"); + } + } + + /** + * + * + * @generated + */ + public Model createModel() + { + ModelImpl model = new ModelImpl(); + return model; + } + + /** + * + * + * @generated + */ + public Bug406914TestPackage getBug406914TestPackage() + { + return (Bug406914TestPackage)getEPackage(); + } + + /** + * + * + * @deprecated + * @generated + */ + @Deprecated + public static Bug406914TestPackage getPackage() + { + return Bug406914TestPackage.eINSTANCE; + } + +} //Bug406914TestFactoryImpl diff --git a/org.eclipse.xtext.tests/src-gen/org/eclipse/xtext/parser/antlr/bug406914Test/impl/Bug406914TestPackageImpl.java b/org.eclipse.xtext.tests/src-gen/org/eclipse/xtext/parser/antlr/bug406914Test/impl/Bug406914TestPackageImpl.java new file mode 100644 index 000000000..de87b4a4d --- /dev/null +++ b/org.eclipse.xtext.tests/src-gen/org/eclipse/xtext/parser/antlr/bug406914Test/impl/Bug406914TestPackageImpl.java @@ -0,0 +1,186 @@ +/** + * generated by Xtext + */ +package org.eclipse.xtext.parser.antlr.bug406914Test.impl; + +import org.eclipse.emf.ecore.EAttribute; +import org.eclipse.emf.ecore.EClass; +import org.eclipse.emf.ecore.EPackage; + +import org.eclipse.emf.ecore.impl.EPackageImpl; + +import org.eclipse.xtext.parser.antlr.bug406914Test.Bug406914TestFactory; +import org.eclipse.xtext.parser.antlr.bug406914Test.Bug406914TestPackage; +import org.eclipse.xtext.parser.antlr.bug406914Test.Model; + +/** + * + * An implementation of the model Package. + * + * @generated + */ +public class Bug406914TestPackageImpl extends EPackageImpl implements Bug406914TestPackage +{ + /** + * + * + * @generated + */ + private EClass modelEClass = null; + + /** + * Creates an instance of the model Package, registered with + * {@link org.eclipse.emf.ecore.EPackage.Registry EPackage.Registry} by the package + * package URI value. + *

Note: the correct way to create the package is via the static + * factory method {@link #init init()}, which also performs + * initialization of the package, or returns the registered package, + * if one already exists. + * + * + * @see org.eclipse.emf.ecore.EPackage.Registry + * @see org.eclipse.xtext.parser.antlr.bug406914Test.Bug406914TestPackage#eNS_URI + * @see #init() + * @generated + */ + private Bug406914TestPackageImpl() + { + super(eNS_URI, Bug406914TestFactory.eINSTANCE); + } + + /** + * + * + * @generated + */ + private static boolean isInited = false; + + /** + * Creates, registers, and initializes the Package for this model, and for any others upon which it depends. + * + *

This method is used to initialize {@link Bug406914TestPackage#eINSTANCE} when that field is accessed. + * Clients should not invoke it directly. Instead, they should simply access that field to obtain the package. + * + * + * @see #eNS_URI + * @see #createPackageContents() + * @see #initializePackageContents() + * @generated + */ + public static Bug406914TestPackage init() + { + if (isInited) return (Bug406914TestPackage)EPackage.Registry.INSTANCE.getEPackage(Bug406914TestPackage.eNS_URI); + + // Obtain or create and register package + Bug406914TestPackageImpl theBug406914TestPackage = (Bug406914TestPackageImpl)(EPackage.Registry.INSTANCE.get(eNS_URI) instanceof Bug406914TestPackageImpl ? EPackage.Registry.INSTANCE.get(eNS_URI) : new Bug406914TestPackageImpl()); + + isInited = true; + + // Create package meta-data objects + theBug406914TestPackage.createPackageContents(); + + // Initialize created meta-data + theBug406914TestPackage.initializePackageContents(); + + // Mark meta-data to indicate it can't be changed + theBug406914TestPackage.freeze(); + + + // Update the registry and return the package + EPackage.Registry.INSTANCE.put(Bug406914TestPackage.eNS_URI, theBug406914TestPackage); + return theBug406914TestPackage; + } + + /** + * + * + * @generated + */ + public EClass getModel() + { + return modelEClass; + } + + /** + * + * + * @generated + */ + public EAttribute getModel_Name() + { + return (EAttribute)modelEClass.getEStructuralFeatures().get(0); + } + + /** + * + * + * @generated + */ + public Bug406914TestFactory getBug406914TestFactory() + { + return (Bug406914TestFactory)getEFactoryInstance(); + } + + /** + * + * + * @generated + */ + private boolean isCreated = false; + + /** + * Creates the meta-model objects for the package. This method is + * guarded to have no affect on any invocation but its first. + * + * + * @generated + */ + public void createPackageContents() + { + if (isCreated) return; + isCreated = true; + + // Create classes and their features + modelEClass = createEClass(MODEL); + createEAttribute(modelEClass, MODEL__NAME); + } + + /** + * + * + * @generated + */ + private boolean isInitialized = false; + + /** + * Complete the initialization of the package and its meta-model. This + * method is guarded to have no affect on any invocation but its first. + * + * + * @generated + */ + public void initializePackageContents() + { + if (isInitialized) return; + isInitialized = true; + + // Initialize package + setName(eNAME); + setNsPrefix(eNS_PREFIX); + setNsURI(eNS_URI); + + // Create type parameters + + // Set bounds for type parameters + + // Add supertypes to classes + + // Initialize classes and features; add operations and parameters + initEClass(modelEClass, Model.class, "Model", !IS_ABSTRACT, !IS_INTERFACE, IS_GENERATED_INSTANCE_CLASS); + initEAttribute(getModel_Name(), ecorePackage.getEString(), "name", null, 0, 1, Model.class, !IS_TRANSIENT, !IS_VOLATILE, IS_CHANGEABLE, !IS_UNSETTABLE, !IS_ID, IS_UNIQUE, !IS_DERIVED, IS_ORDERED); + + // Create resource + createResource(eNS_URI); + } + +} //Bug406914TestPackageImpl diff --git a/org.eclipse.xtext.tests/src-gen/org/eclipse/xtext/parser/antlr/bug406914Test/impl/ModelImpl.java b/org.eclipse.xtext.tests/src-gen/org/eclipse/xtext/parser/antlr/bug406914Test/impl/ModelImpl.java new file mode 100644 index 000000000..f1136242a --- /dev/null +++ b/org.eclipse.xtext.tests/src-gen/org/eclipse/xtext/parser/antlr/bug406914Test/impl/ModelImpl.java @@ -0,0 +1,178 @@ +/** + * generated by Xtext + */ +package org.eclipse.xtext.parser.antlr.bug406914Test.impl; + +import org.eclipse.emf.common.notify.Notification; + +import org.eclipse.emf.ecore.EClass; + +import org.eclipse.emf.ecore.impl.ENotificationImpl; +import org.eclipse.emf.ecore.impl.MinimalEObjectImpl; + +import org.eclipse.xtext.parser.antlr.bug406914Test.Bug406914TestPackage; +import org.eclipse.xtext.parser.antlr.bug406914Test.Model; + +/** + * + * An implementation of the model object 'Model'. + * + *

+ * The following features are implemented: + *

+ * + * + * @generated + */ +public class ModelImpl extends MinimalEObjectImpl.Container implements Model +{ + /** + * The default value of the '{@link #getName() Name}' attribute. + * + * + * @see #getName() + * @generated + * @ordered + */ + protected static final String NAME_EDEFAULT = null; + + /** + * The cached value of the '{@link #getName() Name}' attribute. + * + * + * @see #getName() + * @generated + * @ordered + */ + protected String name = NAME_EDEFAULT; + + /** + * + * + * @generated + */ + protected ModelImpl() + { + super(); + } + + /** + * + * + * @generated + */ + @Override + protected EClass eStaticClass() + { + return Bug406914TestPackage.Literals.MODEL; + } + + /** + * + * + * @generated + */ + public String getName() + { + return name; + } + + /** + * + * + * @generated + */ + public void setName(String newName) + { + String oldName = name; + name = newName; + if (eNotificationRequired()) + eNotify(new ENotificationImpl(this, Notification.SET, Bug406914TestPackage.MODEL__NAME, oldName, name)); + } + + /** + * + * + * @generated + */ + @Override + public Object eGet(int featureID, boolean resolve, boolean coreType) + { + switch (featureID) + { + case Bug406914TestPackage.MODEL__NAME: + return getName(); + } + return super.eGet(featureID, resolve, coreType); + } + + /** + * + * + * @generated + */ + @Override + public void eSet(int featureID, Object newValue) + { + switch (featureID) + { + case Bug406914TestPackage.MODEL__NAME: + setName((String)newValue); + return; + } + super.eSet(featureID, newValue); + } + + /** + * + * + * @generated + */ + @Override + public void eUnset(int featureID) + { + switch (featureID) + { + case Bug406914TestPackage.MODEL__NAME: + setName(NAME_EDEFAULT); + return; + } + super.eUnset(featureID); + } + + /** + * + * + * @generated + */ + @Override + public boolean eIsSet(int featureID) + { + switch (featureID) + { + case Bug406914TestPackage.MODEL__NAME: + return NAME_EDEFAULT == null ? name != null : !NAME_EDEFAULT.equals(name); + } + return super.eIsSet(featureID); + } + + /** + * + * + * @generated + */ + @Override + public String toString() + { + if (eIsProxy()) return super.toString(); + + StringBuffer result = new StringBuffer(super.toString()); + result.append(" (name: "); + result.append(name); + result.append(')'); + return result.toString(); + } + +} //ModelImpl diff --git a/org.eclipse.xtext.tests/src-gen/org/eclipse/xtext/parser/antlr/bug406914Test/util/Bug406914TestAdapterFactory.java b/org.eclipse.xtext.tests/src-gen/org/eclipse/xtext/parser/antlr/bug406914Test/util/Bug406914TestAdapterFactory.java new file mode 100644 index 000000000..5b0016ad2 --- /dev/null +++ b/org.eclipse.xtext.tests/src-gen/org/eclipse/xtext/parser/antlr/bug406914Test/util/Bug406914TestAdapterFactory.java @@ -0,0 +1,133 @@ +/** + * generated by Xtext + */ +package org.eclipse.xtext.parser.antlr.bug406914Test.util; + +import org.eclipse.emf.common.notify.Adapter; +import org.eclipse.emf.common.notify.Notifier; + +import org.eclipse.emf.common.notify.impl.AdapterFactoryImpl; + +import org.eclipse.emf.ecore.EObject; + +import org.eclipse.xtext.parser.antlr.bug406914Test.*; + +/** + * + * The Adapter Factory for the model. + * It provides an adapter createXXX method for each class of the model. + * + * @see org.eclipse.xtext.parser.antlr.bug406914Test.Bug406914TestPackage + * @generated + */ +public class Bug406914TestAdapterFactory extends AdapterFactoryImpl +{ + /** + * The cached model package. + * + * + * @generated + */ + protected static Bug406914TestPackage modelPackage; + + /** + * Creates an instance of the adapter factory. + * + * + * @generated + */ + public Bug406914TestAdapterFactory() + { + if (modelPackage == null) + { + modelPackage = Bug406914TestPackage.eINSTANCE; + } + } + + /** + * Returns whether this factory is applicable for the type of the object. + * + * This implementation returns true if the object is either the model's package or is an instance object of the model. + * + * @return whether this factory is applicable for the type of the object. + * @generated + */ + @Override + public boolean isFactoryForType(Object object) + { + if (object == modelPackage) + { + return true; + } + if (object instanceof EObject) + { + return ((EObject)object).eClass().getEPackage() == modelPackage; + } + return false; + } + + /** + * The switch that delegates to the createXXX methods. + * + * + * @generated + */ + protected Bug406914TestSwitch modelSwitch = + new Bug406914TestSwitch() + { + @Override + public Adapter caseModel(Model object) + { + return createModelAdapter(); + } + @Override + public Adapter defaultCase(EObject object) + { + return createEObjectAdapter(); + } + }; + + /** + * Creates an adapter for the target. + * + * + * @param target the object to adapt. + * @return the adapter for the target. + * @generated + */ + @Override + public Adapter createAdapter(Notifier target) + { + return modelSwitch.doSwitch((EObject)target); + } + + + /** + * Creates a new adapter for an object of class '{@link org.eclipse.xtext.parser.antlr.bug406914Test.Model Model}'. + * + * This default implementation returns null so that we can easily ignore cases; + * it's useful to ignore a case when inheritance will catch all the cases anyway. + * + * @return the new adapter. + * @see org.eclipse.xtext.parser.antlr.bug406914Test.Model + * @generated + */ + public Adapter createModelAdapter() + { + return null; + } + + /** + * Creates a new adapter for the default case. + * + * This default implementation returns null. + * + * @return the new adapter. + * @generated + */ + public Adapter createEObjectAdapter() + { + return null; + } + +} //Bug406914TestAdapterFactory diff --git a/org.eclipse.xtext.tests/src-gen/org/eclipse/xtext/parser/antlr/bug406914Test/util/Bug406914TestSwitch.java b/org.eclipse.xtext.tests/src-gen/org/eclipse/xtext/parser/antlr/bug406914Test/util/Bug406914TestSwitch.java new file mode 100644 index 000000000..23c51e0de --- /dev/null +++ b/org.eclipse.xtext.tests/src-gen/org/eclipse/xtext/parser/antlr/bug406914Test/util/Bug406914TestSwitch.java @@ -0,0 +1,120 @@ +/** + * generated by Xtext + */ +package org.eclipse.xtext.parser.antlr.bug406914Test.util; + +import org.eclipse.emf.ecore.EObject; +import org.eclipse.emf.ecore.EPackage; + +import org.eclipse.emf.ecore.util.Switch; + +import org.eclipse.xtext.parser.antlr.bug406914Test.*; + +/** + * + * The Switch for the model's inheritance hierarchy. + * It supports the call {@link #doSwitch(EObject) doSwitch(object)} + * to invoke the caseXXX method for each class of the model, + * starting with the actual class of the object + * and proceeding up the inheritance hierarchy + * until a non-null result is returned, + * which is the result of the switch. + * + * @see org.eclipse.xtext.parser.antlr.bug406914Test.Bug406914TestPackage + * @generated + */ +public class Bug406914TestSwitch extends Switch +{ + /** + * The cached model package + * + * + * @generated + */ + protected static Bug406914TestPackage modelPackage; + + /** + * Creates an instance of the switch. + * + * + * @generated + */ + public Bug406914TestSwitch() + { + if (modelPackage == null) + { + modelPackage = Bug406914TestPackage.eINSTANCE; + } + } + + /** + * Checks whether this is a switch for the given package. + * + * + * @param ePackage the package in question. + * @return whether this is a switch for the given package. + * @generated + */ + @Override + protected boolean isSwitchFor(EPackage ePackage) + { + return ePackage == modelPackage; + } + + /** + * Calls caseXXX for each class of the model until one returns a non null result; it yields that result. + * + * + * @return the first non-null result returned by a caseXXX call. + * @generated + */ + @Override + protected T doSwitch(int classifierID, EObject theEObject) + { + switch (classifierID) + { + case Bug406914TestPackage.MODEL: + { + Model model = (Model)theEObject; + T result = caseModel(model); + if (result == null) result = defaultCase(theEObject); + return result; + } + default: return defaultCase(theEObject); + } + } + + /** + * Returns the result of interpreting the object as an instance of 'Model'. + * + * This implementation returns null; + * returning a non-null result will terminate the switch. + * + * @param object the target of the switch. + * @return the result of interpreting the object as an instance of 'Model'. + * @see #doSwitch(org.eclipse.emf.ecore.EObject) doSwitch(EObject) + * @generated + */ + public T caseModel(Model object) + { + return null; + } + + /** + * Returns the result of interpreting the object as an instance of 'EObject'. + * + * This implementation returns null; + * returning a non-null result will terminate the switch, but this is the last case anyway. + * + * @param object the target of the switch. + * @return the result of interpreting the object as an instance of 'EObject'. + * @see #doSwitch(org.eclipse.emf.ecore.EObject) + * @generated + */ + @Override + public T defaultCase(EObject object) + { + return null; + } + +} //Bug406914TestSwitch diff --git a/org.eclipse.xtext.tests/src-gen/org/eclipse/xtext/parser/antlr/parser/antlr/Bug406914TestLanguageAntlrTokenFileProvider.java b/org.eclipse.xtext.tests/src-gen/org/eclipse/xtext/parser/antlr/parser/antlr/Bug406914TestLanguageAntlrTokenFileProvider.java new file mode 100644 index 000000000..b1f82d5b8 --- /dev/null +++ b/org.eclipse.xtext.tests/src-gen/org/eclipse/xtext/parser/antlr/parser/antlr/Bug406914TestLanguageAntlrTokenFileProvider.java @@ -0,0 +1,16 @@ +/* + * generated by Xtext + */ +package org.eclipse.xtext.parser.antlr.parser.antlr; + +import java.io.InputStream; +import org.eclipse.xtext.parser.antlr.IAntlrTokenFileProvider; + +public class Bug406914TestLanguageAntlrTokenFileProvider implements IAntlrTokenFileProvider { + + @Override + public InputStream getAntlrTokenFile() { + ClassLoader classLoader = getClass().getClassLoader(); + return classLoader.getResourceAsStream("org/eclipse/xtext/parser/antlr/parser/antlr/internal/InternalBug406914TestLanguage.tokens"); + } +} diff --git a/org.eclipse.xtext.tests/src-gen/org/eclipse/xtext/parser/antlr/parser/antlr/Bug406914TestLanguageParser.java b/org.eclipse.xtext.tests/src-gen/org/eclipse/xtext/parser/antlr/parser/antlr/Bug406914TestLanguageParser.java new file mode 100644 index 000000000..8e81079b6 --- /dev/null +++ b/org.eclipse.xtext.tests/src-gen/org/eclipse/xtext/parser/antlr/parser/antlr/Bug406914TestLanguageParser.java @@ -0,0 +1,40 @@ +/* + * generated by Xtext + */ +package org.eclipse.xtext.parser.antlr.parser.antlr; + +import com.google.inject.Inject; +import org.eclipse.xtext.parser.antlr.AbstractAntlrParser; +import org.eclipse.xtext.parser.antlr.XtextTokenStream; +import org.eclipse.xtext.parser.antlr.parser.antlr.internal.InternalBug406914TestLanguageParser; +import org.eclipse.xtext.parser.antlr.services.Bug406914TestLanguageGrammarAccess; + +public class Bug406914TestLanguageParser extends AbstractAntlrParser { + + @Inject + private Bug406914TestLanguageGrammarAccess grammarAccess; + + @Override + protected void setInitialHiddenTokens(XtextTokenStream tokenStream) { + tokenStream.setInitialHiddenTokens(); + } + + + @Override + protected InternalBug406914TestLanguageParser createParser(XtextTokenStream stream) { + return new InternalBug406914TestLanguageParser(stream, getGrammarAccess()); + } + + @Override + protected String getDefaultRuleName() { + return "Model"; + } + + public Bug406914TestLanguageGrammarAccess getGrammarAccess() { + return this.grammarAccess; + } + + public void setGrammarAccess(Bug406914TestLanguageGrammarAccess grammarAccess) { + this.grammarAccess = grammarAccess; + } +} diff --git a/org.eclipse.xtext.tests/src-gen/org/eclipse/xtext/parser/antlr/parser/antlr/internal/InternalBug301935ExTestLanguageParser.g b/org.eclipse.xtext.tests/src-gen/org/eclipse/xtext/parser/antlr/parser/antlr/internal/InternalBug301935ExTestLanguageParser.g index a8b6b27a9..5b0756444 100644 --- a/org.eclipse.xtext.tests/src-gen/org/eclipse/xtext/parser/antlr/parser/antlr/internal/InternalBug301935ExTestLanguageParser.g +++ b/org.eclipse.xtext.tests/src-gen/org/eclipse/xtext/parser/antlr/parser/antlr/internal/InternalBug301935ExTestLanguageParser.g @@ -193,16 +193,16 @@ ruleNL returns [AntlrDatatypeRuleToken current=new AntlrDatatypeRuleToken()] )* ( ( - kw=Control000d + kw=CarriageReturn { $current.merge(kw); - newLeafNode(kw, grammarAccess.getNLAccess().getControl000dKeyword_1_0()); + newLeafNode(kw, grammarAccess.getNLAccess().getCarriageReturnKeyword_1_0()); } )? - kw=Control000a + kw=LineFeed { $current.merge(kw); - newLeafNode(kw, grammarAccess.getNLAccess().getControl000aKeyword_1_1()); + newLeafNode(kw, grammarAccess.getNLAccess().getLineFeedKeyword_1_1()); } ) ( diff --git a/org.eclipse.xtext.tests/src-gen/org/eclipse/xtext/parser/antlr/parser/antlr/internal/InternalBug301935ExTestLanguageParser.java b/org.eclipse.xtext.tests/src-gen/org/eclipse/xtext/parser/antlr/parser/antlr/internal/InternalBug301935ExTestLanguageParser.java index 6c4aa472a..b3b00fe09 100644 --- a/org.eclipse.xtext.tests/src-gen/org/eclipse/xtext/parser/antlr/parser/antlr/internal/InternalBug301935ExTestLanguageParser.java +++ b/org.eclipse.xtext.tests/src-gen/org/eclipse/xtext/parser/antlr/parser/antlr/internal/InternalBug301935ExTestLanguageParser.java @@ -21,14 +21,14 @@ import java.util.ArrayList; @SuppressWarnings("all") public class InternalBug301935ExTestLanguageParser extends AbstractInternalAntlrParser { public static final String[] tokenNames = new String[] { - "", "", "", "", "Control000a", "Control000d", "RULE_ID", "RULE_WS", "RULE_ANY_OTHER" + "", "", "", "", "LineFeed", "CarriageReturn", "RULE_ID", "RULE_WS", "RULE_ANY_OTHER" }; public static final int RULE_ID=6; public static final int RULE_WS=7; - public static final int Control000d=5; public static final int RULE_ANY_OTHER=8; - public static final int Control000a=4; + public static final int CarriageReturn=5; public static final int EOF=-1; + public static final int LineFeed=4; // delegates // delegators @@ -364,7 +364,7 @@ public class InternalBug301935ExTestLanguageParser extends AbstractInternalAntlr // $ANTLR start "ruleNL" - // InternalBug301935ExTestLanguageParser.g:177:1: ruleNL returns [AntlrDatatypeRuleToken current=new AntlrDatatypeRuleToken()] : ( (this_WS_0= RULE_WS )* ( (kw= Control000d )? kw= Control000a ) (this_WS_3= RULE_WS )* ) ; + // InternalBug301935ExTestLanguageParser.g:177:1: ruleNL returns [AntlrDatatypeRuleToken current=new AntlrDatatypeRuleToken()] : ( (this_WS_0= RULE_WS )* ( (kw= CarriageReturn )? kw= LineFeed ) (this_WS_3= RULE_WS )* ) ; public final AntlrDatatypeRuleToken ruleNL() throws RecognitionException { AntlrDatatypeRuleToken current = new AntlrDatatypeRuleToken(); @@ -376,11 +376,11 @@ public class InternalBug301935ExTestLanguageParser extends AbstractInternalAntlr enterRule(); try { - // InternalBug301935ExTestLanguageParser.g:183:2: ( ( (this_WS_0= RULE_WS )* ( (kw= Control000d )? kw= Control000a ) (this_WS_3= RULE_WS )* ) ) - // InternalBug301935ExTestLanguageParser.g:184:2: ( (this_WS_0= RULE_WS )* ( (kw= Control000d )? kw= Control000a ) (this_WS_3= RULE_WS )* ) + // InternalBug301935ExTestLanguageParser.g:183:2: ( ( (this_WS_0= RULE_WS )* ( (kw= CarriageReturn )? kw= LineFeed ) (this_WS_3= RULE_WS )* ) ) + // InternalBug301935ExTestLanguageParser.g:184:2: ( (this_WS_0= RULE_WS )* ( (kw= CarriageReturn )? kw= LineFeed ) (this_WS_3= RULE_WS )* ) { - // InternalBug301935ExTestLanguageParser.g:184:2: ( (this_WS_0= RULE_WS )* ( (kw= Control000d )? kw= Control000a ) (this_WS_3= RULE_WS )* ) - // InternalBug301935ExTestLanguageParser.g:185:3: (this_WS_0= RULE_WS )* ( (kw= Control000d )? kw= Control000a ) (this_WS_3= RULE_WS )* + // InternalBug301935ExTestLanguageParser.g:184:2: ( (this_WS_0= RULE_WS )* ( (kw= CarriageReturn )? kw= LineFeed ) (this_WS_3= RULE_WS )* ) + // InternalBug301935ExTestLanguageParser.g:185:3: (this_WS_0= RULE_WS )* ( (kw= CarriageReturn )? kw= LineFeed ) (this_WS_3= RULE_WS )* { // InternalBug301935ExTestLanguageParser.g:185:3: (this_WS_0= RULE_WS )* loop1: @@ -413,24 +413,24 @@ public class InternalBug301935ExTestLanguageParser extends AbstractInternalAntlr } } while (true); - // InternalBug301935ExTestLanguageParser.g:194:3: ( (kw= Control000d )? kw= Control000a ) - // InternalBug301935ExTestLanguageParser.g:195:4: (kw= Control000d )? kw= Control000a + // InternalBug301935ExTestLanguageParser.g:194:3: ( (kw= CarriageReturn )? kw= LineFeed ) + // InternalBug301935ExTestLanguageParser.g:195:4: (kw= CarriageReturn )? kw= LineFeed { - // InternalBug301935ExTestLanguageParser.g:195:4: (kw= Control000d )? + // InternalBug301935ExTestLanguageParser.g:195:4: (kw= CarriageReturn )? int alt2=2; int LA2_0 = input.LA(1); - if ( (LA2_0==Control000d) ) { + if ( (LA2_0==CarriageReturn) ) { alt2=1; } switch (alt2) { case 1 : - // InternalBug301935ExTestLanguageParser.g:196:5: kw= Control000d + // InternalBug301935ExTestLanguageParser.g:196:5: kw= CarriageReturn { - kw=(Token)match(input,Control000d,FollowSets000.FOLLOW_6); + kw=(Token)match(input,CarriageReturn,FollowSets000.FOLLOW_6); current.merge(kw); - newLeafNode(kw, grammarAccess.getNLAccess().getControl000dKeyword_1_0()); + newLeafNode(kw, grammarAccess.getNLAccess().getCarriageReturnKeyword_1_0()); } @@ -438,10 +438,10 @@ public class InternalBug301935ExTestLanguageParser extends AbstractInternalAntlr } - kw=(Token)match(input,Control000a,FollowSets000.FOLLOW_7); + kw=(Token)match(input,LineFeed,FollowSets000.FOLLOW_7); current.merge(kw); - newLeafNode(kw, grammarAccess.getNLAccess().getControl000aKeyword_1_1()); + newLeafNode(kw, grammarAccess.getNLAccess().getLineFeedKeyword_1_1()); } diff --git a/org.eclipse.xtext.tests/src-gen/org/eclipse/xtext/parser/antlr/parser/antlr/internal/InternalBug301935TestLanguage.g b/org.eclipse.xtext.tests/src-gen/org/eclipse/xtext/parser/antlr/parser/antlr/internal/InternalBug301935TestLanguage.g index e54efc408..38ada5d7e 100644 --- a/org.eclipse.xtext.tests/src-gen/org/eclipse/xtext/parser/antlr/parser/antlr/internal/InternalBug301935TestLanguage.g +++ b/org.eclipse.xtext.tests/src-gen/org/eclipse/xtext/parser/antlr/parser/antlr/internal/InternalBug301935TestLanguage.g @@ -178,13 +178,13 @@ ruleNL returns [AntlrDatatypeRuleToken current=new AntlrDatatypeRuleToken()] kw='\r' { $current.merge(kw); - newLeafNode(kw, grammarAccess.getNLAccess().getControl000dKeyword_1_0()); + newLeafNode(kw, grammarAccess.getNLAccess().getCarriageReturnKeyword_1_0()); } )? kw='\n' { $current.merge(kw); - newLeafNode(kw, grammarAccess.getNLAccess().getControl000aKeyword_1_1()); + newLeafNode(kw, grammarAccess.getNLAccess().getLineFeedKeyword_1_1()); } ) ( diff --git a/org.eclipse.xtext.tests/src-gen/org/eclipse/xtext/parser/antlr/parser/antlr/internal/InternalBug301935TestLanguageParser.java b/org.eclipse.xtext.tests/src-gen/org/eclipse/xtext/parser/antlr/parser/antlr/internal/InternalBug301935TestLanguageParser.java index 28b0b9eb6..c8efb69ea 100644 --- a/org.eclipse.xtext.tests/src-gen/org/eclipse/xtext/parser/antlr/parser/antlr/internal/InternalBug301935TestLanguageParser.java +++ b/org.eclipse.xtext.tests/src-gen/org/eclipse/xtext/parser/antlr/parser/antlr/internal/InternalBug301935TestLanguageParser.java @@ -348,7 +348,7 @@ public class InternalBug301935TestLanguageParser extends AbstractInternalAntlrPa kw=(Token)match(input,7,FollowSets000.FOLLOW_6); current.merge(kw); - newLeafNode(kw, grammarAccess.getNLAccess().getControl000dKeyword_1_0()); + newLeafNode(kw, grammarAccess.getNLAccess().getCarriageReturnKeyword_1_0()); } @@ -359,7 +359,7 @@ public class InternalBug301935TestLanguageParser extends AbstractInternalAntlrPa kw=(Token)match(input,8,FollowSets000.FOLLOW_7); current.merge(kw); - newLeafNode(kw, grammarAccess.getNLAccess().getControl000aKeyword_1_1()); + newLeafNode(kw, grammarAccess.getNLAccess().getLineFeedKeyword_1_1()); } diff --git a/org.eclipse.xtext.tests/src-gen/org/eclipse/xtext/parser/antlr/parser/antlr/internal/InternalBug406914TestLanguage.g b/org.eclipse.xtext.tests/src-gen/org/eclipse/xtext/parser/antlr/parser/antlr/internal/InternalBug406914TestLanguage.g new file mode 100644 index 000000000..1e66f02b2 --- /dev/null +++ b/org.eclipse.xtext.tests/src-gen/org/eclipse/xtext/parser/antlr/parser/antlr/internal/InternalBug406914TestLanguage.g @@ -0,0 +1,171 @@ +/* + * generated by Xtext + */ +grammar InternalBug406914TestLanguage; + +options { + superClass=AbstractInternalAntlrParser; +} + +@lexer::header { +package org.eclipse.xtext.parser.antlr.parser.antlr.internal; + +// Hack: Use our own Lexer superclass by means of import. +// Currently there is no other way to specify the superclass for the lexer. +import org.eclipse.xtext.parser.antlr.Lexer; +} + +@parser::header { +package org.eclipse.xtext.parser.antlr.parser.antlr.internal; + +import org.eclipse.xtext.*; +import org.eclipse.xtext.parser.*; +import org.eclipse.xtext.parser.impl.*; +import org.eclipse.emf.ecore.util.EcoreUtil; +import org.eclipse.emf.ecore.EObject; +import org.eclipse.xtext.parser.antlr.AbstractInternalAntlrParser; +import org.eclipse.xtext.parser.antlr.XtextTokenStream; +import org.eclipse.xtext.parser.antlr.XtextTokenStream.HiddenTokens; +import org.eclipse.xtext.parser.antlr.AntlrDatatypeRuleToken; +import org.eclipse.xtext.parser.antlr.services.Bug406914TestLanguageGrammarAccess; + +} + +@parser::members { + + private Bug406914TestLanguageGrammarAccess grammarAccess; + + public InternalBug406914TestLanguageParser(TokenStream input, Bug406914TestLanguageGrammarAccess grammarAccess) { + this(input); + this.grammarAccess = grammarAccess; + registerRules(grammarAccess.getGrammar()); + } + + @Override + protected String getFirstRuleName() { + return "Model"; + } + + @Override + protected Bug406914TestLanguageGrammarAccess getGrammarAccess() { + return grammarAccess; + } + +} + +@rulecatch { + catch (RecognitionException re) { + recover(input,re); + appendSkippedTokens(); + } +} + +// Entry rule entryRuleModel +entryRuleModel returns [EObject current=null]: + { newCompositeNode(grammarAccess.getModelRule()); } + iv_ruleModel=ruleModel + { $current=$iv_ruleModel.current; } + EOF; + +// Rule Model +ruleModel returns [EObject current=null] +@init { + enterRule(); +} +@after { + leaveRule(); +}: + ( + ( + ( + lv_name_0_0=RULE_ID + { + newLeafNode(lv_name_0_0, grammarAccess.getModelAccess().getNameIDTerminalRuleCall_0_0()); + } + { + if ($current==null) { + $current = createModelElement(grammarAccess.getModelRule()); + } + setWithLastConsumed( + $current, + "name", + lv_name_0_0, + "org.eclipse.xtext.parser.antlr.Bug406914TestLanguage.ID"); + } + ) + ) + { + newCompositeNode(grammarAccess.getModelAccess().getBS_ESCAPEParserRuleCall_1()); + } + ruleBS_ESCAPE + { + afterParserOrEnumRuleCall(); + } + ) +; + +// Entry rule entryRuleBS_ESCAPE +entryRuleBS_ESCAPE returns [String current=null]: + { newCompositeNode(grammarAccess.getBS_ESCAPERule()); } + iv_ruleBS_ESCAPE=ruleBS_ESCAPE + { $current=$iv_ruleBS_ESCAPE.current.getText(); } + EOF; + +// Rule BS_ESCAPE +ruleBS_ESCAPE returns [AntlrDatatypeRuleToken current=new AntlrDatatypeRuleToken()] +@init { + enterRule(); +} +@after { + leaveRule(); +}: + ( + kw='\b' + { + $current.merge(kw); + newLeafNode(kw, grammarAccess.getBS_ESCAPEAccess().getBackspaceKeyword_0()); + } + | + kw='\f' + { + $current.merge(kw); + newLeafNode(kw, grammarAccess.getBS_ESCAPEAccess().getFormFeedKeyword_1()); + } + | + kw='\n' + { + $current.merge(kw); + newLeafNode(kw, grammarAccess.getBS_ESCAPEAccess().getLineFeedKeyword_2()); + } + | + kw='lineFeed' + { + $current.merge(kw); + newLeafNode(kw, grammarAccess.getBS_ESCAPEAccess().getLineFeedKeyword_3()); + } + | + kw='\r' + { + $current.merge(kw); + newLeafNode(kw, grammarAccess.getBS_ESCAPEAccess().getCarriageReturnKeyword_4()); + } + | + kw='\t' + { + $current.merge(kw); + newLeafNode(kw, grammarAccess.getBS_ESCAPEAccess().getTabKeyword_5()); + } + | + kw='\\' + { + $current.merge(kw); + newLeafNode(kw, grammarAccess.getBS_ESCAPEAccess().getBackslashKeyword_6()); + } + ) +; + +RULE_ID : '^'? ('a'..'z'|'A'..'Z'|'_') ('a'..'z'|'A'..'Z'|'_'|'0'..'9')*; + +RULE_WS : (' '|'\t')+; + +RULE_ANY_OTHER : .; diff --git a/org.eclipse.xtext.tests/src-gen/org/eclipse/xtext/parser/antlr/parser/antlr/internal/InternalBug406914TestLanguage.tokens b/org.eclipse.xtext.tests/src-gen/org/eclipse/xtext/parser/antlr/parser/antlr/internal/InternalBug406914TestLanguage.tokens new file mode 100644 index 000000000..b3e192cbe --- /dev/null +++ b/org.eclipse.xtext.tests/src-gen/org/eclipse/xtext/parser/antlr/parser/antlr/internal/InternalBug406914TestLanguage.tokens @@ -0,0 +1,17 @@ +'\\'=13 +'\b'=7 +'\f'=8 +'\n'=9 +'\r'=11 +'\t'=12 +'lineFeed'=10 +RULE_ANY_OTHER=6 +RULE_ID=4 +RULE_WS=5 +T__10=10 +T__11=11 +T__12=12 +T__13=13 +T__7=7 +T__8=8 +T__9=9 diff --git a/org.eclipse.xtext.tests/src-gen/org/eclipse/xtext/parser/antlr/parser/antlr/internal/InternalBug406914TestLanguageLexer.java b/org.eclipse.xtext.tests/src-gen/org/eclipse/xtext/parser/antlr/parser/antlr/internal/InternalBug406914TestLanguageLexer.java new file mode 100644 index 000000000..e3beb5ec7 --- /dev/null +++ b/org.eclipse.xtext.tests/src-gen/org/eclipse/xtext/parser/antlr/parser/antlr/internal/InternalBug406914TestLanguageLexer.java @@ -0,0 +1,535 @@ +package org.eclipse.xtext.parser.antlr.parser.antlr.internal; + +// Hack: Use our own Lexer superclass by means of import. +// Currently there is no other way to specify the superclass for the lexer. +import org.eclipse.xtext.parser.antlr.Lexer; + + +import org.antlr.runtime.*; +import java.util.Stack; +import java.util.List; +import java.util.ArrayList; + +@SuppressWarnings("all") +public class InternalBug406914TestLanguageLexer extends Lexer { + public static final int T__9=9; + public static final int T__8=8; + public static final int T__7=7; + public static final int RULE_ID=4; + public static final int RULE_WS=5; + public static final int RULE_ANY_OTHER=6; + public static final int T__11=11; + public static final int T__12=12; + public static final int T__13=13; + public static final int EOF=-1; + public static final int T__10=10; + + // delegates + // delegators + + public InternalBug406914TestLanguageLexer() {;} + public InternalBug406914TestLanguageLexer(CharStream input) { + this(input, new RecognizerSharedState()); + } + public InternalBug406914TestLanguageLexer(CharStream input, RecognizerSharedState state) { + super(input,state); + + } + public String getGrammarFileName() { return "InternalBug406914TestLanguage.g"; } + + // $ANTLR start "T__7" + public final void mT__7() throws RecognitionException { + try { + int _type = T__7; + int _channel = DEFAULT_TOKEN_CHANNEL; + // InternalBug406914TestLanguage.g:11:6: ( '\\b' ) + // InternalBug406914TestLanguage.g:11:8: '\\b' + { + match('\b'); + + } + + state.type = _type; + state.channel = _channel; + } + finally { + } + } + // $ANTLR end "T__7" + + // $ANTLR start "T__8" + public final void mT__8() throws RecognitionException { + try { + int _type = T__8; + int _channel = DEFAULT_TOKEN_CHANNEL; + // InternalBug406914TestLanguage.g:12:6: ( '\\f' ) + // InternalBug406914TestLanguage.g:12:8: '\\f' + { + match('\f'); + + } + + state.type = _type; + state.channel = _channel; + } + finally { + } + } + // $ANTLR end "T__8" + + // $ANTLR start "T__9" + public final void mT__9() throws RecognitionException { + try { + int _type = T__9; + int _channel = DEFAULT_TOKEN_CHANNEL; + // InternalBug406914TestLanguage.g:13:6: ( '\\n' ) + // InternalBug406914TestLanguage.g:13:8: '\\n' + { + match('\n'); + + } + + state.type = _type; + state.channel = _channel; + } + finally { + } + } + // $ANTLR end "T__9" + + // $ANTLR start "T__10" + public final void mT__10() throws RecognitionException { + try { + int _type = T__10; + int _channel = DEFAULT_TOKEN_CHANNEL; + // InternalBug406914TestLanguage.g:14:7: ( 'lineFeed' ) + // InternalBug406914TestLanguage.g:14:9: 'lineFeed' + { + match("lineFeed"); + + + } + + state.type = _type; + state.channel = _channel; + } + finally { + } + } + // $ANTLR end "T__10" + + // $ANTLR start "T__11" + public final void mT__11() throws RecognitionException { + try { + int _type = T__11; + int _channel = DEFAULT_TOKEN_CHANNEL; + // InternalBug406914TestLanguage.g:15:7: ( '\\r' ) + // InternalBug406914TestLanguage.g:15:9: '\\r' + { + match('\r'); + + } + + state.type = _type; + state.channel = _channel; + } + finally { + } + } + // $ANTLR end "T__11" + + // $ANTLR start "T__12" + public final void mT__12() throws RecognitionException { + try { + int _type = T__12; + int _channel = DEFAULT_TOKEN_CHANNEL; + // InternalBug406914TestLanguage.g:16:7: ( '\\t' ) + // InternalBug406914TestLanguage.g:16:9: '\\t' + { + match('\t'); + + } + + state.type = _type; + state.channel = _channel; + } + finally { + } + } + // $ANTLR end "T__12" + + // $ANTLR start "T__13" + public final void mT__13() throws RecognitionException { + try { + int _type = T__13; + int _channel = DEFAULT_TOKEN_CHANNEL; + // InternalBug406914TestLanguage.g:17:7: ( '\\\\' ) + // InternalBug406914TestLanguage.g:17:9: '\\\\' + { + match('\\'); + + } + + state.type = _type; + state.channel = _channel; + } + finally { + } + } + // $ANTLR end "T__13" + + // $ANTLR start "RULE_ID" + public final void mRULE_ID() throws RecognitionException { + try { + int _type = RULE_ID; + int _channel = DEFAULT_TOKEN_CHANNEL; + // InternalBug406914TestLanguage.g:167:9: ( ( '^' )? ( 'a' .. 'z' | 'A' .. 'Z' | '_' ) ( 'a' .. 'z' | 'A' .. 'Z' | '_' | '0' .. '9' )* ) + // InternalBug406914TestLanguage.g:167:11: ( '^' )? ( 'a' .. 'z' | 'A' .. 'Z' | '_' ) ( 'a' .. 'z' | 'A' .. 'Z' | '_' | '0' .. '9' )* + { + // InternalBug406914TestLanguage.g:167:11: ( '^' )? + int alt1=2; + int LA1_0 = input.LA(1); + + if ( (LA1_0=='^') ) { + alt1=1; + } + switch (alt1) { + case 1 : + // InternalBug406914TestLanguage.g:167:11: '^' + { + match('^'); + + } + break; + + } + + if ( (input.LA(1)>='A' && input.LA(1)<='Z')||input.LA(1)=='_'||(input.LA(1)>='a' && input.LA(1)<='z') ) { + input.consume(); + + } + else { + MismatchedSetException mse = new MismatchedSetException(null,input); + recover(mse); + throw mse;} + + // InternalBug406914TestLanguage.g:167:40: ( 'a' .. 'z' | 'A' .. 'Z' | '_' | '0' .. '9' )* + loop2: + do { + int alt2=2; + int LA2_0 = input.LA(1); + + if ( ((LA2_0>='0' && LA2_0<='9')||(LA2_0>='A' && LA2_0<='Z')||LA2_0=='_'||(LA2_0>='a' && LA2_0<='z')) ) { + alt2=1; + } + + + switch (alt2) { + case 1 : + // InternalBug406914TestLanguage.g: + { + if ( (input.LA(1)>='0' && input.LA(1)<='9')||(input.LA(1)>='A' && input.LA(1)<='Z')||input.LA(1)=='_'||(input.LA(1)>='a' && input.LA(1)<='z') ) { + input.consume(); + + } + else { + MismatchedSetException mse = new MismatchedSetException(null,input); + recover(mse); + throw mse;} + + + } + break; + + default : + break loop2; + } + } while (true); + + + } + + state.type = _type; + state.channel = _channel; + } + finally { + } + } + // $ANTLR end "RULE_ID" + + // $ANTLR start "RULE_WS" + public final void mRULE_WS() throws RecognitionException { + try { + int _type = RULE_WS; + int _channel = DEFAULT_TOKEN_CHANNEL; + // InternalBug406914TestLanguage.g:169:9: ( ( ' ' | '\\t' )+ ) + // InternalBug406914TestLanguage.g:169:11: ( ' ' | '\\t' )+ + { + // InternalBug406914TestLanguage.g:169:11: ( ' ' | '\\t' )+ + int cnt3=0; + loop3: + do { + int alt3=2; + int LA3_0 = input.LA(1); + + if ( (LA3_0=='\t'||LA3_0==' ') ) { + alt3=1; + } + + + switch (alt3) { + case 1 : + // InternalBug406914TestLanguage.g: + { + if ( input.LA(1)=='\t'||input.LA(1)==' ' ) { + input.consume(); + + } + else { + MismatchedSetException mse = new MismatchedSetException(null,input); + recover(mse); + throw mse;} + + + } + break; + + default : + if ( cnt3 >= 1 ) break loop3; + EarlyExitException eee = + new EarlyExitException(3, input); + throw eee; + } + cnt3++; + } while (true); + + + } + + state.type = _type; + state.channel = _channel; + } + finally { + } + } + // $ANTLR end "RULE_WS" + + // $ANTLR start "RULE_ANY_OTHER" + public final void mRULE_ANY_OTHER() throws RecognitionException { + try { + int _type = RULE_ANY_OTHER; + int _channel = DEFAULT_TOKEN_CHANNEL; + // InternalBug406914TestLanguage.g:171:16: ( . ) + // InternalBug406914TestLanguage.g:171:18: . + { + matchAny(); + + } + + state.type = _type; + state.channel = _channel; + } + finally { + } + } + // $ANTLR end "RULE_ANY_OTHER" + + public void mTokens() throws RecognitionException { + // InternalBug406914TestLanguage.g:1:8: ( T__7 | T__8 | T__9 | T__10 | T__11 | T__12 | T__13 | RULE_ID | RULE_WS | RULE_ANY_OTHER ) + int alt4=10; + alt4 = dfa4.predict(input); + switch (alt4) { + case 1 : + // InternalBug406914TestLanguage.g:1:10: T__7 + { + mT__7(); + + } + break; + case 2 : + // InternalBug406914TestLanguage.g:1:15: T__8 + { + mT__8(); + + } + break; + case 3 : + // InternalBug406914TestLanguage.g:1:20: T__9 + { + mT__9(); + + } + break; + case 4 : + // InternalBug406914TestLanguage.g:1:25: T__10 + { + mT__10(); + + } + break; + case 5 : + // InternalBug406914TestLanguage.g:1:31: T__11 + { + mT__11(); + + } + break; + case 6 : + // InternalBug406914TestLanguage.g:1:37: T__12 + { + mT__12(); + + } + break; + case 7 : + // InternalBug406914TestLanguage.g:1:43: T__13 + { + mT__13(); + + } + break; + case 8 : + // InternalBug406914TestLanguage.g:1:49: RULE_ID + { + mRULE_ID(); + + } + break; + case 9 : + // InternalBug406914TestLanguage.g:1:57: RULE_WS + { + mRULE_WS(); + + } + break; + case 10 : + // InternalBug406914TestLanguage.g:1:65: RULE_ANY_OTHER + { + mRULE_ANY_OTHER(); + + } + break; + + } + + } + + + protected DFA4 dfa4 = new DFA4(this); + static final String DFA4_eotS = + "\4\uffff\1\20\1\uffff\1\22\1\uffff\1\13\6\uffff\1\20\5\uffff\5\20\1\33\1\uffff"; + static final String DFA4_eofS = + "\34\uffff"; + static final String DFA4_minS = + "\1\0\3\uffff\1\151\1\uffff\1\11\1\uffff\1\101\6\uffff\1\156\5\uffff\1\145\1\106\2\145\1\144\1\60\1\uffff"; + static final String DFA4_maxS = + "\1\uffff\3\uffff\1\151\1\uffff\1\40\1\uffff\1\172\6\uffff\1\156\5\uffff\1\145\1\106\2\145\1\144\1\172\1\uffff"; + static final String DFA4_acceptS = + "\1\uffff\1\1\1\2\1\3\1\uffff\1\5\1\uffff\1\7\1\uffff\1\10\1\11\1\12\1\1\1\2\1\3\1\uffff\1\10\1\5\1\6\1\11\1\7\6\uffff\1\4"; + static final String DFA4_specialS = + "\1\0\33\uffff}>"; + static final String[] DFA4_transitionS = { + "\10\13\1\1\1\6\1\3\1\13\1\2\1\5\22\13\1\12\40\13\32\11\1\13\1\7\1\13\1\10\1\11\1\13\13\11\1\4\16\11\uff85\13", + "", + "", + "", + "\1\17", + "", + "\1\23\26\uffff\1\23", + "", + "\32\20\4\uffff\1\20\1\uffff\32\20", + "", + "", + "", + "", + "", + "", + "\1\25", + "", + "", + "", + "", + "", + "\1\26", + "\1\27", + "\1\30", + "\1\31", + "\1\32", + "\12\20\7\uffff\32\20\4\uffff\1\20\1\uffff\32\20", + "" + }; + + static final short[] DFA4_eot = DFA.unpackEncodedString(DFA4_eotS); + static final short[] DFA4_eof = DFA.unpackEncodedString(DFA4_eofS); + static final char[] DFA4_min = DFA.unpackEncodedStringToUnsignedChars(DFA4_minS); + static final char[] DFA4_max = DFA.unpackEncodedStringToUnsignedChars(DFA4_maxS); + static final short[] DFA4_accept = DFA.unpackEncodedString(DFA4_acceptS); + static final short[] DFA4_special = DFA.unpackEncodedString(DFA4_specialS); + static final short[][] DFA4_transition; + + static { + int numStates = DFA4_transitionS.length; + DFA4_transition = new short[numStates][]; + for (int i=0; i='A' && LA4_0<='Z')||LA4_0=='_'||(LA4_0>='a' && LA4_0<='k')||(LA4_0>='m' && LA4_0<='z')) ) {s = 9;} + + else if ( (LA4_0==' ') ) {s = 10;} + + else if ( ((LA4_0>='\u0000' && LA4_0<='\u0007')||LA4_0=='\u000B'||(LA4_0>='\u000E' && LA4_0<='\u001F')||(LA4_0>='!' && LA4_0<='@')||LA4_0=='['||LA4_0==']'||LA4_0=='`'||(LA4_0>='{' && LA4_0<='\uFFFF')) ) {s = 11;} + + if ( s>=0 ) return s; + break; + } + NoViableAltException nvae = + new NoViableAltException(getDescription(), 4, _s, input); + error(nvae); + throw nvae; + } + } + + +} \ No newline at end of file diff --git a/org.eclipse.xtext.tests/src-gen/org/eclipse/xtext/parser/antlr/parser/antlr/internal/InternalBug406914TestLanguageParser.java b/org.eclipse.xtext.tests/src-gen/org/eclipse/xtext/parser/antlr/parser/antlr/internal/InternalBug406914TestLanguageParser.java new file mode 100644 index 000000000..2af149c12 --- /dev/null +++ b/org.eclipse.xtext.tests/src-gen/org/eclipse/xtext/parser/antlr/parser/antlr/internal/InternalBug406914TestLanguageParser.java @@ -0,0 +1,396 @@ +package org.eclipse.xtext.parser.antlr.parser.antlr.internal; + +import org.eclipse.xtext.*; +import org.eclipse.xtext.parser.*; +import org.eclipse.xtext.parser.impl.*; +import org.eclipse.emf.ecore.util.EcoreUtil; +import org.eclipse.emf.ecore.EObject; +import org.eclipse.xtext.parser.antlr.AbstractInternalAntlrParser; +import org.eclipse.xtext.parser.antlr.XtextTokenStream; +import org.eclipse.xtext.parser.antlr.XtextTokenStream.HiddenTokens; +import org.eclipse.xtext.parser.antlr.AntlrDatatypeRuleToken; +import org.eclipse.xtext.parser.antlr.services.Bug406914TestLanguageGrammarAccess; + + + +import org.antlr.runtime.*; +import java.util.Stack; +import java.util.List; +import java.util.ArrayList; + +@SuppressWarnings("all") +public class InternalBug406914TestLanguageParser extends AbstractInternalAntlrParser { + public static final String[] tokenNames = new String[] { + "", "", "", "", "RULE_ID", "RULE_WS", "RULE_ANY_OTHER", "'\\b'", "'\\f'", "'\\n'", "'lineFeed'", "'\\r'", "'\\t'", "'\\\\'" + }; + public static final int T__9=9; + public static final int T__8=8; + public static final int T__7=7; + public static final int RULE_ID=4; + public static final int RULE_WS=5; + public static final int RULE_ANY_OTHER=6; + public static final int T__11=11; + public static final int T__12=12; + public static final int T__13=13; + public static final int EOF=-1; + public static final int T__10=10; + + // delegates + // delegators + + + public InternalBug406914TestLanguageParser(TokenStream input) { + this(input, new RecognizerSharedState()); + } + public InternalBug406914TestLanguageParser(TokenStream input, RecognizerSharedState state) { + super(input, state); + + } + + + public String[] getTokenNames() { return InternalBug406914TestLanguageParser.tokenNames; } + public String getGrammarFileName() { return "InternalBug406914TestLanguage.g"; } + + + + private Bug406914TestLanguageGrammarAccess grammarAccess; + + public InternalBug406914TestLanguageParser(TokenStream input, Bug406914TestLanguageGrammarAccess grammarAccess) { + this(input); + this.grammarAccess = grammarAccess; + registerRules(grammarAccess.getGrammar()); + } + + @Override + protected String getFirstRuleName() { + return "Model"; + } + + @Override + protected Bug406914TestLanguageGrammarAccess getGrammarAccess() { + return grammarAccess; + } + + + + + // $ANTLR start "entryRuleModel" + // InternalBug406914TestLanguage.g:64:1: entryRuleModel returns [EObject current=null] : iv_ruleModel= ruleModel EOF ; + public final EObject entryRuleModel() throws RecognitionException { + EObject current = null; + + EObject iv_ruleModel = null; + + + try { + // InternalBug406914TestLanguage.g:64:46: (iv_ruleModel= ruleModel EOF ) + // InternalBug406914TestLanguage.g:65:2: iv_ruleModel= ruleModel EOF + { + newCompositeNode(grammarAccess.getModelRule()); + pushFollow(FollowSets000.FOLLOW_1); + iv_ruleModel=ruleModel(); + + state._fsp--; + + current =iv_ruleModel; + match(input,EOF,FollowSets000.FOLLOW_2); + + } + + } + + catch (RecognitionException re) { + recover(input,re); + appendSkippedTokens(); + } + finally { + } + return current; + } + // $ANTLR end "entryRuleModel" + + + // $ANTLR start "ruleModel" + // InternalBug406914TestLanguage.g:71:1: ruleModel returns [EObject current=null] : ( ( (lv_name_0_0= RULE_ID ) ) ruleBS_ESCAPE ) ; + public final EObject ruleModel() throws RecognitionException { + EObject current = null; + + Token lv_name_0_0=null; + + + enterRule(); + + try { + // InternalBug406914TestLanguage.g:77:2: ( ( ( (lv_name_0_0= RULE_ID ) ) ruleBS_ESCAPE ) ) + // InternalBug406914TestLanguage.g:78:2: ( ( (lv_name_0_0= RULE_ID ) ) ruleBS_ESCAPE ) + { + // InternalBug406914TestLanguage.g:78:2: ( ( (lv_name_0_0= RULE_ID ) ) ruleBS_ESCAPE ) + // InternalBug406914TestLanguage.g:79:3: ( (lv_name_0_0= RULE_ID ) ) ruleBS_ESCAPE + { + // InternalBug406914TestLanguage.g:79:3: ( (lv_name_0_0= RULE_ID ) ) + // InternalBug406914TestLanguage.g:80:4: (lv_name_0_0= RULE_ID ) + { + // InternalBug406914TestLanguage.g:80:4: (lv_name_0_0= RULE_ID ) + // InternalBug406914TestLanguage.g:81:5: lv_name_0_0= RULE_ID + { + lv_name_0_0=(Token)match(input,RULE_ID,FollowSets000.FOLLOW_3); + + newLeafNode(lv_name_0_0, grammarAccess.getModelAccess().getNameIDTerminalRuleCall_0_0()); + + + if (current==null) { + current = createModelElement(grammarAccess.getModelRule()); + } + setWithLastConsumed( + current, + "name", + lv_name_0_0, + "org.eclipse.xtext.parser.antlr.Bug406914TestLanguage.ID"); + + + } + + + } + + + newCompositeNode(grammarAccess.getModelAccess().getBS_ESCAPEParserRuleCall_1()); + + pushFollow(FollowSets000.FOLLOW_2); + ruleBS_ESCAPE(); + + state._fsp--; + + + afterParserOrEnumRuleCall(); + + + } + + + } + + + leaveRule(); + + } + + catch (RecognitionException re) { + recover(input,re); + appendSkippedTokens(); + } + finally { + } + return current; + } + // $ANTLR end "ruleModel" + + + // $ANTLR start "entryRuleBS_ESCAPE" + // InternalBug406914TestLanguage.g:108:1: entryRuleBS_ESCAPE returns [String current=null] : iv_ruleBS_ESCAPE= ruleBS_ESCAPE EOF ; + public final String entryRuleBS_ESCAPE() throws RecognitionException { + String current = null; + + AntlrDatatypeRuleToken iv_ruleBS_ESCAPE = null; + + + try { + // InternalBug406914TestLanguage.g:108:49: (iv_ruleBS_ESCAPE= ruleBS_ESCAPE EOF ) + // InternalBug406914TestLanguage.g:109:2: iv_ruleBS_ESCAPE= ruleBS_ESCAPE EOF + { + newCompositeNode(grammarAccess.getBS_ESCAPERule()); + pushFollow(FollowSets000.FOLLOW_1); + iv_ruleBS_ESCAPE=ruleBS_ESCAPE(); + + state._fsp--; + + current =iv_ruleBS_ESCAPE.getText(); + match(input,EOF,FollowSets000.FOLLOW_2); + + } + + } + + catch (RecognitionException re) { + recover(input,re); + appendSkippedTokens(); + } + finally { + } + return current; + } + // $ANTLR end "entryRuleBS_ESCAPE" + + + // $ANTLR start "ruleBS_ESCAPE" + // InternalBug406914TestLanguage.g:115:1: ruleBS_ESCAPE returns [AntlrDatatypeRuleToken current=new AntlrDatatypeRuleToken()] : (kw= '\\b' | kw= '\\f' | kw= '\\n' | kw= 'lineFeed' | kw= '\\r' | kw= '\\t' | kw= '\\\\' ) ; + public final AntlrDatatypeRuleToken ruleBS_ESCAPE() throws RecognitionException { + AntlrDatatypeRuleToken current = new AntlrDatatypeRuleToken(); + + Token kw=null; + + + enterRule(); + + try { + // InternalBug406914TestLanguage.g:121:2: ( (kw= '\\b' | kw= '\\f' | kw= '\\n' | kw= 'lineFeed' | kw= '\\r' | kw= '\\t' | kw= '\\\\' ) ) + // InternalBug406914TestLanguage.g:122:2: (kw= '\\b' | kw= '\\f' | kw= '\\n' | kw= 'lineFeed' | kw= '\\r' | kw= '\\t' | kw= '\\\\' ) + { + // InternalBug406914TestLanguage.g:122:2: (kw= '\\b' | kw= '\\f' | kw= '\\n' | kw= 'lineFeed' | kw= '\\r' | kw= '\\t' | kw= '\\\\' ) + int alt1=7; + switch ( input.LA(1) ) { + case 7: + { + alt1=1; + } + break; + case 8: + { + alt1=2; + } + break; + case 9: + { + alt1=3; + } + break; + case 10: + { + alt1=4; + } + break; + case 11: + { + alt1=5; + } + break; + case 12: + { + alt1=6; + } + break; + case 13: + { + alt1=7; + } + break; + default: + NoViableAltException nvae = + new NoViableAltException("", 1, 0, input); + + throw nvae; + } + + switch (alt1) { + case 1 : + // InternalBug406914TestLanguage.g:123:3: kw= '\\b' + { + kw=(Token)match(input,7,FollowSets000.FOLLOW_2); + + current.merge(kw); + newLeafNode(kw, grammarAccess.getBS_ESCAPEAccess().getBackspaceKeyword_0()); + + + } + break; + case 2 : + // InternalBug406914TestLanguage.g:129:3: kw= '\\f' + { + kw=(Token)match(input,8,FollowSets000.FOLLOW_2); + + current.merge(kw); + newLeafNode(kw, grammarAccess.getBS_ESCAPEAccess().getFormFeedKeyword_1()); + + + } + break; + case 3 : + // InternalBug406914TestLanguage.g:135:3: kw= '\\n' + { + kw=(Token)match(input,9,FollowSets000.FOLLOW_2); + + current.merge(kw); + newLeafNode(kw, grammarAccess.getBS_ESCAPEAccess().getLineFeedKeyword_2()); + + + } + break; + case 4 : + // InternalBug406914TestLanguage.g:141:3: kw= 'lineFeed' + { + kw=(Token)match(input,10,FollowSets000.FOLLOW_2); + + current.merge(kw); + newLeafNode(kw, grammarAccess.getBS_ESCAPEAccess().getLineFeedKeyword_3()); + + + } + break; + case 5 : + // InternalBug406914TestLanguage.g:147:3: kw= '\\r' + { + kw=(Token)match(input,11,FollowSets000.FOLLOW_2); + + current.merge(kw); + newLeafNode(kw, grammarAccess.getBS_ESCAPEAccess().getCarriageReturnKeyword_4()); + + + } + break; + case 6 : + // InternalBug406914TestLanguage.g:153:3: kw= '\\t' + { + kw=(Token)match(input,12,FollowSets000.FOLLOW_2); + + current.merge(kw); + newLeafNode(kw, grammarAccess.getBS_ESCAPEAccess().getTabKeyword_5()); + + + } + break; + case 7 : + // InternalBug406914TestLanguage.g:159:3: kw= '\\\\' + { + kw=(Token)match(input,13,FollowSets000.FOLLOW_2); + + current.merge(kw); + newLeafNode(kw, grammarAccess.getBS_ESCAPEAccess().getBackslashKeyword_6()); + + + } + break; + + } + + + } + + + leaveRule(); + + } + + catch (RecognitionException re) { + recover(input,re); + appendSkippedTokens(); + } + finally { + } + return current; + } + // $ANTLR end "ruleBS_ESCAPE" + + // Delegated rules + + + + + + private static class FollowSets000 { + public static final BitSet FOLLOW_1 = new BitSet(new long[]{0x0000000000000000L}); + public static final BitSet FOLLOW_2 = new BitSet(new long[]{0x0000000000000002L}); + public static final BitSet FOLLOW_3 = new BitSet(new long[]{0x0000000000003F80L}); + } + + +} \ No newline at end of file diff --git a/org.eclipse.xtext.tests/src-gen/org/eclipse/xtext/parser/antlr/parser/antlr/lexer/InternalBug301935ExTestLanguageLexer.g b/org.eclipse.xtext.tests/src-gen/org/eclipse/xtext/parser/antlr/parser/antlr/lexer/InternalBug301935ExTestLanguageLexer.g index a878138a7..77779aa45 100644 --- a/org.eclipse.xtext.tests/src-gen/org/eclipse/xtext/parser/antlr/parser/antlr/lexer/InternalBug301935ExTestLanguageLexer.g +++ b/org.eclipse.xtext.tests/src-gen/org/eclipse/xtext/parser/antlr/parser/antlr/lexer/InternalBug301935ExTestLanguageLexer.g @@ -11,9 +11,9 @@ package org.eclipse.xtext.parser.antlr.parser.antlr.lexer; import org.eclipse.xtext.parser.antlr.Lexer; } -Control000a : '\n'; +LineFeed : '\n'; -Control000d : '\r'; +CarriageReturn : '\r'; // Rules duplicated to allow inter-rule references diff --git a/org.eclipse.xtext.tests/src-gen/org/eclipse/xtext/parser/antlr/parser/antlr/lexer/InternalBug301935ExTestLanguageLexer.java b/org.eclipse.xtext.tests/src-gen/org/eclipse/xtext/parser/antlr/parser/antlr/lexer/InternalBug301935ExTestLanguageLexer.java index 32b2889db..6ddd72454 100644 --- a/org.eclipse.xtext.tests/src-gen/org/eclipse/xtext/parser/antlr/parser/antlr/lexer/InternalBug301935ExTestLanguageLexer.java +++ b/org.eclipse.xtext.tests/src-gen/org/eclipse/xtext/parser/antlr/parser/antlr/lexer/InternalBug301935ExTestLanguageLexer.java @@ -14,10 +14,10 @@ import java.util.ArrayList; public class InternalBug301935ExTestLanguageLexer extends Lexer { public static final int RULE_ID=6; public static final int RULE_WS=7; - public static final int Control000d=5; public static final int RULE_ANY_OTHER=8; - public static final int Control000a=4; + public static final int CarriageReturn=5; public static final int EOF=-1; + public static final int LineFeed=4; // delegates // delegators @@ -32,13 +32,13 @@ public class InternalBug301935ExTestLanguageLexer extends Lexer { } public String getGrammarFileName() { return "InternalBug301935ExTestLanguageLexer.g"; } - // $ANTLR start "Control000a" - public final void mControl000a() throws RecognitionException { + // $ANTLR start "LineFeed" + public final void mLineFeed() throws RecognitionException { try { - int _type = Control000a; + int _type = LineFeed; int _channel = DEFAULT_TOKEN_CHANNEL; - // InternalBug301935ExTestLanguageLexer.g:14:13: ( '\\n' ) - // InternalBug301935ExTestLanguageLexer.g:14:15: '\\n' + // InternalBug301935ExTestLanguageLexer.g:14:10: ( '\\n' ) + // InternalBug301935ExTestLanguageLexer.g:14:12: '\\n' { match('\n'); @@ -50,15 +50,15 @@ public class InternalBug301935ExTestLanguageLexer extends Lexer { finally { } } - // $ANTLR end "Control000a" + // $ANTLR end "LineFeed" - // $ANTLR start "Control000d" - public final void mControl000d() throws RecognitionException { + // $ANTLR start "CarriageReturn" + public final void mCarriageReturn() throws RecognitionException { try { - int _type = Control000d; + int _type = CarriageReturn; int _channel = DEFAULT_TOKEN_CHANNEL; - // InternalBug301935ExTestLanguageLexer.g:16:13: ( '\\r' ) - // InternalBug301935ExTestLanguageLexer.g:16:15: '\\r' + // InternalBug301935ExTestLanguageLexer.g:16:16: ( '\\r' ) + // InternalBug301935ExTestLanguageLexer.g:16:18: '\\r' { match('\r'); @@ -70,7 +70,7 @@ public class InternalBug301935ExTestLanguageLexer extends Lexer { finally { } } - // $ANTLR end "Control000d" + // $ANTLR end "CarriageReturn" // $ANTLR start "RULE_ID" public final void mRULE_ID() throws RecognitionException { @@ -229,21 +229,21 @@ public class InternalBug301935ExTestLanguageLexer extends Lexer { // $ANTLR end "RULE_ANY_OTHER" public void mTokens() throws RecognitionException { - // InternalBug301935ExTestLanguageLexer.g:1:8: ( Control000a | Control000d | RULE_ID | RULE_WS | RULE_ANY_OTHER ) + // InternalBug301935ExTestLanguageLexer.g:1:8: ( LineFeed | CarriageReturn | RULE_ID | RULE_WS | RULE_ANY_OTHER ) int alt4=5; alt4 = dfa4.predict(input); switch (alt4) { case 1 : - // InternalBug301935ExTestLanguageLexer.g:1:10: Control000a + // InternalBug301935ExTestLanguageLexer.g:1:10: LineFeed { - mControl000a(); + mLineFeed(); } break; case 2 : - // InternalBug301935ExTestLanguageLexer.g:1:22: Control000d + // InternalBug301935ExTestLanguageLexer.g:1:19: CarriageReturn { - mControl000d(); + mCarriageReturn(); } break; @@ -331,7 +331,7 @@ public class InternalBug301935ExTestLanguageLexer extends Lexer { this.transition = DFA4_transition; } public String getDescription() { - return "1:1: Tokens : ( Control000a | Control000d | RULE_ID | RULE_WS | RULE_ANY_OTHER );"; + return "1:1: Tokens : ( LineFeed | CarriageReturn | RULE_ID | RULE_WS | RULE_ANY_OTHER );"; } public int specialStateTransition(int s, IntStream _input) throws NoViableAltException { IntStream input = _input; diff --git a/org.eclipse.xtext.tests/src-gen/org/eclipse/xtext/parser/antlr/parser/antlr/lexer/InternalBug301935ExTestLanguageLexer.tokens b/org.eclipse.xtext.tests/src-gen/org/eclipse/xtext/parser/antlr/parser/antlr/lexer/InternalBug301935ExTestLanguageLexer.tokens index 07acdebf9..d29f129a6 100644 --- a/org.eclipse.xtext.tests/src-gen/org/eclipse/xtext/parser/antlr/parser/antlr/lexer/InternalBug301935ExTestLanguageLexer.tokens +++ b/org.eclipse.xtext.tests/src-gen/org/eclipse/xtext/parser/antlr/parser/antlr/lexer/InternalBug301935ExTestLanguageLexer.tokens @@ -1,5 +1,5 @@ -Control000a=4 -Control000d=5 +CarriageReturn=5 +LineFeed=4 RULE_ANY_OTHER=8 RULE_ID=6 RULE_WS=7 diff --git a/org.eclipse.xtext.tests/src-gen/org/eclipse/xtext/parser/antlr/serializer/AbstractBug301935TestLanguageSemanticSequencer.java b/org.eclipse.xtext.tests/src-gen/org/eclipse/xtext/parser/antlr/serializer/Bug301935TestLanguageSemanticSequencer.java similarity index 96% rename from org.eclipse.xtext.tests/src-gen/org/eclipse/xtext/parser/antlr/serializer/AbstractBug301935TestLanguageSemanticSequencer.java rename to org.eclipse.xtext.tests/src-gen/org/eclipse/xtext/parser/antlr/serializer/Bug301935TestLanguageSemanticSequencer.java index 3d887bf8e..63f8feb28 100644 --- a/org.eclipse.xtext.tests/src-gen/org/eclipse/xtext/parser/antlr/serializer/AbstractBug301935TestLanguageSemanticSequencer.java +++ b/org.eclipse.xtext.tests/src-gen/org/eclipse/xtext/parser/antlr/serializer/Bug301935TestLanguageSemanticSequencer.java @@ -19,7 +19,7 @@ import org.eclipse.xtext.serializer.sequencer.AbstractDelegatingSemanticSequence import org.eclipse.xtext.serializer.sequencer.ITransientValueService.ValueTransient; @SuppressWarnings("all") -public abstract class AbstractBug301935TestLanguageSemanticSequencer extends AbstractDelegatingSemanticSequencer { +public class Bug301935TestLanguageSemanticSequencer extends AbstractDelegatingSemanticSequencer { @Inject private Bug301935TestLanguageGrammarAccess grammarAccess; diff --git a/org.eclipse.xtext.tests/src-gen/org/eclipse/xtext/parser/antlr/serializer/AbstractBug301935TestLanguageSyntacticSequencer.java b/org.eclipse.xtext.tests/src-gen/org/eclipse/xtext/parser/antlr/serializer/Bug301935TestLanguageSyntacticSequencer.java similarity index 95% rename from org.eclipse.xtext.tests/src-gen/org/eclipse/xtext/parser/antlr/serializer/AbstractBug301935TestLanguageSyntacticSequencer.java rename to org.eclipse.xtext.tests/src-gen/org/eclipse/xtext/parser/antlr/serializer/Bug301935TestLanguageSyntacticSequencer.java index 05a644813..0a8b5ff90 100644 --- a/org.eclipse.xtext.tests/src-gen/org/eclipse/xtext/parser/antlr/serializer/AbstractBug301935TestLanguageSyntacticSequencer.java +++ b/org.eclipse.xtext.tests/src-gen/org/eclipse/xtext/parser/antlr/serializer/Bug301935TestLanguageSyntacticSequencer.java @@ -15,7 +15,7 @@ import org.eclipse.xtext.serializer.analysis.ISyntacticSequencerPDAProvider.ISyn import org.eclipse.xtext.serializer.sequencer.AbstractSyntacticSequencer; @SuppressWarnings("all") -public abstract class AbstractBug301935TestLanguageSyntacticSequencer extends AbstractSyntacticSequencer { +public class Bug301935TestLanguageSyntacticSequencer extends AbstractSyntacticSequencer { protected Bug301935TestLanguageGrammarAccess grammarAccess; diff --git a/org.eclipse.xtext.tests/src-gen/org/eclipse/xtext/parser/antlr/serializer/Bug406914TestLanguageSemanticSequencer.java b/org.eclipse.xtext.tests/src-gen/org/eclipse/xtext/parser/antlr/serializer/Bug406914TestLanguageSemanticSequencer.java new file mode 100644 index 000000000..34bbb5b53 --- /dev/null +++ b/org.eclipse.xtext.tests/src-gen/org/eclipse/xtext/parser/antlr/serializer/Bug406914TestLanguageSemanticSequencer.java @@ -0,0 +1,61 @@ +/* + * generated by Xtext + */ +package org.eclipse.xtext.parser.antlr.serializer; + +import com.google.inject.Inject; +import java.util.Set; +import org.eclipse.emf.ecore.EObject; +import org.eclipse.emf.ecore.EPackage; +import org.eclipse.xtext.Action; +import org.eclipse.xtext.Parameter; +import org.eclipse.xtext.ParserRule; +import org.eclipse.xtext.parser.antlr.bug406914Test.Bug406914TestPackage; +import org.eclipse.xtext.parser.antlr.bug406914Test.Model; +import org.eclipse.xtext.parser.antlr.services.Bug406914TestLanguageGrammarAccess; +import org.eclipse.xtext.serializer.ISerializationContext; +import org.eclipse.xtext.serializer.acceptor.SequenceFeeder; +import org.eclipse.xtext.serializer.sequencer.AbstractDelegatingSemanticSequencer; +import org.eclipse.xtext.serializer.sequencer.ITransientValueService.ValueTransient; + +@SuppressWarnings("all") +public class Bug406914TestLanguageSemanticSequencer extends AbstractDelegatingSemanticSequencer { + + @Inject + private Bug406914TestLanguageGrammarAccess grammarAccess; + + @Override + public void sequence(ISerializationContext context, EObject semanticObject) { + EPackage epackage = semanticObject.eClass().getEPackage(); + ParserRule rule = context.getParserRule(); + Action action = context.getAssignedAction(); + Set parameters = context.getEnabledBooleanParameters(); + if (epackage == Bug406914TestPackage.eINSTANCE) + switch (semanticObject.eClass().getClassifierID()) { + case Bug406914TestPackage.MODEL: + sequence_Model(context, (Model) semanticObject); + return; + } + if (errorAcceptor != null) + errorAcceptor.accept(diagnosticProvider.createInvalidContextOrTypeDiagnostic(semanticObject, context)); + } + + /** + * Contexts: + * Model returns Model + * + * Constraint: + * name=ID + */ + protected void sequence_Model(ISerializationContext context, Model semanticObject) { + if (errorAcceptor != null) { + if (transientValues.isValueTransient(semanticObject, Bug406914TestPackage.Literals.MODEL__NAME) == ValueTransient.YES) + errorAcceptor.accept(diagnosticProvider.createFeatureValueMissing(semanticObject, Bug406914TestPackage.Literals.MODEL__NAME)); + } + SequenceFeeder feeder = createSequencerFeeder(context, semanticObject); + feeder.accept(grammarAccess.getModelAccess().getNameIDTerminalRuleCall_0_0(), semanticObject.getName()); + feeder.finish(); + } + + +} diff --git a/org.eclipse.xtext.tests/src-gen/org/eclipse/xtext/parser/antlr/serializer/Bug406914TestLanguageSyntacticSequencer.java b/org.eclipse.xtext.tests/src-gen/org/eclipse/xtext/parser/antlr/serializer/Bug406914TestLanguageSyntacticSequencer.java new file mode 100644 index 000000000..c68cfbd02 --- /dev/null +++ b/org.eclipse.xtext.tests/src-gen/org/eclipse/xtext/parser/antlr/serializer/Bug406914TestLanguageSyntacticSequencer.java @@ -0,0 +1,55 @@ +/* + * generated by Xtext + */ +package org.eclipse.xtext.parser.antlr.serializer; + +import com.google.inject.Inject; +import java.util.List; +import org.eclipse.emf.ecore.EObject; +import org.eclipse.xtext.IGrammarAccess; +import org.eclipse.xtext.RuleCall; +import org.eclipse.xtext.nodemodel.INode; +import org.eclipse.xtext.parser.antlr.services.Bug406914TestLanguageGrammarAccess; +import org.eclipse.xtext.serializer.analysis.GrammarAlias.AbstractElementAlias; +import org.eclipse.xtext.serializer.analysis.ISyntacticSequencerPDAProvider.ISynTransition; +import org.eclipse.xtext.serializer.sequencer.AbstractSyntacticSequencer; + +@SuppressWarnings("all") +public class Bug406914TestLanguageSyntacticSequencer extends AbstractSyntacticSequencer { + + protected Bug406914TestLanguageGrammarAccess grammarAccess; + + @Inject + protected void init(IGrammarAccess access) { + grammarAccess = (Bug406914TestLanguageGrammarAccess) access; + } + + @Override + protected String getUnassignedRuleCallToken(EObject semanticObject, RuleCall ruleCall, INode node) { + if (ruleCall.getRule() == grammarAccess.getBS_ESCAPERule()) + return getBS_ESCAPEToken(semanticObject, ruleCall, node); + return ""; + } + + /** + * BS_ESCAPE: + * '\b' | '\f' | '\n' | 'lineFeed' | '\r' | '\t' | '\\' + * ; + */ + protected String getBS_ESCAPEToken(EObject semanticObject, RuleCall ruleCall, INode node) { + if (node != null) + return getTokenText(node); + return "\b"; + } + + @Override + protected void emitUnassignedTokens(EObject semanticObject, ISynTransition transition, INode fromNode, INode toNode) { + if (transition.getAmbiguousSyntaxes().isEmpty()) return; + List transitionNodes = collectNodes(fromNode, toNode); + for (AbstractElementAlias syntax : transition.getAmbiguousSyntaxes()) { + List syntaxNodes = getNodesFor(transitionNodes, syntax); + acceptNodes(getLastNavigableState(), syntaxNodes); + } + } + +} diff --git a/org.eclipse.xtext.tests/src-gen/org/eclipse/xtext/parser/antlr/services/Bug301935TestLanguageGrammarAccess.java b/org.eclipse.xtext.tests/src-gen/org/eclipse/xtext/parser/antlr/services/Bug301935TestLanguageGrammarAccess.java index 765a5b3b0..68427affc 100644 --- a/org.eclipse.xtext.tests/src-gen/org/eclipse/xtext/parser/antlr/services/Bug301935TestLanguageGrammarAccess.java +++ b/org.eclipse.xtext.tests/src-gen/org/eclipse/xtext/parser/antlr/services/Bug301935TestLanguageGrammarAccess.java @@ -73,8 +73,8 @@ public class Bug301935TestLanguageGrammarAccess extends AbstractGrammarElementFi private final Group cGroup = (Group)rule.eContents().get(1); private final RuleCall cWSTerminalRuleCall_0 = (RuleCall)cGroup.eContents().get(0); private final Group cGroup_1 = (Group)cGroup.eContents().get(1); - private final Keyword cControl000dKeyword_1_0 = (Keyword)cGroup_1.eContents().get(0); - private final Keyword cControl000aKeyword_1_1 = (Keyword)cGroup_1.eContents().get(1); + private final Keyword cCarriageReturnKeyword_1_0 = (Keyword)cGroup_1.eContents().get(0); + private final Keyword cLineFeedKeyword_1_1 = (Keyword)cGroup_1.eContents().get(1); private final RuleCall cWSTerminalRuleCall_2 = (RuleCall)cGroup.eContents().get(2); //NL: @@ -91,10 +91,10 @@ public class Bug301935TestLanguageGrammarAccess extends AbstractGrammarElementFi public Group getGroup_1() { return cGroup_1; } //'\r'? - public Keyword getControl000dKeyword_1_0() { return cControl000dKeyword_1_0; } + public Keyword getCarriageReturnKeyword_1_0() { return cCarriageReturnKeyword_1_0; } //'\n' - public Keyword getControl000aKeyword_1_1() { return cControl000aKeyword_1_1; } + public Keyword getLineFeedKeyword_1_1() { return cLineFeedKeyword_1_1; } //WS* public RuleCall getWSTerminalRuleCall_2() { return cWSTerminalRuleCall_2; } diff --git a/org.eclipse.xtext.tests/src-gen/org/eclipse/xtext/parser/antlr/services/Bug406914TestLanguageGrammarAccess.java b/org.eclipse.xtext.tests/src-gen/org/eclipse/xtext/parser/antlr/services/Bug406914TestLanguageGrammarAccess.java new file mode 100644 index 000000000..5c4dfba8d --- /dev/null +++ b/org.eclipse.xtext.tests/src-gen/org/eclipse/xtext/parser/antlr/services/Bug406914TestLanguageGrammarAccess.java @@ -0,0 +1,166 @@ +/* + * generated by Xtext + */ +package org.eclipse.xtext.parser.antlr.services; + +import com.google.inject.Inject; +import com.google.inject.Singleton; +import java.util.List; +import org.eclipse.xtext.Alternatives; +import org.eclipse.xtext.Assignment; +import org.eclipse.xtext.Grammar; +import org.eclipse.xtext.GrammarUtil; +import org.eclipse.xtext.Group; +import org.eclipse.xtext.Keyword; +import org.eclipse.xtext.ParserRule; +import org.eclipse.xtext.RuleCall; +import org.eclipse.xtext.TerminalRule; +import org.eclipse.xtext.service.AbstractElementFinder.AbstractGrammarElementFinder; +import org.eclipse.xtext.service.GrammarProvider; + +@Singleton +public class Bug406914TestLanguageGrammarAccess extends AbstractGrammarElementFinder { + + public class ModelElements extends AbstractParserRuleElementFinder { + private final ParserRule rule = (ParserRule) GrammarUtil.findRuleForName(getGrammar(), "org.eclipse.xtext.parser.antlr.Bug406914TestLanguage.Model"); + private final Group cGroup = (Group)rule.eContents().get(1); + private final Assignment cNameAssignment_0 = (Assignment)cGroup.eContents().get(0); + private final RuleCall cNameIDTerminalRuleCall_0_0 = (RuleCall)cNameAssignment_0.eContents().get(0); + private final RuleCall cBS_ESCAPEParserRuleCall_1 = (RuleCall)cGroup.eContents().get(1); + + //Model: + // name=ID BS_ESCAPE; + @Override public ParserRule getRule() { return rule; } + + //name=ID BS_ESCAPE + public Group getGroup() { return cGroup; } + + //name=ID + public Assignment getNameAssignment_0() { return cNameAssignment_0; } + + //ID + public RuleCall getNameIDTerminalRuleCall_0_0() { return cNameIDTerminalRuleCall_0_0; } + + //BS_ESCAPE + public RuleCall getBS_ESCAPEParserRuleCall_1() { return cBS_ESCAPEParserRuleCall_1; } + } + public class BS_ESCAPEElements extends AbstractParserRuleElementFinder { + private final ParserRule rule = (ParserRule) GrammarUtil.findRuleForName(getGrammar(), "org.eclipse.xtext.parser.antlr.Bug406914TestLanguage.BS_ESCAPE"); + private final Alternatives cAlternatives = (Alternatives)rule.eContents().get(1); + private final Keyword cBackspaceKeyword_0 = (Keyword)cAlternatives.eContents().get(0); + private final Keyword cFormFeedKeyword_1 = (Keyword)cAlternatives.eContents().get(1); + private final Keyword cLineFeedKeyword_2 = (Keyword)cAlternatives.eContents().get(2); + private final Keyword cLineFeedKeyword_3 = (Keyword)cAlternatives.eContents().get(3); + private final Keyword cCarriageReturnKeyword_4 = (Keyword)cAlternatives.eContents().get(4); + private final Keyword cTabKeyword_5 = (Keyword)cAlternatives.eContents().get(5); + private final Keyword cBackslashKeyword_6 = (Keyword)cAlternatives.eContents().get(6); + + //BS_ESCAPE: + // '\b' | '\f' | '\n' | 'lineFeed' | '\r' | '\t' | '\\'; + @Override public ParserRule getRule() { return rule; } + + //'\b' | '\f' | '\n' | 'lineFeed' | '\r' | '\t' | '\\' + public Alternatives getAlternatives() { return cAlternatives; } + + //'\b' + public Keyword getBackspaceKeyword_0() { return cBackspaceKeyword_0; } + + //'\f' + public Keyword getFormFeedKeyword_1() { return cFormFeedKeyword_1; } + + //'\n' + public Keyword getLineFeedKeyword_2() { return cLineFeedKeyword_2; } + + //'lineFeed' + public Keyword getLineFeedKeyword_3() { return cLineFeedKeyword_3; } + + //'\r' + public Keyword getCarriageReturnKeyword_4() { return cCarriageReturnKeyword_4; } + + //'\t' + public Keyword getTabKeyword_5() { return cTabKeyword_5; } + + //'\\' + public Keyword getBackslashKeyword_6() { return cBackslashKeyword_6; } + } + + + private final ModelElements pModel; + private final BS_ESCAPEElements pBS_ESCAPE; + private final TerminalRule tID; + private final TerminalRule tWS; + private final TerminalRule tANY_OTHER; + + private final Grammar grammar; + + @Inject + public Bug406914TestLanguageGrammarAccess(GrammarProvider grammarProvider) { + this.grammar = internalFindGrammar(grammarProvider); + this.pModel = new ModelElements(); + this.pBS_ESCAPE = new BS_ESCAPEElements(); + this.tID = (TerminalRule) GrammarUtil.findRuleForName(getGrammar(), "org.eclipse.xtext.parser.antlr.Bug406914TestLanguage.ID"); + this.tWS = (TerminalRule) GrammarUtil.findRuleForName(getGrammar(), "org.eclipse.xtext.parser.antlr.Bug406914TestLanguage.WS"); + this.tANY_OTHER = (TerminalRule) GrammarUtil.findRuleForName(getGrammar(), "org.eclipse.xtext.parser.antlr.Bug406914TestLanguage.ANY_OTHER"); + } + + protected Grammar internalFindGrammar(GrammarProvider grammarProvider) { + Grammar grammar = grammarProvider.getGrammar(this); + while (grammar != null) { + if ("org.eclipse.xtext.parser.antlr.Bug406914TestLanguage".equals(grammar.getName())) { + return grammar; + } + List grammars = grammar.getUsedGrammars(); + if (!grammars.isEmpty()) { + grammar = grammars.iterator().next(); + } else { + return null; + } + } + return grammar; + } + + @Override + public Grammar getGrammar() { + return grammar; + } + + + + //Model: + // name=ID BS_ESCAPE; + public ModelElements getModelAccess() { + return pModel; + } + + public ParserRule getModelRule() { + return getModelAccess().getRule(); + } + + //BS_ESCAPE: + // '\b' | '\f' | '\n' | 'lineFeed' | '\r' | '\t' | '\\'; + public BS_ESCAPEElements getBS_ESCAPEAccess() { + return pBS_ESCAPE; + } + + public ParserRule getBS_ESCAPERule() { + return getBS_ESCAPEAccess().getRule(); + } + + //terminal ID: + // '^'? ('a'..'z' | 'A'..'Z' | '_') ('a'..'z' | 'A'..'Z' | '_' | '0'..'9')*; + public TerminalRule getIDRule() { + return tID; + } + + //terminal WS: + // ' ' | '\t'+; + public TerminalRule getWSRule() { + return tWS; + } + + //terminal ANY_OTHER: + // .; + public TerminalRule getANY_OTHERRule() { + return tANY_OTHER; + } +} diff --git a/org.eclipse.xtext.tests/src/org/eclipse/xtext/GenerateAllTestLanguages.mwe2 b/org.eclipse.xtext.tests/src/org/eclipse/xtext/GenerateAllTestLanguages.mwe2 index 97a9f3e17..bdf8d24bb 100644 --- a/org.eclipse.xtext.tests/src/org/eclipse/xtext/GenerateAllTestLanguages.mwe2 +++ b/org.eclipse.xtext.tests/src/org/eclipse/xtext/GenerateAllTestLanguages.mwe2 @@ -282,12 +282,14 @@ Workflow { ignoreCase = true } } + language = { grammarUri = "classpath:/org/eclipse/xtext/parser/antlr/Bug301935TestLanguage.xtext" fragment = @TestLanguagesFragments { generateStub = true } } + language = { grammarUri = "classpath:/org/eclipse/xtext/parser/antlr/Bug378967TestLanguage.xtext" fragment = @TestLanguagesFragments {} @@ -302,6 +304,10 @@ Workflow { grammarUri = "classpath:/org/eclipse/xtext/parser/antlr/Bug443221TestLanguage.xtext" fragment = @TestLanguagesFragments {} } + language = { + grammarUri = "classpath:/org/eclipse/xtext/parser/antlr/Bug406914TestLanguage.xtext" + fragment = @TestLanguagesFragments {} + } language = { grammarUri = "classpath:/org/eclipse/xtext/parser/assignments/AssignmentsTestLanguage.xtext" fragment = @TestLanguagesFragments {} diff --git a/org.eclipse.xtext.tests/src/org/eclipse/xtext/parser/antlr/Bug406914TestLanguage.xtext b/org.eclipse.xtext.tests/src/org/eclipse/xtext/parser/antlr/Bug406914TestLanguage.xtext new file mode 100644 index 000000000..3670a1161 --- /dev/null +++ b/org.eclipse.xtext.tests/src/org/eclipse/xtext/parser/antlr/Bug406914TestLanguage.xtext @@ -0,0 +1,25 @@ +/******************************************************************************* + * Copyright (c) 2016 itemis AG (http://www.itemis.eu) and others. + * All rights reserved. This program and the accompanying materials + * are made available under the terms of the Eclipse Public License v1.0 + * which accompanies this distribution, and is available at + * http://www.eclipse.org/legal/epl-v10.html + *******************************************************************************/ +grammar org.eclipse.xtext.parser.antlr.Bug406914TestLanguage + +generate bug406914Test "http://eclipse.org/xtext/Bug406914TestLanguage" +import "http://www.eclipse.org/emf/2002/Ecore" + +Model: + name=ID BS_ESCAPE +; + +BS_ESCAPE: + '\b' | '\f' | '\n' | 'lineFeed' | '\r' | '\t' | '\\' +; + +terminal ID : '^'?('a'..'z'|'A'..'Z'|'_') ('a'..'z'|'A'..'Z'|'_'|'0'..'9')*; + +terminal WS : (' '|'\t')+; + +terminal ANY_OTHER: .; \ No newline at end of file diff --git a/org.eclipse.xtext.tests/src/org/eclipse/xtext/parser/antlr/Bug406914TestLanguageRuntimeModule.java b/org.eclipse.xtext.tests/src/org/eclipse/xtext/parser/antlr/Bug406914TestLanguageRuntimeModule.java new file mode 100644 index 000000000..dff9b3b38 --- /dev/null +++ b/org.eclipse.xtext.tests/src/org/eclipse/xtext/parser/antlr/Bug406914TestLanguageRuntimeModule.java @@ -0,0 +1,11 @@ +/* + * generated by Xtext + */ +package org.eclipse.xtext.parser.antlr; + + +/** + * Use this class to register components to be used at runtime / without the Equinox extension registry. + */ +public class Bug406914TestLanguageRuntimeModule extends AbstractBug406914TestLanguageRuntimeModule { +} diff --git a/org.eclipse.xtext.tests/src/org/eclipse/xtext/parser/antlr/Bug406914TestLanguageStandaloneSetup.java b/org.eclipse.xtext.tests/src/org/eclipse/xtext/parser/antlr/Bug406914TestLanguageStandaloneSetup.java new file mode 100644 index 000000000..f61cb93a3 --- /dev/null +++ b/org.eclipse.xtext.tests/src/org/eclipse/xtext/parser/antlr/Bug406914TestLanguageStandaloneSetup.java @@ -0,0 +1,15 @@ +/* + * generated by Xtext + */ +package org.eclipse.xtext.parser.antlr; + + +/** + * Initialization support for running Xtext languages without Equinox extension registry. + */ +public class Bug406914TestLanguageStandaloneSetup extends Bug406914TestLanguageStandaloneSetupGenerated { + + public static void doSetup() { + new Bug406914TestLanguageStandaloneSetup().createInjectorAndDoEMFRegistration(); + } +} diff --git a/org.eclipse.xtext.tests/src/org/eclipse/xtext/parser/antlr/GenerateAntlrParserTestLanguages.mwe2 b/org.eclipse.xtext.tests/src/org/eclipse/xtext/parser/antlr/GenerateAntlrParserTestLanguages.mwe2 index 08a7a2041..e732e305f 100644 --- a/org.eclipse.xtext.tests/src/org/eclipse/xtext/parser/antlr/GenerateAntlrParserTestLanguages.mwe2 +++ b/org.eclipse.xtext.tests/src/org/eclipse/xtext/parser/antlr/GenerateAntlrParserTestLanguages.mwe2 @@ -40,7 +40,6 @@ Workflow { preferXtendStubs = false } } - language = { grammarUri = "classpath:/org/eclipse/xtext/parser/antlr/Bug289515TestLanguage.xtext" fragment = @TestLanguagesFragments {} @@ -93,5 +92,9 @@ Workflow { ignoreCase = true } } + language = { + grammarUri = "classpath:/org/eclipse/xtext/parser/antlr/Bug406914TestLanguage.xtext" + fragment = @TestLanguagesFragments {} + } } } diff --git a/org.eclipse.xtext.tests/src/org/eclipse/xtext/parser/antlr/serializer/Bug301935TestLanguageSemanticSequencer.java b/org.eclipse.xtext.tests/src/org/eclipse/xtext/parser/antlr/serializer/Bug301935TestLanguageSemanticSequencer.java deleted file mode 100644 index ae137e1ea..000000000 --- a/org.eclipse.xtext.tests/src/org/eclipse/xtext/parser/antlr/serializer/Bug301935TestLanguageSemanticSequencer.java +++ /dev/null @@ -1,8 +0,0 @@ -/* - * generated by Xtext - */ -package org.eclipse.xtext.parser.antlr.serializer; - - -public class Bug301935TestLanguageSemanticSequencer extends AbstractBug301935TestLanguageSemanticSequencer { -} diff --git a/org.eclipse.xtext.tests/src/org/eclipse/xtext/parser/antlr/serializer/Bug301935TestLanguageSyntacticSequencer.java b/org.eclipse.xtext.tests/src/org/eclipse/xtext/parser/antlr/serializer/Bug301935TestLanguageSyntacticSequencer.java deleted file mode 100644 index 415ec7e9b..000000000 --- a/org.eclipse.xtext.tests/src/org/eclipse/xtext/parser/antlr/serializer/Bug301935TestLanguageSyntacticSequencer.java +++ /dev/null @@ -1,8 +0,0 @@ -/* - * generated by Xtext - */ -package org.eclipse.xtext.parser.antlr.serializer; - - -public class Bug301935TestLanguageSyntacticSequencer extends AbstractBug301935TestLanguageSyntacticSequencer { -} diff --git a/org.eclipse.xtext.xtext.generator/src/org/eclipse/xtext/xtext/generator/grammarAccess/GrammarAccessExtensions.xtend b/org.eclipse.xtext.xtext.generator/src/org/eclipse/xtext/xtext/generator/grammarAccess/GrammarAccessExtensions.xtend index e2b78bd2f..5955cb259 100644 --- a/org.eclipse.xtext.xtext.generator/src/org/eclipse/xtext/xtext/generator/grammarAccess/GrammarAccessExtensions.xtend +++ b/org.eclipse.xtext.xtext.generator/src/org/eclipse/xtext/xtext/generator/grammarAccess/GrammarAccessExtensions.xtend @@ -54,9 +54,18 @@ import org.eclipse.xtext.Parameter * This API can be used by other templates to generate code * that has hard references to grammar rules/elements * @author Moritz Eysholdt + * @author Karsten Thoms - bug#406914 */ class GrammarAccessExtensions { - + // see http://userguide.icu-project.org/strings/unicodeset BACKSLASH ESCAPES + static Map SPECIAL_CHARS = #{ + "\b" -> "backspace", + "\f" -> "formFeed", + "\n" -> "lineFeed", + "\r" -> "carriageReturn", + "\t" -> "tab", + "\\" -> "backslash" + }; val Map xtextSerializerByLineDelimiter = Maps.newHashMapWithExpectedSize(2) val transliterator = Transliterator.getInstance('Any-Name') @@ -107,6 +116,11 @@ class GrammarAccessExtensions { } private def String toJavaIdentifierSegment(String text, boolean isFirst, boolean uppercaseFirst) { + val special = SPECIAL_CHARS.get(text); + if (special != null) { + return if (uppercaseFirst) special.toFirstUpper else special + } + val r = toJavaIdentifierSegmentInt(text, isFirst, uppercaseFirst) if (r.length > 0) { return r @@ -181,7 +195,7 @@ class GrammarAccessExtensions { /** * Creates an identifier for an AbstractElement which is a valid Java identifier and - * which is unique whithin the element's rule. The identifier tries to be as + * which is unique within the element's rule. The identifier tries to be as * human-readable as possible. */ def String gaElementIdentifier(AbstractElement element) { diff --git a/org.eclipse.xtext.xtext.generator/xtend-gen/org/eclipse/xtext/xtext/generator/grammarAccess/GrammarAccessExtensions.java b/org.eclipse.xtext.xtext.generator/xtend-gen/org/eclipse/xtext/xtext/generator/grammarAccess/GrammarAccessExtensions.java index 8320c08f4..4b5c1923a 100644 --- a/org.eclipse.xtext.xtext.generator/xtend-gen/org/eclipse/xtext/xtext/generator/grammarAccess/GrammarAccessExtensions.java +++ b/org.eclipse.xtext.xtext.generator/xtend-gen/org/eclipse/xtext/xtext/generator/grammarAccess/GrammarAccessExtensions.java @@ -17,6 +17,7 @@ import com.google.inject.Injector; import com.ibm.icu.text.Transliterator; import java.util.ArrayList; import java.util.Arrays; +import java.util.Collections; import java.util.Iterator; import java.util.List; import java.util.Map; @@ -57,6 +58,7 @@ import org.eclipse.xtext.xbase.lib.Extension; import org.eclipse.xtext.xbase.lib.Functions.Function1; import org.eclipse.xtext.xbase.lib.IterableExtensions; import org.eclipse.xtext.xbase.lib.ListExtensions; +import org.eclipse.xtext.xbase.lib.Pair; import org.eclipse.xtext.xbase.lib.StringExtensions; import org.eclipse.xtext.xtext.RuleNames; import org.eclipse.xtext.xtext.generator.CodeConfig; @@ -69,6 +71,7 @@ import org.eclipse.xtext.xtext.generator.parser.antlr.AntlrOptions; * This API can be used by other templates to generate code * that has hard references to grammar rules/elements * @author Moritz Eysholdt + * @author Karsten Thoms - bug#406914 */ @SuppressWarnings("all") public class GrammarAccessExtensions { @@ -92,6 +95,8 @@ public class GrammarAccessExtensions { } } + private static Map SPECIAL_CHARS = Collections.unmodifiableMap(CollectionLiterals.newHashMap(Pair.of("\b", "backspace"), Pair.of("\f", "formFeed"), Pair.of("\n", "lineFeed"), Pair.of("\r", "carriageReturn"), Pair.of("\t", "tab"), Pair.of("\\", "backslash"))); + private final Map xtextSerializerByLineDelimiter = Maps.newHashMapWithExpectedSize(2); private final Transliterator transliterator = Transliterator.getInstance("Any-Name"); @@ -170,6 +175,17 @@ public class GrammarAccessExtensions { } private String toJavaIdentifierSegment(final String text, final boolean isFirst, final boolean uppercaseFirst) { + final String special = GrammarAccessExtensions.SPECIAL_CHARS.get(text); + boolean _notEquals = (!Objects.equal(special, null)); + if (_notEquals) { + String _xifexpression = null; + if (uppercaseFirst) { + _xifexpression = StringExtensions.toFirstUpper(special); + } else { + _xifexpression = special; + } + return _xifexpression; + } final String r = this.toJavaIdentifierSegmentInt(text, isFirst, uppercaseFirst); int _length = r.length(); boolean _greaterThan = (_length > 0); @@ -181,8 +197,8 @@ public class GrammarAccessExtensions { for (final char c : _charArray) { { final String n = this.getUnicodeName(c); - boolean _notEquals = (!Objects.equal(n, null)); - if (_notEquals) { + boolean _notEquals_1 = (!Objects.equal(n, null)); + if (_notEquals_1) { builder.append((n + " ")); } } @@ -278,7 +294,7 @@ public class GrammarAccessExtensions { /** * Creates an identifier for an AbstractElement which is a valid Java identifier and - * which is unique whithin the element's rule. The identifier tries to be as + * which is unique within the element's rule. The identifier tries to be as * human-readable as possible. */ public String gaElementIdentifier(final AbstractElement element) {