#pragma once
#ifndef INPUT_PARSER_H 
#define INPUT_PARSER_H

#include <istream>
#include <vector>
#include <string>

namespace lxs {
    struct DFA;
    struct ENFA; 


    /**
     * Used for parsing token rules
     */
    class InputParser {
        public:
            /**
             * parse the tokens rules read from `is` and return the minimized constructed dfa from those rules
             */
            static DFA parseInput(std::istream& is);
        private:
            /**
             * parse the lines and return pairs of (Token type, regex)
             */
            static std::vector<std::pair<int, std::pair<std::string,std::string> > > parseLines(std::istream &is);

            /**
             * Convert the lines from `parseLines` to ENFA's
             */
            static std::vector<ENFA> linesToEnfa(std::vector<std::pair<int, std::pair<std::string,std::string> > > &input);
    };
    
    /**
     * Used to throw errors when the inputfile was not valid
     */

    class InputParserException: public std::exception {
    public:
        InputParserException(std::string what);
        virtual const char* what() const throw();

    private:
        std::string m_what;
    };
}

#endif // INPUT_PARSER_H
