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 00016 #include "../sexpress/svector.hpp" 00017 #include "../sexpress/shashtbl.hpp" 00018 #include "lisp.hpp" 00019 #include "lreader.hpp" 00020 00021 SString SExpressionExtvarname::TextRepresentation() const 00022 { 00023 return SString("#&")+this->GetValue(); 00024 } 00025 00026 IntelibTypeId SExpressionExtvarname::TypeId(&SExpressionString::TypeId); 00027 00029 // transformers 00030 00031 static SReference QuoteExpression(const SReference &ref) 00032 { 00033 return ~(LReference(ref)); 00034 } 00035 00036 static SReference FunquoteExpression(const SReference &ref) 00037 { 00038 LFunctionConstructor F; 00039 return F^(LReference(ref)); 00040 } 00041 00042 static SReference ExternVarProcess(const char *str) 00043 { 00044 return SReference(new SExpressionExtvarname(str)); 00045 } 00046 00047 static SReference InvalidLexem(const char *) 00048 { 00049 static SLabel inv("#<UNREADABLE-TOKEN>"); 00050 return inv; 00051 } 00052 00054 // LispReader 00055 00056 LispReader::LispReader() 00057 { 00058 AddStringLiteral("#<", '>', InvalidLexem); 00059 AddTokenType("#&", ExternVarProcess); 00060 AddQuoter("'", QuoteExpression); 00061 AddQuoter("#'", FunquoteExpression); 00062 add_vectors_to_reader(*this); 00063 add_hashtables_to_reader(*this); 00064 } 00065