====== EBNF Examples ======
~~NOCACHE~~
===== Arithmetic Expressions =====
"Arithmetic Expressions" {
expression = term { ("+" | "-") term} .
term = factor { ("*"|"/") factor} .
factor = constant | variable | "(" expression ")" .
variable = "x" | "y" | "z" .
constant = digit {digit} .
digit = "0" | "1" | "..." | "9" .
}
"Arithmetic Expressions" {
expression = term { ("+" | "-") term} .
term = factor { ("*"|"/") factor} .
factor = constant | variable | "(" expression ")" .
variable = "x" | "y" | "z" .
constant = digit {digit} .
digit = "0" | "1" | "..." | "9" .
}
See: http://en.wikipedia.org/wiki/Syntax_diagram
===== Designator =====
"Designator" {
Designator = (ident | "this" | "super") {"." ident | "[" Expr "]"}.
}
"Designator" {
Designator = (ident | "this" | "super") {"." ident | "[" Expr "]"}.
}
See: http://dotnet.jku.at/applications/Visualizer/#Simple
===== Backus-Naur Form (BNF) =====
"Backus-Naur Form" {
syntax = rule [ syntax ] .
rule = opt-ws identifier opt-ws "::=" opt-ws expression opt-ws EOL .
expression = list [ "|" expression ] .
line-end = opt-ws EOL | line-end line-end .
list = term [ WHITESPACE list ] .
term = literal | identifier .
identifier = "<" character {character} ">" .
literal = "'" {character} "'" | '"' {character} '"' .
opt-ws = { WHITESPACE } .
character = lowercase-char | uppercase-char | digit | special-char .
lowercase-char = "a" | "b" | "..." | "z" .
uppercase-char = "A" | "B" | "..." | "Z" .
digit = "0" | "1" | "..." | "2" .
special-char = "-" | "_" .
}
"Backus-Naur Form" {
syntax = rule [ syntax ] .
rule = opt-ws identifier opt-ws "::=" opt-ws expression opt-ws EOL .
expression = list [ "|" expression ] .
line-end = opt-ws EOL | line-end line-end .
list = term [ WHITESPACE list ] .
term = literal | identifier .
identifier = "<" character {character} ">" .
literal = "'" {character} "'" | '"' {character} '"' .
opt-ws = { WHITESPACE } .
character = lowercase-char | uppercase-char | digit | special-char .
lowercase-char = "a" | "b" | "..." | "z" .
uppercase-char = "A" | "B" | "..." | "Z" .
digit = "0" | "1" | "..." | "2" .
special-char = "-" | "_" .
}
Adapted from: http://en.wikipedia.org/wiki/Wirth_syntax_notation