#ifndef LEX_ANALYZER_HEADER
#define LEX_ANALYZER_HEADER

#include <stdio.h>
#include "..\..\TheBot\String.h"
#include "..\..\TheBot\Vector.h"

class LexAnalyzer
{
public:
	enum LexemType {l_identifier, l_number, l_plus, l_minus, l_mul, l_div, l_mod, l_bopen, l_bclose,
		l_eopen, l_eclose, l_iopen, l_iclose, l_if, l_else, l_while, l_assign, l_var, l_or, l_and,
		l_more, l_less, l_eq, l_semi, l_end};
		
	struct Lexem
	{
		LexemType type;		
		String info;
		unsigned line;
	};
	
	class ParserError
	{
	private:
		unsigned line;
		unsigned pos;
		char c;
	public:
		ParserError(unsigned line, unsigned pos, char c) {this->line = line; this->pos = pos; this->c = c;}
		
		inline unsigned GetLine() const {return line;}
		inline unsigned GetPos() const {return pos;}
		inline char GetChar() const {return c;}
	};

private:
	enum State {s_init, s_number, s_identifier, s_eq};
	
private:
	unsigned line;
	unsigned pos;
	FILE* source;
	State state;	
	String buffer;
	
public:
	LexAnalyzer(FILE* source);
	~LexAnalyzer();
	
	Lexem GetNext();	
};

#endif