. S-expression S-expression ( ) S-expression A–Z 0–9 A–Z
Confluent Orthogonal Drawing for Syntax Diagrams S-expression ( - - PowerPoint PPT Presentation
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: (
Context-Free Grammars
S-expression → atomic symbol | (S-expression.S-expression) | (S-expression list) S-expression list → ǫ | S-expressionS-expression list atomic-symbol → LETTERatom part atom part → ǫ | LETTERatom part | numberatom part LETTER → A | B | C | · · · | Z number → 0 | 1 | 2 | · · · | 9 (defun factorial (x) (if (zerop x) 1 (* x (factorial (- x 1)))))
Grammar for LISP 1.5: LISP 1.5 S-expression:
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
- 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
- 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
- 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
NFA Conversion Global Optimization Local Optimization Layered Drawing Confluent Conversion Syntax Diagram BNF Grammar
NFA Representation
S-expression → atomic symbol | (S-expression.S-expression) | (S-expression list) S-expression list → ǫ | S-expressionS-expression list atomic-symbol → LETTERatom part atom part → ǫ | LETTERatom part | numberatom part LETTER → A | B | C | · · · | Z number → 0 | 1 | 2 | · · · | 9
Grammar for LISP 1.5:
NFA Representation
S-expression → atomic symbol | (S-expression.S-expression) | (S-expression list)
NFA Representation
S-expression list → ǫ | S-expressionS-expression list
NFA Representation
NFA Representation
S-expression → atomic symbol | (S-expression.S-expression) | (S-expression list) S-expression list → ǫ | S-expressionS-expression list atomic-symbol → LETTERatom part atom part → ǫ | LETTERatom part | numberatom part LETTER → A | B | C | · · · | Z number → 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
- Hard to approximate
- Existing heuristic applicable,
but complicated and slow
- Use fast heuristics, motivated
by hand optimizations NFA state minimization: Crossing minimization:
- Add states to reduce crossings
Changes one st-digraph at a time
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, uses standard GD techniques for final drawing. which optimizes the input grammar and 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, uses standard GD techniques for final drawing. which optimizes the input grammar and Further directions:
- Compare our simple heuristics against
existing NFA min heuristics
- Reduce bends and crossings in layering
- Perform user studies