important Flashcards

(16 cards)

1
Q

What is an attribute grammar?

A

A grammar that adds attributes and equations to describe properties of AST nodes.

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

What is an intrinsic attribute?

A

An attribute set during AST creation, like token values or children.

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

What is a synthesized attribute?

A

An attribute computed from the node or its children, flows upward.

Add.val = left.val + right.val
→ If left = 3 and right = 5, then Add.val = 8
Flows up from children to parent.

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

What is an inherited attribute?

A

An attribute passed from parent to child, flows downward.

Add.type = int → passed to both children.
Int.expectedType = int
Flows down from parent to children.

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

What are the major compiler phases?

A

Lexical Analysis (Scanning) – breaks source code into tokens.

Syntactic Analysis (Parsing) – constructs a parse tree from tokens.

Semantic Analysis – checks for type errors, undeclared variables, etc.

Intermediate Code Generation – produces platform-independent code.

Optimization – improves code performance or size.

Target Code Generation – translates intermediate code into assembly/machine code.

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

true/false

A

Every LL(1) grammar must be unambiguous.
✅ True

If a production is Nullable, its FOLLOW set must be considered in the LL(1) table.
✅ True

A grammar with a collision in the LL(1) table is not LL(1).
✅ True

The FIRST set of a terminal is the terminal itself.
✅ True

Nullable(X) is true if X can derive ε (the empty string).
✅ True

The FOLLOW set of the start symbol includes the end-of-file symbol $.
✅ True

Fixed-point iteration can be used to compute Nullable, FIRST, and FOLLOW sets.
✅ True

If a nonterminal can derive a terminal directly, that terminal is in its FIRST set.
✅ True

LL(1) parsers use a single lookahead token to choose a production.
✅ True

Nullable values can be computed by recursive or iterative methods.
✅ True

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

true/false2

A

Nullable(e) is always true.
✅ True

If a nonterminal X has a production X → ε, then X is Nullable.
✅ True

FIRST(X) includes all terminals that X can derive at the beginning of some sentence.
✅ True

FOLLOW(X) includes terminals that can appear immediately after X in a derivation.
✅ True

The FOLLOW set helps handle Nullable productions in the LL(1) table.
✅ True

If a grammar has two productions with the same FIRST set, it is not LL(1).
✅ True

A grammar with left recursion cannot be parsed by an LL(1) parser.
✅ True

The LL(1) parsing table must have at most one entry per cell.
✅ True

Fixed-point iteration ensures that Nullable computation will terminate.
✅ True

The FIRST set is computed recursively and depends on Nullable.
✅ True

If a nonterminal’s production has a sequence of symbols, the FIRST of that sequence depends on the Nullable status of the symbols.
✅ True

FOLLOW(S) always includes $ if S is the start symbol.
✅ True

An LL(1) grammar allows predictive parsing without backtracking.
✅ True

The computation of FOLLOW uses both FIRST and Nullable.
✅ True

A Nullable production can cause multiple entries in the LL(1) table if FOLLOW is not handled.
✅ True

A terminal symbol cannot be Nullable.
✅ True

In fixed-point iteration, values only change from false to true for Nullable.
✅ True

The FIRST set of a sequence may include tokens from multiple nonterminals if they are Nullable.
✅ True

LL(1) parsing is a top-down parsing strategy.
✅ True

If a production is selected in multiple table cells, the grammar is not LL(1).
✅ True

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

what does shift mean?

A

Push token onto task and read next token

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

what does reduce mean?

A

Pop RHS , Push LHS , build part of tree

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

what is common prefix ?

A

when two productions of the same nonterminal start with the same symbols

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

what is left recursion?

A

When non-terminal calls itself at the beginning of production

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

what does it mean a grammar to be ambiguous

A

if a sentence in language derived by two or more different parse trees

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

what is nullable , first, follow

A

nullable: A nonterminal X is Nullable if it can derive the empty string

First: is the set of terminals that can appear first in any string derived from X.

Follow: is the set of terminals that can appear immediately after X in some derivation.

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

how we decide if grammar is LL(1) or not

A

If any cell has more than one production, the grammar is not LL(1)

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

What does collison mean in LL(1) table?

A

if both element are in the same cell

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