﻿namespace InputReader.TokenFactory
{
    using global::InputReader.Tokens;

    public class EqualTokenFactory : TokenEater
    {
        public override bool CanEat(char digestable)
        {
            if (IsEmpty)
            {
                return digestable == '=';
            }

            switch (digestable)
            {
                case '>':
                    return Buffer == "=";

                default:
                    return false;
            }
        }

        protected override Token CreateToken(int linePos, int line)
        {
            switch (Buffer)
            {
                case "=>":
                    return new Token(TokenType.DoubleArrowRight, linePos, line);

                default:
                    return new Token(TokenType.Equal, linePos, line);
            }

        }
    }
}