Get syntax diagrams automatically generated?
(1) By benstd on 2022-07-27 16:32:15 [link] [source]
Are the .pikchr syntax diagrams automatically generated from the SQLite sources? If so, I'd be more than happy to know how this can be achieved form the source code.
I've altered some parts of the grammar for a research project of mine, and editing the syntax diagrams by hand needs a bit of a learning curve.
Ben
(2.1) By Stephan Beal (stephan) on 2022-07-27 16:41:38 edited from 2.0 in reply to 1 [link] [source]
Are the .pikchr syntax diagrams automatically generated from the SQLite sources?
The pikchrs themselves are hand-written.
I've altered some parts of the grammar for a research project of mine, and editing the syntax diagrams by hand needs a bit of a learning curve.
pikchr was developed by sqlite's project lead, so he has a bit of an advantage when it comes to creating pikchrs. He needs no code generator to get nice-looking pics :).
Edit: also, in case you're not familiar with it, we recently revamped the pikchr editor/sandbox tool to perform rendering client-side, optionally as you type, so it's much more useful in helping to learn pikchr than it was 3+ months ago.
(3.2) Originally by benstd with edits by Richard Hipp (drh) on 2022-07-27 17:24:27 from 3.1 in reply to 2.1 [link] [source]
Thank you for the quick reply. The online tool seems really helpful, as my current approach is text edit -> shell -> click to open file ;). As a feedback: The tool doesn't work in Safari. For example the buttons and menu do not work. In forefoy it works well.
Maybe I can ask you about the concrete problem: I've taken the create table statement as a base. Now I'm trying to connect the SOURCE token correctly. SOURCE is optional. The grammar is as follows:
linerad = 10px linewid *= 0.5 $h = 0.21 $r = 0.2in circle radius 10% A0: arrow 2*arrowht CR: oval "CREATE" fit OR: oval "OR" fit with .w at (linewid right of CR.e,.8*$h below CR) RPL: oval "REPLACE" fit with .w at (linewid right of OR.e,.8*$h below CR) SRC: oval "SOURCE" fit with .w at (linewid right of RPL.e,.8*$h below CR) STR: oval "STREAM" fit with .w at (linewid right of SRC.e,CR) arrow from CR.e right; arrow to STR.w arrow from CR.e right linerad then down even with OR then to OR.w arrow from OR.e right; arrow to RPL.w line from RPL.e right linerad then up even with STR \ then to arrowht left of STR.w arrow from STR.e right oval "IF" fit arrow right 2*arrowht oval "NOT" fit arrow 2*arrowht ETS: oval "EXISTS" fit line from SRC.e right linerad then up even with STR \ then to arrowht left of STR.w # connect SOURCE back to arrow from SRC.w right linerad then down even with CR # IF NOT EXISTS bypass Y1: .5*$h below OR.s # vertical position of back-arrow arrow from STR.e right linerad then down even with Y1 then left even with OR arrow from ETS.e right linerad then down even with Y1 \ then left even with ETS.w line left even with STR.w # second row arrow left even with first circle then down $h*1.25 then right 2*arrowht SN: oval "stream-name" fit arrow 2*arrowht DOT: oval "." bold fit arrow TN: oval "table-name" fit # schema-name bypass arrow from (first circle,SN.n) down even with $h below SN \ then right even with SN line right even with arrowht right of DOT.e then up even with DOT \ then right linerad # Loop back from table-name arrow from TN.e right linerad then down even with DOT.s-(0,2*$h) \ then left even with DOT # third row arrow left even with first circle then down $h*1.25 then right 2*arrowht LP: oval "(" bold fit arrow CD: box "column-def" fit TC: box "table-constraint" fit with .w at CD.e+(1.5*linewid,-1.25*$h) arrow <- from TC.e right 1.5*arrowht C2: oval "," bold fit RP: oval ")" bold fit at (2*linewid right of C2,LP) arrow from RP.e right 3*arrowht TO: box "table-options" fit # column-def loop C1: oval "," bold fit at 1.25*$h below CD arrow from CD.e right linerad then down even with C1 then to C1.e line from C1.w left even with 2*arrowht left of CD.w then up even with CD \ then to arrowht left of CD.w # table-constraint bypass arrow from CD.e right arrow to RP.w # table-constraint loop arrow from (C2.e,RP) right 2*arrowht then down even with C2 then to C2.e line from TC.w left linerad then up even with RP then right 2*arrowht # exit circle and table-options bypass arrow from RP.e right linerad then up 1.5*$h then right even with TO.n arrow right even with TO.e then right 3*arrowht EC: circle same # table-options exit arrow from TO.e right linerad then up 1.5*$h then right even with EC.w # AS select clause arrow from TN.e right 250% oval "AS" fit arrow 2*arrowht box "select-stmt" fit arrow right line right even with linerad right of TO.e then down even with last circle \ then right linerad→ /pikchrshow
(Edit by drh: Reformat to markdown so that we can see the diagram.)
(4.1) By Stephan Beal (stephan) on 2022-07-27 17:31:49 edited from 4.0 in reply to 3.1 [link] [source]
As a feedback: The tool doesn't work in Safari.
If you mean the desktop version then the only response i can give is "patches to improve that are welcomed" (over in the Fossil SCM forum - that's where /pikchrshow is developed)1, and if you mean on a mobile device then the only additional advice i can give is "don't do that."
Maybe I can ask you about the concrete problem: I've taken the create table statement as a base. Now I'm trying to connect the SOURCE token correctly. SOURCE is optional. The grammar is as follows:
This is really not the forum for pikchr-specific questions, but there's a forum for that and several pikchr-skilled folks hang out there. (Edit: or not - see Richard's response.)
- ^ Noting that, based solely on feature availability/compatibility charts, the new /pikchrshow will require at least Safari version 14 or 15, whereas the legacy version will work on much older browser versions.
(5) By Richard Hipp (drh) on 2022-07-27 17:30:34 in reply to 3.2 [source]
linerad = 10px linewid *= 0.5 $h = 0.21 $r = 0.2in circle radius 10% A0: arrow 2*arrowht CR: oval "CREATE" fit OR: oval "OR" fit with .w at (linewid right of CR.e,.8*$h below CR) RPL: oval "REPLACE" fit with .w at (linewid right of OR.e,.8*$h below CR) SRC: oval "SOURCE" fit with .w at (linewid*2 right of RPL.e,.8*$h below CR) STR: oval "STREAM" fit with .w at (linewid right of SRC.e,CR) arrow from CR.e right; arrow to STR.w arrow from CR.e right linerad then down even with OR then to OR.w arrow from OR.e right; arrow to RPL.w line from RPL.e right linerad then up even with STR \ then to arrowht left of STR.w arrow from STR.e right oval "IF" fit arrow right 2*arrowht oval "NOT" fit arrow 2*arrowht ETS: oval "EXISTS" fit line from SRC.e right linerad then up even with STR \ then to arrowht left of STR.w # connect SOURCE back to arrow <- from SRC.w left linerad+arrowht then up even with CR then left # IF NOT EXISTS bypass Y1: .5*$h below OR.s # vertical position of back-arrow arrow from STR.e right linerad then down even with Y1 then left even with OR arrow from ETS.e right linerad then down even with Y1 \ then left even with ETS.w line left even with STR.w # second row arrow left even with first circle then down $h*1.25 then right 2*arrowht SN: oval "stream-name" fit arrow 2*arrowht DOT: oval "." bold fit arrow TN: oval "table-name" fit # schema-name bypass arrow from (first circle,SN.n) down even with $h below SN \ then right even with SN line right even with arrowht right of DOT.e then up even with DOT \ then right linerad # Loop back from table-name arrow from TN.e right linerad then down even with DOT.s-(0,2*$h) \ then left even with DOT # third row arrow left even with first circle then down $h*1.25 then right 2*arrowht LP: oval "(" bold fit arrow CD: box "column-def" fit TC: box "table-constraint" fit with .w at CD.e+(1.5*linewid,-1.25*$h) arrow <- from TC.e right 1.5*arrowht C2: oval "," bold fit RP: oval ")" bold fit at (2*linewid right of C2,LP) arrow from RP.e right 3*arrowht TO: box "table-options" fit # column-def loop C1: oval "," bold fit at 1.25*$h below CD arrow from CD.e right linerad then down even with C1 then to C1.e line from C1.w left even with 2*arrowht left of CD.w then up even with CD \ then to arrowht left of CD.w # table-constraint bypass arrow from CD.e right arrow to RP.w # table-constraint loop arrow from (C2.e,RP) right 2*arrowht then down even with C2 then to C2.e line from TC.w left linerad then up even with RP then right 2*arrowht # exit circle and table-options bypass arrow from RP.e right linerad then up 1.5*$h then right even with TO.n arrow right even with TO.e then right 3*arrowht EC: circle same # table-options exit arrow from TO.e right linerad then up 1.5*$h then right even with EC.w # AS select clause arrow from TN.e right 250% oval "AS" fit arrow 2*arrowht box "select-stmt" fit arrow right line right even with linerad right of TO.e then down even with last circle \ then right linerad→ /pikchrshow
(6) By benstd on 2022-07-27 17:38:47 in reply to 5 [link] [source]
Thank you!