- fbx: fix infinite recursion when parsing nested Scope's.
parent
c9d9fcdfd1
commit
ecd79b3cc3
|
@ -90,16 +90,19 @@ Element::Element(Parser& parser)
|
||||||
if (n->Type() == TokenType_OPEN_BRACKET) {
|
if (n->Type() == TokenType_OPEN_BRACKET) {
|
||||||
compound.reset(new Scope(parser));
|
compound.reset(new Scope(parser));
|
||||||
|
|
||||||
// compound scopes must appear at the end of an element, so TOK_CLOSE_BRACKET should be next
|
// current token should be a TOK_CLOSE_BRACKET
|
||||||
n = parser.CurrentToken();
|
n = parser.CurrentToken();
|
||||||
ai_assert(n);
|
ai_assert(n);
|
||||||
|
|
||||||
if (n->Type() != TokenType_CLOSE_BRACKET) {
|
if (n->Type() != TokenType_CLOSE_BRACKET) {
|
||||||
ParseError("expected closing bracket",n);
|
ParseError("expected closing bracket",n);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
parser.AdvanceToNextToken();
|
||||||
|
return;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
while(n->Type() != TokenType_KEY);
|
while(n->Type() != TokenType_KEY && n->Type() != TokenType_CLOSE_BRACKET);
|
||||||
}
|
}
|
||||||
|
|
||||||
// ------------------------------------------------------------------------------------------------
|
// ------------------------------------------------------------------------------------------------
|
||||||
|
@ -107,7 +110,7 @@ Element::~Element()
|
||||||
{
|
{
|
||||||
std::for_each(tokens.begin(),tokens.end(),Util::delete_fun<Token>());
|
std::for_each(tokens.begin(),tokens.end(),Util::delete_fun<Token>());
|
||||||
}
|
}
|
||||||
|
#include <Windows.h>
|
||||||
// ------------------------------------------------------------------------------------------------
|
// ------------------------------------------------------------------------------------------------
|
||||||
Scope::Scope(Parser& parser,bool topLevel)
|
Scope::Scope(Parser& parser,bool topLevel)
|
||||||
{
|
{
|
||||||
|
@ -123,14 +126,16 @@ Scope::Scope(Parser& parser,bool topLevel)
|
||||||
ParseError("unexpected end of file",NULL);
|
ParseError("unexpected end of file",NULL);
|
||||||
}
|
}
|
||||||
|
|
||||||
do {
|
// note: empty scopes are allowed
|
||||||
|
while(n->Type() != TokenType_CLOSE_BRACKET) {
|
||||||
if (n->Type() != TokenType_KEY) {
|
if (n->Type() != TokenType_KEY) {
|
||||||
ParseError("unexpected token, expected TOK_KEY",n);
|
ParseError("unexpected token, expected TOK_KEY",n);
|
||||||
}
|
}
|
||||||
|
|
||||||
elements.insert(ElementMap::value_type(n->StringContents(),new_Element(parser)));
|
const std::string& str = n->StringContents();
|
||||||
|
elements.insert(ElementMap::value_type(str,new_Element(parser)));
|
||||||
|
|
||||||
// Element() should stop at the next Key (or Close) token
|
// Element() should stop at the next Key token (or right after a Close token)
|
||||||
n = parser.CurrentToken();
|
n = parser.CurrentToken();
|
||||||
if(n == NULL) {
|
if(n == NULL) {
|
||||||
if (topLevel) {
|
if (topLevel) {
|
||||||
|
@ -139,7 +144,6 @@ Scope::Scope(Parser& parser,bool topLevel)
|
||||||
ParseError("unexpected end of file",parser.LastToken());
|
ParseError("unexpected end of file",parser.LastToken());
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
while(n->Type() != TokenType_CLOSE_BRACKET);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
// ------------------------------------------------------------------------------------------------
|
// ------------------------------------------------------------------------------------------------
|
||||||
|
|
|
@ -90,17 +90,12 @@ public:
|
||||||
|
|
||||||
public:
|
public:
|
||||||
|
|
||||||
const std::string& Key() const {
|
|
||||||
return key;
|
|
||||||
}
|
|
||||||
|
|
||||||
const TokenList& Tokens() const {
|
const TokenList& Tokens() const {
|
||||||
return tokens;
|
return tokens;
|
||||||
}
|
}
|
||||||
|
|
||||||
private:
|
private:
|
||||||
|
|
||||||
std::string key;
|
|
||||||
TokenList tokens;
|
TokenList tokens;
|
||||||
boost::scoped_ptr<Scope> compound;
|
boost::scoped_ptr<Scope> compound;
|
||||||
};
|
};
|
||||||
|
|
Loading…
Reference in New Issue