Regular Expressions, Grammars & Parsing Flashcards

1
Q

Regular expressions

A

A sequence of characters that define a search pattern and a regular language

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

|symbol meaning

symbol meaning

A

Boolean OR

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

() symbol meaning

A

Grouping (equivalent to | symbol)

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

. symbol meaning

A

Wild card- can match any one character

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

[^a] symbol meaning

A

Negation

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

gray|grey

A

gray or grey

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

gr(a|e)y

A

gray|grey = gray or grey

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

gr.y

A

gray, grey, groy, grzy etc..

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

? symbol meaning

A

zero or one occurrences of the preceding element

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

zero or more occurrences of the preceding element

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

{n}

A

the preceding item is matched exactly n times

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

{min, }

A

the preceding item is matched min or more times

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

{min, max}

A

the preceding item is matched at least min times, but not more than max times

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

colou?r

A

color, colour

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

ab*c

A

ac, abc, abbc, abbbc etc..

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

ab+c

A

abc, abbc, abbbc etc..

17
Q

N is a set of

A

non-terminals

18
Q

What is a non-terminal symbol?

A

Those symbols that are in the generation of the sentence but not the component of the sentence

19
Q

Non-terminal examples

A

capital letters

20
Q

Grammar

A

A finite set of formal rules for generating correct sentences (N, T, P, S)

21
Q

Σ (or E) is a set of

A

terminals

22
Q

What is a terminal symbol?

A

The components of the sentences generated using a grammar

23
Q

Terminal symbol examples

A

lowercase letters

24
Q

What’s the relationship between N and Σ

A

They are disjoint meaning they have no members in common

25
Q

P is a set of

A

production rules

26
Q

What are production rules?

A

A rewrite rule specifying a symbol substitution than can recursively perform to generate new symbol sequences

27
Q

S is a

A

starting non-terminal and is a member of N

28
Q

Regular grammar

A

Is a mathematical object consisting of 4 components G = (N, E, P, S)

29
Q

Right regular grammar

A

All the non-terminals on the right-hand side exist at the rightmost place

30
Q

B -> a

A

B is a non-terminal in N and a is terminal in Σ

31
Q

B -> aC

A

B and C are non-terminals in N and a is in Σ

32
Q

B -> Ca

A

B and C are in N and a is in Σ

33
Q

B -> ε

A

B is in N and ε is the empty string

34
Q

Context free grammar

A

The syntax or structure of a formal language defined by (N, Σ, P, S)

35
Q

CFG is defined where

A

an alphabet Σ of terminals, a set N of non-terminals, a finite set P of productions

36
Q

::== meaning

A

may expand into or may get replaced with