00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016 #include "../sexpress/sexpress.hpp"
00017 #include "../sexpress/svector.hpp"
00018 #include "sreader.hpp"
00019
00020 static void do_process(int depth, SReference rest, SVectorRef &vec, bool rs)
00021 {
00022 SExpressionCons *dp = rest.DynamicCastGetPtr<SExpressionCons>();
00023 if(!dp) {
00024 vec = new SExpressionVector(rs ? 0 : depth);
00025 } else {
00026 do_process(depth+1, dp->Cdr(), vec, rs);
00027 vec[depth] = dp->Car();
00028 }
00029 }
00030
00031 static SReference process_fixed_vectors(const SReference &list)
00032 {
00033 SVectorRef vr;
00034 do_process(0, list, vr, false);
00035 return vr;
00036 }
00037
00038 static SReference process_resizeable_vectors(const SReference &list)
00039 {
00040 SVectorRef vr;
00041 do_process(0, list, vr, true);
00042 return vr;
00043 }
00044
00045 void add_vectors_to_reader(class IntelibReader &reader)
00046 {
00047 reader.AddSequenceOpener("#(", process_fixed_vectors, ")");
00048 reader.AddSequenceOpener("#~(", process_resizeable_vectors, ")");
00049 }