diff options
Diffstat (limited to 'cpp/src/Slice/Scanner.cpp')
-rw-r--r-- | cpp/src/Slice/Scanner.cpp | 145 |
1 files changed, 73 insertions, 72 deletions
diff --git a/cpp/src/Slice/Scanner.cpp b/cpp/src/Slice/Scanner.cpp index fc2fc290dac..27d362e04c9 100644 --- a/cpp/src/Slice/Scanner.cpp +++ b/cpp/src/Slice/Scanner.cpp @@ -564,7 +564,7 @@ char *slice_text; // // ********************************************************************** -#include <Slice/GrammarUtil.h> // Before Grammer.h, so that YYSTYPE is defined +#include <Slice/GrammarUtil.h> // Before Grammer.h, so that YYSTYPE is defined #include <Slice/Grammar.h> #include <IceUtil/InputUtil.h> @@ -607,7 +607,7 @@ char *slice_text; # define slice_wrap() 1 # endif # ifdef ICE_64 -# pragma error_messages(off,truncwarn) +# pragma error_messages(off,truncwarn) # endif #endif @@ -620,7 +620,7 @@ namespace Slice // // Definitions for the case-insensitive keyword-token map. // -typedef std::map<std::string, int, Slice::CICompare> StringTokenMap; +typedef std::map<std::string, int> StringTokenMap; static StringTokenMap keywordMap; void initScanner(); @@ -628,7 +628,7 @@ int checkKeyword(string&); } -#define YY_USER_INIT initScanner(); +#define YY_USER_INIT initScanner(); @@ -973,11 +973,11 @@ YY_RULE_SETUP int c; do { - c = yyinput(); - if(c == '\n') - { - unit->nextLine(); - } + c = yyinput(); + if(c == '\n') + { + unit->nextLine(); + } } while(c != '\n' && c != EOF); } @@ -991,38 +991,38 @@ YY_RULE_SETUP string comment = slice_text + 2; while(true) { - int c = yyinput(); - if(c == '\n') - { - comment += static_cast<char>(c); - unit->nextLine(); - } - else if(c == '*') - { - int next = yyinput(); - if(next == '/') - { - break; - } - else - { - comment += static_cast<char>(c); - unput(next); - } - } - else if(c == EOF) - { - unit->warning("EOF in comment"); - break; - } - else - { - comment += static_cast<char>(c); - } + int c = yyinput(); + if(c == '\n') + { + comment += static_cast<char>(c); + unit->nextLine(); + } + else if(c == '*') + { + int next = yyinput(); + if(next == '/') + { + break; + } + else + { + comment += static_cast<char>(c); + unput(next); + } + } + else if(c == EOF) + { + unit->warning("EOF in comment"); + break; + } + else + { + comment += static_cast<char>(c); + } } if(!comment.empty() && comment[0] == '*') { - unit->setComment(comment); + unit->setComment(comment); } } YY_BREAK @@ -1396,11 +1396,11 @@ YY_RULE_SETUP *yylvalp = itp; if(!IceUtilInternal::stringToInt64(string(slice_text), itp->v)) { - assert(itp->v != 0); - string msg = "integer constant `"; - msg += slice_text; - msg += "' out of range"; - unit->error(msg); + assert(itp->v != 0); + string msg = "integer constant `"; + msg += slice_text; + msg += "' out of range"; + unit->error(msg); } return ICE_INTEGER_LITERAL; } @@ -1418,22 +1418,22 @@ YY_RULE_SETUP char lastChar = literal[literal.size() - 1]; if(lastChar == 'f' || lastChar == 'F') { - literal = literal.substr(0, literal.size() - 1); // Clobber trailing 'f' or 'F' suffix + literal = literal.substr(0, literal.size() - 1); // Clobber trailing 'f' or 'F' suffix } ftp->v = strtod(literal.c_str(), 0); if((ftp->v == HUGE_VAL || ftp->v == -HUGE_VAL) && errno == ERANGE) { - string msg = "floating-point constant `"; - msg += slice_text; - msg += "' too large (overflow)"; - unit->error(msg); + string msg = "floating-point constant `"; + msg += slice_text; + msg += "' too large (overflow)"; + unit->error(msg); } else if(ftp->v == 0 && errno == ERANGE) { - string msg = "floating-point constant `"; - msg += slice_text; - msg += "' too small (underflow)"; - unit->error(msg); + string msg = "floating-point constant `"; + msg += slice_text; + msg += "' too small (underflow)"; + unit->error(msg); } return ICE_FLOATING_POINT_LITERAL; } @@ -1444,14 +1444,14 @@ YY_RULE_SETUP #line 561 "Scanner.l" { // Ignore white-space - + if(unit->currentLine() != 0) { BEGIN(MAINSCAN); } if(slice_text[0] == '\n') { - unit->nextLine(); + unit->nextLine(); } } YY_BREAK @@ -1460,7 +1460,7 @@ YY_RULE_SETUP #line 574 "Scanner.l" { // Ignore UTF-8 BOM, rule only active when parsing start of file. - + BEGIN(MAINSCAN); } YY_BREAK @@ -1471,14 +1471,14 @@ YY_RULE_SETUP BEGIN(MAINSCAN); if(slice_text[0] < 32 || slice_text[0] > 126) { - stringstream s; - s << "illegal input character: '\\"; - s.width(3); - s.fill('0'); - s << oct << static_cast<int>(static_cast<unsigned char>(slice_text[0])); - s << "'"; - unit->error(s.str()); - return BAD_CHAR; + stringstream s; + s << "illegal input character: '\\"; + s.width(3); + s.fill('0'); + s << oct << static_cast<int>(static_cast<unsigned char>(slice_text[0])); + s << "'"; + unit->error(s.str()); + return BAD_CHAR; } return slice_text[0]; } @@ -2531,6 +2531,7 @@ initScanner() keywordMap["true"] = ICE_TRUE; keywordMap["idempotent"] = ICE_IDEMPOTENT; keywordMap["optional"] = ICE_OPTIONAL; + keywordMap["Value"] = ICE_VALUE; } // @@ -2546,15 +2547,15 @@ checkKeyword(string& id) StringTokenMap::const_iterator pos = keywordMap.find(id); if(pos != keywordMap.end()) { - if(pos->first != id) - { - string msg; - msg = "illegal identifier: `" + id + "' differs from keyword `"; - msg += pos->first + "' only in capitalization"; - unit->error(msg); - id = pos->first; - } - return pos->second; + if(pos->first != id) + { + string msg; + msg = "illegal identifier: `" + id + "' differs from keyword `"; + msg += pos->first + "' only in capitalization"; + unit->error(msg); + id = pos->first; + } + return pos->second; } return ICE_IDENTIFIER; } |