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.ebnf.impl.EtsiBnfImpl;
|
---|
25 | import de.ugoe.cs.swe.bnftools.visitor.EbnfVisitor;
|
---|
26 |
|
---|
27 | public class EbnfFormatterVisitor extends EbnfVisitor {
|
---|
28 | private StringBuffer buf;
|
---|
29 | private FormatterConfig config;
|
---|
30 |
|
---|
31 | public EbnfFormatterVisitor(EObject rootNode, FormatterConfig config) {
|
---|
32 | super(rootNode);
|
---|
33 | this.config = config;
|
---|
34 | buf = new StringBuffer();
|
---|
35 | }
|
---|
36 |
|
---|
37 | public EbnfFormatterVisitor(FormatterConfig config) {
|
---|
38 | this.config = config;
|
---|
39 | buf = new StringBuffer();
|
---|
40 | }
|
---|
41 |
|
---|
42 | public StringBuffer getBuf() {
|
---|
43 | return buf;
|
---|
44 | }
|
---|
45 |
|
---|
46 | // -----------------------------------------------------------------------------
|
---|
47 |
|
---|
48 | protected void visit(EtsiBnf node) {
|
---|
49 | buf.append("grammar " + node.getName());
|
---|
50 | if (node.getType() != null)
|
---|
51 | buf.append(node.getType());
|
---|
52 | buf.append(";");
|
---|
53 | }
|
---|
54 |
|
---|
55 | protected void visit(Atom node) {
|
---|
56 | }
|
---|
57 |
|
---|
58 | protected void visit(DefinitionList node) {
|
---|
59 | }
|
---|
60 |
|
---|
61 | protected void visit(ExtRule node) {
|
---|
62 | }
|
---|
63 |
|
---|
64 | protected void visit(GlobalCombinator node) {
|
---|
65 | }
|
---|
66 |
|
---|
67 | protected void visit(GroupedSequence node) {
|
---|
68 | }
|
---|
69 |
|
---|
70 | protected void visit(HookCombinator node) {
|
---|
71 | }
|
---|
72 |
|
---|
73 | protected void visit(Import node) {
|
---|
74 | }
|
---|
75 |
|
---|
76 | protected void visit(MergeRule node) {
|
---|
77 | }
|
---|
78 |
|
---|
79 | protected void visit(OptionalSequence node) {
|
---|
80 | }
|
---|
81 |
|
---|
82 | protected void visit(RepeatedSequence node) {
|
---|
83 | }
|
---|
84 |
|
---|
85 | protected void visit(Rule node) {
|
---|
86 | }
|
---|
87 |
|
---|
88 | protected void visit(RuleCombinator node) {
|
---|
89 | }
|
---|
90 |
|
---|
91 | protected void visit(RuleReference node) {
|
---|
92 | }
|
---|
93 |
|
---|
94 | protected void visit(SectionHeading node) {
|
---|
95 | }
|
---|
96 |
|
---|
97 | protected void visit(SingleDefinition node) {
|
---|
98 | }
|
---|
99 |
|
---|
100 | protected void visit(StringRule node) {
|
---|
101 | }
|
---|
102 |
|
---|
103 | protected void visit(Term node) {
|
---|
104 | }
|
---|
105 |
|
---|
106 | }
|
---|