This file is helpful for people who want to implement a new FunLog++
code generator or who want to maintain the original FunLog++ system software.
The semantic list is an internal data structure of the FunLog++ compiler.
It serves a general interface for (almost) all FunLog++ code generators.
The only exception currently is the code generator to Delphi Pascal which
directly accesses the syntax tree.
A FunLog++ semantic list consists of a sequence of FunLog++ class code
definitions. A FunLog++ class code definition consists of its class signature
and a list of its method code definitions. A FunLog++ method code definition
consists of its method signature, the determination of the SELF parameter
(if present), and the method body's code link. With class code there additionally
is an explanation name which is intented to be used for error or debug
messages.
Method signature and class signature consist of the method or class
name and its parameters.
MethodSig = ( MethodName( Result, Par(1),
..., Par(Q) ).
ClassSig = ( ClassName(
Result, Par(1), ..., Par(Q) ).
Signatures occur in defining and applying locations.
Link Code
Link code is a data structure to represent the code generator interface
for a FunLog++ method body. The link code has one of few differenty types.
SomeLink = PackedLink; ProperLink;
NoLink.
ProperLink = AggrLink; DataLink; AssignLink;
LazyLink; SystemLink; ErrorLink;
ReceiverLink; LocalLink.
The aggregation link simply combines a sequence of some links which
have to be executed at runtime one after another.
AggrLink = ( '=aggr='( [ SomeLink(1),
..., SomeLink(P) ] ).
Another simple link type is the assign link where some variable gets the
value of some object or of some other variable.
AssignLink = ( '=assign='(Variable,Object)
).
The data link code has two attributes. The value reference determines where
the result has to be stored to. The class signature refers to one of the
class codes in the code list. The data link is the only semantic list concept
in order to refer to a class definition (from any where).
DataLink = ( '=data='(Variable,ClassSig)
).
With the lazy link the evaluation of some FunLog++ command may be delayed
until the result of that link is actually required.
LazyLink = ( '=lazy='(Variable,LinkValue,LinkCode)
).
The system link is introduced in order to easily access target language
procedures and data from within a FunLog++ program. The system link appears
semantic lists for FunLog++ standard library code only.
SystemLink = ( '=systemcall='(Variable,TargetCode)
).
Sometimes error conditions have to be transferred in to the code list as
an error link. These refer to syntax error or semantic error as far as
they could be detected from the FunLog++ compiler..
ErrorLink = ( '=error='(Variable,ErrorMessage,ContextSymbols)
).
Then there are three type of links which send some comand to some specific
context. The receiver link explicitly determines the receiver object of
some FunLog++ command. The top link sends the given command to the outmost
class object which automatically exists for each defined class. The local
link send its command to that SELF object where the messages occured in
the FunLog++ source program.
ReceiverLink = ( ':'(_,ReceiverObject,MethodSig) ).
LocalLink = MethodSig.
NoLink
The nolink is a dummy for places where a link is expected but nothing
is to be done.
Packed Link
The packed link is no real separate link to be regarded by the code
generator. Instead this is a data structure which might appear instead
of some link and which has to be expanded to a proper link.
PackedLink = KonjunctionLink; DisjunctionLink.
Other Code List Elements
Object
= DataLink; Variable; Number; Text; List.
Variable =
( a placeholder for a logical variable ).
Number
= ( denotation of a number ).
Text
= ( denotation of a text ).
List
= ( denotation of a list of SomeLink-s ).
ExplanationName = ( a text of a readable function
name, e.g. "number/1" ).
TargetCode = ( a term
of the target language, e.g. A>B ).
ErrorMessage = ( a text describing
an error situation ).
ContextSymbols = ( a list of Symbol-s to describe
an error context ).
Symbol
= ( a text representing one source code symbol ).
ClassName =
( concatenation of the class path and name items,
preceeded by a separator $ and by the arity number,
e.g. "$1standard$2number" ).
MethodName = ( the
mere method name, e.g. "root" or "throw" ).
Example
source file PRIMO.FUN
result ::= 8-5.
standard ::= {
number(A) ::= {
SELF - B ::= :platform_number_minus(A,B).
}.
}.
platform_number_minus(X,Y) ::= '=systemcall='(Res, is(Res,X-Y)
).
|
semantic list for PRIMO.FUN
[ |
::=( 'PRIMO'(_), "PRIMO",
[
::=( result(A), 0, '=aggr='([
assign(B,8), assign(C,5), '-'(A,B,C) ]) ),
::=( standard(D), 0,'=data=(D,'$1standard'(D))
),
::=( platform_number_minus(E,F,G),
0, '=systemcall='(E, is(E,F-G)) )
]), |
::=( '$1standard'(_), "standard",
[
::=( number(A,B), 2, '=data='(A,'$1standard$2number'(A,B))
)
]), |
::=( '$1standard$2number'(_,A), "number",
[
::=( '-'(B,A,C), 2, '=aggr='(['=assign='(D,'PRIMO'(_)),
':'(D,platform_number_minus(B,A,C) ]) )
]) |
] |