Syntax diagram: Difference between revisions

Content deleted Content added
Bender the Bot (talk | contribs)
m References: HTTP to HTTPS for Wayback Machine, replaced: http://web.archive.org/ → https://web.archive.org/
JMCorey (talk | contribs)
Example: fix both BNF and EBNF to look like railroad diagram cf talk page
Line 11:
We use arithmetic expressions as an example. First we provide a simplified BNF grammar:
<source lang="bnf">
<expression> ::= <term> | <expressionterm> "+" <termexpression>
<term> ::= <factor> | <termfactor> "*" <factorterm>
<factor> ::= <constant> | <variable> | "(" <expression> ")"
<variable> ::= "x" | "y" | "z"
Line 22:
This grammar can also be expressed in [[EBNF]]:
<source lang="ebnf">
expression = term | expression, [ "+" , termexpression ];
term = factor | term, [ "*" , factorterm ];
factor = constant | variable | "(" , expression , ")";
variable = "x" | "y" | "z";
constant = digit , { digit };
digit = "0" | "1" | "2" | "3" | "4" | "5" | "6" | "7" | "8" | "9";