Exams Flashcards

(59 cards)

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

Write type checking rules for the following statements

  • SDecl
  • SExp
  • SWhile
  • SBlock
A
How well did you know this?
1
Not at all
2
3
4
5
Perfectly
5
Q

Write compilation schemes for the following expressions

  • EVar
  • EInt
  • EAss
  • EPreIncr
  • EGEq
A
How well did you know this?
1
Not at all
2
3
4
5
Perfectly
6
Q
  • idc a
  • iload x
  • istore x
  • pop
  • iadd
  • if_cmpge L
A
How well did you know this?
1
Not at all
2
3
4
5
Perfectly
7
Q
  • idc a
  • iload x
  • istore x
  • pop
  • dup
  • iadd
  • if_cmpge L
A
How well did you know this?
1
Not at all
2
3
4
5
Perfectly
8
Q
A
How well did you know this?
1
Not at all
2
3
4
5
Perfectly
9
Q
  • SDecl
  • SExp
  • SWhile
  • SBlock
  • SNil
  • SCons
A
How well did you know this?
1
Not at all
2
3
4
5
Perfectly
10
Q

Write syntax directed interpretation rules for the expression forms above. The environment must be made explicit, as well as all possible side effects.

  • EId
  • EInt
  • EPostIncr
  • ELeq
  • EAss
A
How well did you know this?
1
Not at all
2
3
4
5
Perfectly
11
Q

Write compilation schmes in pseudo code for each of the expression constructions above generating JVM (i. asmin assembler). It is not necessary to remember exactly the names of the instructions - only what arguments they take and how they work.

  • EId
  • EInt
  • EPostIncr
  • ELeq
  • EAss
A
How well did you know this?
1
Not at all
2
3
4
5
Perfectly
12
Q
A
How well did you know this?
1
Not at all
2
3
4
5
Perfectly
13
Q
A
How well did you know this?
1
Not at all
2
3
4
5
Perfectly
14
Q
A
How well did you know this?
1
Not at all
2
3
4
5
Perfectly
15
Q
A
How well did you know this?
1
Not at all
2
3
4
5
Perfectly
16
Q
A
How well did you know this?
1
Not at all
2
3
4
5
Perfectly
17
Q

Write syntax-directed type checking rules for the expressions below. The typing enviroment must be made explicit

  • ESub
  • EMul
  • EPreIncr
  • ECall
  • EPar
A
How well did you know this?
1
Not at all
2
3
4
5
Perfectly
18
Q

Write syntax directed interpretation rules for the statements forms and lists below. The environment must be made explicit, as well as all possible side effects. You can assume an interpreter for expressions

  • SBlock
  • SInit
  • SReturn
A
How well did you know this?
1
Not at all
2
3
4
5
Perfectly
19
Q

Write compilation schemes in pseudo-code for each of the grammer constructions in. The compiler shoul output symbolic JVM instructions (i.e Jasmin assembler). It is not necessary to remember exactly the ames of the instructions - only what arguments they take and how they work.

  • Statements
    • SBlock
    • SInit
    • SReturn
  • Types
    • Int
  • Expressions
    • EInt
    • ESub
    • EMul
    • EPreIncr
    • ECall
    • EPar
A
How well did you know this?
1
Not at all
2
3
4
5
Perfectly
20
Q

JVM instructions

  • Idc a
  • iload x
  • istore x
  • isub
  • imul
  • invokestatic f
  • ireturn
A
How well did you know this?
1
Not at all
2
3
4
5
Perfectly
21
Q
A

(a) not valid (f is unbound)
(b) valid
(c) valid
(d) not valid (g does not have a function type)
(e) not valid (self application x x is not typable)

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
22
Q
A
How well did you know this?
1
Not at all
2
3
4
5
Perfectly
23
Q
A
How well did you know this?
1
Not at all
2
3
4
5
Perfectly
25
Write syntax-directed typing rules for the *expression* below. In any case, the environemnt must be made explicit * EInt * EId * ECall * EAdd * EMul * Elt * Eass * EParenth
26
Compilation scheme * Statements * SExp; * SDecl * SWhile * Expression * EInt * EId * ECall * EAdd * EMul * ELt * EAss * EParenth
27
Write JVM instructions for following * goto *L* * ifeq *L* * if\_icmpl *L* * iload a * istore *a* * idc *a* * imul * iadd * pop * invokestatic *m*
28
(a) valid (b) not valid (h is not a function, cannot apply it to 1) (c) not valid (g + 1 is not a function) (d) valid (e) valid
29
Write interpreation rule for "*if statement*"
30
Write interpretation rules for * EPreIncr * EPostIncr
31
Write interpreation rules for * EAss
32
Write interpetation rules * EInt * EVar * EPreIncr * EGeq * EAss
33
34
35
36
Write type checking rules * SDecl * SExp * SIfElse * SBlock
37
Write interpretation rules * ETrue * EFalse * EInt * EPostIncr * ECall * EPlus
38
Write compilation scheme * ETrue * EFalse * EInt * ECall * EPostIncr * EPlus * SInit * SExp * SIfElse * SBlock
39
Write JVM instructions * Goto L * ifreq L * iload a * istore a * idc i * iadd * dup * pop * invokestatic m
40
41
42
43
44
Write type checking rules * SBlock * SDecl * SExp * SWhile
45
Write interpretation rules * EInt * EID * EAdd * ELt * EAss
46
Write compilation scheme * EInt * EID * EAss * EAdd * ELt * SDecl * SExp * SWhile * SBlock
47
Write JVM instructions * goto L * ifeq L * if\_icmplt L * iload a * istore a * idc i * iadd * pop
48
49
50
51
52
Write type checking rules for * SBlock * SInit * SReturn * SIfElse
53
Write interpretation rules for following expressions * EId * EInt * EPlus * ELt * EAnd
54
Write Jasmin code for the following
55
56
Finite automate for following regular expressions a ab (a+b) (a+b)\*
57
Convert following regular expression to DFA (ab + ba)\*
58
Write a regular expression for 10 + (0 + 11)0\* 1
59
Knowledge gained from previous exam