Re: Grammar railroad diagram

2021-07-10 Thread Corey Huinker
>
>
> Another way that I tested and it's working is to use
> https://www.bottlecaps.de/convert/ paste the postgresql grammar there
> and press "convert" and after press "view diagram".
>

I tried this out and I'm pleased to see that one of the outputs is xhtml +
SVG, because SVGs have hover-over tool-tips, which are an important aspect
of accessibility, which was my major concern the last time a similar thing
was proposed [1].

[1]
https://www.postgresql.org/message-id/cah2-wzmfc+p3pc_u1dsgm3lawurzkx5pqzmxtglgsxbf8gf...@mail.gmail.com


Re: Grammar railroad diagram

2021-07-09 Thread Domingo Alvarez Duarte

Hello Andres !

Another way that I tested and it's working is to use 
https://www.bottlecaps.de/convert/ paste the postgresql grammar there 
and press "convert" and after press "view diagram".


Again optionally manually add the Tokens to a better diagram !



// Tokens from postgresql-13.3/src/include/parser/kwlist.h

ABORT_P ::= "abort"
ABSOLUTE_P ::= "absolute"
ACCESS ::= "access"
ACTION ::= "action"

...



Cheers !

On 9/7/21 4:36, Andres Freund wrote:

Hi,

On 2021-07-03 10:39:02 +0200, Domingo Alvarez Duarte wrote:

I've done a experimental tool to convert bison grammars to a kind of EBNF
understood by https://www.bottlecaps.de/rr/ui

It'd be nice if you could share that tool. The diagrams this can generate
are neat...

Greetings,

Andres Freund





Re: Fwd: Grammar railroad diagram

2021-07-09 Thread grd

Domingo, Bruce,

 

sorry for the error. It was caused by my server using Tomcat's default maxPostSize of 2MB, which

is not sufficient for the diagrams generated from the Postgres grammar. I have now extended it

to 10MB.

 

By the way, I had already created diagrams for PostgreSQL back in 2017, please find them here:

https://cdn.rawgit.com/GuntherRademacher/1e5a275f433fdc61bc4e81e24c287d67/raw/7c8599f5d2bf8450c52750abd70bb4bc90369bf8/gram.xhtml

 

At the time, this answered a question on StackOverflow, but apparently that question has been

deleted since. Those diagrams were created by pasting the content of

 

https://raw.githubusercontent.com/postgres/postgres/master/src/backend/parser/gram.y

 

to

 

https://bottlecaps.de/convert/

 

then clicking "Convert" and on the bottom of the result page, "View Diagram".

 

Downloading diagrams now works after maxPostSize has been extended on my side.

 

Best regards

Gunther

 

Gesendet: Dienstag, 06. Juli 2021 um 20:04 Uhr
Von: "Domingo Alvarez Duarte" 
An: g...@gmx.net
Betreff: Fwd: Grammar railroad diagram


Hello Gunther !

I've sent this to postgresql and they reported the error bellow.

Cheers !

 Forwarded Message 

	
		
			Subject:
			Re: Grammar railroad diagram
		
		
			Date:
			Tue, 6 Jul 2021 12:51:54 -0400
		
		
			From:
			Bruce Momjian 
		
		
			To:
			Domingo Alvarez Duarte 
		
		
			CC:
			pgsql-hackers@lists.postgresql.org
		
	



On Sat, Jul 3, 2021 at 10:39:02AM +0200, Domingo Alvarez Duarte wrote:

I've done a experimental tool to convert bison grammars to a kind of EBNF
understood by https://www.bottlecaps.de/rr/ui to generate railroad diagrams see
bellow the converted 'postgresql-13.3/src/backend/parser/gram.y' and with some
hand made changes to allow view it at https://www.bottlecaps.de/rr/ui the order
of the rules could be changed to a better view of the railroad diagrams. Copy
and paste the EBNF bellow on https://www.bottlecaps.de/rr/ui tab Edit Grammar
then switch to the tab View Diagram.



That is pretty cool. I had trouble figuring out how to get it working,
so here are the steps I used:

1. save my attachment (created by Domingo)
2. go to https://www.bottlecaps.de/rr/ui
3. select "Edit Grammar"
4. choose "Browse" at the bottom
5. select the attachment you saved in #1
6. choose "Load" at the bottom
7. select "View Diagram"

You can even click on the yellow boxes to see the sub-grammar. People
have asked for railroad diagrams in the past, and this certainly
produces them, and "Options" allows many customizations.

I tried downloading as XHTML+SVG and HTML+PNG but got an error:

HTTP Status 500 – Internal Server Error

Type Exception Report

Message The multi-part request contained parameter data (excluding
uploaded files) that exceeded the limit for maxPostSize set on the
associated connector

Description The server encountered an unexpected condition that
prevented it from fulfilling the request.

It might be nice to download this output and host it on the Postgres
website at some point.
 
--
  Bruce Momjian  https://momjian.us
  EDB  https://enterprisedb.com

  If only the physical world exists, free will is an illusion.












Re: Grammar railroad diagram

2021-07-09 Thread Domingo Alvarez Duarte

Hello Andres !

There is two ways to achieve it:

-1 I just add the bison grammar in CocoR format here 
https://github.com/mingodad/CocoR-CPP in the examples folder.


-2 I created an small extension to Bison to do the same and published 
the patch here 
https://github.com/mingodad/bison/commit/da84329ebe5f4bc111ef34b2d46088b655a217f3 
(bison -e yourgramar.y)


And optionally to have the best railroad diagram we need to add the 
"Tokens" manually.


Cheers !

On 9/7/21 4:36, Andres Freund wrote:

Hi,

On 2021-07-03 10:39:02 +0200, Domingo Alvarez Duarte wrote:

I've done a experimental tool to convert bison grammars to a kind of EBNF
understood by https://www.bottlecaps.de/rr/ui

It'd be nice if you could share that tool. The diagrams this can generate
are neat...

Greetings,

Andres Freund





Re: Grammar railroad diagram

2021-07-08 Thread Andres Freund
Hi,

On 2021-07-03 10:39:02 +0200, Domingo Alvarez Duarte wrote:
> I've done a experimental tool to convert bison grammars to a kind of EBNF
> understood by https://www.bottlecaps.de/rr/ui

It'd be nice if you could share that tool. The diagrams this can generate
are neat...

Greetings,

Andres Freund




Re: Grammar railroad diagram

2021-07-06 Thread Domingo Alvarez Duarte

Hello Bruce !

You can download the railroad generator to generate offline using Java 
here -> https://www.bottlecaps.de/rr/download/rr-1.63-java8.zip (link 
from the https://www.bottlecaps.de/rr/ui on tab Welcome).


java -jar rr.war -out:Dafny.atg.xhtml grammar.txt

Cheers !

On 6/7/21 18:51, Bruce Momjian wrote:

On Sat, Jul  3, 2021 at 10:39:02AM +0200, Domingo Alvarez Duarte wrote:

I've done a experimental tool to convert bison grammars to a kind of EBNF
understood by https://www.bottlecaps.de/rr/ui to generate railroad diagrams see
bellow the converted 'postgresql-13.3/src/backend/parser/gram.y' and with some
hand made changes to allow view it at https://www.bottlecaps.de/rr/ui the order
of the rules could be changed to a better view of the railroad diagrams. Copy
and paste the EBNF bellow on https://www.bottlecaps.de/rr/ui tab Edit Grammar
then switch to the tab View Diagram.

That is pretty cool.  I had trouble figuring out how to get it working,
so here are the steps I used:

1.  save my attachment (created by Domingo)
2.  go to https://www.bottlecaps.de/rr/ui
3.  select "Edit Grammar"
4.  choose "Browse" at the bottom
5.  select the attachment you saved in #1
6.  choose "Load" at the bottom
7.  select "View Diagram"

You can even click on the yellow boxes to see the sub-grammar.  People
have asked for railroad diagrams in the past, and this certainly
produces them, and "Options" allows many customizations.

I tried downloading as XHTML+SVG and HTML+PNG but got an error:

HTTP Status 500 – Internal Server Error

Type Exception Report

Message The multi-part request contained parameter data (excluding
uploaded files) that exceeded the limit for maxPostSize set on the
associated connector

Description The server encountered an unexpected condition that
prevented it from fulfilling the request.

It might be nice to download this output and host it on the Postgres
website at some point.






Re: Grammar railroad diagram

2021-07-06 Thread Bruce Momjian
On Sat, Jul  3, 2021 at 10:39:02AM +0200, Domingo Alvarez Duarte wrote:
> I've done a experimental tool to convert bison grammars to a kind of EBNF
> understood by https://www.bottlecaps.de/rr/ui to generate railroad diagrams 
> see
> bellow the converted 'postgresql-13.3/src/backend/parser/gram.y' and with some
> hand made changes to allow view it at https://www.bottlecaps.de/rr/ui the 
> order
> of the rules could be changed to a better view of the railroad diagrams. Copy
> and paste the EBNF bellow on https://www.bottlecaps.de/rr/ui tab Edit Grammar
> then switch to the tab View Diagram.

That is pretty cool.  I had trouble figuring out how to get it working,
so here are the steps I used:

1.  save my attachment (created by Domingo)
2.  go to https://www.bottlecaps.de/rr/ui
3.  select "Edit Grammar"
4.  choose "Browse" at the bottom
5.  select the attachment you saved in #1
6.  choose "Load" at the bottom
7.  select "View Diagram"

You can even click on the yellow boxes to see the sub-grammar.  People
have asked for railroad diagrams in the past, and this certainly
produces them, and "Options" allows many customizations.

I tried downloading as XHTML+SVG and HTML+PNG but got an error:

HTTP Status 500 – Internal Server Error

Type Exception Report

Message The multi-part request contained parameter data (excluding
uploaded files) that exceeded the limit for maxPostSize set on the
associated connector

Description The server encountered an unexpected condition that
prevented it from fulfilling the request.

It might be nice to download this output and host it on the Postgres
website at some point.

-- 
  Bruce Momjian  https://momjian.us
  EDB  https://enterprisedb.com

  If only the physical world exists, free will is an illusion.

stmtblock ::= stmtmulti
stmtmulti ::= stmtmulti ';' stmt | stmt
stmt ::= AlterEventTrigStmt | AlterCollationStmt | AlterDatabaseStmt | 
AlterDatabaseSetStmt | AlterDefaultPrivilegesStmt | AlterDomainStmt | 
AlterEnumStmt | AlterExtensionStmt | AlterExtensionContentsStmt | 
AlterFdwStmt | AlterForeignServerStmt | AlterForeignTableStmt | 
AlterFunctionStmt | AlterGroupStmt | AlterObjectDependsStmt | 
AlterObjectSchemaStmt | AlterOwnerStmt | AlterOperatorStmt | 
AlterTypeStmt | AlterPolicyStmt | AlterSeqStmt | AlterSystemStmt | 
AlterTableStmt | AlterTblSpcStmt | AlterCompositeTypeStmt | 
AlterPublicationStmt | AlterRoleSetStmt | AlterRoleStmt | 
AlterSubscriptionStmt | AlterStatsStmt | AlterTSConfigurationStmt | 
AlterTSDictionaryStmt | AlterUserMappingStmt | AnalyzeStmt | CallStmt | 
CheckPointStmt | ClosePortalStmt | ClusterStmt | CommentStmt | 
ConstraintsSetStmt | CopyStmt | CreateAmStmt | CreateAsStmt | 
CreateAssertionStmt | CreateCastStmt | CreateConversionStmt | 
CreateDomainStmt | CreateExtensionStmt | CreateFdwStmt | 
CreateForeignServerStmt | CreateForeignTableStmt | CreateFunctionStmt | 
CreateGroupStmt | CreateMatViewStmt | CreateOpClassStmt | 
CreateOpFamilyStmt | CreatePublicationStmt | AlterOpFamilyStmt | 
CreatePolicyStmt | CreatePLangStmt | CreateSchemaStmt | CreateSeqStmt | 
CreateStmt | CreateSubscriptionStmt | CreateStatsStmt | 
CreateTableSpaceStmt | CreateTransformStmt | CreateTrigStmt | 
CreateEventTrigStmt | CreateRoleStmt | CreateUserStmt | 
CreateUserMappingStmt | CreatedbStmt | DeallocateStmt | 
DeclareCursorStmt | DefineStmt | DeleteStmt | DiscardStmt | DoStmt | 
DropCastStmt | DropOpClassStmt | DropOpFamilyStmt | DropOwnedStmt | 
DropPLangStmt | DropStmt | DropSubscriptionStmt | DropTableSpaceStmt | 
DropTransformStmt | DropRoleStmt | DropUserMappingStmt | DropdbStmt | 
ExecuteStmt | ExplainStmt | FetchStmt | GrantStmt | GrantRoleStmt | 
ImportForeignSchemaStmt | IndexStmt | InsertStmt | ListenStmt | 
RefreshMatViewStmt | LoadStmt | LockStmt | NotifyStmt | PrepareStmt | 
ReassignOwnedStmt | ReindexStmt | RemoveAggrStmt | RemoveFuncStmt | 
RemoveOperStmt | RenameStmt | RevokeStmt | RevokeRoleStmt | RuleStmt | 
SecLabelStmt | SelectStmt | TransactionStmt | TruncateStmt | 
UnlistenStmt | UpdateStmt | VacuumStmt | VariableResetStmt | 
VariableSetStmt | VariableShowStmt | ViewStmt |
CallStmt ::= CALL func_application
CreateRoleStmt ::= CREATE ROLE RoleId opt_with OptRoleList
opt_with ::= WITH | WITH_LA |
OptRoleList ::= OptRoleList CreateOptRoleElem |
AlterOptRoleList ::= AlterOptRoleList AlterOptRoleElem |
AlterOptRoleElem ::= PASSWORD Sconst | PASSWORD NULL_P | ENCRYPTED 
PASSWORD Sconst | UNENCRYPTED PASSWORD Sconst | INHERIT | CONNECTION 
LIMIT SignedIconst | VALID UNTIL Sconst | USER role_list | IDENT
CreateOptRoleElem ::= AlterOptRoleElem | SYSID Iconst | ADMIN role_list 
| ROLE role_list | IN_P ROLE role_list | IN_P GROUP_P role_list
CreateUserStmt ::= CREATE USER RoleId opt_with OptRoleList
AlterRoleStmt ::= ALTER ROLE RoleSpec opt_with AlterOptRoleList | ALTER 
USER RoleSpec