WLPP Programming Language Specification

The WLPP programming language contains a strict subset of the features of C++. A WLPP source file contains exactly one procedure definition.

Lexical Syntax

A procedure definition is a sequence of tokens optionally separated by white space consisting of spaces, newlines, or comments. Every valid token is one of the following: White space consists of any sequence of the following: Any pair of consecutive tokens may be separated by white space. Pairs of consecutive tokens that both come from one of the following sets must be separated by white space: Tokens that contain letters are case-sensitive; for example, int is an INT token, while Int is not.

Context-free Syntax

A context-free grammar for a valid WLPP program is:

Context-sensitive Syntax

Any ID in a sequence derived from dcl is said to be declared. Any ID derived from factor or lvalue is said to be used. Any particular string x that is an ID may be declared at most once. A string x which is an ID may be used in any number of places, but only if the same string x is declared. String comparisons are case sensitive; for example, "FOO" and "foo" are distinct.

Instances of the tokens ID, NUM, NULL and the non-terminals factor, term, expr, and lvalue have a type, which is either int or int*. Types must satisfy the following rules:

Semantics

Any WLPP program that obeys the lexical, context-free, and context-sensitive syntax rules above is a also a valid C++ program fragment. The meaning of the WLPP program is defined to be identical to that of the C++ program formed by inserting the WLPP program at the indicated location in one of the following C++ program shells: