Ch5 Flashcards

(28 cards)

1
Q

What is another name for syntax analysis?

A

Parser

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

what is the role of a syntax analyzer?

A

recombining tokens , created by the lexical analyzer, by creating a parse tree

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

what creates a syntactic structure of the given source program?

A

A syntax analzer

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

in a syntax tree, what represents tokens?

A

leaves

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

When can we say the the sequence is the same as input text?

A

when the leaves in a parse tree are read from left to right.

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

What role does syntax analysis play in rejecting invalid code?

A

In addition to finding the syntax structure of the input text, it rejects invalid code by reporting syntax errors

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

The syntax of a Programming Language is described by…

A

CFG (Context-Free-Grammar)

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

what is a BNF?

A

Backus Naur Form
a notation that describes CFG

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

How is the syntax analyzer related with CFG?

A

the syntax analyzer checks wether a given source program satisfies the rules implied by CFG or not.
if it satisfies, it creates a parse tree
if doesn’t, it returns an error message.

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

what is an initial phase of the design of a compiler?

A

The design of grammar

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

can a grammar be directly converted to a parser?

A

yes by some tools

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

Parser works on a …..

A

stream of tokens

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

what is the smallest unit of a parser?

A

token

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

How many categories are parsers categorized to an what are they?

A

2,
Top down parser
Bottom up parser

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

how do top-down and bottom-up parsers scan input?

A

from left to right (one symbol at a time).

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

Efficient top-down and bottom-up parsers can be implemented only for sub-classes of CFG.What are they?

A

LL for top-down parsing
LR for bottom-up parsing

17
Q

what is a non terminal?

A

a grammatical symol that can be expanded into more symbols

18
Q

what is a production?

A

a set of rules that explains how symbols are replaced (nonterminal)

19
Q

: a sequence of applications of the rules of a grammar that produces a finished string of terminals.

A

Derivation or parse

20
Q

what is a Start symbol?

A

a grammar that has a one non terminal in which all sentences are derived from this start state.

21
Q

We formally define a grammar as a

A

4-tuple {S, P, N, T}.

22
Q

what is A sentence

A

T derived from S using one or more applications of P

23
Q

What is a Type 0 grammar?

A

A: Free or unrestricted grammars with no restrictions on production forms, except the left side must be non-empty

24
Q

What is a Type 1 grammar?

A

A: Context-sensitive grammars where productions are of the form uXw → uvw, with v non-null and X a single nonterminal.

25
What is a Type 2 grammar?
Context-free grammars with productions of the form X → v, where X is a single nonterminal and v is any string of symbols.
26
What is a Type 3 grammar?
Regular grammars with productions like X → a, X → aY, or X → ε, where X and Y are nonterminals and a is a terminal.
27
Symbols in the alphabet are called ...
Terminals or Leaves
28