1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65
|
/*
This file is a part of KMC software distributed under GNU GPL 3 licence.
The homepage of the KMC project is http://sun.aei.polsl.pl/kmc
Authors: Marek Kokot
Version: 3.2.4
Date : 2024-02-09
*/
#ifndef _PARSER_H
#define _PARSER_H
#include "defs.h"
#include "expression_node.h"
#include "tokenizer.h"
#include "output_parser.h"
#include <iostream>
#include <fstream>
#include <regex>
#include <map>
#include <list>
//************************************************************************************************************
// CParser - parser for complex operations
//************************************************************************************************************
class CParser
{
std::ifstream file;
uint32 line_no;
std::regex input_line_pattern;
std::regex output_line_pattern;
std::regex empty_line_pattern;
std::map<std::string, uint32> input;
void parseInputLine(const std::string& line);
void parseOutputLine(const std::string& line);
void parseOtuputParamsLine();
bool nextLine(std::string& line);
CConfig& config;
CTokenizer tokenizer;
std::list<Token> tokens;
public:
CParser(const std::string& src);
void ParseInputs();
void ParseOutput();
template<unsigned SIZE>
CExpressionNode<SIZE>* GetExpressionRoot();
};
//************************************************************************************************************
template<unsigned SIZE> CExpressionNode<SIZE>* CParser::GetExpressionRoot()
{
COutputParser<SIZE> out_parser(tokens, input);
return out_parser.Parse();
}
#endif
// ***** EOF
|