CS420 Lecture15 SyntaxSemantics
CS420 Lecture15 SyntaxSemantics
Programming
Languages
Dr. Mary Pourebadi
San Diego State University
Lecture 15
Describing Syntax
and Semantics
Book: Chapter 3
ISBN 0-321-49362-1
Chapter 3 Topics
• Introduction
• The General Problem of Describing Syntax
• Formal Methods of Describing Syntax
• Attribute Grammars
• Describing the Meanings of Programs:
Dynamic Semantics
• Recognizers
– A recognition device reads input strings over the alphabet
of the language and decides whether the input strings
belong to the language
– Example: syntax analysis part of a compiler
- Detailed discussion of syntax analysis appears in
Chapter 4
• Recognizers
– A recognition device reads input strings over the alphabet
of the language and decides whether the input strings
belong to the language
– Example: syntax analysis part of a compiler
- Detailed discussion of syntax analysis appears in
Chapter 4
• Generators
– A device that generates sentences of a language
– One can determine if the syntax of a particular sentence is
syntactically correct by comparing it to the structure of
the generator
1-12
Basic Compiler
• Specification of Tokens
• Regular Expressions
• Notational Shorthand
• Specification of Tokens
• Regular Expressions
• Notational Shorthand
• Specification of Tokens
• Regular Expressions
• Notational Shorthand
• Context-Free Grammars
• Context-Free Grammars
– Developed by Noam Chomsky in the mid-1950s
– Language generators, meant to describe the
syntax of natural languages
– Define a class of languages called context-free
languages