2022-04-08 18:17:58 +00:00
|
|
|
#ifndef PARSE_CONTEXT_H
|
|
|
|
#define PARSE_CONTEXT_H
|
2022-03-29 19:31:45 +00:00
|
|
|
|
|
|
|
|
|
|
|
#include "sourceerror.h"
|
|
|
|
|
|
|
|
#include <string>
|
|
|
|
#include <vector>
|
|
|
|
|
|
|
|
|
|
|
|
class SourceFile {
|
|
|
|
std::string fileName;
|
|
|
|
std::string source;
|
|
|
|
std::vector<unsigned> lineOffsets;
|
|
|
|
|
|
|
|
public:
|
|
|
|
// qqq source je CIJELI comdel fajl,
|
|
|
|
// za inicijalizaciju source se koristi std::move, a možda treba biti referenca???
|
|
|
|
SourceFile(std::string fileName, std::string source);
|
|
|
|
|
|
|
|
const std::string& getFileName() const;
|
|
|
|
const std::string getLine(unsigned line) const;
|
|
|
|
void addLineOffset(unsigned offset);
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
|
|
class ParseContext
|
|
|
|
{
|
|
|
|
std::string applicationDir;
|
|
|
|
std::vector<SourceFile> fileMap;
|
|
|
|
|
|
|
|
public:
|
|
|
|
ParseContext();
|
|
|
|
|
|
|
|
unsigned addFile(const std::string& fileName, const std::string& source);
|
|
|
|
SourceFile& getFile(unsigned file);
|
|
|
|
|
|
|
|
void formatError(const SourceError &sourceError, std::ostream &stream, const std::string& ErrorOrWarning);
|
|
|
|
|
|
|
|
};
|
|
|
|
|
|
|
|
#endif // PARSECONTEXT_H
|