CHAPTER 3
DESCRIBING SYNTAX AND SEMANTICS
INTRODUCTION

·        The study of programming languages can be divided into the examination of
syntax and semantics

·        Syntax - is the form of expressions, statements, and program units

·        Semantics - is the meaning of those expressions, statements, and program
units

·        In a well-designed programming language, semantics should follow directly
from syntax

·        Describing syntax is easier than describing semantics


THE GENERAL PROBLEM OF DESCRIBING SYNTAX

 

·        Lexemes - the lowest level of syntactic unit

·        The lexemes of a programming language include its identifiers, literals,
operators and special words

·        Token of a language is a category of its lexemes

 

LANGUAGE RECOGNIZERS

 

FORMAL METHODS OF DESCRIBING SYNTAX

 


CONTEXT FREE GRAMMERS

ORIGINS OF BACKUS -NAUR FORM (BNF)

PARSE TREES

·        Most attractive feature of grammars is that they describe the hierarchical
syntactic structure of sentences of the languages they define. These
hierarchical structures are called parse trees

·        A grammar that generates a sentence for which there are two or more
distinct parse trees is said to be ambiguous

·        Syntactic ambiguity of language structures is a problem because compilers
often base the semantics of those structures on their syntactic form

SYNTAX GRAPHS

 

GRAMMARS AND RECOGNIZERS

RECURSIVE DECENT PARSING

ATTRIBUTE GRAMMARS

STATIC SEMANTICS


BASIC CONCEPTS

DESCRIBING THE MEANING OF PROGRAMS: DYNAMIC SYMANTICS

OPERATIONAL SEMANTICS

AXIOMATIC SEMANTICS


DENOTATIONAL SESMANTICS

·        Denotation semantics is the most rigorous widely known method for
describing the meaning of programs.  It is based on recursive function
theory.

·        The fundamental concept of denotation semantics is to define for each
language entity both a mathematical object and a function that maps
instances of that entity onto instances of the mathematical object.