zenilib  0.5.3.0
 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 
17 {
18  type = 0;
19  flags = 0;
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 
33 {
34  if (start)
36  else
38 }
39 
40 void Token::setHasLeadingSpace(bool space)
41 {
42  if (space)
44  else
46 }
47 
48 void Token::setExpansionDisabled(bool disable)
49 {
50  if (disable)
52  else
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 {
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
bool equals(const Token &other) const
Definition: Token.cpp:24
GLint GLenum GLsizei GLsizei GLsizei GLint GLenum GLenum type
Definition: gl2ext.h:845
GLuint start
Definition: glew.h:1239
GLint location
Definition: gl2ext.h:1164
void reset()
Definition: Token.cpp:16
png_sPLT_entryp pp
Definition: pngrutil.c:1375
void setAtStartOfLine(bool start)
Definition: Token.cpp:32
unsigned int flags
Definition: Token.h:88
#define assert(x)
Definition: SDL_malloc.c:1234
bool uValue(unsigned int *value) const
Definition: Token.cpp:62
void setExpansionDisabled(bool disable)
Definition: Token.cpp:48
SourceLocation location
Definition: Token.h:89
bool iValue(int *value) const
Definition: Token.cpp:56
bool hasLeadingSpace() const
Definition: Token.h:75
std::ostream & operator<<(std::ostream &out, const Token &token)
Definition: Token.cpp:74
EGLSurface EGLint void ** value
Definition: eglext.h:301
std::string text
Definition: Token.h:90
bool numeric_lex_int(const std::string &str, IntType *value)
Definition: numeric_lex.h:37
GLenum GLsizei GLsizei GLsizei GLsizei GLbitfield flags
Definition: glew.h:2767
bool fValue(float *value) const
Definition: Token.cpp:68
void setHasLeadingSpace(bool space)
Definition: Token.cpp:40
bool numeric_lex_float(const std::string &str, FloatType *value)
Definition: numeric_lex.h:49
int type
Definition: Token.h:87