Question

(8) (3 marks) Write BNF grammar rules for a language that is comprised only of sentences described as follows: symbol, fol sy

0 0
Add a comment Improve this question Transcribed image text
Answer #1

(8) BNF

A sequence is

  • one or more occurrences of an a symbol, followed by
  • either 0 or more z symbols or just one x symbol, followed by
  • a sequence is one or more occurrences of b symbol

<sequence> :: = <a_symbol>+ ( <z_symbol>* | <x_symbol> ) <b_symbol>+

<a_symbol> :: = a

<z_symbol> :: = z

<x_symbol> :: = x

<b_symbol> :: = b

OR

<sequence> :: = a+ ( z* | x ) b+

where,

  • + is used to indicate one or more occurrences,
  • * is used to indicate 0 or more occurrences,
  • | is used to indicate or.

(9) Associativity

factor --> expr ** factor | expr

'factor' is to the right side of the operator => right associativity

The factor has to be expanded first to evaluate the expression - >right associative

(10) Major styles of parser

  • Top - down parser

Starts with start symbol and transforms it into input string.

Derivation order : Leftmost derivation order

  • Bottom - up parser

Starts with input string and goes up to the start symbol.

Derivation order : Rightmost derivation in reverse order

(11) Variable bound at

  • Compile time : binding to a datatype
  • Link time : binding static variable to memory
  • Run time : binding non static local variable to memory

(12) Lifetime of a program variable:

Indicates which part of program the variable is active (valid memory)

Add a comment
Know the answer?
Add Answer to:
(8) (3 marks) Write BNF grammar rules for a language that is comprised only of sentences described as follows: symbol,...
Your Answer:

Post as a guest

Your Name:

What's your source?

Earn Coins

Coins can be redeemed for fabulous gifts.

Not the answer you're looking for? Ask your own homework help question. Our experts will answer your question WITHIN MINUTES for Free.
Similar Homework Help Questions
  • 1. (p. 2-3.) Which of the following is NOT a reason for studying concepts of programming...

    1. (p. 2-3.) Which of the following is NOT a reason for studying concepts of programming languages according to Sebesta? a. Increased capacity to express ideas. b. Improved background for choosing appropriate languages. c. Increased ability to design new languages. d. Increased ability to learn new languages. 2. (p. 5-6.) What programming language has dominated scientific computing over the past 50 years? a. FORTRAN b. ALGOL c. SNOBOL d. PL/I 3. (p. 6.) What programming language has dominated artificial intelligence...

ADVERTISEMENT
Free Homework Help App
Download From Google Play
Scan Your Homework
to Get Instant Free Answers
Need Online Homework Help?
Ask a Question
Get Answers For Free
Most questions answered within 3 hours.
ADVERTISEMENT
ADVERTISEMENT
ADVERTISEMENT