This chapter gives a complete description of Refal Plus. Here you can find information
about certain subtle points and technical details.
Syntax Notation
The syntax is described by means of an extended Backus-Naur form (EBNF).
Natural Semantics Specifications
The method that is be used to describe the execution of Refal Plus programs is known as Natural Semantics or Structural Operational Semantics.
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.
Objects and Values
Data processed by a Refal Plus program may be either objects or values.
Result Expressions
A result expression consists of symbols, parentheses, variables and function calls. The evaluation of a result expression produces either a ground expression, a failure, or an error.
Patterns
Patterns accept ground expressions, decompose them, and bind parts of ground expressions to variables. At run-time, matching a ground expression against a pattern either succeeds or fails.
Hard Expressions
Hard expressions are patterns that accept ground expressions, decompose them, and bind parts of ground expressions to variables. At run-time, matching a ground expression against a hard expression always succeeds, which is guaranteed by the context dependent restrictions on Refal Plus programs checked at compile-time.
Paths
The evaluation of a path produces either a ground expression, a failure, or an error.
Sentences
A sentence accepts a given ground expression and tries to match it against a pattern. If the matching succeeds, the following rest is evaluated.
Pattern Alternatives
A pattern alternative matches a given ground expression against a list of sentences.
Function Definitions
A function's definition binds the function's name to the function's body, thereby describing the way in which the function is to be evaluated.
Declarations
A declaration binds a symbolic name to a constant ground expression, an object, or a function.
Context Dependent Restrictions
Any program written in Refal Plus must satisfy a number of context dependent restrictions.
Trace Directives
Trace directives specify what debugging information is to be output at run-time.
Modules
A program written in Refal Plus consists of one or more modules. Each module comprises two components: the interface of the module and the implementation of the module.
Program Execution
A program in Refal Plus may consist of several modules, one of which must export the function Main. The execution of the program amounts to evaluating the call to the function Main.