The Battle for Wesnoth
1.13.4+dev
All
Classes
Namespaces
Files
Functions
Variables
Typedefs
Enumerations
Enumerator
Friends
Macros
Modules
Pages
formula
tokenizer.hpp
Go to the documentation of this file.
1
/*
2
Copyright (C) 2007 - 2016 by David White <dave.net>
3
Part of the Silver Tree Project
4
5
This program is free software; you can redistribute it and/or modify
6
it under the terms of the GNU General Public License as published by or later.
7
This program is distributed in the hope that it will be useful,
8
but WITHOUT ANY WARRANTY.
9
10
See the COPYING file for more details.
11
*/
12
13
#ifndef FORMULA_TOKENIZER_HPP_INCLUDED
14
#define FORMULA_TOKENIZER_HPP_INCLUDED
15
16
#include <string>
17
18
namespace
formula_tokenizer
19
{
20
21
typedef
std::string::const_iterator
iterator
;
22
23
/// TOKEN_TYPE is already defined in a Winnt.h (a windows header wich is included under some conditions.)
24
enum
TOKEN_TYPE
{
TOKEN_OPERATOR
,
TOKEN_STRING_LITERAL
,
25
TOKEN_IDENTIFIER
,
TOKEN_INTEGER
,
TOKEN_DECIMAL
,
26
TOKEN_LPARENS
,
TOKEN_RPARENS
,
27
TOKEN_LSQUARE
,
TOKEN_RSQUARE
,
28
TOKEN_COMMA
,
TOKEN_SEMICOLON
,
29
TOKEN_WHITESPACE
,
TOKEN_EOL
,
TOKEN_KEYWORD
,
30
TOKEN_COMMENT
,
TOKEN_POINTER
};
31
32
struct
token
{
33
34
token
() :
35
type
(
TOKEN_COMMENT
),
36
begin
(),
37
end
(),
38
line_number
(1),
39
filename
()
40
{
41
}
42
43
token
(iterator& i1, iterator i2,
TOKEN_TYPE
type
) :
44
type(type),
45
begin
(i1),
46
end
(i2),
47
line_number
(1),
48
filename
()
49
{
50
}
51
52
TOKEN_TYPE
type
;
53
iterator
begin
,
end
;
54
int
line_number
;
55
const
std::string
*
filename
;
56
};
57
58
token
get_token
(iterator& i1, iterator i2);
59
60
struct
token_error
61
{
62
token_error
() :
description_
(),
formula_
() {}
63
token_error
(
const
std::string
& dsc,
const
std::string
& formula) :
description_
(dsc),
formula_
(formula) {}
64
std::string
description_
;
65
std::string
formula_
;
66
};
67
68
}
69
70
#endif
formula_tokenizer
Definition:
tokenizer.cpp:17
formula_tokenizer::TOKEN_SEMICOLON
Definition:
tokenizer.hpp:28
formula_tokenizer::TOKEN_LPARENS
Definition:
tokenizer.hpp:26
type
GLuint GLuint GLsizei GLenum type
Definition:
glew.h:1221
formula_tokenizer::TOKEN_COMMENT
Definition:
tokenizer.hpp:30
formula_tokenizer::TOKEN_TYPE
TOKEN_TYPE
TOKEN_TYPE is already defined in a Winnt.h (a windows header wich is included under some conditions...
Definition:
tokenizer.hpp:24
formula_tokenizer::TOKEN_INTEGER
Definition:
tokenizer.hpp:25
formula_tokenizer::TOKEN_EOL
Definition:
tokenizer.hpp:29
formula_tokenizer::token::token
token()
Definition:
tokenizer.hpp:34
formula_tokenizer::token_error::description_
std::string description_
Definition:
tokenizer.hpp:64
formula_tokenizer::TOKEN_KEYWORD
Definition:
tokenizer.hpp:29
formula_tokenizer::token::line_number
int line_number
Definition:
tokenizer.hpp:54
formula_tokenizer::get_token
token get_token(iterator &i1, const iterator i2)
Definition:
tokenizer.cpp:38
end
GLuint GLuint end
Definition:
glew.h:1221
formula_tokenizer::TOKEN_COMMA
Definition:
tokenizer.hpp:28
formula_tokenizer::TOKEN_DECIMAL
Definition:
tokenizer.hpp:25
formula_tokenizer::TOKEN_STRING_LITERAL
Definition:
tokenizer.hpp:24
formula_tokenizer::TOKEN_RSQUARE
Definition:
tokenizer.hpp:27
formula_tokenizer::token::end
iterator end
Definition:
tokenizer.hpp:53
formula_tokenizer::TOKEN_RPARENS
Definition:
tokenizer.hpp:26
formula_tokenizer::token_error
Definition:
tokenizer.hpp:60
formula_tokenizer::TOKEN_WHITESPACE
Definition:
tokenizer.hpp:29
formula_tokenizer::token_error::token_error
token_error(const std::string &dsc, const std::string &formula)
Definition:
tokenizer.hpp:63
formula_tokenizer::token::begin
iterator begin
Definition:
tokenizer.hpp:53
formula_tokenizer::token::type
TOKEN_TYPE type
Definition:
tokenizer.hpp:52
formula_tokenizer::token_error::formula_
std::string formula_
Definition:
tokenizer.hpp:65
formula_tokenizer::token_error::token_error
token_error()
Definition:
tokenizer.hpp:62
formula_tokenizer::token::filename
const std::string * filename
Definition:
tokenizer.hpp:55
formula_tokenizer::TOKEN_LSQUARE
Definition:
tokenizer.hpp:27
formula_tokenizer::TOKEN_IDENTIFIER
Definition:
tokenizer.hpp:25
formula_tokenizer::TOKEN_OPERATOR
Definition:
tokenizer.hpp:24
formula_tokenizer::TOKEN_POINTER
Definition:
tokenizer.hpp:30
formula_tokenizer::iterator
std::string::const_iterator iterator
Definition:
tokenizer.hpp:21
string
GLsizei const GLcharARB ** string
Definition:
glew.h:4503
formula_tokenizer::token
Definition:
tokenizer.hpp:32
formula_tokenizer::token::token
token(iterator &i1, iterator i2, TOKEN_TYPE type)
Definition:
tokenizer.hpp:43
Generated by
1.8.8