CSCI305.github.io

CSCI 305 Programming Languages

Syntax and Semantics

Reading: Webster Ch. 3

Outside The Classroom

Instructions

  1. Watch This Video - (26:15)
  2. Watch This Video - (10:44)
  3. EBNF Clarification Video
  4. Complete the Out of class exercise
  5. Review the Lecture Slides

Out of Class Exercise:

Given the following grammar:

<exp> ::= <exp> + <mulexp> | <mulexp>
<mulexp> ::= <mulexp> * <rootexp> | <rootexp>
<rootexp> ::= ( <exp> )
          | a | b | c

Modify it as follows:

Check Your Learning

Solution Video - (02:46)
Solution
<exp> ::= <exp> + <mulexp> | <exp> - <mulexp> | <mulexp>
<mulexp> ::= <mulexp> * <rootexp> | <mulexp> / <rootexp> | <rootexp>
<rootexp> ::= ( <exp> )
          | a | b | c

Group Exercises:

Exercise 1:

Given the following grammar:

<exp> ::= <exp> + <mulexp> | <mulexp>
<mulexp> ::= <mulexp> * <rootexp> | <rootexp>
<rootexp> ::= ( <exp> )
          | a | b | c

Modify it as follows:

Check Your Learning

Solution Video - (03:49)
Solution
<exp> ::= <addexp> = <exp> | <addexp>
<addexp> ::= <addexp> + <modexp> | <modexp>
<modexp> ::= <modexp> % <mulexp> | <mulexp>
<rootexp> ::= ( <exp> ) | a | b | c