schema_editor/comdel/parser/parse_context.h

42 lines
809 B
C
Raw Normal View History

2022-04-08 18:17:58 +00:00
#ifndef PARSE_CONTEXT_H
#define PARSE_CONTEXT_H
2022-03-29 19:31:45 +00:00
2022-05-27 06:18:17 +00:00
#include "source_error.h"
2022-03-29 19:31:45 +00:00
#include <string>
#include <vector>
class SourceFile {
std::string fileName;
std::string source;
std::vector<unsigned> lineOffsets;
public:
SourceFile(std::string fileName, std::string source);
2022-05-27 06:18:17 +00:00
const std::string &getFileName() const;
std::string getLine(unsigned line) const;
2022-03-29 19:31:45 +00:00
void addLineOffset(unsigned offset);
};
2022-05-27 06:18:17 +00:00
class ParseContext {
2022-03-29 19:31:45 +00:00
std::string applicationDir;
std::vector<SourceFile> fileMap;
public:
ParseContext();
2022-05-27 06:18:17 +00:00
unsigned addFile(const std::string &fileName, const std::string &source);
SourceFile &getFile(unsigned file);
2022-03-29 19:31:45 +00:00
2022-05-27 06:18:17 +00:00
void formatError(const SourceError &sourceError, std::ostream &stream, const std::string &errorOrWarning);
2022-03-29 19:31:45 +00:00
};
#endif // PARSECONTEXT_H