Fig .3These two programs statement have identical syntax. Each is an assignmentstatement; the value to be assigned is given by an expression that consists of two variablenames separated by the operator '+'.The semantics of the two statements are quite different. The first statementspecifies that the variables in the expressions are to be added using integer arithmeticoperations. The second statement specifies a floating-point addition, with the integer operand 2 being connected to floating point before adding. The difference between thestatements would be recognized during code generation.Grammar can be written using a number of different notations. Backus-Naur Form (BNF) is one of the methods available. It is simple and widely used. It providescapabilities that are different for most purposes.A BNF grammar consists of a set of rules, each of which defines the syntax of some construct in the programming language.A grammar has four components. They are:
A set of tokens, known as terminal symbols non-enclosed in bracket.
READ, WRITE2.A set of terminals. The character strings enclosed between the angle brackets(<, >) are called terminal symbols. These are the names of the constructsdefined in the grammar.3.A set of productions where each production consists of a non-terminal calledthe left side of the production, as "is defined to be" (:: = ), and a sequence of token and/or non-terminal, called the right side of the product.
: < reads > : : = READ <id - list >.4.A designation of one of the non-terminals as the start symbol.This rule offers two possibilities separated by the symbol, for the syntax of an< id - list > may consist simply of a token
denotes an identifier that isrecognized by the scanner). The second syntax.
ALPHAALPHA, BETAALPHA is an < id - list > that consist of another < id - list > ALPHA, followed by a comma, followed by an
It is also called parse tree or syntax tree. It is convenient to display theanalysis of a source statement in terms of a grammar as a tree.
READ (VALUE)GRAMMAR: (read) : : = READ ( < id -list>)
SUM : = 0 ;SUM : = + VALUE ;