Syntax diagram
Syntax diagrams (or railroad diagrams) are a way to represent a context-free grammar. They represent a graphical alternative to Backus–Naur form, EBNF, Augmented Backus–Naur form, and other text-based grammars as metalanguages. Early books using syntax diagrams include the "Pascal User Manual" written by Niklaus Wirth (diagrams start at page 47) and the Burroughs CANDE Manual. 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... Source: e01 Encyclopedia. Licence: CC BY-SA 4.0.
Syntax diagrams (or railroad diagrams) are a way to represent a context-free grammar. They represent a graphical alternative to Backus–Naur form, EBNF, Augmented Backus–Naur form, and other text-based grammars as metalanguages. Early books using syntax diagrams include the "Pascal User Manual" written by Niklaus Wirth (diagrams start at page 47) and the Burroughs CANDE Manual. 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. ::= | "+" ::= | "*" ::= | | "(" ")" ::= "x" | "y" | "z" ::= | ::= "0" | "1" | "2" | "3" | "4" | "5" | "6" | "7" | "8" | "9" EBNF: expression = term , [ "+" , expression ]; term = factor , [ "*" , term ]; factor = constant | variable | "(" , expression , ")"; variable = "x" | "y" | "z"; constant = digit , { constant }; digit = "0" | "1" | "2" | "3" | "4" | "5" | "6" | "7" | "8" | "9"; ABNF: expression = term ["+" expression] term = factor ["*" term] factor = constant / variable / "(" expression ")" variable = "x" / "y" / "z" constant = 1*digit DIGIT = "0" / "1" / "2" / "3" / "4" / "5" / "6" / "7" / "8" / "9" ABNF also supports ranges, e.g. , but it is not used here for consistency with the other examples. Red (programming language) Parse Dialect: Red [Title: "Parse Dialect"] expression: [term opt ["+" expression]] term: [factor opt ["*" term]] factor: [constant | variable | "(" expression ")"] variable: ["x" | "y" | "z"] constant: [some digit] digit: ["0" | "1" | "2" | "3" | "4" | "5" | "6" | "7" | "8" | "9"] This format also supports ranges, e.g. , but it is not used here for consistency with the other examples. One possible syntax diagram for the example grammars is below. While the syntax for the text-based grammars differs, the syntax diagram for all of them can be the same because it is a metalanguage. ==See also== Recursive transition network Extended Backus–Naur form (EBNF) ==References== Note: the first link is sometimes blocked by the server outside of its domain, but it is available on archive.org. The file was also mirrored at standardpascal.org. ==External links== JSON website including syntax diagrams Generator from EBNF From EBNF to a postscript file with the diagrams EBNF Parser & Renderer SQLite syntax diagram generator for SQL Online Railroad Diagram Generator Augmented Syntax Diagram (ASD) grammars (ASD) Augmented Syntax Diagram Application Demo Site SRFB Syntax Diagram representation by Function Basis + svg generation
Cite this
"Syntax diagram". 1760310427. e01 Encyclopedia. CC BY-SA 4.0. https://en.wikipedia.org/w/index.php?oldid=1316532313 JSON record · API collection · BibTeX · RIS · CSL-JSON · citation policy