Changeset 11 in default for trunk/de.ugoe.cs.swe.bnftools.ebnf.ui/src/de/ugoe/cs/swe/bnftools/ui
- Timestamp:
- 10/22/10 14:53:37 (14 years ago)
- Location:
- trunk/de.ugoe.cs.swe.bnftools.ebnf.ui/src/de/ugoe/cs/swe/bnftools/ui/formatter
- Files:
-
- 2 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/de.ugoe.cs.swe.bnftools.ebnf.ui/src/de/ugoe/cs/swe/bnftools/ui/formatter/EbnfFormatterVisitor.java
r10 r11 1 1 package de.ugoe.cs.swe.bnftools.ui.formatter; 2 2 3 import org.eclipse.emf.common.util.EList; 3 4 import org.eclipse.emf.ecore.EObject; 4 5 … … 45 46 // ----------------------------------------------------------------------------- 46 47 47 protected void visit (EtsiBnf node) {48 protected void visitBefore(EtsiBnf node) { 48 49 buf.append("grammar " + node.getName()); 49 50 if (node.getType() != null) 50 51 buf.append(node.getType()); 51 52 buf.append(";"); 53 buf.append("\n\n"); 52 54 } 53 55 54 protected void visit (Atomnode) {56 protected void visitAfter(EtsiBnf node) { 55 57 } 56 58 57 protected void visit (DefinitionListnode) {59 protected void visitBefore(Atom node) { 58 60 } 59 61 60 protected void visit (ExtRulenode) {62 protected void visitAfter(Atom node) { 61 63 } 62 64 63 protected void visit (GlobalCombinatornode) {65 protected void visitBefore(Term node) { 64 66 } 65 67 66 protected void visit(GroupedSequence node) { 68 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)) 72 buf.append(" "); 67 73 } 68 74 69 protected void visit (HookCombinatornode) {75 protected void visitBefore(DefinitionList node) { 70 76 } 71 77 72 protected void visit (Import node) {78 protected void visitAfter(DefinitionList node) { 73 79 } 74 80 75 protected void visit (MergeRule node) {81 protected void visitBefore(ExtRule node) { 76 82 } 77 83 78 protected void visit (OptionalSequence node) {84 protected void visitAfter(ExtRule node) { 79 85 } 80 86 81 protected void visit (RepeatedSequencenode) {87 protected void visitBefore(GlobalCombinator node) { 82 88 } 83 89 84 protected void visit (Rulenode) {90 protected void visitAfter(GlobalCombinator node) { 85 91 } 86 92 87 protected void visit(RuleCombinator node) { 93 protected void visitBefore(GroupedSequence node) { 94 buf.append("("); 88 95 } 89 96 90 protected void visit(RuleReference node) { 97 protected void visitAfter(GroupedSequence node) { 98 buf.append(")"); 91 99 } 92 100 93 protected void visit (SectionHeadingnode) {101 protected void visitBefore(HookCombinator node) { 94 102 } 95 103 96 protected void visit (SingleDefinitionnode) {104 protected void visitAfter(HookCombinator node) { 97 105 } 98 106 99 protected void visit (StringRulenode) {107 protected void visitBefore(Import node) { 100 108 } 101 109 102 protected void visit (Termnode) {110 protected void visitAfter(Import node) { 103 111 } 104 112 113 protected void visitBefore(MergeRule node) { 114 } 115 116 protected void visitAfter(MergeRule node) { 117 } 118 119 protected void visitBefore(OptionalSequence node) { 120 } 121 122 protected void visitAfter(OptionalSequence node) { 123 } 124 125 protected void visitBefore(RepeatedSequence node) { 126 } 127 128 protected void visitAfter(RepeatedSequence node) { 129 } 130 131 protected void visitBefore(Rule node) { 132 if (node.getRulenumber() > 0) 133 buf.append(node.getRulenumber() + ". "); 134 135 buf.append(node.getName() + " ::= "); 136 } 137 138 protected void visitAfter(Rule node) { 139 buf.append(";\n"); 140 } 141 142 protected void visitBefore(RuleCombinator node) { 143 } 144 145 protected void visitAfter(RuleCombinator node) { 146 } 147 148 protected void visitBefore(RuleReference node) { 149 } 150 151 protected void visitAfter(RuleReference node) { 152 } 153 154 protected void visitBefore(SectionHeading node) { 155 } 156 157 protected void visitAfter(SectionHeading node) { 158 } 159 160 protected void visitBefore(SingleDefinition node) { 161 } 162 163 protected void visitAfter(SingleDefinition node) { 164 } 165 166 protected void visitBefore(StringRule node) { 167 if (node.getLiteral() != null) 168 buf.append("\"" + node.getLiteral() + "\""); 169 else if (node.getColon() != null) 170 buf.append(" " + node.getColon()); 171 } 172 173 protected void visitAfter(StringRule node) { 174 } 175 176 177 105 178 } -
trunk/de.ugoe.cs.swe.bnftools.ebnf.ui/src/de/ugoe/cs/swe/bnftools/ui/formatter/FormatterProcessor.java
r9 r11 104 104 105 105 FormatterConfig config = new FormatterConfig(); 106 EbnfFormatterVisitor visitor = new EbnfFormatterVisitor( rootNode.getElement(),config);107 visitor.accept( );106 EbnfFormatterVisitor visitor = new EbnfFormatterVisitor(config); 107 visitor.accept(rootNode.getElement()); 108 108 109 109 ReplaceEdit replaceEdit = new ReplaceEdit(0, document.getLength(), visitor.getBuf().toString());
Note: See TracChangeset
for help on using the changeset viewer.