Benutzer-Werkzeuge

Webseiten-Werkzeuge


ebnf:examples

EBNF Examples

Arithmetic Expressions

<ebnf> "Arithmetic Expressions" {
expression = term  { ("+" | "-") term} .
term       = factor  { ("*"|"/") factor} .
factor     = constant | variable | "("  expression  ")" .
variable   = "x" | "y" | "z" .
constant   = digit {digit} .
digit      = "0" | "1" | "..." | "9" .
} </ebnf>

<ebnf> „Arithmetic Expressions“ { expression = term { („+“ | „-“) term} . term = factor { („*“|„/“) factor} . factor = constant | variable | „(“ expression „)“ . variable = „x“ | „y“ | „z“ . constant = digit {digit} . digit = „0“ | „1“ | „…“ | „9“ . } </ebnf>

See: http://en.wikipedia.org/wiki/Syntax_diagram

Designator

<ebnf> "Designator" {
  Designator = (ident | "this" | "super") {"." ident | "[" Expr "]"}.
} </ebnf>

<ebnf> „Designator“ {

Designator = (ident | "this" | "super") {"." ident | "[" Expr "]"}.

} </ebnf>

See: http://dotnet.jku.at/applications/Visualizer/#Simple

Backus-Naur Form (BNF)

<ebnf> "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   = "-" | "_" .
} </ebnf>

<ebnf> „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   = "-" | "_" .

} </ebnf>

Adapted from: http://en.wikipedia.org/wiki/Wirth_syntax_notation

ebnf/examples.txt · Zuletzt geändert: 2011/05/30 12:29 von 127.0.0.1

Donate Powered by PHP Valid HTML5 Valid CSS Driven by DokuWiki