Documentation/SyntaxDiagrams

Preamble
Definition and purpose of Syntax diagrams can be found in wikipedia. Diagrams are produced either using Backus–Naur form (BNF) - or any grammar derived from BNF - either resorting to specific program libraries. Diagrams generation is only illustrated using either Railroad Diagram Generator from Gunther Rademacher, either Railroad Diagrams by Tab Atkins. This page assumes you know how to read syntax diagrams.

Mockup, Cheatsheet
Demonstration diagrams for LibreOffice Basic language can be found in this page.

A Basic Syntax cheatsheet (draft) can be found in this page.

Railroad Diagrams

 * Railroad Diagram Generator supports the BNF grammar, .xhtml or .png file generation as well as diagram prototyping.
 * Railroad Diagrams allows diagram prototyping, default options in statements, .svg file generation. Inline .svg diagram generation is possible with its JavaScript library.

Using Tab Atkins' Diagrams
LibreOffice Basic syntax diagrams use Railroad Diagrams. They are generated with its Python library, sources are stored here. Original styling has been tweaked by Ilmari Lauhakangas. Conventions used are:
 * Call statement syntax in online help
 * Basic keywords use propercasing e.g. Call, DimArray, MsgBox, Property, ..
 * Variables are denoted with lowercase e.g. expression, param, value, ..
 * Non-terminal items are denoted with lowercase and rectangles.
 * Diagram fragments are denoted with different extremities.
 * Previous notation in help files remains and is modified when appropriate.

Prototyping with JavaScript library
Diagrams are prototyped locally using generator-no-module.html or online from here. LibreOffice Basic LET statement JavaScript/Python example diagram:

Generating SVG with Python library
Scalable Vector Graphics files can be generated directly from LibreOffice, by copying the prototyped diagram code into Python example file below. Please make sure to drop railroad.py module in LibreOffice folder beforehand. With Python:



Using Gunther Rademacher's Diagrams
Sample diagrams produced out of Railroad Diagram Generator are stored in Documentation team Nextcloud instance.

LibreOffice Basic CALL statement BNF example:

Python.org documentation uses intensively BNF notation without exhibiting diagrams.

Python import statement BNF example: