fix bug in turtle parser: deal with prefix in IRI

This commit is contained in:
bookug 2016-10-14 10:28:53 +08:00
parent 631776f57a
commit cc7accc97d
2 changed files with 20 additions and 9 deletions

View File

@ -360,6 +360,18 @@ TurtleParser::Lexer::Token TurtleParser::Lexer::next(std::string& token)
return Token_Eof;
}
//---------------------------------------------------------------------------
void TurtleParser::Lexer::readUntilSep(std::string& value)
{
value.resize(0);
char c;
while (read(c))
{
if (issep(c)) { unread(); break; }
value += c;
}
}
//---------------------------------------------------------------------------
TurtleParser::TurtleParser(istream& in)
: lexer(in),triplesReader(0),nextBlank(0)
// Constructor
@ -451,6 +463,10 @@ void TurtleParser::parseQualifiedName(const string& prefix,string& name)
parseError("unknown prefix '"+prefix+"'");
string expandedPrefix=prefixes[prefix];
lexer.readUntilSep(name);
name=expandedPrefix+name;
/*
Lexer::Token token=lexer.next(name);
if (isName(token)) {
name=expandedPrefix+name;
@ -458,6 +474,7 @@ void TurtleParser::parseQualifiedName(const string& prefix,string& name)
lexer.unget(token,name);
name=expandedPrefix;
}
*/
}
//---------------------------------------------------------------------------
void TurtleParser::parseBlank(std::string& entry)

View File

@ -94,11 +94,8 @@ class TurtleParser
/// Get the line
unsigned getLine() const { return line; }
void discardLine()
{
char c;
while (read(c) && c != '\n');
}
void readUntilSep(std::string& value);
void discardLine() { char c; while (read(c) && c!='\n'); }
};
/// A triple
struct Triple {
@ -157,10 +154,7 @@ class TurtleParser
/// Read the next triple
bool parse(std::string& subject,std::string& predicate,std::string& object,Type::Type_ID& objectType,std::string& objectSubType);
void discardLine()
{
lexer.discardLine();
}
void discardLine() { lexer.discardLine(); }
};
//---------------------------------------------------------------------------
#endif