Lexer: Removed expermental code, didn't help

This commit is contained in:
Paul Beckingham 2015-07-04 15:03:28 -04:00
parent d8e48e1e2b
commit 1836ac29e2
3 changed files with 9 additions and 357 deletions

View file

@ -38,14 +38,6 @@ static const unsigned int uuid_min_length = 8;
std::string Lexer::dateFormat = "";
bool Lexer::isoEnabled = true;
////////////////////////////////////////////////////////////////////////////////
Lexer::Lexer ()
: _text ("")
, _cursor (0)
, _eos (0)
{
}
////////////////////////////////////////////////////////////////////////////////
Lexer::Lexer (const std::string& text)
: _text (text)
@ -73,14 +65,14 @@ bool Lexer::token (std::string& token, Lexer::Type& type)
return false;
// The sequence is specific, and must follow these rules:
// - date < duration < uuid < identifier
// - uuid < hex < number
// - url < pair < identifier
// - hex < number
// - separator < tag < operator
// - path < substitution < pattern
// - set < number
// - word last
// - date < duration < uuid < identifier
// - uuid < hex < number
// - url < pair < identifier
// - hex < number
// - separator < tag < operator
// - path < substitution < pattern
// - set < number
// - word last
if (isString (token, type, '\'') ||
isString (token, type, '"') ||
isDate (token, type) ||
@ -105,35 +97,6 @@ bool Lexer::token (std::string& token, Lexer::Type& type)
return false;
}
////////////////////////////////////////////////////////////////////////////////
// Classify the whole token.
Lexer::Type Lexer::token (const std::string& token)
{
/*
if (isString (token, '\'')) return Lexer::Type:string;
else if (isString (token, '"')) return Lexer::Type:string;
else if (isDate (token)) return Lexer::Type:date;
else if (isDuration (token)) return Lexer::Type:duration;
else if (isURL (token)) return Lexer::Type:url;
else if (isPair (token)) return Lexer::Type:pair;
else if (isSet (token)) return Lexer::Type:set;
else if (isDOM (token)) return Lexer::Type:dom;
else if (isUUID (token)) return Lexer::Type:uuid;
else if (isHexNumber (token)) return Lexer::Type:hex;
else if (isNumber (token)) return Lexer::Type:number;
else if (isSeparator (token)) return Lexer::Type:separator;
else*/ if (isTag (token)) return Lexer::Type::tag;
/*
else if (isPath (token)) return Lexer::Type:path;
else if (isSubstitution (token)) return Lexer::Type:substitution;
else if (isPattern (token)) return Lexer::Type:pattern;
else if (isOperator (token)) return Lexer::Type:op;
else if (isIdentifier (token)) return Lexer::Type:identifier;
else if (isWord (token)) return Lexer::Type:word;
*/
return Lexer::Type::word;
}
////////////////////////////////////////////////////////////////////////////////
// This static method tokenizes the input and provides a vector of token/type
// results from a high-level lex.
@ -1257,143 +1220,4 @@ bool Lexer::isOneWord (const std::string& text)
return true;
}
/*
////////////////////////////////////////////////////////////////////////////////
bool Lexer::isString (const std::string& input)
{
return false;
}
////////////////////////////////////////////////////////////////////////////////
bool Lexer::isDate (const std::string& input)
{
return false;
}
////////////////////////////////////////////////////////////////////////////////
bool Lexer::isDuration (const std::string& input)
{
return false;
}
////////////////////////////////////////////////////////////////////////////////
bool Lexer::isUUID (const std::string& input)
{
return false;
}
////////////////////////////////////////////////////////////////////////////////
bool Lexer::isNumber (const std::string& input)
{
return false;
}
////////////////////////////////////////////////////////////////////////////////
bool Lexer::isHexNumber (const std::string& input)
{
return false;
}
////////////////////////////////////////////////////////////////////////////////
bool Lexer::isSeparator (const std::string& input)
{
return false;
}
////////////////////////////////////////////////////////////////////////////////
bool Lexer::isURL (const std::string& input)
{
return false;
}
////////////////////////////////////////////////////////////////////////////////
bool Lexer::isPair (const std::string& input)
{
return false;
}
////////////////////////////////////////////////////////////////////////////////
bool Lexer::isSet (const std::string& input)
{
return false;
}
*/
////////////////////////////////////////////////////////////////////////////////
bool Lexer::isTag (const std::string& input)
{
return (input[0] == '+' ||
input[0] == '-') &&
isIdentifierStart (input[0]) &&
input.length () > 1;
}
/*
////////////////////////////////////////////////////////////////////////////////
bool Lexer::isPath (const std::string& input)
{
return false;
}
////////////////////////////////////////////////////////////////////////////////
bool Lexer::isSubstitution (const std::string& input)
{
return false;
}
////////////////////////////////////////////////////////////////////////////////
bool Lexer::isPattern (const std::string& input)
{
return false;
}
////////////////////////////////////////////////////////////////////////////////
bool Lexer::isOperator (const std::string& input)
{
return false;
}
////////////////////////////////////////////////////////////////////////////////
bool Lexer::isDOM (const std::string& input)
{
return false;
}
////////////////////////////////////////////////////////////////////////////////
bool Lexer::isIdentifier (const std::string& input)
{
return false;
}
////////////////////////////////////////////////////////////////////////////////
bool Lexer::isWord (const std::string& input)
{
return false;
}
////////////////////////////////////////////////////////////////////////////////
bool Lexer::isContiguous (const std::string& input)
{
return false;
}
*/
////////////////////////////////////////////////////////////////////////////////

View file

@ -51,11 +51,9 @@ public:
dom, identifier, word,
date, duration };
Lexer ();
Lexer (const std::string&);
~Lexer ();
bool token (std::string&, Lexer::Type&);
Lexer::Type token (const std::string&);
static std::vector <std::pair <std::string, Lexer::Type>> tokens (const std::string&);
static std::vector <std::string> split (const std::string&);
static std::string typeToString (Lexer::Type);
@ -105,31 +103,6 @@ public:
bool isWord (std::string&, Lexer::Type&);
bool isContiguous (std::string&, Lexer::Type&);
// Token Classifiers.
/*
bool isString (const std::string&);
bool isDate (const std::string&);
bool isDuration (const std::string&);
bool isUUID (const std::string&);
bool isNumber (const std::string&);
bool isHexNumber (const std::string&);
bool isSeparator (const std::string&);
bool isURL (const std::string&);
bool isPair (const std::string&);
bool isSet (const std::string&);
*/
bool isTag (const std::string&);
/*
bool isPath (const std::string&);
bool isSubstitution (const std::string&);
bool isPattern (const std::string&);
bool isOperator (const std::string&);
bool isDOM (const std::string&);
bool isIdentifier (const std::string&);
bool isWord (const std::string&);
bool isContiguous (const std::string&);
*/
private:
std::string _text;
std::size_t _cursor;