{ '%', MACRO },
};
-DLLexer::DLLexer(std::istream& in) : ILexer(in)
+DLLexer::DLLexer(std::istream& in) : LLNLexer(in)
{
}
bool DLLexer::isWhiteSpace(void)
{
- return (current == ' ') ||
- (current == '\t') ||
- (current == '\r') ||
- (current == '\n');
+ return (lookahead(1) == ' ') ||
+ (lookahead(1) == '\t') ||
+ (lookahead(1) == '\r') ||
+ (lookahead(1) == '\n');
}
bool DLLexer::isLetter(void)
{
- return ((current >= 'a') && (current <= 'z')) ||
- ((current >= 'A') && (current <= 'Z'));
+ return ((lookahead(1) >= 'a') && (lookahead(1) <= 'z')) ||
+ ((lookahead(1) >= 'A') && (lookahead(1) <= 'Z'));
}
bool DLLexer::isDigit(void)
{
- return ((current >= '0') && (current <= '9'));
+ return ((lookahead(1) >= '0') && (lookahead(1) <= '9'));
}
bool DLLexer::isOperator(void)
{
- return ( (current == '=')
- || (current == '!')
- || (current == '<')
- || (current == '>')
- || (current == '|')
- || (current == '&')
- || (current == ':')
- || (current == '@'));
+ return ( (lookahead(1) == '=')
+ || (lookahead(1) == '!')
+ || (lookahead(1) == '<')
+ || (lookahead(1) == '>')
+ || (lookahead(1) == '|')
+ || (lookahead(1) == '&')
+ || (lookahead(1) == ':')
+ || (lookahead(1) == '@'));
}
bool DLLexer::isStringChar(void)
{
- return ( (current != '"')
- && (current != '\r')
- && (current != '\n'));
+ return ( (lookahead(1) != '"')
+ && (lookahead(1) != '\r')
+ && (lookahead(1) != '\n'));
}
Token DLLexer::next(void)
{
WS();
}
- else if(current == '#')
+ else if(lookahead(1) == '#')
{
COMMENT();
}
{
Number(ret,false);
}
- else if(current == '\'')
+ else if(lookahead(1) == '\'')
{
Char(ret);
}
- else if(current == '"')
+ else if(lookahead(1) == '"')
{
String(ret);
}
- else if(current == '$')
+ else if(lookahead(1) == '$')
{
Symbol(ret);
}
- else if(current == '-')
+ else if(lookahead(1) == '-')
{
consume();
if(isDigit())
{
consume();
}
- while( (current != '\n')
- && (current != EOF));
+ while( (lookahead(1) != '\n')
+ && (lookahead(1) != EOF));
}
ostringstream oss;
do
{
- oss << current;
+ oss << lookahead(1);
consume();
}
- while(isLetter() || isDigit() || current == '_');
+ while(isLetter() || isDigit() || lookahead(1) == '_');
tok = Token(ID, oss.str(), line, column);
}
oss << FloatingPoint(isNegative);
// Get teh exponent if we have one
- if ( current == 'e')
+ if ( lookahead(1) == 'e')
{
// consume the 'e'
- oss << current;
+ oss << lookahead(1);
consume();
- if(current == '-')
+ if(lookahead(1) == '-')
{
// Capture the sign
- oss << current;
+ oss << lookahead(1);
consume();
}
// Capture the integer part
do
{
- oss << current;
+ oss << lookahead(1);
consume();
}
while(isDigit());
// Capture the integer part
do
{
- oss << current;
+ oss << lookahead(1);
consume();
}
while(isDigit());
// Capture the decimal point if we have one
- if(current == '.')
+ if(lookahead(1) == '.')
{
Decimal(oss);
}
void DLLexer::Decimal(std::ostringstream& oss)
{
- oss << current;
+ oss << lookahead(1);
consume();
if(!isDigit())
do
{
- oss << current;
+ oss << lookahead(1);
consume();
}
while ( isDigit() );
ostringstream oss;
match('\'');
- if(current == '\\')
+ if(lookahead(1) == '\\')
{
oss << EscapeSequence();
}
else
{
- oss << current;
+ oss << lookahead(1);
consume();
}
match('\'');
match('"');
while( isStringChar() )
{
- if(current == '\\')
+ if(lookahead(1) == '\\')
{
oss << EscapeSequence();
}
else
{
- oss << current;
+ oss << lookahead(1);
consume();
}
}
match('$');
do
{
- oss << current;
+ oss << lookahead(1);
consume();
}
- while(isLetter() || isDigit() || current == '_');
+ while(isLetter() || isDigit() || lookahead(1) == '_');
tok = Token( SYMBOL, oss.str(), line, column );
}
{
for(int i = 0; i < NUM_SINGLE_CHAR_MATCHES; i++)
{
- if(current == Single_Character_Matches[i].match)
+ if(lookahead(1) == Single_Character_Matches[i].match)
{
consume();
tok = Token( Single_Character_Matches[i].type, line, column );
void DLLexer::MultiCharOp(Token& tok)
{
// save the current token so we can refer back to it
- char last = current;
+ char last = lookahead(1);
// remove the current token from the buffer so we cna see the next
consume();
if(last == '=')
{
- if(current == '=')
+ if(lookahead(1) == '=')
{
consume();
tok = Token(EQ, line, column);
}
else if(last == '!')
{
- if(current == '=')
+ if(lookahead(1) == '=')
{
consume();
tok = Token(NE, line, column);
}
else if(last == '<')
{
- if(current == '=')
+ if(lookahead(1) == '=')
{
consume();
tok = Token(LTE, line, column);
}
else if(last == '>')
{
- if(current == '=')
+ if(lookahead(1) == '=')
{
consume();
tok = Token(GTE, line, column);
}
else if(last == '|')
{
- if(current == '|')
+ if(lookahead(1) == '|')
{
consume();
tok = Token(OR, line, column);
tok = Token(PIPE, line, column);
}
}
- else if((last == '&') && (current == '&'))
+ else if((last == '&') && (lookahead(1) == '&'))
{
consume();
tok = Token(AND, line, column);
}
else if(last == ':')
{
- if(current == '=')
+ if(lookahead(1) == '=')
{
consume();
tok = Token(DEFN, line, column);
}
else if(last == '@')
{
- if(current == '=')
+ if(lookahead(1) == '=')
{
consume();
tok = Token(IMPORT, line, column);
{
ostringstream oss;
- oss << current;
+ oss << lookahead(1);
consume();
- if ( current == 'x' )
+ if ( lookahead(1) == 'x' )
{
- oss << current;
+ oss << lookahead(1);
consume();
for(int i = 0; i < 2; i++)
{
- if ( ((current >= '0') || (current <= '9')) ||
- ((current >= 'a') || (current <= 'f')) ||
- ((current >= 'A') || (current <= 'F')))
+ if ( ((lookahead(1) >= '0') || (lookahead(1) <= '9')) ||
+ ((lookahead(1) >= 'a') || (lookahead(1) <= 'f')) ||
+ ((lookahead(1) >= 'A') || (lookahead(1) <= 'F')))
{
- oss << current;
+ oss << lookahead(1);
consume();
}
else
}
else
{
- oss << current;
+ oss << lookahead(1);
consume();
}
return oss.str();