Lecture 2 - Lexical Analysis Flashcards

1
Q

?

is the first phase of a compiler.

WHAT IS LEXICAL ANALYSIS?

A

Lexical Analysis

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

?

It takes the modified source code from language preprocessors that are written in the form of sentences.

WHAT IS LEXICAL ANALYSIS?

A

Lexical Analysis

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

Lexical Analysis is the ? of a compiler

Lexical Analysis

WHAT IS LEXICAL ANALYSIS?

A

first phase

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

It takes the modified source code from ? that are written in the form of sentences.

Lexical Analysis

WHAT IS LEXICAL ANALYSIS?

A

language preprocessors

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

?

breaks these syntaxes into a series of tokens, by removing any whitespace or commentsin the source code.

WHAT IS LEXICAL ANALYSIS?

A

Lexical Analyzer

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

If the ? finds a token invalid, it generates an error.

WHAT IS LEXICAL ANALYSIS?

A

Lexical analyzer

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

?

It reads character streams from the source code, checks for legal tokens, and passes the data to the syntax analyzer when it demands.

WHAT IS LEXICAL ANALYSIS?

A

Lexical analyzer

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

The Lexical Analyzer breaks these syntaxes into a series of ?, by removing any ?? or comments in the source code.

Lexical analyzer

WHAT IS LEXICAL ANALYSIS?

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

If the Lexical analyzer finds a token invalid, it generates an ?.

Lexical analyzer

WHAT IS LEXICAL ANALYSIS?

A

error

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

It reads character streams from the source code, checks for ?, and passes the data to the ??* when it demands.

Lexical analyzer

WHAT IS LEXICAL ANALYSIS?

A
  • legal tokens
  • syntax analyzer
How well did you know this?
1
Not at all
2
3
4
5
Perfectly
11
Q

?

is a sequence of characters (alphanumeric) in a token.

TOKENS AND LEXEMES

A

Lexemes

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

?

is a basic abstract unit of meaning.

TOKENS AND LEXEMES

A

Lexemes

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

?

Lexemes is a sequence of characters (?) in a token.

Lexemes

TOKENS AND LEXEMES

A

alphanumeric

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

?

There are some predefined rules for every lexeme to be identified as a ?.

Lexemes

TOKENS AND LEXEMES

A

valid token

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

?

is an object that represents something else.

TOKENS AND LEXEMES

A

Token

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

?

could be Keywords, Operators, Strings, Constants, Special Symbols, and Identifiers.

TOKENS AND LEXEMES

A

Tokens

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

?

(6) Tokens and Lexemes

TOKENS AND LEXEMES

A
  • Keywords
  • Identifiers
  • Constants
  • Strings
  • Special Symbols
  • Operators
How well did you know this?
1
Not at all
2
3
4
5
Perfectly
18
Q

?

are pre-defined or reserved words in a programming language.

TOKENS AND LEXEMES

A

Keywords

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

?

Each ? is meant to perform a specific function in a program.

TOKENS AND LEXEMES

A

Keywords - keyword

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

?

are used as the general terminology for naming of variables, functions and arrays.

TOKENS AND LEXEMES

A

Identifiers

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

?

their values can not be modified by the program once they are defined.

TOKENS AND LEXEMES

A

Constants

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

?

refer to fixed values

TOKENS AND LEXEMES

A

Constants

23
Q

?

They are also called as literals

TOKENS AND LEXEMES

A

Constants

24
Q

?

is an array of characters ended with a null character.

TOKENS AND LEXEMES

A

Strings

25
Q

?

are always enclosed in double quotes.

TOKENS AND LEXEMES

A

Strings

26
Q

?

are used in programming languages having some special meaning, thus cannot be used for some other purpose

TOKENS AND LEXEMES

A

Special Symbols

27
Q

?

(6) Special Symbols

Special Symbols

TOKENS AND LEXEMES

A
  • Brackets
  • Parentheses
  • Braces
  • Comma
  • Semi colon
  • Asterisk
28
Q

?

used as array element reference

Special Symbols

TOKENS AND LEXEMES

A

Brackets

29
Q

?

used to indicate function calls and function parameters.

Special Symbols

TOKENS AND LEXEMES

A

Parentheses

30
Q

?

marks the start and end of a block of code containing more than executable statement.

Special Symbols

TOKENS AND LEXEMES

A

Braces

31
Q

?

used to separate more than one statements.

Special Symbols

TOKENS AND LEXEMES

A

Comma

32
Q

?

an operator that essentially invokes an initialization list.

Special Symbols

TOKENS AND LEXEMES

A

Semi colon

33
Q

?

used to create pointer variable

Special Symbols

TOKENS AND LEXEMES

A

Asterisk

34
Q

?

are symbols that triggers an action when applied to variables and other objects.

TOKENS AND LEXEMES

A

Operators

35
Q

?

(3) Operators can be classified as follows

Operators

TOKENS AND LEXEMES

A
  • Unary Operators
  • Binary Operators
  • Ternary Operators
36
Q

?

Require only single operand (e.g., increment and decrement).

Operators

TOKENS AND LEXEMES

A

Unary Operators

37
Q

?

Require two operands (arithmetic operators, relational operators, logical operators, etc.).

Operators

TOKENS AND LEXEMES

A

Binary Operators

38
Q

?

requires three operands (Conditional Operators)

Operators

TOKENS AND LEXEMES

A

Ternary Operators

39
Q

?

are the notations for describing a set of character strings.

REGULAR EXPRESSIONS

A

Regular Expressions

40
Q

?

are used in search engines, search and replace dialogs of word processors and text editors.

REGULAR EXPRESSIONS

A

Regular Expressions

41
Q

?

(4) Regular expression (Classification??)

REGULAR EXPRESSIONS

A
  1. Any terminal symbols (e.g. empty and null) are regular expressions.
  2. The union of two regular expressions is also a regular expression.
  3. The concatenation of two regular expressions is also a regular expression.
  4. The iteration or closure of a regular expression is also a regular expression.
42
Q

?

(12) Regular Expression Basics

REGULAR EXPRESSIONS

A
  • asterisk
  • plus sign
  • question mark
  • backslash
  • period
  • caret
  • square brackets
  • dollar sign
  • or sign
  • curly brackets
  • parentheses
  • minus sign
43
Q

?

match zero or more quantifier

Regular Expression Basics

REGULAR EXPRESSIONS

A

asterisk

44
Q

?

match one or more quantifier

Regular Expression Basics

REGULAR EXPRESSIONS

A

plus sign

45
Q

?

match zero or one quantifier (makes a preceding character optional)

Regular Expression Basics

REGULAR EXPRESSIONS

A

question mark

46
Q

?

matches any character except the newline symbol

Regular Expression Basics

REGULAR EXPRESSIONS

A

period

47
Q

?

negates the character

Regular Expression Basics

REGULAR EXPRESSIONS

A

caret

48
Q

?

match a single character

Regular Expression Basics

REGULAR EXPRESSIONS

A

square brackets

49
Q

?

anchor for the end of the string

Regular Expression Basics

REGULAR EXPRESSIONS

A

dollar sign

50
Q

?

separates a series of alternatives

Regular Expression Basics

REGULAR EXPRESSIONS

A

or sign

51
Q

?

used as range quantifiers

Regular Expression Basics

REGULAR EXPRESSIONS

A

curly brackets

52
Q

?

used for grouping characters or regular expressions

Regular Expression Basics

REGULAR EXPRESSIONS

A

Parentheses

53
Q

?

indicates a range in a character class

Regular Expression Basics

REGULAR EXPRESSIONS

A

Parentheses