Syntax diagram: Difference between revisions

Content deleted Content added
Principle of syntax diagrams: square => rectangular
m Task 70: Update syntaxhighlight tags - remove use of deprecated <source> tags
Line 10:
 
We use arithmetic expressions as an example. First we provide a simplified BNF grammar:
<sourcesyntaxhighlight lang="bnf">
<expression> ::= <term> | <term> "+" <expression>
<term> ::= <factor> | <factor> "*" <term>
Line 18:
<digit> ::= "0" | "1" | "2" | "3" | "4" | "5" | "6" | "7" | "8" | "9"
 
</syntaxhighlight>
</source>
 
This grammar can also be expressed in EBNF:
<sourcesyntaxhighlight lang="ebnf">
expression = term , [ "+" , expression ];
term = factor , [ "*" , term ];
Line 29:
digit = "0" | "1" | "2" | "3" | "4" | "5" | "6" | "7" | "8" | "9";
 
</syntaxhighlight>
</source>
 
One possible set of syntax diagrams for either of these grammars is: