Syntax: A self-paced module for CS 471

Introduction

This module is a self-contained component of CS471, Programming Language Structure I. It can be completed at your own pace during the first half of the course. It uses the relevant chapters from Sebesta's book, as well worked examples and other references. The self-test material is gathered into one place here. The answers are here.

Goals

To learn the basics of formal syntax definitions of programming languages: BNF (Backus Naur Form), EBNF (Extended BNF) and syntax diagrams. To be able to write a simple grammar in any style given a specification. To be able to alter a grammar to meet a new specification. To be able to translate a simple grammar between BNF, EBNF and syntax diagrams. To draw a syntax tree for a given grammar and a sample token stream.

Contents

  1. Components of syntax.
  2. Types of grammar, BNF.
  3. Parse trees.
  4. Ambiguity in grammars.
  5. Extended BNF.
  6. Syntax diagrams.

How to proceed

Follow the sequence of pages given in the contents section above. Answer the self-test at the end of each section.