X-Git-Url: http://git.tdb.fi/?p=libs%2Fdatafile.git;a=blobdiff_plain;f=source%2Ftextparser.cpp;h=f7c830d0030ebcf5428c3c0abf06c63ba043ce60;hp=78d2f1df6334b32dbf67a7871975deda4dafb0a4;hb=e26f7e98e5d8a5666192a43348b3ca7a35f6b860;hpb=d84673be1c2fe8bd32ddaa7877529855cad6daa0 diff --git a/source/textparser.cpp b/source/textparser.cpp index 78d2f1d..f7c830d 100644 --- a/source/textparser.cpp +++ b/source/textparser.cpp @@ -104,10 +104,10 @@ Statement TextParser::parse_statement(const Token *t) 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(); @@ -123,11 +123,13 @@ Token TextParser::parse_token() 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 { @@ -167,7 +169,7 @@ Token TextParser::parse_token() string buf; bool escape=false; - while(in) + while(in || state==INIT) { if(state!=INIT) c=in.get();