Regular Expressions, Grammars & Parsing Flashcards

1
Q

What is an alphabet in regex?

A
  • Alphabet = finite set of fundamental units
    • Unit = Symbols, letters and tokens
How well did you know this?
1
Not at all
2
3
4
5
Perfectly
2
Q

What is a language in regex?

A

Language = alphabet + (exhaustive list of valid words/ a set of rules defining acceptable words)

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

What are words in regex?

A
  • Words = finite strings that are permissible in the language
How well did you know this?
1
Not at all
2
3
4
5
Perfectly
4
Q

What is ε in regex

A
  • ε = Empty/null string
How well did you know this?
1
Not at all
2
3
4
5
Perfectly
5
Q

How do you represent concatentation?

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

How do you represent choice

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

How do you represent none or more?

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

How do you represent one or more?

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

What is regex?

A

Regular Expressions (Regex)

Sequence of characters that define a search pattern AND defines a regular language

Set of regex = rules that define a language

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

Give an example of regex

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

Give a general example of regex

A

Search & Find Processes

  • Given a regular expression
  • Search through set of strings
  • To find all matching instances
  • Report back what has been found (Can include locations)
How well did you know this?
1
Not at all
2
3
4
5
Perfectly
12
Q

Give an example of search and find

A

These are commands to run in the OSs terminal

Win11 = findstr /r [REGEX GOES HERE] filename

Linux = egrep [REGEX GOES HERE] filename

Limitation - this doesn’t work if there are line breaks in the string you want to find because it wont fit the requested string in the regex

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

What are read inputs in grammar?

A
  • A particular form of an input for grammar
    • Formatted document = webpage
    • Source code
    • Arithmetical expression or mathematical formular
How well did you know this?
1
Not at all
2
3
4
5
Perfectly
14
Q

What are rule description in grammar?

A
  • Defines the input format
  • Used to recognise/accept the input
    • Includes error checking
  • Start to process a correctly formatted input
How well did you know this?
1
Not at all
2
3
4
5
Perfectly
15
Q

Explain the tuples to describe grammar

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

What are regular grammars?

A
  • left or right grammar
  • Defined a regular Language
17
Q

What is right grammar?

A
18
Q

What is left grammar?

A
19
Q

How do you use | in regular grammar?

A
20
Q

How do you describe Context Free Grammars?

A
21
Q
A
22
Q

What is BNF

A
23
Q

How do you write production rules in BNF?

A
24
Q

What is option in BNF?

A
25
Q

What is repetition in BNF?

A
26
Q

What is grouping in BNF?

A
27
Q

What is the chomsky hierarchy of languages?

A