1 /******************************************************************************
3 * $Id: cppvalue.cpp,v 1.6 2001/03/19 19:27:40 root Exp $
6 * Copyright (C) 1997-2012 by Dimitri van Heesch.
8 * Permission to use, copy, modify, and distribute this software and its
9 * documentation under the terms of the GNU General Public License is hereby
10 * granted. No representations are made about the suitability of this software
11 * for any purpose. It is provided "as is" without express or implied warranty.
12 * See the GNU General Public License for more details.
14 * Documents produced by Doxygen are derivative works derived from the
15 * input used in their production; they are not affected by this license.
27 for (const char *p = g_strToken.data(); *p != 0; p++)
29 if (*p >= '0' && *p <= '7') val = val * 8 + *p - '0';
34 CPPValue parseDecimal()
37 for (const char *p = g_strToken.data(); *p != 0; p++)
39 if (*p >= '0' && *p <= '9') val = val * 10 + *p - '0';
44 CPPValue parseHexadecimal()
47 for (const char *p = g_strToken.data(); *p != 0; p++)
49 if (*p >= '0' && *p <= '9') val = val * 16 + *p - '0';
50 else if (*p >= 'a' && *p <= 'f') val = val * 16 + *p - 'a' + 10;
51 else if (*p >= 'A' && *p <= 'F') val = val * 16 + *p - 'A' + 10;
53 //printf("parseHexadecimal %s->%x\n",g_strToken.data(),val);
57 CPPValue parseCharacter() // does not work for '\n' and the alike
59 if (g_strToken[1]=='\\')
63 case 'n': return CPPValue((long)'\n');
64 case 't': return CPPValue((long)'\t');
65 case 'v': return CPPValue((long)'\v');
66 case 'b': return CPPValue((long)'\b');
67 case 'r': return CPPValue((long)'\r');
68 case 'f': return CPPValue((long)'\f');
69 case 'a': return CPPValue((long)'\a');
70 case '\\': return CPPValue((long)'\\');
71 case '?': return CPPValue((long)'\?');
72 case '\'': return CPPValue((long)'\'');
73 case '"': return CPPValue((long)'"');
74 case '0': // fall through
75 case '1': // fall through
76 case '2': // fall through
77 case '3': // fall through
78 case '4': // fall through
79 case '5': // fall through
80 case '6': // fall through
81 case '7': // fall through
84 case 'X': return parseHexadecimal();
85 default: printf("Invalid escape sequence %s found!\n",g_strToken.data());
89 return CPPValue((long)g_strToken[1]);
94 return CPPValue(atof(g_strToken));