Go to the documentation of this file.00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014 #ifndef FORMULA_TOKENIZER_HPP_INCLUDED
00015 #define FORMULA_TOKENIZER_HPP_INCLUDED
00016
00017 #include <string>
00018
00019 namespace formula_tokenizer
00020 {
00021
00022 typedef std::string::const_iterator iterator;
00023
00024 enum TOKEN_TYPE { TOKEN_OPERATOR, TOKEN_STRING_LITERAL,
00025 TOKEN_IDENTIFIER, TOKEN_INTEGER, TOKEN_DECIMAL,
00026 TOKEN_LPARENS, TOKEN_RPARENS,
00027 TOKEN_LSQUARE, TOKEN_RSQUARE,
00028 TOKEN_COMMA, TOKEN_SEMICOLON,
00029 TOKEN_WHITESPACE, TOKEN_EOL, TOKEN_KEYWORD,
00030 TOKEN_COMMENT, TOKEN_POINTER };
00031
00032 struct token {
00033
00034 token() :
00035 type(TOKEN_COMMENT),
00036 begin(),
00037 end(),
00038 line_number(1),
00039 filename()
00040 {
00041 }
00042
00043 token(iterator& i1, iterator i2, TOKEN_TYPE type) :
00044 type(type),
00045 begin(i1),
00046 end(i2),
00047 line_number(1),
00048 filename()
00049 {
00050 }
00051
00052 TOKEN_TYPE type;
00053 iterator begin, end;
00054 int line_number;
00055 const std::string* filename;
00056 };
00057
00058 token get_token(iterator& i1, iterator i2);
00059
00060 struct token_error
00061 {
00062 token_error() : description_(), formula_() {}
00063 token_error(const std::string& dsc, const std::string& formula) : description_(dsc), formula_(formula) {}
00064 std::string description_;
00065 std::string formula_;
00066 };
00067
00068 }
00069
00070 #endif