Changeset 27 in default


Ignore:
Timestamp:
11/02/10 15:59:35 (14 years ago)
Author:
zeiss
Message:
 
File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/de.ugoe.cs.swe.bnftools.ebnf.ui/src/de/ugoe/cs/swe/bnftools/ui/formatter/EbnfFormatterVisitor.java

    r26 r27  
    257257        } 
    258258 
    259          
     259        private void newLine() { 
     260                buf.append("\n"); 
     261        } 
     262         
     263        private void text(String str) { 
     264                buf.append(str); 
     265        } 
     266 
     267        private void space() { 
     268                buf.append(" "); 
     269        } 
     270 
    260271        // ----------------------------------------------------------------------------- 
    261272 
     
    267278                 
    268279                //System.out.println(allComments.toString()); 
    269                 buf.append("grammar " + node.getName()); 
     280                text("grammar " + node.getName()); 
    270281                if (node.getType() != null) 
    271                         buf.append(node.getType()); 
    272                 buf.append(";"); 
    273  
    274                 buf.append("\n\n"); 
     282                        text(node.getType()); 
     283                text(";"); 
     284 
     285                newLine(); 
     286                newLine(); 
    275287        } 
    276288 
     
    283295 
    284296        protected void visitAfter(ImportSection node) { 
    285                 buf.append("\n"); 
     297                newLine(); 
    286298        } 
    287299 
     
    315327        protected void visitAfter(Term node) { 
    316328                if (!isLastElement()) 
    317                         buf.append(" "); 
     329                        space(); 
    318330        } 
    319331 
     
    337349 
    338350        protected void visitBefore(GroupedSequence node) { 
    339                 buf.append("("); 
     351                text("("); 
    340352        } 
    341353 
    342354        protected void visitAfter(GroupedSequence node) { 
    343                 buf.append(")"); 
     355                text(")"); 
    344356        } 
    345357 
     
    351363 
    352364        protected void visitBefore(Import node) { 
    353                 buf.append("import \"" + node.getImportURI() + "\";"); 
    354                 buf.append("\n"); 
     365                text("import \"" + node.getImportURI() + "\";"); 
     366                newLine(); 
    355367        } 
    356368 
     
    365377 
    366378        protected void visitBefore(OptionalSequence node) { 
    367                 buf.append("["); 
     379                text("["); 
    368380        } 
    369381 
    370382        protected void visitAfter(OptionalSequence node) { 
    371                 buf.append("]"); 
     383                text("]"); 
    372384        } 
    373385 
    374386        protected void visitBefore(RepeatedSequence node) { 
    375                 buf.append("{"); 
     387                text("{"); 
    376388        } 
    377389 
    378390        protected void visitAfter(RepeatedSequence node) { 
    379                 buf.append("}"); 
     391                text("}"); 
    380392                if (node.isMorethanonce()) 
    381                         buf.append("+"); 
     393                        text("+"); 
    382394        } 
    383395 
    384396        protected void visitBefore(Rule node) { 
    385397                if (lastWasSectionHeading) 
    386                         buf.append("\n"); 
     398                        newLine(); 
    387399                 
    388400                lastWasSectionHeading=false; 
    389401 
    390402                if (node.getRulenumber() > 0) 
    391                         buf.append(node.getRulenumber() + ". "); 
    392                  
    393                 buf.append(node.getName() + " ::= "); 
     403                        text(node.getRulenumber() + ". "); 
     404                 
     405                text(node.getName() + " ::= "); 
    394406        } 
    395407 
    396408        protected void visitAfter(Rule node) { 
    397                 buf.append(";"); 
    398 //              appendComments(node); 
    399                 buf.append("\n"); 
     409                text(";"); 
     410                newLine(); 
    400411        } 
    401412 
     
    407418 
    408419        protected void visitBefore(RuleReference node) { 
    409                 buf.append(node.getRuleref().getName()); 
     420                text(node.getRuleref().getName()); 
    410421        } 
    411422 
     
    415426        protected void visitBefore(SectionHeading node) { 
    416427                if (!lastWasSectionHeading && !buf.substring(buf.length()-2).equals("\n\n")) 
    417                         buf.append("\n"); 
     428                        newLine(); 
    418429                 
    419430                lastWasSectionHeading=true; 
     
    422433//                      buf.append("\n"); 
    423434                 
    424                 buf.append(node.getSectionHeader()); 
     435                text(node.getSectionHeader()); 
    425436        } 
    426437 
    427438        protected void visitAfter(SectionHeading node) { 
    428 //              buf.append("\n"); 
    429439        } 
    430440 
     
    434444        protected void visitAfter(SingleDefinition node) { 
    435445                if (!isLastElement()) 
    436                         buf.append(" | "); 
     446                        text(" | "); 
    437447                 
    438448        } 
     
    440450        protected void visitBefore(StringRule node) { 
    441451                if (node.getLiteral() != null) 
    442                         buf.append("\"" + node.getLiteral() + "\""); 
     452                        text("\"" + node.getLiteral() + "\""); 
    443453                else if (node.getColon() != null) 
    444                         buf.append("\"\"\""); 
     454                        text("\"\"\""); 
    445455        } 
    446456 
    447457        protected void visitAfter(StringRule node) { 
    448458        } 
    449  
    450          
    451459         
    452460} 
Note: See TracChangeset for help on using the changeset viewer.