Module 3: Basic Semantics and Pointer Semantics Flashcards
What is semantics concerned with?
Semantics is concerned with what the parse tree means.
What are the properties that we want from language semantics definitions? (Select all that apply)
a. Preciseness
b. Acceptability
c. Predictability
d. Complete
a. Preciseness
c. Predictability
d. Complete
What are the ways that language semantics can be specified?
a. English specification
b. Reference implementation
c. Formal Language
d. All of the above
d. All of the above
Given the line of code below, is this an explicit or implicit declaration?
int i;
This is an explicit declaration. We are saying that i is that name of the variable explicitly
What does the following represent?
target = test_value + 10
a. explicit declaration
b. implicit declaration
b. implicit declaration
What does scope cover in semantics?
a. How long is the name valid?
b. How to resolve the name?
c. What is the name?
d. What declaration is the name mapped to
a. How long is it valid
b. How to resolve the name
d. What declaration is the name mapped to
What kind of scoping does the C programming language use?
a. Block-level
b. Function-level
c. None
a. Block-level
What is used to map the name to the declaration in scoping?
a. Variable table
b. Nothing
c. Declaration table
d. Symbol table
d. Symbol table
What are the two types of scoping?
a. Static Scoping
b. Dynamic Scoping
How can function calls be resolved to appropriate functions?
a. Names
b. Names + return type?
c. Names + parameter number?
d. Names + parameter number + parameter types
e. All of the above
e. All of the above
Using a box and circle diagram what does the x represent?
a. Name
b. Binding
c. Location
d. Value
a. Name
Using a box and circle diagram what does the box represent?
a. Name
b. Binding
c. Location
d. Value
c. Location
Using a box and circle diagram what does the circle represent?
a. Name
b. Binding
c. Location
d. Value
d. Value
Using a box and circle diagram what does the line represent?
a. Name
b. Binding
c. Location
d. Value
b. Binding
What are the two operations with pointers?
The address operator (&) and the deference operator (*)
True or False: The & operator is a unary operator and can only be applied on an L value.
True.
This means that it can only be applied once and can not be applied on something like
&b
but not
&(b+c)
What is the return value of &?
a. l-value
b. r-value
b. r-value of type T*
For example:
&x -> int*
this would take the address of x and turn it into an int
True or False:
The difference operator can only be applied to l-values
False.
The difference operator can be applied to both l-value and r-value operators.
If x is of type T* what does the box and circle diagram look like?
It gives the typical box diagram of X with Xv inside of the circle. If we call *X we take the address of Xv and find the location that has that address Xv. *X will get the value V from the address and return it. V has to be of type T for it to work.
What type of return value does *X return?
a. l-value
b. r-value
a. l-value
What memory does the malloc operation send values to?
a. global
b. heap
c. stack
b. heap
True or False:
Every malloc results in a new location in the heap.
True
Every malloc does result in a new location in the heap
What does malloc return?
Malloc will return the address of the value.
What does *x mean?
Take the value of inside X, go to that address and return the value of that address. This is type of link.