Index: /trunk/de.ugoe.cs.swe.bnftools.ebnf.ui/src/de/ugoe/cs/swe/bnftools/ui/formatter/EbnfFormatterVisitor.java
===================================================================
--- /trunk/de.ugoe.cs.swe.bnftools.ebnf.ui/src/de/ugoe/cs/swe/bnftools/ui/formatter/EbnfFormatterVisitor.java	(revision 26)
+++ /trunk/de.ugoe.cs.swe.bnftools.ebnf.ui/src/de/ugoe/cs/swe/bnftools/ui/formatter/EbnfFormatterVisitor.java	(revision 27)
@@ -257,5 +257,16 @@
 	}
 
-	
+	private void newLine() {
+		buf.append("\n");
+	}
+	
+	private void text(String str) {
+		buf.append(str);
+	}
+
+	private void space() {
+		buf.append(" ");
+	}
+
 	// -----------------------------------------------------------------------------
 
@@ -267,10 +278,11 @@
 		
 		//System.out.println(allComments.toString());
-		buf.append("grammar " + node.getName());
+		text("grammar " + node.getName());
 		if (node.getType() != null)
-			buf.append(node.getType());
-		buf.append(";");
-
-		buf.append("\n\n");
+			text(node.getType());
+		text(";");
+
+		newLine();
+		newLine();
 	}
 
@@ -283,5 +295,5 @@
 
 	protected void visitAfter(ImportSection node) {
-		buf.append("\n");
+		newLine();
 	}
 
@@ -315,5 +327,5 @@
 	protected void visitAfter(Term node) {
 		if (!isLastElement())
-			buf.append(" ");
+			space();
 	}
 
@@ -337,9 +349,9 @@
 
 	protected void visitBefore(GroupedSequence node) {
-		buf.append("(");
+		text("(");
 	}
 
 	protected void visitAfter(GroupedSequence node) {
-		buf.append(")");
+		text(")");
 	}
 
@@ -351,6 +363,6 @@
 
 	protected void visitBefore(Import node) {
-		buf.append("import \"" + node.getImportURI() + "\";");
-		buf.append("\n");
+		text("import \"" + node.getImportURI() + "\";");
+		newLine();
 	}
 
@@ -365,37 +377,36 @@
 
 	protected void visitBefore(OptionalSequence node) {
-		buf.append("[");
+		text("[");
 	}
 
 	protected void visitAfter(OptionalSequence node) {
-		buf.append("]");
+		text("]");
 	}
 
 	protected void visitBefore(RepeatedSequence node) {
-		buf.append("{");
+		text("{");
 	}
 
 	protected void visitAfter(RepeatedSequence node) {
-		buf.append("}");
+		text("}");
 		if (node.isMorethanonce())
-			buf.append("+");
+			text("+");
 	}
 
 	protected void visitBefore(Rule node) {
 		if (lastWasSectionHeading)
-			buf.append("\n");
+			newLine();
 		
 		lastWasSectionHeading=false;
 
 		if (node.getRulenumber() > 0)
-			buf.append(node.getRulenumber() + ". ");
-		
-		buf.append(node.getName() + " ::= ");
+			text(node.getRulenumber() + ". ");
+		
+		text(node.getName() + " ::= ");
 	}
 
 	protected void visitAfter(Rule node) {
-		buf.append(";");
-//		appendComments(node);
-		buf.append("\n");
+		text(";");
+		newLine();
 	}
 
@@ -407,5 +418,5 @@
 
 	protected void visitBefore(RuleReference node) {
-		buf.append(node.getRuleref().getName());
+		text(node.getRuleref().getName());
 	}
 
@@ -415,5 +426,5 @@
 	protected void visitBefore(SectionHeading node) {
 		if (!lastWasSectionHeading && !buf.substring(buf.length()-2).equals("\n\n"))
-			buf.append("\n");
+			newLine();
 		
 		lastWasSectionHeading=true;
@@ -422,9 +433,8 @@
 //			buf.append("\n");
 		
-		buf.append(node.getSectionHeader());
+		text(node.getSectionHeader());
 	}
 
 	protected void visitAfter(SectionHeading node) {
-//		buf.append("\n");
 	}
 
@@ -434,5 +444,5 @@
 	protected void visitAfter(SingleDefinition node) {
 		if (!isLastElement())
-			buf.append(" | ");
+			text(" | ");
 		
 	}
@@ -440,13 +450,11 @@
 	protected void visitBefore(StringRule node) {
 		if (node.getLiteral() != null)
-			buf.append("\"" + node.getLiteral() + "\"");
+			text("\"" + node.getLiteral() + "\"");
 		else if (node.getColon() != null)
-			buf.append("\"\"\"");
+			text("\"\"\"");
 	}
 
 	protected void visitAfter(StringRule node) {
 	}
-
-	
 	
 }
