Chapter 4 Notes

Lexical and Syntax Analysis

These notes are not complete

§ 4.1 Introduction

T E R M S
syntax
The branch of language study which treats of the combination of words and symbols into phrases.

§ 4.2 Lexical Analysis

T E R M S
scanner
A program which identifies the tokens of a language.
token
An atomic symbol of the source program.
lexeme
The minimal lexical unit of a language
ComputerUser

§ 4.3 The Parsing Problem

T E R M S
parsing
The process of analyzing a source program syntactically to determine its phrase structure.
syntax tree
An ordered labeled tree such that: (a) the terminal nodes are labeled by terminal symbols; (b) the nonterminal nodes are labeled by by nonterminal symbols; and (c) each nonterminal node labeled by N has children labeled by X1, ..., Xn
abstract syntax tree
A syntax tree generated by an abstract syntax.

¶ 4.3.1 Introduction to Parsing

 
T E R M S
parser
A program which identifies the phrase structure of a language.

¶ 4.3.2 Top-Down Parsers

 
T E R M S
top-down parser
A parser which starts at the starts at the root of the syntax tree and progressively analyses toward the leaves.

¶ 4.3.3 Bottom-Up Parsers

 
T E R M S
bottom-up parser
A parser which begins analysis at the leaves of the syntax tree and progresses toward the root.

¶ 4.3.3 The Complexity of Parsing

 

§ 4.4 Recursive-Descent Parsing

T E R M S
recursive-descent parser
A top-down parser which, beginning with the root phrase, calls recognizer functions for each phrase.
left-recursive grammar
A grammar which contains at least one left-recursive production.
left-recursive production
A production of a non-terminal phrase which which has the same non-terminal as its start.
LL(k) parser
A parser which parses the source from left to right and constructs a leftmost derivation of the sentence, looking ahead no more that k tokens.

¶ 4.4.1 The Recursive-Descent Parsing Process

 

¶ 4.4.2 The LL Grammar Class

 

§ 4.5 Bottom-Up Parsing

T E R M S
semantics
The branch of language study which treats of meanings of symbols, words, and phrases.

¶ 4.5.1 The Parsing Problem for Bottom-Up Parsers

 

¶ 4.5.2 Shift-Reduce Algorithms

 

¶ 4.5.3 LR Parsers

 
T E R M S
LR(k) parser
A parser which parses the source from left to right and constructs a rightmost derivation of the sentence, looking ahead no more that k tokens.

Terms

LL(k) parser
LR(k) parser
abstract syntax tree
bottom-up parser
left-recursive grammar
left-recursive production
lexeme
parser
parsing
recursive-descent parser
scanner
semantics
syntax
syntax tree
token
top-down parser

See Also

Chapter 3   Describing Syntax and Semantics
Chapter 5   Names, Bindings, Type Checking, and Scopes

copyright 2007, j.h.young, revised 9/25/2007 Site Logo