formula_tokenizer.hpp

Go to the documentation of this file.
00001 /* $Id: formula_tokenizer.hpp 52533 2012-01-07 02:35:17Z shadowmaster $ */
00002 /*
00003    Copyright (C) 2007 - 2012 by David White <dave.net>
00004    Part of the Silver Tree Project
00005 
00006    This program is free software; you can redistribute it and/or modify
00007    it under the terms of the GNU General Public License as published by or later.
00008    This program is distributed in the hope that it will be useful,
00009    but WITHOUT ANY WARRANTY.
00010 
00011    See the COPYING file for more details.
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
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Defines

Generated by doxygen 1.7.1 on Fri May 25 2012 01:02:51 for The Battle for Wesnoth
Gna! | Forum | Wiki | CIA | devdocs