summaryrefslogtreecommitdiff
path: root/cpp/src/Slice/Scanner.cpp
diff options
context:
space:
mode:
authorMark Spruiell <mes@zeroc.com>2010-05-24 09:51:55 -0700
committerMark Spruiell <mes@zeroc.com>2010-05-24 09:51:55 -0700
commit487dd39e3483217cccb80f46e7a65674c7f6c05a (patch)
tree75fd3df459df63c2646a4e20c7a32f1ff05a09dd /cpp/src/Slice/Scanner.cpp
parentbug 4623 - missing doc comments (diff)
downloadice-487dd39e3483217cccb80f46e7a65674c7f6c05a.tar.bz2
ice-487dd39e3483217cccb80f46e7a65674c7f6c05a.tar.xz
ice-487dd39e3483217cccb80f46e7a65674c7f6c05a.zip
bug 4752 - allow underscores in Slice identifiers
Diffstat (limited to 'cpp/src/Slice/Scanner.cpp')
-rw-r--r--cpp/src/Slice/Scanner.cpp91
1 files changed, 36 insertions, 55 deletions
diff --git a/cpp/src/Slice/Scanner.cpp b/cpp/src/Slice/Scanner.cpp
index 9b74ab2241e..3300be94dc6 100644
--- a/cpp/src/Slice/Scanner.cpp
+++ b/cpp/src/Slice/Scanner.cpp
@@ -17,7 +17,7 @@
#define yytext slice_text
#line 19 "lex.yy.c"
-/* A lexical scanner generated by flex */
+/* A lexical scanner generated by flex*/
/* Scanner skeleton version:
* $Header: /home/daffy/u0/vern/flex/RCS/flex.skl,v 2.91 96/09/10 16:58:48 vern Exp $
@@ -153,6 +153,15 @@ extern FILE *yyin, *yyout;
#define unput(c) yyunput( c, yytext_ptr )
+/* Some routines like yy_flex_realloc() are emitted as static but are
+ not called by all lexers. This generates warnings in some compilers,
+ notably GCC. Arrange to suppress these. */
+#ifdef __GNUC__
+#define YY_MAY_BE_UNUSED __attribute__((unused))
+#else
+#define YY_MAY_BE_UNUSED
+#endif
+
/* The following is because we cannot portably get our hands on size_t
* (without autoconf's help, which isn't available because we want
* flex-generated scanners to compile on their own).
@@ -259,7 +268,7 @@ YY_BUFFER_STATE yy_scan_string YY_PROTO(( yyconst char *yy_str ));
YY_BUFFER_STATE yy_scan_bytes YY_PROTO(( yyconst char *bytes, int len ));
static void *yy_flex_alloc YY_PROTO(( yy_size_t ));
-static void *yy_flex_realloc YY_PROTO(( void *, yy_size_t ));
+static void *yy_flex_realloc YY_PROTO(( void *, yy_size_t )) YY_MAY_BE_UNUSED;
static void yy_flex_free YY_PROTO(( void * ));
#define yy_new_buffer yy_create_buffer
@@ -499,7 +508,6 @@ typedef std::map<std::string, int, Slice::CICompare> StringTokenMap;
static StringTokenMap keywordMap;
void initScanner();
-void checkIdentifier(const string&);
int checkKeyword(string&);
}
@@ -511,7 +519,7 @@ int checkKeyword(string&);
#define MAINSCAN 2
-#line 514 "lex.yy.c"
+#line 522 "lex.yy.c"
/* Macros after this point can all be overridden by user definitions in
* section 1.
@@ -665,10 +673,10 @@ YY_DECL
register char *yy_cp = NULL, *yy_bp = NULL;
register int yy_act;
-#line 68 "Scanner.l"
+#line 67 "Scanner.l"
-#line 671 "lex.yy.c"
+#line 679 "lex.yy.c"
if ( yy_init )
{
@@ -757,7 +765,7 @@ case 1:
yy_c_buf_p = yy_cp -= 1;
YY_DO_BEFORE_ACTION; /* set up yytext again */
YY_RULE_SETUP
-#line 70 "Scanner.l"
+#line 69 "Scanner.l"
{
if(unit->scanPosition(yytext))
{
@@ -770,7 +778,7 @@ case 2:
yy_c_buf_p = yy_cp -= 1;
YY_DO_BEFORE_ACTION; /* set up yytext again */
YY_RULE_SETUP
-#line 77 "Scanner.l"
+#line 76 "Scanner.l"
{
if(unit->scanPosition(yytext))
{
@@ -783,7 +791,7 @@ case 3:
yy_c_buf_p = yy_cp -= 1;
YY_DO_BEFORE_ACTION; /* set up yytext again */
YY_RULE_SETUP
-#line 84 "Scanner.l"
+#line 83 "Scanner.l"
{
if(unit->scanPosition(yytext))
{
@@ -796,7 +804,7 @@ case 4:
yy_c_buf_p = yy_cp -= 1;
YY_DO_BEFORE_ACTION; /* set up yytext again */
YY_RULE_SETUP
-#line 91 "Scanner.l"
+#line 90 "Scanner.l"
{
if(unit->scanPosition(yytext))
{
@@ -806,7 +814,7 @@ YY_RULE_SETUP
YY_BREAK
case 5:
YY_RULE_SETUP
-#line 98 "Scanner.l"
+#line 97 "Scanner.l"
{
// C++-style comment
BEGIN(MAINSCAN);
@@ -824,7 +832,7 @@ YY_RULE_SETUP
YY_BREAK
case 6:
YY_RULE_SETUP
-#line 113 "Scanner.l"
+#line 112 "Scanner.l"
{
// C-style comment
BEGIN(MAINSCAN);
@@ -868,7 +876,7 @@ YY_RULE_SETUP
YY_BREAK
case 7:
YY_RULE_SETUP
-#line 154 "Scanner.l"
+#line 153 "Scanner.l"
{
BEGIN(MAINSCAN);
return ICE_SCOPE_DELIMITER;
@@ -876,7 +884,7 @@ YY_RULE_SETUP
YY_BREAK
case 8:
YY_RULE_SETUP
-#line 159 "Scanner.l"
+#line 158 "Scanner.l"
{
BEGIN(MAINSCAN);
return ICE_METADATA_OPEN;
@@ -884,7 +892,7 @@ YY_RULE_SETUP
YY_BREAK
case 9:
YY_RULE_SETUP
-#line 164 "Scanner.l"
+#line 163 "Scanner.l"
{
BEGIN(MAINSCAN);
return ICE_METADATA_CLOSE;
@@ -892,7 +900,7 @@ YY_RULE_SETUP
YY_BREAK
case 10:
YY_RULE_SETUP
-#line 169 "Scanner.l"
+#line 168 "Scanner.l"
{
BEGIN(MAINSCAN);
return ICE_GLOBAL_METADATA_OPEN;
@@ -900,7 +908,7 @@ YY_RULE_SETUP
YY_BREAK
case 11:
YY_RULE_SETUP
-#line 174 "Scanner.l"
+#line 173 "Scanner.l"
{
BEGIN(MAINSCAN);
return ICE_GLOBAL_METADATA_CLOSE;
@@ -908,14 +916,13 @@ YY_RULE_SETUP
YY_BREAK
case 12:
YY_RULE_SETUP
-#line 179 "Scanner.l"
+#line 178 "Scanner.l"
{
BEGIN(MAINSCAN);
StringTokPtr ident = new StringTok;
ident->v = *yytext == '\\' ? yytext + 1 : yytext;
ident->v.erase(ident->v.find_first_of(" \t\v\n\r\f("));
*yylvalp = ident;
- checkIdentifier(ident->v);
if(*yytext == '\\')
{
return ICE_IDENT_OP;
@@ -925,19 +932,18 @@ YY_RULE_SETUP
YY_BREAK
case 13:
YY_RULE_SETUP
-#line 193 "Scanner.l"
+#line 191 "Scanner.l"
{
BEGIN(MAINSCAN);
StringTokPtr ident = new StringTok;
ident->v = *yytext == '\\' ? yytext + 1 : yytext;
*yylvalp = ident;
- checkIdentifier(ident->v);
return *yytext == '\\' ? ICE_IDENTIFIER : checkKeyword(ident->v);
}
YY_BREAK
case 14:
YY_RULE_SETUP
-#line 202 "Scanner.l"
+#line 199 "Scanner.l"
{
BEGIN(MAINSCAN);
StringTokPtr str = new StringTok;
@@ -1101,7 +1107,7 @@ YY_RULE_SETUP
YY_BREAK
case 15:
YY_RULE_SETUP
-#line 363 "Scanner.l"
+#line 360 "Scanner.l"
{
BEGIN(MAINSCAN);
IntegerTokPtr itp = new IntegerTok;
@@ -1120,7 +1126,7 @@ YY_RULE_SETUP
YY_BREAK
case 16:
YY_RULE_SETUP
-#line 379 "Scanner.l"
+#line 376 "Scanner.l"
{
BEGIN(MAINSCAN);
errno = 0;
@@ -1153,7 +1159,7 @@ YY_RULE_SETUP
YY_BREAK
case 17:
YY_RULE_SETUP
-#line 409 "Scanner.l"
+#line 406 "Scanner.l"
{
// Ignore white-space
@@ -1169,7 +1175,7 @@ YY_RULE_SETUP
YY_BREAK
case 18:
YY_RULE_SETUP
-#line 422 "Scanner.l"
+#line 419 "Scanner.l"
{
// Ignore UTF-8 BOM, rule only active when parsing start of file.
@@ -1178,7 +1184,7 @@ YY_RULE_SETUP
YY_BREAK
case 19:
YY_RULE_SETUP
-#line 428 "Scanner.l"
+#line 425 "Scanner.l"
{
BEGIN(MAINSCAN);
if(yytext[0] < 32 || yytext[0] > 126)
@@ -1197,10 +1203,10 @@ YY_RULE_SETUP
YY_BREAK
case 20:
YY_RULE_SETUP
-#line 444 "Scanner.l"
+#line 441 "Scanner.l"
ECHO;
YY_BREAK
-#line 1203 "lex.yy.c"
+#line 1209 "lex.yy.c"
case YY_STATE_EOF(INITIAL):
case YY_STATE_EOF(BOMSCAN):
case YY_STATE_EOF(MAINSCAN):
@@ -2086,7 +2092,7 @@ int main()
return 0;
}
#endif
-#line 444 "Scanner.l"
+#line 441 "Scanner.l"
namespace Slice {
@@ -2129,31 +2135,6 @@ initScanner()
}
//
-// Check if an identifier is well-formed.
-//
-
-void
-checkIdentifier(const string& id)
-{
- if(id.find('_') != string::npos)
- {
- unit->error("illegal underscore in identifier `" + id + "'");
- }
-
- //
- // Weed out identifiers with reserved suffixes.
- //
- static const string suffixBlacklist[] = { "Helper", "Holder", "Prx", "Ptr" };
- for(size_t i = 0; i < sizeof(suffixBlacklist) / sizeof(*suffixBlacklist); ++i)
- {
- if(id.find(suffixBlacklist[i], id.size() - suffixBlacklist[i].size()) != string::npos)
- {
- unit->error("illegal identifier `" + id + "': `" + suffixBlacklist[i] + "' suffix is reserved");
- }
- }
-}
-
-//
// Check if an identifier looks like a keyword.
// If the identifier is a keyword, return the
// corresponding keyword token; otherwise, return