Back to index

courier  0.68.2
token.h
Go to the documentation of this file.
00001 #ifndef       token_h
00002 #define       token_h
00003 
00004 
00005 #include      "buffer.h"
00006 
00008 //
00009 // The Token class represents one syntactical element in a recipe file, such
00010 // as a semicolon, a brace, or a text string.  The Lexer class creates
00011 // one Token after another from the recipe file.
00012 //
00014 
00015 class  Token {
00016 
00017        Buffer buf;
00018 
00019 public:
00020        enum tokentype {
00021               error,
00022               eof,
00023               qstring,             // Quoted string
00024               sqstring,            // Sinqle-quoted string
00025               btstring,            // Backticked string
00026               equals,
00027               lbrace,
00028               rbrace,
00029               semicolon,
00030               regexpr,
00031                 plus,
00032               minus,
00033               mult,
00034               divi,
00035               lt,
00036               le,
00037               gt,
00038               ge,
00039               eq,
00040               ne,
00041               lor,
00042               land,
00043               bor,
00044               band,
00045               lparen,
00046               rparen,
00047               logicalnot,
00048               bitwisenot,
00049               slt,
00050               sle,
00051               sgt,
00052               sge,
00053               seq,
00054               sne,
00055               length,
00056               substr,
00057               comma,
00058               strregexp,
00059               tokenif,
00060               tokenelse,
00061               tokenelsif,
00062               tokenwhile,
00063               tokento,
00064               tokencc,
00065               exception,
00066               echo,
00067               tokenxfilter,
00068               dotlock,
00069               flock,
00070               logfile,
00071               log,
00072               include,
00073               exit,
00074               foreach,
00075               getaddr,
00076               lookup,
00077               escape,
00078               to_lower,
00079               to_upper,
00080               hasaddr,
00081               gdbmopen,
00082               gdbmclose,
00083               gdbmfetch,
00084               gdbmstore,
00085               timetoken,
00086               importtoken,
00087               unset
00088               };
00089 private:
00090        tokentype type;
00091 public:
00092        Token() : type(error)       {}
00093        ~Token()             {}
00094        Token(const Token &);       // UNDEFINED
00095        Token &operator=(const Token &t) { type=t.type; buf=t.buf; return (*this); }
00096 
00097        void Type(tokentype t) { type=t; }
00098        void Type(tokentype t, const Buffer &tbuf) { type=t; buf=tbuf; }
00099        tokentype Type() const { return (type); }
00100        const Buffer &String() const { return (buf); }
00101        Buffer &String() { return (buf); }
00102 
00103        const char *Name();
00104 } ;
00105 #endif