|  | @@ -23,6 +23,10 @@ struct BfIterator
 | 
	
		
			
				|  |  |      std::istream& source;
 | 
	
		
			
				|  |  |      Instruction currentInst;
 | 
	
		
			
				|  |  |  
 | 
	
		
			
				|  |  | +    BfIterator(const BfIterator& other) = delete;
 | 
	
		
			
				|  |  | +    BfIterator(BfIterator&& other) :
 | 
	
		
			
				|  |  | +        source(other.source), currentInst(other.currentInst) {}
 | 
	
		
			
				|  |  | +
 | 
	
		
			
				|  |  |      inline BfIterator& operator++(void)
 | 
	
		
			
				|  |  |      {
 | 
	
		
			
				|  |  |          while (!source.eof()) {
 | 
	
	
		
			
				|  | @@ -41,10 +45,10 @@ struct BfIterator
 | 
	
		
			
				|  |  |                      currentInst = Instruction::RIGHT;
 | 
	
		
			
				|  |  |                      return *this;
 | 
	
		
			
				|  |  |                  case '.':
 | 
	
		
			
				|  |  | -                    currentInst = Instruction::PLUS;
 | 
	
		
			
				|  |  | +                    currentInst = Instruction::DOT;
 | 
	
		
			
				|  |  |                      return *this;
 | 
	
		
			
				|  |  |                  case ',':
 | 
	
		
			
				|  |  | -                    currentInst = Instruction::PLUS;
 | 
	
		
			
				|  |  | +                    currentInst = Instruction::COMMA;
 | 
	
		
			
				|  |  |                      return *this;
 | 
	
		
			
				|  |  |                  case '[':
 | 
	
		
			
				|  |  |                      currentInst = Instruction::LEFT_PARAN;
 | 
	
	
		
			
				|  | @@ -69,36 +73,69 @@ struct BfIterator
 | 
	
		
			
				|  |  |  };
 | 
	
		
			
				|  |  |  
 | 
	
		
			
				|  |  |  
 | 
	
		
			
				|  |  | -typename<template Dispatcher>
 | 
	
		
			
				|  |  | -struct LoopIterator
 | 
	
		
			
				|  |  | +class BlockIterator
 | 
	
		
			
				|  |  |  {
 | 
	
		
			
				|  |  | -    BfIterator it;
 | 
	
		
			
				|  |  | -    Dispatcher& d;
 | 
	
		
			
				|  |  | +    BfIterator& it;
 | 
	
		
			
				|  |  | +    // iterate, until special character
 | 
	
		
			
				|  |  |  
 | 
	
		
			
				|  |  | -    LoopIterator& operator++(void)
 | 
	
		
			
				|  |  | +    bool isSpecialCharacter(void)
 | 
	
		
			
				|  |  |      {
 | 
	
		
			
				|  |  | -        d(Block());
 | 
	
		
			
				|  |  | +        return *it == Instruction::LEFT_PARAN ||
 | 
	
		
			
				|  |  | +               *it == Instruction::LEFT_PARAN ||
 | 
	
		
			
				|  |  | +               *it == Instruction::COMMA ||
 | 
	
		
			
				|  |  | +               *it == Instruction::DOT;
 | 
	
		
			
				|  |  | +    }
 | 
	
		
			
				|  |  | +public:
 | 
	
		
			
				|  |  | +    BlockIterator& operator++(void)
 | 
	
		
			
				|  |  | +    {
 | 
	
		
			
				|  |  | +        if (!isSpecialCharacter())
 | 
	
		
			
				|  |  | +            it++;
 | 
	
		
			
				|  |  | +        return *this;
 | 
	
		
			
				|  |  |      }
 | 
	
		
			
				|  |  | -
 | 
	
		
			
				|  |  | -    // until ']'
 | 
	
		
			
				|  |  | -    //
 | 
	
		
			
				|  |  | -    // calls d.loop() and d.block()                                 
 | 
	
		
			
				|  |  |  };
 | 
	
		
			
				|  |  |  
 | 
	
		
			
				|  |  |  
 | 
	
		
			
				|  |  | -struct BlockIterator
 | 
	
		
			
				|  |  | +class BlockParser
 | 
	
		
			
				|  |  |  {
 | 
	
		
			
				|  |  | -    BfIterator it;
 | 
	
		
			
				|  |  | -    // iterate, until special character
 | 
	
		
			
				|  |  | +    BfIterator& begin;
 | 
	
		
			
				|  |  | +public:
 | 
	
		
			
				|  |  | +    inline BlockIterator begin(void) { return begin; }
 | 
	
		
			
				|  |  | +    inline BlockIterator& end(void) { return ; }
 | 
	
		
			
				|  |  |  };
 | 
	
		
			
				|  |  |  
 | 
	
		
			
				|  |  |  
 | 
	
		
			
				|  |  | -class BlockParser
 | 
	
		
			
				|  |  | +template<typename Visitor, typename Value>
 | 
	
		
			
				|  |  | +struct LoopIterator
 | 
	
		
			
				|  |  |  {
 | 
	
		
			
				|  |  | -public:
 | 
	
		
			
				|  |  | -    BfIterator 
 | 
	
		
			
				|  |  | -}
 | 
	
		
			
				|  |  | +    BfIterator& it;
 | 
	
		
			
				|  |  | +    Visitor& visitor;
 | 
	
		
			
				|  |  | +    Value value;
 | 
	
		
			
				|  |  | +
 | 
	
		
			
				|  |  | +    LoopIterator(const LoopIterator&) = delete;
 | 
	
		
			
				|  |  | +
 | 
	
		
			
				|  |  | +    LoopIterator& operator++(void)
 | 
	
		
			
				|  |  | +    {
 | 
	
		
			
				|  |  | +        if (*it == Instruction::RIGHT_PARAN)
 | 
	
		
			
				|  |  | +            return *this;
 | 
	
		
			
				|  |  | +        if (*it == Instruction::LEFT_PARAN) {
 | 
	
		
			
				|  |  | +            value = visitor(LoopParser(it))
 | 
	
		
			
				|  |  | +        }
 | 
	
		
			
				|  |  | +        else {
 | 
	
		
			
				|  |  | +            value = visitor(BlockParser(it));
 | 
	
		
			
				|  |  | +        }
 | 
	
		
			
				|  |  | +        return *this;
 | 
	
		
			
				|  |  | +    }
 | 
	
		
			
				|  |  | +
 | 
	
		
			
				|  |  | +
 | 
	
		
			
				|  |  | +    Value& operator * (void)
 | 
	
		
			
				|  |  | +    {
 | 
	
		
			
				|  |  | +        return value;
 | 
	
		
			
				|  |  | +    }
 | 
	
		
			
				|  |  |  
 | 
	
		
			
				|  |  | +    // until ']'
 | 
	
		
			
				|  |  | +    //
 | 
	
		
			
				|  |  | +    // calls d.loop() and d.block()                                 
 | 
	
		
			
				|  |  | +};
 | 
	
		
			
				|  |  |  
 | 
	
		
			
				|  |  |  
 | 
	
		
			
				|  |  |  #endif /* ALTPARSER_H */
 |