Syntax diagram

Syntax diagram

Syntax diagrams (or railroad diagrams) are a way to represent a formal grammar. They represent a graphical alternative to Backus-Naur Form or EBNF. Early books using syntax diagrams include the "Pascal User Manual" written by Niklaus Wirth [http://www.standardpascal.org/The_Programming_Language_Pascal_1973.pdf Niklaus Wirth: "The Programming Language Pascal." (July 1973)] ] (diagrams start at page 47) and the Burroughs CANDE manual http://bitsavers.org/pdf/burroughs/B6500_6700/5000318_B6700_CANDE_Oct72.pdf] . In the compilation field, textual representations like BNF or its variants are usually preferred. BNF is well understood by compiler writers and compilers, but is not well understood by most users of languages. Railroad diagrams are more readily understood by most people. Some of the popularity of the JSON data interchange format is due to its representation in railroad diagrams.

Principle

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 possibles 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

We use arithmetic expressions as an example. First we provide a simplified BNF grammar: ::= | "+" ::= | "*" ::= | | "(" ")" ::= "x" | "y" | "z" ::= | ::= "0" | "1" | "2" | "3" | "4" | "5" | "6" | "7" | "8" | "9"

This grammar can also be expressed in EBNF:expression = term , {"+" term};term = factor , {"*" factor};factor = constant | variable | "(" , expression , ")";variable = "x" | "y" | "z"; constant = digit , {digit};digit = "0" | "1" | "2" | "3" | "4" | "5" | "6" | "7" | "8" | "9";

One possible set of syntax diagrams for this grammar is:

ee also

* Extended Backus-Naur form (EBNF)

References

External links

* [http://www.json.org/ JSON website including syntax diagrams]
* [http://www-cgi.uni-regensburg.de/~brf09510/syntax.html Automatic generator of syntax diagrams]
* [http://www-cgi.uni-regensburg.de/~brf09510/syntax/lazyebnf.ebnf.html Syntax diagrams of BNF]
* [http://dotnet.jku.at/applications/Visualizer/ Generator from EBNF]
* [http://www.informatik.uni-freiburg.de/~thiemann/haskell/ebnf2ps/ From EBNF to a postscript file wit the diagrams]


Wikimedia Foundation. 2010.

Игры ⚽ Нужно решить контрольную?

Look at other dictionaries:

  • Sentence diagram — X bar theory graph of the sentence He studies linguistics at the university. IP = Inflectional phrase. In pedagogy, a sentence diagram is a pictorial representation of the grammatical structure of a natural language sentence. A sentence diagram… …   Wikipedia

  • Space syntax — The term space syntax encompasses a set of theories and techniques for the analysis of spatial configurations. Originally it was conceived by Bill Hillier, Julienne Hanson and colleagues at The Bartlett, University College London in the late… …   Wikipedia

  • Backus–Naur Form — In computer science, Backus–Naur Form (BNF) is a metasyntax used to express context free grammars: that is, a formal way to describe formal languages. John Backus and Peter Naur developed a context free grammar to define the syntax of a… …   Wikipedia

  • Augmented transition network — An augmented transition network (ATN) is a type of graph theoretic structure used in the operational definition of formal languages, used especially in parsing relatively complex natural languages, and having wide application in artificial… …   Wikipedia

  • синтаксическая диаграмма — — [http://www.iks media.ru/glossary/index.html?glossid=2400324] Тематики электросвязь, основные понятия EN syntax diagram …   Справочник технического переводчика

  • linguistics — /ling gwis tiks/, n. (used with a sing. v.) the science of language, including phonetics, phonology, morphology, syntax, semantics, pragmatics, and historical linguistics. [1850 55; see LINGUISTIC, ICS] * * * Study of the nature and structure of… …   Universalium

  • Diagrammatic reasoning — is reasoning by means of visual representations. The study of diagrammatic reasoning is about the understanding of concepts and ideas, visualized with the use of diagrams and imagery instead of by linguistic or algebraic means. Contents 1 Related …   Wikipedia

  • Boolean algebra (introduction) — Boolean algebra, developed in 1854 by George Boole in his book An Investigation of the Laws of Thought , is a variant of ordinary algebra as taught in high school. Boolean algebra differs from ordinary algebra in three ways: in the values that… …   Wikipedia

  • Boolean algebra — This article discusses the subject referred to as Boolean algebra. For the mathematical objects, see Boolean algebra (structure). Boolean algebra, as developed in 1854 by George Boole in his book An Investigation of the Laws of Thought,[1] is a… …   Wikipedia

  • Comment (computer programming) — For comments in Wikipedia markup, see Help:Wiki markup#Character formatting and WP:COMMENT. An illustration of Java source code with prologue comments indicated in red and inline comments in green. Program code is in blue …   Wikipedia

Share the article and excerpts

Direct link
Do a right-click on the link above
and select “Copy Link”