zenilib: zenilib/jni/external/angle/src/compiler/preprocessor/Token.cpp Source File

zenilib 0.5.3.0

- Main Page
- Modules
- Namespaces
- Classes
- Files

- File List
- File Members

All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Macros Groups Pages
Token.cpp
Go to the documentation of this file.
1 //
2 // Copyright (c) 2011 The ANGLE Project Authors. All rights reserved.
3 // Use of this source code is governed by a BSD-style license that can be
4 // found in the LICENSE file.
5 //
6
7 #include "Token.h"
8
9 #include <cassert>
10
11 #include "numeric_lex.h"
12
13 namespace pp
14 {
15
16 void Token::reset()
17 {
18 type = 0;
19 flags = 0;
20 location = SourceLocation();
21 text.clear();
22 }
23
24 bool Token::equals(const Token& other) const
25 {
26 return (type == other.type) &&
27 (flags == other.flags) &&
28 (location == other.location) &&
29 (text == other.text);
30 }
31
32 void Token::setAtStartOfLine(bool start)
33 {
34 if (start)
35 flags |= AT_START_OF_LINE;
36 else
37 flags &= ~AT_START_OF_LINE;
38 }
39
40 void Token::setHasLeadingSpace(bool space)
41 {
42 if (space)
43 flags |= HAS_LEADING_SPACE;
44 else
45 flags &= ~HAS_LEADING_SPACE;
46 }
47
48 void Token::setExpansionDisabled(bool disable)
49 {
50 if (disable)
51 flags |= EXPANSION_DISABLED;
52 else
53 flags &= ~EXPANSION_DISABLED;
54 }
55
56 bool Token::iValue(int* value) const
57 {
58 assert(type == CONST_INT);
59 return numeric_lex_int(text, value);
60 }
61
62 bool Token::uValue(unsigned int* value) const
63 {
64 assert(type == CONST_INT);
65 return numeric_lex_int(text, value);
66 }
67
68 bool Token::fValue(float* value) const
69 {
70 assert(type == CONST_FLOAT);
71 return numeric_lex_float(text, value);
72 }
73
74 std::ostream& operator<<(std::ostream& out, const Token& token)
75 {
76 if (token.hasLeadingSpace())
77 out << " ";
78
79 out << token.text;
80 return out;
81 }
82
83 } // namespace pp
pp::Token::equals
bool equals(const Token &other) const
Definition: Token.cpp:24
type
GLint GLenum GLsizei GLsizei GLsizei GLint GLenum GLenum type
Definition: gl2ext.h:845
start
GLuint start
Definition: glew.h:1239
location
GLint location
Definition: gl2ext.h:1164
pp::Token::reset
void reset()
Definition: Token.cpp:16
pp
png_sPLT_entryp pp
Definition: pngrutil.c:1375
pp::Token::setAtStartOfLine
void setAtStartOfLine(bool start)
Definition: Token.cpp:32
pp::Token::flags
unsigned int flags
Definition: Token.h:88
assert
#define assert(x)
Definition: SDL_malloc.c:1234
numeric_lex.h
pp::Token::HAS_LEADING_SPACE
Definition: Token.h:61
pp::Token::AT_START_OF_LINE
Definition: Token.h:60
pp::Token::uValue
bool uValue(unsigned int *value) const
Definition: Token.cpp:62
pp::Token::setExpansionDisabled
void setExpansionDisabled(bool disable)
Definition: Token.cpp:48
pp::Token::location
SourceLocation location
Definition: Token.h:89
pp::Token::iValue
bool iValue(int *value) const
Definition: Token.cpp:56
pp::Token::hasLeadingSpace
bool hasLeadingSpace() const
Definition: Token.h:75
pp::Token::CONST_INT
Definition: Token.h:26
pp::operator<<
std::ostream & operator<<(std::ostream &out, const Token &token)
Definition: Token.cpp:74
value
EGLSurface EGLint void ** value
Definition: eglext.h:301
pp::Token::text
std::string text
Definition: Token.h:90
pp::numeric_lex_int
bool numeric_lex_int(const std::string &str, IntType *value)
Definition: numeric_lex.h:37
flags
GLenum GLsizei GLsizei GLsizei GLsizei GLbitfield flags
Definition: glew.h:2767
pp::Token::fValue
bool fValue(float *value) const
Definition: Token.cpp:68
pp::Token::setHasLeadingSpace
void setHasLeadingSpace(bool space)
Definition: Token.cpp:40
pp::numeric_lex_float
bool numeric_lex_float(const std::string &str, FloatType *value)
Definition: numeric_lex.h:49
pp::Token
Definition: Token.h:18
pp::Token::CONST_FLOAT
Definition: Token.h:27
pp::Token::type
int type
Definition: Token.h:87
Token.h
pp::SourceLocation
Definition: SourceLocation.h:13
pp::Token::EXPANSION_DISABLED
Definition: Token.h:62