Exams Flashcards

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
24
Q
A
25
Q

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
A
26
Q

Compilation scheme

  • Statements
    • SExp;
    • SDecl
    • SWhile
  • Expression
    • EInt
    • EId
    • ECall
    • EAdd
    • EMul
    • ELt
    • EAss
    • EParenth
A
27
Q

Write JVM instructions for following

  • goto L
  • ifeq L
  • if_icmpl L
  • iload a
  • istore a
  • idc a
  • imul
  • iadd
  • pop
  • invokestatic m
A
28
Q
A

(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
Q

Write interpreation rule for “if statement

A
30
Q

Write interpretation rules for

  • EPreIncr
  • EPostIncr
A
31
Q

Write interpreation rules for

  • EAss
A
32
Q

Write interpetation rules

  • EInt
  • EVar
  • EPreIncr
  • EGeq
  • EAss
A
33
Q
A
34
Q
A
35
Q
A
36
Q

Write type checking rules

  • SDecl
  • SExp
  • SIfElse
  • SBlock
A
37
Q

Write interpretation rules

  • ETrue
  • EFalse
  • EInt
  • EPostIncr
  • ECall
  • EPlus
A
38
Q

Write compilation scheme

  • ETrue
  • EFalse
  • EInt
  • ECall
  • EPostIncr
  • EPlus
  • SInit
  • SExp
  • SIfElse
  • SBlock
A
39
Q

Write JVM instructions

  • Goto L
  • ifreq L
  • iload a
  • istore a
  • idc i
  • iadd
  • dup
  • pop
  • invokestatic m
A
40
Q
A
41
Q
A
42
Q
A
43
Q
A
44
Q

Write type checking rules

  • SBlock
  • SDecl
  • SExp
  • SWhile
A
45
Q

Write interpretation rules

  • EInt
  • EID
  • EAdd
  • ELt
  • EAss
A
46
Q

Write compilation scheme

  • EInt
  • EID
  • EAss
  • EAdd
  • ELt
  • SDecl
  • SExp
  • SWhile
  • SBlock
A
47
Q

Write JVM instructions

  • goto L
  • ifeq L
  • if_icmplt L
  • iload a
  • istore a
  • idc i
  • iadd
  • pop
A
48
Q
A
49
Q
A
50
Q
A
51
Q
A
52
Q

Write type checking rules for

  • SBlock
  • SInit
  • SReturn
  • SIfElse
A
53
Q

Write interpretation rules for following expressions

  • EId
  • EInt
  • EPlus
  • ELt
  • EAnd
A
54
Q

Write Jasmin code for the following

A
55
Q
A
56
Q

Finite automate for following regular expressions

a

ab

(a+b)

(a+b)*

A
57
Q

Convert following regular expression to DFA

(ab + ba)*

A
58
Q

Write a regular expression for

10 + (0 + 11)0* 1

A
59
Q

Knowledge gained from previous exam

A