All Matches
Solution Library
Expert Answer
Textbooks
Search Textbook questions, tutors and Books
Oops, something went wrong!
Change your search query and then try again
Toggle navigation
FREE Trial
S
Books
FREE
Tutors
Study Help
Expert Questions
Accounting
General Management
Mathematics
Finance
Organizational Behaviour
Law
Physics
Operating System
Management Leadership
Sociology
Programming
Marketing
Database
Computer Network
Economics
Textbooks Solutions
Accounting
Managerial Accounting
Management Leadership
Cost Accounting
Statistics
Business Law
Corporate Finance
Finance
Economics
Auditing
Hire a Tutor
AI Study Help
New
Search
Search
Sign In
Register
study help
computer science
concepts of programming languages
Questions and Answers of
Concepts of Programming Languages
What is the general problem with static scoping?
How is a reference to a nonlocal variable in a static-scoped program connected to its definition?
Consider the following program, written in JavaScript- like syntax:Given the following calling sequences and assuming that dynamic scoping is used, what variables are visible during execution of the
Define lifetime, scope, static scope, and dynamic scope.
Consider the following skeletal C program:Given the following calling sequences and assuming that dynamic scoping is used, what variables are visible during execution of the last function called?
Define static, stack-dynamic, explicit heap-dynamic, and implicit heap-dynamic variables. What are their advantages and disadvantages?
Consider the following C program:For each of the four marked points in this function, list each visible variable, along with the number of the definition statement that defines it. void fun (void) {
What are the advantages and disadvantages of dynamic type binding?
Consider the following Python program:List all the variables, along with the program units where they are declared, that are visible in the bodies of sub1, sub2, and sub3, assuming static scoping is
What are the advantages and disadvantages of implicit declarations?
Consider the following JavaScript program:List all the variables, along with the program units where they are declared, that are visible in the bodies of sub1, sub2, and sub3, assuming static scoping
Define static binding and dynamic binding.
Assume the following JavaScript program was interpreted using static-scoping rules. What value of x is displayed in function sub1? Under dynamic-scoping rules, what value of x is displayed in
After language design and implementation, what are the four times bindings can take place in a program?
Write test programs in C++, Java, and C# to determine the scope of a variable declared in a for statement. Specifically, the code must determine whether such a variable is visible after the body of
Consider the following JavaScript skeletal program:Assume that the execution of this program is in the following unit order:main calls sub1sub1 calls sub2sub2 calls sub3a. Assuming static scoping, in
Define binding and binding time.
Write a C99 function that includes the following sequence of statements:x = 21;int x;x = 42;Run the program and explain the results. Rewrite the same code in C++ and Java and compare the results.
Describe a situation when a history-sensitive variable in a subprogram is useful.
What is the l-value of a variable? What is the r-value?
Repeat Programming Exercise 3 with Python.Data from Exercise 3:Write a JavaScript script that has subprograms nested three deep and in which each nested subprogram references variables defined in all
Dynamic type binding is closely related to implicit heap-dynamic variables. Explain this relationship.
Which category of C++ reference variables is always aliases?
What are the design issues for names?
What was Knuth’s insight in developing the LR parsing technique?
Given the following grammar and the right sentential form, draw a parse tree and show the phrases and simple phrases, as well as the handle.S → aAb І bBA A → ab І aAB B → aB І ba. aaAbbb.
In what fundamental way do operational semantics and denotational semantics differ?
Describe, in English, the language defined by the following grammar: → → a | a → b | b →c |C
Show a trace of the recursive descent parser given in Section 4.4.1 for the string a + b * c.
Write and test the code to implement the state diagram of Problem 1. other * start slash Com end +return COMMENT other return SLASH CODE
What are the primary tasks of a lexical analyzer?
Show a trace of the recursive descent parser given in Section 4.4.1 for the string a * (b + c).
Write and test the code to implement the state diagram of Problem 2.Data From Problem 2:Perform the pairwise disjointness test for the following grammar rules.a. A → aB І b І cBBb. B → aB І bA
Describe briefly the three approaches to building a lexical analyzer.
Modify the lexical analyzer given in Section 4.2 to recognize the following list of reserved words and return their respective token codes:for (FOR_CODE, 30), if (IF_CODE, 31), else (ELSE_CODE, 32),
What is a state transition diagram?
Given the following grammar and the right sentential form, draw a parse tree and show the phrases and simple phrases, as well as the handle.S → AbB І bAc A → Ab І aBB B → Ac І cBb І ca.
Why are character classes used, rather than individual characters, for the letter and digit transitions of a state diagram for a lexical analyzer?
What are the two distinct goals of syntax analysis?
For those rules that pass the test in Problem 1, write a recursive-descent parsing subprogram that parses the language generated by the rules. Assume you have a lexical analyzer named lex and an
Describe the differences between top-down and bottom-up parsers.
Get the algorithm to remove the indirect left recursion from a grammar from Aho et al. (2006). Use this algorithm to remove all left recursion from the following grammar: S → Aa І Bb A → Aa І
For those rules that pass the test in Problem 2, write a recursive- descent parsing subprogram that parses the language generated by the rules. Assume you have a lexical analyzer named lex and an
Describe the parsing problem for a top-down parser.
Describe the parsing problem for a bottom-up parser.
Write an EBNF rule that describes the while statement of Java or C++. Write the recursive-descent subprogram in Java or C++ for this rule.
Explain why compilers use parsing algorithms that work on only a subset of all grammars.
Write an EBNF rule that describes the for statement of Java or C++. Write the recursive-descent subprogram in Java or C++ for this rule.
Why are named constants used, rather than numbers, for token codes?
Describe how a recursive-descent parsing subprogram is written for a rule with a single RHS.
Explain the two grammar characteristics that prohibit them from being used as the basis for a top-down parser.
What is the FIRST set for a given grammar and sentential form?
Describe the pairwise disjointness test.
What is left factoring?
What is a phrase of a sentential form?
What is a simple phrase of a sentential form?
What is the handle of a sentential form?
What is the mathematical machine on which both top-down and bottom-up parsers are based?
Describe three advantages of LR parsers.
Describe the purpose of the ACTION table of an LR parser.
Describe the purpose of the GOTO table of an LR parser.
Is left recursion a problem for LR parsers?
Which of the following identifier forms is most readable? Support your decision.SumOfSalessum_of_salesSUMOFSALES
Perl allows both static and a kind of dynamic scoping. Write a Perl program that uses both and clearly shows the difference in effect of the two. Explain clearly the difference between the dynamic
What is the potential danger of case-sensitive names?
Some programming languages are typeless. What are the obvious advantages and disadvantages of having no types in a language?
Write a Common Lisp program that clearly shows the difference between static and dynamic scoping.
What is an alias?
Write a simple assignment statement with one arithmetic operator in some language you know. For each component of the statement, list the various bindings that are required to determine the semantics
Write a JavaScript script that has subprograms nested three deep and in which each nested subprogram references variables defined in all of its enclosing subprograms.
Using the grammar in Example 3.4, show a parse tree and a leftmost derivation for each of the following statements:A = (A + B) * CData From Example 3.4: → → A | B|C → + | → * |
Distinguish between static and dynamic semantics.
What purpose do predicates serve in an attribute grammar?
Modify the grammar of Example 3.4 to add a unary minus operator that has higher precedence than either + or *.Data From Example 3.4: → → A | B|C → + | → * | → ( ) |
What is the difference between a synthesized and an inherited attribute?
How is the order of evaluation of attributes determined for the trees of a given attribute grammar?
What is the primary use of attribute grammars?
Explain the primary uses of a methodology and notation for describing the semantics of programming languages.
Write a grammar for the language consisting of strings that have n copies of the letter a followed by the same number of copies of the letter b, where n > 0. For example, the strings ab, aaaabbbb,
Why can machine languages not be used to define statements in operational semantics?
Draw parse trees for the sentences aabb and aaaabbbb, as derived from the grammar of Problem 13.Data From Problem 13:Write a grammar for the language consisting of strings that have n copies of the
Describe the two levels of uses of operational semantics.
Convert the BNF of Example 3.1 to EBNF.Data From Example 3.1: → begin end > | ; → = → A | BIC -→ + | - |
In denotational semantics, what are the syntactic and semantic domains?
Convert the BNF of Example 3.3 to EBNF.Data From Example 3.3: → → A | BIC %3D → + I * I ( ) |
What is stored in the state of a program for denotational semantics?
Convert the following EBNF to BNF:S → A{b A}A → a[b]A
Which semantics approach is most widely known?
What is the difference between an intrinsic attribute and a non intrinsic synthesized attribute?
What two things must be defined for each language entity in order to construct a denotational description of the language?
Write an attribute grammar whose BNF basis is that of Example 3.6 in Section 3.4.5 but whose language rules are as follows: Data types cannot be mixed in expressions, but assignment statements need
Which part of an inference rule is the antecedent?
Write an attribute grammar whose base BNF is that of Example 3.2 and whose type rules are the same as for the assignment statement example of Section 3.4.5.Data From Example 3.2: → → A| BIC
What is a predicate transformer function?
Using the virtual machine instructions given in Section 3.5.1.1, give an operational semantic definition of the following:a. Java do-whileb. Ada forc. C++ if-then-elsed. C for
What does partial correctness mean for a loop construct?
Write a denotational semantics mapping function for the following statements:a. Ada forb. Java do-whilec. Java Boolean expressionsd. Java for
On what branch of mathematics is axiomatic semantics based?
Compute the weakest precondition for each of the following assignment statements and postconditions:a. a = 2 * (b - 1) - 1 {a > 0}b. b = (c + 10) / 3 {b > 6}c. a = a + 2 * b - 1 {a > 1}d. x
On what branch of mathematics is denotational semantics based?
Showing 700 - 800
of 965
1
2
3
4
5
6
7
8
9
10