00001 // +-------------------------------------------------------------------------+ 00002 // | I__n__t__e__L__i__b 0.6.10 development | 00003 // | Copyright (c) Andrey Vikt. Stolyarov <crocodil_AT_croco.net> 2000-2007. | 00004 // | | 00005 // | This is free software. The library part is available under | 00006 // | GNU LESSER GENERAL PUBLIC LICENSE v.2.1. | 00007 // | GNU LGPL v2.1 is found in docs/gnu_gpl2.txt, or at http://www.gnu.org | 00008 // | Please see also docs/readme.txt and visit http://www.intelib.org | 00009 // | | 00010 // | !!! THERE IS NO WARRANTY OF ANY KIND, NEITHER EXPRESSED NOR IMPLIED !!! | 00011 // +-------------------------------------------------------------------------+ 00012 00013 00014 00015 00023 #ifndef INTELIB_SCHEME_HPP_SENTRY 00024 #define INTELIB_SCHEME_HPP_SENTRY 00025 00026 #include "../sexpress/sexpress.hpp" 00027 00028 00030 00038 class SchReference : public SReference { 00039 public: 00041 SchReference() {} 00043 SchReference(const SchReference& ref) : SReference(ref) {} 00045 SchReference(const SReference& ref) : SReference(ref) {} 00047 SchReference(SExpression* p) : SReference(p) {} 00048 00049 //SchReference(UserLispFunction fun); 00050 00051 template <class X> SchReference(X &x) : SReference(x) {} 00052 template <class X> SchReference(const X &x) : SReference(x) {} 00053 00055 ~SchReference() {} 00056 00058 00062 SchReference Evaluate() const; 00064 00073 SchReference Evaluate(class SchemeContinuation &cont) const; 00074 00076 00080 bool IsTrue() const; 00081 00083 SchReference& operator,(const SReference& ref) 00084 { SReference::operator,(ref); return *this; } 00085 00087 SchReference& operator||(const SReference& ref) 00088 { SReference::operator||(ref); return *this; } 00089 00091 SchReference operator~() const; 00092 00094 bool IsEql(const SReference& other) const; 00096 bool IsEqual(const SReference& other) const; 00097 00098 #if INTELIB_TEXT_REPRESENTATIONS == 1 00099 00102 SString TextRepresentation() const; 00103 #endif 00104 }; 00105 00106 00108 00120 class SchListConstructor : public SListConstructor { 00121 public: 00122 SchListConstructor() {} 00123 ~SchListConstructor() {} 00124 00125 SchReference operator |(const SchReference &t) const 00126 { return SchReference(new SExpressionCons(t, *PTheEmptyList)); } 00127 SchReference operator ^(const SchReference &other) const 00128 { return SchReference(new SExpressionCons(*PTheEmptyList, other)); } 00129 00130 SchReference operator ~() const { return *PTheEmptyList; } 00131 }; 00132 00134 extern SReference *PTheSchemeSymbolQuote; 00136 extern SReference *PTheSchemeBooleanTrue; 00138 extern SReference *PTheSchemeBooleanFalse; 00139 00140 inline bool SchReference::IsTrue() const 00141 { return GetPtr() != PTheSchemeBooleanFalse->GetPtr(); } 00142 00143 inline SchReference SchReference::operator~() const 00144 { 00145 return 00146 SchReference( 00147 new SExpressionCons( 00148 *PTheSchemeSymbolQuote, 00149 SReference( 00150 new SExpressionCons(*this, *PTheEmptyList) 00151 ) 00152 ) 00153 ); 00154 } 00155 00157 00161 inline SchReference operator~(const SReference& r) 00162 { return ~SchReference(r); } 00163 00164 00165 00166 #endif