Subversion Repositories Kolibri OS

Rev

Details | Last modification | View Log | RSS feed

Rev Author Line No. Line
4680 right-hear 1
 
2
#define __substitute_h__
3
4
 
5
#include "lispobject.h"
6
#include "lispenvironment.h"
7
8
 
9
 
10
 */
11
class SubstBehaviourBase : public YacasBase
12
{
13
public:
14
    virtual ~SubstBehaviourBase();
15
    virtual LispBoolean Matches(LispPtr& aResult, LispPtr& aElement) = 0;
16
};
17
18
 
19
 */
20
void InternalSubstitute(LispPtr& aTarget, LispPtr& aSource,
21
                        SubstBehaviourBase& aBehaviour);
22
23
 
24
 
25
 * of substitution
26
 */
27
class SubstBehaviour : public SubstBehaviourBase
28
{
29
public:
30
    SubstBehaviour(LispEnvironment& aEnvironment,LispPtr& aToMatch,
31
                  LispPtr& aToReplaceWith);
32
    virtual LispBoolean Matches(LispPtr& aResult, LispPtr& aElement);
33
private:
34
    LispEnvironment& iEnvironment;
35
    LispPtr& iToMatch;
36
    LispPtr& iToReplaceWith;
37
};
38
39
 
40
 * names.
41
 */
42
class LocalSymbolBehaviour : public SubstBehaviourBase
43
{
44
public:
45
    LocalSymbolBehaviour(LispEnvironment& aEnvironment,
46
                         LispString ** aOriginalNames,
47
                         LispString ** aNewNames, LispInt aNrNames);
48
    virtual LispBoolean Matches(LispPtr& aResult, LispPtr& aElement);
49
private:
50
    LispEnvironment& iEnvironment;
51
    LispString ** iOriginalNames;
52
    LispString ** iNewNames;
53
    LispInt iNrNames;
54
};
55
56
 
57
 * When typing `(...) all occurrences of @a will be
58
 * replaced with:
59
 * 1) a evaluated if a is an atom
60
 * 2) function call with function name replaced by evaluated
61
 *    head of function if a is a function. For instance, if
62
 *    a is f(x) and f is g, then f(x) gets replaced by g(x)
63
 */
64
class BackQuoteBehaviour : public SubstBehaviourBase
65
{
66
public:
67
    BackQuoteBehaviour(LispEnvironment& aEnvironment)
68
        : iEnvironment(aEnvironment) {};
69
    virtual LispBoolean Matches(LispPtr& aResult, LispPtr& aElement);
70
    LispEnvironment& iEnvironment;
71
};
72
73
 
74
 
75
 
76
 
77