confluent orthogonal drawing for syntax diagrams
play

Confluent Orthogonal Drawing for Syntax Diagrams S-expression ( - PowerPoint PPT Presentation

Confluent Orthogonal Drawing for Syntax Diagrams S-expression ( S-expression S-expression ) . AZ AZ 09 Michael J. Bannister David A. Brown David Eppstein Context-Free Grammars LISP 1.5 S-expression: (


  1. Confluent Orthogonal Drawing for Syntax Diagrams � S-expression � ( � S-expression � � S-expression � ) . A–Z A–Z 0–9 Michael J. Bannister David A. Brown David Eppstein

  2. Context-Free Grammars LISP 1.5 S-expression: ( defun factorial (x) ( if ( zerop x) 1 ( * x (factorial (- x 1))))) Grammar for LISP 1.5: � S-expression � → � atomic symbol � | ( � S-expression � . � S-expression � ) | ( � S-expression list � ) � S-expression list � → ǫ | � S-expression �� S-expression list � � atomic-symbol � → � LETTER �� atom part � � atom part � → ǫ | � LETTER �� atom part � | � number �� atom part � � LETTER � → A | B | C | · · · | Z � number � → 0 | 1 | 2 | · · · | 9

  3. Syntax Diagrams Syntax Diagram from the CANDE Information Manual

  4. Syntax Diagrams Syntax Diagram from the Pascal User Manual and Report

  5. Syntax Diagrams JSON Data Interchange Standard

  6. Extended Backus–Naur Form • More expressive than BNF • More expressive than BNF • Notation for lists: • Notation for lists: natural number = digit { digit } natural number = digit { digit } • Notation for optionals: • Notation for optionals: integer = [ ”-” ] natural number integer = [ ”-” ] natural number • Direct translation to syntax diagrams − − digit

  7. Extended Backus–Naur Form • More expressive than BNF • More expressive than BNF • Notation for lists: • Notation for lists: natural number = digit { digit } natural number = digit { digit } • Notation for optionals: • Notation for optionals: integer = [ ”-” ] natural number integer = [ ”-” ] natural number • Direct translation to syntax diagrams − − digit

  8. Extended Backus–Naur Form • More expressive than BNF • More expressive than BNF • Notation for lists: • Notation for lists: natural number = digit { digit } natural number = digit { digit } • Notation for optionals: • Notation for optionals: integer = [ ”-” ] natural number integer = [ ”-” ] natural number • Direct translation to syntax diagrams − − digit

  9. Hand Optimizations JSON Data Interchange Standard

  10. Software Pipeline BNF Grammar Layered Drawing NFA Conversion Global Optimization Confluent Conversion Local Optimization Syntax Diagram

  11. NFA Representation Grammar for LISP 1.5: � S-expression � → � atomic symbol � | ( � S-expression � . � S-expression � ) | ( � S-expression list � ) � S-expression list � → ǫ | � S-expression �� S-expression list � � atomic-symbol � → � LETTER �� atom part � � atom part � → ǫ | � LETTER �� atom part � | � number �� atom part � � LETTER � → A | B | C | · · · | Z � number � → 0 | 1 | 2 | · · · | 9

  12. NFA Representation � S-expression � → � atomic symbol � | ( � S-expression � . � S-expression � ) | ( � S-expression list � )

  13. NFA Representation � S-expression list � → ǫ | � S-expression �� S-expression list �

  14. NFA Representation

  15. NFA Representation � S-expression � → � atomic symbol � | ( � S-expression � . � S-expression � ) | ( � S-expression list � ) � S-expression list � → ǫ | � S-expression �� S-expression list � � atomic-symbol � → � LETTER �� atom part � � atom part � → ǫ | � LETTER �� atom part � | � number �� atom part � � LETTER � → A | B | C | · · · | Z � number � → 0 | 1 | 2 | · · · | 9

  16. Global Optimization Can modify the entire NFA representation NFA state minimization • Combine graphs to reduce states

  17. Global Optimization Nesting!

  18. Local Optimizations Changes one st -digraph at a time NFA state minimization: • Hard to approximate • Existing heuristic applicable, but complicated and slow • Use fast heuristics, motivated by hand optimizations Crossing minimization: • Add states to reduce crossings

  19. Local Optimizations Loop back!

  20. Local Optimizations Parallel state elimination!

  21. Local Optimizations Confluent pinch!

  22. Optimization Global Optimization Local Optimization

  23. Sugiyama Layering

  24. Sugiyama Layering

  25. Sugiyama Layering

  26. Confluent Conversion

  27. Experimental Results Subset of JSON grammar

  28. Experimental Results Pascal Type Declarations

  29. Conclusion Software pipeline producing syntax diagrams, which optimizes the input grammar and uses standard GD techniques for final drawing. Further directions: • Compare our simple heuristics against existing NFA min heuristics • Reduce bends and crossings in layering • Perform user studies

  30. Conclusion Software pipeline producing syntax diagrams, which optimizes the input grammar and uses standard GD techniques for final drawing. Further directions: • Compare our simple heuristics against existing NFA min heuristics • Reduce bends and crossings in layering • Perform user studies Thank you!

Recommend


More recommend