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
00039 struct TokenPath
00040 {
00041 enum Direction {
00042 leftChild,
00043 rightChild,
00044 parent,
00045 leftSibling,
00046 rightSibling,
00047 previous,
00048 next
00049 };
00050
00051 static char const* Names[];
00052 static int get(std::string& tok);
00053
00054 TokenPath(int root) :
00055 root(root)
00056 { }
00057
00059 void add(Direction d) {
00060 path.push_back(d);
00061 code += dirCode[d];
00062 }
00063
00065 char const* Code() const;
00066
00068 std::ostream& serialize(std::ostream& os) const;
00069
00070 static char const* const dirCode;
00071
00072 std::vector<Direction> path;
00073 int root;
00074 std::string code;
00075 };
00076
00077 inline std::ostream& operator <<(std::ostream& s, const TokenPath& d)
00078 {
00079 return d.serialize(s);
00080 }
00081
00082 }
00083
00084 #endif // Parser_TokenPath_H
00085
00086