Confluent Orthogonal Drawing
for Syntax Diagrams
hS-expressioni
(
hS-expressioni
.
hS-expressioni
)
A–Z
A–Z
0–9
Michael J. Bannister
David A. Brown
David Eppstein
Context-Free Grammars
LISP 1.5 S-expression:
(defun factorial (x)
(if (zerop x)
1
(* x (factorial (- x 1)))))
Grammar for LISP 1.5:
hS-expressioni → hatomic symboli
| (hS-expressioni.hS-expressioni)
| (hS-expression listi)
hS-expression listi → | hS-expressionihS-expression listi
hatomic-symboli → hLETTERihatom parti
hatom parti → | hLETTERihatom parti | hnumberihatom parti
hLETTERi → A | B | C | · · · | Z
hnumberi → 0 | 1 | 2 | · · · | 9
Syntax Diagrams
Syntax Diagram from the CANDE Information Manual
Syntax Diagrams
Syntax Diagram from the Pascal User Manual and Report
Syntax Diagrams
JSON Data Interchange Standard
Extended Backus–Naur Form
• More expressive than BNF
• Notation for lists:
natural number = digit { digit }
• Notation for optionals:
integer = [ ”-” ] natural number
• Direct translation to syntax diagrams
−
digit
Extended Backus–Naur Form
• More expressive than BNF
• Notation for lists:
natural number = digit { digit }
• Notation for optionals:
integer = [ ”-” ] natural number
• Direct translation to syntax diagrams
−
digit
Extended Backus–Naur Form
• More expressive than BNF
• Notation for lists:
natural number = digit { digit }
• Notation for optionals:
integer = [ ”-” ] natural number
• Direct translation to syntax diagrams
−
digit
Hand Optimizations
JSON Data Interchange Standard
Software Pipeline
BNF Grammar
NFA Conversion
Layered Drawing
Global Optimization
Confluent Conversion
Local Optimization
Syntax Diagram
NFA Representation
Grammar for LISP 1.5:
hS-expressioni → hatomic symboli
| (hS-expressioni.hS-expressioni)
| (hS-expression listi)
hS-expression listi → | hS-expressionihS-expression listi
hatomic-symboli → hLETTERihatom parti
hatom parti → | hLETTERihatom parti |
hnumberihatom parti
hLETTERi → A | B | C | · · · | Z
hnumberi → 0 | 1 | 2 | · · · | 9
NFA Representation
hS-expressioni → hatomic symboli
| (hS-expressioni.hS-expressioni)
| (hS-expression listi)
NFA Representation
hS-expression listi → |
hS-expressionihS-expression listi
NFA Representation
NFA Representation
hS-expressioni → hatomic symboli
| (hS-expressioni.hS-expressioni)
| (hS-expression listi)
hS-expression listi → | hS-expressionihS-expression listi
hatomic-symboli → hLETTERihatom parti
hatom parti → | hLETTERihatom parti | hnumberihatom parti
hLETTERi → A | B | C | · · · | Z
hnumberi → 0 | 1 | 2 | · · · | 9
Global Optimization
Can modify the entire NFA representation
NFA state minimization
• Combine graphs to reduce states
Global Optimization
Nesting!
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
Local Optimizations
Loop back!
Local Optimizations
Parallel state elimination!
Local Optimizations
Confluent pinch!
Optimization
Global Optimization
Local Optimization
Sugiyama Layering
Sugiyama Layering
Sugiyama Layering
Confluent Conversion
Experimental Results
Subset of JSON grammar
Experimental Results
Pascal Type Declarations
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
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!
© Copyright 2026 Paperzz