diff options
author | Eugene Sandulenko | 2016-06-27 18:51:47 +0200 |
---|---|---|
committer | Eugene Sandulenko | 2016-08-03 23:40:36 +0200 |
commit | 840487d2ef1aa50748e526bd70dc2b7a3677d7eb (patch) | |
tree | 594b8bc83878f5991d07750da7dec2d8b2261c66 /engines/director/lingo/lingo.cpp | |
parent | d440a73a41bb0d1dd6df22013a8df9b6b596600e (diff) | |
download | scummvm-rg350-840487d2ef1aa50748e526bd70dc2b7a3677d7eb.tar.gz scummvm-rg350-840487d2ef1aa50748e526bd70dc2b7a3677d7eb.tar.bz2 scummvm-rg350-840487d2ef1aa50748e526bd70dc2b7a3677d7eb.zip |
DIRECTOR: Lingo: Parse macro definitions reliably
Diffstat (limited to 'engines/director/lingo/lingo.cpp')
-rw-r--r-- | engines/director/lingo/lingo.cpp | 27 |
1 files changed, 25 insertions, 2 deletions
diff --git a/engines/director/lingo/lingo.cpp b/engines/director/lingo/lingo.cpp index b65fd81d9a..0ecd6893eb 100644 --- a/engines/director/lingo/lingo.cpp +++ b/engines/director/lingo/lingo.cpp @@ -122,9 +122,32 @@ void Lingo::addCode(Common::String code, ScriptType type, uint16 id) { _currentScriptType = type; _scripts[type][id] = _currentScript; - parse(code.c_str()); + // macros have conflicting grammar. Thus we ease life for the parser. + if (code.contains("\nmacro ")) { + const char *begin = strstr(code.c_str(), "\nmacro ") + 1; + char *end; + bool first = true; - code1(STOP); + while ((end = strstr(begin, "\nmacro "))) { + if (first) { + begin = code.c_str(); + first = false; + } + Common::String chunk(begin, end); + + parse(chunk.c_str()); + + _currentScript->clear(); + + begin = end + 1; + } + + parse(begin); + } else { + parse(code.c_str()); + + code1(STOP); + } Common::hexdump((byte *)&_currentScript->front(), _currentScript->size() * sizeof(inst)); } |