Previous Page
Library
Parser
Preprocessor
Interpreter
Compiler
An exchange format
Next Page

ELAN - Preprocessor

The ELAN syntax provides a few fancy constructions: for instance the construction P {& s_I=t_I}_I=1...3 is processed into P & s_1=t_1 & s_2=t_2 & s_3=t_3 and t_1,...,t_3 is processed into t_1,t_2,t_3, thanks the ELAN preprocessor that performs textual replacements. The construction
FOR EACH v SUCH THAT v:=(S) t : { e }
can be seen as a program generation feature. This construction replaces in the sequence of lexems e all occurrences of the variable v by each result of the strategy S applied to t. From the following specification written in ELAN:
operators global
FOR EACH L:list[identifier] AND F:identifier
SUCH THAT L:=() a.b.nil AND F:=(listExtract) extract(L) :
{ F : term; } end

where listExtract is a variant, for the sort list[identifier], of the strategy mapStrat previously defined. The preprocessor extracts the elements a and b from the list a.b.nil and creates the following declarations:
operators global
a : term; b : term;
end

So the preprocessor may be used to automatically generate parts of specifications used to analyse the rest of a program. It should be emphasised that it needs all the power of the ELAN interpreter to perform its task: in the previous example, the strategy listExtract has to be executed before further analysis. This illustrates the strong interaction between the parser, the preprocessor and the interpreter.