LEXICAL AND SYNTAX ANALYSIS

0.0(0)
studied byStudied by 0 people
learnLearn
examPractice Test
spaced repetitionSpaced Repetition
heart puzzleMatch
flashcardsFlashcards
Card Sorting

1/41

encourage image

There's no tags or description

Looks like no tags are added yet.

Study Analytics
Name
Mastery
Learn
Test
Matching
Spaced

No study sessions yet.

42 Terms

1
New cards

American Standard Code Information Interchange

ASCII

2
New cards
  1. Assembly

  2. Interpreter

  3. Compiler

Language Translator

3
New cards
  1. Preprocessor

  2. Compiler

  3. Assembler

  4. Linker

Language Translator - Internal Architecture

4
New cards
  1. Lexical Analysis

  2. Syntax Analysis

  3. Semantic Analysis

  4. Intermediate Code Generator

  5. Code Optimization

  6. Target Code Generation

Compiler - Internal Architecture

5
New cards
  1. Compilation

  2. Pure Interpretation

  3. Hybrid Implementation

Three Primary Approaches

6
New cards

involves translating high-level code into machine code using a compiler.

Compilation

7
New cards

Pure Interpretation

executes the original source code directly using an interpreter.

8
New cards

Hybrid Implementation

combines both methods. It translates high-level code into an intermediate representation, which is then interpreted.

9
New cards

Lexical Analysis

also known as scanning, is the first phase of processing source code. It converts the raw source code into tokens.

10
New cards

Syntax Analyzer

takes the generated tokens and verifies whether they follow the grammatical rules of the programming language.

11
New cards

Simplicity

Lexical analysis is less complex than syntax analysis. Separating them makes both processes easier to manage and maintain.

12
New cards

Efficiency

Since lexical analysis consumes a significant portion of compilation time, optimizing it separately improves overall performance without affecting syntax analysis.

13
New cards

Portability

Lexical analyzers handle platform-dependent elements, while syntax analyzers remain platform independent, making compilers more adaptable across different systems.

14
New cards

Lexical Analyzer

is essentially a pattern matcher that identifies tokens in a given string

  • Serves as front end of the Syntax Analyzer

15
New cards

Lexemes

are the actual sequence of characters in the source code.

16
New cards

Tokens

are the classification or category assigned to a lexeme.

17
New cards

Finite Automata

Is used to recognize patterns in a regular language, determining which token category the sequence belongs to. (e.g. identifier, integer, or operator)

18
New cards

State Transition Diagram

A directed graph where each state represents a step in token recognition

19
New cards

parsing

is the act of determining if a set of words or symbols conforms to a set of grammar rules. In

20
New cards

sentential form

is a string with terminal and non-terminal symbols.

21
New cards

leftmost derivation

expands the leftmost non-terminal in each step.

22
New cards

LL Parser

are a family of top-down parsers

23
New cards

1. Left-to-right scan of the input.

2. Leftmost derivation.

The two L's stand for:

24
New cards

rightmost derivation

expands the rightmost non-terminal in each step.

25
New cards

Bottom-up parsing

reverses this process, reducing rightmost derivations

26
New cards

RECURSIVE-DESCENT PARSING

consists of a collection of subprograms, many of which are recursive, and produces a parse tree in top-down order.

27
New cards

EBNF

is a few simple extensions to BNF which make expressing grammars more convenient

28
New cards

PAIRWISE DISJOINTNESS TEST

test requires that the FIRST sets of each alternative are disjoint:

29
New cards

Left factoring

is a technique to transform the grammar to fix this issue.

30
New cards

BOTTOM-UP PARSING

is a technique used in syntax analysis of programming languages, where the parser starts with the input and works backward to reconstruct the parse tree

31
New cards

Rightmost Derivation

It means we always expand (replace) the rightmost non-terminal first at each step

32
New cards

Handle

is the specific part of the input that should be reduced next in bottom-up parsing.

33
New cards

Phrase

is any valid sequence of symbols in the input that folows the grammar rules.

34
New cards
35
New cards

Shift

The next input token is moved onto a stack.

36
New cards

Reduce

The top elements of the stack are replaced using a grammar rule.

37
New cards

Accept

Successful completion

38
New cards

Error

discover syntax mistake

39
New cards

PDA(pushdown automaton)

a theoretical computing model used to recognize context-free languages.

40
New cards

canonical LR

The most well-known bottom-up parsing algorithm is the ____________, introduced by Donald Knuth. LR

41
New cards

GOTO Table

Determines the next state after a reduction.

42
New cards

ACTION Table

Defines whether to shift, reduce, accept, or report an error based on the current state and input symbol.