Documentation Source Text

Check-in [effc38b25c]
Login

Many hyperlinks are disabled.
Use anonymous login to enable hyperlinks.

Overview
Comment:Continuing work on the syntax bubble-diagram generator.
Timelines: family | ancestors | descendants | both | trunk
Files: files | file ages | folders
SHA1: effc38b25cdf202aa922e3ad909618dc69dce373
User & Date: drh 2008-09-29 20:57:48
Context
2008-10-01
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
20:21
Continuing work on the syntax bubble-diagram generator. check-in: 461cf70bbf user: drh tags: trunk
Changes
Hide Diffs Unified Diffs Ignore Whitespace Patch

Changes to art/syntax/bubble-generator.tcl.

48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
..
82
83
84
85
86
87
88
89
90

91
92
93
94
95
96
97
...
140
141
142
143
144
145
146

147
148

149
150
151
152
153
154
155
156
157
158
159
160
161

162
163
164
165
166
167
168



169
170
171
172
173
174
175
...
503
504
505
506
507
508
509

510
511
512
            {opt
               {line ( number {opt {line , number}} )}
            }
        }
    } {loop {} column-constraint}
  }
  column-constraint {
    line
      {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 )}}}
................................................................................
  set b .bb.b$bn
  button $b -text $name -command [list draw_graph $name $graph]
  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 italic}   ;# default variable font
set RADIUS 13                     ;# default turn radius



# Draw a right-hand turn around.  Approximately a ")"
#
proc draw_right_turnback {tag x y0 y1} {
  global RADIUS
  if {$y0 + 2*$RADIUS < $y1} {
................................................................................
#
proc draw_bubble {txt} {
  global tagcnt
  incr tagcnt
  set tag x$tagcnt
  if {[regexp {^[a-z]} $txt]} {
    set font $::font2

  } else {
    set font $::font1

  }
  set id1 [.c create text 0 0 -anchor c -text $txt -font $font -tags $tag]
  foreach {x0 y0 x1 y1} [.c bbox $id1] break
  set h [expr {$y1-$y0+2}]
  set rad [expr {($h+1)/2}]
  set top [expr {$y0-2}]
  set btm [expr {$y1}]
  set left [expr {$x0+2}]
  set right [expr {$x1-2}]
  if {$left>$right} {
    set left [expr {($x0+$x1)/2}]
    set right $left
  }

  .c create arc [expr {$left-$rad}] $top [expr {$left+$rad}] $btm \
       -width 2 -start 90 -extent 180 -style arc -tags $tag
  .c create arc [expr {$right-$rad}] $top [expr {$right+$rad}] $btm \
       -width 2 -start -90 -extent 180 -style arc -tags $tag
  if {$left<$right} {
    .c create line $left $top $right $top -width 2 -tags $tag
    .c create line $left $btm $right $btm -width 2 -tags $tag



  }
  foreach {x0 y0 x1 y1} [.c bbox $tag] break
  set width [expr {$x1-$x0}]
  .c move $tag [expr {-$x0}] 0

  # Entry is always 0 0
  # Return:  TAG EXIT_X EXIT_Y
................................................................................
  draw_diagram $spec
  foreach {x0 y0 x1 y1} [.c bbox all] break
  .c move all [expr {-$x0}] [expr {-$y0}]
  foreach {x0 y0 x1 y1} [.c bbox all] break
  .c config -width $x1 -height $y1
  update
  .c postscript -file $name.ps -width $x1 -height $y1

  exec convert -density 72x72 -antialias $name.ps $name.gif
  exec xv $name.gif &
}







|







 







|

>







 







>


>







|
|




>
|
|
|
|
|
|
|
>
>
>







 







>
|


48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
..
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
...
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
...
510
511
512
513
514
515
516
517
518
519
520
            {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 )}}}
................................................................................
  set b .bb.b$bn
  button $b -text $name -command [list draw_graph $name $graph]
  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


# Draw a right-hand turn around.  Approximately a ")"
#
proc draw_right_turnback {tag x y0 y1} {
  global RADIUS
  if {$y0 + 2*$RADIUS < $y1} {
................................................................................
#
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
  }
  set id1 [.c create text 0 0 -anchor c -text $txt -font $font -tags $tag]
  foreach {x0 y0 x1 y1} [.c bbox $id1] break
  set h [expr {$y1-$y0+2}]
  set rad [expr {($h+1)/2}]
  set top [expr {$y0-2}]
  set btm [expr {$y1}]
  set left [expr {$x0+3*$istoken}]
  set right [expr {$x1-3*$istoken}]
  if {$left>$right} {
    set left [expr {($x0+$x1)/2}]
    set right $left
  }
  if {$istoken} {
    .c create arc [expr {$left-$rad}] $top [expr {$left+$rad}] $btm \
         -width 2 -start 90 -extent 180 -style arc -tags $tag
    .c create arc [expr {$right-$rad}] $top [expr {$right+$rad}] $btm \
         -width 2 -start -90 -extent 180 -style arc -tags $tag
    if {$left<$right} {
      .c create line $left $top $right $top -width 2 -tags $tag
      .c create line $left $btm $right $btm -width 2 -tags $tag
    }
  } else {
    .c create rect $left $top $right $btm -width 2 -tags $tag
  }
  foreach {x0 y0 x1 y1} [.c bbox $tag] break
  set width [expr {$x1-$x0}]
  .c move $tag [expr {-$x0}] 0

  # Entry is always 0 0
  # Return:  TAG EXIT_X EXIT_Y
................................................................................
  draw_diagram $spec
  foreach {x0 y0 x1 y1} [.c bbox all] break
  .c move all [expr {-$x0}] [expr {-$y0}]
  foreach {x0 y0 x1 y1} [.c bbox all] break
  .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 &
}

Added art/syntax/sample1.html.

























>
>
>
>
>
>
>
>
>
>
>
>
1
2
3
4
5
6
7
8
9
10
11
12
<dl>
<dt>create-table-stmt:</dt>
<dd><img src="create-table-stmt-long.gif"></dd>
<dt>column-def:</dt>
<dd><img src="column-def.gif"></dd>
<dt>column-constraint:</dt>
<dd><img src="column-constraint.gif"></dd>
<dt>constraint:</dt>
<dd><img src="constraint.gif"></dd>
<dt>conflict-clause:</dt>
<dd><img src="conflict-clause.gif"></dd>
</dl>