60 likes | 141 Vues
Learn about Backus-Naur Form (BNF), a formal mathematical language description method that eliminates ambiguity, using production rules and symbols. Explore how BNF defines a language's grammar, with a notation system for generating strings. Example BNF grammar included.
E N D
What is it? • A formal, mathematical way to describe a language • It describes the grammar of a language, so that there is no disagreement or ambiguity as to what is allowed • How ….?
Production Rules • Symbol := alternative1 | alternative 2 … • alternative1 := subsymbol1 | terminal • Terminals are the end of the line, they terminate the production process. • The language described is the set of all the strings you can produce by following the production rules
Example BNF Grammar <S> := ‘-’ <FN> | <FN> <FN> := <DL> | <DL> ‘.’ <DL> <DL> := <D> | <D> <DL> <D> := ‘0’|’1’|’2’|’3’|’4’|’5’ |’6’|’7’|’8’|’9’ S=Start Symbol, FN = Fractional Number, DL = Digit list, D=digit