Add Tests for ZCG cpp

This commit is contained in:
Jan
2021-02-10 18:03:50 +01:00
parent 31497d804c
commit f9ef7cc35b
102 changed files with 502 additions and 21 deletions

View File

@ -0,0 +1,46 @@
#include "HeaderFileReader.h"
#include <iostream>
#include "Parsing/Impl/CommentRemovingStreamProxy.h"
#include "Parsing/Impl/IncludingStreamProxy.h"
#include "Parsing/Impl/ParserFilesystemStream.h"
HeaderFileReader::HeaderFileReader(const ZoneCodeGeneratorArguments* args, std::string filename)
: m_args(args),
m_filename(std::move(filename))
{
}
bool HeaderFileReader::ReadHeaderFile(IDataRepository* repository) const
{
std::cout << "Reading header file: " << m_filename << std::endl;
ParserFilesystemStream stream(m_filename);
if(!stream.IsOpen())
{
std::cout << "Could not open header file" << std::endl;
return false;
}
IParserLineStream* lineStream = &stream;
IncludingStreamProxy includeProxy(lineStream);
lineStream = &includeProxy;
CommentRemovingStreamProxy commentProxy(lineStream);
lineStream = &commentProxy;
while(true)
{
auto line = lineStream->NextLine();
if (line.IsEof())
break;
std::cout << "Line " << line.m_filename << ":" << line.m_line_number << ": " << line.m_line << std::endl;
}
return true;
}