mirror of
https://github.com/carbon-language/carbon-lang.git
synced 2026-10-05 22:02:55 +01:00
Replace int lines with file-associated SourceLocations (#779)
Most interesting changes should be ast/source_location.h and syntax/parse_and_lex_context.h
This commit is contained in:
@@ -18,11 +18,15 @@ class ParseAndLexContext {
|
||||
public:
|
||||
// Creates an instance analyzing the given input file.
|
||||
ParseAndLexContext(const std::string& input_file)
|
||||
: input_file_name(input_file) {}
|
||||
: input_file_name(global_arena->New<std::string>(input_file)) {}
|
||||
|
||||
// Writes a syntax error diagnostic, containing message, for the input file at
|
||||
// the given line, to standard error.
|
||||
auto PrintDiagnostic(const std::string& message, int line_number) -> void;
|
||||
// Writes a syntax error diagnostic containing message to standard error.
|
||||
auto PrintDiagnostic(const std::string& message) -> void;
|
||||
|
||||
auto SourceLoc() -> SourceLocation {
|
||||
return SourceLocation(input_file_name,
|
||||
static_cast<int>(current_token_position.begin.line));
|
||||
}
|
||||
|
||||
// The source range of the token being (or just) lex'd.
|
||||
location current_token_position;
|
||||
@@ -30,7 +34,7 @@ class ParseAndLexContext {
|
||||
private:
|
||||
// A path to the file processed, relative to the current working directory
|
||||
// when *this is called.
|
||||
const std::string input_file_name;
|
||||
Ptr<const std::string> input_file_name;
|
||||
};
|
||||
|
||||
} // namespace Carbon
|
||||
|
||||
Reference in New Issue
Block a user