diff options
author | Dimitri van Heesch <dimitri@stack.nl> | 1999-12-15 19:25:10 (GMT) |
---|---|---|
committer | Dimitri van Heesch <dimitri@stack.nl> | 1999-12-15 19:25:10 (GMT) |
commit | 322885a8700a209812bf5a94205260c9bef6ac1f (patch) | |
tree | cc1cd70cf5761ddf72ff114c0b65576c3f4c1d2a /src/cppvalue.cpp | |
parent | 361bf7915be13b5c74688e33c427aea30641814c (diff) | |
download | Doxygen-322885a8700a209812bf5a94205260c9bef6ac1f.zip Doxygen-322885a8700a209812bf5a94205260c9bef6ac1f.tar.gz Doxygen-322885a8700a209812bf5a94205260c9bef6ac1f.tar.bz2 |
initial version
Diffstat (limited to 'src/cppvalue.cpp')
-rw-r--r-- | src/cppvalue.cpp | 85 |
1 files changed, 85 insertions, 0 deletions
diff --git a/src/cppvalue.cpp b/src/cppvalue.cpp new file mode 100644 index 0000000..ab2a1d4 --- /dev/null +++ b/src/cppvalue.cpp @@ -0,0 +1,85 @@ +/****************************************************************************** + * + * $Id$ + * + * + * Copyright (C) 1997-1999 by Dimitri van Heesch. + * + * Permission to use, copy, modify, and distribute this software and its + * documentation under the terms of the GNU General Public License is hereby + * granted. No representations are made about the suitability of this software + * for any purpose. It is provided "as is" without express or implied warranty. + * See the GNU General Public License for more details. + * + * All output generated with Doxygen is not covered by this license. + * + */ + +#include <stdlib.h> + +#include "cppvalue.h" +#include "constexp.h" + +CPPValue parseOctal() +{ + long val = 0; + for (const char *p = strToken.data(); *p != 0; p++) + { + if (*p >= '0' && *p <= '7') val = val * 8 + *p - '0'; + } + return CPPValue(val); +} + +CPPValue parseDecimal() +{ + long val = 0; + for (const char *p = strToken.data(); *p != 0; p++) + { + if (*p >= '0' && *p <= '9') val = val * 10 + *p - '0'; + } + return CPPValue(val); +} + +CPPValue parseHexadecimal() +{ + long val = 0; + for (const char *p = strToken.data(); *p != 0; p++) + { + if (*p >= '0' && *p <= '9') val = val * 16 + *p - '0'; + else if (*p >= 'a' && *p <= 'f') val = val * 16 + *p - 'a' + 10; + else if (*p >= 'A' && *p <= 'F') val = val * 16 + *p - 'A' + 10; + } + return CPPValue(val); +} + +CPPValue parseCharacter() // does not work for '\n' and the alike +{ + if (strToken[1]=='\\') + { + switch(strToken[2]) + { + case 'n': return CPPValue((long)'\n'); + case 't': return CPPValue((long)'\t'); + case 'v': return CPPValue((long)'\v'); + case 'b': return CPPValue((long)'\b'); + case 'r': return CPPValue((long)'\r'); + case 'f': return CPPValue((long)'\f'); + case 'a': return CPPValue((long)'\a'); + case '\\': return CPPValue((long)'\\'); + case '?': return CPPValue((long)'\?'); + case '\'': return CPPValue((long)'\''); + case '"': return CPPValue((long)'"'); + case '0': return parseOctal(); + case 'x': + case 'X': return parseHexadecimal(); + default: printf("Invalid escape sequence %s found!\n",strToken.data()); + return CPPValue(0L); + } + } + return CPPValue((long)strToken[1]); +} + +CPPValue parseFloat() +{ + return CPPValue(atof(strToken)); +} |