Programming Language Macro: Lexical Issues and Tokens

CS 4410

Comments

Single line comment in Macro is delimited by - (two hyphens) and the end-of-line charactor. Moreover, we also have multiple line comment like in C or Pascal. Multi-line comments are enclosed in a pair of curly parenthesis, {}. Comments may appear anywhere in the programs; they are ignored by the scanner. Two kind of comments are convenient both for coding and debugging (why ?). It could be tricky dealing with end-of-file in comment (it's an error, right?).

White spaces

Spaces and tabs are considered white spaces, so is end-of-line charactor. White spaces are to separate tokens, but they will not appear as tokens.

Case sensitivity

Macro is case insensitive. (Certainly, case matters in strings, as in below.)

Reserved words

tabular11

Constants

There are three kinds of constants: integers, float-point numbers and strings. Integer are consisted of digits only. Float-point numbers contain a decimal point, where at least one digit must appear at each side of the decimal point (so we don't have 1. or .2). For simplicity, we don't have exponential parts here. A string is enclosed in a pair of double quotation marks, and is limited to within one line. Backslash works as the escape charactor as in C.

Identifiers

An identifier begins with a charactor, and is followed by a sequence of letters and/or digits, but excluding the reserved words.

Operators and delimiters

  1. Assignment: ":="
  2. Arithmetic: "+", "-", "*", "/"
  3. Relation: "<", "<=", ">", ">=", "==", "<>"
  4. Delimiters: "..", ":", ";", ",", ".", "(", ")", "[", "]"