#ifndef LEX_ANALYZER_HEADER
#define LEX_ANALYZER_HEADER

#include "String.h"
#include "Vector.h"
#include <cstdio>

class LexAnalyzer
{
public:		
	class Lexem
	{
	friend class LexAnalyzer;
	public:
		enum Type {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_fix, l_lesseq, l_moreeq, l_noteq, l_not, l_string, l_end};
	private:
		Type type;		
		String info;
		unsigned line;
	public:
		inline Type GetType() const {return type;}
		inline const String& GetInfo() const {return info;}
		inline unsigned GetLine() const {return 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, s_not, s_more, s_less, s_string};
	
private:
	unsigned line;
	unsigned pos;
	FILE *source;
	State state;	
	String buffer;
	
public:
	LexAnalyzer(FILE *source);
	~LexAnalyzer();
	
	Lexem GetNext();	
};

#endif
