Link to home
Start Free TrialLog in
Avatar of shahrine99
shahrine99

asked on

BNF grammer

The following BNF grammer describes a Pascal-like syntax for declarations:
<decl_list> -> <decl> ; <decl_list>
                          | <decl>
<decl> -> <identifier> : <type>
<type> -> integar
            | real
            | record <decl_list> end
<identifier> -> a | b | c

Using this grammer, give a parse tree and a leftmost derivation for the following sentence:

a : record b : integer; c : real end
Avatar of AmigoJack
AmigoJack

what is "BNF"? by reading everything up to your last sentence, it really looks like how to declare variables, define records and which datatypes can be used.

summoned that, your last line (after your last sentence) would be a record named "a" which has the two members "b" (datatype integer) and "c" (datatype real). is that what you wanted? otherwise please rephrase your last sentence or tell me what a "parse tree" and a "leftmost derivation" is

<identifier> : <type> (where type is a <decl_list> because its no simple datatype)
ASKER CERTIFIED SOLUTION
Avatar of AmigoJack
AmigoJack

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
Avatar of shahrine99

ASKER

ok....ya it seems right...i looked at my book and looked at several examples for leftmost derviatives and yours seem similiar to it...but what about parse tree? BNF means Backus-Naur Form...it is a way to describe a language in a mathmatical way..i see that you already visted the link that u sent to me.
BNF = Backus Naur Form

A little history: It is based on Chomsky's grammar rules and was  originally used to describe Algol 60.
John Backus is the inventor of Fortran.
Peter Naur  - see http://en.wikipedia.org/wiki/Peter_Naur - he prefers BNF to be called Backus Normal Form.