Refal Plus Reference Manual
The material in this guide is Copyright (c) Ruten Gurin and Sergei Romanenko 1991-2007.
Introduction
Programming in Refal Plus
Your First Refal Plus Program
Data Structures
Objects vs. Values
Ground Expressions
Representing Tree Structures
Types of Objects
Garbage Collection
Evaluation and Analysis of Ground Expressions
Variables
Result Expressions
Patterns
Functions Defined in the Program
Formats of Functions
Function Definitions
One-Sentence Function Definitions
Local Variables
A Syntax-Related Subtlety: Paths, Rests, and Sources
Local Variables (Continuation)
Recursion
Logical conditions
Conditions and Predicates
Conditionals
Logical Connectives
Example: Formal Differentiation
Example: Comparison of Sets
Direct access selectors
Functions returning several results
Traversing Ground Expressions
Quicksort
Iteration
Search and backtracking
The Queens Problem
The Sequence Problem
Example: a compiler for a small imperative language
The Source Language
The Target Language
The General Structure of the Compiler
The Modules of the Compiler and their Interfaces
The Main Module
The Scanner
The Parser
The Code Generator
The Dictionary Module
Syntax and Semantics of Refal Plus
Syntax Notation
Natural Semantics Specifications
Lexical Structure of Programs
Comments
Identifiers
Tokens
Keywords
Character Symbols
Word Symbols
Numeric Symbols
Variables
Normalization of the Token Stream
Objects and Values
Static and Dynamic Symbols
Ground Expressions
Symbolic Names
Expression Names
Function Names
Reference Names
Module Names
Named Ground Expressions
Variable Values and Environments
Result Expressions
Patterns
Hard Expressions
Paths
Conditions
Bindings
Searches
Matches
Rests
Delimited Paths
Negative Conditions
Fences
Cuts
Failures
Right Hand Sides
Error Generators
Error Traps
Sources
Alternatives
Alternative Matches
Result Expressions as Sources
Sentences
Pattern Alternatives
Function Definitions
Declarations
Constant Declarations
Object Declarations
Function Declarations
Context Dependent Restrictions
Elimination of Redundant Constructs
Restrictions Imposed by Function Declarations
Restrictions on the Use of References to Functions
Restrictions on the Use of Variables
Restrictions on the Use of Cuts
Trace Directives
Modules
Program Execution
Refal Plus Library Functions
Access: Direct Access to Ground Expressions
Apply: Application of Functions Passed as Arguments
Arithm: Arithmetic Operations on Integers
Bit: Bitwise Operations
Box: Box Operations
Class: Predicates for Determining Classes of Symbols
Compare: Comparison Operations
Convert: Data Convertions
Dos: Calls to the Operating System
StdIO: Standard Input/Output
String: String Operations
Table: Table Operations
Vector: Vector Operations
Bibliography