1
0
mirror of https://github.com/TomHarte/CLK.git synced 2024-07-10 12:29:01 +00:00

Further documented interface, fixed a potential parsing blockage.

This commit is contained in:
Thomas Harte 2016-09-05 22:12:52 -04:00
parent 963e307d0c
commit cfe8251166
2 changed files with 24 additions and 6 deletions

View File

@ -101,13 +101,20 @@ class Acorn1200BaudTapeParser: public StaticAnalyer::TapeParser<WaveType, Symbol
return;
}
if( waves.size() >= 4 &&
waves[0] == WaveType::Short &&
waves[1] == WaveType::Short &&
waves[2] == WaveType::Short &&
waves[3] == WaveType::Short)
if(waves.size() >= 4)
{
push_symbol(SymbolType::One, 4);
// If this makes a 1, post it.
if( waves[0] == WaveType::Short &&
waves[1] == WaveType::Short &&
waves[2] == WaveType::Short &&
waves[3] == WaveType::Short)
{
push_symbol(SymbolType::One, 4);
return;
}
// Otherwise, eject at least one wave as all options are exhausted.
remove_waves(1);
return;
}
}

View File

@ -83,7 +83,18 @@ template <typename WaveType, typename SymbolType> class TapeParser {
}
private:
/*!
Should be implemented by subclasses. Consumes @c pulse. Is likely either to call @c push_wave
or to take no action.
*/
virtual void process_pulse(Storage::Tape::Tape::Pulse pulse) = 0;
/*!
Should be implemented by subclasses. Inspects @c waves for a potential new symbol. If one is
found should call @c push_symbol. May wish alternatively to call @c remove_waves to have entries
removed from the start of @c waves that cannot form a valid symbol. Need not do anything while
the waves at the start of @c waves may end up forming a symbol but the symbol is not yet complete.
*/
virtual void inspect_waves(const std::vector<WaveType> &waves) = 0;
std::vector<WaveType> _wave_queue;