diff --git a/StaticAnalyser/Acorn/Tape.cpp b/StaticAnalyser/Acorn/Tape.cpp index cf6104025..62adde4ca 100644 --- a/StaticAnalyser/Acorn/Tape.cpp +++ b/StaticAnalyser/Acorn/Tape.cpp @@ -101,13 +101,20 @@ class Acorn1200BaudTapeParser: public StaticAnalyer::TapeParser= 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; } } diff --git a/StaticAnalyser/TapeParser.hpp b/StaticAnalyser/TapeParser.hpp index 7adc3c20c..581be2fab 100644 --- a/StaticAnalyser/TapeParser.hpp +++ b/StaticAnalyser/TapeParser.hpp @@ -83,7 +83,18 @@ template 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 &waves) = 0; std::vector _wave_queue;