be a bit more relaxed about allowing - in names (Fixes #1593)

deque
Marc Zinnschlag 11 years ago
parent 517b27e29a
commit 563c2e5730

@ -343,17 +343,13 @@ namespace Compiler
} }
else if (!(c=='"' && name.empty())) else if (!(c=='"' && name.empty()))
{ {
if (!(std::isalpha (c) || std::isdigit (c) || c=='_' || c=='`' || if (!isStringCharacter (c))
/// \todo add an option to disable the following hack. Also, find out who is
/// responsible for allowing it in the first place and meet up with that person in
/// a dark alley.
(c=='-' && !name.empty() && std::isalpha (mStream.peek()))))
{ {
putback (c); putback (c);
break; break;
} }
if (first && std::isdigit (c)) if (first && (std::isdigit (c) || c=='`' || c=='-'))
error = true; error = true;
} }
@ -499,6 +495,17 @@ namespace Compiler
return true; return true;
} }
bool Scanner::isStringCharacter (char c, bool lookAhead)
{
return std::isalpha (c) || std::isdigit (c) || c=='_' ||
/// \todo disable this when doing more stricter compiling
c=='`' ||
/// \todo disable this when doing more stricter compiling. Also, find out who is
/// responsible for allowing it in the first place and meet up with that person in
/// a dark alley.
(c=='-' && (!lookAhead || isStringCharacter (mStream.peek(), false)));
}
bool Scanner::isWhitespace (char c) bool Scanner::isWhitespace (char c)
{ {
return c==' ' || c=='\t'; return c==' ' || c=='\t';

@ -92,6 +92,8 @@ namespace Compiler
bool scanSpecial (char c, Parser& parser, bool& cont); bool scanSpecial (char c, Parser& parser, bool& cont);
bool isStringCharacter (char c, bool lookAhead = true);
static bool isWhitespace (char c); static bool isWhitespace (char c);
public: public:

Loading…
Cancel
Save