Changeset 27 in default for trunk/de.ugoe.cs.swe.bnftools.ebnf.ui
- Timestamp:
- 11/02/10 15:59:35 (14 years ago)
- 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 257 257 } 258 258 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 260 271 // ----------------------------------------------------------------------------- 261 272 … … 267 278 268 279 //System.out.println(allComments.toString()); 269 buf.append("grammar " + node.getName());280 text("grammar " + node.getName()); 270 281 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(); 275 287 } 276 288 … … 283 295 284 296 protected void visitAfter(ImportSection node) { 285 buf.append("\n");297 newLine(); 286 298 } 287 299 … … 315 327 protected void visitAfter(Term node) { 316 328 if (!isLastElement()) 317 buf.append(" ");329 space(); 318 330 } 319 331 … … 337 349 338 350 protected void visitBefore(GroupedSequence node) { 339 buf.append("(");351 text("("); 340 352 } 341 353 342 354 protected void visitAfter(GroupedSequence node) { 343 buf.append(")");355 text(")"); 344 356 } 345 357 … … 351 363 352 364 protected void visitBefore(Import node) { 353 buf.append("import \"" + node.getImportURI() + "\";");354 buf.append("\n");365 text("import \"" + node.getImportURI() + "\";"); 366 newLine(); 355 367 } 356 368 … … 365 377 366 378 protected void visitBefore(OptionalSequence node) { 367 buf.append("[");379 text("["); 368 380 } 369 381 370 382 protected void visitAfter(OptionalSequence node) { 371 buf.append("]");383 text("]"); 372 384 } 373 385 374 386 protected void visitBefore(RepeatedSequence node) { 375 buf.append("{");387 text("{"); 376 388 } 377 389 378 390 protected void visitAfter(RepeatedSequence node) { 379 buf.append("}");391 text("}"); 380 392 if (node.isMorethanonce()) 381 buf.append("+");393 text("+"); 382 394 } 383 395 384 396 protected void visitBefore(Rule node) { 385 397 if (lastWasSectionHeading) 386 buf.append("\n");398 newLine(); 387 399 388 400 lastWasSectionHeading=false; 389 401 390 402 if (node.getRulenumber() > 0) 391 buf.append(node.getRulenumber() + ". ");392 393 buf.append(node.getName() + " ::= ");403 text(node.getRulenumber() + ". "); 404 405 text(node.getName() + " ::= "); 394 406 } 395 407 396 408 protected void visitAfter(Rule node) { 397 buf.append(";"); 398 // appendComments(node); 399 buf.append("\n"); 409 text(";"); 410 newLine(); 400 411 } 401 412 … … 407 418 408 419 protected void visitBefore(RuleReference node) { 409 buf.append(node.getRuleref().getName());420 text(node.getRuleref().getName()); 410 421 } 411 422 … … 415 426 protected void visitBefore(SectionHeading node) { 416 427 if (!lastWasSectionHeading && !buf.substring(buf.length()-2).equals("\n\n")) 417 buf.append("\n");428 newLine(); 418 429 419 430 lastWasSectionHeading=true; … … 422 433 // buf.append("\n"); 423 434 424 buf.append(node.getSectionHeader());435 text(node.getSectionHeader()); 425 436 } 426 437 427 438 protected void visitAfter(SectionHeading node) { 428 // buf.append("\n");429 439 } 430 440 … … 434 444 protected void visitAfter(SingleDefinition node) { 435 445 if (!isLastElement()) 436 buf.append(" | ");446 text(" | "); 437 447 438 448 } … … 440 450 protected void visitBefore(StringRule node) { 441 451 if (node.getLiteral() != null) 442 buf.append("\"" + node.getLiteral() + "\"");452 text("\"" + node.getLiteral() + "\""); 443 453 else if (node.getColon() != null) 444 buf.append("\"\"\"");454 text("\"\"\""); 445 455 } 446 456 447 457 protected void visitAfter(StringRule node) { 448 458 } 449 450 451 459 452 460 }
Note: See TracChangeset
for help on using the changeset viewer.