- Timestamp:
- 05/07/14 16:02:46 (11 years ago)
- Location:
- v2/trunk
- Files:
-
- 16 deleted
- 12 edited
Legend:
- Unmodified
- Added
- Removed
-
v2/trunk/de.ugoe.cs.swe.bnftools.ebnf.ui/src-gen/de/ugoe/cs/swe/bnftools/ui/AbstractEbnfUiModule.java
r61 r65 39 39 } 40 40 41 // contributed by org.eclipse.xtext.generator.exporting. QualifiedNamesFragment41 // contributed by org.eclipse.xtext.generator.exporting.SimpleNamesFragment 42 42 public Class<? extends org.eclipse.xtext.ui.refactoring.IDependentElementsCalculator> bindIDependentElementsCalculator() { 43 43 return org.eclipse.xtext.ui.refactoring.impl.DefaultDependentElementsCalculator.class; 44 }45 46 // contributed by org.eclipse.xtext.generator.builder.BuilderIntegrationFragment47 public void configureIResourceDescriptionsBuilderScope(com.google.inject.Binder binder) {48 binder.bind(org.eclipse.xtext.resource.IResourceDescriptions.class).annotatedWith(com.google.inject.name.Names.named(org.eclipse.xtext.resource.impl.ResourceDescriptionsProvider.NAMED_BUILDER_SCOPE)).to(org.eclipse.xtext.builder.clustering.CurrentDescriptions.ResourceSetAware.class);49 }50 51 // contributed by org.eclipse.xtext.generator.builder.BuilderIntegrationFragment52 public Class<? extends org.eclipse.xtext.ui.editor.IXtextEditorCallback> bindIXtextEditorCallback() {53 return org.eclipse.xtext.builder.nature.NatureAddingEditorCallback.class;54 }55 56 // contributed by org.eclipse.xtext.generator.builder.BuilderIntegrationFragment57 public void configureIResourceDescriptionsPersisted(com.google.inject.Binder binder) {58 binder.bind(org.eclipse.xtext.resource.IResourceDescriptions.class).annotatedWith(com.google.inject.name.Names.named(org.eclipse.xtext.builder.impl.PersistentDataAwareDirtyResource.PERSISTED_DESCRIPTIONS)).to(org.eclipse.xtext.builder.builderState.IBuilderState.class);59 }60 61 // contributed by org.eclipse.xtext.generator.builder.BuilderIntegrationFragment62 public Class<? extends org.eclipse.xtext.ui.editor.DocumentBasedDirtyResource> bindDocumentBasedDirtyResource() {63 return org.eclipse.xtext.builder.impl.PersistentDataAwareDirtyResource.class;64 44 } 65 45 … … 154 134 } 155 135 156 // contributed by org.eclipse.xtext.generator.types.TypesGeneratorFragment157 public java.lang.ClassLoader bindClassLoaderToInstance() {158 return getClass().getClassLoader();159 }160 161 // contributed by org.eclipse.xtext.generator.types.TypesGeneratorFragment162 public Class<? extends org.eclipse.xtext.common.types.access.IJvmTypeProvider.Factory> bindIJvmTypeProvider$Factory() {163 return org.eclipse.xtext.common.types.access.jdt.JdtTypeProviderFactory.class;164 }165 166 // contributed by org.eclipse.xtext.generator.types.TypesGeneratorFragment167 public Class<? extends org.eclipse.xtext.common.types.xtext.AbstractTypeScopeProvider> bindAbstractTypeScopeProvider() {168 return org.eclipse.xtext.common.types.xtext.ui.JdtBasedSimpleTypeScopeProvider.class;169 }170 171 // contributed by org.eclipse.xtext.generator.types.TypesGeneratorFragment172 public Class<? extends org.eclipse.xtext.common.types.xtext.ui.ITypesProposalProvider> bindITypesProposalProvider() {173 return org.eclipse.xtext.common.types.xtext.ui.JdtTypesProposalProvider.class;174 }175 176 // contributed by org.eclipse.xtext.generator.types.TypesGeneratorFragment177 public Class<? extends org.eclipse.xtext.common.types.access.jdt.IJavaProjectProvider> bindIJavaProjectProvider() {178 return org.eclipse.xtext.common.types.xtext.ui.XtextResourceSetBasedProjectProvider.class;179 }180 181 // contributed by org.eclipse.xtext.generator.types.TypesGeneratorFragment182 public Class<? extends org.eclipse.xtext.ui.editor.hyperlinking.IHyperlinkHelper> bindIHyperlinkHelper() {183 return org.eclipse.xtext.common.types.xtext.ui.TypeAwareHyperlinkHelper.class;184 }185 186 // contributed by org.eclipse.xtext.generator.types.TypesGeneratorFragment187 public Class<? extends org.eclipse.xtext.ui.editor.contentassist.PrefixMatcher> bindPrefixMatcher() {188 return org.eclipse.xtext.ui.editor.contentassist.FQNPrefixMatcher.class;189 }190 191 // contributed by org.eclipse.xtext.generator.types.TypesGeneratorFragment192 public Class<? extends org.eclipse.xtext.ui.editor.contentassist.AbstractJavaBasedContentProposalProvider.ReferenceProposalCreator> bindAbstractJavaBasedContentProposalProvider$ReferenceProposalCreator() {193 return org.eclipse.xtext.common.types.xtext.ui.TypeAwareReferenceProposalCreator.class;194 }195 196 // contributed by org.eclipse.xtext.generator.types.TypesGeneratorFragment197 public Class<? extends org.eclipse.xtext.ui.editor.IValidationJobScheduler> bindIValidationJobScheduler() {198 return org.eclipse.xtext.common.types.xtext.ui.JdtValidationJobScheduler.class;199 }200 201 // contributed by org.eclipse.xtext.generator.types.TypesGeneratorFragment202 public Class<? extends org.eclipse.xtext.ui.refactoring.impl.RefactoringResourceSetProvider> bindRefactoringResourceSetProvider() {203 return org.eclipse.xtext.common.types.ui.refactoring.JvmRefactoringResourceSetProvider.class;204 }205 206 // contributed by org.eclipse.xtext.generator.types.TypesGeneratorFragment207 public Class<? extends org.eclipse.xtext.common.types.ui.query.IJavaSearchParticipation> bindIJavaSearchParticipation() {208 return org.eclipse.xtext.common.types.ui.query.IJavaSearchParticipation.Yes.class;209 }210 211 136 // contributed by org.eclipse.xtext.ui.generator.templates.CodetemplatesGeneratorFragment 212 137 public com.google.inject.Provider<org.eclipse.xtext.ui.codetemplates.ui.preferences.TemplatesLanguageConfiguration> provideTemplatesLanguageConfiguration() { -
v2/trunk/de.ugoe.cs.swe.bnftools.ebnf.ui/src/de/ugoe/cs/swe/bnftools/ui/quickfix/EbnfQuickfixProvider.xtend
r64 r65 27 27 */ 28 28 class EbnfQuickfixProvider extends org.eclipse.xtext.ui.editor.quickfix.DefaultQuickfixProvider { 29 30 //***************************************************************************************** 29 31 //works 30 32 @Fix(EbnfValidator.ruleReferencedOneDescription) … … 37 39 ) [ element, context | 38 40 var Rule rule = element as Rule; 41 39 42 var IXtextDocument xtextDocument = context.getXtextDocument(); 40 43 var ICompositeNode node = NodeModelUtils.findActualNodeFor(rule); … … 50 53 var boolean foundRule = false; 51 54 var EObject r = references.get(0) as EObject; 52 var Rule containingRule =null;55 var Rule containingRule = null; 53 56 while (!foundRule) { 54 57 r = r.eContainer; … … 69 72 } 70 73 } 71 72 73 // delete rule 74 xtextDocument.replace(offset, textLength, ""); 74 // delete rule 75 xtextDocument.replace(offset, textLength, ""); 75 76 ] 76 77 77 78 } 78 79 80 //***************************************************************************************** 81 82 // @Fix(EbnfValidator.passthroughRuleDescription) 83 // def void fixRemovePassthroughRule(Issue issue, IssueResolutionAcceptor acceptor) { 84 // acceptor.accept( 85 // issue, 86 // "Remove passthrough rule", 87 // "Delete the passthrough rule and replace its references with its right side", 88 // "upcase.png", 89 // [ element, context | 90 // var Rule rule = element as Rule; 91 // var IXtextDocument xtextDocument = context.getXtextDocument(); 92 // var ICompositeNode node = NodeModelUtils.findActualNodeFor(rule); 93 // var String nodeText = node.text; 94 // var int textLength = nodeText.length - 2; 95 // var int offset = node.textRegion.offset; 96 // var ICompositeNode dList = NodeModelUtils.findActualNodeFor(rule.definitionList); 97 // var String refText = "(" + dList.text + ")"; 98 // var int refLength = rule.name.length; 99 // var List<RuleReference> references = EbnfAnalysisUtils.findReferences(rule); 100 // //sort references by offset 101 // var int i = 0; 102 // var List<RuleReference> referenceHleper = new ArrayList<RuleReference>(); 103 // while(i<references.length){ 104 // 105 // i++; 106 // } 107 // for (ruleRef : references) { 108 // var ICompositeNode refNode = NodeModelUtils.findActualNodeFor(ruleRef); 109 // var int refOffset = refNode.textRegion.offset; 110 // 111 // xtextDocument.replace(refOffset, refLength, refText); 112 // if (refOffset < offset) { 113 // offset += refText.length - refLength; 114 // } 115 // } 116 // ] 117 // ); 118 // } 119 120 //***************************************************************************************** 79 121 //works 80 // @Fix(EbnfValidator.passthroughRuleDescription) 81 // def void fixRemovePassthroughRule(Issue issue, IssueResolutionAcceptor acceptor) { 82 // acceptor.accept( 83 // issue, 84 // "Remove passthrough rule", 85 // "Delete the passthrough rule and replace its references with its right side", 86 // "upcase.png", 87 // [ element, context | 88 // var Rule rule = element as Rule; 89 // var IXtextDocument xtextDocument = context.getXtextDocument(); 90 // var ICompositeNode node = NodeModelUtils.findActualNodeFor(rule); 91 // var String nodeText = node.text; 92 // var int textLength = nodeText.length - 2; 93 // var int offset = node.textRegion.offset; 94 // var ICompositeNode dList = NodeModelUtils.findActualNodeFor(rule.definitionList); 95 // var String refText = "(" + dList.text + ")"; 96 // var int refLength = rule.name.length; 97 // var List<RuleReference> references = EbnfAnalysisUtils.findReferences(rule); 98 // //sort references by offset 99 // var int i = 0; 100 // var List<RuleReference> referenceHleper = new ArrayList<RuleReference>(); 101 // while(i<references.length){ 102 // 103 // i++; 104 // } 105 // for (ruleRef : references) { 106 // var ICompositeNode refNode = NodeModelUtils.findActualNodeFor(ruleRef); 107 // var int refOffset = refNode.textRegion.offset; 108 // 109 // xtextDocument.replace(refOffset, refLength, refText); 110 // if (refOffset < offset) { 111 // offset += refText.length - refLength; 112 // } 113 // } 114 // ] 115 // ); 116 // } 117 118 @Fix(EbnfValidator.unusedRuleDescription) 122 @Fix(EbnfValidator.unusedRuleDescription) 119 123 def void fixUnusedRule(Issue issue, IssueResolutionAcceptor acceptor) { 120 124 … … 131 135 } 132 136 } 133 -
v2/trunk/de.ugoe.cs.swe.bnftools.ebnf/src-gen/de/ugoe/cs/swe/bnftools/AbstractEbnfRuntimeModule.java
r61 r65 35 35 } 36 36 37 // contributed by org.eclipse.xtext.generator.grammarAccess.GrammarAccessFragment 38 public java.lang.ClassLoader bindClassLoaderToInstance() { 39 return getClass().getClassLoader(); 40 } 41 37 42 // contributed by org.eclipse.xtext.generator.grammarAccess.GrammarAccessFragment 38 43 public Class<? extends org.eclipse.xtext.IGrammarAccess> bindIGrammarAccess() { … … 102 107 // contributed by org.eclipse.xtext.generator.scoping.AbstractScopingFragment 103 108 public void configureIScopeProviderDelegate(com.google.inject.Binder binder) { 104 binder.bind(org.eclipse.xtext.scoping.IScopeProvider.class).annotatedWith(com.google.inject.name.Names.named(org.eclipse.xtext.scoping.impl.AbstractDeclarativeScopeProvider.NAMED_DELEGATE)).to(org.eclipse.xtext.scoping.impl.ImportedNamespaceAwareLocalScopeProvider.class); 109 binder.bind(org.eclipse.xtext.scoping.IScopeProvider.class).annotatedWith(com.google.inject.name.Names.named(org.eclipse.xtext.scoping.impl.AbstractDeclarativeScopeProvider.NAMED_DELEGATE)).to(org.eclipse.xtext.scoping.impl.SimpleLocalScopeProvider.class); 110 } 111 112 // contributed by org.eclipse.xtext.generator.scoping.AbstractScopingFragment 113 public Class<? extends org.eclipse.xtext.scoping.IGlobalScopeProvider> bindIGlobalScopeProvider() { 114 return org.eclipse.xtext.scoping.impl.ImportUriGlobalScopeProvider.class; 105 115 } 106 116 … … 110 120 } 111 121 112 // contributed by org.eclipse.xtext.generator.exporting. QualifiedNamesFragment122 // contributed by org.eclipse.xtext.generator.exporting.SimpleNamesFragment 113 123 public Class<? extends org.eclipse.xtext.naming.IQualifiedNameProvider> bindIQualifiedNameProvider() { 114 return org.eclipse.xtext.naming.DefaultDeclarativeQualifiedNameProvider.class; 115 } 116 117 // contributed by org.eclipse.xtext.generator.builder.BuilderIntegrationFragment 118 public Class<? extends org.eclipse.xtext.resource.IContainer.Manager> bindIContainer$Manager() { 119 return org.eclipse.xtext.resource.containers.StateBasedContainerManager.class; 120 } 121 122 // contributed by org.eclipse.xtext.generator.builder.BuilderIntegrationFragment 123 public Class<? extends org.eclipse.xtext.resource.containers.IAllContainersState.Provider> bindIAllContainersState$Provider() { 124 return org.eclipse.xtext.resource.containers.ResourceSetBasedAllContainersStateProvider.class; 125 } 126 127 // contributed by org.eclipse.xtext.generator.builder.BuilderIntegrationFragment 128 public void configureIResourceDescriptions(com.google.inject.Binder binder) { 129 binder.bind(org.eclipse.xtext.resource.IResourceDescriptions.class).to(org.eclipse.xtext.resource.impl.ResourceSetBasedResourceDescriptions.class); 130 } 131 132 // contributed by org.eclipse.xtext.generator.builder.BuilderIntegrationFragment 133 public void configureIResourceDescriptionsBuilderScope(com.google.inject.Binder binder) { 134 binder.bind(org.eclipse.xtext.resource.IResourceDescriptions.class).annotatedWith(com.google.inject.name.Names.named(org.eclipse.xtext.resource.impl.ResourceDescriptionsProvider.NAMED_BUILDER_SCOPE)).to(org.eclipse.xtext.resource.impl.ResourceSetBasedResourceDescriptions.class); 124 return org.eclipse.xtext.naming.SimpleNameProvider.class; 135 125 } 136 126 … … 145 135 } 146 136 147 // contributed by org.eclipse.xtext.generator.types.TypesGeneratorFragment148 public java.lang.ClassLoader bindClassLoaderToInstance() {149 return getClass().getClassLoader();150 }151 152 // contributed by org.eclipse.xtext.generator.types.TypesGeneratorFragment153 public org.eclipse.xtext.common.types.TypesFactory bindTypesFactoryToInstance() {154 return org.eclipse.xtext.common.types.TypesFactory.eINSTANCE;155 }156 157 // contributed by org.eclipse.xtext.generator.types.TypesGeneratorFragment158 public Class<? extends org.eclipse.xtext.common.types.access.IJvmTypeProvider.Factory> bindIJvmTypeProvider$Factory() {159 return org.eclipse.xtext.common.types.access.ClasspathTypeProviderFactory.class;160 }161 162 // contributed by org.eclipse.xtext.generator.types.TypesGeneratorFragment163 public Class<? extends org.eclipse.xtext.common.types.xtext.AbstractTypeScopeProvider> bindAbstractTypeScopeProvider() {164 return org.eclipse.xtext.common.types.xtext.ClasspathBasedTypeScopeProvider.class;165 }166 167 // contributed by org.eclipse.xtext.generator.types.TypesGeneratorFragment168 public Class<? extends org.eclipse.xtext.scoping.IGlobalScopeProvider> bindIGlobalScopeProvider() {169 return org.eclipse.xtext.common.types.xtext.TypesAwareDefaultGlobalScopeProvider.class;170 }171 172 137 } -
v2/trunk/de.ugoe.cs.swe.bnftools.ebnf/src-gen/de/ugoe/cs/swe/bnftools/serializer/EbnfSyntacticSequencer.java
r61 r65 77 77 * ( 78 78 '{' | 79 '+' | 79 80 '}' | 81 '*' | 82 ')' | 80 83 '|' | 81 '+' |82 '*' |83 84 '[' | 84 ']' |85 85 '(' | 86 ' )'86 ']' 87 87 )* 88 88 */ -
v2/trunk/de.ugoe.cs.swe.bnftools.ebnf/src-gen/de/ugoe/cs/swe/bnftools/services/EbnfGrammarAccess.java
r61 r65 379 379 private final Keyword cSemicolonKeyword_4 = (Keyword)cGroup.eContents().get(4); 380 380 381 ////Import: 'import' importedNamespace=FqnWithWildCard; 382 ////FqnWithWildCard: Fqn('.*')? ';'; 383 ////Fqn:ID('.'ID)*; 381 384 //Rule: 382 385 // (rulenumber=INT rulevariant=ID? ".")? name=ID "::=" definitionList=DefinitionList? ";"?; … … 1150 1153 } 1151 1154 1155 ////Import: 'import' importedNamespace=FqnWithWildCard; 1156 ////FqnWithWildCard: Fqn('.*')? ';'; 1157 ////Fqn:ID('.'ID)*; 1152 1158 //Rule: 1153 1159 // (rulenumber=INT rulevariant=ID? ".")? name=ID "::=" definitionList=DefinitionList? ";"?; -
v2/trunk/de.ugoe.cs.swe.bnftools.ebnf/src-gen/de/ugoe/cs/swe/bnftools/validation/AbstractEbnfValidator.java
r61 r65 7 7 import java.util.List; 8 8 import org.eclipse.emf.ecore.EPackage; 9 import org.eclipse.xtext.validation.ComposedChecks; 9 10 11 @ComposedChecks(validators= {org.eclipse.xtext.validation.ImportUriValidator.class, org.eclipse.xtext.validation.NamesAreUniqueValidator.class}) 10 12 public class AbstractEbnfValidator extends org.eclipse.xtext.validation.AbstractDeclarativeValidator { 11 13 -
v2/trunk/de.ugoe.cs.swe.bnftools.ebnf/src/de/ugoe/cs/swe/bnftools/EBNF.xtext
r61 r65 53 53 ('label:' label=ID)? ';' 54 54 ; 55 56 //Import: 'import' importedNamespace=FqnWithWildCard; 57 //FqnWithWildCard: Fqn('.*')? ';'; 58 //Fqn:ID('.'ID)*; 59 55 60 56 61 Rule: -
v2/trunk/de.ugoe.cs.swe.bnftools.ebnf/src/de/ugoe/cs/swe/bnftools/GenerateEBNF.mwe2
r61 r65 73 73 // Xtend-based API for validation 74 74 fragment = validation.ValidatorFragment auto-inject { 75 //composedCheck = "org.eclipse.xtext.validation.ImportUriValidator"76 //composedCheck = "org.eclipse.xtext.validation.NamesAreUniqueValidator"75 composedCheck = "org.eclipse.xtext.validation.ImportUriValidator" 76 composedCheck = "org.eclipse.xtext.validation.NamesAreUniqueValidator" 77 77 } 78 78 79 79 // old scoping and exporting API 80 //fragment = scoping.ImportURIScopingFragment auto-inject {}81 //fragment = exporting.SimpleNamesFragment auto-inject {}80 fragment = scoping.ImportURIScopingFragment auto-inject {} 81 fragment = exporting.SimpleNamesFragment auto-inject {} 82 82 83 83 // scoping and exporting API 84 fragment = scoping.ImportNamespacesScopingFragment auto-inject {}85 fragment = exporting.QualifiedNamesFragment auto-inject {}86 fragment = builder.BuilderIntegrationFragment auto-inject {}84 // fragment = scoping.ImportNamespacesScopingFragment auto-inject {} 85 // fragment = exporting.QualifiedNamesFragment auto-inject {} 86 // fragment = builder.BuilderIntegrationFragment auto-inject {} 87 87 88 88 // generator API … … 115 115 116 116 // provides the necessary bindings for java types integration 117 fragment = types.TypesGeneratorFragment auto-inject {}117 // fragment = types.TypesGeneratorFragment auto-inject {} 118 118 119 119 // generates the required bindings only if the grammar inherits from Xbase -
v2/trunk/de.ugoe.cs.swe.bnftools.ebnf/src/de/ugoe/cs/swe/bnftools/formatting/EbnfFormatter.xtend
r63 r65 9 9 import org.eclipse.xtext.formatting.impl.AbstractDeclarativeFormatter 10 10 import org.eclipse.xtext.formatting.impl.FormattingConfig 11 import org.eclipse.emf.ecore.EObject 12 import de.ugoe.cs.swe.bnftools.ebnf.Rule 13 import de.ugoe.cs.swe.bnftools.ebnf.DefinitionList 11 14 12 15 /** … … 29 32 c.setLinewrap(0, 1, 1).after(ML_COMMENTRule) 30 33 31 32 34 var EbnfGrammarAccess f = getGrammarAccess as EbnfGrammarAccess; 33 35 c.setLinewrap.before(f.ruleRule); 34 36 c.setLinewrap.before(f.importRule); 35 37 c.setNoSpace.after(f.ruleAccess.rulenumberINTTerminalRuleCall_0_0_0) 36 // //c.setLinewrap.after(f.); 38 39 37 40 // for (Keyword bar : f.findKeywords("|")) { 41 // 38 42 // c.setSpace("\n\t\t").before(bar); 39 43 // } -
v2/trunk/de.ugoe.cs.swe.bnftools.ebnf/src/de/ugoe/cs/swe/bnftools/generator/EbnfGenerator.xtend
r63 r65 19 19 import de.ugoe.cs.swe.bnftools.ebnf.RuleReference 20 20 import de.ugoe.cs.swe.bnftools.ebnf.StringRule 21 import java.io.File 21 22 22 23 /** … … 30 31 for (e : resource.allContents.toIterable.filter(EtsiBnf)) { 31 32 if (e.bnfEntry.size!=0) { 32 fsa.generateFile(e.name + ".fo", e.compile)33 fsa.generateFile(e.name + ".fo", e.compile) 33 34 } 34 35 } … … 50 51 <fo:page-sequence master-reference="A4"> 51 52 <fo:flow flow-name="xsl-region-body" font-family="verdana"> 53 54 <fo:block span="all" text-align="center" text-indent="1em" font-family="Arial" font-size="20pt" font-weight="bold" background-color="#EEEEEE" line-height="20mm">«bnf.name»</fo:block> 55 52 56 «FOR bnfentry:bnf.bnfEntry» 53 57 «bnfentry.compile» … … 63 67 ''' 64 68 65 def compile(Rule rule)'''<fo:block><fo:inline id="«rule.name»" color="purple">«IF rule.rulenumber!=0»«rule.rulenumber». \t«ENDIF»«rule.name»</fo:inline> ::= «rule.definitionList.compile»</block>'''69 def compile(Rule rule)'''<fo:block><fo:inline id="«rule.name»" color="purple">«IF rule.rulenumber!=0»«rule.rulenumber». «ENDIF»«rule.name»</fo:inline> ::= «rule.definitionList.compile»</fo:block>''' 66 70 67 71 def compile(DefinitionList dList)'''«FOR sDef:dList.singleDefinition»«sDef.compile»«IF !sDef.equals(dList.singleDefinition.last)» | «ENDIF»«ENDFOR»''' … … 80 84 «IF atom.atomRuleReference!= null»«atom.atomRuleReference.compile»«ENDIF»«IF atom.atomStringRule!= null»«atom.atomStringRule.compile»«ENDIF»''' 81 85 82 def compile(RuleReference rRef)'''<fo:basic-link internal-destination="«rRef.ruleref.name»" text-decoration="underline" color="blue">«rRef.ruleref.name»</fo:basic-link> '''86 def compile(RuleReference rRef)'''<fo:basic-link internal-destination="«rRef.ruleref.name»" text-decoration="underline" color="blue">«rRef.ruleref.name»</fo:basic-link> ''' 83 87 84 def compile(StringRule sRule)'''«IF sRule.colon!=null»«sRule.colon»«ENDIF»«IF sRule.literal!=null»«sRule.literal» «ENDIF»'''88 def compile(StringRule sRule)'''«IF sRule.colon!=null»«sRule.colon»«ENDIF»«IF sRule.literal!=null»«sRule.literal» «ENDIF»''' 85 89 86 90 -
v2/trunk/de.ugoe.cs.swe.bnftools.ebnf/src/de/ugoe/cs/swe/bnftools/scoping/EbnfScopeProvider.xtend
r61 r65 3 3 */ 4 4 package de.ugoe.cs.swe.bnftools.scoping 5 6 //import org.eclipse.xtext.naming.IQualifiedNameConverter 7 //import com.google.inject.Inject 8 //import org.eclipse.xtext.scoping.impl.ImportUriGlobalScopeProvider 5 9 6 10 /** … … 13 17 class EbnfScopeProvider extends org.eclipse.xtext.scoping.impl.AbstractDeclarativeScopeProvider { 14 18 19 15 20 } -
v2/trunk/de.ugoe.cs.swe.bnftools.ebnf/src/de/ugoe/cs/swe/bnftools/validation/EbnfValidator.xtend
r63 r65 14 14 import de.ugoe.cs.swe.bnftools.ebnf.DefinitionList 15 15 import de.ugoe.cs.swe.bnftools.ebnf.SingleDefinition 16 import java.util.ArrayList 17 16 18 //import java.util.HashMap 17 19 //import java.util.Set 18 20 //import java.util.HashSet 19 20 21 //import org.eclipse.xtext.validation.Check 21 22 /** … … 32 33 public static final String equalAlternativeDescription = "The rule contains equal alternatives"; 33 34 public static final String duplicateRulesDescription = "The rule is a duplicate"; 35 34 36 //public static final String duplicateSubRulesDescription = "A part the of rule is a duplicate"; 35 37 public static final String nonUniqueNameDescription = "The rule has the same Name as the Rule in Line "; … … 49 51 50 52 if (references.size() == 1 && rule.rulenumber != 1) { 51 warning(ruleReferencedOneDescription, EbnfPackage$Literals::RULE__NAME,ruleReferencedOneDescription,rule.name); 53 warning(ruleReferencedOneDescription, EbnfPackage$Literals::RULE__NAME, ruleReferencedOneDescription, 54 rule.name); 52 55 } 53 56 } … … 75 78 76 79 // run through all Rules 77 for (currentRule : allRules) { 78 if (currentRule != rule) { 79 var ICompositeNode currentRuleDefinitionList = NodeModelUtils.findActualNodeFor( 80 currentRule.getDefinitionList()); 81 var String currentRuleRightHandSideText = currentRuleDefinitionList.text.trim().replaceAll("[ \t\n\r]", 82 ""); 83 84 if (currentRuleRightHandSideText.equals(rightHandSideText)) { 85 var String description = duplicateRulesDescription + " with rule \"" + currentRule.getName() + 86 "\" (Line " + NodeModelUtils.findActualNodeFor(currentRule).getStartLine() + ")"; 87 warning(description, EbnfPackage$Literals::RULE__NAME); 88 } 89 } 90 } 80 for (currentRule : allRules) { 81 if (currentRule != rule) { 82 var ICompositeNode currentRuleDefinitionList = NodeModelUtils.findActualNodeFor( 83 currentRule.getDefinitionList()); 84 var String currentRuleRightHandSideText = currentRuleDefinitionList.text.trim().replaceAll("[ \t\n\r]", 85 ""); 86 87 if (currentRuleRightHandSideText.equals(rightHandSideText)) { 88 var String description = duplicateRulesDescription + " with rule \"" + currentRule.getName() + 89 "\" (Line " + NodeModelUtils.findActualNodeFor(currentRule).getStartLine() + ")"; 90 warning(description, EbnfPackage$Literals::RULE__NAME); 91 } 92 } 93 } 94 95 // //get all Single Definitions as Trimmed Strings 96 // var List<String> singleDefsAsString = new ArrayList<String>(); 97 // 98 // for (SingleDefinition s : (rule.definitionList).singleDefinition) { 99 // singleDefsAsString.add(NodeModelUtils.findActualNodeFor(s).text.trim().replaceAll("[ \t\n\r]", "")); 100 // } 101 // 102 // // for every rule get the single definitions as Strings 103 // var int j = 0; 104 // while (j<allRules.size) { 105 // var currentRule=allRules.get(j); 106 // if (currentRule != rule) { 107 // var List<String> singleDefsAsString1 = new ArrayList<String>(); 108 // 109 // for (SingleDefinition s : ( currentRule.definitionList).singleDefinition) { 110 // singleDefsAsString1.add(NodeModelUtils.findActualNodeFor(s).text.trim().replaceAll("[ \t\n\r]", "")); 111 // } 112 // 113 // //for every String SingleDefinition find a corresponding ind the current rule 114 // if (singleDefsAsString.size == singleDefsAsString1.size) { 115 // var List<String> singleDefsAsStringCpy = singleDefsAsString.clone; 116 // var boolean equal = true; 117 // while (equal) { 118 // var String momentaryString = singleDefsAsStringCpy.get(0); 119 // var int i = 0; 120 // var boolean found = false; 121 // while (i < singleDefsAsString1.size && !found) { 122 // if (singleDefsAsString1.get(i).equals(momentaryString)) { 123 // singleDefsAsStringCpy.remove(0); 124 // singleDefsAsString1.remove(i); 125 // found = true 126 // } 127 // i++; 128 // } 129 // if (!found) { 130 // equal = false; 131 // } 132 // if (singleDefsAsStringCpy.empty) { 133 // var String description = duplicateRulesDescription + " with rule \"" + currentRule.getName() + 134 // "\" (Line " + NodeModelUtils.findActualNodeFor(currentRule).getStartLine() + ")"; 135 // warning(description, EbnfPackage$Literals::RULE__NAME) 136 // } 137 // } 138 // } 139 // 140 // } 141 // j++; 142 // } 91 143 } 92 144 … … 122 174 123 175 if ((references.size() == 0) && (rule.getRulenumber() != 1)) 124 warning(unusedRuleDescription, EbnfPackage$Literals::RULE__NAME, unusedRuleDescription,rule.name);176 warning(unusedRuleDescription, EbnfPackage$Literals::RULE__NAME, unusedRuleDescription, rule.name); 125 177 } 126 178 … … 144 196 145 197 if (d1.equals(d2)) 146 warning(equalAlternativeDescription, EbnfPackage$Literals::RULE__NAME,equalAlternativeDescription); 198 warning(equalAlternativeDescription, EbnfPackage$Literals::RULE__NAME, 199 equalAlternativeDescription, rule.name); 147 200 } 148 201 } … … 162 215 var List<RuleReference> references = EbnfAnalysisUtils.findReferences(rule); 163 216 164 if (EbnfAnalysisUtils.isPassthroughRule(rule) ) {217 if (EbnfAnalysisUtils.isPassthroughRule(rule) && rule.rulenumber != 1) { 165 218 if (references.size() == 0) { 166 219 warning(unreferencedPassthroughRuleDescription, EbnfPackage$Literals::RULE__NAME); 167 220 } else { 168 warning(passthroughRuleDescription, EbnfPackage$Literals::RULE__NAME,passthroughRuleDescription); 221 warning(passthroughRuleDescription, EbnfPackage$Literals::RULE__NAME, passthroughRuleDescription, 222 rule.name); 169 223 } 170 224 } 171 225 } 172 226 173 174 // ---------------------------------------------------------------------------------------------------- 175 /* Checks if a subrule is used more then once, e.g.: 227 // ---------------------------------------------------------------------------------------------------- 228 /* Checks if a subrule is used more then once, e.g.: 176 229 * a ::= (a b) e 177 230 * b ::= (a b) d
Note: See TracChangeset
for help on using the changeset viewer.