Syntax diagram: Difference between revisions

Content deleted Content added
m Reverted edits by 89.255.27.240 (talk) to last version by Pavelik
Line 1:
KAAS IS LEKKER'''Syntax diagrams''' (or '''railroad diagrams''') are a way to represent a [[context-free grammar]]. They represent a graphical alternative to [[Backus–Naur form]] or to [[EBNF]] as [[metalanguages]]. Early books using syntax diagrams include the "Pascal User Manual" written by Niklaus Wirth <ref name="Wirth1974">[http://e-collection.library.ethz.ch/eserv/eth:3059/eth-3059-01.pdf Niklaus Wirth: ''The Programming Language Pascal.'' (July 1973)]</ref> (diagrams start at page 47) and the Burroughs [[CANDE]] Manual.<ref name="burroughs71">[http://bitsavers.org/pdf/burroughs/B6500_6700/5000318_B6700_CANDE_Oct72.pdf Burroughs B6700/B7700 ''Command AND Edit (CANDE) Language: Information Manual'']</ref>. In the compilation field, textual representations like BNF or its variants are usually preferred. BNF is text-based, and used by compiler writers and parser generators. Railroad diagrams are visual, and may be more readily understood by laypeople, sometimes incorporated into graphic design. The canonical source defining the [[JSON]] data interchange format provides yet another example of a popular modern usage of these diagrams.
 
== Principle of syntax diagrams ==
 
kASjsio
The representation of a grammar is made of a set of syntax diagrams. Each diagram defines a non-terminal. There is a main diagram which defines the language in the following way: to belong to the language, a word must describe a path in the main diagram.
 
Each diagram has an entry point and an end point. The diagram describes possible paths between these two points by going through other nonterminals and terminals. Terminals are represented by round boxes while nonterminals are represented by square boxes.
 
== Example ==