Changeset 11 in default for trunk/de.ugoe.cs.swe.bnftools.ebnf.ui/src/de/ugoe/cs/swe/bnftools/visitor
- Timestamp:
- 10/22/10 14:53:37 (14 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/de.ugoe.cs.swe.bnftools.ebnf.ui/src/de/ugoe/cs/swe/bnftools/visitor/EbnfVisitor.java
r9 r11 1 1 package de.ugoe.cs.swe.bnftools.visitor; 2 2 3 import java.util.Collections;4 5 import org.eclipse.emf.common.util.TreeIterator;6 3 import org.eclipse.emf.ecore.EObject; 7 import org.eclipse.emf.ecore.util.EcoreUtil;8 4 9 5 import com.sun.xml.internal.bind.v2.schemagen.xmlschema.Import; … … 28 24 29 25 public abstract class EbnfVisitor { 26 30 27 protected EObject rootNode = null; 31 28 … … 43 40 44 41 public void accept(EObject node) { 45 TreeIterator<Object> it = EcoreUtil.getAllContents(Collections 46 .singleton(node)); 47 48 while (it.hasNext()) { 49 EObject currentNode = (EObject) it.next(); 50 dispatcher(currentNode); 42 dispatcherBefore(node); 43 acceptInner(node); 44 dispatcherAfter(node); 45 } 46 47 private void acceptInner(EObject node) { 48 for (int i=0; i < node.eContents().size(); i++) { 49 EObject currentNode = (EObject) node.eContents().get(i); 50 dispatcherBefore(currentNode); 51 acceptInner(currentNode); 52 dispatcherAfter(currentNode); 51 53 } 52 54 } 53 54 protected void dispatcher (EObject node) {55 56 protected void dispatcherBefore(EObject node) { 55 57 // ugly, but no time to find a prettier solution 56 58 if (node instanceof EtsiBnf) { 57 visit ((EtsiBnf) node);59 visitBefore((EtsiBnf) node); 58 60 } else if (node instanceof Atom) { 59 visit ((Atom) node);61 visitBefore((Atom) node); 60 62 } else if (node instanceof DefinitionList) { 61 visit ((DefinitionList) node);63 visitBefore((DefinitionList) node); 62 64 } else if (node instanceof ExtRule) { 63 visit ((ExtRule) node);65 visitBefore((ExtRule) node); 64 66 } else if (node instanceof GlobalCombinator) { 65 visit ((GlobalCombinator) node);67 visitBefore((GlobalCombinator) node); 66 68 } else if (node instanceof GroupedSequence) { 67 visit ((GroupedSequence) node);69 visitBefore((GroupedSequence) node); 68 70 } else if (node instanceof HookCombinator) { 69 visit ((HookCombinator) node);71 visitBefore((HookCombinator) node); 70 72 } else if (node instanceof Import) { 71 visit ((Import) node);73 visitBefore((Import) node); 72 74 } else if (node instanceof MergeRule) { 73 visit ((MergeRule) node);75 visitBefore((MergeRule) node); 74 76 } else if (node instanceof OptionalSequence) { 75 visit ((OptionalSequence) node);77 visitBefore((OptionalSequence) node); 76 78 } else if (node instanceof RepeatedSequence) { 77 visit ((RepeatedSequence) node);79 visitBefore((RepeatedSequence) node); 78 80 } else if (node instanceof Rule) { 79 visit ((Rule) node);81 visitBefore((Rule) node); 80 82 } else if (node instanceof RuleCombinator) { 81 visit ((RuleCombinator) node);83 visitBefore((RuleCombinator) node); 82 84 } else if (node instanceof RuleReference) { 83 visit ((RuleReference) node);85 visitBefore((RuleReference) node); 84 86 } else if (node instanceof SectionHeading) { 85 visit ((SectionHeading) node);87 visitBefore((SectionHeading) node); 86 88 } else if (node instanceof SingleDefinition) { 87 visit ((SingleDefinition) node);89 visitBefore((SingleDefinition) node); 88 90 } else if (node instanceof StringRule) { 89 visit ((StringRule) node);91 visitBefore((StringRule) node); 90 92 } else if (node instanceof Term) { 91 visit ((Term) node);93 visitBefore((Term) node); 92 94 } 93 95 } 94 96 95 protected void visit(EtsiBnf node) { 96 } 97 98 protected void visit(Atom node) { 99 } 100 101 protected void visit(DefinitionList node) { 102 } 103 104 protected void visit(ExtRule node) { 105 } 106 107 protected void visit(GlobalCombinator node) { 108 } 109 110 protected void visit(GroupedSequence node) { 111 } 112 113 protected void visit(HookCombinator node) { 114 } 115 116 protected void visit(Import node) { 117 } 118 119 protected void visit(MergeRule node) { 120 } 121 122 protected void visit(OptionalSequence node) { 123 } 124 125 protected void visit(RepeatedSequence node) { 126 } 127 128 protected void visit(Rule node) { 129 } 130 131 protected void visit(RuleCombinator node) { 132 } 133 134 protected void visit(RuleReference node) { 135 } 136 137 protected void visit(SectionHeading node) { 138 } 139 140 protected void visit(SingleDefinition node) { 141 } 142 143 protected void visit(StringRule node) { 144 } 145 146 protected void visit(Term node) { 147 } 148 97 protected void dispatcherAfter(EObject node) { 98 // ugly, but no time to find a prettier solution 99 if (node instanceof EtsiBnf) { 100 visitAfter((EtsiBnf) node); 101 } else if (node instanceof Atom) { 102 visitAfter((Atom) node); 103 } else if (node instanceof DefinitionList) { 104 visitAfter((DefinitionList) node); 105 } else if (node instanceof ExtRule) { 106 visitAfter((ExtRule) node); 107 } else if (node instanceof GlobalCombinator) { 108 visitAfter((GlobalCombinator) node); 109 } else if (node instanceof GroupedSequence) { 110 visitAfter((GroupedSequence) node); 111 } else if (node instanceof HookCombinator) { 112 visitAfter((HookCombinator) node); 113 } else if (node instanceof Import) { 114 visitAfter((Import) node); 115 } else if (node instanceof MergeRule) { 116 visitAfter((MergeRule) node); 117 } else if (node instanceof OptionalSequence) { 118 visitAfter((OptionalSequence) node); 119 } else if (node instanceof RepeatedSequence) { 120 visitAfter((RepeatedSequence) node); 121 } else if (node instanceof Rule) { 122 visitAfter((Rule) node); 123 } else if (node instanceof RuleCombinator) { 124 visitAfter((RuleCombinator) node); 125 } else if (node instanceof RuleReference) { 126 visitAfter((RuleReference) node); 127 } else if (node instanceof SectionHeading) { 128 visitAfter((SectionHeading) node); 129 } else if (node instanceof SingleDefinition) { 130 visitAfter((SingleDefinition) node); 131 } else if (node instanceof StringRule) { 132 visitAfter((StringRule) node); 133 } else if (node instanceof Term) { 134 visitAfter((Term) node); 135 } 136 } 137 138 protected void visitBefore(EtsiBnf node) { 139 } 140 141 protected void visitAfter(EtsiBnf node) { 142 } 143 144 protected void visitBefore(Atom node) { 145 } 146 147 protected void visitAfter(Atom node) { 148 } 149 150 protected void visitBefore(Term node) { 151 } 152 153 protected void visitAfter(Term node) { 154 } 155 156 protected void visitBefore(DefinitionList node) { 157 } 158 159 protected void visitAfter(DefinitionList node) { 160 } 161 162 protected void visitBefore(ExtRule node) { 163 } 164 165 protected void visitAfter(ExtRule node) { 166 } 167 168 protected void visitBefore(GlobalCombinator node) { 169 } 170 171 protected void visitAfter(GlobalCombinator node) { 172 } 173 174 protected void visitBefore(GroupedSequence node) { 175 } 176 177 protected void visitAfter(GroupedSequence node) { 178 } 179 180 protected void visitBefore(HookCombinator node) { 181 } 182 183 protected void visitAfter(HookCombinator node) { 184 } 185 186 protected void visitBefore(Import node) { 187 } 188 189 protected void visitAfter(Import node) { 190 } 191 192 protected void visitBefore(MergeRule node) { 193 } 194 195 protected void visitAfter(MergeRule node) { 196 } 197 198 protected void visitBefore(OptionalSequence node) { 199 } 200 201 protected void visitAfter(OptionalSequence node) { 202 } 203 204 protected void visitBefore(RepeatedSequence node) { 205 } 206 207 protected void visitAfter(RepeatedSequence node) { 208 } 209 210 protected void visitBefore(Rule node) { 211 } 212 213 protected void visitAfter(Rule node) { 214 } 215 216 protected void visitBefore(RuleCombinator node) { 217 } 218 219 protected void visitAfter(RuleCombinator node) { 220 } 221 222 protected void visitBefore(RuleReference node) { 223 } 224 225 protected void visitAfter(RuleReference node) { 226 } 227 228 protected void visitBefore(SectionHeading node) { 229 } 230 231 protected void visitAfter(SectionHeading node) { 232 } 233 234 protected void visitBefore(SingleDefinition node) { 235 } 236 237 protected void visitAfter(SingleDefinition node) { 238 } 239 240 protected void visitBefore(StringRule node) { 241 } 242 243 protected void visitAfter(StringRule node) { 244 } 245 149 246 }
Note: See TracChangeset
for help on using the changeset viewer.