Changeset 12 in default for trunk/de.ugoe.cs.swe.bnftools.ebnf.ui/src/de/ugoe/cs/swe/bnftools/ui
- Timestamp:
- 10/22/10 15:45:35 (14 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/de.ugoe.cs.swe.bnftools.ebnf.ui/src/de/ugoe/cs/swe/bnftools/ui/formatter/EbnfFormatterVisitor.java
r11 r12 3 3 import org.eclipse.emf.common.util.EList; 4 4 import org.eclipse.emf.ecore.EObject; 5 6 import com.sun.xml.internal.bind.v2.schemagen.xmlschema.Import;7 5 8 6 import de.ugoe.cs.swe.bnftools.ebnf.Atom; … … 13 11 import de.ugoe.cs.swe.bnftools.ebnf.GroupedSequence; 14 12 import de.ugoe.cs.swe.bnftools.ebnf.HookCombinator; 13 import de.ugoe.cs.swe.bnftools.ebnf.Import; 15 14 import de.ugoe.cs.swe.bnftools.ebnf.MergeRule; 16 15 import de.ugoe.cs.swe.bnftools.ebnf.OptionalSequence; … … 29 28 private FormatterConfig config; 30 29 30 int ruleCounter = 0; 31 31 32 public EbnfFormatterVisitor(EObject rootNode, FormatterConfig config) { 32 33 super(rootNode); … … 67 68 68 69 protected void visitAfter(Term node) { 69 SingleDefinition parent = (SingleDefinition) node.eContainer(); 70 int index = parent.getTerms().indexOf(node); 71 if ((parent.getTerms().size() > 0) && (index < parent.getTerms().size()-1)) 70 if (!isLastElement()) 72 71 buf.append(" "); 73 72 } … … 106 105 107 106 protected void visitBefore(Import node) { 107 buf.append("import \"" + node.getImportURI() + "\";\n"); 108 108 } 109 109 … … 118 118 119 119 protected void visitBefore(OptionalSequence node) { 120 buf.append("["); 120 121 } 121 122 122 123 protected void visitAfter(OptionalSequence node) { 124 buf.append("]"); 123 125 } 124 126 125 127 protected void visitBefore(RepeatedSequence node) { 128 buf.append("{"); 126 129 } 127 130 128 131 protected void visitAfter(RepeatedSequence node) { 132 buf.append("}"); 133 if (node.isMorethanonce()) 134 buf.append("+"); 129 135 } 130 136 131 137 protected void visitBefore(Rule node) { 138 if (ruleCounter == 0) 139 buf.append("\n"); 140 141 ruleCounter++; 132 142 if (node.getRulenumber() > 0) 133 143 buf.append(node.getRulenumber() + ". "); … … 147 157 148 158 protected void visitBefore(RuleReference node) { 159 buf.append(node.getRuleref().getName()); 149 160 } 150 161 … … 162 173 163 174 protected void visitAfter(SingleDefinition node) { 175 if (!isLastElement()) 176 buf.append(" | "); 177 164 178 } 165 179 … … 168 182 buf.append("\"" + node.getLiteral() + "\""); 169 183 else if (node.getColon() != null) 170 buf.append(" " + node.getColon());184 buf.append("\"\"\""); 171 185 } 172 186
Note: See TracChangeset
for help on using the changeset viewer.