[9] | 1 | package de.ugoe.cs.swe.bnftools.ui.formatter;
|
---|
| 2 |
|
---|
| 3 | import org.eclipse.emf.ecore.EObject;
|
---|
| 4 |
|
---|
| 5 | import com.sun.xml.internal.bind.v2.schemagen.xmlschema.Import;
|
---|
| 6 |
|
---|
| 7 | import de.ugoe.cs.swe.bnftools.ebnf.Atom;
|
---|
| 8 | import de.ugoe.cs.swe.bnftools.ebnf.DefinitionList;
|
---|
| 9 | import de.ugoe.cs.swe.bnftools.ebnf.EtsiBnf;
|
---|
| 10 | import de.ugoe.cs.swe.bnftools.ebnf.ExtRule;
|
---|
| 11 | import de.ugoe.cs.swe.bnftools.ebnf.GlobalCombinator;
|
---|
| 12 | import de.ugoe.cs.swe.bnftools.ebnf.GroupedSequence;
|
---|
| 13 | import de.ugoe.cs.swe.bnftools.ebnf.HookCombinator;
|
---|
| 14 | import de.ugoe.cs.swe.bnftools.ebnf.MergeRule;
|
---|
| 15 | import de.ugoe.cs.swe.bnftools.ebnf.OptionalSequence;
|
---|
| 16 | import de.ugoe.cs.swe.bnftools.ebnf.RepeatedSequence;
|
---|
| 17 | import de.ugoe.cs.swe.bnftools.ebnf.Rule;
|
---|
| 18 | import de.ugoe.cs.swe.bnftools.ebnf.RuleCombinator;
|
---|
| 19 | import de.ugoe.cs.swe.bnftools.ebnf.RuleReference;
|
---|
| 20 | import de.ugoe.cs.swe.bnftools.ebnf.SectionHeading;
|
---|
| 21 | import de.ugoe.cs.swe.bnftools.ebnf.SingleDefinition;
|
---|
| 22 | import de.ugoe.cs.swe.bnftools.ebnf.StringRule;
|
---|
| 23 | import de.ugoe.cs.swe.bnftools.ebnf.Term;
|
---|
| 24 | import de.ugoe.cs.swe.bnftools.visitor.EbnfVisitor;
|
---|
| 25 |
|
---|
| 26 | public class EbnfFormatterVisitor extends EbnfVisitor {
|
---|
| 27 | private StringBuffer buf;
|
---|
| 28 | private FormatterConfig config;
|
---|
| 29 |
|
---|
| 30 | public EbnfFormatterVisitor(EObject rootNode, FormatterConfig config) {
|
---|
| 31 | super(rootNode);
|
---|
| 32 | this.config = config;
|
---|
| 33 | buf = new StringBuffer();
|
---|
| 34 | }
|
---|
| 35 |
|
---|
| 36 | public EbnfFormatterVisitor(FormatterConfig config) {
|
---|
| 37 | this.config = config;
|
---|
| 38 | buf = new StringBuffer();
|
---|
| 39 | }
|
---|
| 40 |
|
---|
| 41 | public StringBuffer getBuf() {
|
---|
| 42 | return buf;
|
---|
| 43 | }
|
---|
| 44 |
|
---|
| 45 | // -----------------------------------------------------------------------------
|
---|
| 46 |
|
---|
| 47 | protected void visit(EtsiBnf node) {
|
---|
| 48 | buf.append("grammar " + node.getName());
|
---|
| 49 | if (node.getType() != null)
|
---|
| 50 | buf.append(node.getType());
|
---|
| 51 | buf.append(";");
|
---|
| 52 | }
|
---|
| 53 |
|
---|
| 54 | protected void visit(Atom node) {
|
---|
| 55 | }
|
---|
| 56 |
|
---|
| 57 | protected void visit(DefinitionList node) {
|
---|
| 58 | }
|
---|
| 59 |
|
---|
| 60 | protected void visit(ExtRule node) {
|
---|
| 61 | }
|
---|
| 62 |
|
---|
| 63 | protected void visit(GlobalCombinator node) {
|
---|
| 64 | }
|
---|
| 65 |
|
---|
| 66 | protected void visit(GroupedSequence node) {
|
---|
| 67 | }
|
---|
| 68 |
|
---|
| 69 | protected void visit(HookCombinator node) {
|
---|
| 70 | }
|
---|
| 71 |
|
---|
| 72 | protected void visit(Import node) {
|
---|
| 73 | }
|
---|
| 74 |
|
---|
| 75 | protected void visit(MergeRule node) {
|
---|
| 76 | }
|
---|
| 77 |
|
---|
| 78 | protected void visit(OptionalSequence node) {
|
---|
| 79 | }
|
---|
| 80 |
|
---|
| 81 | protected void visit(RepeatedSequence node) {
|
---|
| 82 | }
|
---|
| 83 |
|
---|
| 84 | protected void visit(Rule node) {
|
---|
| 85 | }
|
---|
| 86 |
|
---|
| 87 | protected void visit(RuleCombinator node) {
|
---|
| 88 | }
|
---|
| 89 |
|
---|
| 90 | protected void visit(RuleReference node) {
|
---|
| 91 | }
|
---|
| 92 |
|
---|
| 93 | protected void visit(SectionHeading node) {
|
---|
| 94 | }
|
---|
| 95 |
|
---|
| 96 | protected void visit(SingleDefinition node) {
|
---|
| 97 | }
|
---|
| 98 |
|
---|
| 99 | protected void visit(StringRule node) {
|
---|
| 100 | }
|
---|
| 101 |
|
---|
| 102 | protected void visit(Term node) {
|
---|
| 103 | }
|
---|
| 104 |
|
---|
| 105 | }
|
---|