Lecture 3 Flashcards

1
Q

What does a lexical analyser do?

A

Reads sequence of characters and outputs sequence of tokens

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

What does a parser do?

A

Reads sequence of tokens and outputs a structured internal representation of the program. A syntax tree

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

What is interpretation?

A

Execution according to language semantics

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

What is compilation?

A

Code generation according to language semantics

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

What is a leftmost derivation?

A

A derivation where the leftmost non-terminal in each step is replaced

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

When is a syntax unambiguous?

A

When sequences of tokens only have one possible syntax tree.

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

How can we avoid ambiguity?

A

precedence for operators

Associativity of operators: left- or right associative.

<expression> ::= <int> | <expression> <op> <int>

Enforce parentheses around expressions.

<expression> ::= (<expression> <op> <expression>)
</expression></op></expression></expression></int></op></expression></int></expression>

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

What is scanning?

A

Translating a process from sequence of characters to sequence of tokens.

characters -> lexemizer -> sequence of lexems -> tokenizer -> sequence of tokens

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

What is a model of computation?

A

Programming language with a formally defined syntax and semantics

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

What is a declarative model?

A

All computations are independent of any external state and are themselves stateless and deterministic.

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

What is the syntax of variable-value, and variable-variable unification?

A

<statement> ::= <id> = <value>

<statement> ::= <id> = <id>
</id></id></statement></value></id></statement>

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

What is the syntax of records?

A

<record> ::= <literal> | <literal> ( {<feature>:<id>}+ )

<literal> ::= <atom> | <name>
<feature> ::= <atom> | <bool> | <int>

features in a record must be unique
</int></bool></atom></feature></name></atom></literal></id></feature></literal></literal></record>

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