Changeset 65 in default for v2/trunk/de.ugoe.cs.swe.bnftools.ebnf/src
- Timestamp:
- 05/07/14 16:02:46 (11 years ago)
- Location:
- v2/trunk/de.ugoe.cs.swe.bnftools.ebnf/src/de/ugoe/cs/swe/bnftools
- Files:
-
- 6 edited
Legend:
- Unmodified
- Added
- Removed
-
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.