CH3 Flashcards

(51 cards)

1
Q

what is the role of Regular expressions?

A

important notations for specifying lexeme patterns

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

a finite set of symbols

A

alphabet

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

what are symbols?

A

letter, digit , or punctuation mark .

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

What is ASCII?

A

an alphabet used in SW

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

A finite sequence of symbols drawn from an alphabet

A

String(Word)

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

number of occurrences of symbol in s

A

length of a string

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

how is a length of a string denoted

A

|s|

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

what is a language

A

a countable set of strings generated from a fixed alphabet

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

what is a formal language

A

all possible strings that can be generated from an alphabet.

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

In lexical analysis, the most important operations on languages are

A

Union
Concatenation
Closure(Kleene star, and Kleene +)

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

How do you represent a java identifier in the form of a regular expression?

A

L(L or D)*
in which letters include an underscore

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

It is used for describing all the languages that can be built from these operators (Union, concatenation, and Kleene closure), applied to the symbols of some alphabet.

A

Regular Expressions.

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

are used to describe tokens of a programming language

A

Regular expressions

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

What is a regular expression built from?

A

smaller regular expressions

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

True/False
All regular expressions denote the same language.

A

False.
Each regular expression denotes a language.

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

True/False
Regular expressions are widely used to specify patterns.

A

True

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

What is a regular set?

A

A language that is denoted by a regular expression

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

What are the rules of Regular expressions built from?

A

Union
Concatenation
Closure(Kleene star, and Kleene +)

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

Formally, the set of regular expressions can be defined by the following recursive rules:

A
  1. epsilon is a regular expression
  2. every symbol in the Language is a Regular expression
  3. if r1 and r2 are regular expressions then so are r1|r2, r1 r2 , r1*
  4. Nothing else is a Regular expression
How well did you know this?
1
Not at all
2
3
4
5
Perfectly
20
Q

How can we remove parentheses in Regular Expressions?

A

By using precedence rules

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

What are the precedence rules?

A
  1. closure(*)
  2. concatenation
  3. union
22
Q

Describe the role of regular definitions.

A

Some regular expressions may be quite complex, so regular definitions are used to denote those complex regular expressions as symbols

23
Q

What is a recognizer?

A

It is also called a program for a language, and it is also called a finite automata. It takes a string ‘x’ and tells whether this string belongs to the language or not. If it belongs, it answers ‘yes’ and if it doesn’t belong, it answers ‘no’. It is also a machine that has a finite number of states and transitions.

24
Q

What are the types of finite automaton?

25
NFA and DFA can be used as a ....
Lexical analyzer
26
Both NFA and DFA recognize ...
Regular Sets
27
which of the types of finite automaton is used as a lexical analyzer?
Both of them. but DFA is considered to be widely used as a lexical analyzer
28
State the differences between DFA and NFA
*DFA* - can be converted to efficient programs - faster recognizer, but it may take more space - widely used as a lexical analyzer *NFA* - not closer to real machines - can’t be converted to efficient programs - slower, but it may take less space
29
What are the algorithms responsible to converting RE to DFA
Definition of RE i done first for tokens then : 1. RE->NFA->DFA 2. RE->DFA
30
NFA is a mathematical model that consists of :
1. input alphabet/symbols 2. a finite set of states denoted by circles 3 a transition function for each state and symbol that belongs to the alphabet(including the epsilon, the specifies the next state)(denoted by an arrow). 4. start state s0 that has an arrow pointing to it denoting that it is the start state 5. final/acceptance set of states denoted by double circles.
31
Epsilon-transitions are allowed in ..
NFA
32
what do we mean by Epsilon-transitions?
that we can move from state to state without consuming any symbol
33
When does the NFA accept a string?
when there is a path from the starting state and moving through states by following valid transitions based on the input symbols until reaching to the final acceptance state with the correct string.
34
A Deterministic Finite Automaton (DFA) is a special form of a NFA that obey a number of additional restrictions.State them
1. no epsilon transitions 2. no identically labeled transitions of the same state 3. we never have a choice of several next states 4. the state and next input symbol uniquely identifies the transition.
35
"no identically labeled transitions of the same state" this is a DFA rule. what does it mean?
it means we never have a choice of several next states
36
what uniquely determines the transition (or lack of same)?
the state and the next input symbol
37
What is the reason of the name of the automata DFA
because each state and the next input symbol uniquely identifies a transition
38
How is the transition function defined in DFA?
move(s,c) a state s reached by a state s from any transition of symbol c.
39
If there was a transition function move(s,c), and there wasn't any transition. How is this case defined?
It is defined as that there is no epsilon transition
40
Describe Thomson's construction in two words
simple and systematic
41
How many final states does Thomson's construction guarantee that the resulting NFA will have?
One resulting Final State
42
State the steps for Thomson's Construction
1. from each subexpression construct a NFA fragment 2. combine these fragments
43
True/False a fragment can be a complete
False. it can be a complete NFA construction by adding the necessary components to make a complete NFA.
44
What does an NFA fragment consist of?
NFA fragment = a number of states + transitions between these states
45
A fragment has 2 incomplete transitions. State and define them.
1. Incoming Half Transition : points into the fragment without consuming any input symbol 2. Outgoing Half Transition : points out of the fragment, it is labeled by an epsilon or an alphabet symbol
46
which of the incomplete transitions of a fragment allows the movement to another fragment or state?
Outgoing Half Transition
47
..... serves to identify the starting state of the completed NFA.
Incoming Half Transition
48
When an NFA fragment has been constructed for the whole regular expression, the construction is completed by connecting the ..... to an accepting state
Outgoing Half Transiton
49
we allow a NFA to have several accepting states, a NFA constructed using this method will have only one.which method is meant here?
Thomson’s Construction
50
we allow a NFA to have several accepting states, a NFA constructed using this method will have only one. when is the final state added?
at the end of the construction
51