Token TextParser::parse_token()
{
int c=0;
- unsigned comment=0;
+ int comment=0;
// Skip over comments and whitespace
- while(in)
+ while(in && comment>=0)
{
c=in.get();
int next=in.peek();
else if(comment==3) // Skip the second character of block comment end
comment=0;
else if(!isspace(c) && !comment)
- break;
+ comment=-1;
}
- if(comment) // Didn't hit any non-whitespace
+ if(comment>0) // EOF while in comment
throw ParseError(src+": Unfinished comment at end of input", src, in.get_line_number());
+ else if(comment==0) // Didn't hit any non-whitespace
+ return Token(Token::SPECIAL, "");
enum ParseState
{
string buf;
bool escape=false;
- while(in)
+ while(in || state==INIT)
{
if(state!=INIT)
c=in.get();