|
|
|
Backus-Naur Form |
|---|---|---|
| |
||
|
|
BNF is a tool for describing the syntax of a context-free grammar. It is used here to describe Regular Expression Syntax. BNF defines the set of all possible strings of symbols that constitute legal programs (i.e. strings) in a language. Each production rule in the grammar has an analogous BNF rule.
|
|
|
BNF Production RulesBNF describes the syntax of a grammar using a set of production rules using terminal and non-terminal symbols.
terminalTerminal symbols (characters or character sequences) are bracketed by the meta-symbol "'". For example: the symbol or character a 'a'
non-terminalNon-terminal symbols are bracketed by the meta-symbols "<" and ">". For example: the non-terminal symbol set <set>
production ruleEach production rule has a left hand side (LHS) and a right hand side (RHS) separated by the meta-symbol "::=" (read as "consists of" or "defined as"). The LHS is defined by the RHS. The LHS is a non-terminal symbol. The RHS is some sequence of terminal and non-terminal symbols that define the rule. For example: set is defined as a subset and another subset. <set> ::= <subset> <subset>
repetitionA symbol or symbols enclosed in curly brackets ( { and } ) denotes possible repetition of the enclosed symbols zero or more times. For example: set is defines as 0 or more subsets <set> ::= { <subset> }
alternateThe meta-symbol "|" (read as "or") is used to define alternate RHS definitions. For example: set is defined as a subset or a set and a subset <set> ::= <subset> | <set> <subset>
|
|
| |
||
Last updated
| ||