void CFParser :: parse(_ScriptReader& reader, TapeWriter& writer) { // if (_symbolMode) // reader.switchDFA(dfaSymbolic); ScriptLog log; TokenInfo token(this, &log); token.read(reader); size_t readerRollback = reader.Position(); //size_t outputRollback = compiler->Position(); size_t startId = mapRuleId("start"); if (token.state != dfaEOF) { if (!applyRule(startId, token, reader)) throw EParseError(token.column, token.row); if (token.state != dfaEOF) throw EParseError(token.column, token.row); } IdentifierTextReader logReader((ident_t)log.getBody()); CachedScriptReader scriptReader(&logReader); _baseParser->parse(scriptReader, writer); }
void CFParser :: parse(_ScriptReader& reader, MemoryDump* output) { if (_symbolMode) reader.switchDFA(dfaSymbolic); ScriptLog log; size_t startId = mapRuleId("start"); while (!reader.Eof()) { MemoryWriter writer(&_body); int presaved = writer.Position(); int trace = buildDerivationTree(reader, startId, writer); generateOutput(trace, reader, log); IdentifierTextReader logReader((const char*)log.getBody()); ScriptReader scriptReader(&logReader); _baseParser->parse(scriptReader, output); _body.trim(presaved); log.clear(); } }