00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019
00020
00021
00022
00023
00024 #ifndef Parser_TokenPath_H
00025 #define Parser_TokenPath_H
00026
00027
00028 #include <vector>
00029 #include <string>
00030 #include <iostream>
00031
00032 namespace Parser {
00033
00037 struct TokenPath
00038 {
00039 enum Direction {
00040 leftChild,
00041 rightChild,
00042 parent,
00043 leftSibling,
00044 rightSibling,
00045 previous,
00046 next
00047 };
00048
00049 static char const* Names[];
00050 static int get(std::string& tok);
00051
00052 TokenPath(int root) :
00053 root(root)
00054 { }
00055
00057 void add(Direction d) {
00058 path.push_back(d);
00059 code += dirCode[d];
00060 }
00061
00063 char const* Code() const;
00064
00066 std::ostream& serialize(std::ostream& os) const;
00067
00068 static char const* const dirCode;
00069
00070 std::vector<Direction> path;
00071 int root;
00072 std::string code;
00073 };
00074
00075 inline std::ostream& operator <<(std::ostream& s, const TokenPath& d)
00076 {
00077 return d.serialize(s);
00078 }
00079
00080 }
00081
00082 #endif // Parser_TokenPath_H
00083
00084