1. Core EBNF Operators & Syntax
In EBNF syntax diagrams, production rules use standard formal grammar notation to define terminals, non-terminals, choices, and repetitions along a visual track.| EBNF Notation | Railroad Meaning | Description |
|---|---|---|
rule = ... ; |
Production Rule | Defines a named grammar rule ended with a semicolon |
"literal" |
Terminal Node | Represents exact characters or keywords enclosed in double quotes |
| |
Choice Branch | Branches the track into mutually exclusive alternatives |
( ... )* |
Zero-or-More Loop | Creates a returning loop track for elements that can repeat 0 or more times |
+ |
One-or-More Loop | Indicates an element that must occur at least once |
Mermaid
Edit Mermaid in VPasCode
railroad-ebnf-beta
title "Basic Token Rule"
identifier = letter ( letter | digit )* ;
letter = "a" | "b" | "c" ;
digit = "0" | "1" | "2" ; 
2. Arithmetic Expression Grammar Example
Use production rules to model nested language structures such as mathematical expressions, operator precedence, and parenthesized grouping.
Mermaid
Edit Mermaid in VPasCode
railroad-ebnf-beta
title "Arithmetic Expression Grammar"
expression = term ( ( "+" | "-" ) term )* ;
term = factor ( ( "*" | "/" ) factor )* ;
factor = number | "(" expression ")" ;
number = digit+ ;
digit = "0" | "1" | "2" | "3" | "4" | "5" | "6" | "7" | "8" | "9" ; 
3. Command & Query Language Example
The following example demonstrates a complete SQL query production rule set mapped directly from EBNF notation into a visual railroad syntax diagram.
Mermaid
Edit Mermaid in VPasCode
railroad-ebnf-beta
title "SQL Statement Grammar"
select_statement = "SELECT" column_clause "FROM" table_name [ where_clause ] ;
column_clause = "*" | column_name ( "," column_name )* ;
where_clause = "WHERE" condition ;
table_name = identifier ;
column_name = identifier ;
identifier = "a" | "b" | "c" ; 