Many hyperlinks are disabled.
Use anonymous login
to enable hyperlinks.
Overview
Comment: | Continuing work on the bubble syntax diagrams. |
---|---|
Downloads: | Tarball | ZIP archive |
Timelines: | family | ancestors | descendants | both | trunk |
Files: | files | file ages | folders |
SHA1: |
2bb38606e0cd20d0011d15e9e7ad1c9b |
User & Date: | drh 2008-10-01 17:25:48.000 |
Context
2008-10-01
| ||
19:48 | Continuing work on the syntax bubble diagrams. (check-in: f73a84dfb0 user: drh tags: trunk) | |
17:25 | Continuing work on the bubble syntax diagrams. (check-in: 2bb38606e0 user: drh tags: trunk) | |
2008-09-29
| ||
20:57 | Continuing work on the syntax bubble-diagram generator. (check-in: effc38b25c user: drh tags: trunk) | |
Changes
Changes to art/syntax/bubble-generator.tcl.
︙ | ︙ | |||
10 11 12 13 14 15 16 | canvas .c -bg white pack .c -side top -fill both -expand 1 wm withdraw . # Graphs: # set all_graphs { | > > > > > > > > | | | | | | > > > > > > > > > | > | | > | > > | | | | > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > | 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 | canvas .c -bg white pack .c -side top -fill both -expand 1 wm withdraw . # Graphs: # set all_graphs { alter-table-stmt { stack {line ALTER TABLE {opt {line database-name .}} table-name} {tailbranch {line RENAME TO new-table-name} {line ADD {opt COLUMN} column-def} } } X-create-table-stmt-1 { stack {line CREATE {or {} TEMP TEMPORARY} TABLE} {opt {line IF NOT EXISTS}} {line {opt {line database-name .}} table-name} {tailbranch {line ( {loop column-def ,} {loop {} {, table-constraint}} )} {line AS select-stmt} } } create-table-stmt { stack {line CREATE {or {} TEMP TEMPORARY} TABLE {opt {line IF NOT EXISTS}}} {line {opt {line database-name .}} table-name {tailbranch {line ( {loop column-def ,} {loop {} {, table-constraint}} )} {line AS select-stmt} } } } column-def { line column-name {or type-name nil} {loop {} column-constraint} } type-name { line {loop name {}} {or {} {line ( number )} {line ( number , number )} } } X-column-def-c { line column-name {or {} {line type-name} {line type-name ( number )} {line type-name ( number , number )} } {loop {} column-constraint} } X-column-def-b { line column-name {opt {line type-name {opt {line ( number {opt {line , number}} )} } } } {loop {} column-constraint} } column-constraint { stack {opt {line CONSTRAINT name}} {or {line PRIMARY KEY conflict-clause {opt AUTOINCREMENT}} {line NOT NULL conflict-clause} {line UNIQUE conflict-clause} {line CHECK ( expr )} {line DEFAULT {or value {line ( expr )}}} {line COLLATE collation-name} {line foreign-key-clause} } } table-constraint { stack {opt {line CONSTRAINT name}} {or {line {or {line PRIMARY KEY} UNIQUE} ( column-list ) conflict-clause} {line CHECK ( expr )} {line FOREIGN KEY ( column-list ) foreign-key-clause } } } foreign-key-clause { stack {line REFERENCES foreign-table {opt {line ( column-list )}}} {toploop {or {line ON {or DELETE UPDATE INSERT} {or {line SET NULL} {line SET DEFAULT} CASCADE RESTRICT } } {line MATCH name} nil } {} } {or {line {opt NOT} DEFERRABLE {or {} {line INITIALLY DEFERRED} {line INITIALLY IMMEDIATE} } } nil } } X-foreign-key-action { or {line MATCH name} {line ON {or DELETE UPDATE INSERT} {or {line SET NULL} {line SET DEFAULT} CASCADE RESTRICT } } } X-foreign-key-deferment { line {opt NOT} DEFERRABLE {or {} {line INITIALLY DEFERRED} {line INITIALLY IMMEDIATE} } } conflict-clause { opt {line ON CONFLICT {or ROLLBACK ABORT FAIL IGNORE REPLACE}} } } # Draw the button bar # set bn 0 foreach {name graph} $all_graphs { incr bn set b .bb.b$bn button $b -text $name -command [list draw_graph $name $graph] pack $b -side top -fill x -expand 1 } incr bn set b .bb.b$bn button $b -text Everything -command {draw_all_graphs} pack $b -side top -fill x -expand 1 set tagcnt 0 ;# tag counter set font1 {Helvetica 16 bold} ;# default token font set font2 {Helvetica 15} ;# default variable font set RADIUS 13 ;# default turn radius set DPI 80 ;# dots per inch |
︙ | ︙ | |||
139 140 141 142 143 144 145 146 147 148 149 150 151 152 | # Draw a bubble containing $txt. # proc draw_bubble {txt} { global tagcnt incr tagcnt set tag x$tagcnt if {[regexp {^[a-z]} $txt]} { set font $::font2 set istoken 0 } else { set font $::font1 set istoken 1 } | > > > | 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 | # Draw a bubble containing $txt. # proc draw_bubble {txt} { global tagcnt incr tagcnt set tag x$tagcnt if {$txt=="nil"} { return [list $tag 0 0] } if {[regexp {^[a-z]} $txt]} { set font $::font2 set istoken 0 } else { set font $::font1 set istoken 1 } |
︙ | ︙ | |||
282 283 284 285 286 287 288 | set back_y [expr {$btm + $sep + 1}] .c move $t $enter_x $enter_y set e2 [expr {$exit_x + $sep}] .c create line $exit_x $exit_y $e2 $exit_y \ -width 2 -tags $tag draw_right_turnback $tag $e2 $exit_y $back_y set e3 [expr {$enter_x-$sep}] | > | > > | | | | > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > | 355 356 357 358 359 360 361 362 363 364 365 366 367 368 369 370 371 372 373 374 375 376 377 378 379 380 381 382 383 384 385 386 387 388 389 390 391 392 393 394 395 396 397 398 399 400 401 402 403 404 405 406 407 408 409 410 411 412 413 414 415 416 417 418 419 420 421 422 423 424 425 426 427 428 429 430 431 432 433 434 435 436 437 438 439 440 441 442 443 444 445 446 447 448 449 450 451 452 453 454 455 456 457 458 459 460 461 462 463 464 465 466 467 468 469 470 471 | set back_y [expr {$btm + $sep + 1}] .c move $t $enter_x $enter_y set e2 [expr {$exit_x + $sep}] .c create line $exit_x $exit_y $e2 $exit_y \ -width 2 -tags $tag draw_right_turnback $tag $e2 $exit_y $back_y set e3 [expr {$enter_x-$sep}] set emid [expr {($e2+$e3)/2}] .c create line $e2 $back_y $emid $back_y \ -width 2 -tags $tag -arrow last .c create line $emid $back_y $e3 $back_y \ -width 2 -tags $tag set r2 [expr {($enter_y - $back_y)/2.0}] draw_left_turnback $tag $e3 $back_y $enter_y .c create line $e3 $enter_y $enter_x $enter_y \ -arrow last -width 2 -tags $tag set exit_x [expr {$enter_x + $exx}] set exit_y [expr {$enter_y + $exy}] } .c addtag $tag withtag $t .c dtag $t $t set btm [lindex [.c bbox $tag] 3] } set width [lindex [.c bbox $tag] 2] return [list $tag $exit_x $exit_y] } proc draw_loop {forward back} { global tagcnt incr tagcnt set tag x$tagcnt set sep $::RADIUS set vsep [expr {$sep/2}] foreach {ft fexx fexy} [draw_diagram $forward] break foreach {fx0 fy0 fx1 fy1} [.c bbox $ft] break set fw [expr {$fx1-$fx0}] foreach {bt bexx bexy} [draw_backwards_line $back] break foreach {bx0 by0 bx1 by1} [.c bbox $bt] break set bw [expr {$bx1-$bx0}] set dy [expr {$fy1 - $by0 + $vsep}] .c move $bt 0 $dy set biny $dy set bexy [expr {$dy+$bexy}] set by0 [expr {$dy+$by0}] set by1 [expr {$dy+$by1}] if {$fw>$bw} { set dx [expr {($fw-$bw)/2}] .c move $bt $dx 0 set bexx [expr {$dx+$bexx}] .c create line 0 $biny $dx $biny -width 2 -tags $bt .c create line $bexx $bexy $fx1 $bexy -width 2 -tags $bt -arrow first set mxx $fexx } elseif {$bw>$fw} { set dx [expr {($bw-$fw)/2}] .c move $ft $dx 0 set fexx [expr {$dx+$fexx}] .c create line 0 0 $dx $fexy -width 2 -tags $ft .c create line $fexx $fexy $bx1 $fexy -width 2 -tags $ft set mxx $bexx } .c addtag $tag withtag $bt .c addtag $tag withtag $ft .c dtag $bt $bt .c dtag $ft $ft .c move $tag $sep 0 set mxx [expr {$mxx+$sep}] .c create line 0 0 $sep 0 -width 2 -tags $tag draw_left_turnback $tag $sep 0 $biny draw_right_turnback $tag $mxx $fexy $bexy foreach {x0 y0 x1 y1} [.c bbox $tag] break .c create line $mxx $fexy $x1 $fexy -width 2 -tags $tag return [list $tag $x1 $fexy] } proc draw_toploop {forward back} { global tagcnt incr tagcnt set tag x$tagcnt set sep $::RADIUS set vsep [expr {$sep/2}] foreach {ft fexx fexy} [draw_diagram $forward] break foreach {fx0 fy0 fx1 fy1} [.c bbox $ft] break set fw [expr {$fx1-$fx0}] foreach {bt bexx bexy} [draw_backwards_line $back] break foreach {bx0 by0 bx1 by1} [.c bbox $bt] break set bw [expr {$bx1-$bx0}] set dy [expr {-($by1 - $fy0 + $vsep)}] .c move $bt 0 $dy set biny $dy set bexy [expr {$dy+$bexy}] set by0 [expr {$dy+$by0}] set by1 [expr {$dy+$by1}] if {$fw>$bw} { set dx [expr {($fw-$bw)/2}] .c move $bt $dx 0 set bexx [expr {$dx+$bexx}] .c create line 0 $biny $dx $biny -width 2 -tags $bt .c create line $bexx $bexy $fx1 $bexy -width 2 -tags $bt -arrow first set mxx $fexx } elseif {$bw>$fw} { set dx [expr {($bw-$fw)/2}] .c move $ft $dx 0 set fexx [expr {$dx+$fexx}] .c create line 0 0 $dx $fexy -width 2 -tags $ft .c create line $fexx $fexy $bx1 $fexy -width 2 -tags $ft set mxx $bexx } .c addtag $tag withtag $bt .c addtag $tag withtag $ft .c dtag $bt $bt .c dtag $ft $ft .c move $tag $sep 0 set mxx [expr {$mxx+$sep}] |
︙ | ︙ | |||
487 488 489 490 491 492 493 494 495 496 497 498 499 500 | } if {$cmd=="stack"} { return [draw_stack [lrange $spec 1 end]] } if {$cmd=="loop"} { return [draw_loop [lindex $spec 1] [lindex $spec 2]] } if {$cmd=="or"} { return [draw_or [lrange $spec 1 end]] } if {$cmd=="opt"} { return [draw_or [list {} [lindex $spec 1]]] } if {$cmd=="tailbranch"} { | > > > | 612 613 614 615 616 617 618 619 620 621 622 623 624 625 626 627 628 | } if {$cmd=="stack"} { return [draw_stack [lrange $spec 1 end]] } if {$cmd=="loop"} { return [draw_loop [lindex $spec 1] [lindex $spec 2]] } if {$cmd=="toploop"} { return [draw_toploop [lindex $spec 1] [lindex $spec 2]] } if {$cmd=="or"} { return [draw_or [lrange $spec 1 end]] } if {$cmd=="opt"} { return [draw_or [list {} [lindex $spec 1]]] } if {$cmd=="tailbranch"} { |
︙ | ︙ | |||
514 515 516 517 518 519 520 | .c config -width $x1 -height $y1 update .c postscript -file $name.ps -width $x1 -height $y1 global DPI exec convert -density ${DPI}x$DPI -antialias $name.ps $name.gif exec xv $name.gif & } | > > > > > > > > > | 642 643 644 645 646 647 648 649 650 651 652 653 654 655 656 657 | .c config -width $x1 -height $y1 update .c postscript -file $name.ps -width $x1 -height $y1 global DPI exec convert -density ${DPI}x$DPI -antialias $name.ps $name.gif exec xv $name.gif & } proc draw_all_graphs {} { global all_graphs foreach {name graph} $all_graphs { if {[regexp {^X-} $name]} continue draw_graph $name $graph } wm withdraw . } |