SEMANTICS Flashcards

1
Q

What are the three primary methods of describing programming language semantics?

A

Operational semantics, axiomatic semantics, and denotational semantics.

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
2
Q

Describe operational semantics.

A

Operational semantics defines the meaning of a program by executing its statements on a machine (real or simulated). The state change of the machine represents the meaning of the statement.

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
3
Q

What is required to use operational semantics for a high-level language?

A

A virtual machine, as hardware pure interpreters are too expensive and software pure interpreters are machine-dependent.

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
4
Q

What is the process for building operational semantics?

A

Build a translator to convert source code to machine code of an idealized computer and build a simulator for the idealized computer.

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
5
Q

Explain axiomatic semantics.

A

Axiomatic semantics is based on formal logic and involves defining axioms or inference rules for each statement type to allow transformation of expressions into other expressions.

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
6
Q

What are assertions in axiomatic semantics?

A

Assertions are statements that express relationships and constraints among variables. A precondition is an assertion before a statement, and a postcondition is an assertion after a statement.

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
7
Q

What is a weakest precondition in axiomatic semantics?

A

The least restrictive precondition that will guarantee the postcondition.

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
8
Q

Describe denotational semantics.

A

Denotational semantics is based on recursive function theory and involves defining a mathematical object for each language entity and a function that maps instances of language entities to instances of corresponding mathematical objects.

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
9
Q

How is the state of a program defined in denotational semantics?

A

The state of a program is defined by the values of all its current variables, represented as s = {<i1, v1>, <i2, v2>, …, <in, vn>}.

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
10
Q

Compare operational semantics and denotational semantics.

A

Operational semantics defines state changes by coded algorithms, while denotational semantics defines state changes by rigorous mathematical functions.

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
11
Q

What are the key evaluation points for denotational semantics?

A

It can be used to prove program correctness, provides rigorous thinking about programs, aids in language design, and has been used in compiler generation systems, but is complex and of little use to language users.

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
12
Q

What is an attribute grammar?

A

A descriptive formalism that can describe both the syntax and the semantics of a language.

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
13
Q

What are the summary points regarding BNF and context-free grammars?

A

BNF and context-free grammars are equivalent meta-languages, well-suited for describing the syntax of programming languages.

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
14
Q

Why are BNF and EBNF notations important?

A

They provide a structured and formal way to describe the syntax of programming languages, making it easier to understand and implement language constructs.

How well did you know this?
1
Not at all
2
3
4
5
Perfectly