Content deleted Content added
m →Example: "because is a metalanguage" -> "because it is a metalanguage" |
m General fixes, removed erroneous space |
||
Line 1:
'''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]]
== Principle of syntax diagrams ==
Line 9:
== Example ==
We use arithmetic expressions as an example, in various grammar formats.
BNF:
Line 44:
Note that ABNF also supports ranges, e.g. '''DIGIT = %x30-39''', but it is not used here for consistency with the other examples.
[[
<syntaxhighlight lang="Red">
expression: [term opt ["+" expression]]
Line 54:
</syntaxhighlight>
Note that this format also supports ranges, e.g. '''digit: charset [#"0" - #"9"]''', but it is not used here for consistency with the other examples.
One possible syntax diagram for the example grammars is below. Note that 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]].
|