View the step-by-step solution to:

Module 2 2.1 Which of the four enumerated strings can be derived from the following grammar (starting with <S>)?

ok--that is too much for that assignment... i have attached another in rtf format..please advise how much this will cost...

Module 2 2.1 Which of the four enumerated strings can be derived from the following grammar (starting with <S>)? <S> -> <A> <B> <C> <A> -> a <A> a <B> -> b <B> b <C> -> c <C> c i. abcabc ii. aaabbbc iii. abc iv. ab a. i, iii c. ii, iii b. i, iv d. ii, iv 2.2 Write a BNF description for the C++ if statement. Assume the following are already defined: stmt : a single statement (not including any semicolon) stmts : one or more statements (including each statement's following semicolon) expression : an expression (suitable for a condition) Make sure your description allows for if statements with a single statement in the "body" of the if , and for those with multiple statements. Remember to include all syntax elements, including braces and semicolons. 2.3 Consider each of the following examples of axiomatic semantics: a. {num >= 100} d = num * 3 {d >= 300} b. {value > 10} result = value + 1 {result > 0) Which example follows the principle of using the weakest precondition? Explain. Change the other example's precondition so that it is the weakest precondition. 2.4 Consider the following statement and postcondition: while x <= 10 do x = x + 1; y = y + 1 end {y = 20} For this statement and postcondition, create a valid precondition, and explain how you arrived at your answer.
Background image of page 1
Module 3 3.1 Suppose you were given a compiler for a new language called X. You know that X has a for loop construct similar to that of C++, but you do not know whether for is a keyword or a reserved word in the language. Explain how you could write a program to determine this. 3.2 Give an example of C++ code that creates an alias. 3.3 In the following C++ function, state where stack-dynamic and explicit heap-dynamic variables are being created: int* maker() { int x; int *pInt; x = 3; pInt = new int; *pInt = x; return pInt; } 3.4 According to the text, a language is strongly typed if: a. it is specifically designed for one purpose b. type errors are always detected c. the type for all variables must be declared d. it uses coercion to force agreement of operators 3.5 Consider the following pseudocode: s: stringType; f: floatType; i: integerType; s := '34.5478379343'; f := s; i := f; Explain why this code would be illegal under static type binding and legal under dynamic type binding. Describe the problems code such as this can cause for a programmer, even when it is legal. 3.6 Consider the following pseudocode: recordStructure Fraction is
Background image of page 2
Show entire document

Recently Asked Questions

Why Join Course Hero?

Course Hero has all the homework and study help you need to succeed! We’ve got course-specific notes, study guides, and practice tests along with expert tutors.


Educational Resources
  • -

    Study Documents

    Find the best study resources around, tagged to your specific courses. Share your own to gain free Course Hero access.

    Browse Documents
  • -

    Question & Answers

    Get one-on-one homework help from our expert tutors—available online 24/7. Ask your own questions or browse existing Q&A threads. Satisfaction guaranteed!

    Ask a Question