Lexical Structure of Programs

A program in Refal Plus is a finite character sequence. The syntax analysis of programs is done in two steps. First, the program is scanned, in order to break up the character stream into tokens. Then the token sequence is parsed to produce an abstract syntax tree.

Thus, the definition of the Refal Plus syntax comprises two parts. The first part describes the lexical structure of programs, i.e. how tokens are represented by character sequences, whereas the second part describes how to construct programs by combining tokens.

Program = { Token | WhiteSpace }.

WhiteSpace = WhiteStuff { WhiteStuff }.

WhiteStuff = Space | HorizontalTab | NewLine | Comment.

A program is a finite sequence of tokens. Tokens may be separated by spaces, horizontal tabs, new line characters, and comments, which cannot occur within tokens and are ignored unless they are essential to separate two consecutive tokens.