Concept of Programming Languages by Robert W. Sebesta Answer
Review Questions
1. Define syntax and semantics.
Syntax is form of a programming language’s expressions, statements, and program units.
Semantics is meaning of expressions, statements and program units.
2.Who are language descriptions for ?
Language descriptions is for programming language implementors
4. Describe the operation of a general language recognizer.
The general operation of language recognizers is it will scan whether inputted string is inside certain language. If it is, it will accept the string.
5. What is the difference between a sentence and a sentential form ?
Sentence is strings of a language while sentential form is strings in the derivation
7. What three extensions are common to most EBNFs ?
optional part of RHS is delimited by brackets, the enclosed part can be repeated indefinitely or left out left altogether.
8. Distinguish between static and dynamic semantics.
Static semantics is only indirectly related to the meaning of programs during execution.
Dynamic semantics is not universally accepted in notation.
9. What purpose do predicates serve in an attribute grammar ?
Predicates function as boolean expression on the union of the attribute set and a set of literal attribute values
10. What is the difference between a synthesized and an inherited attribute ?
Synthesized attributes are used to pass semantic information up a parse tree while inherited attributes pass smenatic information down and accross a tree.
11. How is the order of evaluation attributes determined for the trees of a given attribute grammar?
The parse tree is evaluated based on its underlying BNF grammar, wit a possibility of having empty set of attributes values attached to each node.
12. What is the primary use of attribute grammars ?
Attribute grammars are used to describe more of the structure of a programming language than can be described with a context-free grammar.