Formal semantics of programming languages solutions
Lecturer: Tri Djoko Wahjono
1.Define syntax and semantics.
syntax:the form of expressions, statements, and program units of programming languages.
semantics: the meaning of the syntax.
3.Describe the operation of a general language generator.
A general language generator is a device that can be used to generate the sentences of the language. It generates unpredictable sentences which makes a generator seems to be a device of limited usefulness as language descriptor.
4.Describe the operation of a general language recognizer.
A general language recognizer is a recognition device capable of reading strings of characters from the alphabet. It would analyze the given string and it would either accept or reject the string based from the language given. These recognition devices are like filters separating correct sentences from those that are incorrectly.
5.What is the difference between a sentence and a sentential form?
A sentence is a sentential form that has only terminal symbols. A sentential form is every string of symbols in the derivation.
8.Distinguish between static and dynamic semantics.
Static semantics is more on the legal forms of programs (syntax rather symantics) and is only indirectly related to the meaning of the programs during execution. Static semantics is so named because the analysis required to check these specifications can be done at compile time. In many cases, the semantic rules of language state its type constraints.
Dynamic semantics is describing the meaning of the programs. Programmers need to know precisely what statements of a language do. Compile writers determine the semantics of a language for which they are writing compilers from English descriptions.
10.What is the difference between a synthesized and an inherited attribute?
The synthesized attributes are the result of the attribute evaluation rules, and may also use the values of the inherited attributes. The inherited attributes are passed down from parent nodes.In some approaches, synthesized attributes are used to pass semantic information up the parse tree, while inherited attributes help pass semantic information down it.12.What is the primary use of attribute grammars?An attribute grammar is an extension to a context-free grammar. The primary purpose of an attribute grammar is it allows certain language rules to be described, such as type of compatibility. An attribute grammar is a formal way to define attributes for the productions of a formal grammar, associating these attributes to values. The evaluation occurs in the nodes of the abstract syntax tree, when the language is processed by some parser or compiler.
Describe the two levels of uses of operational semantics.
-Natural operational semantics, is the highest level which interest is in the final result of the execution of a complete program.
-Structural operational semantics is the lowest level which used to determine the precise meaning of a program through an exaination of the complete sequence of state changes that occur when the program is executed.
You might also like
Kubuntu 10.04 Desktop Edition