43 lines
872 B
C++
43 lines
872 B
C++
#ifndef PARSE_CONTEXT_H
|
|
#define PARSE_CONTEXT_H
|
|
|
|
|
|
#include "source_error.h"
|
|
|
|
#include <string>
|
|
#include <vector>
|
|
|
|
/*** Represent source file */
|
|
class SourceFile {
|
|
std::string fileName;
|
|
std::string source;
|
|
std::vector<unsigned> lineOffsets;
|
|
|
|
public:
|
|
SourceFile(std::string fileName, std::string source);
|
|
|
|
const std::string &getFileName() const;
|
|
|
|
std::string getLine(unsigned line) const;
|
|
|
|
void addLineOffset(unsigned offset);
|
|
};
|
|
|
|
/*** Represent parsing context */
|
|
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
|